nRF Cloud Utils
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 help with device credentials. Onboarding uses the nRF Cloud API through the Memfault CLI.
See also the official nRF Cloud documentation.
Table of contents
Install
Run the following command to use this package. Install memfault-cli too, as it is needed for most onboarding operations.
pip3 install nrfcloud-utils memfault-cli
To use the --rtt option of device_credentials_installer and gather_attestation_tokens, install the rtt extra, which adds pynrfjprog:
pip3 install "nrfcloud-utils[rtt]"
Requirements
-
Create an account in nrfcloud.com.
-
To onboard devices, create an organization auth token (OAT) with the
device:writepermission, under Admin > Organization Auth Tokens in the nRF Cloud app. See nRF Cloud device onboarding.The
nrf93_onboardscript uses an OAT too. See nRF93M1 device onboarding. -
Depending on your goal, you'll need to configure your nRF Connect SDK project with the following libraries:
-
For basic device registration: Enable the AT Host library. Refer to the AT Client sample in the nRF Connect SDK for an implementation example.
-
For using the Provisioning Service: Enable the Provisioning Service library. You can find more documentation about the Provisioning Service here. The nRF Connect SDK provides a sample with a focused look at provisioning steps on cellular devices.
- For devices with a Nordic cellular modem, the device ID that the firmware uses must match the modem UUID that the scripts use by default.
This is the default of the nRF Cloud library since the nRF Connect SDK v3.4.0.
With older versions, set the
CONFIG_NRF_CLOUD_CLIENT_ID_SRC_INTERNAL_UUIDKconfig option toy(which enablesCONFIG_MODEM_JWT).
⚠️A device ID mismatch will prevent the device from connecting to nRF Cloud.
For devices without a modem, such as nRF71 Series and nRF70 Series Wi-Fi devices, see Devices without a modem instead.
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, use the device_credentials_installer script. Be aware of which device ID is your project using, as it can be either a UUID or an IMEI. Depending on your device ID type, use one of the following commands:
UUID
device_credentials_installer -d --ca *_ca.pem --ca-key *_prv.pem --verify --coap
Device without a modem, key generated on the device (for example, nRF71 Series or nRF70 Series with Wi-Fi)
For a device without a modem, pass the device ID that the firmware uses and let the device generate its key, using the following command:
device_credentials_installer -d --ca *_ca.pem --ca-key *_prv.pem --verify --coap --cmd-type tls_cred_shell --id-str <device_id>
See Devices without a modem for the firmware requirements.
⚠️Failure to select the correct device ID will result in a connection refused from nRF Cloud.
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 with onboard.csv, using the nrfcloud command from the Memfault CLI:
nrfcloud --org-token $OAT --org <org> --project <project> device create --csv onboard.csv
See nRF Cloud device onboarding for details.
It is possible to install credentials on many devices in a row using the --append option and onboard them all at once with the resulting onboard.csv.
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.
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
To include RTT support in the development environment, run poetry install -E rtt.
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=src tests
Metadata
Release files for nrfcloud-utils 4.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nrfcloud_utils-4.0.0.tar.gz | 30.3 kB | Without provenance | Details for nrfcloud_utils-4.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nrfcloud_utils-4.0.0-py3-none-any.whl | Python 3 | none | any | Details for nrfcloud_utils-4.0.0-py3-none-any.whl |
Total release size: 66.6 kB
Release files / nrfcloud_utils-4.0.0.tar.gz
| Download URL | nrfcloud_utils-4.0.0.tar.gz |
|---|---|
| Size | 30.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c8cac186dab068f8149903d4c90fa1e7de76b6d583099d1f2209e796c52d12a
|
|
BLAKE2b-256 checksum How to use checksums |
1ecbade1aa9df821a0f4d060992fb248f3626cd6f23418509952e87346607777
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.4 CPython/3.11.18 Linux/7.0.0-1019-azure
|
Release files / nrfcloud_utils-4.0.0-py3-none-any.whl
| Download URL | nrfcloud_utils-4.0.0-py3-none-any.whl |
|---|---|
| Size | 36.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
93097512866a168b125719d66bf3e695a26a148c5e1893b451605ed67ee5d925
|
|
BLAKE2b-256 checksum How to use checksums |
a18a68f632095b93f3a7bc4cbcd25fca88dc132c383bdd17908c89abe9648dc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.4 CPython/3.11.18 Linux/7.0.0-1019-azure
|
Security for nrfcloud-utils 4.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.