deploy Lambda and IoT Rule

1. Start deployment of a severless application with AWS Lambda function and AWS ioT Rule

Open AWS Lambda console by clicking on this link.

Alternatively, please open the Serverless Application Repository by clicking this link, confirm option “Show apps that create custom IAM roles or resource policies” and search for aws-iot-corelorawan-sampledecoder. Please click on the name of the application, i.e. “aws-iot-corelorawan-sampledecoder”. AWS Lambda console will start.

AWS Management Console

2. Select a decoder

Please scroll down to the bottom of the page. Please provide the parameter decoder name based on the following table. If you do not have any of the devices listed in the table, please select the decoder name “sample_device” to proceed with this workshop. You can also submit a request to include your device in this workshop by creating a new issue in our GitHub repository by clicking here. Please state the manufacturer and model of your LoRaWAN device. We will soon provide you a feedback on how your device can be used for this workshop.

Manufacturer Device Decoder name
Axioma W1 axioma_w1
Dragino LHT65 dragino_lht65
Dragino LBT1 dragino_lbt1
Dragino LSE01 dragino_lse01
Dragino LGT92 dragino_lgt92
Dragino LDS01 dragino_lds01
Browan Tabs Object Locator tabs_objectlocator
Other device or no device available yet sample_device

After that please check the box “I acknowledge that this app creates resource policies.” and click on “Deploy”.

AWS Management Console 3. Review deployment
Please wait few seconds for a successful deployment. After that please click on the name of the Lambda function “TransformLoRaWANBinaryPayloadFunction”. AWS Management Console

4. Create the test event
Please click on “Configure the test event” AWS Management Console In the window that opens, please provide the event name e.g. IoTCoreForLoRaWANEvent. After that please paste the following JSON content:

   {
       "PayloadData": "<Sample PayloadData>",
       "WirelessDeviceId": "57728ff8-5d1d-4130-9de2-f004d8722bc2",
       "WirelessMetadata": {
         "LoRaWAN": {
           "DataRate": 0,
           "DevEui": "a84041d55182720b",
           "FPort": 2,
           "Frequency": 867900000,
           "Gateways": [
             {
               "GatewayEui": "dca632fffe45b3c0",
               "Rssi": -76,
               "Snr": 9.75
             }
           ],
           "Timestamp": "2020-12-07T14:41:48Z"
         }
       } 
   }

AWS Management Console

5. Provide PayloadData sample

Please replace the string <Sample PayloadData> in the JSON document with a sample payload for the device you selected in step 2 according to this table. After that please click on “Create”.

Manufacturer Device name Sample “PayloadData”
Axioma W1 eoFaXxADAAAAwKRZXwMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
Dragino LHT65 y6QHxgG4AQhmf/8=
Dragino LSE01 AuHtlACmawQPVGM=
Dragino LGT92 DSEAAAEVCMUGpAA=
Dragino LBT1 DxwAAAIDQUJCQ0NEREVFRkYwMjcxMjFGNkFDMy0wNTk=
Browan Tabs Object Locator Ae48SPbhAgRupmA=
Other device or no device available yet Ae48SPbhAgRupmA=

AWS Management Console

6. Run a test

Please click on “Test”.

AWS Management Console

In the attribute TransformedPayloadData you can observe the result of binary decoding for the payload you specified in step 5. The output bellow assumes that you have selected “sample_device” in step 2. It will contain other attributes if you have selected other decoder in step 2.

AWS Management Console

6. Note the AWS Lamdbda function ARN

As a preparation for the next step, please note the ARN of the deployed AWS Lambda function. We will need this ARN later to review the created AWS IoT Rule.

AWS Management Console

7. Optional: review the source code of the binary decoder
Though not required for the purpose of this workshop, feel invited to switch to the “Code” section of the AWS Lambda function and inspect the Python source code. You will find the decoders for the individual devices in the directory decoders. The AWS Lambda function handler is in file app.py.

AWS Management Console