diff options
| author | Your Name <you@example.com> | 2026-05-23 15:26:52 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-23 15:26:52 +0530 |
| commit | be4d490e96de3d20cc6c9921f09534cde0ca0765 (patch) | |
| tree | 624cdbaff079e14a26fc22f7741a1452b54555b9 /main/tollgate_client.h | |
| parent | 4ce93d0470e8ab2402486c893f50bfdf216752e6 (diff) | |
Phase 8c-8f: Extract portal, stratum_client, mint_health, client into tollgate_core
New component modules:
- tollgate_core_portal.c/h: template rendering, usage calc, captive URI detection
- tollgate_core_stratum_client.c/h: Stratum V1 JSON protocol parsing, message building
- tollgate_core_mint_health.c/h: mint health state tracking, recovery threshold logic
- tollgate_core_client.c/h: discovery/session/usage JSON parsing, renewal check, price calc
Main shims updated to delegate pure logic to component:
- captive_portal.c: uses tollgate_core_portal_render(), format_usage(), is_captive_uri()
- stratum_client.c: uses tollgate_core_stratum_parse_notify/build_*()
- mint_health.c: uses tollgate_core_mint_health_update/is_reachable/mark_unreachable()
- tollgate_client.c: uses tollgate_core_client_parse_*/should_renew/calc_price_per_min()
4 new unit tests (test_portal, test_stratum_client, test_mint_health_core, test_client_core)
All 25 unit tests pass. ESP-IDF build passes (68% partition free).
Diffstat (limited to 'main/tollgate_client.h')
| -rw-r--r-- | main/tollgate_client.h | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/main/tollgate_client.h b/main/tollgate_client.h index ccee624..463cf63 100644 --- a/main/tollgate_client.h +++ b/main/tollgate_client.h | |||
| @@ -1,36 +1,11 @@ | |||
| 1 | #ifndef TOLLGATE_CLIENT_H | 1 | #ifndef TOLLGATE_CLIENT_H |
| 2 | #define TOLLGATE_CLIENT_H | 2 | #define TOLLGATE_CLIENT_H |
| 3 | 3 | ||
| 4 | #include "tollgate_core_client.h" | ||
| 4 | #include "esp_err.h" | 5 | #include "esp_err.h" |
| 5 | #include <stdint.h> | 6 | #include <stdint.h> |
| 6 | #include <stdbool.h> | 7 | #include <stdbool.h> |
| 7 | 8 | ||
| 8 | #define TG_CLIENT_MAX_GW_IP_LEN 16 | ||
| 9 | #define TG_CLIENT_MAX_MINT_URL 256 | ||
| 10 | #define TG_CLIENT_MAX_METRIC 32 | ||
| 11 | |||
| 12 | typedef enum { | ||
| 13 | TG_CLIENT_IDLE, | ||
| 14 | TG_CLIENT_DETECTING, | ||
| 15 | TG_CLIENT_NO_TOLLGATE, | ||
| 16 | TG_CLIENT_NEEDS_PAY, | ||
| 17 | TG_CLIENT_PAYING, | ||
| 18 | TG_CLIENT_PAID, | ||
| 19 | TG_CLIENT_RENEWING, | ||
| 20 | TG_CLIENT_MINING, | ||
| 21 | TG_CLIENT_ERROR | ||
| 22 | } tollgate_client_state_t; | ||
| 23 | |||
| 24 | typedef struct { | ||
| 25 | bool is_tollgate; | ||
| 26 | int price_per_step; | ||
| 27 | int step_size_ms; | ||
| 28 | char mint_url[TG_CLIENT_MAX_MINT_URL]; | ||
| 29 | char metric[TG_CLIENT_MAX_METRIC]; | ||
| 30 | bool mining_available; | ||
| 31 | uint16_t mining_port; | ||
| 32 | } tollgate_discovery_t; | ||
| 33 | |||
| 34 | esp_err_t tollgate_client_init(void); | 9 | esp_err_t tollgate_client_init(void); |
| 35 | 10 | ||
| 36 | esp_err_t tollgate_client_on_sta_connected(const char *gw_ip_str); | 11 | esp_err_t tollgate_client_on_sta_connected(const char *gw_ip_str); |