Device type event handler documentation

Device type event handler

External systems and individual IoT devices (hereafter collectively called "devices") can communicate with our application. As each device type is different, you are free in what your devices send and what you want to return to them. To ochestrate communcation, you should define an event handler for each device type.

The event handler is called when:

  • an HTTP or CoAP request has been received
  • a new command is created
  • a command is deleted
  • a command is due
  • a device is installed at a location
  • the installation between device and location is updated
  • a device is uninstalled from a location

The event handler can:

  • add a text to the log file of this activity
  • get a file by its hashId
  • encode or decode base64
  • schedule or drop a command
  • mark a command as sent
  • set the reporting frequency of the device and inform the system when communication should be counted against this frequency
  • run a report parser
  • store data about the device (in its fields)
  • define the response (in case of an HTTP or CoAP request)
  • perform a HTTP request

See the interfaces EventWithoutResponse and IncomingRequestEvent for more details.

The event handler function should:

  • be written in Typescript,
  • be named handle
  • have the following signature:
    function handle(args: ArgumentsForIncomingRequestEvent, exec: Exec): IncomingRequestResponse;
    function handle(args: ArgumentsForEventWithoutResponse, exec: Exec): void;
    function handle(args: Arguments, exec: Exec): IncomingRequestResponse | void {

    }

An example event handler can be inserted using the toolbar above the code editor.

Inspecting activity

You can inspect activity on this event handler by going to "Activity" in the connectivity environment and filtering "Device Type" on the name chosen for this device type.