From 7cdd5c04d5e966b3c90a3d86720e0823b4f7ee2c Mon Sep 17 00:00:00 2001 From: bt Date: Tue, 10 Mar 2026 22:50:53 +0100 Subject: Update spec --- PROTOCOL.md | 74 +++++++++++++------------------------------------------------ 1 file changed, 16 insertions(+), 58 deletions(-) (limited to 'PROTOCOL.md') diff --git a/PROTOCOL.md b/PROTOCOL.md index 895d1df..886161c 100644 --- a/PROTOCOL.md +++ b/PROTOCOL.md @@ -2,48 +2,41 @@ # SOLEC protocol specification +## Data format + * Payload can contain multiple numeric types or binary data in a single frame * Numeric types are big endian -* Numeric types names are same as in [Go](https://go.dev/ref/spec#Numeric_types) * See [test payload](#Test) for an example of complex data structure -## Frame +### Frame structure | Type | Description | |----------|----------------| | `uint8` | Payload type | | `uint16` | Payload length | -| `[]any` | Payload | - +| `any` | Payload | -## Data types -### Numeric types +### Special types -* `uint8` -* `uint16` -* `uint32` -* `uint64` +#### Strings and binary -### `binary` +Strings and binary data are prefixed wtith 2 bytes denoting their length. +Strings are UTF-8 encoded. -| Type | Description | -|--------|----------------| -| uint16 | Data length | -| binary | Data | +#### Timestamps -### `string` +Timestamps are stored as `uint64` in [Unix format](https://en.wikipedia.org/wiki/Unix_time). +Timezone is always set to UTC. -UTF-8 encoded string encapsulated in `bianry` type. +### Payloads -### `time` +All payload types are described in following files: -[Unix timestamp](https://en.wikipedia.org/wiki/Unix_time) stored in `uint16`. -Timezone is always UTC. +* [Kaitai Struct](https://git.sr.ht/~rctt/solec/blob/main/solec.ksy) +* [SVG graph](https://git.sr.ht/~rctt/solec/blob/main/solec.svg) -# Payloads - -## Payload prefixes +### Payload types | Type | Name | |------|--------------| @@ -53,39 +46,4 @@ Timezone is always UTC. | 0x04 | Message | | 0xFF | Test | -## Payload types - -### Handshake - -| Type | Name | Description | -|--------|---------------------|----------------------------------------------------------| -| uint8 | ProtocolVersionMajor | Bumped if changes are incompatible with previous version | -| uint8 | PrococolVersionMinor | Bumber if changes are backwards compatible | - - -### Ping - -Can be send by client or server. Receiver shoudl reply with `Pong`. - -### Pong - -Reply to `ping`. - -| Type | Name | Description | -|--------|------|-------------------------| -| uint64 | Time | Set just before sending | - -### Test - -Used for testing purposes. Can change at any time. -| Type | Name | Description | -|--------|-------|-------------| -| uint8 | Num1 | | -| time | Time1 | | -| string | Str1 | | -| uint16 | Num2 | | -| binary | Bin1 | | -| uint32 | Num3 | | -| string | Str2 | | -| uint64 | Num4 | | -- cgit v1.2.3