summaryrefslogtreecommitdiffstats
path: root/PROTOCOL.md
blob: 886161cb8e8c19f2e1f83141bc3ba3f5c1c0fe26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!--- ---------------------------------------------------------------------  -->

# SOLEC protocol specification

## Data format

* Payload can contain multiple numeric types or binary data in a single frame
* Numeric types are big endian
* See [test payload](#Test) for an example of complex data structure

### Frame structure

| Type     | Description    |
|----------|----------------|
| `uint8`  | Payload type   |
| `uint16` | Payload length |
| `any`    | Payload        |


### Special types

#### Strings and binary

Strings and binary data are prefixed wtith 2 bytes denoting their length.
Strings are UTF-8 encoded.

#### Timestamps

Timestamps are stored as `uint64` in [Unix format](https://en.wikipedia.org/wiki/Unix_time).
Timezone is always set to UTC.

### Payloads

All payload types are described in following files:

* [Kaitai Struct](https://git.sr.ht/~rctt/solec/blob/main/solec.ksy)
* [SVG graph](https://git.sr.ht/~rctt/solec/blob/main/solec.svg)

### Payload types

| Type | Name         |
|------|--------------|
| 0x01 | Handshake    |
| 0x02 | Ping         |
| 0x03 | Pong         |
| 0x04 | Message      |
| 0xFF | Test         |