aws-samples / aws-iot-core-lorawan

Quickly get started with AWS IoT Core for LoRaWAN with sample solutions (binary decoding, device and gateway monitoring, downlink, dashboarding, provisioning automation)
MIT No Attribution
78 stars 32 forks source link

fPort needed for decoder #4

Closed apachler closed 3 years ago

apachler commented 3 years ago

Issue

I am trying to implement a new decoder for a device that sends different messages on different ports. Because the actual implementation of lambda_handler in app.py does not pass the fPort to the decoder, it is impossible to differentiate between these messages.

Device

NAS Pulse Reader UM3080 specification

Request

What would be the best approach to make the fPort available for the decoder?

Any other ideas?

Just wanted to discuss how it should be implemented. I am going to do the whole refactoring for all decoders once the desired approach is defined.

Thanks!

asvand commented 3 years ago

Hi Andreas,

thanks for your feedback!

I suggest to adjust app.py so that is passes he fPort as a parameter additionally to the PayloadData in the dict_from_payload function of the decoder. By doing so, we would make dict_from_payload logic agnostic of the invocation context or AWS IoT Core for LoRaWAN, so it could be reused by customers in other contexts.

Does it make sense for you? If you agree, I would make an according adjustment in app.py

apachler commented 3 years ago

Hi Andrei,

yes, that sounds good to me ;)

If you are done with your adjustments I am going to complete the NAS UM3080 payload decoder and create a pull request for it ...

Thanks!

asvand commented 3 years ago

Hi Andreas, take a look at the implementation in branch feature/transform_binary_payload/fport:

https://github.com/aws-samples/aws-iot-core-lorawan/blob/feature/transform_binary_payload/fport/transform_binary_payload/src-payload-decoders/python/sample_device.py

app.py is also updated accordingly.

If that works for you, I will merge it into master.

apachler commented 3 years ago

Sure, that will work quite well 👍

asvand commented 3 years ago

Done!