====== SW16 CFLink Protocol ======
This document details the CFLink protocol for the SW16 device.
===== Queries =====
==== STA - Query Input Status ====
The ''STA'' (Status) query returns the states of all the dry contact inputs.
=== Data ===
< [F2][F3]RSWXSTA[F4]P01:|P02:|P03:|P04:|P05:|P06:|P07:|P08:|P09:|P10:|P11:|P12:|P13:|P14:|P15:|P16:[F5][F5]
* **** = The current state of each dry contact input:
* ''0'' = open, off.
* ''1'' = closed, on.
=== Example ===
// States returned for SW16 on CFLink ID [22]
< [F2][22][F3]RSWXSTA[F4]P01:1|P02:0|P03:0|P04:0|P05:0|P06:0|P07:0|P08:0|P09:0|P10:0|P11:0|P12:0|P13:0|P14:0|P15:0|P16:0[F5][F5]
// Port 1 is closed, on.
// Ports 2-16 are open, off.
==== LED - Query LED States ====
The ''LED'' query returns the states of all the LEDs (except backlight LEDs).
=== Data ===
> [F2][F3]QSWXLED[F4][F5][F5]
=== Reply ===
< [F2][F3]RSWXLED[F4]::[F5][F5]
The reply will include data for all ports of the device. So for the SW16, there will be 16 sets of port data, separated by single pipe ''|''.\\
\\
* **** = The port number in ''P##'' format. Eg. Port 1 is ''P01''.
* **** = The current action state of the LED:
* ''X'' = Not changing
* ''B'' = Blinking
* ''D'' = Dimming
* ''P'' = Pulsing
* ''R'' = Ramping
* **** = The level of the LED brightness, ''0'' to ''100''.
\\
Note that the LED level
=== Example ===
// Request the LED states of a SW16 on CFLink ID [22]
> [F2][22][F3]QSWXLED[F4][F5][F5]
// Returns states for all 16 LEDs
< [F2][22][F3]RSWXLED[F4]P01:X:0|P02:X:100|P03:D:50|P04:D:20|P05:B:0|P06:B:70|P07:P:0|P08:P:68|P09:X:0|P10:X:0|P11:X:0|P12:X:0|P13:X:0|P14:X:0|P15:X:0|P16:X:0[F5][F5]
==== BKL - Query Backlight LED States ====
The ''BKL'' (Backlight) query returns the states of all the backlight LEDs.
=== Data ===
> [F2][F3]QSWXBKL[F4][F5][F5]
=== Reply ===
< [F2][F3]RSWXBKL[F4]::[F5][F5]
==== BKL - Query Backlight LED States ====
The ''BKL'' (Backlight) query returns the states of all the backlight LEDs.
=== Data ===
> [F2][F3]QSWXBKL[F4][F5][F5]
=== Reply ===
< [F2][F3]RSWXBKL[F4]::[F5][F5]
The reply will include data for all backlight LEDs of the device. So for the SW16, there will be 4 sets of port data, separated by single pipe ''|''.
* **** = The port number in ''P##'' format. Eg. Port 1 is ''P01''.
* **** = The current action state of the backlight LED:
* ''X'' = Not changing
* ''B'' = Blinking
* ''D'' = Dimming
* ''P'' = Pulsing
* ''R'' = Ramping
* **** = The level of the backlight LED brightness, ''0'' to ''100''.
=== Example ===
// Request the backlight LED states of a SW16 on CFLink ID [22]
> [F2][22][F3]QSWXBKL[F4][F5][F5]
// Returns states for all 4 LEDs
< [F2][22][F3]RSWXBKL[F4]P01:X:0|P02:P:100|P03:D:50|P04:B:20[F5][F5]
===== Transmission Messages =====
==== LED - Set LED States ====
The ''LED'' command is used to set the states of one or more of the 16 LED channels on the SW16.
=== Data ===
The ''LED'' command can be used to change the LED states in a variety of ways, including basic on/off/toggle, and more advanced blinking, dimming and ramping.\\
Combine multiple LED port changes by using the [[hardware:cflink:cflink-introduction#data-separators|port separator]] character, ''|'' (single pipe).
== On, Off, Toggle ==
> [F2][F3]TSWXLED[F4]:[F5][F5]
* **** = The port number in ''P##'' format. Eg. Port 1 is ''P01''.
* **** = The state to set the LED to
* ''0'' = Off
* ''1'' = On
* ''T'' = Toggle (invert the LED state, on if it was off, off if it was on)
== Pulse ==
> [F2][F3]TSWXLED[F4]:P:
* **** = The port number in ''P##'' format. Eg. Port 1 is ''P01''.
* **