Configuration

The ConCaVa repository contains a config.js.example file, containing all the configuration options.

Adapters

ConCaVa allows you to provide your own authentication, metadata (device configuration), and storage. These are down through generic adapters. Adapters are simply asynchronous JavaScript functions. Each of these adapter functions accepts four or five arguments:

// req = Express request
// config = auth, metadata, or storage object from config.js
// data = SensorData instance
// classes = { SensorData, SensorAttribute }
// cb = callback function

function (req, config, data, cb) {}
function (req, config, data, classes, cb) {}

The latter is used for providing metadata with the classes used by ConCaVa. If ConCaVa sees the function expects four arguments, it will ignore the classes variable.

Authentication

Example authentication adapter:

function auth (req, config, data, cb) {
    // return cb() // To disable authentication

    console.log(req.auth) // { udid: '...', token: '...' }
    // token will only be added if config.byToken === true

    var user = { id: 1, name: 'User 1' }
    cb(null, user)
    // The value of user is assigned to req.user
}

Metadata

Example metadata adapter:

function metadata (req, config, data, classes, cb) {
    // data is instance of classes.SensorData
    if (data.getDeviceId() !== '0000000000000001') {
        return cb('No metadata for device.')
    }

    var attr1 = new classes.SensorAttribute('attr1')
    attr1.addConverter('uint32be')
    attr1.addValidator('min', 100)
    attr1.addValidator('max', 1300)

    var attr2 = new classes.SensorAttribute('attr2')
    attr2.addConverter('int16le')
    attr2.addCalibrator('return val + 7')

    data.setAttributes([attr1, attr2])
    cb()
}

Storage

The data object can be retrieved with data.getData(). This is a key/value object which uses the converter names (e.g. attr1 and attr2) and their determined values. The following values are added by default:

timestamp      UNIX timestamp
_raw           Hex string with raw payload

The approach here is to make the data time bound. Therefore a timestamp is added. Which can be overriden by providing your own timestamp attribute in the payload, to use the time of the measurement instead of the time the payload has been received.

Example storage adapter:

function storage (req, config, data, cb) {
    var udid = data.getDeviceId()

    console.log(udid, data.getData())
    cb()
}

Note

In debug mode, ConCaVa will also write the data to the log file.

Available

The following adapters are available:

Search for 'adapter' on Github to see all official adapters. Contributing other adapters is highly appreciated. See the contributing page for more information.

Connectors

Connectors are used to support other communication protocols. They act as a proxy for ConCaVa. A connector extracts the UDID and binary payload from protocol packet of your liking. For example: the MQTT connector provides an MQTT broker that uses the clientId and password configuration options for UDID and auth token. Any data it receives will used as binary payload to forward to ConCaVa.

Available

The following connectors are available:

  • LoRa. Handles LoRa XML (from a KPN server webhook for example).
  • LoRa TTN. Handles The Things Network LoRa packets.
  • MQTT.
  • SPUL stands for Sensor Protocol Ultra Light. Documentation can be found here.

Search for 'ConCaVa' on the Docker Hub to see all connectors. Contributing other connectors is highly appreciated. See the contributing page for more information.

Other Tooling

We've developed a standardized API and GUI for managing the MySQL metadata:

  • https://github.com/kukua/concava-api
  • https://github.com/kukua/concava-gui