nerves_hub_link is the client library that connects a Nerves device to NervesHub. The device appears in your product the first time it connects.
Requirements
- A Nerves project.
nerves_hub_link2.13.0 and later need Elixir 1.15 or later. - A product in NervesHub. See Products.
- Each device needs a unique serial number. With a shared secret, NervesHub identifies the device by the serial number its firmware reports. With a certificate, NervesHub identifies the device by the certificate’s common name, so issue each certificate with the device’s serial number as its common name.
1
Add the dependency
Add Then fetch it:
nerves_hub_link inside the deps function in mix.exs:nerves_hub_link is an OTP application and starts with your firmware. You do not need to add it to a supervision tree. To start it yourself, see Connection lifecycle.2
Choose how the device authenticates
NervesHubLink picks a configurator in this order:
- The module you set as
configuratorin the:nerves_hub_linkconfig. NervesHubLink.Configurator.NervesKey, if thenerves_keylibrary is in your project.NervesHubLink.Configurator.TPM, if thetpmlibrary is in your project.NervesHubLink.Configurator.SharedSecret.
Shared secrets are the quickest way to connect a first device. They only work when the NervesHub instance has them turned on. See Feature prerequisites.
3
Configure the connection
Add the configuration for your method to
config/target.exs. Replace the host with your NervesHub device host.- Certificate and key files
- NervesKey
- TPM
4
Set up firmware signing
From
nerves_hub_link 2.13.0, a device refuses firmware it cannot signature-check. A device with no fwup_public_keys configured asks NervesHub for your organization’s signing keys when it connects. If it has none configured and receives none, it stops taking updates.Register a signing key before you upload firmware. See Firmware signing.5
Build, burn, and check the connection
- The device has a network connection and can reach the host. NervesHubLink checks that the network is available before its first connection attempt.
- With a shared secret, the key and secret match an active secret in Product settings, and the device clock is correct. NervesHub accepts a signature for 90 seconds.
- With a certificate, the signing CA is registered and the device exists or the CA has a just-in-time provisioning profile. See Device certificates.

