Skip to content

Commit

Permalink
Initial connection to Meshtastic device
Browse files Browse the repository at this point in the history
  • Loading branch information
GUVWAF committed Oct 6, 2023
1 parent 42d004b commit b00c7c1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/SendReceiveClient/SendReceiveClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
#define SEND_PERIOD 300

uint32_t next_send_time = 0;
bool not_yet_connected = true;

// This callback function will be called whenever the radio connects to a node
void connected_callback(mt_node_t *node, mt_nr_progress_t progress) {
if (not_yet_connected)
Serial.println("Connected to Meshtastic device!");
not_yet_connected = false;
}

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

randomSeed(micros());

// Initial connection to the Meshtastic device
mt_request_node_report(connected_callback);

// Register a callback function to be called whenever a text message is received
set_text_message_callback(text_message_callback);
}
Expand Down

0 comments on commit b00c7c1

Please sign in to comment.