2026-05-19 4:37 AM
MCU : STM32WLE5CCU6
STM32CubeIde version : 2.1.1
STMC32CubeMx version : 6.17.0
Firmware Package Name and Version : STM32Cube FW_WL V1.5.0
Application : FUOTA using LoRaWAN
Setup : End Node(STM32WL) <===> Gateway(Dragino LPS8) <====> TTN
Hello everyone,
Before i step into complicated FUOTA using LoRaWAN, i was trying some custom downlink packets to switch to Class C from Class A.
I was successfully able to send uplink packets.
I was successfully able to get the downlink packets both confirmed and unconfirmed and glow led's and perform operations.
Now i want to send a downlink packet which switches to class c.
I have not enabled Additional LoRaWAN packages yet, i figured switching to class c might really don't need this as long as i am calling the correct API's
Basically if i send a downlink packet 0x01 from TTN, the device switches to Class C.
For switching to Class C, I am using `smtc_modem_set_class(STACK_ID, SMTC_MODEM_CLASS_C)` which itself doesn't return any error and the log says switched to class c.
I am reverifying using following code and this also returns class c.
smtc_modem_class_t myClass = 0;
smtc_modem_get_class(STACK_ID, &myClass);
Log for the same.
« Event received: ALARM
5200s000:###### TX Payload HEX: 01 00 81 69 1A 39 00 00
5200s000: TX MNG REQ time=05200000, final_time=05201743
5200s000: Next TX on freq 868500000, DR 1
5201s733: Payload: 40 B8 95 0B 26 80 02 00 02 26 A3 6C 6A 0C F9 1E F7 BC BB 16 3E
size: 21
5202s484: TX DONE
5202s484: RX1 LoRa at 5016 ms freq:868500000, DR 1, BW125, rx timeout 98 ms
5208s076: RX DONE
5208s076: RP: RX size 14
Event received: DOWNDATA
Data received on port 2
5208s077:RX Payload HEX: 01
5208s077:Command: switch to Class C
5208s077: RXC LoRa at 4 ms freq:869525000, DR 3, rx timeout 20 ms
5208s081:Class C enabled
Event received: TXDONE
After this when the next alarm fires, i get a bunch of write CMD error 1. This happens every reporting interval when i
try to send uplink packets.
« Event received: ALARM
5260s000:###### TX Payload HEX: 01 00 81 B3 1A 4D 00 00
5260s000: TX MNG REQ time=05260000, final_time=05265709
5260s000: Next TX on freq 868100000, DR 1
5265s750: write CMD error 15265s750: write CMD error 15265s750: write CMD error 15265s750: write CMD error 15265s750: write CMD error 15265s750: write CMD error 15265s750: write CMD error 15265s750: write CMD error 15265s750: write CMD error 15265s750: write CMD error 15265s750: Payload: 40 B8 95 0B 26 80 03 00 02 7A 54 1C 66 31 0E DF 1D AB 7C 06 26
size: 21
5265s751: write CMD error 15266s493: TX DONE
5266s493: write CMD error 15266s493: write CMD error 15266s493: RXC LoRa at 4 ms freq:869525000, DR 3, rx timeout 20 ms
5266s494: write CMD error 15266s494: write CMD error 15266s494: write CMD error 15266s494: write CMD error 15266s494: write CMD error 15266s494: write CMD error 15266s494: write CMD error 15266s494: write CMD error 15266s495: write CMD error 15266s497: write CMD error 15266s497: RX1 LoRa at 5012 ms freq:868100000, DR 1, BW125, rx timeout 98 ms
5271s499: write CMD error 15271s499: write CMD error 15271s499: write CMD error 15271s500: write CMD error 15271s500: write CMD error 15271s500: write CMD error 15271s500: write CMD error 15271s500: write CMD error 15271s500: write CMD error 15271s500: write CMD error 15271s500: write CMD error 15271s500: write CMD error 15271s509: write CMD error 15271s607: IRQ_RADIO_RX_TX_TIMEOUT
5271s607: write CMD error 15271s608: write CMD error 15271s608: RXC LoRa at 4 ms freq:869525000, DR 3, rx timeout 20 ms
5271s608: write CMD error 15271s608: write CMD error 15271s608: write CMD error 15271s608: write CMD error 15271s609: write CMD error 15271s609: write CMD error 15271s609: write CMD error 15271s609: write CMD error 15271s609: write CMD error 15271s612: write CMD error 15271s612: RX2 LoRa at 884 ms freq:869525000, DR 3, BW125, rx timeout 24 ms
5272s488: write CMD error 15272s488: write CMD error 15272s488: write CMD error 15272s489: write CMD error 15272s489: write CMD error 15272s489: write CMD error 15272s489: write CMD error 15272s489: write CMD error 15272s489: write CMD error 15272s489: write CMD error 15272s489: write CMD error 15272s489: write CMD error 15272s496: write CMD error 15272s520: IRQ_RADIO_RX_TX_TIMEOUT
5272s520: write CMD error 15272s520: write CMD error 15272s520: RXC LoRa at 4 ms freq:869525000, DR 3, rx timeout 20 ms
5272s521: write CMD error 15272s521: write CMD error 15272s521: write CMD error 15272s521: write CMD error 15272s521: write CMD error 15272s521: write CMD error 15272s521: write CMD error 15272s521: write CMD error 15272s522: write CMD error 15272s524: write CMD error 1Event received: TXDONE
After i traced the function causing this error i have forund
void SUBGRF_WriteCommand( SUBGHZ_RadioSetCmd_t Command, uint8_t *pBuffer, uint16_t Size ) {
HAL_StatusTypeDef status = HAL_OK;
CRITICAL_SECTION_BEGIN();
status = HAL_SUBGHZ_ExecSetCmd( &hsubghz, Command, pBuffer, Size ); CRITICAL_SECTION_END();
if(status !=0)
MW_LOG( TS_ON, VLEVEL_M, " write CMD error %d", status);
}
With the error also i am able to see data after every minute on TTN, the error doesn't effect any uplink transactions.
Another thing happens, as far as i understand(ignoring the error and considering that end node is in class c),
if i schedule a downlink that should be received as soon as i schedule it because device is in class c right?
But in my case it takes another uplink to get the downlink packet.
This makes me wonder though node is saying i am in class c, i am not sure if it is.
Any insight would be helpful.
Best regards
Devjeet Mandal
P.S i have attached my lora_app.c for your reference.
P.S I am not able to find accurate label so i am choosing a random. I was expecting a label called STM32WL or LoRaWAN.
2026-05-19 4:54 AM
Ok i was trying something where i disabled low power mode(i was using sleep and not stop, now i have disabled sleep also) and i now i am able to get unconfirmed downlinks as soon as queue it. Still i am getting the error.
Is the error critical? or should i leave it as it is and continue with FUOTA?
This is the log i am getting without alarm
« 7050s144: RX DONE
7050s145: RP: RX size 14
7050s145: write CMD error 17050s145: write CMD error 1Event received: DOWNDATA
Data received on port 2
7050s146:RX Payload HEX: 15
7050s146: RXC LoRa at 4 ms freq:869525000, DR 3, rx timeout 20 ms
7050s146: write CMD error 17050s146: write CMD error 17050s147: write CMD error 17050s147: write CMD error 17050s147: write CMD error 17050s147: write CMD error 17050s147: write CMD error 17050s147: write CMD error 17050s147: write CMD error 17050s150: write CMD error 1