Repository navigation
Hotfix release
v0.2.1 shipped with a regression that crashed ESP8266 boards (Xtensa LX106) on the first basic data frame parsed in loop(). Symptom reported by users: the sketch boots, sends the first MQTT/serial message, then resets before the second loop cycle completes.
Root cause
parse_data_frame_() read three uint16_t fields with *(uint16_t*)(&radar_data_frame_[N]) at offsets 9, 12 and 15. Offsets 9 and 15 are odd, which is double-UB:
- Strict-aliasing violation (
uint8_t[]read viauint16_t*). - Unaligned 16-bit load. ESP8266 (Xtensa LX106) has no hardware handler and faults the CPU. ESP32 (LX6) silently emulated the load via its unaligned-access exception simulator, hiding the bug.
Fix
Replaced the three casts with memcpy(&dst, &buf[N], sizeof(uint16_t)). GCC compiles this into a single unaligned half-word load on architectures that support it (ESP32 / ARM Cortex-M3+ / x86) and into byte loads on those that don't (ESP8266 / AVR) — one portable form, zero performance cost. LD2410 payload is little-endian on all supported Arduino targets, so no byte-swap is needed.
Verification
- Host parser unit tests: 13/13 PASS.
- ESP32 + LD2410C 10-minute stress test on real hardware: 67M frames parsed, 0 reboots, heap stable at 331 176 B.
What's Changed
- fix(parser): use memcpy for 16-bit reads to prevent ESP8266 unaligned-load crash (#47)
- chore(release): bump version to 0.2.2 for Library Manager pickup
Full Changelog: v0.2.1...v0.2.2