-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #260 from jpmeijers/master
Class C support
- Loading branch information
Showing
7 changed files
with
176 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Johan Stokking <johan@thethingsnetwork.org> | ||
Fokke Zandbergen <mail@fokkezb.nl> | ||
Alessandro Blason <mrblason@gmail.com> | ||
JP Meijers <git@jpmeijers.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include <TheThingsNetwork.h> | ||
|
||
// Set your AppEUI and AppKey | ||
const char *appEui = "0000000000000000"; | ||
const char *appKey = "00000000000000000000000000000000"; | ||
|
||
#define loraSerial Serial1 | ||
#define debugSerial Serial | ||
|
||
// Replace REPLACE_ME with TTN_FP_EU868 or TTN_FP_US915 | ||
#define freqPlan REPLACE_ME | ||
|
||
TheThingsNetwork ttn(loraSerial, debugSerial, freqPlan); | ||
|
||
void setup() | ||
{ | ||
loraSerial.begin(57600); | ||
debugSerial.begin(9600); | ||
|
||
// Wait a maximum of 10s for Serial Monitor | ||
while (!debugSerial && millis() < 10000) | ||
; | ||
|
||
// Set callback for incoming messages | ||
ttn.onMessage(message); | ||
|
||
debugSerial.println("-- STATUS"); | ||
ttn.showStatus(); | ||
|
||
debugSerial.println("-- JOIN"); | ||
ttn.join(appEui, appKey, -1, 10000, CLASS_C); | ||
|
||
// Class C RX only takes affect after a TX | ||
uint8_t payload[] = {0x00}; | ||
ttn.sendBytes(payload, 1); | ||
} | ||
|
||
void loop() | ||
{ | ||
debugSerial.println("-- LOOP"); | ||
|
||
// Check for received data. | ||
ttn.poll(); | ||
|
||
// When using Class C we can poll as quickly as we can, as we only check the serial buffer. | ||
//delay(1000); | ||
} | ||
|
||
void message(const uint8_t *payload, size_t size, port_t port) | ||
{ | ||
debugSerial.println("-- MESSAGE"); | ||
debugSerial.print("Received " + String(size) + " bytes on port " + String(port) + ":"); | ||
|
||
for (int i = 0; i < size; i++) | ||
{ | ||
debugSerial.print(" " + String(payload[i])); | ||
} | ||
|
||
debugSerial.println(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters