Page tree
Skip to end of metadata
Go to start of metadata

Device Gateway is configured using a JSON configuration file, path to which is provided to the DGW via -conf flag.

The default configuration file (provided in the binary distribution) is located at
conf/device-gateway.json


Configuration File

The DGW configuration file has the following format:

{
  "id": "",
  "description": "Example LinkSmart® Device Gateway",
  "publicEndpoint": "http://fqdn-of-the-host:8080",
  "staticDir": "./static",
  "catalog": [],
  "http": {
    "bindAddr": "0.0.0.0",
    "bindPort": 8080
  },
  "protocols": {
    "REST": {
      "location": "/rest"
    },
    "MQTT": {
      "discover": false,
      "discoverID": "main_broker",
      "url": "tcp://localhost:1883",
      "prefix": "example-dgw",
      "offlineBuffer": 100
    }
  },
  "serviceCatalog": {
    "endpoint": "http://localhost:8082",
    "ttl": 120
  }
}


where

  • id is the ID of the DGW, which must be unique in the deployment environment. If not given, a UUID v4 will be generated.
  • description is a human-readable description for the DGW
  • dnssdEnabled is a flag enabling advertisement of DGW endpoint using DNS-SD (service type _pw-dgw._tcp)
  • publicEndpoint is the URL of the gateway protocol://fqdn:port, which is in the deployment environment
  • staticDir is the path to a directory for serving static files
  • [deprecated] catalog is an array of remote Resource Catalogs. All registered devices will be published to each configured remote catalog (if not empty).
    • discover is the flag enabling automatic discovery of the Resource Catalog using DNS-SD
    • endpoint is the URL of the remote Resource Catalog API (http://address:port/path)
  • http is the configuration of the built-in HTTP server
    • bindAddr is the bind address to listen on (0.0.0.0 to listen on all interfaces)
    • bindPort is the TCP port to listen on
  • protocols is a dictionary defining the configuration of the DGW API. At the moment, REST and MQTT protocols are supported.

REST protocol:

  • location is the location (root) of the REST API for all devices registered on the DGW

MQTT protocol:

  • discover is a flag enabling the discovery of broker endpoint from Service Catalog
  • discoverID is the the name of broker to be discovered. If not given, the first listed MQTT broker in Service Catalog will be retrieved.
  • url is the broker URL in the form scheme://address:port, where scheme is either tcp or ssl
  • prefix is the default topic prefix for all mqtt messages to/from devices registered on the DGW, when the topic is not defined in device configurations. 
  • username is the username for username/password authentication (for mosquitto broker see mosquito.conf)
  • password is the password for username/password authentication if used without ssl/tls trasmitted in plaintext
  • caFile is the path to the CA certificate for SSL/TLS authentication of the message broker with a self-signed certificate (for mosquitto broker see mosquitto-tls)
  • certFile is the path to the client certificate for certificate-based authentication of the client
  • keyFile is the path to the client private key for certificate-based authentication of the client
  • offlineBuffer is the size of the internal queue that holds messages while the client is temporarily offline (default=0)

Sample configuration file: device-gateway.json


Authentication

The auth field configures the authentication for Device Gateway's built-in HTTP server:

    "auth": {
        "enabled": "boolean",
        "provider": "string",
        "providerURL": "string",
        "serviceID": "string",
        "basicEnabled": "bool",
        "authorization": {}
    }


where

  • enabled is a boolean flag enabling/disabling the authentication
  • provider is the name of a supported auth provider
  • providerURL is the URL of the auth provider endpoint
  • serviceID is the ID of the service in the authentication provider (used for validating auth tokens provided by the clients)
  • basicEnabled is a boolean flag enabling/disabling the Basic Authentication
  • authorization - optional, see authorization configuation

To publish the devices to an authenticated remote Resource Catalog, the auth field of that catalog should be set:

    "catalog": [
        {
            "discover": "boolean",
            "endpoint": "string",
            "auth": {
                "provider": "string",
                "providerURL": "string",
                "username": "string",
                "password": "string",
                "serviceID": "string"
            }
        }
    ]


where

  • provider and providerURL are the authentication configurations used by that Resource Catalog
  • username and password are the authentication credentials for accessing that Resource Catalog
  • serviceID is the ID of that Resource Catalog in the authentication provider


  • No labels