Skip to content

Commit b00c7c1

Browse files
committed
Initial connection to Meshtastic device
1 parent 42d004b commit b00c7c1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

examples/SendReceiveClient/SendReceiveClient.ino

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
#define SEND_PERIOD 300
3030

3131
uint32_t next_send_time = 0;
32+
bool not_yet_connected = true;
33+
34+
// This callback function will be called whenever the radio connects to a node
35+
void connected_callback(mt_node_t *node, mt_nr_progress_t progress) {
36+
if (not_yet_connected)
37+
Serial.println("Connected to Meshtastic device!");
38+
not_yet_connected = false;
39+
}
3240

3341
// This callback function will be called whenever the radio receives a text message
3442
void text_message_callback(uint32_t from, const char* text) {
@@ -68,6 +76,9 @@ void setup() {
6876

6977
randomSeed(micros());
7078

79+
// Initial connection to the Meshtastic device
80+
mt_request_node_report(connected_callback);
81+
7182
// Register a callback function to be called whenever a text message is received
7283
set_text_message_callback(text_message_callback);
7384
}

0 commit comments

Comments
 (0)