- Newest
- Most votes
- Most comments
Hi,
using DynamoDB to store decoder for each WirelessDeviceId and using this DynamoDB table in your Lambda could be a viable approach. In particular that approach makes sense if you need to store any additional per-device information (e.g. some metadata) in DynamoDB anyway. You could also use get_dynamod() and aws_lambda() in one rule.
However there is also an alternative which removes the need for DynamoDB table to store decoder for each WirelessDeviceId:
-
Create an individual Wireless Destination for each kind of device (i.e for each of decoders). E.g. if you have decoders A and B, you create Wireless Destinations Dest_A and Dest_B. Now if you have device D1,D2 of type A,, and devices D3,D4 of type B, you will need to ensure that each of devices is assigned an appropriate Wireless Destination (i.e. Dest_A for D1,D2 and Dest_B for D3 ,D4).
-
All of the Wireless Destinations should point to the same IoT Rule. However, in the topic field of the Wireless Destination (click on the "Advanced" dropdown in the console, you specify the name of the decoder (e.g. for decoder A you point to the IoT Rule "ProcescLoRaWANUplink" and use topic name "A")
-
Now in the IoT Rule you can use expression like:
select topic() as DecoderName, ....
- Now your Lambda function has access to the DecoderName.
This approach moves part of complexity to the management of relationship between the individual LoRaWAN device and correct Wireless Destination. It makes sense if decoder name is the only additional information you want to store per device, according to the requirements of your use case.
Let me know if it helped or if you have other questions here.
Relevant content
- asked 2 years ago
- Accepted Answerasked 2 months ago
- asked 2 months ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
Great thank you Andrei. I'm trying to make the unique destination/one rule method work. I've set up a test destination/rule combo and and am using the "Advanced" setting in the test destination with a topic of transformer01. In my rule I have the query SELECT *, topic() as TransformerName FROM 'test/lora/uplink' and republishing to test/lora/transformed. However, when I test using the MQTT interface, I get a result of TransformerName": "test/lora/uplink", which means the topic() isn't pulling the value of transformer01 in the destinations Advanced setting. What am I missing?
Also, if I try to drop the FROM 'test/lora/uplink' from the rule's query I get no messages (assuming that is what topic() is reading). This may be slightly off topic, but it's pretty confusing since the destination is configured to point directly to the rule, but it still needs to look for the topic on which the destination was published? Starting to get a little lost.... Thanks for your help!
Rookie mistake, I wasn't thinking that of course that wouldn't work with the MQTT test client as its not publishing to the destination only the topic specified in the interface. I just tested with a real device pointing to the new destination and it worked. Thank you!
Thanks for your feedback and great to hear that it worked! Please mark the question as answered, as it will help other customers to benefit from our fruitful discussion. Have a great day!