upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/main/config.c
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-19 01:10:06 +0530
committerYour Name <you@example.com>2026-05-19 01:10:06 +0530
commit42902a36bc52e009a1e8d3c371741e30a9cb4c33 (patch)
tree46db33710a3650b2267933a8375d3598af11319a /main/config.c
parentfe7c3be2fd9d464dbc837d1913409d2691bd50f5 (diff)
feat: ContextVM (MCP over Nostr) server with full integration
Complete CVM implementation: persistent WebSocket relay listener, kind 25910 event subscription, MCP protocol handlers, CEP-6 announcements, 10 MCP tools, per-board hardware locks, WiFi EU regulatory fix. Architecture: - cvm_server.c: WS relay listener, kind 25910 subscription, MCP dispatch - mcp_handler.c/h: 10 MCP tools (get_config, set_config, get_balance, wallet_send, get_sessions, get_usage, set_payout, set_metric, set_price, wallet_melt) - Responses published via existing WS connection (not new TLS) - Auth check: only owner npub accepted - CEP-6: kinds 11316 (server), 11317 (tools), 10002 (relay list) - WS ping/pong keepalive every 30s, 60s TLS read timeout Critical fixes: - WiFi country code DE (ESP-IDF defaults to CN, breaks EU APs) - Subscription #p filter must be array not string - Use-after-free: tags_str freed before nostr_event_to_json - MCP responses via existing WS (ESP32 can't open multiple TLS) - EVENT msg buffer underflow, WS frame masking, TLS write loop Per-board hardware locks: - Lock files in physical-router-test-automation/locks/ - lock-a/b/c, unlock-a/b/c targets in 3 Makefiles - All hardware-touching targets require board lock Verified on Board B via relay.primal.net: - 282 unit tests passing (61 CVM + 60 MCP + 161 existing) - MCP initialize roundtrip: PASS - tools/list: PASS - tools/call get_config: PASS - tools/call get_balance: PASS - tools/call set_price: PASS (write operation) - CEP-6 announcements (11316, 11317, 10002): all accepted by relay - WiFi STA connection (EnterSSID-2.4GHz): PASS with country code DE - Board A WiFi confirmed hardware issue (not firmware)
Diffstat (limited to 'main/config.c')
-rw-r--r--main/config.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/main/config.c b/main/config.c
index e937fb3..9dd2a1d 100644
--- a/main/config.c
+++ b/main/config.c
@@ -16,7 +16,7 @@ esp_err_t tollgate_config_init(void)
16{ 16{
17 memset(&g_config, 0, sizeof(g_config)); 17 memset(&g_config, 0, sizeof(g_config));
18 g_config.max_retry = 5; 18 g_config.max_retry = 5;
19 g_config.ap_channel = 1; 19 g_config.ap_channel = 6;
20 g_config.ap_max_conn = 4; 20 g_config.ap_max_conn = 4;
21 g_config.price_per_step = 21; 21 g_config.price_per_step = 21;
22 g_config.step_size_ms = 60000; 22 g_config.step_size_ms = 60000;
@@ -33,8 +33,8 @@ esp_err_t tollgate_config_init(void)
33 g_config.payout.check_interval_s = 60; 33 g_config.payout.check_interval_s = 60;
34 g_config.payout.recipient_count = 0; 34 g_config.payout.recipient_count = 0;
35 g_config.payout.mint_count = 0; 35 g_config.payout.mint_count = 0;
36 g_config.cvm_enabled = false; 36 g_config.cvm_enabled = true;
37 strncpy(g_config.cvm_relays, "wss://relay.damus.io", sizeof(g_config.cvm_relays) - 1); 37 strncpy(g_config.cvm_relays, "wss://relay.primal.net", sizeof(g_config.cvm_relays) - 1);
38 38
39 esp_vfs_spiffs_conf_t conf = { 39 esp_vfs_spiffs_conf_t conf = {
40 .base_path = "/spiffs", 40 .base_path = "/spiffs",
@@ -54,7 +54,9 @@ esp_err_t tollgate_config_init(void)
54 const char *default_json = "{" 54 const char *default_json = "{"
55 "\"nsec\":\"a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2\"," 55 "\"nsec\":\"a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2\","
56 "\"wifi_networks\":[" 56 "\"wifi_networks\":["
57 "{\"ssid\":\"EnterSSID-2.4GHz\",\"password\":\"c03rad0r123!\"}" 57 "{\"ssid\":\"EnterSSID-2.4GHz\",\"password\":\"c03rad0r123!\"},"
58 "{\"ssid\":\"c03rad0r\",\"password\":\"c03rad0r123\"},"
59 "{\"ssid\":\"TK-GAESTE\",\"password\":\"\"}"
58 "]," 60 "],"
59 "\"ap_password\":\"\"," 61 "\"ap_password\":\"\","
60 "\"mint_url\":\"https://testnut.cashu.space\"," 62 "\"mint_url\":\"https://testnut.cashu.space\","
@@ -289,6 +291,9 @@ esp_err_t tollgate_config_get_wifi(wifi_config_t *wifi_config)
289 strncpy((char *)wifi_config->sta.ssid, g_config.networks[idx].ssid, sizeof(wifi_config->sta.ssid) - 1); 291 strncpy((char *)wifi_config->sta.ssid, g_config.networks[idx].ssid, sizeof(wifi_config->sta.ssid) - 1);
290 strncpy((char *)wifi_config->sta.password, g_config.networks[idx].password, sizeof(wifi_config->sta.password) - 1); 292 strncpy((char *)wifi_config->sta.password, g_config.networks[idx].password, sizeof(wifi_config->sta.password) - 1);
291 wifi_config->sta.threshold.authmode = WIFI_AUTH_WPA2_PSK; 293 wifi_config->sta.threshold.authmode = WIFI_AUTH_WPA2_PSK;
294 wifi_config->sta.pmf_cfg.capable = true;
295 wifi_config->sta.pmf_cfg.required = false;
296 wifi_config->sta.scan_method = WIFI_ALL_CHANNEL_SCAN;
292 return ESP_OK; 297 return ESP_OK;
293} 298}
294 299