Radiolib RAK3172 chirpstack

Hi everyone,

I am having issues with the JOIN process using the RAK3172-T STM32WLE5CC chip and the RadioLib library. My network server is ChirpStack, which correctly registers the JoinAccept, but the library seems not to listen to the response and returns the error RADIOLIB_ERR_NO_JOIN_ACCEPT.

I have verified that the JoinRequest is sent correctly and that the JoinAccept is received by ChirpStack, but the device does not seem to process this response. Has anyone had a similar problem or knows how to solve it?

I also checked the pins on my rak3172 module.

The RF switch, which is controlled by PB8 and PC13, this is correct?

//STM32WLE5JC - rak3172
static const uint32_t rfswitch_pins[] = {PB8, PC13, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC};
static const Module::RfSwitchMode_t rfswitch_table[] = {
  {STM32WLx::MODE_IDLE,  {LOW,  LOW}},
  {STM32WLx::MODE_RX,    {HIGH, LOW}},
  {STM32WLx::MODE_TX_HP, {LOW, HIGH}},
  END_OF_MODE_TABLE,
};

DevEUI":“F565C0FE7D52AC10” (radiolib SF:8 sensor) JOIN ERROR

Mar 24 19:28:33 dragino-291854 fwd[1765]: [MACINFO~][JOIN_REQ]:{"Size":23, "Rssi":-77, "snr":14, "AppEUI":"04C9F4C3A98045FA", "DevEUI":"F565C0FE7D52AC10"}
Mar 24 19:28:33 dragino-291854 fwd[1765]: [INFO~][PKTS][primary_server-UP] received Join_Req from DevEui: F565C0FE7D52AC10 (fcnt=0)
Mar 24 19:28:33 dragino-291854 fwd[1765]: [PKTS~][primary_server-UP] {"rxpk":[{"jver":1,"tmst":3221369781,"time":"2025-03-24T18:27:45.841847Z","chan":1,"rfch":1,"freq":868.300000,"mid": 8,"stat":1,"modu":"LORA","datr":"SF8BW125","codr":"4/5","rssis":-78,"lsnr":14.0,"foff":-827,"rssi":-77,"size":23,"data":"APpFgKnD9MkEEKxSff7AZfUAAOBSbdQ="}]}
Mar 24 19:28:33 dragino-291854 fwd[1765]: [MACINFO~][JOIN_REQ]:{"Size":23, "Rssi":-77, "snr":14, "AppEUI":"04C9F4C3A98045FA", "DevEUI":"F565C0FE7D52AC10"}
Mar 24 19:28:33 dragino-291854 fwd[1765]: [INFO~][PKTS][secondary_server-UP] received Join_Req from DevEui: F565C0FE7D52AC10 (fcnt=0)
Mar 24 19:28:33 dragino-291854 fwd[1765]: [PKTS~][secondary_server-UP] {"rxpk":[{"jver":1,"tmst":3221369781,"time":"2025-03-24T18:27:45.856156Z","chan":1,"rfch":1,"freq":868.300000,"mid": 8,"stat":1,"modu":"LORA","datr":"SF8BW125","codr":"4/5","rssis":-78,"lsnr":14.0,"foff":-827,"rssi":-77,"size":23,"data":"APpFgKnD9MkEEKxSff7AZfUAAOBSbdQ="}]}
Mar 24 19:28:33 dragino-291854 fwd[1765]: [INFO~][NETWORK][primary_server-UP] PUSH_ACK received in 42 ms
Mar 24 19:28:33 dragino-291854 fwd[1765]: [PKTS~][primary_server-DOWN] {"txpk":{"imme":false,"rfch":0,"powe":16,"ant":0,"brd":0,"tmst":3226369781,"freq":868.3,"modu":"LORA","datr":"SF8BW125","codr":"4/5","ipol":true,"size":33,"data":"IDygTvsNxGfdH0czdJr6r8u1qlO6Fqb3IsM1EidxLVaE"}}
Mar 24 19:28:33 dragino-291854 fwd[1765]: lgw_time_on_air:1645: INFO: LoRa packet ToA: 134 ms
Mar 24 19:28:33 dragino-291854 fwd[1765]: [DEBUG~][PKTS][primary_server-DOWN] A packet enqueue, us=3226369781, cur_us=3221644029
Mar 24 19:28:33 dragino-291854 fwd[1765]: #########DEBUG###########
Mar 24 19:28:33 dragino-291854 fwd[1765]: 203CA04EFB0DC467DD1F4733749AFAAFCBB5AA53BA16A6F722C3351227712D5684
Mar 24 19:28:33 dragino-291854 fwd[1765]: #########DEBUG###########
Mar 24 19:28:33 dragino-291854 fwd[1765]: [MACINFO~][JOIN_ACCEPT]:{"Size":33, "NetID":"FB0DC4", "DevAddr":"471FDD67", "DLSettings":{"RX1DRoffset":3, "RX2DR":3}}
Mar 24 19:28:33 dragino-291854 fwd[1765]: [INFO~][NETWORK][primary_server-DOWN] PULL_ACK received in 33 ms
Mar 24 19:28:33 dragino-291854 fwd[1765]: lgw_send:1353:  --- IN
Mar 24 19:28:33 dragino-291854 fwd[1765]: lgw_send:1487:  --- OUT
Mar 24 19:28:33 dragino-291854 fwd[1765]: [INFO~][JIT] send done on rf_chain 0 in count_us=3226369781 with freq=868300000, SF8
Mar 24 19:28:33 dragino-291854 fwd[1765]: [INFO~][NETWORK][primary_server-DOWN] PULL_ACK received in 42 ms

Thanks in advance for your help.

Hi @jpa ,

The switching states should be this.

Definition:
CTRL1 = PB8
CTRL2 = PC13

To enable RX:
CTRL1(PB8) - HIGH
CTRL2(PC13) - LOW

To enable TX:
CTRL1(PB8) - LOW
CTRL2(PC13) - HIGH 

Based on your code, it appears to be correct. Maybe the issue is not on the RF path configuration.

Hi Carl
Thanks for your response.

I’m including screenshots of my configurations and logs generated when attempting to join, along with some sample code.

I’m using Dragino as the gateway, and Chirpstack as the network server.

Everything seems fine. Chirpstack performs the join, and the gateway seems to send data to the node, but it doesn’t receive the join confirmation.

I hope you can help me.

LOG DRAGINO

08:20:25 dragino-291854 fwd[31054]: lgw_receive:1323: INFO: RSSI temperature offset applied: 1.113 dB (current temperature 26.9 C)
Mar 26 08:20:25 dragino-291854 fwd[31054]: lgw_receive:1326: INFO: nb pkt found:1 left:0
Mar 26 08:20:25 dragino-291854 fwd[31054]: [MACINFO~][JOIN_REQ]:{"Size":23, "Rssi":-81, "snr":13, "AppEUI":"04C9F4C3A98045FA", "DevEUI":"F565C0FE7D52AC10"}
Mar 26 08:20:25 dragino-291854 fwd[31054]: [INFO~][PKTS][primary_server-UP] received Join_Req from DevEui: F565C0FE7D52AC10 (fcnt=0)
Mar 26 08:20:25 dragino-291854 fwd[31054]: [PKTS~][primary_server-UP] {"rxpk":[{"jver":1,"tmst":2745709830,"time":"2025-03-26T07:20:25.333831Z","chan":1,"rfch":1,"freq":868.300000,"mid": 8,"stat":1,"modu":"LORA","datr":"SF7BW125","codr":"4/5","rssis":-82,"lsnr":12.8,"foff":-659,"rssi":-81,"size":23,"data":"APpFgKnD9MkEEKxSff7AZfUAAOBSbdQ="}]}
Mar 26 08:20:25 dragino-291854 fwd[31054]: [MACINFO~][JOIN_REQ]:{"Size":23, "Rssi":-81, "snr":13, "AppEUI":"04C9F4C3A98045FA", "DevEUI":"F565C0FE7D52AC10"}
Mar 26 08:20:25 dragino-291854 fwd[31054]: [INFO~][PKTS][secondary_server-UP] received Join_Req from DevEui: F565C0FE7D52AC10 (fcnt=0)
Mar 26 08:20:25 dragino-291854 fwd[31054]: [PKTS~][secondary_server-UP] {"rxpk":[{"jver":1,"tmst":2745709830,"time":"2025-03-26T07:20:25.342805Z","chan":1,"rfch":1,"freq":868.300000,"mid": 8,"stat":1,"modu":"LORA","datr":"SF7BW125","codr":"4/5","rssis":-82,"lsnr":12.8,"foff":-659,"rssi":-81,"size":23,"data":"APpFgKnD9MkEEKxSff7AZfUAAOBSbdQ="}]}
Mar 26 08:20:25 dragino-291854 fwd[31054]: [INFO~][NETWORK][primary_server-UP] PUSH_ACK received in 32 ms
Mar 26 08:20:25 dragino-291854 fwd[31054]: [PKTS~][primary_server-DOWN] {"txpk":{"imme":false,"rfch":0,"powe":16,"ant":0,"brd":0,"tmst":2750709830,"freq":868.3,"modu":"LORA","datr":"SF7BW125","codr":"4/5","ipol":true,"size":33,"data":"IO6v0McOZifn6NDoLCPz/ujgLDtMqMIyZvbRMEPChvDt"}}
Mar 26 08:20:25 dragino-291854 fwd[31054]: lgw_time_on_air:1645: INFO: LoRa packet ToA: 72 ms
Mar 26 08:20:25 dragino-291854 fwd[31054]: [DEBUG~][PKTS][primary_server-DOWN] A packet enqueue, us=2750709830, cur_us=2745965027
Mar 26 08:20:25 dragino-291854 fwd[31054]: #########DEBUG###########
Mar 26 08:21:37 dragino-291854 fwd[31054]: 20EEAFD0C70E6627E7E8D0E82C23F3FEE8E02C3B4CA8C23266F6D13043C286F0ED
Mar 26 08:21:37 dragino-291854 fwd[31054]: #########DEBUG###########
Mar 26 08:21:37 dragino-291854 fwd[31054]: [MACINFO~][JOIN_ACCEPT]:{"Size":33, "NetID":"C70E66", "DevAddr":"D0E8E727", "DLSettings":{"RX1DRoffset":6, "RX2DR":8}}
Mar 26 08:21:37 dragino-291854 fwd[31054]: [INFO~][NETWORK][primary_server-DOWN] PULL_ACK received in 28 ms
Mar 26 08:21:37 dragino-291854 fwd[31054]: lgw_send:1353:  --- IN
Mar 26 08:21:37 dragino-291854 fwd[31054]: lgw_send:1487:  --- OUT
Mar 26 08:21:37 dragino-291854 fwd[31054]: [INFO~][JIT] send done on rf_chain 0 in count_us=2750709830 with freq=868300000, SF7
Mar 26 08:21:37 dragino-291854 fwd[31054]: [INFO~][NETWORK][primary_server-DOWN] PULL_ACK received in 28 ms

Log RADIOLIB

[STM32WL] Initializing ... [STM32WL] Starting to listen ... Join ('login') the LoRaWAN Network
[10.051091] RLB_PRO: Setting up dynamic channels
[10.054042] RLB_PRO: UL:   0 1  (0 - 5) | DL:   0 1  (0 - 5)
2[10.059523] RLB_PRO: UL:   1 1  (0 - 5) | DL:   1 1  (0 - 5)
2[10.067435] RLB_PRO: UL:   2 1  (0 - 5) | DL:   2 1  (0 - 5)
2[10.073103] RLB_PRO: [MAC] 0x03
[10.073317] RLB_PRO: 00000000: 50                                               P                 
[10.084197] RLB_PRO: LinkAdrReq: dataRate = 5, txSteps = 0, nbTrans = 0
[10.090056] RLB_PRO: LinkAdrAns: 07
[10.093276] RLB_PRO: [MAC] 0x04
[10.095564] RLB_PRO: 00000000: 07                                               .                 
[10.106538] RLB_PRO: DutyCycleReq: max duty cycle = 1/2^7
[10.112113] RLB_PRO: [MAC] 0x05
[10.112451] RLB_PRO: 00000000: 00 d2 ad 84                                      ....              
[10.123315] RLB_PRO: RXParamSetupReq: Rx1DrOffset = 0, rx2DataRate = 0, freq = 
[10.129429] RLB_PRO: [MAC] 0x08
[10.132133] RLB_PRO: 00000000: 01                                               .                 
[10.140059] RLB_PRO: RXTimingSetupReq: delay = 1 sec
[10.145633] RLB_PRO: [MAC] 0x09
[10.145857] RLB_PRO: 00000000: 05                                               .                 
[10.156824] RLB_PRO: [MAC] 0x0c
[10.162505] RLB_PRO: 00000000: 65                                               e                 
[10.168084] RLB_PRO: ADRParamSetupReq: limitExp = 6, delayExp = 5
[10.173657] RLB_PRO: [MAC] 0x0f
[10.177518] RLB_PRO: 00000000: fa                                               .                 
[10.184750] RLB_PRO: RejoinParamSetupReq: maxTime = 15, maxCount = 10
[10.259314] RLB_PRO: 
[10.259408] RLB_PRO: PHY:  Frequency =  MHz, TX = 16 dBm
[10.266111] RLB_PRO: LoRa: SF = 7, BW =  kHz, CR = 4/5, IQ: U
[10.338115] RLB_PRO: JoinRequest sent (DevNonce = 0) <-- Rx Delay start
[10.343884] RLB_PRO: 00000000: 00 fa 45 80 a9 c3 f4 c9 04 10 ac 52 7d fe c0 65  ..E........R}..e
[10.349134] RLB_PRO: 00000010: f5 00 00 e0 52 6d d4                             ....Rm.           
[10.360207] RLB_PRO: 
[10.360291] RLB_PRO: PHY:  Frequency =  MHz, TX = 16 dBm
[10.366621] RLB_PRO: LoRa: SF = 7, BW =  kHz, CR = 4/5, IQ: D
[15.338041] RLB_PRO: Opening Rx1 window (32 ms timeout)... <-- Rx Delay end 
[15.372003] RLB_PRO: Closing Rx1 window
[15.372559] RLB_PRO: 
[15.372911] RLB_PRO: PHY:  Frequency =  MHz, TX = 16 dBm
[15.378821] RLB_PRO: LoRa: SF = 12, BW =  kHz, CR = 4/5, IQ: D
 [16.338038] RLB_PRO: Opening Rx2 window (670 ms timeout)... <-- Rx Delay end 
[17.013003] RLB_PRO: Closing Rx2 window
Join failed - RADIOLIB_ERR_NO_JOIN_ACCEPT (-1116)

Sample code

#include <Arduino.h>
//
#include <Util/config.h>
//
#include <RadioLib.h>
//
// regional choices: EU868, US915, AU915, AS923, AS923_2, AS923_3, AS923_4, IN865, KR920, CN470
const LoRaWANBand_t Region = EU868;

// subband choice: for US915/AU915 set to 2, for CN470 set to 1, otherwise leave on 0
const uint8_t subBand = 0;
//-----------------------------------------------------------------------------------------------------------------------------------------
// the Device EUI & two keys can be generated on the TTN console 
#define RADIOLIB_LORAWAN_DEV_EUI   0xf565c0fe7d52ac10
// joinEUI - previous versions of LoRaWAN called this AppEUI
// for development purposes you can use all zeros - see wiki for details
#define RADIOLIB_LORAWAN_JOIN_EUI  0x04c9f4c3a98045fa
// the Device EUI & two keys can be generated on the TTN console 
//#define RADIOLIB_LORAWAN_DEV_EUI   0x---------------
//#define     SECRET_APP_KEY      "2b7e151628aed2a6abf7158809cf4f3c"             
#define RADIOLIB_LORAWAN_APP_KEY   0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c 
// Put your Nwk Key here
//#define     SECRET_NWK_EUI      "6eadbfd6d9114fd5a641-1e10b06748de"
#define RADIOLIB_LORAWAN_NWK_KEY   0x6e, 0xad, 0xbf, 0xd6, 0xd9, 0x11, 0x4f, 0xd5, 0xa6, 0x41, 0x1e, 0x10, 0xb0, 0x67, 0x48, 0xde 

uint64_t joinEUI =   RADIOLIB_LORAWAN_JOIN_EUI;
uint64_t devEUI  =   RADIOLIB_LORAWAN_DEV_EUI;
uint8_t appKey[] = { RADIOLIB_LORAWAN_APP_KEY };
uint8_t nwkKey[] = { RADIOLIB_LORAWAN_NWK_KEY };

void debug(bool failed, const __FlashStringHelper* message, int state, bool halt);
// helper function to display a byte array
void arrayDump(uint8_t *buffer, uint16_t len);
void customDelay(RadioLibTime_t ms);
String stateDecode(const int16_t result);
String ReceivedData(void);
void setFlag(void);
void  sendLoRaWAN(void);

bool receivedFlag = false;

//STM32WLE5JC - rak3172
static const uint32_t rfswitch_pins[] = {PB8, PC13, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC};
static const Module::RfSwitchMode_t rfswitch_table[] = {
  {STM32WLx::MODE_IDLE,  {LOW,  LOW}},
  {STM32WLx::MODE_RX,    {HIGH, LOW}},
  {STM32WLx::MODE_TX_HP, {LOW, HIGH}},
  END_OF_MODE_TABLE,
};

//Instancias
STM32WLx radio = new STM32WLx_Module();
// create the LoRaWAN node
LoRaWANNode node(&radio, &Region, subBand);

// ---------------------- MAIN -----------------------

void setup() {
  Serial.begin(DEBUG_BAUD_RATE);    
  //
  Serial.println("Init");
  
  delay(5000);

  // set RF switch control configuration
  // this has to be done prior to calling begin()
  radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);

  delay(1000);

  // initialize STM32WL with default settings, except frequency
  Serial.print(F("[STM32WL] Initializing ... "));
  //int state = radio.begin(868.1, 125.0, 12, 5, 0x12, 0x10 , 8, 1.7, false);
  int state = radio.begin(868.0);
  debug(state != RADIOLIB_ERR_NONE, F("Initialise radio failed"), state, true);

  delay(2000);

  // Override the default join rate
  uint8_t joinDR = 5;
  
  // Optionally provide a custom sleep function - see config.h
  //node.setSleepFunction(customDelay);

  // set appropriate TCXO voltage for Nucleo WL55JC1
  //state = radio.setTCXO(3.0);
  //debug(state != RADIOLIB_ERR_NONE, F("Initialise node failed"), state, true);

  // set the function that will be called
  // when new packet is received
  radio.setDio1Action(setFlag);

  // start listening for LoRa packets
  Serial.print(F("[STM32WL] Starting to listen ... "));
  state = radio.startReceive();
  debug(state != RADIOLIB_ERR_NONE, F("Initialise node failed"), state, true);

  delay(1000);

  // Setup the OTAA session information
  state = node.beginOTAA(joinEUI, devEUI, NULL, appKey); //  To activate a LoRaWAN 1.0.4 session
  //state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey); // To activate a LoRaWAN 1.1 session      
  debug(state != RADIOLIB_ERR_NONE, F("Initialise node failed"), state, true);  
  
  delay(1000);

  Serial.println(F("Join ('login') the LoRaWAN Network"));
  state = node.activateOTAA(joinDR);
  debug(state != RADIOLIB_LORAWAN_NEW_SESSION, F("Join failed"), state, true);

  // Print the DevAddr
  Serial.print("[LoRaWAN] DevAddr: ");
  Serial.println((unsigned long)node.getDevAddr(), HEX);

  // Enable the ADR algorithm (on by default which is preferable)
  node.setADR(true);

  // Set a datarate to start off with
  node.setDatarate(5);

  // Manages uplink intervals to the TTN Fair Use Policy
  node.setDutyCycle(true, 1250);

  // Update dwell time limits - 400ms is the limit for the US
  node.setDwellTime(true, 400);

  Serial.println(F("Ready!\n"));  
  //
  sendLoRaWAN();
}

void loop() {
  ReceivedData();
}

// this function is called when a complete packet
// is received by the module
// IMPORTANT: this function MUST be 'void' type
//            and MUST NOT have any arguments!
void setFlag(void) {
  // we got a packet, set the flag
  receivedFlag = true;
}

//
void  sendLoRaWAN() {
  Serial.println(F("Sending uplink"));

  // This is the place to gather the sensor inputs
  // Instead of reading any real sensor, we just generate some random numbers as example
  uint8_t value1 = radio.random(100);
  uint16_t value2 = radio.random(2000);

  // Build payload byte array
  uint8_t uplinkPayload[3];
  uplinkPayload[0] = value1;
  uplinkPayload[1] = highByte(value2);   // See notes for high/lowByte functions
  uplinkPayload[2] = lowByte(value2);
  
  // Perform an uplink
  int16_t state = node.sendReceive(uplinkPayload, sizeof(uplinkPayload));    
  debug(state < RADIOLIB_ERR_NONE, F("Error in sendReceive"), state, false);

  // Check if a downlink was received 
  // (state 0 = no downlink, state 1/2 = downlink in window Rx1/Rx2)
  if(state > 0) {
    Serial.println(F("Received a downlink"));
  } else {
    Serial.println(F("No downlink received"));
  }
}

//
String ReceivedData(void) {  //  
  // check if the flag is set
  String Result = "";

  if(receivedFlag) {
    // reset flag
    receivedFlag = false;

    // you can read received data as an Arduino String    
    int state = radio.readData(Result);

    // you can also read received data as byte array
    /*
      byte byteArr[8];
      int numBytes = radio.getPacketLength();
      int state = radio.readData(byteArr, numBytes);
    */

    if (state == RADIOLIB_ERR_NONE && Result.length() > 0) {
      // packet was successfully received
      Serial.println(F("[STM32WL] Received packet!"));

      // print data of the packet
      Serial.print(F("[STM32WL] Data:\t\t"));
      Serial.println(Result);

      // print RSSI (Received Signal Strength Indicator)
      Serial.print(F("[STM32WL] RSSI:\t\t"));
      Serial.print(radio.getRSSI());
      Serial.println(F(" dBm"));

      // print SNR (Signal-to-Noise Ratio)
      Serial.print(F("[STM32WL] SNR:\t\t"));
      Serial.print(radio.getSNR());
      Serial.println(F(" dB"));

    } else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
      // packet was received, but is malformed
      Serial.println(F("CRC error!"));

    } else {
      // some other error occurred
      Serial.print(F("failed, code "));
      Serial.println(state);
    }
  }

  return(Result);
}

Hi Carl, thanks for your response.
I use Dragino for the gateway, and Chirpstack for the network server.

Everything seems to be configured correctly, as the join is successful in Chirpstack, and the gateway also receives confirmation. This leads me to conclude that the node is not in listening mode; it’s not receiving confirmation from the join.

I hope you can help me.

Sample code

#include <Arduino.h>
//
#include <Util/config.h>
//
#include <RadioLib.h>
//
// regional choices: EU868, US915, AU915, AS923, AS923_2, AS923_3, AS923_4, IN865, KR920, CN470
const LoRaWANBand_t Region = EU868;

// subband choice: for US915/AU915 set to 2, for CN470 set to 1, otherwise leave on 0
const uint8_t subBand = 0;
//-----------------------------------------------------------------------------------------------------------------------------------------
// the Device EUI & two keys can be generated on the TTN console 
#define RADIOLIB_LORAWAN_DEV_EUI   0xf565c0fe7d52ac10
// joinEUI - previous versions of LoRaWAN called this AppEUI
// for development purposes you can use all zeros - see wiki for details
#define RADIOLIB_LORAWAN_JOIN_EUI  0x04c9f4c3a98045fa
// the Device EUI & two keys can be generated on the TTN console 
//#define RADIOLIB_LORAWAN_DEV_EUI   0x---------------
//#define     SECRET_APP_KEY      "2b7e151628aed2a6abf7158809cf4f3c"             
#define RADIOLIB_LORAWAN_APP_KEY   0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c 
// Put your Nwk Key here
//#define     SECRET_NWK_EUI      "6eadbfd6d9114fd5a641-1e10b06748de"
#define RADIOLIB_LORAWAN_NWK_KEY   0x6e, 0xad, 0xbf, 0xd6, 0xd9, 0x11, 0x4f, 0xd5, 0xa6, 0x41, 0x1e, 0x10, 0xb0, 0x67, 0x48, 0xde 

uint64_t joinEUI =   RADIOLIB_LORAWAN_JOIN_EUI;
uint64_t devEUI  =   RADIOLIB_LORAWAN_DEV_EUI;
uint8_t appKey[] = { RADIOLIB_LORAWAN_APP_KEY };
uint8_t nwkKey[] = { RADIOLIB_LORAWAN_NWK_KEY };

void debug(bool failed, const __FlashStringHelper* message, int state, bool halt);
// helper function to display a byte array
void arrayDump(uint8_t *buffer, uint16_t len);
void customDelay(RadioLibTime_t ms);
String stateDecode(const int16_t result);
String ReceivedData(void);
void setFlag(void);
void  sendLoRaWAN(void);

bool receivedFlag = false;

//STM32WLE5JC - rak3172
static const uint32_t rfswitch_pins[] = {PB8, PC13, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC};
static const Module::RfSwitchMode_t rfswitch_table[] = {
  {STM32WLx::MODE_IDLE,  {LOW,  LOW}},
  {STM32WLx::MODE_RX,    {HIGH, LOW}},
  {STM32WLx::MODE_TX_HP, {LOW, HIGH}},
  END_OF_MODE_TABLE,
};

//Instancias
STM32WLx radio = new STM32WLx_Module();
// create the LoRaWAN node
LoRaWANNode node(&radio, &Region, subBand);

// ---------------------- MAIN -----------------------

void setup() {
  Serial.begin(DEBUG_BAUD_RATE);    
  //
  Serial.println("Init");
  
  delay(5000);

  // set RF switch control configuration
  // this has to be done prior to calling begin()
  radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);

  delay(1000);

  // initialize STM32WL with default settings, except frequency
  Serial.print(F("[STM32WL] Initializing ... "));
  //int state = radio.begin(868.1, 125.0, 12, 5, 0x12, 0x10 , 8, 1.7, false);
  int state = radio.begin(868.0);
  debug(state != RADIOLIB_ERR_NONE, F("Initialise radio failed"), state, true);

  delay(2000);

  // Override the default join rate
  uint8_t joinDR = 5;
  
  // Optionally provide a custom sleep function - see config.h
  //node.setSleepFunction(customDelay);

  // set appropriate TCXO voltage for Nucleo WL55JC1
  //state = radio.setTCXO(3.0);
  //debug(state != RADIOLIB_ERR_NONE, F("Initialise node failed"), state, true);

  // set the function that will be called
  // when new packet is received
  radio.setDio1Action(setFlag);

  // start listening for LoRa packets
  Serial.print(F("[STM32WL] Starting to listen ... "));
  state = radio.startReceive();
  debug(state != RADIOLIB_ERR_NONE, F("Initialise node failed"), state, true);

  delay(1000);

  // Setup the OTAA session information
  state = node.beginOTAA(joinEUI, devEUI, NULL, appKey); //  To activate a LoRaWAN 1.0.4 session
  //state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey); // To activate a LoRaWAN 1.1 session      
  debug(state != RADIOLIB_ERR_NONE, F("Initialise node failed"), state, true);  
  
  delay(1000);

  Serial.println(F("Join ('login') the LoRaWAN Network"));
  state = node.activateOTAA(joinDR);
  debug(state != RADIOLIB_LORAWAN_NEW_SESSION, F("Join failed"), state, true);

  // Print the DevAddr
  Serial.print("[LoRaWAN] DevAddr: ");
  Serial.println((unsigned long)node.getDevAddr(), HEX);

  // Enable the ADR algorithm (on by default which is preferable)
  node.setADR(true);

  // Set a datarate to start off with
  node.setDatarate(5);

  // Manages uplink intervals to the TTN Fair Use Policy
  node.setDutyCycle(true, 1250);

  // Update dwell time limits - 400ms is the limit for the US
  node.setDwellTime(true, 400);

  Serial.println(F("Ready!\n"));  
  //
  sendLoRaWAN();
}

void loop() {
  ReceivedData();
}

// this function is called when a complete packet
// is received by the module
// IMPORTANT: this function MUST be 'void' type
//            and MUST NOT have any arguments!
void setFlag(void) {
  // we got a packet, set the flag
  receivedFlag = true;
}

//
void  sendLoRaWAN() {
  Serial.println(F("Sending uplink"));

  // This is the place to gather the sensor inputs
  // Instead of reading any real sensor, we just generate some random numbers as example
  uint8_t value1 = radio.random(100);
  uint16_t value2 = radio.random(2000);

  // Build payload byte array
  uint8_t uplinkPayload[3];
  uplinkPayload[0] = value1;
  uplinkPayload[1] = highByte(value2);   // See notes for high/lowByte functions
  uplinkPayload[2] = lowByte(value2);
  
  // Perform an uplink
  int16_t state = node.sendReceive(uplinkPayload, sizeof(uplinkPayload));    
  debug(state < RADIOLIB_ERR_NONE, F("Error in sendReceive"), state, false);

  // Check if a downlink was received 
  // (state 0 = no downlink, state 1/2 = downlink in window Rx1/Rx2)
  if(state > 0) {
    Serial.println(F("Received a downlink"));
  } else {
    Serial.println(F("No downlink received"));
  }
}

//
String ReceivedData(void) {  //  
  // check if the flag is set
  String Result = "";

  if(receivedFlag) {
    // reset flag
    receivedFlag = false;

    // you can read received data as an Arduino String    
    int state = radio.readData(Result);

    // you can also read received data as byte array
    /*
      byte byteArr[8];
      int numBytes = radio.getPacketLength();
      int state = radio.readData(byteArr, numBytes);
    */

    if (state == RADIOLIB_ERR_NONE && Result.length() > 0) {
      // packet was successfully received
      Serial.println(F("[STM32WL] Received packet!"));

      // print data of the packet
      Serial.print(F("[STM32WL] Data:\t\t"));
      Serial.println(Result);

      // print RSSI (Received Signal Strength Indicator)
      Serial.print(F("[STM32WL] RSSI:\t\t"));
      Serial.print(radio.getRSSI());
      Serial.println(F(" dBm"));

      // print SNR (Signal-to-Noise Ratio)
      Serial.print(F("[STM32WL] SNR:\t\t"));
      Serial.print(radio.getSNR());
      Serial.println(F(" dB"));

    } else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
      // packet was received, but is malformed
      Serial.println(F("CRC error!"));

    } else {
      // some other error occurred
      Serial.print(F("failed, code "));
      Serial.println(state);
    }
  }

  return(Result);
}

Log Radiolib

STM32WL] Initializing ... [STM32WL] Starting to listen ... Join ('login') the LoRaWAN Network
[10.051091] RLB_PRO: Setting up dynamic channels
[10.054042] RLB_PRO: UL:   0 1  (0 - 5) | DL:   0 1  (0 - 5)
2[10.059523] RLB_PRO: UL:   1 1  (0 - 5) | DL:   1 1  (0 - 5)
2[10.067435] RLB_PRO: UL:   2 1  (0 - 5) | DL:   2 1  (0 - 5)
2[10.073103] RLB_PRO: [MAC] 0x03
[10.073317] RLB_PRO: 00000000: 50                                               P                 
[10.084197] RLB_PRO: LinkAdrReq: dataRate = 5, txSteps = 0, nbTrans = 0
[10.090056] RLB_PRO: LinkAdrAns: 07
[10.093276] RLB_PRO: [MAC] 0x04
[10.095564] RLB_PRO: 00000000: 07                                               .                 
[10.106538] RLB_PRO: DutyCycleReq: max duty cycle = 1/2^7
[10.112113] RLB_PRO: [MAC] 0x05
[10.112451] RLB_PRO: 00000000: 00 d2 ad 84                                      ....              
[10.123315] RLB_PRO: RXParamSetupReq: Rx1DrOffset = 0, rx2DataRate = 0, freq = 
[10.129429] RLB_PRO: [MAC] 0x08
[10.132133] RLB_PRO: 00000000: 01                                               .                 
[10.140059] RLB_PRO: RXTimingSetupReq: delay = 1 sec
[10.145633] RLB_PRO: [MAC] 0x09
[10.145857] RLB_PRO: 00000000: 05                                               .                 
[10.156824] RLB_PRO: [MAC] 0x0c
[10.162505] RLB_PRO: 00000000: 65                                               e                 
[10.168084] RLB_PRO: ADRParamSetupReq: limitExp = 6, delayExp = 5
[10.173657] RLB_PRO: [MAC] 0x0f
[10.177518] RLB_PRO: 00000000: fa                                               .                 
[10.184750] RLB_PRO: RejoinParamSetupReq: maxTime = 15, maxCount = 10
[10.259314] RLB_PRO: 
[10.259408] RLB_PRO: PHY:  Frequency =  MHz, TX = 16 dBm
[10.266111] RLB_PRO: LoRa: SF = 7, BW =  kHz, CR = 4/5, IQ: U
[10.338115] RLB_PRO: JoinRequest sent (DevNonce = 0) <-- Rx Delay start
[10.343884] RLB_PRO: 00000000: 00 fa 45 80 a9 c3 f4 c9 04 10 ac 52 7d fe c0 65  ..E........R}..e
[10.349134] RLB_PRO: 00000010: f5 00 00 e0 52 6d d4                             ....Rm.           
[10.360207] RLB_PRO: 
[10.360291] RLB_PRO: PHY:  Frequency =  MHz, TX = 16 dBm
[10.366621] RLB_PRO: LoRa: SF = 7, BW =  kHz, CR = 4/5, IQ: D
[15.338041] RLB_PRO: Opening Rx1 window (32 ms timeout)... <-- Rx Delay end 
[15.372003] RLB_PRO: Closing Rx1 window
[15.372559] RLB_PRO: 
[15.372911] RLB_PRO: PHY:  Frequency =  MHz, TX = 16 dBm
[15.378821] RLB_PRO: LoRa: SF = 12, BW =  kHz, CR = 4/5, IQ: D
 [16.338038] RLB_PRO: Opening Rx2 window (670 ms timeout)... <-- Rx Delay end 
[17.013003] RLB_PRO: Closing Rx2 window
Join failed - RADIOLIB_ERR_NO_JOIN_ACCEPT (-1116)

Log Gateway

08:20:25 dragino-291854 fwd[31054]: lgw_receive:1323: INFO: RSSI temperature offset applied: 1.113 dB (current temperature 26.9 C)
Mar 26 08:20:25 dragino-291854 fwd[31054]: lgw_receive:1326: INFO: nb pkt found:1 left:0
Mar 26 08:20:25 dragino-291854 fwd[31054]: [MACINFO~][JOIN_REQ]:{"Size":23, "Rssi":-81, "snr":13, "AppEUI":"04C9F4C3A98045FA", "DevEUI":"F565C0FE7D52AC10"}
Mar 26 08:20:25 dragino-291854 fwd[31054]: [INFO~][PKTS][primary_server-UP] received Join_Req from DevEui: F565C0FE7D52AC10 (fcnt=0)
Mar 26 08:20:25 dragino-291854 fwd[31054]: [PKTS~][primary_server-UP] {"rxpk":[{"jver":1,"tmst":2745709830,"time":"2025-03-26T07:20:25.333831Z","chan":1,"rfch":1,"freq":868.300000,"mid": 8,"stat":1,"modu":"LORA","datr":"SF7BW125","codr":"4/5","rssis":-82,"lsnr":12.8,"foff":-659,"rssi":-81,"size":23,"data":"APpFgKnD9MkEEKxSff7AZfUAAOBSbdQ="}]}
Mar 26 08:20:25 dragino-291854 fwd[31054]: [MACINFO~][JOIN_REQ]:{"Size":23, "Rssi":-81, "snr":13, "AppEUI":"04C9F4C3A98045FA", "DevEUI":"F565C0FE7D52AC10"}
Mar 26 08:20:25 dragino-291854 fwd[31054]: [INFO~][PKTS][secondary_server-UP] received Join_Req from DevEui: F565C0FE7D52AC10 (fcnt=0)
Mar 26 08:20:25 dragino-291854 fwd[31054]: [PKTS~][secondary_server-UP] {"rxpk":[{"jver":1,"tmst":2745709830,"time":"2025-03-26T07:20:25.342805Z","chan":1,"rfch":1,"freq":868.300000,"mid": 8,"stat":1,"modu":"LORA","datr":"SF7BW125","codr":"4/5","rssis":-82,"lsnr":12.8,"foff":-659,"rssi":-81,"size":23,"data":"APpFgKnD9MkEEKxSff7AZfUAAOBSbdQ="}]}
Mar 26 08:20:25 dragino-291854 fwd[31054]: [INFO~][NETWORK][primary_server-UP] PUSH_ACK received in 32 ms
Mar 26 08:20:25 dragino-291854 fwd[31054]: [PKTS~][primary_server-DOWN] {"txpk":{"imme":false,"rfch":0,"powe":16,"ant":0,"brd":0,"tmst":2750709830,"freq":868.3,"modu":"LORA","datr":"SF7BW125","codr":"4/5","ipol":true,"size":33,"data":"IO6v0McOZifn6NDoLCPz/ujgLDtMqMIyZvbRMEPChvDt"}}
Mar 26 08:20:25 dragino-291854 fwd[31054]: lgw_time_on_air:1645: INFO: LoRa packet ToA: 72 ms
Mar 26 08:20:25 dragino-291854 fwd[31054]: [DEBUG~][PKTS][primary_server-DOWN] A packet enqueue, us=2750709830, cur_us=2745965027
Mar 26 08:20:25 dragino-291854 fwd[31054]: #########DEBUG###########
Mar 26 08:21:37 dragino-291854 fwd[31054]: 20EEAFD0C70E6627E7E8D0E82C23F3FEE8E02C3B4CA8C23266F6D13043C286F0ED
Mar 26 08:21:37 dragino-291854 fwd[31054]: #########DEBUG###########
Mar 26 08:21:37 dragino-291854 fwd[31054]: [MACINFO~][JOIN_ACCEPT]:{"Size":33, "NetID":"C70E66", "DevAddr":"D0E8E727", "DLSettings":{"RX1DRoffset":6, "RX2DR":8}}
Mar 26 08:21:37 dragino-291854 fwd[31054]: [INFO~][NETWORK][primary_server-DOWN] PULL_ACK received in 28 ms
Mar 26 08:21:37 dragino-291854 fwd[31054]: lgw_send:1353:  --- IN
Mar 26 08:21:37 dragino-291854 fwd[31054]: lgw_send:1487:  --- OUT
Mar 26 08:21:37 dragino-291854 fwd[31054]: [INFO~][JIT] send done on rf_chain 0 in count_us=2750709830 with freq=868300000, SF7
Mar 26 08:21:37 dragino-291854 fwd[31054]: [INFO~][NETWORK][primary_server-DOWN] PULL_ACK received in 28 ms

Hi @jpa ,

I am not sure if something related but the timing of the join request and join accepts seems to have a huge gap.

Btw, since I am not using with RadioLib on my day-to-day job, if I am in your case, I will try first the RAK3172 default FW and see if there will be no issue in LoRa/LoRaWAN. If it works, then the issue might be somewhere else and not on the physical RF receiving side.

Is it possible to use the RUI3 API on Platformio? Could you tell me how to do it?

Thank you very much for your help.

RUI3 API is not compatible to PIO (so far).

Hi Carl

To be more standard in the test, I used the radiolib example code for Arduino IDE.

The error is the same.
14:30:22 The Join request is sent (I don’t know why it shows two entries).

It is responded to at 14:30:23 (I’m not sure if this is the join gateway sending it to the node).

In the Dragino log, the join is responded to at 14:31:49. That’s strange.

LoRaWAN_Starter.ino


#include "config.h"

void setup() {
  Serial.begin(115200);
  //
  delay(5000);  // Give time to switch to the serial monitor
  //
  Serial.println(F("\nSetup ... "));

  // this has to be done prior to calling begin()
  radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);

  Serial.println(F("Initialise the radio"));
  int16_t state = radio.begin(868.0);
  debug(state != RADIOLIB_ERR_NONE, F("Initialise radio failed"), state, true);

  // set appropriate TCXO voltage for Nucleo WL55JC1
  state = radio.setTCXO(1.7);
  debug(state != RADIOLIB_ERR_NONE, F("Initialise node failed"), state, true);

  // Setup the OTAA session information
  //state = node.beginOTAA(joinEUI, devEUI, NULL, appKey); //OTAA 1.0.4
  state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey); //OTAA 1.1.0
  debug(state != RADIOLIB_ERR_NONE, F("Initialise node failed"), state, true);

  Serial.println(F("Join ('login') the LoRaWAN Network"));
  state = node.activateOTAA();
  debug(state != RADIOLIB_LORAWAN_NEW_SESSION, F("Join failed"), state, true);

  Serial.println(F("Ready!\n"));
}

void loop() {
  Serial.println(F("Sending uplink"));

  // This is the place to gather the sensor inputs
  // Instead of reading any real sensor, we just generate some random numbers as example
  uint8_t value1 = radio.random(100);
  uint16_t value2 = radio.random(2000);

  // Build payload byte array
  uint8_t uplinkPayload[3];
  uplinkPayload[0] = value1;
  uplinkPayload[1] = highByte(value2);   // See notes for high/lowByte functions
  uplinkPayload[2] = lowByte(value2);
  
  // Perform an uplink
  int16_t state = node.sendReceive(uplinkPayload, sizeof(uplinkPayload));    
  debug(state < RADIOLIB_ERR_NONE, F("Error in sendReceive"), state, false);

  // Check if a downlink was received 
  // (state 0 = no downlink, state 1/2 = downlink in window Rx1/Rx2)
  if(state > 0) {
    Serial.println(F("Received a downlink"));
  } else {
    Serial.println(F("No downlink received"));
  }

  Serial.print(F("Next uplink in "));
  Serial.print(uplinkIntervalSeconds);
  Serial.println(F(" seconds\n"));
  
  // Wait until next uplink - observing legal & TTN FUP constraints
  delay(uplinkIntervalSeconds * 1000UL);  // delay needs milli-seconds
}

config.h

#ifndef _RADIOLIB_EX_LORAWAN_CONFIG_H
#define _RADIOLIB_EX_LORAWAN_CONFIG_H

#include <RadioLib.h>

// first you have to set your radio model and pin configuration
// this is provided just as a default example
STM32WLx radio = new STM32WLx_Module();

// if you have RadioBoards (https://github.com/radiolib-org/RadioBoards)
// and are using one of the supported boards, you can do the following:
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>

Radio radio = new RadioModule();
*/

// how often to send an uplink - consider legal & FUP constraints - see notes
const uint32_t uplinkIntervalSeconds = 5UL * 60UL;    // minutes x seconds

// joinEUI - previous versions of LoRaWAN called this AppEUI
// for development purposes you can use all zeros - see wiki for details
#define RADIOLIB_LORAWAN_JOIN_EUI  0xf4f065f7d4ca7bb1

// the Device EUI & two keys can be generated on the TTN console 
//#ifndef RADIOLIB_LORAWAN_DEV_EUI   // Replace with your Device EUI
#define RADIOLIB_LORAWAN_DEV_EUI   0x44a7379abc48666d
//#endif
//#ifndef RADIOLIB_LORAWAN_APP_KEY   // Replace with your App Key "2b7e151628aed2a6abf7158809cf4f3c" 
#define RADIOLIB_LORAWAN_APP_KEY   0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c 
//#endif

//#ifndef RADIOLIB_LORAWAN_NWK_KEY   // Put your Nwk Key here "6eadbfd6d9114fd5a641-1e10b06748de"
#define RADIOLIB_LORAWAN_NWK_KEY   0x6e, 0xad, 0xbf, 0xd6, 0xd9, 0x11, 0x4f, 0xd5, 0xa6, 0x41, 0x1e, 0x10, 0xb0, 0x67, 0x48, 0xde 
//#endif

// for the curious, the #ifndef blocks allow for automated testing &/or you can
// put your EUI & keys in to your platformio.ini - see wiki for more tips

// regional choices: EU868, US915, AU915, AS923, AS923_2, AS923_3, AS923_4, IN865, KR920, CN500
const LoRaWANBand_t Region = EU868;
const uint8_t subBand = 0;  // For US915, change this to 2, otherwise leave on 0

// ============================================================================
// Below is to support the sketch - only make changes if the notes say so ...

// copy over the EUI's & keys in to the something that will not compile if incorrectly formatted
uint64_t joinEUI =   RADIOLIB_LORAWAN_JOIN_EUI;
uint64_t devEUI  =   RADIOLIB_LORAWAN_DEV_EUI;
uint8_t appKey[] = { RADIOLIB_LORAWAN_APP_KEY };
uint8_t nwkKey[] = { RADIOLIB_LORAWAN_NWK_KEY };

//STM32WLE5JC - rak3172
static const uint32_t rfswitch_pins[] = {PB8, PC13, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC};
static const Module::RfSwitchMode_t rfswitch_table[] = {
  {STM32WLx::MODE_IDLE,  {LOW,  LOW}},
  {STM32WLx::MODE_RX,    {HIGH, LOW}},
  {STM32WLx::MODE_TX_LP, {LOW, HIGH}},
  {STM32WLx::MODE_TX_HP, {LOW, HIGH}},
  END_OF_MODE_TABLE,
};

// create the LoRaWAN node
LoRaWANNode node(&radio, &Region, subBand);

// result code to text - these are error codes that can be raised when using LoRaWAN
// however, RadioLib has many more - see https://jgromes.github.io/RadioLib/group__status__codes.html for a complete list
String stateDecode(const int16_t result) {
  switch (result) {
  case RADIOLIB_ERR_NONE:
    return "ERR_NONE";
  case RADIOLIB_ERR_CHIP_NOT_FOUND:
    return "ERR_CHIP_NOT_FOUND";
  case RADIOLIB_ERR_PACKET_TOO_LONG:
    return "ERR_PACKET_TOO_LONG";
  case RADIOLIB_ERR_RX_TIMEOUT:
    return "ERR_RX_TIMEOUT";
  case RADIOLIB_ERR_CRC_MISMATCH:
    return "ERR_CRC_MISMATCH";
  case RADIOLIB_ERR_INVALID_BANDWIDTH:
    return "ERR_INVALID_BANDWIDTH";
  case RADIOLIB_ERR_INVALID_SPREADING_FACTOR:
    return "ERR_INVALID_SPREADING_FACTOR";
  case RADIOLIB_ERR_INVALID_CODING_RATE:
    return "ERR_INVALID_CODING_RATE";
  case RADIOLIB_ERR_INVALID_FREQUENCY:
    return "ERR_INVALID_FREQUENCY";
  case RADIOLIB_ERR_INVALID_OUTPUT_POWER:
    return "ERR_INVALID_OUTPUT_POWER";
  case RADIOLIB_ERR_NETWORK_NOT_JOINED:
	  return "RADIOLIB_ERR_NETWORK_NOT_JOINED";
  case RADIOLIB_ERR_DOWNLINK_MALFORMED:
    return "RADIOLIB_ERR_DOWNLINK_MALFORMED";
  case RADIOLIB_ERR_INVALID_REVISION:
    return "RADIOLIB_ERR_INVALID_REVISION";
  case RADIOLIB_ERR_INVALID_PORT:
    return "RADIOLIB_ERR_INVALID_PORT";
  case RADIOLIB_ERR_NO_RX_WINDOW:
    return "RADIOLIB_ERR_NO_RX_WINDOW";
  case RADIOLIB_ERR_INVALID_CID:
    return "RADIOLIB_ERR_INVALID_CID";
  case RADIOLIB_ERR_UPLINK_UNAVAILABLE:
    return "RADIOLIB_ERR_UPLINK_UNAVAILABLE";
  case RADIOLIB_ERR_COMMAND_QUEUE_FULL:
    return "RADIOLIB_ERR_COMMAND_QUEUE_FULL";
  case RADIOLIB_ERR_COMMAND_QUEUE_ITEM_NOT_FOUND:
    return "RADIOLIB_ERR_COMMAND_QUEUE_ITEM_NOT_FOUND";
  case RADIOLIB_ERR_JOIN_NONCE_INVALID:
    return "RADIOLIB_ERR_JOIN_NONCE_INVALID";
  case RADIOLIB_ERR_N_FCNT_DOWN_INVALID:
    return "RADIOLIB_ERR_N_FCNT_DOWN_INVALID";
  case RADIOLIB_ERR_A_FCNT_DOWN_INVALID:
    return "RADIOLIB_ERR_A_FCNT_DOWN_INVALID";
  case RADIOLIB_ERR_DWELL_TIME_EXCEEDED:
    return "RADIOLIB_ERR_DWELL_TIME_EXCEEDED";
  case RADIOLIB_ERR_CHECKSUM_MISMATCH:
    return "RADIOLIB_ERR_CHECKSUM_MISMATCH";
  case RADIOLIB_ERR_NO_JOIN_ACCEPT:
    return "RADIOLIB_ERR_NO_JOIN_ACCEPT";
  case RADIOLIB_LORAWAN_SESSION_RESTORED:
    return "RADIOLIB_LORAWAN_SESSION_RESTORED";
  case RADIOLIB_LORAWAN_NEW_SESSION:
    return "RADIOLIB_LORAWAN_NEW_SESSION";
  case RADIOLIB_ERR_NONCES_DISCARDED:
    return "RADIOLIB_ERR_NONCES_DISCARDED";
  case RADIOLIB_ERR_SESSION_DISCARDED:
    return "RADIOLIB_ERR_SESSION_DISCARDED";
  }
  return "See https://jgromes.github.io/RadioLib/group__status__codes.html";
}

// helper function to display any issues
void debug(bool failed, const __FlashStringHelper* message, int state, bool halt) {
  if(failed) {
    Serial.print(message);
    Serial.print(" - ");
    Serial.print(stateDecode(state));
    Serial.print(" (");
    Serial.print(state);
    Serial.println(")");
    while(halt) { delay(1); }
  }
}

// helper function to display a byte array
void arrayDump(uint8_t *buffer, uint16_t len) {
  for(uint16_t c = 0; c < len; c++) {
    char b = buffer[c];
    if(b < 0x10) { Serial.print('0'); }
    Serial.print(b, HEX);
  }
  Serial.println();
}

#endif

Mar 27 14:30:23 dragino-291854 fwd[795]: [MACINFO~][JOIN_REQ]:{"Size":23, "Rssi":-90, "snr":7, "AppEUI":"F4F065F7D4CA7BB1", "DevEUI":"F565C0FE7D52AC10"}
Mar 27 14:30:23 dragino-291854 fwd[795]: [INFO~][PKTS][primary_server-UP] received Join_Req from DevEui: F565C0FE7D52AC10 (fcnt=0)
Mar 27 14:30:23 dragino-291854 fwd[795]: [PKTS~][primary_server-UP] {"rxpk":[{"jver":1,"tmst":117398955,"time":"2025-03-27T13:30:22.969354Z","chan":0,"rfch":1,"freq":868.100000,"mid": 8,"stat":1,"modu":"LORA","datr":"SF9BW125","codr":"4/5","rssis":-91,"lsnr":7.0,"foff":-975,"rssi":-90,"size":23,"data":"ALF7ytT3ZfD0EKxSff7AZfUAAHmM/Cg="}]}
Mar 27 14:30:23 dragino-291854 fwd[795]: [INFO~][NETWORK][primary_server-UP] PUSH_ACK received in 3 ms
Mar 27 14:30:23 dragino-291854 fwd[795]: [MACINFO~][JOIN_REQ]:{"Size":23, "Rssi":-90, "snr":7, "AppEUI":"F4F065F7D4CA7BB1", "DevEUI":"F565C0FE7D52AC10"}
Mar 27 14:30:23 dragino-291854 fwd[795]: [INFO~][PKTS][secondary_server-UP] received Join_Req from DevEui: F565C0FE7D52AC10 (fcnt=0)
Mar 27 14:30:23 dragino-291854 fwd[795]: [PKTS~][secondary_server-UP] {"rxpk":[{"jver":1,"tmst":117398955,"time":"2025-03-27T13:30:22.978686Z","chan":0,"rfch":1,"freq":868.100000,"mid": 8,"stat":1,"modu":"LORA","datr":"SF9BW125","codr":"4/5","rssis":-91,"lsnr":7.0,"foff":-975,"rssi":-90,"size":23,"data":"ALF7ytT3ZfD0EKxSff7AZfUAAHmM/Cg="}]}
Mar 27 14:30:23 dragino-291854 fwd[795]: [INFO~][NETWORK][primary_server-DOWN] PULL_ACK received in 5 ms
Mar 27 14:30:23 dragino-291854 fwd[795]: [INFO~][NETWORK][secondary_server-UP] PUSH_ACK received in 13 ms
Mar 27 14:31:49 dragino-291854 fwd[795]: [PKTS~][primary_server-DOWN] {"txpk":{"imme":false,"rfch":0,"powe":14,"ant":0,"brd":0,"tmst":122398955,"freq":868.1,"modu":"LORA","datr":"SF9BW125","codr":"4/5","ipol":true,"size":33,"data":"INKDXiRc9vXYxZWlTurOOe6lIAqx0QdzrFErCudil8RW"}}
Mar 27 14:31:49 dragino-291854 fwd[795]: lgw_time_on_air:1645: INFO: LoRa packet ToA: 247 ms
Mar 27 14:31:49 dragino-291854 fwd[795]: [DEBUG~][PKTS][primary_server-DOWN] A packet enqueue, us=122398955, cur_us=117829465
Mar 27 14:31:49 dragino-291854 fwd[795]: #########DEBUG###########
Mar 27 14:31:49 dragino-291854 fwd[795]: 20D2835E245CF6F5D8C595A54EEACE39EEA5200AB1D10773AC512B0AE76297C456
Mar 27 14:31:49 dragino-291854 fwd[795]: #########DEBUG###########
Mar 27 14:31:49 dragino-291854 fwd[795]: [MACINFO~][JOIN_ACCEPT]:{"Size":33, "NetID":"245CF6", "DevAddr":"95C5D8F5", "DLSettings":{"RX1DRoffset":2, "RX2DR":5}}
Mar 27 14:31:49 dragino-291854 fwd[795]: lgw_send:1353:  --- IN
Mar 27 14:31:49 dragino-291854 fwd[795]: lgw_send:1487:  --- OUT
Mar 27 14:31:49 dragino-291854 fwd[795]: [INFO~][JIT] send done on rf_chain 0 in count_us=122398955 with freq=868100000, SF9
Mar 27 14:31:49 dragino-291854 fwd[795]: [INFO~][NETWORK][secondary_server-DOWN] PULL_ACK received in 1 ms
Mar 27 14:31:49 dragino-291854 fwd[795]: [INFO~][NETWORK][primary_server-DOWN] PULL_ACK received in 1 ms
Mar 27 14:31:49 dragino-291854 fwd[795]: [INFO~][NETWORK][secondary_server-DOWN] PULL_ACK received in 1 ms
Mar 27 14:31:49 dragino-291854 fwd[795]: [INFO~][NETWORK][primary_server-DOWN] PULL_ACK received in 1 ms
Mar 27 14:31:49 dragino-291854 fwd[795]: [INFO~][NETWORK][secondary_server-DOWN] PULL_ACK received in 1 ms
Mar 27 14:31:49 dragino-291854 fwd[795]: [INFO~][NETWORK][primary_server-DOWN] PULL_ACK received in 1 ms
Mar 27 14:31:49 dragino-291854 fwd[795]: [INFO~][NETWORK][secondary_server-DOWN] PULL_ACK received in 1 ms
Mar 27 14:31:49 dragino-291854 fwd[795]: [INFO~][NETWORK][primary_server-DOWN] PULL_ACK received in 1 ms
Mar 27 14:31:49 dragino-291854 fwd[795]: [INFO~][NETWORK][secondary_server-DOWN] PULL_ACK received in 1 ms
Mar 27 14:31:49 dragino-291854 fwd[795]: [INFO~][NETWORK][primary_server-DOWN] PULL_ACK received in 1 ms

Is the LNS you use supports LoRaWAN 1.1.0? Maybe you can try 1.0.4?

You can try to do basic test using AT commands but you need to upload first RAKwireless default FW.

You can use STM32Cubeprogrammer - https://learn.rakwireless.com/hc/en-us/articles/26687606549911-How-To-Guide-STM32CubeProgrammer-for-RAK-Modules

Did I get the same result with LoRaWAN 1.1.0 as with 1.0.4
Chirpstack performs the join correctly, but the node doesn’t notice.

In the design, I only have one microprocessor, the RAK3172-T (STM32WLE5CC), so my code can’t work with AT commands.

Could you provide a link to a basic example for Arduino that doesn’t use AT commands? all run in STM32WLE5CC

Thanks

Hi @jpa ,

Please use STM32Cubeprogrammer to reupload the default FW of RAK3172-T.

Here’s the guide - https://learn.rakwireless.com/hc/en-us/articles/26687606549911-How-To-Guide-STM32CubeProgrammer-for-RAK-Modules (don’t forget to erase first!).

The FW to upload is here - https://downloads.rakwireless.com/RUI/RUI3/Image/RAK3172-T_latest_final.hex

Once the default FW is uploaded, please use this guide to program it and connect to Chirpstack - RAK3172 WisDuo LPWAN Module Quick Start Guide. This example uses TTN as LNS but the concept is the same. Please use LoRaWAN 1.0.3 or 1.0.4.

Is there an example without AT command?

Please pay attention on the link and references I provided. The link above is exactly using Arduino based code and not AT command.

Hi Carl

Could you give me an example of C-class Lorawan OTAA for using RUI3?

Thanks for your answers.

Hi @jpa ,

If you are using Arduino IDE, you can find it in the examples.

You have to change the class from A to C.

if (!api.lorawan.deviceClass.set(RAK_LORA_CLASS_C)

Please note that you need to have an uplink first after joining to activate class C.