LogoLogo
1.0.0
1.0.0
  • Introduction
  • High level architecture
  • Public key infrastructure
  • Terminology
  • Tutorials
    • Quickstart
    • Production Setup with NervesKey
  • Nerves Hub
    • Setup
      • Add NervesHub to your project
      • Connecting to your environment
      • Firmware signing keys
      • Products
      • Devices
      • Firmware
      • Deployments
    • Command-line tools
    • Managing organizations and products
    • Device management
    • HTTP API
    • Device WebSocket
  • Nerves Key
    • Introduction
    • NervesKey for Raspberry Pi
    • Private keys and certificates
    • General NervesKey storage
    • Provisioning in Elixir
    • Nerves integration
    • NervesHubLink integration
    • MQTT integration
Powered by GitBook
On this page
  • Device registration
  • Integration with your Nerves project

Was this helpful?

  1. Nerves Key

NervesHubLink integration

This section walks you through integrating a device with a NervesKey with NervesHub.

PreviousNerves integrationNextMQTT integration

Last updated 7 days ago

Was this helpful?

Device registration

Devices must be registered with NervesHub via the commandline tools, web user interface or via an API integration first to authenticate with a NervesKey. The only exception is if you are using the JITP feature in which case registration is automated.

The command-line tools are the easiest for this. Follow to get them installed.

You will need the device's manufacturing serial number for this step. If you don't have it NervesKey.manufacturer_sn/1 can retrieve it. From the CLI, run mix nerves_hub.device create. Fill in the manufacturing serial number when it asks for an identifier. Fill in the description and tags fields as you'd like:

$ nh device create
NervesHub server: api.nerves-hub.org:443
NervesHub organization: your_organization
identifier: 123456789ABCDE
description: My favorite device
tags: qa
Local NervesHub user password:
Device 123456789ABCDE created

When registering devices in bulk, we've found that there's usually a convenient hook in the manufacturing process to call mix nerves_hub.device create with commandline parameters.

If you are not using the Signer CA approach you also want to upload a certificate per device. This can be done using:

nh device cert import 123456789ABCDE device-cert-file-path-goes-here

Integration with your Nerves project

You can tell nerves_hub_link to read those certificates and key from the chip and assign the SSL options for you by enabling add it as a dependency in your mix.exs:

def deps() do
  [
    {:nerves_hub_link, "~> 2.7"},
    {:nerves_key, "~> 1.2"}
  ]
end

NervesKey will default to using i2c bus 1 and :primary cerificate pair.

NervesHubLink will use the NervesKey library by default if it is available. NervesHubLink itself needs to be configured a bit:

config :nerves_hub_link,
  # point this at the device endpoint of your instance
  host: "devices.nervescloud.com",
  # if you want the remote console
  remote_iex: true,
these instructions