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);
}