-
Notifications
You must be signed in to change notification settings - Fork 20
CANServer v2 WebSocket
As of firmware version 2.1 the CANServer supports clients subscribing to Analysis Items and Lua Variables.
The websocket endpoint is: ws://canserver.local/ws (Depending on what you have set the hostname to. Will always be <hostname>.local. See Network for details on that).
The CANServer will send a PING frame every 3 seconds. Clients are required to respond with a PONG frame or the connection will be closed by the CANServer. Clients can send PING frames and the CANServer will respond with PONG frames but this does not negate the need to respond to the CANServer's PINGs.
The CANServer uses a simple subscribe/publish protocol. All frames passed back and forth are of the TEXT type, with json payloads
Clients can subscribe (and unsubscribe) to Analysis Items, Lua Variables, and Display Strings. When any of the subscribed items are updated the CANServer will send the changed value to all subscribed clients.
Subscribed values will be sent at a maximum rate of 25Hz.
{
"t": "sub",
"p": {
"i": "<AnalysisItemName>"
}
}
{
"t": "unsub",
"p": {
"i": "<AnalysisItemName>"
}
}
{
"t": "sub",
"p": {
"l": "<LuaVariableName>"
}
}
{
"t": "usub",
"p": {
"l": "<LuaVariableName>"
}
}
{
"t": "sub",
"p": {
"d": <DisplayId (0-3)>
}
}
{
"t": "usub",
"p": {
"d": <DisplayId (0-3)>
}
}
Once subscriptions have been sent to the server any time a subscribed item or variable is changed it will be sent to the client. The format of the frame is follows:
(This example is for an Analysis Item)
{
"t": "val",
"p": {
"i": "<AnalysisItemName>",
"v": 8833.23
}
}
(This example is for an Lua Variable)
{
"t": "val",
"p": {
"l": "<LuaVaraibleName>",
"v": 8833.23
}
}