Hey @beegee - sorry I am quite time limited right now, so I am sorry that I could not do much more than a quick look: I was able install the latest lib directly from Github for Arduino as well as the needed RPI_PICO_TimerInterrupt. Compiling with the latest Arduino Pico BSP set to RAK11300 worked.
I needed to change the LoRaWAN parameters to be more in line with my EU868 network:
// Define LoRa parameters
#define RF_FREQUENCY 868300000 // Hz
#define TX_OUTPUT_POWER 22 // dBm
#define LORA_BANDWIDTH 0 // [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved]
#define LORA_SPREADING_FACTOR 7 // [SF7..SF12]
#define LORA_CODINGRATE 1 // [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
#define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx
#define LORA_SYMBOL_TIMEOUT 0 // Symbols
#define LORA_FIX_LENGTH_PAYLOAD_ON false
#define LORA_IQ_INVERSION_ON false
#define RX_TIMEOUT_VALUE 0
#define TX_TIMEOUT_VALUE 3000
as well as load the EU868 region:
// Initialize LoRaWan
uint32_t err_code = lmh_init(&lora_callbacks, lora_param_init, true, CLASS_A, LORAMAC_REGION_EU868);
with that changes I could see within ChirpStack that the node sent join requests and also got acknowledgements sent back.
For unknown reason however, it seems like the node does not see any acknowledgement:
Setup LoRaWAN
Join LoRaWAN
OVER_THE_AIR_ACTIVATION failed!
Check your EUI's and Keys's!
Check if a Gateway is in range!
Did not join network, skip sending frame
OVER_THE_AIR_ACTIVATION failed!
Check your EUI's and Keys's!
Check if a Gateway is in range!
Did not join network, skip sending frame
OVER_THE_AIR_ACTIVATION failed!
Check your EUI's and Keys's!
Check if a Gateway is in range!
Did not join network, skip sending frame
OVER_THE_AIR_ACTIVATION failed!
Check your EUI's and Keys's!
Check if a Gateway is in range!
Did not join network, skip sending frame
I do not know what happens here - I also wondered how to set the Network key in your lib, however as I had network key set the same as the application key, it seemed to be working fine.
As the gateway sends out JoinAccept, it looks promising, I am not sure why the node does not pick this up, however as I said that was all that I could do, I sadly will not have more time to look into it.
In regards to RadioLib I am a bit stunned that it did not work out for you. Most important thing is to use the latest Arduino Pico and latest RadioLib. The use of the lib is a bit complicated at the start and this is not yet communicated in the right way. Looking at my example posted at the end of my blog it does not show the whole reality.
On the first bootup, you have to setup like this. With that it will erase the virtual EEPROM and do an OTAA as well as save the OTAA information in said EEPROM.
// first we need to initialize the device storage
// this will reset all persistently stored parameters
// NOTE: This should only be done once prior to first joining a network!
// After wiping persistent storage, you will also have to reset
// the end device in TTN and perform the join procedure again!
// Here, a delay is added to make sure that during re-flashing
// the .wipe() is not triggered and the session is lost
delay(5000);
node.wipe();
// now we can start the activation
// Serial.print(F("[LoRaWAN] Attempting over-the-air activation ... "));
uint64_t joinEUI = 0x12AD1011B0C0FFEE;
uint64_t devEUI = 0x70B3D57ED005E120;
uint8_t nwkKey[] = { 0x74, 0x6F, 0x70, 0x53, 0x65, 0x63, 0x72, 0x65,
0x74, 0x4B, 0x65, 0x79, 0x31, 0x32, 0x33, 0x34 };
uint8_t appKey[] = { 0x61, 0x44, 0x69, 0x66, 0x66, 0x65, 0x72, 0x65,
0x6E, 0x74, 0x4B, 0x65, 0x79, 0x41, 0x42, 0x43 };
state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);
// after the device has been activated,
// the session can be restored without rejoining after device power cycle
// on EEPROM-enabled boards by calling "restore"
//Serial.print(F("[LoRaWAN] Resuming previous session ... "));
//state = node.restore();
if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while(true);
}
your session/join should work now, let it run for a bit so that it can save the info to the EEPROM. If you (in the future) do not want to OTAA on each boot up, you should shutdown your node, hold the boot button, connect it again to USB (with that the U2F bootloader will come up and the device will not boot - which is important - as it would erase the EEPROM again ;).
You then need to change the same code area again to following:
// first we need to initialize the device storage
// this will reset all persistently stored parameters
// NOTE: This should only be done once prior to first joining a network!
// After wiping persistent storage, you will also have to reset
// the end device in TTN and perform the join procedure again!
// Here, a delay is added to make sure that during re-flashing
// the .wipe() is not triggered and the session is lost
// delay(5000);
// node.wipe();
// now we can start the activation
// Serial.print(F("[LoRaWAN] Attempting over-the-air activation ... "));
// uint64_t joinEUI = 0x12AD1011B0C0FFEE;
// uint64_t devEUI = 0x70B3D57ED005E120;
// uint8_t nwkKey[] = { 0x74, 0x6F, 0x70, 0x53, 0x65, 0x63, 0x72, 0x65,
// 0x74, 0x4B, 0x65, 0x79, 0x31, 0x32, 0x33, 0x34 };
// uint8_t appKey[] = { 0x61, 0x44, 0x69, 0x66, 0x66, 0x65, 0x72, 0x65,
// 0x6E, 0x74, 0x4B, 0x65, 0x79, 0x41, 0x42, 0x43 };
// state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);
// after the device has been activated,
// the session can be restored without rejoining after device power cycle
// on EEPROM-enabled boards by calling "restore"
Serial.print(F("[LoRaWAN] Resuming previous session ... "));
state = node.restore();
if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while(true);
}
so that it will not do OTAA but just restore the saved session from the EEPROM and join with that info.
All the best