#ifndef _CONFIG_H #define _CONFIG_H #include // first you have to set your radio model and pin configuration // this is provided just as a default example SX1278 radio = new Module(10, 2, 9, 3); // if you have RadioBoards (https://github.com/radiolib-org/RadioBoards) // and are using one of the supported boards, you can do the following: /* #define RADIO_BOARD_AUTO #include Radio radio = new RadioModule(); */ // how often to send an uplink - consider legal & FUP constraints const uint32_t uplinkIntervalSeconds = 1UL * 60UL; // minutes x seconds #define LORAWAN_VERSION (0) // use version 1.LORAWAN_VERSION when joining #define LORAWAN_OTAA (1) // use OTAA (1) or ABP (0) #if (LORAWAN_OTAA == 1) // joinEUI - previous versions of LoRaWAN called this AppEUI // for development purposes you can use all zeros - see wiki for details #define RADIOLIB_LORAWAN_JOIN_EUI 0x0000000000000000 // the Device EUI & two keys can be generated on the TTN console #ifndef RADIOLIB_LORAWAN_DEV_EUI // Replace with your Device EUI #define RADIOLIB_LORAWAN_DEV_EUI 0x---------------- #endif #ifndef RADIOLIB_LORAWAN_APP_KEY // Replace with your App Key #define RADIOLIB_LORAWAN_APP_KEY 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x-- #endif // copy over the EUI's & keys in to the something that will not compile if incorrectly formatted uint64_t joinEUI = RADIOLIB_LORAWAN_JOIN_EUI; uint64_t devEUI = RADIOLIB_LORAWAN_DEV_EUI; uint8_t appKey[] = { RADIOLIB_LORAWAN_APP_KEY }; #if (LORAWAN_VERSION == 1) #ifndef RADIOLIB_LORAWAN_NWK_KEY // Put your Nwk Key here #define RADIOLIB_LORAWAN_NWK_KEY 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x-- #endif uint8_t nwkKey[] = { RADIOLIB_LORAWAN_NWK_KEY }; // LW v1.1 only #endif #else // ABP #ifndef RADIOLIB_LORAWAN_DEV_ADDR // Replace with your DevAddr #define RADIOLIB_LORAWAN_DEV_ADDR 0x------ #endif #ifndef RADIOLIB_LORAWAN_NWKSENC_KEY // Replace with your NwkSEnc Key #define RADIOLIB_LORAWAN_NWKSENC_KEY 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x-- #endif #ifndef RADIOLIB_LORAWAN_APPS_KEY // Replace with your AppS Key #define RADIOLIB_LORAWAN_APPS_KEY 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x-- #endif // copy over the keys in to the something that will not compile if incorrectly formatted uint32_t devAddr = RADIOLIB_LORAWAN_DEV_ADDR; uint8_t sNwkSEncKey[] = { RADIOLIB_LORAWAN_NWKSENC_KEY }; uint8_t appSKey[] = { RADIOLIB_LORAWAN_APPS_KEY }; #if (LORAWAN_VERSION == 1) #ifndef RADIOLIB_LORAWAN_FNWKSINT_KEY // Replace with your FNwkSInt Key #define RADIOLIB_LORAWAN_FNWKSINT_KEY 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x-- #endif #ifndef RADIOLIB_LORAWAN_SNWKSINT_KEY // Replace with your SNwkSInt Key #define RADIOLIB_LORAWAN_SNWKSINT_KEY 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x--, 0x-- #endif uint8_t fNwkSIntKey[] = { RADIOLIB_LORAWAN_FNWKSINT_KEY }; // LW v1.1 only uint8_t sNwkSIntKey[] = { RADIOLIB_LORAWAN_SNWKSINT_KEY }; // LW v1.1 only #endif #endif // OTAA/ABP // for the curious, the #ifndef blocks allow for automated testing &/or you can // put your EUI & keys in to your platformio.ini - see wiki for more tips // regional choices: EU868, US915, AU915, AS923, IN865, KR920, CN780, CN500 const LoRaWANBand_t Region = EU868; const uint8_t subBand = 0; // For US915, change this to 2, otherwise leave on 0 // ============================================================================ // Below is to support the sketch - only make changes if the notes say so ... // create the LoRaWAN node LoRaWANNode node(&radio, &Region, subBand); // helper function to display any issues void debug(bool isFail, const __FlashStringHelper* message, int state, bool Freeze) { if (isFail) { Serial.print(message); Serial.print("("); Serial.print(state); Serial.println(")"); while (Freeze); } } // helper function to display a byte array void arrayDump(uint8_t *buffer, uint16_t len) { for(uint16_t c = 0; c < len; c++) { char b = buffer[c]; if(b < 0x10) { Serial.print('0'); } Serial.print(b, HEX); } Serial.println(); } #endif