85 lines
3 KiB
C
85 lines
3 KiB
C
|
|
#include <RadioLib.h>
|
|
|
|
// How often to send an uplink - consider legal & FUP constraints - see notes
|
|
uint32_t uplinkInterval = 3 * 60 * 1000; // minutes x seconds x milliseconds
|
|
|
|
uint64_t joinEUI = 0x0000000000000000;
|
|
uint64_t devEUI = 0x0000000000000000;
|
|
uint8_t appKey[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
uint8_t nwkKey[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
|
|
|
|
|
|
// 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 ...
|
|
|
|
// Auto select MCU <-> radio connections
|
|
// If you get an error message when compiling, it may be that the
|
|
// pinmap could not be determined - see the notes for more info
|
|
|
|
#if defined(ARDUINO_TTGO_LORA32_V1)
|
|
#pragma message ("TTGO LoRa32 v1 - no Display")
|
|
SX1276 radio = new Module(18, 26, 14, 33);
|
|
|
|
// #elif defined(ARDUINO_TTGO_LORA32_V2)
|
|
// #pragma error ("ARDUINO_TTGO_LORA32_V2 awaiting pin map")
|
|
|
|
#elif defined(ARDUINO_TTGO_LoRa32_v21new) // T3_V1.6.1
|
|
#pragma message ("Using TTGO LoRa32 v2.1 marked T3_V1.6.1 + Display")
|
|
SX1276 radio = new Module(18, 26, 14, 33);
|
|
|
|
// #elif defined(ARDUINO_TBEAM_USE_RADIO_SX1262)
|
|
// #pragma error ("ARDUINO_TBEAM_USE_RADIO_SX1262 awaiting pin map")
|
|
|
|
// #elif defined(ARDUINO_TBEAM_USE_RADIO_SX1276)
|
|
// #pragma message ("Using TTGO LoRa32 v2.1 marked T3_V1.6.1 + Display")
|
|
// SX1276 radio = new Module(18, 26, 23, 33);
|
|
|
|
// #elif defined(ARDUINO_HELTEC_WIFI_LORA_32)
|
|
// #pragma error ("ARDUINO_HELTEC_WIFI_LORA_32 awaiting pin map")
|
|
|
|
#elif defined(ARDUINO_heltec_wifi_kit_32_V2)
|
|
#pragma message ("ARDUINO_heltec_wifi_kit_32_V2 awaiting pin map")
|
|
SX1276 radio = new Module(18, 26, 14, 35);
|
|
|
|
#elif defined(ARDUINO_heltec_wifi_kit_32_V3)
|
|
#pragma message ("Using Heltec WiFi LoRa32 v3 - Display + USB-C")
|
|
SX1262 radio = new Module(8, 14, 12, 13);
|
|
|
|
// #elif defined(ARDUINO_CUBECELL_BOARD)
|
|
// #pragma message ("Using TTGO LoRa32 v2.1 marked T3_V1.6.1 + Display")
|
|
// SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
|
|
|
// #elif defined(ARDUINO_CUBECELL_BOARD_V2)
|
|
// #pragma error ("ARDUINO_CUBECELL_BOARD_V2 awaiting pin map")
|
|
|
|
#elif defined(ARDUINO_SAMD_FEATHER_M0)
|
|
#pragma message ("Adafruit Feather M0 with RFM95")
|
|
#pragma message ("Link required on board")
|
|
SX1276 radio = new Module(8, 3, 4, 6);
|
|
|
|
#else
|
|
#pragma message ("Unknown board - no pinmap")
|
|
SX1262 radio = new Module(8, 14, 12, 13);
|
|
|
|
#endif
|
|
|
|
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);
|
|
}
|
|
}
|