upleb.uk

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

summaryrefslogtreecommitdiff
path: root/main/tollgate_platform.c
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-20 02:10:01 +0530
committerYour Name <you@example.com>2026-05-20 02:10:01 +0530
commit82f1fc0d5535eda3fc9eab799d81b3e220dbe4ef (patch)
tree341dcecb0a87a6219bc51d424316dfadcf69bf65 /main/tollgate_platform.c
parent2c12c4281c47aa87a1c7bb82abe09bf9dbc788c3 (diff)
feat: add tollgate_core component + market config wiring
- Add tollgate_core ESP-IDF component (skeleton: cashu, dns, firewall, session) - Add tollgate_platform.c with SPIFFS config backend - Wire market_enabled, market_scan_interval_s, client_auto_switch in config.c - Add lwip_tollgate_hooks.h (updated from feature branch) - Add E2E fix plan, tollgate_core design doc, WPA autodetect plan - Add integration test network helpers - Add CONSOLIDATION.md plan Reverts the broken merge (be4788b) that gutted config.c/tollgate_main.c/tollgate_api.c and replaces it with a clean addition on top of intact master.
Diffstat (limited to 'main/tollgate_platform.c')
-rw-r--r--main/tollgate_platform.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/main/tollgate_platform.c b/main/tollgate_platform.c
new file mode 100644
index 0000000..4083c4e
--- /dev/null
+++ b/main/tollgate_platform.c
@@ -0,0 +1,63 @@
1#include "tollgate_platform.h"
2#include "tollgate_core.h"
3#include "config.h"
4#include "esp_log.h"
5#include "freertos/FreeRTOS.h"
6#include "freertos/task.h"
7
8static const char *TAG = "tollgate_platform";
9
10static uint16_t platform_get_price_sats(void)
11{
12 const tollgate_config_t *cfg = tollgate_config_get();
13 return cfg ? (uint16_t)cfg->price_per_step : 21;
14}
15
16static int32_t platform_get_step_ms(void)
17{
18 const tollgate_config_t *cfg = tollgate_config_get();
19 return cfg ? (int32_t)cfg->step_size_ms : 60000;
20}
21
22static const char *platform_get_mint_url(void)
23{
24 const tollgate_config_t *cfg = tollgate_config_get();
25 return cfg ? cfg->mint_url : "https://testnut.cashu.space";
26}
27
28static const char *platform_get_metric(void)
29{
30 const tollgate_config_t *cfg = tollgate_config_get();
31 return cfg ? cfg->metric : "milliseconds";
32}
33
34static int32_t platform_get_step_bytes(void)
35{
36 const tollgate_config_t *cfg = tollgate_config_get();
37 return cfg ? (int32_t)cfg->step_size_bytes : 22020096;
38}
39
40static int64_t platform_get_time_ms(void)
41{
42 return (int64_t)xTaskGetTickCount() * portTICK_PERIOD_MS;
43}
44
45static bool platform_spend_proofs(const char *raw_token_json)
46{
47 (void)raw_token_json;
48 return true;
49}
50
51const tollgate_platform_t *tollgate_get_platform(void)
52{
53 static const tollgate_platform_t platform = {
54 .get_price_sats = platform_get_price_sats,
55 .get_step_ms = platform_get_step_ms,
56 .get_mint_url = platform_get_mint_url,
57 .get_metric = platform_get_metric,
58 .get_step_bytes = platform_get_step_bytes,
59 .get_time_ms = platform_get_time_ms,
60 .spend_proofs = platform_spend_proofs,
61 };
62 return &platform;
63}