Skip to content

Device subclasses

Daniel Berenguer edited this page Feb 8, 2016 · 5 revisions

Device subclasses

We talked in this page about the necessity to implement a subclass for each device type. Every device has its own registers, variable names, inputs and outputs (AKA endpoints) so all these attributes need to be defined by the subclass. The following device subclasses are available from the uSWAP library:

BINOUTS

SWAP device providing 8-binary outputs and 4 PWM outputs. This device is usually implemented with an output-board. Binouts condenses all endpoints in only two registers. First register (1-byte) contains the information about all the eight binary outputs. The second register (4-bytes) does the same for the PWM outputs.

Endpoint attributes

Binary (ON/OFF) outputs. Each bit represents the state of a binary output. Lower output (BINOUT0) is the less significant bit

uint8_t binOutputs[8];

PWM (0-255) outputs. Each byte represents the level of a PWM output. Lower output (PWMOUT0) is the less significant byte.

uint8_t pwmOutputs[4];

Endpoint names

Endpoints can be accessed from mqttgateway (via MQTT and HTTP) by means of the following names:

"BINOUT0" : binary endpoint 0
"BINOUT1" : binary endpoint 1
"BINOUT2" : binary endpoint 2
"BINOUT3" : binary endpoint 3
"BINOUT4" : binary endpoint 4
"BINOUT5" : binary endpoint 5
"BINOUT6" : binary endpoint 6
"BINOUT7" : binary endpoint 7

"PWMOUT0" : PWM output 0
"PWMOUT1" : PWM output 1
"PWMOUT2" : PWM output 2
"PWMOUT3" : PWM output 3

CO2METER

SWAP Temperature + Humidity + CO2 sensor device.

Endpoint attributes

Voltage supply (in mV)

uint16_t voltage;

CO2 level in ppm

uint16_t co2;

Temperature in ºC

float temperature;

Humidity in %

float humidity;

Endpoint names

Endpoints can be accessed from mqttgateway (via MQTT and HTTP) by means of the following names:

"VOLTAGE" : Voltage supply
"CO2" : CO2 level
"TEMPERATURE" : Temperature
"HUMIDITY" : Humidity

CURRENTMETER

SWAP Temperature + Humidity + CO2 sensor device.

Endpoint attributes

Voltage supply (in mV)

uint16_t voltage;

Temperature in ºC

float temperature;

Current consumed (in mA) - 3 channels

uint16_t current0, current1, current2;

Endpoint names

Endpoints can be accessed from mqttgateway (via MQTT and HTTP) by means of the following names:

"VOLTAGE" : Voltage supply
"TEMPERATURE" : Temperature
"CURRENT0" : Current - 1st channel
"CURRENT1" : Current - 2nd channel
"CURRENT2" : Current - 3rd channel

DEVTEMPHUM

SWAP Temperature + Humidity sensor device.

Endpoint attributes

Voltage supply (in mV)

uint16_t voltage;

Temperature in ºC

float temperature;

Humidity in %

float humidity;

Endpoint names

Endpoints can be accessed from mqttgateway (via MQTT and HTTP) by means of the following names:

"VOLTAGE" : Voltage supply
"TEMPERATURE" : Temperature
"HUMIDITY" : Humidity

DEVTEMP

SWAP Temperature sensor device.

Endpoint attributes

Voltage supply (in mV)

uint16_t voltage;

Temperature in ºC

float temperature;

Endpoint names

Endpoints can be accessed from mqttgateway (via MQTT and HTTP) by means of the following names:

"VOLTAGE" : Voltage supply
"TEMPERATURE" : Temperature

RGBDRIVER

SWAP RGB LED strip driver

Endpoint attributes

RGB levels. First byte is RED, second byte is GREEN. Third byte is BLUE

uint8_t rgb[3];

Endpoint names

Endpoints can be accessed from mqttgateway (via MQTT and HTTP) by means of the following names:

"RGB" : 3-byte RGB code
"RED" : RED color
"GREEN" : GREEN color
"BLUE" : BLUE color
Clone this wiki locally