IO Module (ID 6)
Purpose
The IoModule with ModuleId 6 is driving and configuring all GPIOs. E.g. toggling a LED, a motor or reading values from a basic sensor.
Functionality
The IO module only supports toggling of LEDs and different pins at the moment. It will be extended to include support for basic sensors that can be read by e.g. analog/digital conversion.
Change LED Mode
Changes the LED mode to one of the states. It is possible to turn leds on or off, but also eg. signal number of connections.
Mode | Blink pattern |
---|---|
on |
all LEDs are on |
off |
all LEDs are off |
connections |
if networkId = 1, red LED on |
//Set led mode
action [nodeId] io led [mode = on / off / connections]
//Switch leds on on all nodes
action 0 io led on
Set Pins
Sets a pin to either high or low output.
//Configure pins low or high
action [nodeId] io pinset [pinNumber] [mode] ...
//Configure Pins 21 and 22
action 0 io pinset 21 high 22 low
Read Pins
Reads the digital level of one or up to 5 pins (0 = low and 1 = high).
This changes the pin’s GPIO configuration output (after it has changed it to input and read the pin). |
//Pass the pin numbers to read
action [nodeId] io pinread [pinNumber] {pinNumber} ...
//Read pin 21
action 0 io pinread 21
//Read pins 2, 1 and 19
action 0 io pinread 2 1 19
Example response:
{
"nodeId": 2,
"type": "pin_level_result",
"module": 6,
"pins": [
{"pin_number": 2, "pin_level": 1},
{"pin_number": 1, "pin_level": 1},
{"pin_number": 19, "pin_level": 0}
]
}
Start identification
Starts identification procedure which will blink all board LEDs with a 200ms period for a total of 30 seconds. Can also be handled by other modules to start custom identification. This mode overrules curent led mode.
//Trigger identification
action [nodeId] io identify [mode = on / off]
//Trigger identification
action 0 io identify on
Implementation Details
The SET_LED(_RESPONSE)
and SET_IDENTIFICATION(_RESPONSE)
messages are also transmitted over via MeshAccessConnections
which are established with the FmKeyId::ORGANIZATION
.
This is required for devices which are not part of the mesh network, but instead part of the overall organization.