Case 1
Tests, a fix and a feature for an open-source ESP32 MQTT bridge
- ESP32
- Bluetooth LE
- MQTT
- Native tests
- Public
- Original project
- Bluetti_ESP32_Bridge by Mario Lukas
- Licence
- GPL-3.0, public fork
- Size
- About 3,100 lines of C++, no tests
- Changes
- 3, each verified on its own
An open-source ESP32 program that connects portable power stations to an MQTT broker over Bluetooth LE. About 3,100 lines of C++, no tests. Original project: Bluetti_ESP32_Bridge by Mario Lukas, GPL-3.0. Our work is in a public fork, and the fix and the feature are offered upstream as pull requests.
What we delivered, as three separate changes, each verified on its own:
- Test suite
A first native test suite. Host-side tests for the reply field parsers and the frame CRC: 14 cases, run under address and undefined-behaviour sanitizers. The suite also surfaced an undefined-behaviour shift in the version parser, recorded for a later fix.
- Fix
A fix. A command arriving on an MQTT topic the firmware does not handle still queued a Bluetooth write, built from uninitialised values. We reproduced it in a test that failed first; the firmware now logs the topic and sends nothing. Flash cost: 92 bytes.
- Feature
A feature. Every Bluetooth LE reply is now checked (length and CRC-16/MODBUS) before use; short or corrupt replies are logged and dropped. The same change fixed a one-byte buffer overrun in the field copy. 25 native cases, 13 of 14 mutants caught. Open: the reply layout is not yet confirmed on a real station.