|
5 | 5 | #include "meshtastic/mesh.pb.h" |
6 | 6 | #include <pb_encode.h> |
7 | 7 | #include <pb_decode.h> |
8 | | - |
9 | | -// Some sane limits on a few strings that the protocol would otherwise allow to be unlimited length |
10 | | -#define MAX_USER_ID_LEN (sizeof(meshtastic_User().id) - 1) |
11 | | -#define MAX_LONG_NAME_LEN (sizeof(meshtastic_User().long_name) - 1) |
12 | | -#define MAX_SHORT_NAME_LEN (sizeof(meshtastic_User().short_name) - 1) |
13 | | - |
14 | | -#define BAUD_DEFAULT 9600 |
15 | | -#define BROADCAST_ADDR 0xFFFFFFFF |
16 | | - |
17 | | -extern uint32_t my_node_num; |
18 | | - |
19 | | -// The strings will be truncated if they're longer than the lengths above, but |
20 | | -// will always be NUL-terminated. If not available, they'll be NULL. |
21 | | -typedef struct { |
22 | | - uint32_t node_num; |
23 | | - bool is_mine; |
24 | | - bool has_user; |
25 | | - char user_id[MAX_USER_ID_LEN]; |
26 | | - char long_name[MAX_LONG_NAME_LEN]; |
27 | | - char short_name[MAX_SHORT_NAME_LEN]; |
28 | | - double latitude; |
29 | | - double longitude; |
30 | | - int8_t altitude; // To the nearest meter above (or below) sea level |
31 | | - uint16_t ground_speed; // meters per second |
32 | | - uint8_t battery_level; |
33 | | - uint32_t last_heard_from; |
34 | | - uint32_t last_heard_position; |
35 | | - uint32_t time_of_last_position; |
36 | | - float voltage; |
37 | | - float channel_utilization; |
38 | | - float air_util_tx; |
39 | | -} mt_node_t; |
40 | | - |
41 | | -// Initialize, using wifi to connect to the MT radio |
42 | | -void mt_wifi_init(int8_t cs_pin, int8_t irq_pin, int8_t reset_pin, |
43 | | - int8_t enable_pin, const char * ssid, const char * password); |
44 | | - |
45 | | -// Initialize, using serial pins and baud rate to connect to the MT radio |
46 | | -void mt_serial_init(int8_t rx_pin, int8_t tx_pin, uint32_t baud = BAUD_DEFAULT); |
47 | | - |
48 | | -// Call this once per loop() and pass the current millis(). Returns bool indicating whether the connection is ready. |
49 | | -bool mt_loop(uint32_t now); |
50 | | - |
51 | | -// Will print lots of (semi)useful information to the main Serial output |
52 | | -void mt_set_debug(bool on); |
53 | | - |
54 | | -typedef enum { |
55 | | - MT_NR_IN_PROGRESS, |
56 | | - MT_NR_DONE, |
57 | | - MT_NR_INVALID |
58 | | -} mt_nr_progress_t; |
59 | | - |
60 | | -// Ask the MT radio for a node report (it won't arrive right away) |
61 | | -// For each node it receives, your callback will be called with |
62 | | -// the second parameter set to MT_NR_IN_PROGRESS. At the end of the |
63 | | -// report, if the IDs matched, the callback will be called with |
64 | | -// NULL as the first parameter and the second set to either MT_NR_DONE |
65 | | -// (if it was indeed the reply to our request) or MT_NR_INVALID (if it |
66 | | -// turned out to have been a reply to someone else's request). |
67 | | -// |
68 | | -// Everything we pass to your callback could be destroyed immediately |
69 | | -// after it returns, so it should save it somewhere else if it needs it. |
70 | | -// |
71 | | -// Returns true if we were able to request the report, false if we couldn't |
72 | | -// even do that. |
73 | | -bool mt_request_node_report(void (*callback)(mt_node_t *, mt_nr_progress_t)); |
74 | | - |
75 | | -// Set the callback function that gets called when the node receives a text message. |
76 | | -void set_text_message_callback(void (*callback)(uint32_t from, const char * text)); |
77 | | - |
78 | | -// Set the callback function that gets called when the node receives a text message. |
79 | | -void set_telemetry_callback(void (*callback)(uint32_t from, meshtastic_Telemetry * telemetry)); |
80 | | - |
81 | | -// Send a text message with *text* as payload, to a destination node (optional), on a certain channel (optional). |
82 | | -bool mt_send_text(const char * text, uint32_t dest = BROADCAST_ADDR, uint8_t channel_index = 0); |
| 8 | +#include "mt_protocol.h" |
83 | 9 |
|
84 | 10 | #endif |
0 commit comments