Persist accelerometer deadzone in NVS across reboots.
Each node saves its local deadzone on UART or ESP-NOW set; pod_settings loads and applies it after BMA456 init. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+5
-12
@@ -3,6 +3,7 @@
|
||||
#include "esp_now_comm.h"
|
||||
#include "led_ring.h"
|
||||
#include "ota_espnow.h"
|
||||
#include "pod_settings.h"
|
||||
#include "esp_now_proto.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_event.h"
|
||||
@@ -13,7 +14,6 @@
|
||||
#include "esp_wifi.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/idf_additions.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "ota_uart.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -399,6 +399,10 @@ static void handle_slave_accel_deadzone(const uint8_t *master_mac,
|
||||
bma456_is_ready() ? "ok" : "not installed");
|
||||
|
||||
bma456_set_accel_deadzone(cfg->deadzone);
|
||||
if (pod_settings_save_accel_deadzone(cfg->deadzone) != ESP_OK) {
|
||||
ESP_LOGW(TAG, "slave deadzone %lu applied but not saved to NVS",
|
||||
(unsigned long)cfg->deadzone);
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_client_presence(const alox_EspNowSlavePresence *presence,
|
||||
@@ -607,17 +611,6 @@ static void master_discover_task(void *param) {
|
||||
}
|
||||
|
||||
static esp_err_t init_wifi_stack(uint8_t channel) {
|
||||
esp_err_t err;
|
||||
|
||||
err = nvs_flash_init();
|
||||
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
err = nvs_flash_init();
|
||||
}
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user