janjongboom/mbed-simulator

LoRaWAN example downlink from TTN results in -1001

pfhsfu opened this issue · 2 comments

Hi Jan / contributors,

First of all, thank you so much to spend the time setting up the examples and hosting the mbed-simulator for everyone! much appreciated. It made playing with TTN without any LoraWan devices a breeze experience!

I got the mbed-simulator device set up and connected to my TTN application.
The uplink works perfectly.

However, when I try to send downlink messages from TTN to the mbed-simulator, it wouldn't trigger the lora_event_handler() unless I press the send button from the mbed-simulator. The
lorawan.receive() would be triggered once and returns error code: -1001, LORAWAN_STATUS_WOULD_BLOCK.

I am just wondering if I am missing something to make the downlink to work between the TTN application and the mbed-simulator.

Again, thanks a lot for your work!

Cheers,
Peter

Hi Peter, the device is in class A mode, and LoRaWAN class A devices can only receive data after a transmission. This is why you need to send before calling receive.

When you receive you need to pass in the port number that you expect the message on. The LORAWAN_STATUS_WOULD_BLOCK message is sent when there's no message on this port. Try sending the downlink message on port 15, that should work.

There is a new API that makes this more clear, and we also have class C support (which allows for receiving at any point, without sending) but this is not released in the online simulator at this point. It is present in the offline version. Need to update the online version at some point.

Other than that, great that you like the simulator :-)

Hi Jan, Yes, changing the downlink port to 15 on the TTN application certainly worked!
I will try out the localhost version to play with class C support.

Thank you so much!