An upgrade campaign defines the different steps required to go from a configuration A of a system to a configuration B. There are simple campaigns where only one component needs to be upgraded (custom application or firmware) and complex campaigns appears when both components need to be upgraded. Before starting your campaign, you have to identify all steps and write down a procedure. Upgrade campaigns are usually a repetition of simple steps, it is important to write down a procedure to avoid forgetting steps. To perform an upgrade campaign, you must:
- Authenticate
- Select devices you want to upgrade,
- Create upgrade batches,
- Perform upgrade and retries,
- Write a report
- Clean AirVantage
All these steps are described below.
The central entity in AirVantage is the system. A system is the combination of a firmware (application), connected device (hardware) and a subscription (SIM). All sub-items are optional (a system can just include a subscription or just a gateway).
Every feature of AirVantage User Interface is available through APIs.
Before starting with this tutorial, you may have a look to the folowing documentation:
In order to be able to use APIs, an API client must be registered in AirVantage which is explained in the How to create a new API client?
First, we prepare the campaign by the authentication and then we identify the list of systems to be upgraded and finally create the batch.
Step 1. First get an access token using Resource owner flow:
URL:
> POST https://eu.airvantage.net/api/oauth/token
Header:
Content-type : application/x-www-form-urlencoded
Body:
grant_type=password&username={{username}}&password={{password}}&client_id={{client_id}}&client_secret={{client_secret}}
Response:
{
"access_token": "o9GLplDRn3AVRyBnZOb1X-EBBvhWDOz4QnwsvSCvhCv9M-5K_yOfVzq5qiE0ACzbgzfNUjM7241MdSFNcb-wjw",
"expires_in": 86008,
"token_type": "Bearer",
"refresh_token": "KQ4kpSSCH7qlNjvrnj3HosmsJ-IuxJ4qTfORp6rv0nK-uULBTzs9G6T5vVyXE5vzlQvndf_yV71D0lPqZUDhLg“
}
The clientId and the Client Secret can be passed in base64 encoded in the header identified by {{client_id:client_secret}} in the following example:
URL:
> POST https://eu.airvantage.net/api/oauth/token
Header:
Content-type : application/x-www-form-urlencoded Authorization: Basic {{client_id:client_secret}}
Body:
grant_type=password&username={{username}}&password={{password}}
The response is the same.
Step 2. Then use this access token in all your APIs calls:
URL:
> GET https://eu.airvantage.net/api/v1/applications?name=myApplication
Header:
Authorization: bearer {{accessToken}}
Step 1. Find systems with a specific label:
URL:
> GET https://eu.airvantage.net/api/v1/systems?fields=uid,name,gateway&labels={{my_label}}
Header:
Authorization: bearer {{accessToken}}
Step 2. Find systems with an application:
URL:
> GET https://eu.airvantage.net/api/v1/systems?application=name:myApps&fields=uid,name,gateway
Header:
Authorization: bearer {{accessToken}}
Note: When you want to perform a complex campaign, divide it in several simple campaigns, for example you want to upgrade firmware and custom software, perform first the firmware upgrade campaign, and then the custom application upgrade campaign.
To easily find systems later put a label by selecting all devices (1) and choose the “change label” feature. For such campaign the label’s name can be: tmp_XXXX_YYYY where:
URL:
> PUT https://eu.airvantage.net/api/v1/systems/1cc562f8ec1340e79214f2113db751f6
Header:
Authorization: bearer {{accessToken}}
Content-Type: application/json
Body:
{
"labels" : ["tmp_fota_me", "working"]
}
We advise to perform upgrade campaign by batch. A good practice is to create a first batch of 10 devices to test the complete procedure then a batch 50 devices and finally batches of 100 devices. To test your campaign, it’s easier to start with device communicating regularly, so choose devices with a recent “Last Communication Date”. To create a batch, select the X systems you want to upgrade and put a label on them. Use a label tmp_XXXX_YYYY_batchZZZZ where:
First, we prepare the campaign by authenticating, identify the list of systems to be upgraded and create a batch.
Select all devices on the batch you want to upgrade and create an “Upgrade Firmware” or an “Install Application” operation on the whole batch:
Step 1. Get the FW application
URL:
> GET https://eu.airvantage.net/api/v1/application?name=myApps&fields=uid,name
Header:
Authorization: bearer {{accessToken}}
Body:
{
"items": [ {
"uid": "08fc7db9841945df8ffa647165bb57e6",
"name": "ALEOS GX400",
"revision": "4.2.5.005",
"type": "ALEOS.PROD.12",
"category": "FIRMWARE",
"state": "RELEASED" }],
"count": 1, "size": 1, "offset": 0
}
This API returns the application uuid to be used in the next step.
Step 2. Upgrade the systems. Declare the application uuid in the body.
URL:
> POST https://eu.airvantage.net/api/v1/operations/systems/applications/install
Header:
Authorization: bearer {{accessToken}}
Content-Type: application/json
Body:
{ "application" : "08fc7db9841945df8ffa647165bb57e6", "systems": { "label":" tmp_fota_me" } }
Response:
HTTP/1.1 200 OK
Content-Type: application/json
...
{ "operation":"4b89657f63aac4b299c1d46e98a495326" }
This API returns the operation uuid which can be used with other API later.
Note: An operation is created and you can see it in the “Monitoring/Operation” tab in AirVantage.
This API uses the previous result (operation uuid) to get more information about the operation we have just created.
URL:
> GET https://eu.airvantage.net/api/v1/operations/4b89657f63aac4b299c1d46e98a495326
Header:
Authorization: bearer {{accessToken}}
Response:
HTTP/1.1 200 OK
Content-Type: application/json
...
{
"uid": "4b89657f63aac4b299c1d46e98a495326",
"state": "FINISHED",
"category": "TASK",
"entity": "GATEWAY",
"type": "IMPORT",
"startDate": 1362489511437,
"endDate": 1362489512865,
"counters": [ { "state": "PENDING", "count": 0 }, { "state": "IN_PROGRESS", "count": 0 }, { "state": "CANCELLED", "count": 0 },
{ "state": "FAILURE", "count": 0 }, { "state": "SUCCESS", "count": 2 } ],
"total": 2, "target": null, "targetCount": 2, …
}
If needed, you can retry a previous operation identified with its uuid. A new operation is created with a new uuid in the response (like Operation creation).
URL:
> POST https://eu.airvantage.net/api/v1/operations/4b89657f63aac4b299c1d46e98a495326/retry
Header:
Authorization: bearer {{accessToken}}
Response:
HTTP/1.1 200 OK
Content-Type: application/json
...
{ "operation":"848d850a92994b089db07b3848faa6d4" }
OK! So now you launch the campign. It is time to have a status and clean it up once the campaign is finalized
A report could ease your upgrade campaign. This report will contain:
Example of an illustrated report, each states and steps can be more described in a document:
At the end of the campaign you have to: