fix: four real firmware defects found in adversarial review
rd03e.c: RD03E_FRAME_LEN was 5 but the frame's own documented layout (header + gesture + distance_lo + distance_hi + footer[2]) is 6 bytes. The footer check read buf[i+3], colliding with the distance high byte at that same index — so every frame that validated at all was forced to have distance_cm = lo | 0x5500 (~218m) regardless of what the sensor reported. Distance readings were garbage 100% of the time, not intermittently. mems_mic.c: i2s_del_channel() was missing on 2 of 3 init failure paths, leaking the channel handle. bmp280.c: the I2C bus/device handles leaked on 4 of 5 init failure paths; added a fail label that releases both. app_main.c: sensors now init before Wi-Fi bring-up, matching the rationale sensor_driver.h already documents (a hanging sensor bus must not be able to block network bring-up). rtlsdr_experimental.c: rtlsdr_exp_stop() waited 500ms before usb_host_uninstall(), but the daemon task blocks up to 1000ms inside usb_host_lib_handle_events() before re-checking its running flag — the delay must exceed that or teardown races a live daemon task. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,13 +8,15 @@
|
||||
// correctly" is where the verification stops. See README.md's "What's
|
||||
// verified vs. not" section before treating any of this as field-tested.
|
||||
//
|
||||
// Boot sequence: bring up Wi-Fi station mode (device_config.h credentials),
|
||||
// wait (briefly, non-fatally) for an initial connection, initialize every
|
||||
// registered sensor driver, then hand off to the telemetry task, which
|
||||
// periodically samples the sensor registry and POSTs the results to the
|
||||
// backend. Wi-Fi reconnection and per-cycle "are we online" checks happen
|
||||
// independently after this, so a boot-time Wi-Fi hiccup doesn't wedge the
|
||||
// device -- it just starts reporting once the connection comes up.
|
||||
// Boot sequence: initialize every registered sensor driver first (so a
|
||||
// slow/hanging sensor bus can't block network bring-up -- see
|
||||
// sensor_driver.h), then bring up Wi-Fi station mode (device_config.h
|
||||
// credentials), wait (briefly, non-fatally) for an initial connection, and
|
||||
// hand off to the telemetry task, which periodically samples the sensor
|
||||
// registry and POSTs the results to the backend. Wi-Fi reconnection and
|
||||
// per-cycle "are we online" checks happen independently after this, so a
|
||||
// boot-time Wi-Fi hiccup doesn't wedge the device -- it just starts
|
||||
// reporting once the connection comes up.
|
||||
|
||||
#include "wifi_manager.h"
|
||||
#include "sensor_registry.h"
|
||||
@@ -34,6 +36,8 @@ static const char *TAG = "app_main";
|
||||
void app_main(void) {
|
||||
ESP_LOGI(TAG, "Quantumancy sensor node starting");
|
||||
|
||||
sensor_registry_init_all();
|
||||
|
||||
ESP_ERROR_CHECK(wifi_manager_start());
|
||||
|
||||
esp_err_t err = wifi_manager_wait_connected(pdMS_TO_TICKS(BOOT_WIFI_WAIT_MS));
|
||||
@@ -44,7 +48,6 @@ void app_main(void) {
|
||||
"wifi_manager will keep retrying in the background", BOOT_WIFI_WAIT_MS);
|
||||
}
|
||||
|
||||
sensor_registry_init_all();
|
||||
telemetry_client_start_task();
|
||||
|
||||
ESP_LOGI(TAG, "startup complete, telemetry task running");
|
||||
|
||||
Reference in New Issue
Block a user