main¶
Firmware boot entrypoint for the Oizom environmental monitor.
This module is the top-level entry point executed on the Raspberry Pi
firmware. It performs the minimal bootstrap required to bring the device
online: installing a global utils.oizom_logger.OizomLogger,
constructing a single Sensor.Sensor.Sensor orchestrator instance,
and handing control to that orchestrator for the remainder of the process
lifetime.
The sensor lifecycle proceeds in four phases:
The global logger is configured and installed so that all downstream modules emit through a consistent handler chain.
A
Sensor.Sensor.Sensorinstance is constructed, which loads the base configuration and prepares per-sensor wrappers derived fromSensorBase.SensorBase.GenericSensor.sensor.setup()fetches the device-specific configuration from the Gateway, instantiates each sensor wrapper, and starts the supporting communication threads.sensor.loop()enters the infinite read-average-publish cycle and blocks until the process is terminated.
This file is the Docker container CMD target in production and the
python3 main.py entry point for local development on the Pi.
Example
Launch the firmware locally on the device:
$ python3 main.py # doctest: +SKIP
Note
Only one Sensor.Sensor.Sensor instance must exist per process;
the module-level sensor singleton is created at import time so any
subsequent import of this module re-uses the same orchestrator rather
than constructing a second one.
Attributes¶
Functions¶
|
Boot the sensor orchestrator and run the firmware main loop. |
Module Contents¶
- main.main() None¶
Boot the sensor orchestrator and run the firmware main loop.
Performs the two-step firmware startup sequence on the module-level
Sensor.Sensor.Sensorsingleton: firstsetup()is invoked to pull device configuration from the Gateway and initialize everySensorBase.SensorBase.GenericSensorwrapper plus its supporting threads, thenloop()is invoked to enter the infinite read-average-publish cycle. This function does not return under normal operation; control only leaves the loop when the process is terminated or an unrecoverable exception propagates upward.- Parameters:
None – This function takes no arguments; it operates on the module-level
sensorsingleton.- Returns:
- This function does not return under normal operation. The
inner
sensor.loop()call blocks for the lifetime of the firmware process.
- Return type:
None
- Raises:
Exception – Any exception raised during
sensor.setup()orsensor.loop()is propagated unchanged so that the supervising process (Docker, systemd, or the developer shell) can observe the failure and trigger a restart.
Example
Invoke the firmware entrypoint directly from the device shell:
$ python3 main.py # doctest: +SKIP
Note
This function is intended to be called exactly once per process, from the
if __name__ == "__main__":guard at the bottom of this module. Calling it a second time would attempt to re-run setup on an already-initialized orchestrator and is not supported.
- main.context_logger¶
- main.sensor¶