Contents

DashIO C++ Core Library

All C++/Arduino libraries include the core library files DashIO.h and DashIO.cpp. The DashIO library is important for developing your projects for two main reasons:

  • The header file provides all the information you will need to creating controls (methods and attributes) and their configuration messages.
  • To enable you to create your own libraries for whatever project you can imaging.

The DashIO library contains the core functionality through the following objects:

  • DashioDevice
  • DashioConnection
  • All controls (for configuration)

These objects will be discussed in detail below.

DashioDevice

The DashioDevice is the workhorse of the library, providing much of the functionality for messaging. It holds important attributes for the IoT device:

  • deviceID - the unique identifier of the IoT device. A UUID may be used for the deviceID, or the mac address from the comms peripheral is also suitable.
  • type - human readable text to describe the IoT device. This can be whatever you choose and may be a manufaturer product designator. Once this is assigned to the dashioDevice it cannot be changed.
  • name - human readable name for the IoT device. This can be changed by through the DashIo protocol.
  • mqttSubscrberTopic - the dashioDevice also creates and stores the mqttSubscrberTopic for MQTT connections.

The dashioDevice contains all the methods for creating the messages that are sent through the BLE, TCP and MQTT connections. This data includes messages for each control and their configuration messages. Please refer to the file DashIO.h for details.

DashioConnection

The DashioConnection provides the message processing for incoming messages for each connection. There must be one DashioConnection instance for each connection in the device. The key attributes for the connection are:

  • connectionType - Set at instantiation to define the type of connection (BLE_CONN, TCP_CONN or MQTT_CONN). The DashioConnection must be instantiated with the connectionTYpe as an attribute.
  • messageReceived - A flag to indicate that a message has been received, process and is available to be used. Must be set to false once the messages has been used.
  • control - Contains the control_type of the received message.
  • idStr - Contains the control_ID of the received message.
  • payloadStr - Contains the primary payload field of the received message.
  • payloadStr2 - Contains the. secondary payload field of the received message.

Incoming message data is pprocessed by the DashioConnection through one of the folloing methods:

void processMessage(const String& message);
bool processChar(char chr);

processMessage allows complete messages to be processed, while processChar allows individual characters to be processed as they are received. Once processChar has detected a complete messages has been received, it processes the message through processMessage.

Controls

Control configuration objects are only required to be created for configuration messages. The process of creating and sending a configuration message is:

  1. Create a controlCfg object and set any attributes that you want to change from the default values.
  2. From the dashioDevice, call a method to create the configuration message getConfigMessage with controlCfg as an attribute
  3. Send the configuration message through the appropriate comms library.

The example below shows the creation of button control confguration message:

ButtonCfg aButton("BUTTON_ID", "DEV_VIEW_ID", "Button", {0.5, 0.788, 0.2, 0.121});
aButton.iconName = "bell";
aButton.offColor = "blue";
aButton.onColor = "black";
String message = dashioDevice.getConfigMessage(aButton);

All controls are instantiated with the same set of attributes as in the example above. In order, they are:

  • controlID - Identifier of the control. Must be unique to the IoT device.
  • parentID - Identifier of the control that is the parent control to this control. May be a device view, menu, or button group.
  • title - Title or name of the control to be displayed on the DashIO app.
  • coordinates - Position and size of the control on the device view, where 0 is the top or left side and 1 is right or the right side. The four coordinates, in order, are {control left side position, control top position, control width, control height}.

In the above example code the iconName, offColor, and onColor are also set for the button. There are many attributes than can be set for each control. Please refer to the file DashIO.h for details or all alltribtes for all controls.