Example-lorawan on Bluepill board

Hey! So I’ve been researching for a LoRaWAN stack to develop a new project within our team, but as common knowledge the chip scarcity has afflicted us in the way of searching the right MCU (and therefore the OS to use).

A simple ardunio-lmic program was develop to test the available hardware (stm32f103cb with sx1276 transceiver) with positive results (TTN OTAA join accepted by the gateway [Dragino DLOS8 outdoor LoRaWAN], and packets sent from the node)

After several hours of trying the mbedOS LoRaWAN stack, I decided to test RIOT-OS. I have ported example/lorawan (based on B-L072-LW stm32 board) to the bluepill (stm32f103CX, 64 and 128kb flash available boards), but every connection try, the join request fails. I don’t even see the join request on the TTN console. Working on 915MHz and the frequency plan was correctly set in the Makefile of the example.

Checked the keys 1000 times and also created a new device in the TTN console to discard any troubles with the TTN application platform.

With DEBUG enabled on semtech_loramac.h, this is the output from the terminal:

2021-04-01 15:24:27,087 # LoRaWAN Class A low-power application
2021-04-01 15:24:27,090 # =====================================
2021-04-01 15:24:27,094 # [semtech-loramac] initializing loramac
2021-04-01 15:24:27,165 # Starting join procedure
2021-04-01 15:24:27,168 # [semtech-loramac] Starting join procedure: 0
2021-04-01 15:24:27,171 # [semtech-loramac] loramac cmd msg
2021-04-01 15:24:27,175 # [semtech-loramac] starting OTAA join
2021-04-01 15:24:27,593 # [semtech-loramac] Transmission completed
2021-04-01 15:24:29,733 # [semtech-loramac] MAC timer timeout
2021-04-01 15:24:30,736 # [semtech-loramac] MAC timer timeout
2021-04-01 15:24:31,740 # [semtech-loramac] MAC timer timeout
2021-04-01 15:24:32,743 # [semtech-loramac] MAC timer timeout
2021-04-01 15:24:33,747 # [semtech-loramac] MAC timer timeout
2021-04-01 15:24:34,048 # [semtech-loramac] MAC timer timeout
2021-04-01 15:24:34,187 # [semtech-loramac] RX timer timeout
2021-04-01 15:24:34,750 # [semtech-loramac] MAC timer timeout
2021-04-01 15:24:35,020 # [semtech-loramac] MAC timer timeout
2021-04-01 15:24:35,263 # [semtech-loramac] RX timer timeout
2021-04-01 15:24:35,753 # [semtech-loramac] MAC timer timeout
2021-04-01 15:24:35,757 # [semtech-loramac] MLME confirm event
2021-04-01 15:24:35,761 # [semtech-loramac] MLME confirm msg received
2021-04-01 15:24:35,764 # [semtech-loramac] join not successful
2021-04-01 15:24:35,766 # Join procedure failed

Greetings from Chile!

Hi there!

There have been two topics related to LoRaWAN recently:

I’m not saying they’re identical, but maybe the suggestions posted there can be of use for you.

Thanks very much for the response, I’ve already looked into those topics and forward to try ABP test to tell if the gateway receives the packet.

[Update]: As stated before, I tried tests (pkg/semtech_loramac, tests/drivers_sx127x) and after getting some problems with pyterm and riot-shell (fixed using socat on Ubuntu 20.04) I was able to command the bluepill with the terminal in order to execute the tests.

On pkg/semtech_loramac OTAA join fails (exactly as example/lorawan) but ABP join is successful but I still don’t see any payload being sent to the gateway (tried diferent loramac tx {msg} uncnf 42)

On tests/drivers_sx127x I was able to get random numbers from sx1276 and able to set the configuration parameters, but I don’t have another node to set as point-to-point testbench.

I tried changing the LoRa module with the Dragino RPi LoRa hat with same results (arduino-lmic otaa joins after few tries but works).

Looks like you have a similar setup as me. When configuring your Dragino as a gateway, do you see data in stdout when the node sends its Join request?

Hi @aidiaz

The problem you describe seems to be something with the radio configuration. The fact ABP joins is because the only thing it does is setting the NWKSKEY and APPSKEY. There’s no handshake.

If you were able to use drivers_sx127x it means the SPI connection is OK, and you are selecting the right SX127x version (otherwise the initialization would fail).

Some questions:

  • How are you setting the 915 MHz band in Semtech LoRaMAC? Could you send the snippet?
  • Could you enable debug in the driver and post the results backs? Feel free to apply the following patch:
diff --git a/drivers/sx127x/sx127x.c b/drivers/sx127x/sx127x.c
index 4ca4577cda..01c13481c6 100644
--- a/drivers/sx127x/sx127x.c
+++ b/drivers/sx127x/sx127x.c
@@ -41,7 +41,7 @@
 #include "sx127x_registers.h"
 #include "sx127x_netdev.h"
 
-#define ENABLE_DEBUG 0
+#define ENABLE_DEBUG 1
 #include "debug.h"
 
 /* The reset signal must be applied for at least 100 µs to trigger the manual
diff --git a/drivers/sx127x/sx127x_getset.c b/drivers/sx127x/sx127x_getset.c
index 371ce746be..bb1c15b946 100644
--- a/drivers/sx127x/sx127x_getset.c
+++ b/drivers/sx127x/sx127x_getset.c
@@ -34,7 +34,7 @@
 #include "sx127x_registers.h"
 #include "sx127x_internal.h"
 
-#define ENABLE_DEBUG 0
+#define ENABLE_DEBUG 1
 #include "debug.h"
 
 uint8_t sx127x_get_state(const sx127x_t *dev)
diff --git a/drivers/sx127x/sx127x_internal.c b/drivers/sx127x/sx127x_internal.c
index c49b6ac9c0..ac994de412 100644
--- a/drivers/sx127x/sx127x_internal.c
+++ b/drivers/sx127x/sx127x_internal.c
@@ -34,7 +34,7 @@
 #include "sx127x_internal.h"
 #include "sx127x_params.h"
 
-#define ENABLE_DEBUG 0
+#define ENABLE_DEBUG 1
 #include "debug.h"
 
 
diff --git a/drivers/sx127x/sx127x_netdev.c b/drivers/sx127x/sx127x_netdev.c
index d6829b779a..06267dac66 100644
--- a/drivers/sx127x/sx127x_netdev.c
+++ b/drivers/sx127x/sx127x_netdev.c
@@ -34,7 +34,7 @@
 #include "sx127x_netdev.h"
 #include "sx127x.h"
 
-#define ENABLE_DEBUG 0
+#define ENABLE_DEBUG 1
 #include "debug.h"
 
 /* Internal helper functions */
  • Could you also try tests/pkg_semtech_loramac? You would have more control from there.

Please let us know how it goes.

PS: Chileno por acá también!

@jia200x, the outputs with the debug enabled on the suggested files:

[sx127x] netdev: initializing driver...
[sx127x] SPI_0 initialized with success
[sx127x] SX1276 transceiver detected
[sx127x] Set channel: 868000000
[sx127x] Set channel: 923299987
[sx127x] Set op mode: SLEEP
[sx127x] initializing radio settings
[sx127x] Set channel: 868300000
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set power: 14
[sx127x] Set bandwidth: 0
[sx127x] Set spreading factor: 7
[sx127x] Set coding rate: 1
[sx127x] Set CRC: 1
[sx127x] Set freq hop: 0
[sx127x] Set Hop period: 0
[sx127x] Set fixed header length: 0
[sx127x] Set IQ invert: 0
[sx127x] Set payload len: 0
[sx127x] Set preamble length: 8
[sx127x] Set symbol timeout: 10
[sx127x] Set RX single: 0
[sx127x] Set TX timeout: 30000
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] netdev: initialization done
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set op mode: RECEIVER
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set syncword: 34
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set syncword: 34
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
main(): This is RIOT! (Version: 2021.04-devel-1253-ge3f39)
All up, running the shell now

And after setting up the keys and trying loramac join otaa:

[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set op mode: RECEIVER
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set channel: 914100000
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set bandwidth: 0
[sx127x] Set coding rate: 1
[sx127x] Set spreading factor: 10
[sx127x] Set CRC: 1
[sx127x] Set freq hop: 0
[sx127x] Set Hop period: 0
[sx127x] Set fixed header length: 0
[sx127x] Set IQ invert: 0
[sx127x] Set power: 30
[sx127x] Set preamble length: 8
[sx127x] Set TX timeout: 3000
[sx127x] Set max payload len: 23
[sx127x] Sending packet now.
[sx127x] Modem option is LoRa.
[sx127x] Set payload len: 23
[sx127x] Set standby
[sx127x] Set op mode: STANDBY
[sx127x] Change state: IDLE
[sx127x] Waiting for chip to wake up.
[sx127x] Wrote to payload buffer.
[sx127x] Change state: TX
[sx127x] Set op mode: TRANSMITTER
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
Join procedure failed!

I can’t even seem to receive the join request on the gateway. As done before, re-re-re-tested the hardware running arduino-lmic and join OTAA succeeds.

Tried flashing the bluepill with LORA_REGION=US915 make flash term BOARD=bluepill, with same results.

Gracias!

Forgot to connect DIO0-1-2, @jia200x the actual output is:

loramac join otaa
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set op mode: RECEIVER
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set channel: 914300000
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set bandwidth: 0
[sx127x] Set coding rate: 1
[sx127x] Set spreading factor: 10
[sx127x] Set CRC: 1
[sx127x] Set freq hop: 0
[sx127x] Set Hop period: 0
[sx127x] Set fixed header length: 0
[sx127x] Set IQ invert: 0
[sx127x] Set power: 30
[sx127x] Set preamble length: 8
[sx127x] Set TX timeout: 3000
[sx127x] Set max payload len: 23
[sx127x] Sending packet now.
[sx127x] Modem option is LoRa.
[sx127x] Set payload len: 23
[sx127x] Set standby
[sx127x] Set op mode: STANDBY
[sx127x] Change state: IDLE
[sx127x] Waiting for chip to wake up.
[sx127x] Wrote to payload buffer.
[sx127x] Change state: TX
[sx127x] Set op mode: TRANSMITTER
[sx127x] Change state: IDLE
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set channel: 925700000
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set bandwidth: 2
[sx127x] Set coding rate: 1
[sx127x] Set spreading factor: 10
[sx127x] Set preamble length: 8
[sx127x] Set fixed header length: 0
[sx127x] Set payload len: 0
[sx127x] Set CRC: 0
[sx127x] Set freq hop: 0
[sx127x] Set Hop period: 0
[sx127x] Set IQ invert: 1
[sx127x] Set symbol timeout: 65
[sx127x] Set RX single: 1
[sx127x] Set max payload len: 255
[sx127x] Set RX timeout: 3000
[sx127x] Set RX
[sx127x] Change state: RX
[sx127x] Set op mode: RECEIVER SINGLE
[sx127x] Change state: IDLE
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set channel: 923300000
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set bandwidth: 2
[sx127x] Set coding rate: 1
[sx127x] Set spreading factor: 12
[sx127x] Set preamble length: 8
[sx127x] Set fixed header length: 0
[sx127x] Set payload len: 0
[sx127x] Set CRC: 0
[sx127x] Set freq hop: 0
[sx127x] Set Hop period: 0
[sx127x] Set IQ invert: 1
[sx127x] Set symbol timeout: 29
[sx127x] Set RX single: 1
[sx127x] Set max payload len: 66
[sx127x] Set RX timeout: 3000
[sx127x] Set RX
[sx127x] Change state: RX
[sx127x] Set op mode: RECEIVER SINGLE
[sx127x] Change state: IDLE
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
Join procedure failed!

Runned latest example/lorawan with debug info enabled. Freshly TTN keys in the makefile, and region set to US915.

main(): This is RIOT! (Version: 2021.04-devel-1253-ge3f39)
LoRaWAN Class A low-power application
=====================================
[semtech-loramac] initializing loramac
[sx127x] netdev: initializing driver...
[sx127x] SPI_0 initialized with success
[sx127x] SX1276 transceiver detected
[sx127x] Set channel: 868000000
[sx127x] Set channel: 434000000
[sx127x] Set op mode: SLEEP
[sx127x] initializing radio settings
[sx127x] Set channel: 868300000
[sx127x] set modem: 1
[sx127x] Set op mode: SLEEP
[sx127x] Set power: 14
[sx127x] Set bandwidth: 0
[sx127x] Set spreading factor: 7
[sx127x] Set coding rate: 1
[sx127x] Set CRC: 1
[sx127x] Set freq hop: 0
[sx127x] Set Hop period: 0
[sx127x] Set fixed header length: 0
[sx127x] Set IQ invert: 0
[sx127x] Set payload len: 0
[sx127x] Set preamble length: 8
[sx127x] Set symbol timeout: 10
[sx127x] Set RX single: 0
[sx127x] Set TX timeout: 30000
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] netdev: initialization done
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set op mode: RECEIVER
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set syncword: 34
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set syncword: 34
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
Starting join procedure
[semtech-loramac] Starting join procedure: 0
[semtech-loramac] loramac cmd msg
[semtech-loramac] starting OTAA join
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set op mode: RECEIVER
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set channel: 914300000
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set bandwidth: 0
[sx127x] Set coding rate: 1
[sx127x] Set spreading factor: 10
[sx127x] Set CRC: 1
[sx127x] Set freq hop: 0
[sx127x] Set Hop period: 0
[sx127x] Set fixed header length: 0
[sx127x] Set IQ invert: 0
[sx127x] Set power: 30
[sx127x] Set preamble length: 8
[sx127x] Set TX timeout: 3000
[sx127x] Set max payload len: 23
[sx127x] Sending packet now.
[sx127x] Modem option is LoRa.
[sx127x] Set payload len: 23
[sx127x] Set standby
[sx127x] Set op mode: STANDBY
[sx127x] Change state: IDLE
[sx127x] Waiting for chip to wake up.
[sx127x] Wrote to payload buffer.
[sx127x] Change state: TX
[sx127x] Set op mode: TRANSMITTER
[sx127x] Change state: IDLE
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[semtech-loramac] Transmission completed
[semtech-loramac] MAC timer timeout
^A[semtech-loramac] MAC timer timeout
[semtech-loramac] MAC timer timeout
^E[semtech-loramac] MAC timer timeout
[semtech-loramac] MAC timer timeout
[semtech-loramac] MAC timer timeout
[sx127x] Set channel: 925700000
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set bandwidth: 2
[sx127x] Set coding rate: 1
[sx127x] Set spreading factor: 10
[sx127x] Set preamble length: 8
[sx127x] Set fixed header length: 0
[sx127x] Set payload len: 0
[sx127x] Set CRC: 0
[sx127x] Set freq hop: 0
[sx127x] Set Hop period: 0
[sx127x] Set IQ invert: 1
[sx127x] Set symbol timeout: 65
[sx127x] Set RX single: 1
[sx127x] Set max payload len: 255
[sx127x] Set RX timeout: 3000
[sx127x] Set RX
[sx127x] Change state: RX
[sx127x] Set op mode: RECEIVER SINGLE
[sx127x] Change state: IDLE
[semtech-loramac] RX timer timeout
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
^A[semtech-loramac] MAC timer timeout
[semtech-loramac] MAC timer timeout
[sx127x] Set channel: 923300000
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set bandwidth: 2
[sx127x] Set coding rate: 1
[sx127x] Set spreading factor: 12
[sx127x] Set preamble length: 8
[sx127x] Set fixed header length: 0
[sx127x] Set payload len: 0
[sx127x] Set CRC: 0
[sx127x] Set freq hop: 0
[sx127x] Set Hop period: 0
[sx127x] Set IQ invert: 1
[sx127x] Set symbol timeout: 29
[sx127x] Set RX single: 1
[sx127x] Set max payload len: 66
[sx127x] Set RX timeout: 3000
[sx127x] Set RX
[sx127x] Change state: RX
[sx127x] Set op mode: RECEIVER SINGLE
[sx127x] Change state: IDLE
[semtech-loramac] RX timer timeout
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[semtech-loramac] MAC timer timeout
[semtech-loramac] MLME confirm event
[semtech-loramac] MLME confirm msg received
[semtech-loramac] join not successful
Join procedure failed
main(): This is RIOT! (Version: 2021.04-devel-1253-ge3f39)
LoRaWAN Class A low-power application
=====================================
[semtech-loramac] initializing loramac
[sx127x] netdev: initializing driver...
[sx127x] SPI_0 initialized with success
[sx127x] SX1276 transceiver detected
[sx127x] Set channel: 868000000
[sx127x] Set channel: 434000000
[sx127x] Set op mode: SLEEP
[sx127x] initializing radio settings
[sx127x] Set channel: 868300000
[sx127x] set modem: 1
[sx127x] Set op mode: SLEEP
[sx127x] Set power: 14
[sx127x] Set bandwidth: 0
[sx127x] Set spreading factor: 7
[sx127x] Set coding rate: 1
[sx127x] Set CRC: 1
[sx127x] Set freq hop: 0
[sx127x] Set Hop period: 0
[sx127x] Set fixed header length: 0
[sx127x] Set IQ invert: 0
[sx127x] Set payload len: 0
[sx127x] Set preamble length: 8
[sx127x] Set symbol timeout: 10
[sx127x] Set RX single: 0
[sx127x] Set TX timeout: 30000
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] netdev: initialization done
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set op mode: RECEIVER
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set syncword: 34
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set syncword: 34
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
Starting join procedure
[semtech-loramac] Starting join procedure: 0
[semtech-loramac] loramac cmd msg
[semtech-loramac] starting OTAA join
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set op mode: RECEIVER
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set channel: 914300000
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set bandwidth: 0
[sx127x] Set coding rate: 1
[sx127x] Set spreading factor: 10
[sx127x] Set CRC: 1
[sx127x] Set freq hop: 0
[sx127x] Set Hop period: 0
[sx127x] Set fixed header length: 0
[sx127x] Set IQ invert: 0
[sx127x] Set power: 30
[sx127x] Set preamble length: 8
[sx127x] Set TX timeout: 3000
[sx127x] Set max payload len: 23
[sx127x] Sending packet now.
[sx127x] Modem option is LoRa.
[sx127x] Set payload len: 23
[sx127x] Set standby
[sx127x] Set op mode: STANDBY
[sx127x] Change state: IDLE
[sx127x] Waiting for chip to wake up.
[sx127x] Wrote to payload buffer.
[sx127x] Change state: TX
[sx127x] Set op mode: TRANSMITTER
[sx127x] Change state: IDLE
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[semtech-loramac] Transmission completed
[semtech-loramac] MAC timer timeout
[semtech-loramac] MAC timer timeout
[semtech-loramac] MAC timer timeout
[semtech-loramac] MAC timer timeout
[semtech-loramac] MAC timer timeout
[semtech-loramac] MAC timer timeout
[sx127x] Set channel: 925700000
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set bandwidth: 2
[sx127x] Set coding rate: 1
[sx127x] Set spreading factor: 10
[sx127x] Set preamble length: 8
[sx127x] Set fixed header length: 0
[sx127x] Set payload len: 0
[sx127x] Set CRC: 0
[sx127x] Set freq hop: 0
[sx127x] Set Hop period: 0
[sx127x] Set IQ invert: 1
[sx127x] Set symbol timeout: 65
[sx127x] Set RX single: 1
[sx127x] Set max payload len: 255
[sx127x] Set RX timeout: 3000
[sx127x] Set RX
[sx127x] Change state: RX
[sx127x] Set op mode: RECEIVER SINGLE
[sx127x] Change state: IDLE
[semtech-loramac] RX timer timeout
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[semtech-loramac] MAC timer timeout
[semtech-loramac] MAC timer timeout
[sx127x] Set channel: 923300000
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set bandwidth: 2
[sx127x] Set coding rate: 1
[sx127x] Set spreading factor: 12
[sx127x] Set preamble length: 8
[sx127x] Set fixed header length: 0
[sx127x] Set payload len: 0
[sx127x] Set CRC: 0
[sx127x] Set freq hop: 0
[sx127x] Set Hop period: 0
[sx127x] Set IQ invert: 1
[sx127x] Set symbol timeout: 29
[sx127x] Set RX single: 1
[sx127x] Set max payload len: 66
[sx127x] Set RX timeout: 3000
[sx127x] Set RX
[sx127x] Change state: RX
[sx127x] Set op mode: RECEIVER SINGLE
[sx127x] Change state: IDLE
[semtech-loramac] RX timer timeout
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[semtech-loramac] MAC timer timeout
[semtech-loramac] MLME confirm event
[semtech-loramac] MLME confirm msg received
[semtech-loramac] join not successful
Join procedure failed

Hi again,

I don’t see anything suspicious in the logs (besides the fact I would expect that the freq hop and hop period were set, but maybe it’s handled internally by the pkg). The Join Request procedure is doing what’s supposed to do and the region configuration seems to be fine.

How far are you from the gateway? Could you try a lower Datarate? (e.g DR0)

@akshaim might be able to help here, since he has a faraday cage next to him. I asked him offline if he could run those tests with US915. Let’s see what’s the outcome.

@jia200x thnx for the support, the DLOS8 (outdoor gateway) is >15m apart from the node and with a few doors in between (the other node seems to join without problems). DR0 showed the same results. Hope you can help, been pretty interested in testing class C LoRaWAN support from RIOT.

I’ve been using a LoRaWAN compliant gateway for the OTAA test, since single packet forwarders are no supported by TTN, so the gateway has been pretty much there all the time (tested about 2.5km in dense city). On other hand, the RPi Hat from Dragino has a sx1276 so can be used as a typical transceiver with a better pitch pinout (2.54mm vs 1.27mm) than common LoRa txrx available, and I used to discard hardware problems.

When joining with RIOT apparently I can’t see any package to be received as shown in the logs.

The logs you are referring to, are the logs of the gateway, the logs of the gateway tab in TTN or the Application Data in TTN?

In any case, the problem could be related to:

  1. The gateway is not receiving the frame (it’s either not sent or there’s an issue with the transmission power)
  2. The keys are wrong (e.g wrong endianness)

If 2., you should be able to see frames in both the gateway logs but not in the Application Data. If 1., you won’t be able to see messages at all.

If I understood correctly, you also have a Pi Hat with an sx1276? Could you then try to send raw messages between the Pi and a RIOT node running tests/driver_sx127x? Then we are able to confirm at least if packets go out of the radio.

@jia200x I’ve been tracking the 3 logs you refer (as I have other nodes in arduino platform that work). Due the results I would totally assume (1) is the actual scenario, because frames doesn’t show up at all (in any log). I will try raw radio between nodes, hope to come up with results same day, thanks!

@jia200x It seems like we have a problem. Join fails. I can see the join request on TTN ? Maybe a timing issue ?

So runned tests/driver_sx127x and actually received packages from the bluepill. Mounted a listener on a TTGO T3.

The output at the bluepill test (channel: 902MHz, BW:125kHz SF:7 CR:5)

sending "RIOT-OS" payload (8 bytes)
[sx127x] Sending packet now.
[sx127x] Modem option is LoRa.
[sx127x] Set payload len: 8
[sx127x] Set standby
[sx127x] Set op mode: STANDBY
[sx127x] Change state: IDLE
[sx127x] Waiting for chip to wake up.
[sx127x] Wrote to payload buffer.
[sx127x] Change state: TX
[sx127x] Set op mode: TRANSMITTER
[sx127x] Change state: IDLE
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
Transmission completed

The received packet on the LoRa listener:

So the radio is actually working.

Hi @aidiaz

Ok, there’s something at least. Could you try the following patch and send the results back?

diff --git a/drivers/sx127x/sx127x.c b/drivers/sx127x/sx127x.c
index 4ca4577cda..01c13481c6 100644
--- a/drivers/sx127x/sx127x.c
+++ b/drivers/sx127x/sx127x.c
@@ -41,7 +41,7 @@
 #include "sx127x_registers.h"
 #include "sx127x_netdev.h"
 
-#define ENABLE_DEBUG 0
+#define ENABLE_DEBUG 1
 #include "debug.h"
 
 /* The reset signal must be applied for at least 100 µs to trigger the manual
diff --git a/drivers/sx127x/sx127x_getset.c b/drivers/sx127x/sx127x_getset.c
index 371ce746be..bb1c15b946 100644
--- a/drivers/sx127x/sx127x_getset.c
+++ b/drivers/sx127x/sx127x_getset.c
@@ -34,7 +34,7 @@
 #include "sx127x_registers.h"
 #include "sx127x_internal.h"
 
-#define ENABLE_DEBUG 0
+#define ENABLE_DEBUG 1
 #include "debug.h"
 
 uint8_t sx127x_get_state(const sx127x_t *dev)
diff --git a/drivers/sx127x/sx127x_internal.c b/drivers/sx127x/sx127x_internal.c
index c49b6ac9c0..ac994de412 100644
--- a/drivers/sx127x/sx127x_internal.c
+++ b/drivers/sx127x/sx127x_internal.c
@@ -34,7 +34,7 @@
 #include "sx127x_internal.h"
 #include "sx127x_params.h"
 
-#define ENABLE_DEBUG 0
+#define ENABLE_DEBUG 1
 #include "debug.h"
 
 
diff --git a/drivers/sx127x/sx127x_netdev.c b/drivers/sx127x/sx127x_netdev.c
index d6829b779a..148d2b0c6c 100644
--- a/drivers/sx127x/sx127x_netdev.c
+++ b/drivers/sx127x/sx127x_netdev.c
@@ -34,7 +34,7 @@
 #include "sx127x_netdev.h"
 #include "sx127x.h"
 
-#define ENABLE_DEBUG 0
+#define ENABLE_DEBUG 1
 #include "debug.h"
 
 /* Internal helper functions */
@@ -89,10 +89,15 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
             /* Write payload buffer */
             for (const iolist_t *iol = iolist; iol; iol = iol->iol_next) {
                 if(iol->iol_len > 0) {
+                    uint8_t *p = iol->iol_base;
+                    for (unsigned i=0;i<iol->iol_len;i++) {
+                        printf("%02x ", p[i]);
+                    }
                     sx127x_write_fifo(dev, iol->iol_base, iol->iol_len);
                     DEBUG("[sx127x] Wrote to payload buffer.\n");
                 }
             }
+            printf("\n");
             break;
         default:
             DEBUG("[sx127x] netdev: Unsupported modem (%d)\n",

Regardless of that, I have the impression the issue might be related to the TX power. I would have expected a higher SNR.

What sx127x shield are you using? I remember we had a similar issue with a LoRa shield because the PA_BOOST was not set. Sometimes other implementations enable it, which makes a huge difference in TX Power.

The semtech pkg falls back to RTC via ztimer, so I don’t think it’s a timing issue in this case. Also, if there was a timing issue, the EU868 wouldn’t join. As suggested above, I think it’s something regarding TX Power (PA_BOOST or related)

@jia200x, I could have messed with tx_power so first re runned tests/driver_sx127x without the patch and setup 125 7 5, channel set 902000000, everything else default. Results:

> main(): This is RIOT! (Version: 2021.01)
[sx127x] netdev: initializing driver...
[sx127x] SPI_0 initialized with success
[sx127x] SX1276 transceiver detected
[sx127x] Set channel: 868000000
[sx127x] Set channel: 434000000
[sx127x] Set op mode: SLEEP
[sx127x] initializing radio settings
[sx127x] Set channel: 868300000
[sx127x] set modem: 1
[sx127x] Set op mode: SLEEP
[sx127x] Set power: 14
[sx127x] Set bandwidth: 0
[sx127x] Set spreading factor: 7
[sx127x] Set coding rate: 1
[sx127x] Set CRC: 1
[sx127x] Set freq hop: 0
[sx127x] Set Hop period: 0
[sx127x] Set fixed header length: 0
[sx127x] Set IQ invert: 0
[sx127x] Set payload len: 0
[sx127x] Set preamble length: 8
[sx127x] Set symbol timeout: 10
[sx127x] Set RX single: 0
[sx127x] Set TX timeout: 30000
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] netdev: initialization done
Initialization successful - starting the shell now
> setup 125 7 5
setup 125 7 5
setup: setting 125KHz bandwidth
[sx127x] Set bandwidth: 0
[sx127x] Set spreading factor: 7
[sx127x] Set coding rate: 1
[Info] setup: configuration set with success
> channel 902000000
channel 902000000
usage: channel <get|set>
> channel set 902000000
channel set 902000000
[sx127x] Set channel: 902000000
New channel set
> send riotos
send riotos
sending "riotos" payload (7 bytes)
[sx127x] Sending packet now.
[sx127x] Modem option is LoRa.
[sx127x] Set payload len: 7
[sx127x] Set standby
[sx127x] Set op mode: STANDBY
[sx127x] Change state: IDLE
[sx127x] Waiting for chip to wake up.
[sx127x] Wrote to payload buffer.
[sx127x] Change state: TX
[sx127x] Set op mode: TRANSMITTER
> [sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE

After the patch, same configuration:

> main(): This is RIOT! (Version: 2021.01)
[sx127x] netdev: initializing driver...
[sx127x] SPI_0 initialized with success
[sx127x] SX1276 transceiver detected
[sx127x] Set channel: 868000000
[sx127x] Set channel: 434000000
[sx127x] Set op mode: SLEEP
[sx127x] initializing radio settings
[sx127x] Set channel: 868300000
[sx127x] set modem: 1
[sx127x] Set op mode: SLEEP
[sx127x] Set power: 14
[sx127x] Set bandwidth: 0
[sx127x] Set spreading factor: 7
[sx127x] Set coding rate: 1
[sx127x] Set CRC: 1
[sx127x] Set freq hop: 0
[sx127x] Set Hop period: 0
[sx127x] Set fixed header length: 0
[sx127x] Set IQ invert: 0
[sx127x] Set payload len: 0
[sx127x] Set preamble length: 8
[sx127x] Set symbol timeout: 10
[sx127x] Set RX single: 0
[sx127x] Set TX timeout: 30000
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] netdev: initialization done
Initialization successful - starting the shell now
> setup 125 7 5
setup 125 7 5
setup: setting 125KHz bandwidth
[sx127x] Set bandwidth: 0
[sx127x] Set spreading factor: 7
[sx127x] Set coding rate: 1
[Info] setup: configuration set with success
> channel set 902000000
channel set 902000000
[sx127x] Set channel: 902000000
New channel set
> send RIOT
send RIOT
sending "RIOT" payload (5 bytes)
[sx127x] Sending packet now.
[sx127x] Modem option is LoRa.
[sx127x] Set payload len: 5
[sx127x] Set standby
[sx127x] Set op mode: STANDBY
[sx127x] Change state: IDLE
[sx127x] Waiting for chip to wake up.
52 49 4f 54 00 [sx127x] Wrote to payload buffer.

[sx127x] Change state: TX
[sx127x] Set op mode: TRANSMITTER
>

This time no payload received on listener.

When running examples\lorawan with the patch:

main(): This is RIOT! (Version: 2021.01)
LoRaWAN Class A low-power application
=====================================
[sx127x] SPI_0 initialized with success
[sx127x] SX1276 transceiver detected
[sx127x] Set channel: 868000000
[sx127x] Set channel: 434000000
[sx127x] Set op mode: SLEEP
[sx127x] set modem: 1
[sx127x] Set op mode: SLEEP
[sx127x] Set op mode: RECEIVER
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set syncword: 34
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set syncword: 34
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
Starting join procedure
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set op mode: RECEIVER
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
[sx127x] Set channel: 914300000
[sx127x] set modem: 1
[sx127x] already using modem: 1
[sx127x] Set freq hop: 0
[sx127x] Set bandwidth: 0
[sx127x] Set coding rate: 1
[sx127x] Set spreading factor: 10
[sx127x] Set CRC: 1
[sx127x] Set freq hop: 0
[sx127x] Set Hop period: 0
[sx127x] Set fixed header length: 0
[sx127x] Set IQ invert: 0
[sx127x] Set payload len: 0
[sx127x] Set power: 30
[sx127x] Set preamble length: 8
[sx127x] Set RX single: 0
[sx127x] Set TX timeout: 3000
[sx127x] Set max payload len: 23
[sx127x] Sending packet now.
[sx127x] Modem option is LoRa.
[sx127x] Set payload len: 23
[sx127x] Set standby
[sx127x] Set op mode: STANDBY
[sx127x] Change state: IDLE
[sx127x] Waiting for chip to wake up.
00 ce 0c 04 d0 7e d5 b3 70 be 8d 72 63 50 83 e3 00 f3 a6 e2 37 d0 7e [sx127x] Wrote to payload buffer.

[sx127x] Change state: TX
[sx127x] Set op mode: TRANSMITTER
[sx127x] Set sleep
[sx127x] Set op mode: SLEEP
[sx127x] Change state: IDLE
Join procedure failed

After all I still can’t see neither the join request and obviously the join accept frames (respect what @akshaim achieved with US915).

The module I’ve been running the past tests is:

Tested this one, with no join request received, exact same results.

image

Bluepill problem?