Skip to content

thin-edge/device-registration-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

device-registration-server

thin-edge.io plugin to register child devices.

Plugin summary

A http server which provides a simple interface for child devices to register themselves and indicate which operations they support via a HTTP API.

The device-registration-server should be installed on the device where thin-edge.io is running as it needs access to the same filesystem.

What will be deployed to the device?

  • A service called device-registration-server

Technical summary

The following details the technical aspects of the plugin to get an idea what systems it supports.

Languages golang
CPU Architectures armv7/arm64/x86_64 (though it can be built for other architectures)
Supported init systems systemd and init.d/open-rc
Required Dependencies -
Optional Dependencies (feature specific) -

How to do I get it?

The following linux package formats are provided on the releases page and also in the tedge-community repository:

Operating System Repository link
Debian/Raspbian (deb) Latest version of 'device-registration-server' @ Cloudsmith
Alpine Linux (apk) Latest version of 'device-registration-server' @ Cloudsmith
RHEL/CentOS/Fedora (rpm) Latest version of 'device-registration-server' @ Cloudsmith

Documentation

API

POST /register: Register child device

A child device can register itself to the service

Example

curl \
    http://127.0.0.1:9000/register \
    -X POST \
    --data '{"name":"mychild","supportedOperations":["c8y_Firmware"]}' -H "Content-Type: application/json"

Response: 201

{
    "id": "tedge01_mychild",
    "name": "mychild",
    "parent": "tedge01",
}
Property Description
id Child device id that should be used in all communication with thin-edge.io
name Local child device name. This will be the value that was sent by the child device whilst registering itself
parent Id of the parent device (for reference only)

Configuration

The device-registration-service can be controlled by either environment variables or command line flags.

The following flags are supported.

  --bind string
        Bind address to which the http server should attach to. It listens on all adapters by default.
  --config-dir string
        thin-edge.io base configuration directory (default "/etc/tedge")
  --device-id string
        Use static device id instead of using the tedge cli
  --port int
        Port (default 9000)
  --separator string
        Device name separator (default "_")
  --use-prefix
        Prefix the child id with the main device id (default true)
  --version
        Show version information

Alternatively the values for the flags can be provided via environment variables. The mapping between the flags to environment variables is as follows:

Flag Env Variable
--device-id REGISTRATION_DEVICE_ID
--config-dir REGISTRATION_CONFIG_DIR
--bind REGISTRATION_BIND
--port REGISTRATION_PORT
--separator REGISTRATION_SEPARATOR
`--use-prefix=<true false>`

Building

You can build the project and all of the packages by using, though the command will fail if you have uncommitted changes.

just release

If you have uncommitted changes then you can build a snapshot with the following command:

just release-snapshot

Running it locally

You can start the project locally by running:

mkdir -p tmp/operations/c8y
go run main.go --use-prefix=false --device-id main001 --config-dir tmp

Then send a request to the local service using curl.

curl http://127.0.0.1:9000/register \
    -X POST \
    --data '{"name":"mychild","supportedOperations":["c8y_Firmware"]}' -H "Content-Type: application/json"

Example output:

{"name":"mychild","id":"mychild","parent":"main001"}

About

thin-edge.io plugin to register child devices

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published