Files
buzz_detector/main/config_store.h
T

27 lines
1.3 KiB
C

#pragma once
#include <stddef.h>
#include <stdint.h>
#include "esp_err.h"
// All runtime-tunable parameters in one struct. Defaults come from Kconfig, the
// saved copy (NVS) wins when present and layout-compatible.
typedef struct {
float threshold; // cosine similarity needed for a frame to "match"
float min_rms; // loudness gate (int16 RMS); quieter frames never match
uint32_t win_n; // sliding window length (frames), 1..32
uint32_t win_m; // matches needed inside the window, 1..win_n
uint32_t cooldown_ms; // quiet tail that groups matches into one buzz event
float noise_mult; // learn/adapt gate = noise floor * this
float adapt_weight; // weight of the NEW template in `adapt` (0..1)
uint32_t monitor_ms; // min interval between `monitor` lines
uint32_t heartbeat_h; // heartbeat period in hours, 0 = off
} app_config_t;
esp_err_t config_init(void); // nvs_flash_init + load
void config_get(app_config_t *out); // thread-safe copy
esp_err_t config_set_param(const char *name, const char *value, char *err, size_t err_len);
esp_err_t config_reset_defaults(void);
int config_param_count(void);
const char *config_param_name(int i);
void config_param_format(int i, char *buf, size_t len); // "0.800 (range 0.1..0.999) help"