upleb.uk

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

summaryrefslogtreecommitdiff
path: root/main/beacon_price.h
diff options
context:
space:
mode:
Diffstat (limited to 'main/beacon_price.h')
-rw-r--r--main/beacon_price.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/main/beacon_price.h b/main/beacon_price.h
new file mode 100644
index 0000000..cb2eb5b
--- /dev/null
+++ b/main/beacon_price.h
@@ -0,0 +1,44 @@
1#ifndef BEACON_PRICE_H
2#define BEACON_PRICE_H
3
4#include "esp_err.h"
5#include <stdint.h>
6#include <stdbool.h>
7
8#define TOLLGATE_OUI_0 0xC0
9#define TOLLGATE_OUI_1 0xFF
10#define TOLLGATE_OUI_2 0xEE
11#define TOLLGATE_IE_TYPE 0x01
12#define TOLLGATE_IE_VERSION 1
13
14#define TOLLGATE_IE_GEOHASH_MAX 9
15
16typedef struct __attribute__((packed)) {
17 uint8_t version;
18 uint8_t metric;
19 uint16_t price_per_step;
20 uint32_t step_size;
21 uint8_t mint_hash[4];
22 uint8_t geohash_len;
23 char geohash[TOLLGATE_IE_GEOHASH_MAX];
24 uint8_t npub_hash[4];
25} tollgate_price_payload_t;
26
27#define TOLLGATE_IE_PAYLOAD_SIZE sizeof(tollgate_price_payload_t)
28#define TOLLGATE_IE_TOTAL_SIZE (6 + TOLLGATE_IE_PAYLOAD_SIZE)
29
30typedef struct __attribute__((packed)) {
31 uint8_t element_id;
32 uint8_t length;
33 uint8_t vendor_oui[3];
34 uint8_t vendor_oui_type;
35 tollgate_price_payload_t payload;
36} tollgate_price_ie_t;
37
38esp_err_t beacon_price_start(void);
39esp_err_t beacon_price_stop(void);
40void beacon_price_build_ie(tollgate_price_ie_t *ie);
41void beacon_price_hash_mint(const char *mint_url, uint8_t hash_out[4]);
42void beacon_price_hash_npub(const char *npub_hex, uint8_t hash_out[4]);
43
44#endif