RadioLib: ABP does not work on SX1262 EU868 with Platformio - There are no channels defined - are you in ABP mode with no defined subband?
Background
I have taken the LoRaWAN example and managed to connect to TTN.
I have set up two devices in TTN to test this issue for APB mode and OTAA mode respectively.
Using the LoRaWAN MAC V1.1.0 I ran into the DevNonce is too smal issue, which is not the topic of discussion here
Device and library info
- LoRaWAN specs: LoRaWAN V1.0.4
- LoRa Network: The Things Network
- Controller: ESP32 - Devkit V4
- LoRa module: WaveShare Lora Node (HF) [SX1262]
- Frequency plan: EU868
- IDE Environment: VSCode + Platformio (Library pulled from platformio)
- RadioLib version: 6.4.0
- Framework:
- framework-arduinoespressif32 @ 3.20009.0 (2.0.9)
- tool-esptoolpy @ 1.40501.0 (4.5.1)
- tool-mkfatfs @ 2.0.1
- tool-mklittlefs @ 1.203.210628 (2.3)
- tool-mkspiffs @ 2.230.0 (2.30)
- toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
- And also:
- framework-arduinoespressif32 @ 3.20014.231204 (2.0.14)
Behaviour: “There are no channels defined - are you in ABP mode with no defined subband?”
The initial OTAA is successful and successfully transmits data. However, once the device looses power (reset) it tries to connect using the APB mode as it now has the correct keys. This is where the error occurs. I can also confirm this is the default behaviour when using ABP mode directly.
The only way I can get around this is to allow the device in TTN settings to reset the nonces and force the OTAA to run every time it starts up, which is not ideal.
Sketch
Please note that the ESP sleep function puts it into deep sleep and essentially restarts on wake. This is why it is essential for the connection to re-establish after a power down event.
#include <Arduino.h>
#include <low_power.h>
#include <Ticker.h>
// This was needed for compilation issues
#include <RadioLib.h>
#include <pins.h>
// ------------------- SETTINGS -------------------
#define TCXO_PRESENT 1 // Temperature compensated crystal oscillator present
#define USE_OTAA 1 // 1 for OTAA, 0 for ABP
#define SPREAD_FACTOR 9U // LoRaWAN SF
#define SLEEP 0 // Sleep between transmissions
// ------------------- SETTINGS -------------------
SX1262 radio = new Module(loraPins.cs, loraPins.dio1, loraPins.reset, loraPins.busy);
LoRaWANNode node(&radio, &EU868);
#if USE_OTAA
uint64_t deviceEUI = 0x1122333444455555; // Redacted
uint64_t joinEUI = 0x1111111111111111; // Redacted
uint8_t nwkKey[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // Redacted
uint8_t appKey[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // Redacted
#else
uint32_t devAddr = 0x12345678;
uint64_t deviceEUI = 0x1122333444455555;
uint8_t nwkSKey[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // Redacted
uint8_t appSKey[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // Redacted
uint8_t fNwkSIntKey[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // Redacted
uint8_t sNwkSIntKey[] = {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // Redacted
#endif
void setup()
{
Serial.begin(115200);
// I need to specify these manually as the module I use did not start correctly due to TXCO and useRegulatorLDO
int state = radio.begin(868.8F, 125.0F, SPREAD_FACTOR, 7, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, 20, 8, TCXO_PRESENT ? 1.6F : 0, TCXO_PRESENT ? true : false);
TCXO_PRESENT ? radio.XTAL = true : radio.XTAL = false;
delay(1);
while (state != RADIOLIB_ERR_NONE)
{
Serial.printf("failed to start radio, code: %i\n", state);
while (1)
;
}
Serial.printf("Radio started successfully!\n");
#if USE_OTAA
// This is the only way to get it to work, force the device to use OTAA to
// provision on each connection as recurring connections attempt to use ABP
// and fail... Ensure that the device can reset join nonces in the TTN settings (Join settings)
// state = node.beginOTAA(joinEUI, deviceEUI, appKey, appKey, 255, true);
state = node.beginOTAA(joinEUI, deviceEUI, appKey, appKey, 255, false); // Causes crash
#else
// Does not work
state = node.beginABP(devAddr, nwkSKey, appSKey, fNwkSIntKey, sNwkSIntKey);
#endif
if (state >= RADIOLIB_ERR_NONE)
{
Serial.printf("successfully started node!");
}
else
{
Serial.printf("failed to start LoRaWAN node, code: %i\n", state);
while (1)
;
}
}
void loop()
{
// send uplink to port 10
Serial.print(F("[LoRaWAN] Sending uplink packet ... "));
String strUp = String("Hello world!");
String strDown;
int state = node.sendReceive(strUp, 10, strDown);
if (state == RADIOLIB_ERR_NONE)
{
Serial.println(F("received a downlink!"));
// print data of the packet (if there are any)
Serial.print(F("[LoRaWAN] Data:\t\t"));
if (strDown.length() > 0)
{
Serial.println(strDown);
}
else
{
Serial.println(F("<MAC commands only>"));
}
// print RSSI (Received Signal Strength Indicator)
Serial.print(F("[LoRaWAN] RSSI:\t\t"));
Serial.print(radio.getRSSI());
Serial.println(F(" dBm"));
// print SNR (Signal-to-Noise Ratio)
Serial.print(F("[LoRaWAN] SNR:\t\t"));
Serial.print(radio.getSNR());
Serial.println(F(" dB"));
// print frequency error
Serial.print(F("[LoRaWAN] Frequency error:\t"));
Serial.print(radio.getFrequencyError());
Serial.println(F(" Hz"));
}
else if (state == RADIOLIB_ERR_RX_TIMEOUT)
{
Serial.println(F("no downlink!"));
}
else
{
Serial.print(F("failed, code "));
Serial.println(state);
}
// wait before sending another packet
uint32_t minimumDelay = 60000; // try to send once every minute
uint32_t interval = node.timeUntilUplink(); // calculate minimum duty cycle delay (per law!)
uint32_t delayMs = max(interval, minimumDelay); // cannot send faster than duty cycle allows
#if SLEEP
// This puts the ESP into deep sleep, will restart on wake
deepSleepFor(delayMs * 1000);
// Can be replaced with the following for testing:
// delay(delayMs);
// ESP.restart();
#else
delay(delayMs);
#endif
}
Debug mode output – Failure on restart
(12:26:31.530) rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
(12:26:31.548) configsip: 0, SPIWP:0xee
(12:26:31.548) clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
(12:26:31.548) mode:DIO, clock div:2
(12:26:31.548) load:0x3fff0030,len:1184
(12:26:31.548) load:0x40078000,len:13192
(12:26:31.560) load:0x40080400,len:3028
(12:26:31.560) entry 0x400805e4
(12:26:31.721) [nvs_utils.cpp:9->nvsInit()]: Initialising EEPROM
(12:26:31.721) [nvs_utils.cpp:26->nvsInit()]: EEPROM initialised
(12:26:31.731)
(12:26:31.731) RadioLib Debug Info
(12:26:31.731) Version: 6.4.0.0
(12:26:31.731) Platform: ESP32
(12:26:31.731) Compiled: Feb 1 2024 12:24:25
(12:26:31.731)
(12:26:31.731) CMDW 80
(12:26:31.744) SI 0
(12:26:31.744) SO AA
(12:26:31.757) CMDW 80
(12:26:31.757) SI 0
(12:26:31.757) SO A2
(12:26:31.757) CMDR C0
(12:26:31.757) SI 0
(12:26:31.757) SO 22
(12:26:31.757) CMDR 1D 3 20
(12:26:31.757) SI 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
(12:26:31.757) SO A2 53 58 31 32 36 31 20 56 32 44 20 32 44 30 32 0
(12:26:31.757) Found SX126x: RADIOLIB_SX126X_REG_VERSION_STRING:
(12:26:31.778) 0000320 53 58 31 32 36 31 20 56 32 44 20 32 44 30 32 00 | SX1261 V2D 2D02.
(12:26:31.778)
(12:26:31.778) M SX126x
(12:26:31.778) CMDW 80
(12:26:31.778) SI 0
(12:26:31.778) SO AA
(12:26:31.798) CMDW 80
(12:26:31.798) SI 0
(12:26:31.798) SO A2
(12:26:31.798) CMDR C0
(12:26:31.798) SI 0
(12:26:31.798) SO 22
(12:26:31.798) CMDW 80
(12:26:31.798) SI 0
(12:26:31.798) SO A2
(12:26:31.798) CMDR C0
(12:26:31.798) SI 0
(12:26:31.798) SO 22
(12:26:31.798) CMDW 80
(12:26:31.798) SI 0
(12:26:31.798) SO A2
(12:26:31.798) CMDR C0
(12:26:31.798) SI 0
(12:26:31.798) SO 22
(12:26:31.798) CMDR 17
(12:26:31.798) SI 0 0 0
(12:26:31.798) SO A2 0 20
(12:26:31.798) CMDR C0
(12:26:31.798) SI 0
(12:26:31.798) SO 22
(12:26:31.798) CMDW 7
(12:26:31.832) SI 0 0
(12:26:31.832) SO A2 A2
(12:26:31.832) CMDR C0
(12:26:31.832) SI 0
(12:26:31.832) SO 22
(12:26:31.832) CMDW 97
(12:26:31.832) SI 0 0 1 40
(12:26:31.832) SO A2 A2 A2 A2
(12:26:31.832) CMDR C0
(12:26:31.832) SI 0
(12:26:31.832) SO 22
(12:26:31.832) CMDW 8F
(12:26:31.832) SI 0 0
(12:26:31.832) SO A2 A2
(12:26:31.832) CMDR C0
(12:26:31.832) SI 0
(12:26:31.832) SO 22
(12:26:31.832) CMDW 8A
(12:26:31.832) SI 1
(12:26:31.832) SO A2
(12:26:31.832) CMDR C0
(12:26:31.832) SI 0
(12:26:31.832) SO 22
(12:26:31.832) CMDW 93
(12:26:31.832) SI 20
(12:26:31.832) SO A2
(12:26:31.832) CMDR C0
(12:26:31.832) SI 0
(12:26:31.832) SO 22
(12:26:31.832) CMDW 88
(12:26:31.832) SI 3 16 A 0 0 0 0
(12:26:31.832) SO A2 A2 A2 A2 A2 A2 A2
(12:26:31.832) CMDR C0
(12:26:31.832) SI 0
(12:26:31.832) SO 22
(12:26:31.832) CMDW 2
(12:26:31.832) SI 43 FF
(12:26:31.832) SO A2 A2
(12:26:31.832) CMDR C0
(12:26:31.832) SI 0
(12:26:31.832) SO 22
(12:26:31.832) CMDW 8
(12:26:31.832) SI 0 0 0 0 0 0 0 0
(12:26:31.864) SO A2 A2 A2 A2 A2 A2 A2 A2
(12:26:31.864) CMDR C0
(12:26:31.864) SI 0
(12:26:31.864) SO 22
(12:26:31.864) CMDW 89
(12:26:31.864) SI 7F
(12:26:31.864) SO A2
(12:26:31.864) CMDR C0
(12:26:31.864) SI 0
(12:26:31.864) SO 22
(12:26:31.864) CMDR 11
(12:26:31.864) SI 0 0
(12:26:31.864) SO A2 1
(12:26:31.864) CMDR C0
(12:26:31.864) SI 0
(12:26:31.864) SO 22
(12:26:31.864) CMDW 8B
(12:26:31.864) SI 9 6 3 0
(12:26:31.864) SO A2 A2 A2 A2
(12:26:31.864) CMDR C0
(12:26:31.864) SI 0
(12:26:31.864) SO 22
(12:26:31.864) CMDR 11
(12:26:31.864) SI 0 0
(12:26:31.864) SO A2 1
(12:26:31.864) CMDR C0
(12:26:31.864) SI 0
(12:26:31.864) SO 22
(12:26:31.864) CMDW D 7 40
(12:26:31.864) SI 14 24
(12:26:31.864) SO A2 A2
(12:26:31.864) CMDR 11
(12:26:31.864) SI 0 0
(12:26:31.864) SO A2 1
(12:26:31.864) CMDR C0
(12:26:31.864) SI 0
(12:26:31.864) SO 22
(12:26:31.898) CMDR 1D 7 36
(12:26:31.898) SI 0 0
(12:26:31.898) SO A2 D
(12:26:31.898) CMDR C0
(12:26:31.898) SI 0
(12:26:31.898) SO 22
(12:26:31.898) CMDW D 7 36
(12:26:31.898) SI D
(12:26:31.898) SO A2
(12:26:31.898) CMDW 8C
(12:26:31.898) SI 0 8 0 FF 1 0
(12:26:31.898) SO A2 A2 A2 A2 A2 A2
(12:26:31.898) CMDR C0
(12:26:31.898) SI 0
(12:26:31.898) SO 22
(12:26:31.898) CMDW 96
(12:26:31.898) SI 0
(12:26:31.898) SO A2
(12:26:31.898) CMDR C0
(12:26:31.898) SI 0
(12:26:31.898) SO 22
(12:26:31.898) CMDW D 8 E7
(12:26:31.898) SI 18
(12:26:31.898) SO A2
(12:26:31.898) CMDW 9D
(12:26:31.898) SI 1
(12:26:31.898) SO A2
(12:26:31.898) CMDR C0
(12:26:31.898) SI 0
(12:26:31.898) SO 22
(12:26:31.898) CMDR 11
(12:26:31.898) SI 0 0
(12:26:31.898) SO A2 1
(12:26:31.898) CMDR C0
(12:26:31.898) SI 0
(12:26:31.898) SO 22
(12:26:31.898) CMDR 1D 7 36
(12:26:31.898) SI 0 0
(12:26:31.898) SO A2 D
(12:26:31.898) CMDR C0
(12:26:31.898) SI 0
(12:26:31.898) SO 22
(12:26:31.898) CMDW D 7 36
(12:26:31.898) SI D
(12:26:31.941) SO A2
(12:26:31.941) CMDW 8C
(12:26:31.941) SI 0 8 0 FF 1 0
(12:26:31.941) SO A2 A2 A2 A2 A2 A2
(12:26:31.941) CMDR C0
(12:26:31.941) SI 0
(12:26:31.941) SO 22
(12:26:31.941) CMDR 11
(12:26:31.941) SI 0 0
(12:26:31.941) SO A2 1
(12:26:31.941) CMDR C0
(12:26:31.941) SI 0
(12:26:31.941) SO 22
(12:26:31.941) CMDR 1D 7 36
(12:26:31.941) SI 0 0
(12:26:31.941) SO A2 D
(12:26:31.941) CMDR C0
(12:26:31.941) SI 0
(12:26:31.941) SO 22
(12:26:31.941) CMDW D 7 36
(12:26:31.941) SI D
(12:26:31.941) SO A2
(12:26:31.941) CMDW 8C
(12:26:31.941) SI 0 8 0 FF 1 0
(12:26:31.941) SO A2 A2 A2 A2 A2 A2
(12:26:31.941) CMDR C0
(12:26:31.941) SI 0
(12:26:31.941) SO 22
(12:26:31.941) CMDR 11
(12:26:31.941) SI 0 0
(12:26:31.941) SO A2 1
(12:26:31.941) CMDR C0
(12:26:31.941) SI 0
(12:26:31.941) SO 22
(12:26:31.941) CMDW 8B
(12:26:31.941) SI 9 6 3 0
(12:26:31.941) SO A2 A2 A2 A2
(12:26:31.941) CMDR C0
(12:26:31.941) SI 0
(12:26:31.941) SO 22
(12:26:31.941) CMDR 11
(12:26:31.941) SI 0 0
(12:26:31.941) SO A2 1
(12:26:31.941) CMDR C0
(12:26:31.941) SI 0
(12:26:31.941) SO 22
(12:26:31.941) CMDW 8B
(12:26:31.941) SI 9 4 3 0
(12:26:31.941) SO A2 A2 A2 A2
(12:26:31.941) CMDR C0
(12:26:31.941) SI 0
(12:26:31.941) SO 22
(12:26:31.980) CMDW 98
(12:26:31.980) SI D7 DB
(12:26:31.980) SO A2 A2
(12:26:31.980) CMDR C0
(12:26:31.980) SI 0
(12:26:31.980) SO 22
(12:26:31.980) CMDW 86
(12:26:31.980) SI 36 4C CC C0
(12:26:31.980) SO A2 A2 A2 A2
(12:26:31.980) CMDR C0
(12:26:31.980) SI 0
(12:26:31.980) SO 22
(12:26:31.980) CMDR 1D 8 D8
(12:26:31.980) SI 0 0
(12:26:31.980) SO A2 C8
(12:26:31.980) CMDR C0
(12:26:31.980) SI 0
(12:26:31.980) SO 22
(12:26:31.980) CMDW D 8 D8
(12:26:31.980) SI DE
(12:26:31.980) SO A2
(12:26:31.980) CMDR 1D 8 E7
(12:26:31.980) SI 0 0
(12:26:31.980) SO A2 18
(12:26:31.980) CMDR C0
(12:26:31.980) SI 0
(12:26:31.980) SO 22
(12:26:31.980) CMDW 95
(12:26:31.980) SI 4 7 0 1
(12:26:31.980) SO A2 A2 A2 A2
(12:26:31.980) CMDR C0
(12:26:31.980) SI 0
(12:26:31.980) SO 22
(12:26:31.980) CMDW 8E
(12:26:31.980) SI 14 4
(12:26:31.980) SO A2 A2
(12:26:31.980) CMDR C0
(12:26:31.980) SI 0
(12:26:31.980) SO 22
(12:26:31.980) CMDW D 8 E7
(12:26:31.980) SI 18
(12:26:31.980) SO A2
(12:26:32.020) [main.cpp:89->setup()]: Radio started successfully!
(12:26:32.020) LoRaWAN node not present... Attempting over-the-air activation ... Found existing session; restoring...
(12:26:32.020) LoRaWAN session: v1.0
(12:26:32.059) Setting up dynamic channels
(12:26:32.059) Channel UL/DL 0 frequency = 868.099976 MHz
(12:26:32.059) Channel UL/DL 1 frequency = 868.299988 MHz
(12:26:32.059) Channel UL/DL 2 frequency = 868.500000 MHz
(12:26:32.059) exe MAC CID = 07, len = 5
(12:26:32.059) New channel: index = 3, freq = 867.099976 MHz, maxDr = 5, minDr = 0
(12:26:32.059) CMDW 98
(12:26:32.059) SI D7 DB
(12:26:32.059) SO A2 A2
(12:26:32.059) CMDR C0
(12:26:32.059) SI 0
(12:26:32.059) SO 22
(12:26:32.059) CMDW 86
(12:26:32.059) SI 36 31 99 80
(12:26:32.059) SO A2 A2 A2 A2
(12:26:32.059) CMDR C0
(12:26:32.059) SI 0
(12:26:32.059) SO 22
(12:26:32.059) UL: 3 1 867.10 (0 - 5) | DL: 3 1 867.10 (0 - 5)
(12:26:32.106) exe MAC CID = 07, len = 5
(12:26:32.106) New channel: index = 4, freq = 867.299988 MHz, maxDr = 5, minDr = 0
(12:26:32.106) CMDW 98
(12:26:32.106) SI D7 DB
(12:26:32.106) SO A2 A2
(12:26:32.106) CMDR C0
(12:26:32.106) SI 0
(12:26:32.106) SO 22
(12:26:32.106) CMDW 86
(12:26:32.106) SI 36 34 CC C0
(12:26:32.106) SO A2 A2 A2 A2
(12:26:32.106) CMDR C0
(12:26:32.106) SI 0
(12:26:32.106) SO 22
(12:26:32.106) UL: 4 1 867.30 (0 - 5) | DL: 4 1 867.30 (0 - 5)
(12:26:32.106) exe MAC CID = 07, len = 5
(12:26:32.106) New channel: index = 5, freq = 867.500000 MHz, maxDr = 5, minDr = 0
(12:26:32.106) CMDW 98
(12:26:32.106) SI D7 DB
(12:26:32.106) SO A2 A2
(12:26:32.106) CMDR C0
(12:26:32.106) SI 0
(12:26:32.106) SO 22
(12:26:32.106) CMDW 86
(12:26:32.106) SI 36 38 0 0
(12:26:32.106) SO A2 A2 A2 A2
(12:26:32.106) CMDR C0
(12:26:32.106) SI 0
(12:26:32.106) SO 22
(12:26:32.106) UL: 5 1 867.50 (0 - 5) | DL: 5 1 867.50 (0 - 5)
(12:26:32.139) exe MAC CID = 07, len = 5
(12:26:32.139) New channel: index = 6, freq = 867.700012 MHz, maxDr = 5, minDr = 0
(12:26:32.139) CMDW 98
(12:26:32.139) SI D7 DB
(12:26:32.139) SO A2 A2
(12:26:32.139) CMDR C0
(12:26:32.139) SI 0
(12:26:32.139) SO 22
(12:26:32.139) CMDW 86
(12:26:32.139) SI 36 3B 33 40
(12:26:32.139) SO A2 A2 A2 A2
(12:26:32.139) CMDR C0
(12:26:32.139) SI 0
(12:26:32.139) SO 22
(12:26:32.139) UL: 6 1 867.70 (0 - 5) | DL: 6 1 867.70 (0 - 5)
(12:26:32.139) exe MAC CID = 07, len = 5
(12:26:32.139) New channel: index = 7, freq = 867.900024 MHz, maxDr = 5, minDr = 0
(12:26:32.171) CMDW 98
(12:26:32.171) SI D7 DB
(12:26:32.171) SO A2 A2
(12:26:32.171) CMDR C0
(12:26:32.171) SI 0
(12:26:32.171) SO 22
(12:26:32.171) CMDW 86
(12:26:32.171) SI 36 3E 66 80
(12:26:32.171) SO A2 A2 A2 A2
(12:26:32.171) CMDR C0
(12:26:32.171) SI 0
(12:26:32.171) SO 22
(12:26:32.171) UL: 7 1 867.90 (0 - 5) | DL: 7 1 867.90 (0 - 5)
(12:26:32.171) exe MAC CID = 03, len = 4
(12:26:32.171) ADR REQ: dataRate = 2, txPower = 0, chMask = 0x0000, chMaskCntl = 00, nbTrans = 0
(12:26:32.171) CMDR 1D 8 E7
(12:26:32.171) SI 0 0
(12:26:32.171) SO A2 18
(12:26:32.171) CMDR C0
(12:26:32.171) SI 0
(12:26:32.171) SO 22
(12:26:32.202) CMDW 95
(12:26:32.202) SI 4 7 0 1
(12:26:32.202) SO A2 A2 A2 A2
(12:26:32.202) CMDR C0
(12:26:32.202) SI 0
(12:26:32.202) SO 22
(12:26:32.202) CMDW 8E
(12:26:32.202) SI 10 4
(12:26:32.202) SO A2 A2
(12:26:32.202) CMDR C0
(12:26:32.202) SI 0
(12:26:32.202) SO 22
(12:26:32.202) CMDW D 8 E7
(12:26:32.202) SI 18
(12:26:32.202) SO A2
(12:26:32.202) ADR channel 0: 1 --> 0
(12:26:32.202) ADR channel 1: 1 --> 0
(12:26:32.202) ADR channel 2: 1 --> 0
(12:26:32.202) ADR channel 3: 1 --> 0
(12:26:32.202) ADR channel 4: 1 --> 0
(12:26:32.202) ADR channel 5: 1 --> 0
(12:26:32.202) ADR channel 6: 1 --> 0
(12:26:32.202) ADR channel 7: 1 --> 0
(12:26:32.205) ADR channel 0: 0 --> 0
(12:26:32.205) ADR channel 0: 0 --> 0
(12:26:32.205) ADR channel 0: 0 --> 0
(12:26:32.209) ADR channel 0: 0 --> 0
(12:26:32.209) ADR channel 0: 0 --> 0
(12:26:32.209) ADR channel 0: 0 --> 0
(12:26:32.214) ADR channel 0: 0 --> 0
(12:26:32.214) ADR channel 0: 0 --> 0
(12:26:32.214) UL: 0 0 868.10 (0 - 5) | DL: 0 1 868.10 (0 - 5)
(12:26:32.250) UL: 1 0 868.30 (0 - 5) | DL: 1 1 868.30 (0 - 5)
(12:26:32.250) UL: 2 0 868.50 (0 - 5) | DL: 2 1 868.50 (0 - 5)
(12:26:32.250) UL: 3 0 867.10 (0 - 5) | DL: 3 1 867.10 (0 - 5)
(12:26:32.250) UL: 4 0 867.30 (0 - 5) | DL: 4 1 867.30 (0 - 5)
(12:26:32.250) UL: 5 0 867.50 (0 - 5) | DL: 5 1 867.50 (0 - 5)
(12:26:32.250) UL: 6 0 867.70 (0 - 5) | DL: 6 1 867.70 (0 - 5)
(12:26:32.250) UL: 7 0 867.90 (0 - 5) | DL: 7 1 867.90 (0 - 5)
(12:26:32.250) UL: 0 0 0.00 (0 - 0) | DL: 0 0 0.00 (0 - 0)
(12:26:32.253) UL: 0 0 0.00 (0 - 0) | DL: 0 0 0.00 (0 - 0)
(12:26:32.259) UL: 0 0 0.00 (0 - 0) | DL: 0 0 0.00 (0 - 0)
(12:26:32.265) UL: 0 0 0.00 (0 - 0) | DL: 0 0 0.00 (0 - 0)
(12:26:32.265) UL: 0 0 0.00 (0 - 0) | DL: 0 0 0.00 (0 - 0)
(12:26:32.293) UL: 0 0 0.00 (0 - 0) | DL: 0 0 0.00 (0 - 0)
(12:26:32.293) UL: 0 0 0.00 (0 - 0) | DL: 0 0 0.00 (0 - 0)
(12:26:32.293) UL: 0 0 0.00 (0 - 0) | DL: 0 0 0.00 (0 - 0)
(12:26:32.293) ADR ANS: status = 0x07
(12:26:32.293) exe MAC CID = 04, len = 1
(12:26:32.293) Max duty cycle: 1/2^7
(12:26:32.293) exe MAC CID = 05, len = 4
(12:26:32.293) Rx param REQ: rx1DrOffset = 0, rx2DataRate = 3, freq = 869.525024
(12:26:32.302) CMDW 98
(12:26:32.302) SI D8 DB
(12:26:32.302) SO A2 A2
(12:26:32.302) CMDR C0
(12:26:32.302) SI 0
(12:26:32.302) SO 2A
(12:26:32.302) CMDW 86
(12:26:32.302) SI 36 58 66 80
(12:26:32.308) SO AA AA AA AA
(12:26:32.308) Rx param ANS: status = 0x06
(12:26:32.308) exe MAC CID = 08, len = 1
(12:26:32.312) RX timing: delay = 5 sec
(12:26:32.312) exe MAC CID = 09, len = 1
(12:26:32.340) TX timing: dlDwell = 0, ulDwell = 0, maxEirp = 16 dBm
(12:26:32.340) exe MAC CID = 0c, len = 1
(12:26:32.340) ADR param setup: limitExp = 6, delayExp = 5
(12:26:32.340) exe MAC CID = 0f, len = 1
(12:26:32.340) Rejoin setup: maxTime = 15, maxCount = 10
(12:26:32.340) Number of MAC commands: 0
(12:26:32.340) CMDR 1D 8 E7
(12:26:32.340) SI 0 0
(12:26:32.340) SO A2 18
(12:26:32.340) CMDR C0
(12:26:32.341) SI 0
(12:26:32.341) SO 22
(12:26:32.341) CMDW 95
(12:26:32.341) SI 4 7 0 1
(12:26:32.341) SO A2 A2 A2 A2
(12:26:32.341) CMDR C0
(12:26:32.347) SI 0
(12:26:32.347) SO 22
(12:26:32.347) CMDW 8E
(12:26:32.347) SI 10 4
(12:26:32.347) SO A2 A2
(12:26:32.347) CMDR C0
(12:26:32.347) SI 0
(12:26:32.347) SO 22
(12:26:32.352) CMDW D 8 E7
(12:26:32.352) SI 18
(12:26:32.352) SO A2
(12:26:32.352) CMDR 11
(12:26:32.352) SI 0 0
(12:26:32.352) SO A2 1
(12:26:32.352) CMDR C0
(12:26:32.357) SI 0
(12:26:32.357) SO 22
(12:26:32.357) CMDR 11
(12:26:32.357) SI 0 0
(12:26:32.357) SO A2 1
(12:26:32.357) CMDR C0
(12:26:32.357) SI 0
(12:26:32.357) SO 22
(12:26:32.357) CMDW D 7 40
(12:26:32.363) SI 34 44
(12:26:32.363) SO A2 A2
(12:26:32.363) CMDR 11
(12:26:32.363) SI 0 0
(12:26:32.363) SO A2 1
(12:26:32.363) CMDR C0
(12:26:32.393) SI 0
(12:26:32.393) SO 22
(12:26:32.393) CMDR 1D 7 36
(12:26:32.393) SI 0 0
(12:26:32.393) SO A2 D
(12:26:32.393) CMDR C0
(12:26:32.393) SI 0
(12:26:32.393) SO 22
(12:26:32.393) CMDW D 7 36
(12:26:32.393) SI D
(12:26:32.393) SO A2
(12:26:32.393) CMDW 8C
(12:26:32.393) SI 0 8 0 FF 1 0
(12:26:32.393) SO A2 A2 A2 A2 A2 A2
(12:26:32.393) CMDR C0
(12:26:32.393) SI 0
(12:26:32.393) SO 22
(12:26:32.393) [main.cpp:129->setup()]: successfully started node!
(12:26:32.423) [LoRaWAN] Sending uplink packet ... There are no channels defined - are you in ABP mode with no defined subband?
(12:26:32.496)
(12:26:32.496) Channel frequency UL = 0.000000 MHz
(12:26:32.496) failed, code -12
Please let me know if I can be of more assistance
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Comments: 17 (2 by maintainers)
So despite that promising lead described above, I was not able to replicate this with a DRF1262G, the module seems to have no issue calibrating and setting the frequency to 869.525024 MHz:
So … hardware issue it is 😃
A bit late, but here’s what I think is actually going on.
The -707 error happens when attempting to change frequency to 869.525024 MHz. This also triggers image rejection calibration. This calibration actually fails, though for some reason this is not caught by the library, hence why it errors during the next SPI transfer.
So, why is this calibration failing, and why don’t the previous calibrations fail? Checking previous calibration comands (CMDW 98 in the log), all those that pass have arguments 0xD7, 0xDB. But the ones that fail have 0xD8, 0xDB. These arguments specify the frequency range in which to perform the calibration, and are calculated from the frequency we want to set. The calculation is from LR1110 datasheet, the SX1262 datasheet does not actually specify it, it only has some commonly used bands. The equations for LR1110 yield the same numbers, and so I though it should be safe to use it. So perhaps there are some corner cases that need to be investigated … or perhaps my assumption that the calibration is the same for LR1110 and SX126x doesn’t really hold up. I’ll see if I can replicate the issue without LoRaWAN stack.
As a SW developer, I too can be prone to blaming the HW, let’s cut it some slack - at least for now 😉
Tested on the new devboard, also with sx1262 and TCXO. Settings are a bit different but I do not recieve the same error and the connection is stable. @StevenCellist I think you are correct and we can put this down as a hardware issue.
Thanks again for the support!
I plan on swapping to a different model in future but the tests were done on the same board. The latest dump with lora v1.1 were all OTAA, however.
Ah, thanks for the heads up, will add in a button and test on button press instead.
Given the -707 error and the custom config, I’m 99% certain this is a hardware/crystal issue, not a problem with the library, especially not the LW stack. Maybe @jgromes can suggest something, and I’d suggest converting this to a discussion.