Upload files to Cumulocity IoT by creating an event and uploading a given file to it.
USAGE
#!/bin/bash | |
# | |
# 1. Pipe a list of ESNs from a file and create a c8y_Command (shell) operation for each device (using go-c8y-cli piping) | |
# A unique batch marker is used to group the operations together (to make querying for the operation easier) | |
# 2. Poll the created operations () | |
# 3. Print out a summary of how many operations failed and how man were successful | |
# | |
# Input file: | |
# * esn.txt - Newline delimited file containing one ESN per line (file must have an empty line at the end, otherwise the last ESN might be skipped) | |
# |
Updating the location information in Cumulocity IoT should not be a problem with thin-edge.io.
For reference, I created the options by reading the following Cumulocity IoT documentation links:
In summary, updating a location of a device (in the backend) involves creating an event and then updating a fragment on the device's managed object, however you have a few different options on how to achieve this with thin-edge.io:
To install a specific version of thin-edge.io on a Debian based operating system, you will have to use APT Package Pinning, as the tedge-full
package is a virtual package, and installing a specific version of the virtual package does not transfer to the package's dependencies (unfortunately).
Below shows how the exact thin-edge.io version can be installed.
Create a debian package pin definition for thin-edge.io
Create the following file:
sudo vi /etc/apt/preferences.d/tedge
{ | |
"$schema": "http://json-schema.org/draft-04/schema#", | |
"$id": "https://thin-edge.io/workflow.json", | |
"title": "thin-edge.io workflow", | |
"description": "Workflows can be used to customize existing operations and add user defined processes which are coordinated by thin-edge.io", | |
"type": "object", | |
"definitions": { | |
"on_state": { | |
"oneOf": [ | |
{ |
After a successfully completed firmware workflow, if the tedge-agent service is restarted, then tedge-agent will reprocess the restart-current-operation
file again as the file is not deleted after the workflow has been completed.
file: /data/tedge/.agent/restart-current-operation
Before creating a custom operation handler, create the configuration and confirm that the operation will be delivered to the device. Once you have confirm this, then you can add your custom handler.
Below shows the steps to create a custom SmartREST collection for Cumulocity IoT, and how to check that the message arrives on the local thin-edge.io MQTT broker.
Create a SmartREST template collection in Cumulocity IoT, and create a custom "response"
Below is an example collection which create two custom operations for the message ids:
#!/bin/bash | |
######################################################################################################################## | |
# Debug script to check the behaviour of the tedge-mapper-c8y/mosquitto and the responsiveness of the | |
# Cumulocity IoT token request/response topics (c8y/s/uat and c8y/s/dat). | |
# | |
# The script does the following: | |
# 1. Install a systemd service (and enables it) | |
# 2. Create mqtt subscriber to c8y/s/dat | |
# 3. Publish a mqtt message to c8y/s/uat | |
# 4. Wait for a message on the c8y/s/dat topic (give up after a few seconds) |