feat: new protocol updates
This commit is contained in:
parent
879cd88ecd
commit
53f1b36505
1 changed files with 63 additions and 29 deletions
92
doc/proto.md
92
doc/proto.md
|
@ -12,7 +12,7 @@ This can be changed with something like TLS but that's up to the implementer.
|
|||
Packets are sent in big endian.
|
||||
|
||||
| offset | size | name | description | example |
|
||||
|----------------------------------|---------------------------|---------------|------------------------------------------------------------------------------------|--------------|
|
||||
| -------------------------------- | ------------------------- | ------------- | ---------------------------------------------------------------------------------- | ------------ |
|
||||
| `0x00` | 1 byte | `version` | This describes the version of the packet | `0x01` |
|
||||
| `0x01` | 4 bytes | `dest` | This describes who the packet is for a.k.a. destination device id | `0xAABBCCDD` |
|
||||
| `0x05` | 4 bytes | `src` | This describes who sent the packet a.k.a. source device id | `0xAABBCCDD` |
|
||||
|
@ -52,21 +52,25 @@ The master will not track the broken packet's `packet_id`, so the slave can send
|
|||
Domo has a data framework reliant on data types.
|
||||
These define what kind of data the property holds.
|
||||
|
||||
| `data_type` | physical type (rust types) | size | virtual type | description |
|
||||
|-------------|----------------------------|-----------|---------------------|-----------------------------------------------------------------------------|
|
||||
| `0x0*` | | | | **Meta** |
|
||||
| `0x00` | `None` | 0 bytes | Nothing | Nothing, mostly used internally or as example. |
|
||||
| `0x01` | `Vec<DataType>` | 2+ bytes | Array | An array of DataTypes. first two bytes is the u16 length |
|
||||
| `0x1*` | | | | **Simple** |
|
||||
| `0x10` | `bool` | 1 byte | Switch | A simple switch with two states. `0x00` = off, `0x01` = on, `0x02` = toggle |
|
||||
| `0x11` | `u8` | 1 byte | Slider | A simple slider with u8 precision. |
|
||||
| `0x12` | `[u8; 256]` | 256 bytes | Text | A simple bit of text. |
|
||||
| `0x2*` | | | | **Cosmetic** |
|
||||
| `0x20` | `[u8; 3]` | 3 bytes | Color | An RGB value. |
|
||||
| `0x9*` | | | | **Time & Space** |
|
||||
| `0x90` | `u64` | 8 bytes | Seconds | A simple value that is in seconds. |
|
||||
| `0xF*` | | | | **Domo types** |
|
||||
| `0xF0` | `[u8; 4]` | 4 bytes | Domo node reference | A reference to a node. |
|
||||
| `data_type` | size | type | description |
|
||||
| ----------- | --------- | ---------- | ---------------------------------------------------------------------- |
|
||||
| `0x0*` | | | **Meta** |
|
||||
| `0x00` | 0 bytes | Nothing | Nothing |
|
||||
| `0x01` | 2+ bytes | Array | An array of DataTypes. first two bytes is the length in u16 BE |
|
||||
| `0x1*` | | | **Basic** |
|
||||
| `0x10` | 1 byte | Boolean | `0x00` = false, `0x01` = true, `0x02` = toggle item (reserved for set) |
|
||||
| `0x11` | 8 bytes | Number | A number. |
|
||||
| `0x12` | 256 bytes | Text | A simple bit of text. |
|
||||
| `0x13` | 4 bytes | Identifier | An identifier. |
|
||||
| `0x2*` | | | **Color** |
|
||||
| `0x20` | 3 bytes | RGB | An RGB value. |
|
||||
|
||||
<!--
|
||||
REQ prop/get "firmware"
|
||||
RES prop/get <DataType::Identifier(0xABFF21FA)> // this is the setup packet id
|
||||
RES raw/setup size=10B
|
||||
RES raw/data [0x0000 (0x2710)] ....
|
||||
-->
|
||||
|
||||
## Dynamic data (`dynamic_data`)
|
||||
|
||||
|
@ -75,7 +79,7 @@ Dynamic data is a data snippet with a `prop_data_type` byte and the data next to
|
|||
> **Note**: this section uses relative offset
|
||||
|
||||
| offset | size | name | description | example |
|
||||
|--------|-------------------------------|------------------|-------------------------|---------|
|
||||
| ------ | ----------------------------- | ---------------- | ----------------------- | ------- |
|
||||
| `0x00` | 1 byte | `prop_data_type` | Describes the data type | `0x00` |
|
||||
| `0x01` | depending on `prop_data_type` | `data` | The data | |
|
||||
|
||||
|
@ -107,7 +111,7 @@ Leave `0` to get a random id.
|
|||
#### Command data
|
||||
|
||||
| offset | size | name | description | reserved | example |
|
||||
|--------|---------|-------------|------------------------------------------------------------|----------|--------------|
|
||||
| ------ | ------- | ----------- | ---------------------------------------------------------- | -------- | ------------ |
|
||||
| `0x14` | 4 bytes | `device_id` | the device identifier. leave `0x00000000` to get random id | no | `0x00000000` |
|
||||
|
||||
### `0x02` - Remove node
|
||||
|
@ -123,7 +127,7 @@ there is no extra data required.
|
|||
#### Command data
|
||||
|
||||
| offset | size | name | description | reserved | example |
|
||||
|--------|----------|-----------------|--------------------------------------------------------------------|----------|---------|
|
||||
| ------ | -------- | --------------- | ------------------------------------------------------------------ | -------- | ------- |
|
||||
| `0x14` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
||||
| `0x34` | 1 byte | `data_type` | The type of data; see "Data types". | no | `0x01` |
|
||||
| `0x35` | 1 byte | `read_only` | Whether the property is readonly. <br/>(`0x00` = no, `0x01` = yes) | no | `0x00` |
|
||||
|
@ -133,7 +137,7 @@ there is no extra data required.
|
|||
#### Command data
|
||||
|
||||
| offset | size | name | description | reserved | example |
|
||||
|--------|----------|-----------------|---------------------------------------------|----------|---------|
|
||||
| ------ | -------- | --------------- | ------------------------------------------- | -------- | ------- |
|
||||
| `0x14` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
||||
|
||||
### `0x0E` - Error
|
||||
|
@ -143,7 +147,7 @@ Send a packet to state an error occurred.
|
|||
#### Command data
|
||||
|
||||
| offset | size | name | description | example |
|
||||
|--------|-------------------------------|-------------------|---------------------------------|----------|
|
||||
| ------ | ----------------------------- | ----------------- | ------------------------------- | -------- |
|
||||
| `0x14` | 1 byte | `error_code` | error code; check 'Error codes' | `0x00` |
|
||||
| `0x15` | 2 bytes | `metadata_length` | metadata length | `0x0000` |
|
||||
| `0x17` | `<0x14-0x15:metadata_length>` | `metadata` | metadata | |
|
||||
|
@ -151,7 +155,7 @@ Send a packet to state an error occurred.
|
|||
#### Error codes
|
||||
|
||||
| `status_code` | name | description | recoverable |
|
||||
|---------------|------------------------|----------------------------------------------------------------------------------------------|-----------------------------------|
|
||||
| ------------- | ---------------------- | -------------------------------------------------------------------------------------------- | --------------------------------- |
|
||||
| `0x1*` | `net_*` | **Network errors** | |
|
||||
| `0x00` | `net_duplicate_packet` | `reply_to` packet is invalid because another packet was sent recently with same `packet_id`. | resend with different `packet_id` |
|
||||
| `0x01` | `net_broken_packet` | recent packet was broken. | resend packet |
|
||||
|
@ -172,37 +176,67 @@ Get a properties value
|
|||
#### Command data
|
||||
|
||||
| offset | size | name | description | reserved | example |
|
||||
|--------|----------|-----------------|---------------------------------------------|----------|----------|
|
||||
| ------ | -------- | --------------- | ------------------------------------------- | -------- | -------- |
|
||||
| `0x14` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
||||
| `0x34` | dynamic | `dynamic_data` | Dynamic data snippet | response | `0x0100` |
|
||||
| `0x34` | dynamic | `dynamic_data` | Dynamic data snippet | response | `0x0100` |
|
||||
|
||||
### `0x11` - Set property
|
||||
|
||||
#### Command data
|
||||
|
||||
| offset | size | name | description | reserved | example |
|
||||
|--------|----------|-----------------|---------------------------------------------|----------|----------|
|
||||
| ------ | -------- | --------------- | ------------------------------------------- | -------- | -------- |
|
||||
| `0x14` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
||||
| `0x34` | dynamic | `dynamic_data` | Dynamic data snippet | no | `0x0100` |
|
||||
| `0x34` | dynamic | `dynamic_data` | Dynamic data snippet | no | `0x0100` |
|
||||
|
||||
### `0x12` - Reset property
|
||||
|
||||
#### Command data
|
||||
|
||||
| offset | size | name | description | reserved | example |
|
||||
|--------|----------|-----------------|---------------------------------------------|----------|---------|
|
||||
| ------ | -------- | --------------- | ------------------------------------------- | -------- | ------- |
|
||||
| `0x14` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
||||
|
||||
### `0x1A` - Subscribe to property
|
||||
|
||||
| offset | size | name | description | reserved | example |
|
||||
|--------|----------|-----------------|---------------------------------------------|----------|--------------|
|
||||
| ------ | -------- | --------------- | ------------------------------------------- | -------- | ------------ |
|
||||
| `0x14` | 4 bytes | `device_id` | Who's property? | no | `0x00000000` |
|
||||
| `0x18` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
||||
|
||||
### `0x1A` - Unsubscribe to property
|
||||
|
||||
| offset | size | name | description | reserved | example |
|
||||
|--------|----------|-----------------|---------------------------------------------|----------|--------------|
|
||||
| ------ | -------- | --------------- | ------------------------------------------- | -------- | ------------ |
|
||||
| `0x14` | 4 bytes | `device_id` | Who's property? | no | `0x00000000` |
|
||||
| `0x18` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
||||
|
||||
## `0xF*` - Raw data transmission
|
||||
|
||||
This is useful for things like OTA updates.
|
||||
|
||||
### `0xF0` - Setup transfer
|
||||
|
||||
Since this procedure is quite expensive (network wise), the sides must shake hands.
|
||||
|
||||
#### Command data
|
||||
|
||||
| offset | size | name | description | reserved | example |
|
||||
| ------ | --------- | ------ | -------------------- | -------- | ------- |
|
||||
| `0x14` | 8 bytes | `size` | u64 size of the data | request | `0x00` |
|
||||
| `0x1c` | 128 bytes | `mime` | media type of data | request | `0x00` |
|
||||
|
||||
### `0xF1` - Data
|
||||
|
||||
This is raw data.
|
||||
This may be sent without the initial transfer setup for custom implementations.
|
||||
|
||||
#### Command data
|
||||
|
||||
The `sequence_number` is added for redundancy, all data sent will always reply to it's previous data segment.
|
||||
|
||||
| offset | size | name | description | example |
|
||||
| ------ | -------- | ----------------- | ------------------------------- | ------------ |
|
||||
| `0x14` | 4 bytes | `sequence_number` | the sequence number of the data | `0x00000000` |
|
||||
| `0x18` | 4 bytes | `size` | size of this slice of data | `0x00000000` |
|
||||
| `0x1c` | `<size>` | `data` | the data | |
|
Loading…
Reference in a new issue