How to post a DeviceEUI to a IoT topic?

0

I have several Wireless/LoRa devices with their own DeviceId and DevEui identifiers. I have them routing their uplinks to a vanilla topic like devices/lorawan/uplink.

But I'd like them to post their uplinks on their own subtopic using their DevEui or DeviceId.

e.g. devices/lorawan/ab123fffe4567890/uplinks

I assume this is done using a Wireless destination, but it's not clear what the variable is when configuring the topic inside the destination settings. Something likedevices/lorawan/${WirelessMetadata.DevEui}/uplinks?

已提问 2 年前269 查看次数
1 回答
1
已接受的回答

Hi,

my proposed approach is to follow these steps:

  1. Point a Wireless Destination to an AWS IoT Rule (let's call it ProcessLoRaWANUplink)
  2. Use the following IoT SQL:
SELECT *
  1. Add "Republish" action and specify a topic as following:
 devices/lorawan/${WirelessMetadata.LoRaWAN.DevEui}/uplinks

Please notice:

  • You should double-check that including metadata is enabled in the Service Profile you assigned to the LoRaWAN device
  • Double-Check that IAM Role assigned to the "Republish" action us allowing "iot:Publish" to "devices/lorawan/*". In this specific case, I recommend not to use "Create role" option when creating an Action the Management Console, but create a role using AWS IAM Management Console, using the following trust relationship:
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "iot.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}

and the following policy:

{
    "Version": "2012-10-17",
    "Statement": {
        "Effect": "Allow",
        "Action": "iot:Publish",
        "Resource": "arn:aws:iot:<Region e.g. eu-west-1>:<Account id>:topic/devices/lorawan/*"
    }
}

best regards, Andrei

已回答 2 年前
  • Thank you! Got it working. Question though, is there any kind of scalability / pricing penalty for republishing which is effectively doubling the number of messages on the broker?

  • Short answer is: yes, there will be price impact and no, there are no scalability concerns I see here.

    Long answer: The IoT Core Message broker is not involved if you "just" specify an IoT Rule in your Wireless Destination. In such case you are billed "only" for the IoT Rules invocations and Actions executions.

    If you follow the approach proposed in my reply, you will additionally be billed for a/ Repbulishing action b/ IoT IoT Core Message broker publishing.

    Based on my experience I recommend to look to the actual cost estimation (https://aws.amazon.com/iot-core/pricing/), especially for LoRaWAN devices that typically ingest only few times a day / hour.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则