diff options
| author | Your Name <you@example.com> | 2026-05-19 13:14:48 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-19 13:14:48 +0530 |
| commit | fe6aa9663d4cdabdc6e71db6068f8cd9e3739ffe (patch) | |
| tree | 8cadb07243c07a6b3fa9453b239c9ac5cb02b454 /main/cvm_server.c | |
| parent | 77031f06a9a87320d011f501590985161d1eb305 (diff) | |
feat: WiFi beacon price discovery via Vendor IE (two-board verified)
Price discovery allows TollGate ESP32 boards to advertise their per-step
price via WiFi Vendor-Specific Information Elements (OUI 0xC0FFEE) in
beacon and probe response frames. Nearby boards passively scan and build
a market view of competing TollGates without requiring internet access.
Features:
- beacon_price.c/h: 26-byte packed Vendor IE payload (price, step, metric,
mint_hash, geohash, npub_hash), injected via esp_wifi_set_vendor_ie()
- market.c/h: Passive WiFi scan receiver, vendor IE callback parsing,
BSSID-correlated market entries, effective price ranking
- GET /market API endpoint: JSON market snapshot with discovered entries
- AP-only services: beacon + market + API start on WIFI_EVENT_AP_START,
independent of STA connectivity
- STA reconnect fix: 2s delay between retries creates scan windows;
s_sta_connecting guard prevents double-connect
- write-config-ap-only-a/b Makefile targets for STA-less testing
- market_tick() in main loop, client price comparison logging
Hardware verified: both boards discover each other via Vendor IE beacons.
Board A sees TollGate-C0E9CA (RSSI=-30), Board B sees TollGate-B96D80
(RSSI=-25). test-market.mjs: 9/9, test-price-discovery.mjs: 7/7 per board.
Unit tests: 45 new assertions across test_beacon_price (28) and test_market
(17). All 15 test suites pass. ESP-IDF build clean for ESP32-S3.
Diffstat (limited to 'main/cvm_server.c')
| -rw-r--r-- | main/cvm_server.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/main/cvm_server.c b/main/cvm_server.c index 644738b..a4804d2 100644 --- a/main/cvm_server.c +++ b/main/cvm_server.c | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "nucula_wallet.h" | 8 | #include "nucula_wallet.h" |
| 9 | #include "cJSON.h" | 9 | #include "cJSON.h" |
| 10 | #include "esp_log.h" | 10 | #include "esp_log.h" |
| 11 | #include "esp_timer.h" | ||
| 11 | #include "esp_tls.h" | 12 | #include "esp_tls.h" |
| 12 | #include "esp_crt_bundle.h" | 13 | #include "esp_crt_bundle.h" |
| 13 | #include "esp_random.h" | 14 | #include "esp_random.h" |
| @@ -576,7 +577,7 @@ static void cvm_relay_task(void *arg) | |||
| 576 | char *text = parse_ws_text_frame(buf, rlen); | 577 | char *text = parse_ws_text_frame(buf, rlen); |
| 577 | if (text) { | 578 | if (text) { |
| 578 | if (strlen(text) > 0) { | 579 | if (strlen(text) > 0) { |
| 579 | process_relay_message(tls, relay_url, text); | 580 | process_relay_message(relay_url, text); |
| 580 | } | 581 | } |
| 581 | free(text); | 582 | free(text); |
| 582 | } | 583 | } |