Fix LoraWan config change detection

This commit is contained in:
Theo Arends 2025-05-25 16:39:30 +02:00
parent 559209ee14
commit fe596c680d
2 changed files with 13 additions and 0 deletions

View File

@ -161,6 +161,16 @@ void LoraWanDeleteData(void) {
UfsJsonSettingsDelete(key); // Use defaults UfsJsonSettingsDelete(key); // Use defaults
} }
} }
uint32_t LoraWanGetCfgCrc(void) {
uint32_t crc32 = 0;
for (uint32_t n = 0; n < Lora->nodes; n++) {
if (Lora->settings.end_node[n]->AppKey[0] > 0) { // Only save used slots
crc32 += GetCfgCrc32((uint8_t*)Lora->settings.end_node[n], sizeof(LoraEndNode_t));
}
}
return crc32;
}
#endif // USE_UFILESYS #endif // USE_UFILESYS
/*********************************************************************************************/ /*********************************************************************************************/

View File

@ -176,6 +176,9 @@ void LoraSettingsSave(void) {
// Called from FUNC_SAVE_SETTINGS every SaveData second and at restart // Called from FUNC_SAVE_SETTINGS every SaveData second and at restart
#ifdef USE_UFILESYS #ifdef USE_UFILESYS
uint32_t crc32 = GetCfgCrc32((uint8_t*)&Lora->settings +4, sizeof(LoraSettings_t) -4); // Skip crc32 uint32_t crc32 = GetCfgCrc32((uint8_t*)&Lora->settings +4, sizeof(LoraSettings_t) -4); // Skip crc32
#ifdef USE_LORAWAN_BRIDGE
crc32 += LoraWanGetCfgCrc();
#endif // USE_LORAWAN_BRIDGE
if (crc32 != Lora->settings.crc32) { if (crc32 != Lora->settings.crc32) {
Lora->settings.crc32 = crc32; Lora->settings.crc32 = crc32;
if (LoraSaveData()) { if (LoraSaveData()) {