-
Notifications
You must be signed in to change notification settings - Fork 5
/
HACKING
137 lines (92 loc) · 3.76 KB
/
HACKING
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
Protocols
=========
Router Web API
--------------
If enabled in the router config, the router can be
controlled using an HTTP-based API. The default port
is 7535.
Use the dimmer to regulate the global brightness::
POST /api/dimmer <= on
POST /api/dimmer <= off
POST /api/dimmer <= A0A0
GET /api/dimmer => A0A0
The backlight is a special layer that is below all other
layers. It always sets all LEDs to the same color::
POST /api/backlight <= FF00FF
GET /api/backlight => FF00FF
You can also get a list of connected clients, and close
their connections::
GET /api/clients
POST /api/clients/1234 <= kill
The dimmer and backlight support jsonp. Just add `?jsonp=func` as
a GET parameter and the response will be javascript calling the
function named `func` with the results.
Router Webhooks
---------------
In the router configuration, you can specify URLs that the router
will call when the backlight color or dimmer setting changes:
GET /foo?dimmer=12826
GET /bar?color=ffff0000ffff
Network protocol
----------------
This section is probably only useful if you want
to implement the actual low-level network protocol.
Check `vaporware/language_bindings/` - there may
already be a library for your language!
Open a TCP connection to the router
(default port: 7534) and send commands::
<command> ::= <auth>
| <set-led-8>
| <set-led-16>
| <strobe>
All commands consist of a 1-byte opcode and a payload.
First, you have to authenticate yourself using
the auth command and a 16-byte access token.
Shorter tokens are to be padded with 0x00 bytes.
Tokens have a priority defined in the server
config which determines rendering order::
<auth> ::= 0x02 <token>
<token> ::= <byte>{16}
Now, you can set LEDs to colors.
Currently, you can only set desired raw PWM values. Values range
from 0x0000 (lowest or, for the alpha channel, transparent)
to 0xFFFF (highest or opaque)::
<set-led-16> ::= 0x03 <led-id:int16> <rgba-16>
<rgba-16> ::= <r:int16> <g:int16> <b:int16> <a:int16>
<int16> ::= <high:byte> <low:byte>
For historicaly reasons, there is also a legacy
low-precision version of the set-led command::
<set-led-8> ::= 0x01 <led-id:int16> <rgba-8>
<rgba-8> ::= <r:byte> <g:byte> <b:byte> <a:byte>
Changes don't take effect until you issue
a strobe command, at which point they take
effect all at once::
<strobe> ::= 0xFF
Bus protocol
------------
The following describes the protocol the router
uses to communicate with the LED modules.
The router acts as the bus master. It is the only device
that can send data on the bus. The LED modules may only receive.
The bus speed is 500000 baud (slower bus speeds may be used;
however that requires a special firmware for the LED modules).
The router sends whole frames.
The byte 0x54 is called the escape mark and 0x55 the stark mark.
To escape a payload, substitute 0x54 by 0x54 0x00 and 0x55 by 0x54 0x01.
Each frame consists of the start mark and an escaped payload.
<frame> ::= 0x55 escape(<frame-payload>)
<frame-payload> ::= <address> <command>
<command> ::= <set-raw> | <set-xyY> | <set-conf> | <set-addr> | <strobe>
The set-raw command can be used to set the values for the PWM output
channels directly. Currently, all LED modules have 16 channels.
<set-raw> ::= 0x00 ( <int16> ){16}
Alternatively, the desired colors can be expressed using the xyY color
space. Note that this requires properly calibrated LED modules.
<set-xyy> ::= 0x01 ( <xyY> ){5}
<xyY> ::= <x: int16> <y: int16> <Y: int16>
Updates only take effect when a strobe command is sent:
<strobe> ::= 0xff
Again, all 16-bit numbers are big endian::
<int16> ::= <high byte> <low byte>
The set-conf and set-addr commands are currently
unsupported and unspecified.