upleb.uk

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

summaryrefslogtreecommitdiff
path: root/main/tollgate_client.h
diff options
context:
space:
mode:
Diffstat (limited to 'main/tollgate_client.h')
-rw-r--r--main/tollgate_client.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/main/tollgate_client.h b/main/tollgate_client.h
new file mode 100644
index 0000000..2055e52
--- /dev/null
+++ b/main/tollgate_client.h
@@ -0,0 +1,46 @@
1#ifndef TOLLGATE_CLIENT_H
2#define TOLLGATE_CLIENT_H
3
4#include "esp_err.h"
5#include <stdint.h>
6#include <stdbool.h>
7
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
12typedef 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_ERROR
21} tollgate_client_state_t;
22
23typedef struct {
24 bool is_tollgate;
25 int price_per_step;
26 int step_size_ms;
27 char mint_url[TG_CLIENT_MAX_MINT_URL];
28 char metric[TG_CLIENT_MAX_METRIC];
29} tollgate_discovery_t;
30
31esp_err_t tollgate_client_init(void);
32
33esp_err_t tollgate_client_on_sta_connected(const char *gw_ip_str);
34
35void tollgate_client_on_sta_disconnected(void);
36
37void tollgate_client_tick(void);
38
39tollgate_client_state_t tollgate_client_get_state(void);
40
41const tollgate_discovery_t *tollgate_client_get_discovery(void);
42
43int64_t tollgate_client_get_remaining_ms(void);
44int64_t tollgate_client_get_allotment_ms(void);
45
46#endif