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

Method writeFlashFromPack

ESP32_AP-Flasher/src/flasher.cpp:450–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

448}
449
450bool flasher::writeFlashFromPack(String filename, uint8_t type) {
451 JsonDocument doc;
452 fs::File readfile = contentFS->open(filename, "r");
453 DeserializationError err = deserializeJson(doc, readfile);
454 if (!err) {
455 for (JsonObject elem : doc.as<JsonArray>()) {
456 if (elem["type"] != nullptr) {
457 uint8_t jtype = elem["type"];
458 if (jtype == type) {
459 const char *name = elem["name"];
460 Seriallog.print("Flashing from FW pack: ");
461 Seriallog.println(name);
462
463 uint32_t offset = elem["offset"];
464 uint16_t length = elem["length"];
465 readfile.seek(offset);
466 bool result = writeFlashFromPackOffset(&readfile, length);
467 readfile.close();
468 return result;
469 }
470 }
471 }
472 Seriallog.print("Failed to find this tag's type in the FW pack database.\r\n");
473 } else {
474 Seriallog.println(err.c_str());
475 Seriallog.print("Failed to read json header from FW pack\r\n");
476 }
477 readfile.close();
478 return false;
479}
480
481bool flasher::readBlock(uint16_t offset, uint8_t *data, uint16_t len, bool infopage) {
482 if (infopage) {

Callers 5

doAPFlashFunction · 0.45
doAPUpdateFunction · 0.45
doTagFlashFunction · 0.45
autoFlashFunction · 0.45
webFlasherTaskFunction · 0.45

Calls 4

openMethod · 0.80
printlnMethod · 0.80
closeMethod · 0.80
printMethod · 0.45

Tested by

no test coverage detected