Refactor notification system to use HTTP POST for buzz events, updating configuration and documentation accordingly.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
# Door buzzer detector (ESP32-S3, ESP-IDF, spectral template matching)
|
||||
|
||||
Listens through an I2S MEMS mic, compares the *shape* of the spectrum of every 32 ms frame to a stored
|
||||
buzzer template (cosine similarity of a 32-band log-spectrum fingerprint), and sends an ntfy.sh push
|
||||
notification when a sliding window says "that was the buzzer". No machine learning.
|
||||
buzzer template (cosine similarity of a 32-band log-spectrum fingerprint), and posts each completed buzz
|
||||
event to a configurable HTTP endpoint. No machine learning.
|
||||
|
||||
Written in C (C11), as your file list (`main.c`, ...) implied. ESP-IDF API usage follows v5.x/v6.0 conventions
|
||||
(`driver/i2s_std.h`, `esp_driver_*` components, esp_console REPL).
|
||||
@@ -31,7 +31,7 @@ door_buzzer/
|
||||
├── config_store.c/h # runtime parameters in NVS
|
||||
├── processing.c/h # features -> score -> detector task, stats, monitor
|
||||
├── console.c/h # serial commands
|
||||
├── notifier.c/h # Wi-Fi w/ backoff + ntfy HTTPS task
|
||||
├── notifier.c/h # Wi-Fi w/ backoff + queued event HTTP POST
|
||||
└── led.c/h # WS2812 status LED
|
||||
```
|
||||
|
||||
@@ -60,10 +60,12 @@ idf.py set-target esp32s3
|
||||
idf.py menuconfig # "Door Buzzer Detector"
|
||||
```
|
||||
* **Wi-Fi**: SSID + password.
|
||||
* **ntfy**: server (default `https://ntfy.sh`), **topic** (pick something unguessable: anyone who knows it can read it),
|
||||
optional heartbeat topic and interval (hours, 0 = off). Subscribe to the topic in the ntfy phone app.
|
||||
* **Buzz event HTTP endpoint**: configure a full endpoint URL and secret. Each completed buzz sends one
|
||||
`application/json` POST with `{"delay_ms":<detected duration>,"secret":"<configured secret>"}`. There are no
|
||||
HTTP retries or heartbeat messages. The endpoint must be reachable from the ESP32; `127.0.0.1` refers to
|
||||
the ESP32 itself, so use the server's LAN address when it runs on another machine.
|
||||
* **Hardware**: pins, I2S slot, `Right shift` (default 14 = 4x digital gain for the quiet INMP441).
|
||||
* **Detector defaults**: threshold, loudness gate, N/M, and a 500 ms quiet tail for grouping intermittent matching frames into one buzz. Each new match within that tail extends the event; its reported duration runs from the first qualifying match through the last, excluding the final quiet tail. Duration is frame-granular (32 ms hops), and is included in the alert notification and `status`. Settings can also be changed live with `set` and persist in NVS.
|
||||
* **Detector defaults**: threshold, loudness gate, N/M, and a 500 ms quiet tail for grouping intermittent matching frames into one buzz. Each new match within that tail extends the event; its reported duration runs from the first qualifying match through the last, excluding the final quiet tail. Duration is frame-granular (32 ms hops), and is included in the event POST body and `status`. Settings can also be changed live with `set` and persist in NVS.
|
||||
* Console: defaults to the **UART** USB port. For the native USB port set *Component config > ESP System Settings > Channel for console output*
|
||||
to *USB Serial/JTAG*.
|
||||
|
||||
@@ -101,8 +103,8 @@ buzz> autothresh # threshold = midpoint of background p99 and buzzer p5, sa
|
||||
**d. Live test**
|
||||
```
|
||||
buzz> monitor on # timestamp, RMS, score, MATCH flag, state
|
||||
buzz> alert # test notification
|
||||
buzz> status # template source, timing (must be << 32 ms), Wi-Fi, notification counters
|
||||
buzz> alert # test event POST (delay_ms=42)
|
||||
buzz> status # template source, timing, Wi-Fi, event POST counters
|
||||
```
|
||||
`learn reset` clears the NVS template and falls back to `template.h`. During any calibration session the detector is
|
||||
paused (pressing the buzzer will not send alerts).
|
||||
@@ -110,7 +112,7 @@ paused (pressing the buzzer will not send alerts).
|
||||
### Console reference
|
||||
`selftest` `selfcheck` `learn [reset]` `adapt [w]` `background` `test` `autothresh` `monitor on|off`
|
||||
`set <param> <value>` `get [param]` `status` `fingerprint` `alert` `reboot`.
|
||||
Parameters: `threshold min_rms win_n win_m cooldown_ms noise_mult adapt_weight monitor_ms heartbeat_h`.
|
||||
Parameters: `threshold min_rms win_n win_m cooldown_ms noise_mult adapt_weight monitor_ms`.
|
||||
|
||||
## Design notes
|
||||
|
||||
@@ -123,7 +125,7 @@ Parameters: `threshold min_rms win_n win_m cooldown_ms noise_mult adapt_weight m
|
||||
* **Concurrency:** audio task (core 1, prio 10) -> pool of 8 frame slots + two index queues (no allocation; drops and logs if processing lags)
|
||||
-> processing task (core 1, prio 8). Network and console tasks are separate; the notifier has its own queue. Mode and session data
|
||||
are guarded by a mutex; template and config by mutexes. Audio and processing tasks are on the task watchdog (5 s, panic -> reboot).
|
||||
* **Notifier:** exponential Wi-Fi reconnect (1 s .. 60 s); up to 4 delivery attempts with backoff, then dropped and logged.
|
||||
* **Event sender:** exponential Wi-Fi reconnect (1 s .. 60 s); at most one HTTP POST per queued buzz event, no request retries.
|
||||
* Simplifications chosen on purpose: one `TEST_CAL` mode serves `test` and `selfcheck`; calibration results (background/buzzer stats) live in RAM only
|
||||
(re-run after reboot before `autothresh`); `TEMPLATE_SUGGESTED_THRESHOLD` is shown in `status`, not applied automatically.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user