Skip to main content

Scripts and utilities for working with the nRF Cloud

Project description

nRF Cloud Utils

PyPI version License Python versions

nRF Cloud Utils is a script collection to make it easier to interface with nRF Cloud. They also include nrfcredstore to interface with nRF91 Series devices.

The scripts in this repository mainly use endpoints in the nRF Cloud API and the nRF Cloud Provisioning API.

See also the official nRF Cloud documentation.

Table of Contents

Install

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

pip3 install nrfcloud-utils

Requirements

  1. Create an account in nrfcloud.com.
  2. Retrieve your API key. You can find it in your nRF Cloud User Account page. Note that if you are part of multiple teams on nRF Cloud, the API key will be different for each one.
  3. Depending on your goal, you'll need to configure your nRF Connect SDK project with the following libraries:
  1. When compiling with the nRF Cloud Libraries, make sure your project has the next Kconfig options:

    # Enable modem-based JSON Web Token (JWT) generation required for nRF Cloud authentication
    CONFIG_MODEM_JWT=y
    
    # Configure the nRF Cloud library to use the device's internal UUID as the client ID
    CONFIG_NRF_CLOUD_CLIENT_ID_SRC_INTERNAL_UUID=y
    
    # Define the modem security tag where nRF Cloud credentials will be stored (16842753 is the standard tag used by Nordic examples)
    CONFIG_NRF_CLOUD_SEC_TAG=16842753
    

Failure to include these settings will prevent the device from connecting to nRF Cloud.

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.

To get your device registered is using the device_credentials_installer script:

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. This file is needed 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.

Onboard the device to your account using the nrf_cloud_onboard script as follows:

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

It is possible to 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 to nRF Cloud, you should be able to visualize it on the Devices panel.

Advanced Usage

For a more detailed overview of the scripts and their capabilities, refer to the Advanced Usage Guide. This guide provides in-depth instructions on leveraging advanced features, including the use of the Provisioning Service for remote provisioning of devices, as an alternative to local provisioning.

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-3.0.1.tar.gz (38.7 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-3.0.1-py3-none-any.whl (47.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nrfcloud_utils-3.0.1.tar.gz
  • Upload date:
  • Size: 38.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.13 Linux/6.11.0-1015-azure

File hashes

Hashes for nrfcloud_utils-3.0.1.tar.gz
Algorithm Hash digest
SHA256 0f4831e8673281ef34027b304a6d6664301fd9b983e8be5ef1afd0bdc2568ffb
MD5 7ef3c33af36a708fbdc23e2da13b6541
BLAKE2b-256 a559f2d638bec1e4b8d8299990b9639b70c343737dda5cd3a1e37c06db0370b9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nrfcloud_utils-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 47.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.13 Linux/6.11.0-1015-azure

File hashes

Hashes for nrfcloud_utils-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 85725662685fccfcdaad99d98e642ca4e1439e22223943ba5659191cf12c5f23
MD5 18ac1a6767e483afb159df381b316163
BLAKE2b-256 f90b4e58706fec99e1ce8a986682dfa15f285327a28da0c1ea4f7281ea697524

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