Skip to content

Instantly share code, notes, and snippets.

View reubenmiller's full-sized avatar

Reuben Miller reubenmiller

  • Hamburg, Germany
View GitHub Profile
@reubenmiller
reubenmiller / c8y.crt
Last active June 19, 2024 20:01
WIP: Copy/paste
-----BEGIN CERTIFICATE-----
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
@reubenmiller
reubenmiller / README.md
Last active May 6, 2024 07:13
thin-edge.io upload file to Cumulocity IoT via the local c8y proxy

README

Summary

Upload files to Cumulocity IoT by creating an event and uploading a given file to it.

Usage

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)
#
@reubenmiller
reubenmiller / README.md
Last active March 11, 2024 09:49
Update Cumulocity Location using thin-edge.io

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:

@reubenmiller
reubenmiller / README.md
Last active December 20, 2023 14:36
Only install specific thin-edge.io version

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.

  1. Create a debian package pin definition for thin-edge.io

    Create the following file:

sudo vi /etc/apt/preferences.d/tedge

@reubenmiller
reubenmiller / tedge.workflow.json
Last active May 22, 2024 15:16
draft: thin-edge.io workflow schema
{
"$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": [
{
@reubenmiller
reubenmiller / tedge-workflow-punchlist.md
Last active November 27, 2023 16:33
WIP: thin-edge.io workflow punchlist (firmware update)

1. restart state file is not being deleted (after image has been restarted)

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

// cat /data/tedge/.agent/restart-current-operation
{"target":"device/main//","cmd_id":"c8y-mapper-2023-11-26T12:26:39.248420821Z","payload":{"status":"executing","context":{"command":{"topic":{"name":"te/device/main///cmd/firmware_update/c8y-mapper-2023-11-26T12:26:39.248420821Z"},"status":"rollback_restart","payload":{"name":"core-image-tedge-mender-raspberrypi4-64","reason":"Nothing to commit. Either the boot loader triggered the rollback, the device was rebooted after switching to new partition, or someone did a manual rollback!","remoteUrl":"https://t2873877.latest.stage.c8y.io/inventory/binaries/4785008","status":"rollback_restart","
@reubenmiller
reubenmiller / c8y-onboarding-devices-manually.md
Created November 17, 2023 23:31
Onboarding thin-edge.io device's to Cumulocity IoT without automatic registration enabled

Onboarding thin-edge.io to Cumulocity IoT without auto registration enabled

Part 1: Create and upload the device certificate without auto registration

  1. On the device, create the device certificate

    tedge cert create --device-id mytestdevice001
@reubenmiller
reubenmiller / copy_managed_objects.md
Created November 15, 2023 08:54
go-c8y-cli: copy managed objects across tenants

Copy managed objects across tenants

Long Version

  1. Activate a session to the source tenant

    set-session
    
@reubenmiller
reubenmiller / c8y-custom-operation-handler.md
Created November 11, 2023 19:49
thin-edge.io - custom operation handler guide

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.

Part 1: Send operations from Cumulocity IoT to thin-edge.io

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.

  1. 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: