Enhance buzzer detection logic to group intermittent matches with a 500 ms quiet tail, updating relevant configurations and documentation.

This commit is contained in:
2026-10-19 15:28:21 -05:00
parent 7862a09858
commit 63d9995f59
10 changed files with 131 additions and 50 deletions
+13 -3
View File
@@ -13,7 +13,8 @@
static const char *TAG = "config";
#define NVS_NS "buzz"
#define CFG_KEY "cfg"
#define CFG_MAGIC 0xB0220002u
#define CFG_MAGIC 0xB0220003u
#define CFG_MAGIC_PRE_500MS 0xB0220002u
#define CFG_MAGIC_PRE_COOLDOWN_MS 0xB0220001u
typedef struct { uint32_t magic; app_config_t cfg; } cfg_blob_t;
@@ -33,7 +34,7 @@ static const param_t s_params[] = {
P(min_rms, PT_FLOAT, 0.0, 32767.0, "loudness gate (int16 RMS)"),
P(win_n, PT_UINT, 1, 32, "sliding window length N (frames)"),
P(win_m, PT_UINT, 1, 32, "matches M needed in window (<= N)"),
P(cooldown_ms, PT_UINT, 0, 86400000, "cooldown after alert (ms)"),
P(cooldown_ms, PT_UINT, 0, 86400000, "quiet tail used to group buzzer frames (ms)"),
P(noise_mult, PT_FLOAT, 1.0, 100.0, "learn/adapt gate = noise floor x this"),
P(adapt_weight, PT_FLOAT, 0.0, 1.0, "weight of new template in adapt"),
P(monitor_ms, PT_UINT, 10, 60000, "min interval between monitor lines (ms)"),
@@ -102,7 +103,16 @@ esp_err_t config_init(void)
} else if (blob.magic == CFG_MAGIC_PRE_COOLDOWN_MS) {
s_cfg = blob.cfg;
s_cfg.cooldown_ms = CONFIG_BUZZ_COOLDOWN_MS;
ESP_LOGI(TAG, "migrating saved config to millisecond cooldown");
ESP_LOGI(TAG, "migrating saved config to event-grouping cooldown");
err = save_locked();
if (err != ESP_OK) {
nvs_close(h);
return err;
}
} else if (blob.magic == CFG_MAGIC_PRE_500MS) {
s_cfg = blob.cfg;
s_cfg.cooldown_ms = CONFIG_BUZZ_COOLDOWN_MS;
ESP_LOGI(TAG, "updating saved cooldown for buzz-event grouping");
err = save_locked();
if (err != ESP_OK) {
nvs_close(h);