Add runtime BMA456 tap config with NVS persistence and goTool UI.

Expose multitap parameters over UART/ESP-NOW (like deadzone), store per node in NVS, and allow get/set from CLI, REST, and the dashboard without poll-overwrite while editing.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
simon
2026-09-26 13:07:13 +02:00
co-authored by Cursor
parent f006f8b912
commit d7441cb85f
32 changed files with 1859 additions and 150 deletions
+47
View File
@@ -389,6 +389,48 @@ static void handle_accel_deadzone(const uint8_t *master_mac,
}
}
static void handle_tap_config(const uint8_t *master_mac,
const alox_EspNowTapConfig *msg) {
uint32_t my_id = esp_now_core_own_mac()[5];
if (msg->client_id != 0 && msg->client_id != my_id) {
return;
}
if (s_joined && !esp_now_core_mac_equal(master_mac, s_master_mac)) {
return;
}
bma456_tap_config_t cfg = {
.tap_sens_thres = (uint16_t)msg->tap_sens_thres,
.max_gest_dur = (uint16_t)msg->max_gest_dur,
.tap_shock_dur = (uint16_t)msg->tap_shock_dur,
.quite_time_after_gest = (uint16_t)msg->quite_time_after_gest,
.wait_for_timeout = (uint16_t)msg->wait_for_timeout,
.axis_sel = (uint16_t)msg->axis_sel,
.enable_single = msg->enable_single,
.enable_double = msg->enable_double,
.enable_triple = msg->enable_triple,
};
char mac_str[18];
esp_now_core_mac_to_str(master_mac, mac_str, sizeof(mac_str));
ESP_LOGI(TAG,
"tap config from master %s: sens=%u id=%lu (sensor %s)", mac_str,
(unsigned)cfg.tap_sens_thres, (unsigned long)my_id,
bma456_is_ready() ? "ok" : "not installed");
if (!bma456_tap_config_valid(&cfg)) {
ESP_LOGW(TAG, "invalid tap config from master; ignored");
return;
}
if (bma456_set_tap_config(&cfg) != ESP_OK) {
ESP_LOGW(TAG, "tap config apply failed");
return;
}
if (pod_settings_save_tap_config(&cfg) != ESP_OK) {
ESP_LOGW(TAG, "tap config applied but not saved to NVS");
}
}
static void handle_discover(const uint8_t *sender_mac,
const alox_EspNowDiscover *discover) {
if (discover->network != esp_now_core_network()) {
@@ -577,6 +619,11 @@ void esp_now_slave_on_recv(const esp_now_recv_info_t *info, const uint8_t *data,
handle_accel_deadzone(info->src_addr, &msg.payload.accel_deadzone);
}
break;
case alox_EspNowMessage_tap_config_tag:
if (from_joined_master(info->src_addr)) {
handle_tap_config(info->src_addr, &msg.payload.tap_config);
}
break;
case alox_EspNowMessage_accel_stream_tag:
if (from_joined_master(info->src_addr)) {
handle_accel_stream(info->src_addr, &msg.payload.accel_stream);