jgromes / RadioLib

Universal wireless communication library for embedded devices
https://jgromes.github.io/RadioLib/
MIT License
1.55k stars 387 forks source link

Issue with Lorawan, I can send JoinRequest to Helium network; but i don't receive any joinAccept message from my esp32 device. #1298

Closed predictitai closed 3 hours ago

predictitai commented 4 hours ago

Hello,

First of all thank you so much for this library to be available for everyone! I use T-Deck plus (with SC126x radio) in combination with Helium-IoT Console and see that I receive a JoinRequest and JoinAccept. The Issue is that I don't receive any data from the Helium server (from 100 tries I was only able to get it once, even at different locations). I have no clock jitter and set the scanguard to 50. To avoid throttling i disabled the dutyCycle checks.

I receive the following message: JoinAccept reply length mismatch, expected 33B got 0B with error code -1102.

Debug mode output

Setup ... Initialise the radio RLB_DBG: RadioLib Info Version: "7.1.0.0" Platform: "ESP32" Compiled: "Oct 31 2024" "10:57:57" RLB_DBG: Found SX126x: RADIOLIB_SX126X_REG_VERSION_STRING: RLB_DBG: 00000320: 53 58 31 32 36 31 20 56 32 44 20 32 44 30 32 00 SX1261 V2D 2D02. RLB_DBG: RLB_DBG: M SX126x Join ('login') the LoRaWAN Network RLB_PRO: Setting up dynamic channels RLB_PRO: UL: 0 1 868.100 (0 - 5) | DL: 0 1 868.100 (0 - 5) RLB_PRO: UL: 1 1 868.300 (0 - 5) | DL: 1 1 868.300 (0 - 5) RLB_PRO: UL: 2 1 868.500 (0 - 5) | DL: 2 1 868.500 (0 - 5) RLB_PRO: [MAC] 0x03 RLB_PRO: 00000000: 20 RLB_PRO: LinkAdrReq: dataRate = 2, txSteps = 0, nbTrans = 0 RLB_PRO: LinkAdrAns: 07 RLB_PRO: [MAC] 0x04 RLB_PRO: 00000000: 07 . RLB_PRO: DutyCycleReq: max duty cycle = 1/2^7 RLB_PRO: [MAC] 0x05 RLB_PRO: 00000000: 00 d2 ad 84 .... RLB_PRO: RXParamSetupReq: Rx1DrOffset = 0, rx2DataRate = 0, freq = 869.525 RLB_PRO: [MAC] 0x08 RLB_PRO: 00000000: 01 . RLB_PRO: RXTimingSetupReq: delay = 1 sec RLB_PRO: [MAC] 0x09 RLB_PRO: 00000000: 05 . RLB_PRO: [MAC] 0x0c RLB_PRO: 00000000: 65 e RLB_PRO: ADRParamSetupReq: limitExp = 6, delayExp = 5 RLB_PRO: [MAC] 0x0f RLB_PRO: 00000000: fa . RLB_PRO: RejoinParamSetupReq: maxTime = 15, maxCount = 10 RLB_PRO: RLB_PRO: PHY: Frequency = 868.300 MHz, TX = 16 dBm RLB_PRO: LoRa: SF = 10, BW = 125.0 kHz, CR = 4/5, IQ: U RLB_DBG: Timeout in 1853 ms RLB_PRO: JoinRequest sent (DevNonce = 57719) <-- Rx Delay start RLB_PRO: 00000000: 00 64 bf 97 76 8d 2a 9b b0 e7 16 5d a4 c2 ba e7 .d..v.*....].... RLB_PRO: 00000010: ba 77 e1 ba 9c 04 15 .w..... RLB_PRO: RLB_PRO: PHY: Frequency = 868.300 MHz, TX = 16 dBm RLB_PRO: LoRa: SF = 10, BW = 125.0 kHz, CR = 4/5, IQ: D RLB_PRO: Opening Rx1 window (331 ms timeout)... <-- Rx Delay end RLB_PRO: Closing Rx1 window RLB_PRO: RLB_PRO: PHY: Frequency = 869.525 MHz, TX = 16 dBm RLB_PRO: LoRa: SF = 12, BW = 125.0 kHz, CR = 4/5, IQ: D RLB_PRO: Opening Rx2 window (788 ms timeout)... <-- Rx Delay end RLB_PRO: Closing Rx2 window RLB_PRO: JoinAccept reply length mismatch, expected 33B got 0B Quick attempt 1 failed. Retrying in 60 seconds... Errorcode: -1102

To Reproduce I used code from https://github.com/Xinyuan-LilyGO/T-Deck but removed Radiolib completely and replaced it with the latest version https://github.com/jgromes/RadioLib version 7.1.0

Sketch that is causing the module fail

#include "config.h" #define SHORT_ATTEMPT_INTERVAL 60 // Short interval between quick attempts in seconds #define LONG_SLEEP_INTERVAL 300 // Deep sleep interval in seconds after a session of attempts #define MAX_SHORT_ATTEMPTS 3 // Max quick attempts per session void setup() { //! The board peripheral power control pin needs to be set to HIGH when using the peripheral pinMode(BOARD_POWERON, OUTPUT); digitalWrite(BOARD_POWERON, HIGH); //! Set CS on all SPI buses to high level during initialization pinMode(BOARD_SDCARD_CS, OUTPUT); pinMode(RADIO_CS_PIN, OUTPUT); pinMode(BOARD_TFT_CS, OUTPUT); digitalWrite(BOARD_SDCARD_CS, HIGH); digitalWrite(RADIO_CS_PIN, HIGH); digitalWrite(BOARD_TFT_CS, HIGH); pinMode(BOARD_SPI_MISO, INPUT_PULLUP); SPI.begin(BOARD_SPI_SCK, BOARD_SPI_MISO, BOARD_SPI_MOSI); Serial.begin(115200); while (!Serial); delay(5000); // Give time to switch to the serial monitor Serial.println(F("\nSetup ... ")); Serial.println(F("Initialise the radio")); int16_t state = radio.begin(); debug(state != RADIOLIB_ERR_NONE, F("Initialise radio failed"), state, true); // Setup the OTAA session information state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey); debug(state != RADIOLIB_ERR_NONE, F("Initialise node failed"), state, true); Serial.println(F("Join ('login') the LoRaWAN Network")); while (true) { bool connected = false; // Inner loop: multiple quick attempts within one session for (int attempt = 0; attempt < MAX_SHORT_ATTEMPTS; attempt++) { int connectionStatus = node.activateOTAA(); if (connectionStatus == RADIOLIB_LORAWAN_NEW_SESSION) { Serial.println("Connected to the network!"); connected = true; break; } else { Serial.printf("Quick attempt %d failed. Retrying in %d seconds... Errorcode: %d \n", attempt + 1, SHORT_ATTEMPT_INTERVAL, connectionStatus); delay(SHORT_ATTEMPT_INTERVAL * 1000); // Short wait before next quick attempt } } if (connected) { // Exit setup on success return; } else { // If no connection after all quick attempts, enter long sleep Serial.println("Session failed. Entering deep sleep for a longer interval."); esp_sleep_enable_timer_wakeup(LONG_SLEEP_INTERVAL * 1000000); // Set sleep interval in microseconds esp_deep_sleep_start(); } } Serial.println(F("Ready!\n")); } void loop() { Serial.println(F("Sending uplink")); int state = radio.transmit("hello world!"); if (state == RADIOLIB_ERR_NONE) { Serial.println("Message sent successfully!"); } else { Serial.print("Failed to send message, code: "); Serial.println(state); } delay(uplinkIntervalSeconds * 1000UL); // delay needs milliseconds }

Expected behavior When the helium server receives a JoinRequest and sends a JoinAccept I would expect the data to be received from my T-Deck plus device.

Additional info (please complete):

predictitai commented 3 hours ago

found the solution, activateOTAA() does sent values >0