Github Repo | C Header | C source | JS source |
---|---|---|---|
mongoose-os-libs/rpc-service-ota | mgos_rpc_service_ota.h |
This service provides an ability to manage OTA on devices remotely.
It is possible to call this service programmatically via serial, HTTP/RESTful,
Websocket, MQTT or other transports
(see RPC section) or via the mos
tool.
See in-depth description of our OTA mechanism at Updating firmware reliably - embedded.com.
See OTA video tutorial:
Below is a list of exported RPC methods and arguments:
Trigger OTA firmware update. Arguments:
{
"url": "https://foo.com/fw123.zip", // Required. URL to the new firmware.
"commit_timeout": "300" // Optional. Time frame in seconds to do
// OTA.Commit after reboot. If commit is
// not done during the timeout, OTA rolls back.
}
A new firmware gets downloaded to the separate flash partition,
and is marked dirty. When the download is complete, device is rebooted.
After reboot, a firmware partition could become committed by calling
OTA.Commit
- in which case, it is marked as "good". Otherwise, a device
reboots back into the old firmware after the commit_timeout
seconds.
Example usage:
mos call OTA.Update '{"url": "http://1.2.3.4/fw.zip", "commit_timeout": 300}'
Commit current firmware. Arguments: none.
Example usage:
mos call OTA.Commit
Rolls back to the previous firmware. Arguments: none.
Example usage:
mos call OTA.Revert
Create new firmware patition with the copy of currently running firmware. Arguments:
{
// Optional. If true, then current firmware is uncommited, and needs to
// be explicitly commited after the first reboot. Otherwise, it'll reboot
// into the created snapshot. This option is useful if a dangerous, risky
// live update is to be done on the living device. Then, if the update
// fails and device bricks, it'll revert to the created good snapshot.
"set_as_revert": false,
// Optional. Same meaning as for OTA.Update
"commit_timeout": "300"
}
Example usage:
mos call OTA.CreateSnapshot
Get current boot state. Arguments: none.
Example usage:
mos call OTA.GetBootState
{
"active_slot": 0, # Currently active flash partition.
"is_committed": true, # Current firmware is marked as "good" (committed).
"revert_slot": 0, # If uncommitted, slot to roll back to.
"commit_timeout": 0 # Commit timeout.
}
Get current boot state. Arguments: see OTA.GetBootState
reply section.
Example usage:
mos call OTA.SetBootState '{"revert_slot": 1}'
bool mgos_rpc_service_ota_init(void);
void mgos_updater_rpc_finish(int error_code, int64_t id,
const struct mg_str src);
edit this doc__cplusplus