Skip to main content

Scripts and utilities for working with the nRF Cloud

Project description

nRF Cloud Utilities

nRF Cloud Utils is a script collection to make it easier to interface with nRF Cloud. A common use-case is to register devices with your account or to run a fota job.

The scripts in this repository mainly use endpoints in the REST API.

See also the official nRF Cloud documentation.

Install

Run the following command to use this package as a dependency:

pip3 install nrfcloud-utils

Requirements

Do you already have an nRF Cloud account? If not, please visit nrfcloud.com and register. Then, click on the burger on the top-right to get to your user account. Take note of your API key, you will need it soon. Note that if you are part of multiple teams on nRF Cloud, the API key will be different for each one.

To register a device, you need compatible firmware flashed to it. Most scripts work with an AT Host library enabled app or the AT Client sample flashed. However, if you intend to use the Provisioning Service, you will need to enable its library in your firmware or flash the nRF Cloud Multi Service sample.

How-To: Registering devices quickly

Start by creating a local certificate authority (CA). Its contents won't be checked, but you need one to make certificates for your devices. Optionally, pass options to the script to specify owner information.

create_ca_cert

Now, you should have three .pem files containing the key pair and the CA certificate of your CA. The files have a unique prefix.

The fastest way to get your device registered is using the Device Credentials Installer:

device_credentials_installer -d --ca *_ca.pem --ca-key *_prv.pem --coap --verify

Upon success, you can find an onboard.csv file with information about your device. We need this file to register the certificate with your account. If you encounter a No device found error, you might need to specify the serial port using the --port option.

Finally, add the device to your account with the Onboarding script:

nrf_cloud_onboard --api-key $API_KEY --csv onboard.csv

You can also install credentials on many devices in a row using the --append option and add the bulk onboard.csv to your account with the same command.

Congratulations! You have successfully registered your device. When compiling with the nRF Cloud Libraries, make sure to use the correct KConfig options:

CONFIG_NRF_CLOUD_CLIENT_ID_SRC_INTERNAL_UUID=y
CONFIG_NRF_CLOUD_SEC_TAG=16842753

For a more detailed overview of the scripts, see Advanced Usage. There, you can also find details on how to use the Provisioning Service instead of provisioning your devices locally.

Development installation

Clone the repository:

git clone https://github.com/nRFCloud/utils.git nrfcloud-utils
cd nrfcloud-utils

For development mode, you need poetry:

curl -sSL https://install.python-poetry.org | python3 -

Make sure poetry is in your PATH. If you're using bash:

echo 'export PATH=/home/$USER/.local/bin:$PATH' | tee -a ~/.bashrc
source ~/.bashrc

Install package dependencies, development dependencies, and the nrfcloud-utils into poetry's internal virtual environment:

poetry install

Test

Unit tests are included in the tests folder. Each test script corresponds to a script in the sources. Static files used in the tests are put in the tests/fixtures folder. Running the tests depends on a development installation.

poetry run pytest

Check coverage

poetry run pytest --cov=. tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nrfcloud_utils-1.0.3.tar.gz (46.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nrfcloud_utils-1.0.3-py3-none-any.whl (57.6 kB view details)

Uploaded Python 3

File details

Details for the file nrfcloud_utils-1.0.3.tar.gz.

File metadata

  • Download URL: nrfcloud_utils-1.0.3.tar.gz
  • Upload date:
  • Size: 46.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.11 Linux/6.8.0-1021-azure

File hashes

Hashes for nrfcloud_utils-1.0.3.tar.gz
Algorithm Hash digest
SHA256 703043815e6d3a544d06b3ba292a633c1580e1a28b8c58a7eda965662ec58639
MD5 d01b13ed971396efd659a47839c1e4e1
BLAKE2b-256 8fac5f4510a7f3484477a1fa3afd17d214ceeabc2371caf5fcae62d961dc28c9

See more details on using hashes here.

File details

Details for the file nrfcloud_utils-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: nrfcloud_utils-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 57.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.11 Linux/6.8.0-1021-azure

File hashes

Hashes for nrfcloud_utils-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9ca6dfa32f7795940bb1e85112a47ed662d58b12a708457e0fc04b46bbcdc76c
MD5 1f403523ca7aee166c4085820ca417bb
BLAKE2b-256 cf487d36c1ebe809318aa560b7f0fdf244bb1f711b121fd64a621445e168bece

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page