Skip to content
This repository was archived by the owner on May 2, 2024. It is now read-only.

Commit 410c6b1

Browse files
committed
update examples
now can get the message port
1 parent 1a3622e commit 410c6b1

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

examples/ttn-otaa-sleep/ttn-otaa-sleep.ino

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@ const char* appKey = "CHANGE_ME"; // Chaneg to TTN Application Key
1212
TTN_esp32 ttn ;
1313
TTN_CayenneLPP lpp;
1414

15-
void message(const uint8_t* payload, size_t size, int rssi)
15+
void message(const uint8_t* payload, size_t size, uint8_t port, int rssi)
1616
{
1717
Serial.println("-- MESSAGE");
18-
Serial.print("Received " + String(size) + " bytes RSSI=" + String(rssi) + "db");
18+
Serial.printf("Received %d bytes on port %d (RSSI=%ddB) :", size, port, rssi);
1919
for (int i = 0; i < size; i++)
2020
{
21-
Serial.print(" " + String(payload[i]));
22-
// Serial.write(payload[i]);
21+
Serial.printf(" %02X", payload[i]);
2322
}
24-
2523
Serial.println();
2624
}
2725

examples/ttn-otaa/ttn-otaa.ino

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@ const char* appKey = "CHANGE_ME"; // Chaneg to TTN Application Key
1212
TTN_esp32 ttn ;
1313
TTN_CayenneLPP lpp;
1414

15-
void message(const uint8_t* payload, size_t size, int rssi)
15+
void message(const uint8_t* payload, size_t size, uint8_t port, int rssi)
1616
{
1717
Serial.println("-- MESSAGE");
18-
Serial.print("Received " + String(size) + " bytes RSSI=" + String(rssi) + "db");
18+
Serial.printf("Received %d bytes on port %d (RSSI=%ddB) :", size, port, rssi);
1919
for (int i = 0; i < size; i++)
2020
{
21-
Serial.print(" " + String(payload[i]));
22-
// Serial.write(payload[i]);
21+
Serial.printf(" %02X", payload[i]);
2322
}
24-
2523
Serial.println();
2624
}
2725

examples/ttn_abp/ttn_abp.ino

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,14 @@ const char* appSKey = "CHANGE_ME"; // Change to TTN Application Session Key
1212
TTN_esp32 ttn ;
1313
TTN_CayenneLPP lpp;
1414

15-
void message(const uint8_t* payload, size_t size, int rssi)
15+
void message(const uint8_t* payload, size_t size, uint8_t port, int rssi)
1616
{
1717
Serial.println("-- MESSAGE");
18-
Serial.print("Received " + String(size) + " bytes RSSI= " + String(rssi) + "dB");
19-
18+
Serial.printf("Received %d bytes on port %d (RSSI=%ddB) :", size, port, rssi);
2019
for (int i = 0; i < size; i++)
2120
{
22-
Serial.print(" " + String(payload[i]));
23-
// Serial.write(payload[i]);
21+
Serial.printf(" %02X", payload[i]);
2422
}
25-
2623
Serial.println();
2724
}
2825

0 commit comments

Comments
 (0)