| 599 | } |
| 600 | |
| 601 | bool doAPUpdate(uint8_t type) { |
| 602 | // this function expects the tag to be already flashed with some version of the OpenEpaperLink Firmware, and that it correctly reported its type |
| 603 | class flasher *f = new flasher(); |
| 604 | if (!f->connectTag(AP_PROCESS_PORT)) { |
| 605 | Serial.printf("Sorry, failed to connect to this tag...\r\n"); |
| 606 | delete f; |
| 607 | return false; |
| 608 | } |
| 609 | |
| 610 | f->readInfoBlock(); |
| 611 | if (f->getInfoBlockMD5() && f->findTagByMD5()) { |
| 612 | // header (MD5) was correctly set. We'll use the type set there, instead of the provided 'type' in the argument |
| 613 | type = f->tagtype; |
| 614 | } else { |
| 615 | f->readInfoBlock(); |
| 616 | // Couldn't recognize the firmware, maybe it was already used for OpenEPaperLink? |
| 617 | if (!f->getInfoBlockMac()) { |
| 618 | // infoblock mac was incorrectly configured, we skipped it in an earlier version. We'll consider it lost, and overwrite it with the wifi mac. |
| 619 | f->getMacFromWiFi(); |
| 620 | } |
| 621 | // we'll try to update the MD5, searching for it by type. |
| 622 | f->findTagByType(type); |
| 623 | f->writeInfoBlock(); |
| 624 | } |
| 625 | bool res = f->writeFlashFromPack("/AP_FW_Pack.bin", f->tagtype); |
| 626 | #ifdef HAS_RGB_LED |
| 627 | if (res) addFadeColor(CRGB::Green); |
| 628 | if (!res) addFadeColor(CRGB::Red); |
| 629 | #endif |
| 630 | if (res) f->zbs->reset(); |
| 631 | delete f; |
| 632 | return res; |
| 633 | } |
| 634 | #endif |
| 635 | |
| 636 | void flashCountDown(uint8_t c) { |
no test coverage detected