nerves-hub
Search…
Deployments

Creating

Deployments associate firmware images to devices. NervesHub won't send firmware to a device until you create a deployment. First find the UUID of the firmware. You can list the firmware on NervesHub by calling:
1
mix nerves_hub.firmware list
2
3
Firmwares:
4
------------
5
product: example
6
version: 0.3.0
7
platform: rpi3
8
architecture: arm
9
uuid: 1cbecdbb-aa7d-5aee-4ba2-864d518417df
Copied!
In this example we will create a new deployment for our test group using firmware 1cbecdbb-aa7d-5aee-4ba2-864d518417df.
1
mix nerves_hub.deployment create
2
3
NervesHub organization: nerveshub
4
Deployment name: qa_deployment
5
firmware uuid: 1cbecdbb-aa7d-5aee-4ba2-864d518417df
6
version condition:
7
tags: qa
8
Local user password:
9
Deployment test created
Copied!
Here we create a new deployment called qa_deployment. In the conditions of this deployment we left the version condition unspecified and the tags set to only qa. This means that in order for a device to qualify for an update, it needs to have at least the tags [qa] and the device can be coming from any version.
At this point we can try to update the connected device.
Start by bumping the application version number from 0.1.0 to 0.1.1. Then, create new firmware:
1
mix firmware
Copied!
We can publish, sign, and deploy firmware in a single command now.
1
mix nerves_hub.firmware publish --key devkey --deploy qa_deployment
Copied!

Conditionally applying updates

It's not always appropriate to apply a firmware update immediately. Custom logic can be added to the device by implementing the NervesHubLink.Client behaviour and telling the NervesHubLink OTP application about it.
Here's an example implementation:
1
defmodule MyApp.NervesHubClient do
2
@behaviour NervesHubLink.Client
3
4
# May return:
5
# * `:apply` - apply the action immediately
6
# * `:ignore` - don't apply the action, don't ask again.
7
# * `{:reschedule, timeout_in_milliseconds}` - call this function again later.
8
9
@impl NervesHubLink.Client
10
def update_available(data) do
11
if SomeInternalAPI.is_now_a_good_time_to_update?(data) do
12
:apply
13
else
14
{:reschedule, 60_000}
15
end
16
end
17
end
Copied!
To have NervesHubLink invoke it, update your config.exs as follows:
1
config :nerves_hub_link, client: MyApp.NervesHubClient
Copied!
Last modified 1yr ago