Skip to main content

OTA Endpoints

Over-the-Air (OTA) firmware update endpoints for ESP32 devices. These endpoints live at /toy/ota/.

There is a second set of OTA endpoints at /toy/device/ota/ (documented in Device Endpoints) that are used by the admin dashboard.

Endpoint Summary

MethodPathAuthDescription
POST/toy/ota/NoneFirmware version check and device registration (called on boot)
POST/toy/ota/activateNoneQuick device activation check
GET/toy/ota/NoneOTA system status and latest firmware versions

POST /toy/ota/

Called by the ESP32 on every boot. Registers or updates the device record and returns available firmware if an update is pending.

Request

MAC address is read from the Device-Id header first, falling back to mac or mac_address in the body.

Headers:

HeaderRequiredDescription
Device-IdPreferredDevice MAC address (e.g. AA:BB:CC:DD:EE:FF)
Client-IdOptionalClient identifier; defaults to Device-Id
Content-TypeYesapplication/json

Body (all fields optional except MAC resolution):

{
"mac": "AA:BB:CC:DD:EE:FF",
"mac_address": "AA:BB:CC:DD:EE:FF",
"version": "1.0.5",
"board": "esp32s3",
"flash_size": 8388608,
"chip_model_name": "ESP32-S3",
"chip_info": "rev3",
"application": "cheeko",
"ota": {}
}
FieldTypeDescription
mac / mac_addressstringMAC address fallback if Device-Id header absent
versionstringCurrent firmware version running on device
boardstringBoard type: esp32, esp32s3, esp32c3
flash_sizeintegerFlash size in bytes
chip_model_namestringChip model string
chip_infostringChip revision info
applicationstringApplication name
otaobjectOTA-specific metadata

Response

Note: this endpoint returns the raw payload without the standard { code, msg, data } envelope.

{
"device": {
"mac": "AA:BB:CC:DD:EE:FF",
"currentVersion": "1.0.5",
"board": "esp32s3",
"autoUpdate": true
},
"firmware": {
"version": "1.1.0",
"url": "https://cdn.example.com/firmware/cheeko-1.1.0.bin",
"size": 1234567,
"force": 0,
"name": "cheeko-1.1.0",
"remark": "Bug fixes and stability improvements"
},
"serverTime": {
"timestamp": 1711123456789,
"timezone": "UTC",
"offset": 0
}
}

firmware is null when no update is available or when the device already runs the latest version.

FieldTypeDescription
device.macstringNormalized MAC address
device.currentVersionstringVersion reported by device
device.boardstringBoard type
device.autoUpdatebooleanWhether auto-update is enabled for this device
firmwareobject or nullAvailable firmware; null if up to date
firmware.versionstringTarget firmware version
firmware.urlstringDownload URL
firmware.sizeintegerFile size in bytes
firmware.forceinteger0 = optional, 1 = forced update
firmware.namestringFirmware release name
firmware.remarkstringRelease notes
serverTime.timestampintegerServer Unix time in milliseconds
serverTime.timezonestringTimezone identifier
serverTime.offsetintegerUTC offset in minutes

Error responses

ConditionResponse
Missing MAC400 with { "code": 400, "msg": "Device ID is required..." }
Invalid MAC format400 with { "code": 400, "msg": "Invalid device ID format" }
Internal error200 with { "error": "<message>" }

POST /toy/ota/activate

Quick activation check. Returns HTTP 200 with body success for registered devices; returns HTTP 202 (empty body) for unregistered devices or when the MAC is missing.

Request

MAC address read from Device-Id header or mac body field.

{ "mac": "AA:BB:CC:DD:EE:FF" }

Response

ScenarioStatusBody
Device registered and active200success (plain text)
Device not found202(empty)
Missing MAC202(empty)
Internal error202(empty)

GET /toy/ota/

Returns current OTA system status and the latest available firmware version for each board type.

Request

Query paramTypeDescription
typestringOptional. Filter by board type (esp32, esp32s3, esp32c3). If omitted, returns all three.

Response

{
"code": 0,
"msg": "success",
"data": {
"status": "online",
"latestVersions": {
"esp32": {
"version": "1.1.0",
"forceUpdate": false
},
"esp32s3": {
"version": "1.1.0",
"forceUpdate": false
},
"esp32c3": {
"version": "1.0.8",
"forceUpdate": true
}
},
"serverTime": 1711123456789
}
}
FieldTypeDescription
statusstringAlways "online" when the API is reachable
latestVersionsobjectMap of board type → { version, forceUpdate }
latestVersions.<type>.versionstringLatest firmware version for that board
latestVersions.<type>.forceUpdatebooleanWhether this version is a forced update
serverTimeintegerServer Unix time in milliseconds

A board type key is omitted from latestVersions if no firmware record exists for it.