Regarding scripting of certification to cloud

Hi everyone!

In preparations of getting our custom nRF9160 HW, I'm making use of the fantastic scripts to generate credentials and provision our devices with nRFCloud.

I have successfully generate our CA as such:

python create_ca_cert.py -c NO -o "Copmany AS" -cn Company -e [email protected] -p absolute/path/to/output/folder -f company-

Then I installed the credentials as such:

python device_credentials_installer.py -A -d --ca absolute/path/to/...efd212_ca.pem --ca_key absolute/path/to/...efd212_prv.pem --csv provision.csv --rtt --devinfo devinfo.csv --devinfo_append --mosh_rtt_hex absolute/path/to/merged.hex

Finally I provisioned them as such:

python nrf_cloud_provision.py --apikey $APIKEY --csv provision.csv --devinfo devinfo.csv --name_prefix Company- --name_imei

All the scripts run without error.

However, after installing my own app on the device again, and attempting to connect to the cloud, I get 

<dbg> app: cloud_event_handler: NRF_CLOUD_EVT_TRANSPORT_CONNECTING
<err> nrf_cloud_transport: MQTT input error: -128
<err> nrf_cloud_transport: Error disconnecting from cloud: -128
<dbg> app: cloud_event_handler: NRF_CLOUD_EVT_TRANSPORT_DISCONNECTED

Q1: I guess I've missed a step somewhere? A new device shows up in the web portal. Can you please guide me? Is there something I've done wrong or missed?

Q2: The device in the web portal has a long and unreadable name. How can I chose my own name of the devices? I would like them to be more readable. I tried using devinfo with --name_prefix and --name_imei, but alas, to no avail. I guess I've misunderstood the meaning of the devinfo here? Are there any ways to chose my own name during this process?

Thank you all for all and any help!

Kind regards,

Torje

  • Update: I had not added CONFIG_MODEM_JWT=y and CONFIG_NRF_CLOUD_CLIENT_ID_SRC_INTERNAL_UUID=y. After doing so, I'm successfully connecting to the cloud.

    I've also learned that the provisions.csv can be manually edited to change the device names on nRFCloud.

    So now this question remains: What does the --name_prefix and --name_imei do? And maybe more importantly, what does the devinfo do?
    Can the name change be done in the same script procedures?

    Thanks!

    Torje

  • Update again:

    I figured out how to use own names, or own prefix and IMEI instead of UUID. For reference incase others are looking for the same:
    We can change the names in the provision.csv output, and must change name accordingly in prj.conf as such:
    CONFIG_NRF_CLOUD_CLIENT_ID_SRC_COMPILE_TIME=y
    CONFIG_NRF_CLOUD_CLIENT_ID="Very-Cool-Device"

    We can chose to use prefix and IMEI in the script, and must chose this in the prj.conf as well as such:
    CONFIG_NRF_CLOUD_CLIENT_ID_PREFIX="cool-"
    CONFIG_NRF_CLOUD_CLIENT_ID_SRC_IMEI=y

    I have not understood what the devinfo.csv with --name_prefix and --name_imei do. The names are set before, and saved in provisions.csv. If someone would clarify, that would be welcomed. 

    Thanks!

    Torje

  • Hi Torje,

    You can find how they are used from the source codes: utils/nrf_cloud_provision.py at master · nRFCloud/utils (github.com).

      --name_imei          Use the device's IMEI as the friendly name. Requires --devinfo. (default: False)
      --name_prefix NAME_PREFIX
                            Prefix string for IMEI friendly name (default: None)

    If you input --devinfo devinfo.csv --name_prefix Company- --name_imei arguments, the client ID will be changed to Company-xxxxxxxxxxxxxxx and will be stored with credentials into nRF cloud, then you can use the following configuration when building the device firmware.

    CONFIG_NRF_CLOUD_CLIENT_ID_SRC_INTERNAL_UUID=n
    CONFIG_NRF_CLOUD_CLIENT_ID_SRC_IMEI=y
    CONFIG_NRF_CLOUD_CLIENT_ID_PREFIX="Company-"

    Best regards,
    Charlie

  • Hi Charlie,

    I've been studying and testing based on this documentation, but I'm not really the wiser from it. It seems to me that getting the prefix and the IMEI as names is done by:

     --id_str ID_STR       Device ID to use instead of UUID. Will be a prefix if used with --id_imei (default: )
      --id_imei             Use IMEI for device ID instead of UUID. Add a prefix with --id_str (default: False)

    Using the devinfo made no difference, but these arguments did. I have tried the different combinations of it. In my case, the devinfo changes, with name_imei and name_prefix, makes no change. The changes in my snip above are what changes the name, and works when setting the corresponding configs the firmware.

    These are my obsevations, where the name_imei and name_prefix makes no difference. Am I mistaken or totally wrong? 

    Thanks again!

    -Torje

  • Hi Torje,

    Did you attach the csv file that your devices information behind --devinfo? Its format is 

    # First column in each row is the device ID
    # Add a list to the list [ <device_id>, <mfw_version>, <imei>]

    What I see from the source codes is that process_device_info_csv which processes device information is more like a stand-alone function without any bonding to do_provisioning. It can be used to modify the device ID stored in nRF Cloud.

    Best regards,

    Charlie

Related