Configuring your device driver

Device Services built with one of the SDKs get their configuration either from a .toml file, or from the Registry. Much of this config follows the pattern of the other EdgeX services, but there is also a facility to include configuration specific to your device service.

In the current Go SDK and in the C SDK since Delhi, you can add a “Driver” section. Let’s say you are writing a driver for some networked devices that might have to be accessed via a proxy. You can add to your configuration.toml:

   ProxyHost = ""
   ProxyPort = "8081"

And then in C the values will be accessible in the init callback. So you might have:

static bool myInit
  (void *impl, struct iot_logging_client *lc, const edgex_nvpairs *config)
  myData *me = (myData *)impl;
  me->logger = lc;
  for (const edgex_nvpairs *p = config; p; p = p->next)
    if (strcmp (p->name, "ProxyHost") == 0) me->config.proxHost = strdup (p->value);
    else if (strcmp (p->name, "ProxyPort") == 0) me->config.proxPort = atoi (p->value);

/* etc */

Or in Go, you can call the service.DriverConfigs() function which returns a string-string map
containing the configuration values.