Coming back to the IoT platform after a little break. This time trying to work a little more on the server side and actually put together some working code and work on the data reception end of things. Although not really talked about much in the posts here, a lot of time and effort was put into the gateway management system updating it for self registration, automatic updates, and automatic authentication certificate updates. Perhaps that can be dived into in more detail in a later post.

Looking at the system diagram below we will be looking at the hub portion of the system. Data comes in to the hub (which is the MQTT server) and then will be processed by a Python script subscribed to the MQTT channel. This Python script will take care of the “MQTT client” and “python data parser” parts of the server.

Thinking about how the server should function it might be better to not run everything in the same Python thread and therefore allowing each customer (group_id) to have its own independently running process. These processes would subscribe to the MQTT channel designated for the specific hub_id. The “hub manager” would hold a handle to, and keep track of each “hub parser” process.

Since we would also like to keep each device on its own independent MQTT channel the following MQTT channel structure is proposed for each “hub parser” to subscribe to…

Since each device will have its own channel it will be necessary to inform the “hub parser” when a new device is added so the appropriate channel can be subscribed to, the channel these commands will be sent to is proposed to be the following…

In order to request a “hub parser” process/instance to start/stop the individual “hub manager” will also need to monitor a channel to accept these start/stop commands under the following channel name…

The commands can be sent from inside the php script as hubs/devices are added through the management web interface.

Looking at this from a structure perspective each a customer (or “group”) can own one or more “hubs” and each “hub” can operate independently in its own instance, however, it will be managed by the “hub manager” (to keep track of the instance handles). As a new “hub” is added through the management interface a new “hub parser” instance can be started.

As of now let’s try to create the “hub manager” and then “hub parser” instances and see where we can get from there, and see what other things might be needed to connect everything together.

Leave a Reply

Your email address will not be published. Required fields are marked *