/* Simple OTAA join for TheThingNetwork LoRaWAN network * * Uncomment one of the region defined below to select the * proper radio setup. * * EU868/IN865 have duty cycle restrictions. For debugging it makes sense * to disable those via setDutyCycle(false); * * For an external antenna one should set the proper antenna gain * (default is 2.0) via setAntennaGain(). * * Please edit the keys below as they are just debugging samples. * * * This example code is in the public domain. */ #include "LoRaWAN.h" // #define REGION_AS923_920_923 /* Japan, Malaysia, Singapore */ // #define REGION_AS923_923_925 /* Brunei, Cambodia, Hong Kong, Indonesia, Laos, Taiwan, Thailand, Vietnam */ // #define REGION_AU915 #define REGION_EU868 // #define REGION_IN865 // #define REGION_KR920 // #define REGION_US915 const char *appEui = "******"; const char *appKey = "*********"; const char *devEui = "**********"; void setup( void ) { Serial.begin(9600); #if defined(REGION_AS923_920_923) LoRaWAN.begin(AS923); #endif #if defined(REGION_AS923_920_923) LoRaWAN.begin(AS923); #endif #if defined(REGION_AU915) LoRaWAN.begin(AU915); LoRaWAN.setSubBand(2); #endif #if defined(REGION_EU868) LoRaWAN.begin(EU868); LoRaWAN.addChannel(1, 868300000, 0, 20); #endif #if defined(REGION_IN865) LoRaWAN.begin(IN865); #endif #if defined(REGION_KR920) LoRaWAN.begin(KR920); #endif #if defined(REGION_US915) LoRaWAN.begin(US915); LoRaWAN.setSubBand(2); #endif LoRaWAN.setADR(true); LoRaWAN.setDutyCycle(false); LoRaWAN.setAntennaGain(2.0); LoRaWAN.joinOTAA(appEui, appKey, devEui); Serial.println("JOIN( )"); } void loop( void ) { if (LoRaWAN.joined() && !LoRaWAN.busy()) { Serial.print("TRANSMIT( "); Serial.print("TimeOnAir: "); Serial.print(LoRaWAN.getTimeOnAir()); Serial.print(", NextTxTime: "); Serial.print(LoRaWAN.getNextTxTime()); Serial.print(", MaxPayloadSize: "); Serial.print(LoRaWAN.getMaxPayloadSize()); Serial.print(", DR: "); Serial.print(LoRaWAN.getDataRate()); Serial.print(", TxPower: "); Serial.print(LoRaWAN.getTxPower(), 1); Serial.print("dbm, UpLinkCounter: "); Serial.print(LoRaWAN.getUpLinkCounter()); Serial.print(", DownLinkCounter: "); Serial.print(LoRaWAN.getDownLinkCounter()); Serial.println(" )"); LoRaWAN.beginPacket(); LoRaWAN.write(0xef); LoRaWAN.endPacket(); } delay(10000); }