-
Notifications
You must be signed in to change notification settings - Fork 12
/
LoRaWAN-Channel-Mask-Join.ino
45 lines (37 loc) · 1.06 KB
/
LoRaWAN-Channel-Mask-Join.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <MKRWAN.h>
#include "arduino_secrets.h"
LoRaModem modem;
// Enter your sensitive data in the secret tab or arduino_secrets.h
String appEui = APP_EUI;
String appKey = APP_KEY;
void setup() {
// Initialize serial port at 9600 bauds
Serial.begin(9600);
while (!Serial);
// Initialize LoRa module with the US915-928 region parameters
if (!modem.begin(US915)) {
Serial.println("Failed to start module");
while (1) {}
};
// Device module version and EUI
delay(5000);
Serial.print("Your module version is: ");
Serial.println(modem.version());
Serial.print("Your device EUI is: ");
Serial.println(modem.deviceEUI());
// Enable US915-928 channels
// LoRaWAN® Regional Parameters and TTN specification: channels 8 to 15 plus 65
modem.sendMask("ff000001f000ffff00020000");
Serial.println(modem.getChannelMask());
modem.setADR(true);
join();
}
void join() {
// Try to connect
int connected = modem.joinOTAA(appEui, appKey);
if (!connected) {
Serial.println("Something went wrong, retrying...");
join();
}
}
void loop(){}