# RPC Service - OTA (Over The Air updates) 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](/docs/mos/userguide/rpc.md)) or via the `mos` tool. See in-depth description of our OTA mechanism at [Updating firmware reliably - embedded.com](http://www.embedded.com/design/prototyping-and-development/4443082/Updating-firmware-reliably). See OTA video tutorial: Below is a list of exported RPC methods and arguments: ## OTA.Update Trigger OTA firmware update. Arguments: ```javascript { "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}'mos call OTA.Commitmos call OTA.Revertmos call OTA.CreateSnapshotmos 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.
}mos call OTA.SetBootState '{"revert_slot": 1}'