This firmware supports over-the-air (OTA) updates, allowing the device to download and apply new firmware versions without requiring physical access. The update process is managed via HTTP requests to a specified server hosting the firmware binary.
-
Firmware URL:
The firmware binary is hosted on an HTTP server. The URL for the firmware is hardcoded in the firmware as:http://192.168.2.20:5005/UpdateImages/firmware.bin
Ensure that the server is accessible and the firmware binary is available at this location.
-
Authentication:
The firmware supports basic authentication for the HTTP server. The credentials are defined in the firmware as:
- Username:
WEBDAV_NAME
- Password:
WEBDAV_PASS
- Update Trigger:
The firmware periodically checks for updates by comparing the current version (THIS_VERSION
) with the version available on the MQTT server. The URL for the current version is:
http://192.168.2.28:8093/v1/state/mqtt.0.WindowSensors.CurrentVersion
- Update Conditions:
- If the version available on the server is greater than the current version, the update process is initiated.
- The device downloads the firmware binary and streams it to the internal update library (
Update
).
- Update Completion:
- If the update is successful, the device restarts to apply the new firmware.
- If the update fails, an error message is logged, and the device continues running the current firmware.
The firmware uses MQTT to publish and log update-related information:
-
Current Version:
After a successful update, the device publishes the current firmware version to the topic:WindowSensors//currentVersion
-
Logs:
Update logs are published to the topic:
WindowSensors//log
- IP Address:
The device publishes its IP address to the topic:
WindowSensors//ipAddress
- MQTT Server:
The MQTT server is configured as:
192.168.2.28
nsure the server is reachable and properly configured to handle the topics.
- Device Class Identifier:
The device class identifier is set as:
WindowSensors
- MAC Address:
The last three bytes of the device's MAC address are used to uniquely identify the device in MQTT topics.
- The device checks the current firmware version from the MQTT server.
- If an update is available, it downloads the firmware binary from the specified URL.
- The update is applied, and the device restarts.
- After restarting, the device publishes its new version and IP address to the MQTT server.
- Ensure the firmware binary is compatible with the device.
- The HTTP server hosting the firmware must be reliable and accessible.
- Proper error handling is implemented to ensure the device remains operational in case of update failures.