RadioLib: Seeed-Studio LoRa-E5-Mini LoRaWAN OTAA timeout
Using the E5 dev board (https://www.seeedstudio.com/LoRa-E5-mini-STM32WLE5JC-p-4869.html), I can get chirpstack to recieve a JoinRequest and issue a JoinAccept however RadioLib provides a timeout error (-6).
I don’t know if I am setting the RFSwitches correctly:
////////////////////////////////////////////////////////////////////////////////////////////
#include <Arduino.h>
#include <RadioLib.h>
// no need to configure pins, signals are routed to the radio internally
STM32WLx radio = new STM32WLx_Module();
// create the node instance on the US-915 band
// using the radio module and the encryption key
// make sure you are using the correct band
// based on your geographical location!
LoRaWANNode node(&radio, &US915);
// using PA0 as a placeholder since the E5-mini does not have the PC3 connection
//ref: https://github.com/Seeed-Studio/LoRaWan-E5-Node
static const uint32_t rfswitch_pins[] = {PA0, PA4, PA5}; //TX received in chirpstack
//static const uint32_t rfswitch_pins[] = {PA0, PA5, PA4}; // no response
//static const uint32_t rfswitch_pins[] = {PA4, PA0, PA5}; //TX received in chirpstack
//static const uint32_t rfswitch_pins[] = {PA4, PA5, PA0}; // no response
//static const uint32_t rfswitch_pins[] = {PA5, PA0, PA4}; //TX received in chirpstack
//static const uint32_t rfswitch_pins[] = {PA5, PA4, PA0}; //TX received in chirpstack
static const Module::RfSwitchMode_t rfswitch_table[] = {
{STM32WLx::MODE_IDLE, {LOW, LOW, LOW}},
{STM32WLx::MODE_RX, {HIGH, HIGH, LOW}},
{STM32WLx::MODE_TX_LP, {HIGH, HIGH, HIGH}},
{STM32WLx::MODE_TX_HP, {HIGH, LOW, HIGH}},
END_OF_MODE_TABLE,
};
void setup() {
Serial.begin(115200);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);
int state = radio.begin();
if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while(true);
}
// 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!
// node.wipe();
// application identifier - pre-LoRaWAN 1.1.0, this was called appEUI
// when adding new end device in TTN, you will have to enter this number
// you can pick any number you want, but it has to be unique
uint64_t joinEUI = 0x12AD1011B0C0FFEE;
// device identifier - this number can be anything
// when adding new end device in TTN, you can generate this number,
// or you can set any value you want, provided it is also unique
uint64_t devEUI = 0x70B3D57ED005E120;
// select some encryption keys which will be used to secure the communication
// there are two of them - network key and application key
// because LoRaWAN uses AES-128, the key MUST be 16 bytes (or characters) long
// network key is the ASCII string "topSecretKey1234"
uint8_t nwkKey[] = { 0x74, 0x6F, 0x70, 0x53, 0x65, 0x63, 0x72, 0x65,
0x74, 0x4B, 0x65, 0x79, 0x31, 0x32, 0x33, 0x34 };
//746F705365637265744B657931323334
// application key is the ASCII string "aDifferentKeyABC"
uint8_t appKey[] = { 0x61, 0x44, 0x69, 0x66, 0x66, 0x65, 0x72, 0x65,
0x6E, 0x74, 0x4B, 0x65, 0x79, 0x41, 0x42, 0x43 };
//61446966666572656E744B6579414243
// prior to LoRaWAN 1.1.0, only a single "nwkKey" is used
// when connecting to LoRaWAN 1.0 network, "appKey" will be disregarded
// and can be set to NULL
// some frequency bands only use a subset of the available channels
// you can set the starting channel and their number
// for example, the following corresponds to US915 FSB2 in TTN
/*
node.startChannel = 8;
node.numChannels = 8;
*/
// now we can start the activation
// this can take up to 20 seconds, and requires a LoRaWAN gateway in range
Serial.print(F("[LoRaWAN] Attempting over-the-air activation ... "));
state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);
if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while(true);
}
/////////////////////////////////////////////////////////////////////////////////////////// The remainder of the STM32WLx_Transmit_Interrupt.ino code is unchanged.
Serial terminal output:
[LoRa-E5] Initializing ... success!
[LoRaWAN] Attempting over-the-air activation ... failed, code -6
///////////////////////////////////////////////////////////////////////////////////////////
Is this a RF Switch issue?
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Comments: 20 (7 by maintainers)
Commits related to this issue
- [LoRaWAN] Fixed debug float print (#844) — committed to jgromes/RadioLib by jgromes 9 months ago
- [STM32WLx] Added missing interrupt actions (#844) — committed to jgromes/RadioLib by jgromes 9 months ago
Then it is rather strange that chirpstack sends RekeyInd with revision set to 0. MIC calculation changed quite a lot across different LoRaWAN versions, so if there is some mismatch there it could cause this issue. I’m confident it’s correct on RadioLib end, since I’ve tested extensively against TTN on v1.1.
It’s just the MAC command being sent from server to the node without any user data, that’s not uncommon.
@gpabdo Throw this near the top of BuildOpt.h
#define RADIOLIB_DEBUG
I’ve then added my own debug statements with RADIOLIB_DEBUG_PRINTLN(“… %d”, val);