Skip to content

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 use swupdate as 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

  1. 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_version must be newer than the installed firmware, unless the plugin allows an equal or older one. See OTA Commands.

  2. Download the package:

    curl -X POST "$URL" -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
      -d '[{"n":"StartOTADownload","vs":"{\"id\":\"swupdate\"}"}]'
    
  3. Once the status is update_ready, install it:

    curl -X POST "$URL" -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
      -d '[{"n":"InstallOTAUpdate","vs":"{\"id\":\"swupdate\"}"}]'
    

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