Robust contacts - backup first before saving and fallback to backup file#1447
Robust contacts - backup first before saving and fallback to backup file#1447weebl2000 wants to merge 3 commits into
Conversation
3dd2cef to
ad26168
Compare
9778b43 to
06dc6f5
Compare
|
I think what actually caused the contacts to miss in the first place was the nodeinfo files that were written regardless of auto-add contacts. |
c16b3be to
8266d35
Compare
ff716be to
97822b2
Compare
97822b2 to
ac41da2
Compare
ac41da2 to
e4c480b
Compare
|
Hey, I'm working on something similar for the repeater - however as far as I know the rename is atomic - thus there is no need to create a .bak file in my eyes. |
e4c480b to
29e0fd1
Compare
|
This fixes a real and reproducible data loss path. Confirmed on a Seeed Xiao S3 WIO (ESP32-S3), env The current I implemented the same atomic tmp + rename pattern independently and it stops the wipe: Contacts now survive the reboot. The extra |
d3ab801 to
16e98d9
Compare
… + minor Changes vs dev_plus: - meshcore-dev#1727 hardware-CAD redesign: cad_enabled pref (slot 293), 'cad on/off' CLI cmd, RSSI interference (int.thresh) + separate hardware-CAD gate in RadioLibWrappers. DEVIATION (per request): cad_enabled defaults to 1 (CAD ENABLED) on repeater/room/sensor; companion getCADEnabled() returns true. companion getInterferenceThreshold() aligned to PR (0; RSSI int.thresh disabled until currentRSSI() is fixed). Fixed a merge-dup of performChannelScan() decl. - meshcore-dev#2001: 'af' getter ftoa -> ftoa3 - meshcore-dev#1896: ESP32 RTC fallback seed literal -> RTC_TIME_MIN - meshcore-dev#1925: rak11200 P_LORA_DIO_1 via platformio build flag (not header #define) No-ops (verified already-aligned in dev_plus, or intentionally absent): meshcore-dev#1677 AEAD, meshcore-dev#1686 short-sleeps (=> meshcore-dev#1347 subset), meshcore-dev#2674 be-more-patient(+backoff), meshcore-dev#1447 robust-contacts (absent), meshcore-dev#2537 fix-serial-bursts (absent).
The fs->remove("/contacts3.bak") before the rename sequence creates a
vulnerability window: if power is lost right after removing the backup
but before the rename completes, both the backup and primary file could
be lost. The remove is unnecessary since rename() on both SPIFFS and
LittleFS replaces the target if it already exists.
16e98d9 to
a576855
Compare
Problem: Contacts sometimes partially disappear on Heltec v4 and Heltec Wireless Tracker v1.2. This is likely caused by power loss or reset during a direct overwrite of the contacts file.
Solution: Atomic-style write pattern for
saveContacts:/contacts3.tmp)/contacts3→/contacts3.bak/contacts3.tmp→/contacts3/contacts3.bak(no longer needed until next save)If the write fails mid-save, the
.tmpfile is removed and the original contacts file is left untouched.On load, if
/contacts3is missing or empty,loadContactsfalls back to/contacts3.bakautomatically. This covers the edge case where power is lost between steps 3 and 4.Platform guard: Only enabled on devices with sufficient flash for the temporary file (~2x contacts storage during save). Disabled on NRF52 unless
EXTRAFSorQSPIFLASHis defined.Build firmware: Build from this branch