Trigger OTA via HTTP¶
This guide covers driving a firmware update on a device through the ToloMEO HTTP API.
Prerequisites¶
- The device's control channel id and a bearer token
curl- A service running an
OTAPlugin. The examples useswupdateas the service name and the plugin id
Set the Endpoint¶
URL="https://apis.tolomeo.io/iot/http/channels/<control-channel-id>/messages/services%2Fswupdate%2Freq"
TOKEN="<your-token>"
Every command below is a POST to $URL with a SenML body.
Run an Update¶
-
Notify the update:
curl -X POST "$URL" -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d '[{"n":"NotifyOTAUpdate","vs":"{\"id\":\"swupdate\",\"fw_name\":\"firmware\",\"fw_version\":\"1.2.3\",\"url\":\"https://example.com/firmware/v1.2.3.swu\"}"}]'fw_versionmust be newer than the installed firmware, unless the plugin allows an equal or older one. See OTA Commands. -
Download the package:
-
Once the status is
update_ready, install it:
Recover from a Failure¶
Send the recovery command with the same curl call. Pick the command from the
recovery table:
curl -X POST "$URL" -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '[{"n":"AbortOTAUpdate","vs":"{\"id\":\"swupdate\"}"}]'
Warning
ResetOTAState is a hard reset for development and recovery. It drops the pending update, which must then be
notified again, and is refused while updating.
See also
- OTA Commands — every command, payload, reply and status event
- Trigger OTA via NATS — the same lifecycle with the NATS CLI, plus status reads and pauses