After taking a little break to resolve some SSL certificate issues we turn our attention back to the current issue at hand, the server side Python script. As seen in the image below (the “python data parser”), this exists to forward the data coming in from the sensors (through MQTT) to a database or other parts of the server side. The “python data parser” is the current part of the system we are going to turn our attention to at the moment.

For review we are attempting to come up with a system that is a little like the below in which we have a Python script that acts as a manager for separately running instances of parsers (one per a hub), where a hub can have one or more gateways attached to it.

The first script, the hub_manager, will need to retrieve a list of hubs from the database (the hub table), then spawn a process of hub_parser for each of them. For reference the database tables are shown below. Each hub_parser will also need to connect into the MQTT server, meaning each will need its own SSL certificate, which we will have to take care of. If we want this system to be fully automated then the SSL certificates will also need to be automatically generated (and updated when they expire). For the present task we will just pre-create the required certificates then resolve the auto-creation process later.

Back to the hub_manager Python script, the startup process of the script will go something like this…
+ connect to the mySQL database
+ connect to the MQTT broker (server)
+ retrieve a list of hubs from the hub table above
+ iterate through the hub list and create an instance of hub_parser for each record in the list
+ monitor an MQTT channel (hub_manager/cmd) to spawn/end hubs that are created/deleted

Next we will look at the hub_parser script, which will be responsible for parsing the data incoming from the attached gateways and forwarding it to the database for storage, or other parts of the server side.

Leave a Reply

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