I am thinking about using AWS IoT for an application, where there are several thousands of small bitmap displays (connected with proprietary wireless protocol) behind (possibly hundreds of) distributed gateways (PCs or Raspberry Pi's).
So far I have come up with the following concept:
The gateway PC terminates the MQTT session. It has no own device table.
thingname = <gatewayId>_<displayId>
Display bitmaps are stored on S3 (filename = thingname)
Updating the displays is just replacing the S3 file and then updating the bitmap version (eg SHA) in the desired state of the device shadow.
The gateway would have to subscribe to the updates like
/update/<gatewayId>/#
There will be a rule that republishes from
/update/<gatewayId>_<displayId>
to/update/<gatewayId>/<displayId>
(because thingnames cannot contain slashes and wildcards in MQTT must be complete path components)For each received message, the gateway will download the bitmap from S3, send it to the display and then update the reported state to the new version.
How do I handle disconnected gateways, that come back online?
Subscriptions are not persistent, so I somehow need to find all things (from that gateway), where the desired state != reported state and update them again.
Can there be a rule to do that? The idea is to have the gateway publish a reconnect message (like /reconnect/<gatewayId>
) when it comes back online. The rule would have to find all device shadows for that gateway, where desired state != reported state and publish them.
NB: I know that I can program the mechanism without the device shadow with a database of its own. But the idea was to use the IoT mechanism for that.
Another question: Creating the bitmaps is really quick (could be a 1000 per second) , sending to the displays can be very slow (especially sending the first bitmap of a bunch can take a minute). So there might several thousand bitmaps (for one gateway) created before the first message can be confirmed. Is this a problem?