blc_server
Webserver which send data of blc channels
Install
It requires libwebsockets v3.1 or higher.
On OSX
You simply use: **brew install libwebsockets
Ubuntu 18.04
You need to compile it from sources ( apt only install v2.04 )
git clone git clone https://libwebsockets.org/repo/libwebsockets #Download the sources
cd libwebsockets
cmake .
make -j .
sudo make -j install
cd ..
rm -rf libwebsockets #remove the sources it is not necessary anymore
Then install blc_server like any other blaar project
cd $BLAAR_DIR
git submodule add https://promethe.u-cergy.fr/blaar/blc_server.git
./install.sh blc_server
Protocol
Webpage
Once you launch it, a http server is started on port '80' ( default http port ). It will send a standard webpage allowing to display the structure of the blc channels by requesting data on the websocket 'blc_channels'.
Websockets
The server creates a websocket named blc_channels. On the first connection and for each changes, it sensd a description of the blc channels in text (JSON):
{ "channels": [
{"id": 1, "name": "/toto", "type": "UIN8", "format": "NDEF", "dims": [
{"length":2, "step":1},
{"length":10, "step":2}]
},
...
{"id": 5, "name": "/titi", "type": "UIN8", "format": "RGB3", "dims": [
{"length":3, "step":1},
{"length":800, "step":3 },
{"length":600, "step":1800}]
}
]}
You can send and request data for each channel. In binary mode send:
<id int32_t><timing int32_t>[<data uchar>]
id is the id of the blc channel you want to update, timing has no effect and data is the content of the blc channel you want to update. If there is no data, the server will send back the content of the blc channel. If timing is -1 it will send it only once, if it is >=0 it will send it periodically at 10Hz, if it is -2 it will stop to send it periodically.
The format of the data from the server is in binary and can concatenate many channels:
<size uint32><id uint32><data uchar><size><id><data> ... <size><id><data>
size if the size of one message i.e. 4 bytes (size) + 4 bytes (id) + size of data, id is the id of the blc channel to update, data is an array of bytes.