| 448 | } |
| 449 | |
| 450 | bool 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 | |
| 481 | bool flasher::readBlock(uint16_t offset, uint8_t *data, uint16_t len, bool infopage) { |
| 482 | if (infopage) { |
no test coverage detected