Hello everyone!
I’m using STM32F411 mcu with SX1272 radio as a LoRaWAN node with this LMiC library. I had to port it for F411 - change some registers, pins, ISR names etc. but it works - I’m able to see packets sent by my node in the TTN console.
But after few days of debugging I’m still not able to receive any downlink messages. Here is the piece of code responsible for printing out downlinks (in onEvent
function):
case EV_TXCOMPLETE:
// Check if we have a downlink on either Rx1 or Rx2 windows
if( ( LMIC.txrxFlags & ( TXRX_DNW1 | TXRX_DNW2 ) ) != 0 )
{
debug_str( "Received downlink\r\n");
if( LMIC.dataLen != 0 )
{ // data received in rx slot after tx
debug_buf( LMIC.frame + LMIC.dataBeg, LMIC.dataLen );
}
}
if( ( LMIC.txrxFlags & TXRX_ACK ) != 0 )
debug_str( "Received ACK\r\n" );
break;
The above code is based an downlink examples I was able to find so I think there’s nothing wrong with it.
Here is a piece of the node’s logs (the stm32 LMiC library I used didn’t have printing out debug informations implemented so I had to do this myself based on the arduino LMiC library, but to do this in simpler way, all numeric values are hexadecimal):
02D9BA84: engineUpdate, opmode = 0x00
02E13A85: engineUpdate, opmode = 0x08
02E13AD7: Uplink data pending
02E13B20: Airtime available at 02D9C352 (channel duty limit)
02E13BA3: Ready for uplink
02E13C1B: TXMODE, freq = 33BE27A0, len = 19, SF = 07, BW = 0000007D, CR = 4/05, IH 00000000
02E1B59B: RXMODE_SINGLE, freq = 33BE27A0, SF = 07, BW = 0000007D, CR = 4/05, IH = 00000000
02E1C960: RADIO RX TIMEOUT
02E1C9AF: RXMODE_SINGLE, freq = 33D3E608, SF = 0C, BW = 0000007D, CR = 4/05, IH = 00000000
02E1ECFB: RADIO RX TIMEOUT
TXCOMPLETE
02E43B98: engineUpdate, opmode = 0x00
02EBBB99: engineUpdate, opmode = 0x08
02EBBBEA: Uplink data pending
02EBBC34: Airtime available at 02E450AE (channel duty limit)
02EBBCB7: Ready for uplink
02EBBD2F: TXMODE, freq = 33BE27A0, len = 19, SF = 07, BW = 0000007D, CR = 4/05, IH 00000000
02EC36AF: RXMODE_SINGLE, freq = 33BE27A0, SF = 07, BW = 0000007D, CR = 4/05, IH = 00000000
02EC4A75: RADIO RX TIMEOUT
02EC4AC5: RXMODE_SINGLE, freq = 33D3E608, SF = 0C, BW = 0000007D, CR = 4/05, IH = 00000000
02EC6E11: RADIO RX TIMEOUT
TXCOMPLETE
02EE40E3: engineUpdate, opmode = 0x00
02F5C0E4: engineUpdate, opmode = 0x08
02F5C135: Uplink data pending
02F5C17F: Airtime available at 02EED1C2 (channel duty limit)
02F5C202: Ready for uplink
02F5C27A: TXMODE, freq = 33BE27A0, len = 19, SF = 07, BW = 0000007D, CR = 4/05, IH 00000000
02F63BFA: RXMODE_SINGLE, freq = 33BE27A0, SF = 07, BW = 0000007D, CR = 4/05, IH = 00000000
02F64FC0: RADIO RX TIMEOUT
02F65010: RXMODE_SINGLE, freq = 33D3E608, SF = 0C, BW = 0000007D, CR = 4/05, IH = 00000000
02F6735F: RADIO RX TIMEOUT
TXCOMPLETE
We can see that the node is sending uplink messages with 868.1Mhz (I’ve disabled all the other channels for debugging purposes, enabling them doesn’t solve the problem anyway), SF7BW125, CR 4/5 and then listening on RX1 window with the same settings and on RX2 window with 869.525Mhz, SF12BW125, CR4/5. The RX1 windows timing is correct (my OSTICKS_PER_SEC is 32768) - it opens about 1 second after TX. There’s something wrong with the second one - it should open after about 2 seconds but it seems to open directly after RX1. I don’t think that’s the cause since I’m aiming for RX1 window anyway.
Let’s take a look at the gateway’s logs then (lora_pkt_fwd by Semtech):
INFO: Received pkt from mote: 26011D57 (fcnt=101)
JSON up: {"rxpk":[{"tmst":4165619523,"chan":0,"rfch":1,"freq":868.100000,"stat":1,"modu":"LORA","datr":"SF7BW125",
"codr":"4/5","lsnr":10.2,"rssi":-62,"size":25,"data":"QFcdASYAZQABbA12gx8NtS3LBjDWdvABLQ=="}]}
INFO: [down] PULL_RESP received - tokem[169:243] :)
JSON down: {"txpk":{"imme":false,"tmst":4166619523,"freq":868.1,"rfch":0,"powe":14,"modu":"LORA","datr":"SF7BW125",
"codr":"4/5","ipol":true,"size":14,"ncrc":true,"data":"YFcdASYABAABmg5Gbr0="}}
INFO: tx_start_delay=1495 (1495.500000) - (1497, bw_delay=1.500000, notch_delay=0.000000)
INFO: [down] PULL_ACK received in 101 ms
##### 2018-08-10 17:08:06 GMT #####
### [UPSTREAM] ###
# RF packets received by concentrator: 2
# CRC_OK: 100.00%, CRC_FAIL: 0.00%, NO_CRC: 0.00%
# RF packets forwarded: 2 (50 bytes)
# PUSH_DATA datagrams sent: 3 (533 bytes)
# PUSH_DATA acknowledged: 0.00%
### [DOWNSTREAM] ###
# PULL_DATA sent: 3 (100.00% acknowledged)
# PULL_RESP(onse) datagrams received: 2 (380 bytes)
# RF packets sent to concentrator: 2 (33 bytes)
# TX errors: 0
# TX rejected (collision packet): 0.00% (req:5, rej:0)
# TX rejected (collision beacon): 0.00% (req:5, rej:0)
# TX rejected (too late): 0.00% (req:5, rej:0)
# TX rejected (too early): 0.00% (req:5, rej:0)
# BEACON queued: 0
# BEACON sent so far: 0
# BEACON rejected: 0
### [JIT] ###
# SX1301 time (PPS): 4108975322
src/jitqueue.c:471:jit_print_queue(): INFO: [jit] queue is empty
### [GPS] ###
# GPS sync is disabled
##### END #####
As we can see, the gateway receives the packet sent by the node and attempts to send the downlink with the same channel settings one second after the uplink packet reception. I don’t see any errors here neither - the downlink should fit into the node’s first RX window.
Things I’ve looked into so far:
LMIC_setClockError - the LMiC library I use didn’t have this function so I’ve implemented it on myself based on the arduino LMiC library. I was able to confirm that:
- without setting clock error RX1 starts ~1sec after TX and lasts for ~6ms
- with setting clock error at 1% RX1 starts ~1sec after TX and lasts for ~20ms
- with setting clock error at 10% RX1 starts ~1sec after TX and lasts for ~160ms
but even with 10% the downlinks are still not being received.
IQ inversion - I’ve confirmed that the node is listening correctly with inverted IQ.
Does anyone here have any suggestions about where else can I look for possible solutions?