Skip to content

Commit

Permalink
Fix Lora watchdog
Browse files Browse the repository at this point in the history
- Update file JSON settings demo
  • Loading branch information
arendst committed Mar 20, 2024
1 parent 46fae91 commit c18ed34
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
3 changes: 2 additions & 1 deletion lib/lib_rf/LoRa/src/LoRa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ int LoRaClass::endPacket(bool async)
if (!async) {
// wait for TX done
while ((readRegister(REG_IRQ_FLAGS) & IRQ_TX_DONE_MASK) == 0) {
yield();
// yield();
delay(0); // Prevent watchdog crashes
}
// clear IRQ's
writeRegister(REG_IRQ_FLAGS, IRQ_TX_DONE_MASK);
Expand Down
28 changes: 1 addition & 27 deletions tasmota/tasmota_xdrv_driver/xdrv_122_file_json_settings_demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@

#define DRV_DEMO_MAX_DRV_TEXT 16

const uint16_t DRV_DEMO_VERSION = 0x0105; // Latest driver version (See settings deltas below)

// Global structure containing driver saved variables
struct {
uint32_t crc32; // To detect file changes
uint16_t version; // To detect driver function changes
char drv_text[DRV_DEMO_MAX_DRV_TEXT][10];
} DrvDemoSettings;

Expand All @@ -65,7 +62,6 @@ bool DrvDemoLoadData(void) {
if (!root) { return false; }

DrvDemoSettings.crc32 = root.getUInt(PSTR("Crc"), DrvDemoSettings.crc32);
DrvDemoSettings.version = root.getUInt(PSTR("Version"), DrvDemoSettings.version);
JsonParserArray arr = root[PSTR("Text")];
if (arr) {
for (uint32_t i = 0; i < DRV_DEMO_MAX_DRV_TEXT; i++) {
Expand All @@ -80,10 +76,8 @@ bool DrvDemoLoadData(void) {
bool DrvDemoSaveData(void) {
Response_P(PSTR("{\"" XDRV_122_KEY "\":{"
"\"Crc\":%u,"
"\"Version\":%u,"
"\"Text\":["),
DrvDemoSettings.crc32,
DrvDemoSettings.version);
DrvDemoSettings.crc32);
for (uint32_t i = 0; i < DRV_DEMO_MAX_DRV_TEXT; i++) {
ResponseAppend_P(PSTR("%s\"%s\""),
(i)?",":"",
Expand All @@ -109,7 +103,6 @@ void DrvDemoSettingsLoad(bool erase) {
AddLog(LOG_LEVEL_INFO, PSTR("DRV: " D_USE_DEFAULTS));

memset(&DrvDemoSettings, 0x00, sizeof(DrvDemoSettings));
DrvDemoSettings.version = DRV_DEMO_VERSION;
// Init any other parameter in struct DrvDemoSettings
snprintf_P(DrvDemoSettings.drv_text[0], sizeof(DrvDemoSettings.drv_text[0]), PSTR("Azalea"));

Expand All @@ -123,25 +116,6 @@ void DrvDemoSettingsLoad(bool erase) {
DrvDemoDeleteData();
}
else if (DrvDemoLoadData()) {
if (DrvDemoSettings.version != DRV_DEMO_VERSION) { // Fix version dependent changes

// *** Start fix possible setting deltas ***
if (DrvDemoSettings.version < 0x0103) {
AddLog(LOG_LEVEL_INFO, PSTR("CFG: Update oldest version restore"));

snprintf_P(DrvDemoSettings.drv_text[1], sizeof(DrvDemoSettings.drv_text[1]), PSTR("Begonia"));
}
if (DrvDemoSettings.version < 0x0104) {
AddLog(LOG_LEVEL_INFO, PSTR("CFG: Update old version restore"));

}

// *** End setting deltas ***

// Set current version and save settings
DrvDemoSettings.version = DRV_DEMO_VERSION;
DrvDemoSettingsSave();
}
AddLog(LOG_LEVEL_INFO, PSTR("CFG: Demo loaded from file"));
}
else {
Expand Down

0 comments on commit c18ed34

Please sign in to comment.