Merge pull request #11842 from s-hadinger/zigbee_esp32_read_prev_conf

Zigbee Fix loading previous file
This commit is contained in:
Theo Arends 2021-04-22 18:02:48 +02:00 committed by GitHub
commit 199ce169b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -290,6 +290,14 @@ bool loadZigbeeDevices(void) {
if (!f.valid() && dfsp) { if (!f.valid() && dfsp) {
file = dfsp->open(TASM_FILE_ZIGBEE, "r"); file = dfsp->open(TASM_FILE_ZIGBEE, "r");
if (file) { if (file) {
uint32_t signature = 0x0000;
file.read((uint8_t*)&signature, 4);
if (signature == ZIGB_NAME2) {
// skip another 4 bytes
file.read((uint8_t*)&signature, 4);
} else {
file.seek(0); // seek back to beginning of file
}
f.init(&file); f.init(&file);
storage_class = PSTR("File System"); storage_class = PSTR("File System");
} }