Protocol specification
The protocol is available on TCP/IP port 10001.
The protocol is line-based, meaning each request and each response is transmitted as a single line of text.
All requests are executed in order, and each request generates exactly one response. After sending a request, it is important to read the entire response. Otherwise, the TCP/IP connection will stall when the transmit buffer in the printer is full. Alternatively, responses can be suppressed by prefixing the request with a tile character.
Line termination
A line may be terminated using any of the following:
- LF — ASCII line feed, decimal
10, hex0A - CR — ASCII carrige return, decimal
13, hex0D - CR+LF
Character encoding
All content must be encoded using UTF-8.
Request format
The format of the request is a method name, followed by an optional parameter as a JSON value, separated by a single space.
If a client does not need to know whether a request is successful or
not, the request can be prefixed with a tilde character (~),
e.g. "~trigger". This will cause the printer to omit sending a
response, and instead terminate the connection on error.
Reponse format
The format of a response is a single line consisting of a status code followed by a single space and a JSON variable. The status code is one of the following:
| Status code | Description |
|---|---|
OK | The request was successful. |
METHOD_NOT_FOUND | The requested method does not exist. |
INVALID_PARAMS | The parameters are invalid, e.g. it could be invalid JSON, the wrong type, or be missing required keys. |
REQUEST_FAILED | The request failed, e.g. a request for an object that doesn't exist, or the printer is in the wrong state, etc. |
The returned variable can be of any valid JSON type, e.g. null, a
string, an object, etc. For successful requests (with status OK),
the type of the response depends on the request. For unsuccessful
requests, the type is always a string.
Responses that do not have a meaningful return value will still return
null. For example:
OK null