The TCP Server
The TCP server is an licensed feature that allows the user to control the Otii application over a TCP socket using any language that supports TCP communication.
The communication with the server is performed using JSON messages sent to and from the server.
Message description
There is five types of messages request, response, progress, information and error.
Message types
Type |
Description |
---|---|
request |
Used for requests sent from the client. |
response |
Server response on requests from client. |
progress |
Server progress on requests supporting progress messaging |
information |
Information messages sent from server not connected to a request. |
error |
Error messages sent from server. |
Request syntax
Key |
Type |
Required |
Description |
---|---|---|---|
type |
String |
Yes |
Type of message. |
cmd |
String |
Yes |
Requested command. |
trans_id |
String |
Optional |
Transaction id for matching response objects. |
data |
Object |
Conditional |
Data for the command. |
{
"type": "request",
"cmd": "arc_calibrate",
"trans_id": "someId",
"data": {
"device_id": "Arc512031204843494E3130393033313036"
}
}
Response syntax
Key |
Type |
Required |
Description |
---|---|---|---|
type |
String |
Yes |
Type of message. |
cmd |
String |
Yes |
Requested command if the response is for a command request. |
trans_id |
String |
Conditional |
Corresponding requests transaction id if provided in request. |
data |
Object |
Conditional |
Data for response. |
{
"type": "response",
"cmd": "otii_devices",
"trans_id": "someId",
"data": {
"devices": [
{
"device_id": "Arc512031204843494E3130393033313036",
"name": "fire",
"type": "Arc"
}
]
}
}
Progress syntax
Key |
Type |
Required |
Description |
---|---|---|---|
type |
String |
Yes |
Type of message. |
cmd |
String |
Yes |
Requested command. |
progress_value |
Number |
Yes |
Progress described with a value from 0.0 to 1.0. |
trans_id |
String |
Conditional |
Corresponding requests transaction id if provided in request. |
data |
Object |
Conditional |
Progress data with more information if available. |
{
"type": "progress",
"cmd": "otii_save_project",
"progress_value": 0.73,
"trans_id": "someId"
}
Information syntax
Key |
Type |
Required |
Description |
---|---|---|---|
type |
String |
Yes |
Type of message. |
info |
String |
Yes |
Information message. |
data |
Object |
Conditional |
Information data with more information. |
{
"type": "information",
"info": "connected",
"data": {
"otii_version": "2.0.0",
"protocol_version": "0.1",
"server": "otii-server"
}
}
Error syntax
Key |
Type |
Required |
Description |
---|---|---|---|
type |
String |
Yes |
Type of message. |
errorcode |
String |
Yes |
The error code. |
cmd |
String |
Conditional |
Requested command if the error is for a command request. |
trans_id |
String |
Conditional |
Corresponding requests transaction id if provided in request. |
data |
Object |
Conditional |
Error data with more information. |
{
"type": "error",
"errorcode": "Device not connected",
"cmd": "arc_set_main_voltage",
"trans_id": "someId",
"data": {
"device_id": "Arc512031204843494E3130393033313036"
}
}