upleb.uk

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

summaryrefslogtreecommitdiff
path: root/main/cvm_server.c
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-19 13:21:25 +0530
committerYour Name <you@example.com>2026-05-19 13:31:08 +0530
commiteeba74a4a1c011e85e33dea4252b381e35a64ea4 (patch)
tree14862e7d300511e28e214c743fd2f699bc54c5b8 /main/cvm_server.c
parentb0d9d494f00ee77f9efc22d1ef2ea3c94b23ddbd (diff)
feat: multi-mint wallet with health tracking, WPA auto-detect, display gating
Squash merge of feature/multi-mint-support (21 commits): Multi-mint wallet: - Accept payments from 4 mints: minibits, coinos, 21mint, lnvoltz - Periodic health probing (300s interval, 3 recovery threshold) - Multi-wallet init with nucula_wallet_init_multi() - /mints and /wallet API endpoints WPA auto-detect: - wifi_auth_mode config field (default WPA2, supports WPA3) - Runtime mapping to wifi_auth_mode_t in STA config Display gating: - display_enabled config field (default true) - Guards display_init/display_update per-board Bug fixes: - 3s delay before service start prevents lwip mem_free assertion - Real npub in discovery (identity_get()->npub_hex) - Health probe interval 300s (production value) - Duplicate services_start_task call removed - UTF-8 arrow replaced with ASCII in log message Tests: 61+14 unit tests passing, firmware builds clean
Diffstat (limited to 'main/cvm_server.c')
-rw-r--r--main/cvm_server.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/main/cvm_server.c b/main/cvm_server.c
index a4804d2..10af956 100644
--- a/main/cvm_server.c
+++ b/main/cvm_server.c
@@ -31,9 +31,6 @@ static void publish_announcements_via_ws(esp_tls_t *tls);
31#define CVM_WS_BUF_SIZE 8192 31#define CVM_WS_BUF_SIZE 8192
32#define CVM_MAX_RESPONSE_SIZE 4096 32#define CVM_MAX_RESPONSE_SIZE 4096
33#define CVM_RECONNECT_DELAY_MS 5000 33#define CVM_RECONNECT_DELAY_MS 5000
34#define CVM_WS_READ_TIMEOUT_MS 1000
35#define CVM_WS_PING_INTERVAL_S 30
36#define CVM_WS_MAX_CONSECUTIVE_TIMEOUTS 65
37 34
38static char *parse_ws_text_frame(const uint8_t *buf, int len) 35static char *parse_ws_text_frame(const uint8_t *buf, int len)
39{ 36{
@@ -557,19 +554,14 @@ static void cvm_relay_task(void *arg)
557 return; 554 return;
558 } 555 }
559 556
560 int64_t last_ping_time = (int64_t)esp_timer_get_time() / 1000000;
561 int consecutive_timeouts = 0; 557 int consecutive_timeouts = 0;
562
563 while (g_running) { 558 while (g_running) {
564 int rlen = esp_tls_conn_read(tls, buf, CVM_WS_BUF_SIZE - 1); 559 int rlen = esp_tls_conn_read(tls, buf, CVM_WS_BUF_SIZE - 1);
565 if (rlen < 0) { 560 if (rlen < 0) {
566 consecutive_timeouts++; 561 ESP_LOGW(TAG, "Read error on %s (rlen=%d)", relay_url, rlen);
567 if (consecutive_timeouts >= CVM_WS_MAX_CONSECUTIVE_TIMEOUTS) { 562 break;
568 ESP_LOGW(TAG, "Read timeout on %s (%d consecutive)", relay_url, consecutive_timeouts); 563 }
569 break; 564 if (rlen == 0) {
570 }
571 } else if (rlen == 0) {
572 ESP_LOGW(TAG, "Connection closed by %s", relay_url);
573 break; 565 break;
574 } else { 566 } else {
575 consecutive_timeouts = 0; 567 consecutive_timeouts = 0;
@@ -591,13 +583,6 @@ static void cvm_relay_task(void *arg)
591 } 583 }
592 } 584 }
593 585
594 int64_t now = (int64_t)esp_timer_get_time() / 1000000;
595 if (now - last_ping_time >= CVM_WS_PING_INTERVAL_S) {
596 uint8_t ping[2] = {0x89, 0x00};
597 esp_tls_conn_write(tls, ping, 2);
598 last_ping_time = now;
599 ESP_LOGD(TAG, "Sent WS keepalive ping");
600 }
601 } 586 }
602 587
603 free(buf); 588 free(buf);