Version: 1.0
Status: ⚫⚪⚪
FirmwareControl plugin for Thunder framework.
This document describes purpose and functionality of the FirmwareControl plugin. It includes detailed specification about its configuration, methods and properties as well as sent notifications.
All identifiers of the interfaces described in this document are case-sensitive. Thus, unless stated otherwise, all keywords, entities, properties, relations and actions should be treated as such.
The table below provides and overview of acronyms used in this document and their definitions.
| Acronym | Description |
|---|---|
| API | Application Programming Interface |
| HTTP | Hypertext Transfer Protocol |
| JSON | JavaScript Object Notation; a data interchange format |
| JSON-RPC | A remote procedure call protocol encoded in JSON |
The table below provides and overview of terms and abbreviations used in this document and their definitions.
| Term | Description |
|---|---|
| callsign | The name given to an instance of a plugin. One plugin can be instantiated multiple times, but each instance the instance name, callsign, must be unique. |
| Ref ID | Description |
|---|---|
| HTTP | HTTP specification |
| JSON-RPC | JSON-RPC 2.0 specification |
| JSON | JSON specification |
| Thunder | Thunder API Reference |
Control Firmware upgrade to the device.
The plugin is designed to be loaded and executed within the Thunder framework. For more information about the framework refer to [Thunder].
The table below lists configuration options of the plugin.
| Name | Type | M/O | Description |
|---|---|---|---|
| callsign | string | mandatory | Plugin instance name (default: FirmwareControl) |
| classname | string | mandatory | Class name: FirmwareControl |
| locator | string | mandatory | Library name: libThunderFirmwareControl.so |
| startmode | string | mandatory | Determines in which state the plugin should be moved to at startup of the framework |
| configuration | object | optional | ... |
| configuration?.source | string | optional | Source URL or location of the firmware |
| configuration?.download | string | optional | Location where the firmware to be downloaded |
| configuration?.waittime | integer | optional | Maximum duration to finish download or install process |
This plugin implements the following interfaces:
- FirmwareControl.json (version 1.0.0) (compliant format)
The following methods are provided by the FirmwareControl plugin:
Built-in methods:
| Method | Description |
|---|---|
| versions | Retrieves a list of JSON-RPC interfaces offered by this service |
| exists | Checks if a JSON-RPC method or property exists |
| register | Registers for an asynchronous JSON-RPC notification |
| unregister | Unregisters from an asynchronous JSON-RPC notification |
FirmwareControl interface methods:
| Method | Description |
|---|---|
| upgrade | Upgrade the device to the given firmware |
| resume | Resume download from the last paused position |
versions method
Retrieves a list of JSON-RPC interfaces offered by this service.
This method takes no parameters.
| Name | Type | M/O | Description |
|---|---|---|---|
| result | array | mandatory | A list ofsinterfaces with their version numbers Array length must be at most 255 elements. |
| result[#] | object | mandatory | ... |
| result[#].name | string | mandatory | Name of the interface |
| result[#].major | integer | mandatory | Major part of version number |
| result[#].minor | integer | mandatory | Minor part of version number |
| result[#].patch | integer | mandatory | Patch part of version version number |
{
"jsonrpc": "2.0",
"id": 42,
"method": "FirmwareControl.1.versions"
}{
"jsonrpc": "2.0",
"id": 42,
"result": [
{
"name": "JMyInterface",
"major": 1,
"minor": 0,
"patch": 0
}
]
}exists method
Checks if a JSON-RPC method or property exists.
This method will return True for the following methods/properties: status, downloadsize, versions, exists, register, unregister, upgrade, resume.
| Name | Type | M/O | Description |
|---|---|---|---|
| params | object | mandatory | ... |
| params.method | string | mandatory | Name of the method or property to look up |
| Name | Type | M/O | Description |
|---|---|---|---|
| result | boolean | mandatory | Denotes if the method exists or not |
{
"jsonrpc": "2.0",
"id": 42,
"method": "FirmwareControl.1.exists",
"params": {
"method": "status"
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": false
}register method
Registers for an asynchronous JSON-RPC notification.
This method supports the following event names: upgradeprogress.
| Name | Type | M/O | Description |
|---|---|---|---|
| params | object | mandatory | ... |
| params.event | string | mandatory | Name of the notification to register for |
| params.id | string | mandatory | Client identifier |
| Name | Type | M/O | Description |
|---|---|---|---|
| result | null | mandatory | Always null |
| Message | Description |
|---|---|
ERROR_FAILED_REGISTERED |
Failed to register for the notification (e.g. already registered) |
{
"jsonrpc": "2.0",
"id": 42,
"method": "FirmwareControl.1.register",
"params": {
"event": "upgradeprogress",
"id": "myapp"
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": null
}unregister method
Unregisters from an asynchronous JSON-RPC notification.
This method supports the following event names: upgradeprogress.
| Name | Type | M/O | Description |
|---|---|---|---|
| params | object | mandatory | ... |
| params.event | string | mandatory | Name of the notification to register for |
| params.id | string | mandatory | Client identifier |
| Name | Type | M/O | Description |
|---|---|---|---|
| result | null | mandatory | Always null |
| Message | Description |
|---|---|
ERROR_FAILED_UNREGISTERED |
Failed to unregister from the notification (e.g. not yet registered) |
{
"jsonrpc": "2.0",
"id": 42,
"method": "FirmwareControl.1.unregister",
"params": {
"event": "upgradeprogress",
"id": "myapp"
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": null
}upgrade method
Upgrade the device to the given firmware. (Note: Ensure size of firmware image should be < 500MB).
Also see: upgradeprogress
| Name | Type | M/O | Description |
|---|---|---|---|
| params | object | mandatory | ... |
| params.name | string | mandatory | Name of the firmware |
| params?.location | string | optional | Location or URL of the firmware to be upgraded |
| params?.type | string | optional | Type of the firmware (must be one of the following: CDL, RCDL) |
| params?.progressinterval | integer | optional | Number of seconds between progress update events (5 seconds, 10 seconds etc). 0 means invoking callback only once to report final upgrade result |
| params?.hmac | string | optional | HMAC value of firmare |
| Name | Type | M/O | Description |
|---|---|---|---|
| result | null | mandatory | Always null (default: None) |
| Message | Description |
|---|---|
ERROR_INPROGRESS |
Operation in progress |
ERROR_INCORRECT_URL |
Invalid location given |
ERROR_UNAVAILABLE |
Error in download |
ERROR_BAD_REQUEST |
Bad file name given |
ERROR_ILLEGAL_STATE |
Invalid state of device |
ERROR_INCORRECT_HASH |
Incorrect hash given |
{
"jsonrpc": "2.0",
"id": 42,
"method": "FirmwareControl.1.upgrade",
"params": {
"name": "firmware_v.0",
"location": "http://my.site.com/images",
"type": "RCDL",
"progressinterval": 10,
"hmac": "2834e6d07fa4c7778ef7a4e394f38a5c321afbed51d54ad512bd3fffbc7aa5debc"
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": null
}resume method
Resume download from the last paused position.
Also see: upgradeprogress
| Name | Type | M/O | Description |
|---|---|---|---|
| params | object | mandatory | ... |
| params.name | string | mandatory | Name of the firmware |
| params?.location | string | optional | Location or URL of the firmware to be upgraded |
| Name | Type | M/O | Description |
|---|---|---|---|
| result | null | mandatory | Always null (default: None) |
| Message | Description |
|---|---|
ERROR_INPROGRESS |
Operation in progress |
ERROR_INCORRECT_URL |
Invalid location given |
ERROR_UNAVAILABLE |
Error in download |
ERROR_BAD_REQUEST |
Bad file name given |
ERROR_ILLEGAL_STATE |
Invalid state of device |
{
"jsonrpc": "2.0",
"id": 42,
"method": "FirmwareControl.1.resume",
"params": {
"name": "firmware_v.0",
"location": "http://my.site.com/images"
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": null
}The following properties are provided by the FirmwareControl plugin:
FirmwareControl interface properties:
| Property | R/W | Description |
|---|---|---|
| status | read-only | Current status of a upgrade |
| downloadsize | read-only | Max free space available to download image |
status property
Provides access to the current status of a upgrade.
This property is read-only.
Also see: upgradeprogress
| Name | Type | M/O | Description |
|---|---|---|---|
| (property) | string | mandatory | Upgrade status (must be one of the following: downloadaborted, downloadcompleted, downloadstarted, installaborted, installinitiated, installnotstarted, installstarted, none, upgradecancelled, upgradecompleted, upgradestarted) |
{
"jsonrpc": "2.0",
"id": 42,
"method": "FirmwareControl.1.status"
}{
"jsonrpc": "2.0",
"id": 42,
"result": "completed"
}downloadsize property
Provides access to the max free space available to download image.
This property is read-only.
| Name | Type | M/O | Description |
|---|---|---|---|
| (property) | integer | mandatory | Available free space in bytes |
{
"jsonrpc": "2.0",
"id": 42,
"method": "FirmwareControl.1.downloadsize"
}{
"jsonrpc": "2.0",
"id": 42,
"result": 315576
}Notifications are autonomous events triggered by the internals of the implementation and broadcasted via JSON-RPC to all registered observers. Refer to [Thunder] for information on how to register for a notification.
The following events are provided by the FirmwareControl plugin:
FirmwareControl interface events:
| Notification | Description |
|---|---|
| upgradeprogress | Notifies progress of upgrade |
upgradeprogress notification
Notifies progress of upgrade.
| Name | Type | M/O | Description |
|---|---|---|---|
| params | object | mandatory | ... |
| params.status | string | mandatory | Upgrade status (must be one of the following: downloadaborted, downloadcompleted, downloadstarted, installaborted, installinitiated, installnotstarted, installstarted, none, upgradecancelled, upgradecompleted, upgradestarted) |
| params.error | string | mandatory | Reason of error (must be one of the following: downloaddirectorynotexist, generic, incorrecthash, invalidparameters, invalidrange, invalidstate, noenoughspace, none, operationotsupported, resumenotsupported, timedout, unauthenticated, unavailable, unkown) |
| params.progress | integer | mandatory | Progress of upgrade (number of bytes transferred during download or percentage of completion during install |
{
"jsonrpc": "2.0",
"id": 42,
"method": "FirmwareControl.1.register",
"params": {
"event": "upgradeprogress",
"id": "myid"
}
}{
"jsonrpc": "2.0",
"method": "myid.upgradeprogress",
"params": {
"status": "completed",
"error": "operationotsupported",
"progress": 89
}
}The client ID parameter is passed within the notification designator, i.e.
<client-id>.upgradeprogress.