Final project - lamp protocol
I've defined a simple protocol for the lamps to communicate amongst themselves.
All commands start with the letter "L", followed by another letter and a series of parameters. The code for parsing the commands is pretty reliable, I will post it shortly.
Read past the link for a list of the commands.
The commands are:
Light LED: LS(LED number),(Red),(Green),(Blue)
Lights a multicolor LED (LED number) based on RGB values, which run from 0 (dark) to 255 (max bright)
Sensor: LE(Lamp number), (Sensor Number)
Sent by lamp (Lamp number) when the sensor (Sensor Number) is triggered.
Wakeup LW(Lamp number)
Sent by a lamp when it powers up. Used by the other lamps to maintain a list of which other lamps are active.
Timeout LT(Lamp number)
Sent by a lamp when it has received no local input for the time out period. When each lamp has received a timeout message from all other lamps, it goes into the timeout routine.
I am thinking of adding a heartbeat command, that allows the lamps to keep track of which other lamps are active, and a variant of the LS command that takes a specific lamp number. Right now LS will set all lamps to the same configuration. Also might add a debug command. The commands would look like this:
LB (Lamp number)
Sent every few seconds to indicate that a lamp is awake, or in response to receiving an LW message. (This allows a recently switched on lamp to build an inventory of other active lamps)
LI(Lamp number), (LED number), (Red), (Green), (Blue)
Like the LS command, but with a specific lamp number at the beginning. Maybe define a wildcard value for
LD(Lamp number)
This will trigger a debug output from the lamp specified, maybe current value of LEDs, timeout state, internal count of other active lamps.