Firmware hosting for Over-The-Air updates
Warning: This is experimental. API and internals will change.
Authorization
Once you have a firmware created, use the following:
x-ota-firmware-id: <id>
x-ota-firmware-key: <key>
Devices need to send:
x-ota-firmware-id: <firmware-id>
x-ota-device-id: <random-id>
Optionally, set the env OTA_SECRET
to require it for all endpoints:
x-ota-secret: <secret>
Status code
- 401
INVALID_AUTH
Allow a device to use OTA
Request headers
{
'x-ota-firmware-id': String,
'x-ota-firmware-key': String
}
Request body
{
device_id: String // Use 'all' to allow anyone
}
Status code
- 200
Deny a device to use OTA
Request headers
{
'x-ota-firmware-id': String,
'x-ota-firmware-key': String
}
Request body
{
device_id: String // Use 'all' to remove the anyone allowance
}
Status code
- 200
Upload a new OTA update
Request headers
{
'x-ota-firmware-id': String,
'x-ota-firmware-key': String
}
Request body
{
file: Object // E.g. send a file via multipart/form-data
}
Response body
{
hash: String
}
Status code
- 200
Check for updates
Request headers
{
'x-ota-firmware-id': String,
'x-ota-device-id': String
}
Response body (on status 200)
{
hash: String
}
Status code
- 200 New hash
- 204 Hash is up to date
- 404
FIRMWARE_NOT_UPLOADED
Download a firmware
Request headers
{
'x-ota-firmware-id': String,
'x-ota-device-id': String
}
Status code
- 200
- 404
FIRMWARE_NOT_AVAILABLE
How to self-host
Set environment variables by using the .env
file:
BACKEND_HOST = "127.0.0.1"
BACKEND_PORT = 1337
OTA_SECRET = "" # Optional to protect all endpoints
Run the server:
node app.js
MIT