Drumber / RemoteLightServer

A server for the RemoteLight LED control software that can control addressable LED strips using Raspberry Pi boards.
Apache License 2.0
3 stars 0 forks source link

Server protocol clarification #3

Closed piccinnigius closed 3 years ago

piccinnigius commented 3 years ago

Awesome work! only one question, wich is the server protocol of json? i've tried to send the json array over 20002 port but i've got only errors in decoding...

Thanks so much!

Drumber commented 3 years ago

Hey, the protocol consists of a Json array, which contains as many Json objects as the set number of pixels. A Json object contains the RGB color ("value") represented as 4 bytes integer and the alpha value ("falpha"), which is actually always 0.0.

Example packet (2 pixels): [{"value":-65536,"falpha":0.0},{"value":-65536,"falpha":0.0}]

value parameter

value '-65536' converted to binary (2's complement): 11111111 11111111 00000000 00000000 == red

11111111 00000000 00000000 00000000 would be black

falpha parameter

Here are the relevant lines in the code:

However, I had planned to rework and optimize the protocol (only send colors as bytes and not serialized as json). As soon as the new protocol is ready, I would post it here.

piccinnigius commented 3 years ago

Hi @Drumber sorry for late feedback. I would like to reach a point where the server can be called throght websocket or some generic js apis! As soon as I can make a test i and I will keep you updated under this issue