-
On the device, create the device certificate
tedge cert create --device-id mytestdevice001
-
Copy the public certificate from the device
Option 1: use scp to copy it from a remote device to your machine
scp mydevice:/etc/tedge/device-certs/tedge-certificate.pem ./mytestdevice001.pub
Option 2: Print the public cert to console and copy paste it to a local file on your machine
cat $(tedge config get device.cert_path)
-
On your local machine, upload the certificate using go-c8y-cli (copied from the previous step)
c8y devicemanagement certificates create --name mytestdevice001 --status ENABLED --file ./mytestdevice001.pub
-
On the device again, create a simple script to retry the connection until it is successful
file: ./tedge-connect-c8y-retry.sh
#!/bin/sh set -e while true; do if tedge connect c8y; then echo "Connected" break fi echo "Connection failed. waiting 10 seconds" sleep 10 done
Note You should use a large sleep interval if you are using this in production, e.g. 600 seconds (depends on your exact use-case)
-
Execute the script
sudo chmod +x ./tedge-connect-c8y-retry.sh sudo ./tedge-connect-c8y-retry.sh
-
Create a local csv file with the list of devices which you want to register
file: manual-registration.csv
"ID","AUTH_TYPE","TYPE","NAME","com_cumulocity_model_Agent.active" manual_reg_001,CERTIFICATES,thin-edge.io,manual_reg_001,true
-
Send the registration request to Cumulocity IoT (using go-c8y-cli)
c8y api POST devicecontrol/bulkNewDeviceRequests --file "manual-registration.csv"
-
Wait for the device to connect