Code 1: The final (non-working) RadioLib
SPI code
// This code compiles, initializes the radio successfully,
// but the gateway never receives a Join Request.
#include <RadioLib.h>
// ANONYMIZED KEYS
uint64_t devEUI = 0x0102030405060708;
uint64_t joinEUI = 0x0807060504030201;
uint8_t appKey[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
// Pin definitions confirmed from official docs
#define PIN_LORA_NSS (4)
#define PIN_LORA_DIO1 (1)
#define PIN_LORA_NRST (2)
#define PIN_LORA_BUSY (3)
#define PIN_LORA_RFSW (5)
SX1262 radio = new Module(PIN_LORA_NSS, PIN_LORA_DIO1, PIN_LORA_NRST, PIN_LORA_BUSY);
LoRaWANNode node(&radio, &EU868);
void setup() {
Serial.begin(115200);
while(!Serial);
int state = radio.begin();
if (state != RADIOLIB_ERR_NONE) {
Serial.printf("Radio init failed: %d\n", state);
while(true);
}
radio.setDio2AsRfSwitch(true);
radio.setRfSwitchPins(PIN_LORA_RFSW, RADIOLIB_NC);
node.beginOTAA(joinEUI, devEUI, appKey, appKey);
}
void loop() {
// Fails here with -1101
node.sendReceive("A", 1);
delay(60000);
}
Code 2: The simple UART test that FAILS TO COMPILE
// This simple code fails to compile with "undefined reference to 'Serial'"
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.println("Test");
Serial1.begin(9600);
}
void loop() {
if (Serial1.available()) {
Serial.write(Serial1.read());
}
if (Serial.available()) {
Serial1.write(Serial.read());
}
}