Skip to content

Commit 928d75e

Browse files
committed
update SendReceiveClient
1 parent f769738 commit 928d75e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

examples/SendReceiveClient/SendReceiveClient.ino

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
// will ignore these settings and use their own.
2323
#define SERIAL_RX_PIN 13
2424
#define SERIAL_TX_PIN 15
25+
2526
// A different baud rate to communicate with the Meshtastic device can be specified here
2627
#define BAUD_RATE 9600
2728

@@ -39,12 +40,17 @@ void connected_callback(mt_node_t *node, mt_nr_progress_t progress) {
3940
}
4041

4142
// This callback function will be called whenever the radio receives a text message
42-
void text_message_callback(uint32_t from, const char* text) {
43+
void text_message_callback(uint32_t from, uint32_t to, const char* text) {
4344
// Do your own thing here. This example just prints the message to the serial console.
44-
Serial.print("Received a text message from ");
45+
Serial.print("Received a text message from: ");
4546
Serial.print(from);
46-
Serial.print(": ");
47+
Serial.print(" to: ");
48+
Serial.print(to);
49+
Serial.print(" message: ");
4750
Serial.println(text);
51+
if (to == my_node_num){
52+
Serial.println("This is a DM to me!");
53+
}
4854
}
4955

5056
void setup() {
@@ -80,7 +86,7 @@ void setup() {
8086
mt_request_node_report(connected_callback);
8187

8288
// Register a callback function to be called whenever a text message is received
83-
set_text_message_callback(text_message_callback);
89+
set_directed_text_message_callback(text_message_callback);
8490
}
8591

8692
void loop() {

0 commit comments

Comments
 (0)