diff options
Diffstat (limited to 'main/tollgate_client.h')
| -rw-r--r-- | main/tollgate_client.h | 46 |
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 | |||
| 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_ERROR | ||
| 21 | } tollgate_client_state_t; | ||
| 22 | |||
| 23 | typedef 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 | |||
| 31 | esp_err_t tollgate_client_init(void); | ||
| 32 | |||
| 33 | esp_err_t tollgate_client_on_sta_connected(const char *gw_ip_str); | ||
| 34 | |||
| 35 | void tollgate_client_on_sta_disconnected(void); | ||
| 36 | |||
| 37 | void tollgate_client_tick(void); | ||
| 38 | |||
| 39 | tollgate_client_state_t tollgate_client_get_state(void); | ||
| 40 | |||
| 41 | const tollgate_discovery_t *tollgate_client_get_discovery(void); | ||
| 42 | |||
| 43 | int64_t tollgate_client_get_remaining_ms(void); | ||
| 44 | int64_t tollgate_client_get_allotment_ms(void); | ||
| 45 | |||
| 46 | #endif | ||