MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / SendFileCredential

Method SendFileCredential

src/Networking/ESP8266WiFi/WiFiInterface.cpp:1155–1186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1153}
1154
1155int32_t WiFiInterface::SendFileCredential(GCodeBuffer &gb, size_t credIndex) noexcept
1156{
1157 static_assert(MaxCredentialChunkSize <= sizeof(bufferOut->data));
1158
1159 StringRef fileName(reinterpret_cast<char *_ecv_array>(&(bufferOut->data)), MaxCredentialChunkSize);
1160 gb.GetQuotedString(fileName);
1161
1162 FileStore *_ecv_null const cert = platform.OpenSysFile(fileName.c_str(), OpenMode::read);
1163
1164 // Send the contents of the file with a null terminator appended at the end. The authentication
1165 // fails without the null terminator.
1166 int32_t rslt = ResponseEmpty;
1167
1168 for(size_t total = 0, sz = 0; rslt == ResponseEmpty && total <= cert->Length(); total += sz)
1169 {
1170 rslt = ResponseUnknownError;
1171
1172 memset(bufferOut->data, 0, sizeof(bufferOut->data));
1173 sz = cert->Read(bufferOut->data, MaxCredentialChunkSize);
1174
1175 if (sz < MaxCredentialChunkSize)
1176 {
1177 bufferOut->data[sz] = 0;
1178 sz++;
1179 }
1180
1181 rslt = SendCredential(credIndex, bufferOut->data, sz);
1182 }
1183
1184 cert->Close();
1185 return rslt;
1186}
1187
1188GCodeResult WiFiInterface::HandleWiFiCode(int mcode, GCodeBuffer &gb, const StringRef& reply, OutputBuffer *_ecv_null & longReply) THROWS(GCodeException)
1189{

Callers

nothing calls this directly

Calls 3

LengthMethod · 0.45
ReadMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected