MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / FlashC6_H2

Function FlashC6_H2

ESP32_AP-Flasher/src/espflasher.cpp:206–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204}
205
206bool FlashC6_H2(const char *RepoUrl) {
207 String JsonFilename = "/firmware_" SHORT_CHIP_NAME ".json" ;
208 bool Ret = false;
209 bool bLoaderInit = false;
210 bool bDownload = strlen(RepoUrl) > 0;
211 int retry;
212 JsonDocument jsonDoc;
213
214 LOG("%s#%d: ",__FUNCTION__,__LINE__); util::printHeap();
215
216 do {
217 if(bDownload) {
218 String FileUrl = RepoUrl + JsonFilename;
219 if(!downloadAndWriteBinary(JsonFilename, FileUrl.c_str())) {
220 LOG("%s#%d: ",__FUNCTION__,__LINE__); util::printHeap();
221 break;
222 }
223 }
224
225 File readfile = contentFS->open(JsonFilename, "r");
226 if(!readfile) {
227 wsSerial("load " + JsonFilename + ": Failed to open file");
228 return true;
229 }
230 DeserializationError jsonError = deserializeJson(jsonDoc, readfile);
231
232 if(jsonError) {
233 wsSerial(String("json error parsing") + JsonFilename);
234 break;
235 }
236
237 if(!bDownload) {
238 Ret = true;
239 break;
240 }
241
242 JsonArray jsonArray = jsonDoc.as<JsonArray>();
243 for(JsonObject obj : jsonArray) {
244 String filename = "/" + obj["filename"].as<String>();
245 String binaryUrl = RepoUrl + filename;
246
247 for(retry = 0; retry < 10; retry++) {
248 if(downloadAndWriteBinary(filename, binaryUrl.c_str())) {
249 break;
250 }
251 wsSerial("Retry " + String(retry));
252 if(retry < 9) {
253 delay(1000);
254 }
255 }
256 if(retry == 10) {
257 break;
258 }
259 }
260 if(retry < 10) {
261 Ret = true;
262 }
263 } while(false);

Callers 1

C6firmwareUpdateTaskFunction · 0.85

Calls 13

strlenFunction · 0.85
printHeapFunction · 0.85
downloadAndWriteBinaryFunction · 0.85
wsSerialFunction · 0.85
openMethod · 0.80
printfMethod · 0.80
printlnMethod · 0.80
connect_to_targetFunction · 0.70
flash_binaryFunction · 0.70
delayFunction · 0.50
loader_port_esp32_initFunction · 0.50
esp_loader_get_targetFunction · 0.50

Tested by

no test coverage detected