arduino-libraries / MKRWAN

An Arduino library for sending and receiving data using LoRaWAN protocol and LoRa® radios.
https://www.arduino.cc
GNU Lesser General Public License v3.0
86 stars 60 forks source link

Add method to get downlink port #22

Open ah01 opened 6 years ago

ah01 commented 6 years ago

There is no way how to find out port number of downlink message.

If I understand it correctly, port number is returned by modem (https://github.com/arduino/mkrwan1300-fw/blob/master/Projects/Multi/Applications/LoRa/AT_Slave/src/at.c#L848) but this information is not used by library (https://github.com/arduino-libraries/MKRWAN/blob/master/src/MKRWAN.h#L793).

facchinm commented 6 years ago

Hi @ah01 , I agree that exposing the downlink port could be useful but I need some recommendation on the actual usage, not being an hardcore LoRa user :slightly_smiling_face:

In fact, with the actual API, if you receive two different packets and avoid reading the first they end up in the same ringbuffer, ready to be retrieved.

This works well if the packet payload embeds the relevant information (about its size, for example, or its content). If I understand well, the downlink port information may be used to multiplex the stream to different "endpoints"; this makes it difficult to adapt to the actual APIs since it would need different streams (one per port).

Simply exposing last received packet port information may be misleading in case of multiple messages.