fix: CRC32 at a logical place
This commit is contained in:
parent
3f7c7f35bf
commit
7aee04e629
1 changed files with 28 additions and 28 deletions
48
doc/proto.md
48
doc/proto.md
|
@ -12,16 +12,16 @@ This can be changed with something like TLS but that's up to the implementer.
|
||||||
Packets are sent in big endian.
|
Packets are sent in big endian.
|
||||||
|
|
||||||
| offset | size | name | description | example |
|
| offset | size | name | description | example |
|
||||||
|--------|---------------------------|---------------|------------------------------------------------------------------------------------|--------------|
|
|----------------------------------|---------------------------|---------------|------------------------------------------------------------------------------------|--------------|
|
||||||
| `0x00` | 1 byte | `version` | This describes the version of the packet | `0x01` |
|
| `0x00` | 1 byte | `version` | This describes the version of the packet | `0x01` |
|
||||||
| `0x01` | 4 bytes | `src` | This describes who sent the packet a.k.a. source device id | `0xAABBCCDD` |
|
| `0x01` | 4 bytes | `src` | This describes who sent the packet a.k.a. source device id | `0xAABBCCDD` |
|
||||||
| `0x05` | 4 bytes | `dest` | This describes who the packet is for a.k.a. destination device id | `0xAABBCCDD` |
|
| `0x05` | 4 bytes | `dest` | This describes who the packet is for a.k.a. destination device id | `0xAABBCCDD` |
|
||||||
| `0x09` | 4 bytes | `checksum` | This is the CRC32 checksum of the *whole packet*. | `0x00000000` |
|
| `0x09` | 4 bytes | `packet_id` | This is the unique identifier of the packet | `0xFAB1B39D` |
|
||||||
| `0x0D` | 4 bytes | `packet_id` | This is the unique identifier of the packet | `0xFAB1B39D` |
|
| `0x0D` | 4 bytes | `reply_to` | This describes what this packet is replying to, if initial message, value is `0x0` | `0x00000000` |
|
||||||
| `0x11` | 4 bytes | `reply_to` | This describes what this packet is replying to, if initial message, value is `0x0` | `0x00000000` |
|
| `0x11` | 1 byte | `command` | This describes what kind of command is sent | `0x00` |
|
||||||
| `0x12` | 1 byte | `command` | This describes what kind of command is sent | `0x00` |
|
| `0x12` | 2 bytes | `data_length` | This describes the length of the data in bytes | `0x0001` |
|
||||||
| `0x13` | 2 bytes | `data_length` | This describes the length of the data in bytes | `0x0001` |
|
| `0x14` | `<0x11-0x12:data_length>` | `data` | This is the data of the command | `0x00` |
|
||||||
| `0x15` | `<0x11-0x12:data_length>` | `data` | This is the data of the command | `0x00` |
|
| `0x14 + <0x11-0x12:data_length>` | 4 bytes | `checksum` | This is the CRC32 checksum of the packet without the checksum. | `0x00000000` |
|
||||||
|
|
||||||
# Packets in practice
|
# Packets in practice
|
||||||
|
|
||||||
|
@ -43,10 +43,10 @@ The "reserved" column (if present) will state what should be filled in by each s
|
||||||
# Error checking
|
# Error checking
|
||||||
|
|
||||||
If the CRC32 doesn't match up the receiver will send a `0x0E` (error) packet to the probable source.
|
If the CRC32 doesn't match up the receiver will send a `0x0E` (error) packet to the probable source.
|
||||||
The error code `0x01`/`net_broken_packet` should be used. The metadata may contain some textual info on what went wrong.
|
The error code `0x01`/`net_broken_packet` should be used. The metadata may contain some textual info on what went
|
||||||
|
wrong.
|
||||||
The master will not track the broken packet's `packet_id`, so the slave can send it again.
|
The master will not track the broken packet's `packet_id`, so the slave can send it again.
|
||||||
|
|
||||||
|
|
||||||
# Data types
|
# Data types
|
||||||
|
|
||||||
Domo has a data framework reliant on data types.
|
Domo has a data framework reliant on data types.
|
||||||
|
@ -92,7 +92,7 @@ This command will register a node.
|
||||||
|
|
||||||
| offset | size | name | description | example |
|
| offset | size | name | description | example |
|
||||||
|--------|---------|-------------|------------------------------------------------|--------------|
|
|--------|---------|-------------|------------------------------------------------|--------------|
|
||||||
| `0x15` | 4 bytes | `device_id` | the device identifier. (reserved for response) | `0x00000000` |
|
| `0x14` | 4 bytes | `device_id` | the device identifier. (reserved for response) | `0x00000000` |
|
||||||
|
|
||||||
#### Example request
|
#### Example request
|
||||||
|
|
||||||
|
@ -122,9 +122,9 @@ there is no extra data required.
|
||||||
|
|
||||||
| offset | size | name | description | reserved | example |
|
| offset | size | name | description | reserved | example |
|
||||||
|--------|-----------|-----------------|---------------------------------------------|----------|---------|
|
|--------|-----------|-----------------|---------------------------------------------|----------|---------|
|
||||||
| `0x15` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
| `0x14` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
||||||
| `0x35` | 1 byte | `data_type` | The type of data; see "Data types". | no | `0x01` |
|
| `0x34` | 1 byte | `data_type` | The type of data; see "Data types". | no | `0x01` |
|
||||||
| `0x36` | **1 bit** | `read_only` | Whether the property is readonly. | no | `0b0` |
|
| `0x35` | **1 bit** | `read_only` | Whether the property is readonly. | no | `0b0` |
|
||||||
|
|
||||||
### `0x04` - Remove property
|
### `0x04` - Remove property
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ there is no extra data required.
|
||||||
|
|
||||||
| offset | size | name | description | reserved | example |
|
| offset | size | name | description | reserved | example |
|
||||||
|--------|----------|-----------------|---------------------------------------------|----------|---------|
|
|--------|----------|-----------------|---------------------------------------------|----------|---------|
|
||||||
| `0x15` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
| `0x14` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
||||||
|
|
||||||
### `0x0E` - Error
|
### `0x0E` - Error
|
||||||
|
|
||||||
|
@ -142,9 +142,9 @@ Send a packet to state an error occurred.
|
||||||
|
|
||||||
| offset | size | name | description | example |
|
| offset | size | name | description | example |
|
||||||
|--------|-------------------------------|-------------------|---------------------------------|----------|
|
|--------|-------------------------------|-------------------|---------------------------------|----------|
|
||||||
| `0x15` | 1 byte | `error_code` | error code; check 'Error codes' | `0x00` |
|
| `0x14` | 1 byte | `error_code` | error code; check 'Error codes' | `0x00` |
|
||||||
| `0x16` | 2 bytes | `metadata_length` | metadata length | `0x0000` |
|
| `0x15` | 2 bytes | `metadata_length` | metadata length | `0x0000` |
|
||||||
| `0x18` | `<0x14-0x15:metadata_length>` | `metadata` | metadata | |
|
| `0x17` | `<0x14-0x15:metadata_length>` | `metadata` | metadata | |
|
||||||
|
|
||||||
#### Error codes
|
#### Error codes
|
||||||
|
|
||||||
|
@ -168,9 +168,9 @@ Get a properties value
|
||||||
|
|
||||||
| offset | size | name | description | reserved | example |
|
| offset | size | name | description | reserved | example |
|
||||||
|--------|-------------------------|-----------------|---------------------------------------------|----------|---------|
|
|--------|-------------------------|-----------------|---------------------------------------------|----------|---------|
|
||||||
| `0x15` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
| `0x14` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
||||||
| `0x35` | 1 byte | `data_type` | The type of the data. | response | `0x00` |
|
| `0x34` | 1 byte | `data_type` | The type of the data. | response | `0x00` |
|
||||||
| `0x36` | determined by data type | `data` | The actual data. | response | |
|
| `0x35` | determined by data type | `data` | The actual data. | response | |
|
||||||
|
|
||||||
### `0x11` - Set property
|
### `0x11` - Set property
|
||||||
|
|
||||||
|
@ -178,9 +178,9 @@ Get a properties value
|
||||||
|
|
||||||
| offset | size | name | description | reserved | example |
|
| offset | size | name | description | reserved | example |
|
||||||
|--------|-------------------------|-----------------|---------------------------------------------|----------|---------|
|
|--------|-------------------------|-----------------|---------------------------------------------|----------|---------|
|
||||||
| `0x15` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
| `0x14` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
||||||
| `0x35` | 1 byte | `data_type` | The type of the data. | no | `0x00` |
|
| `0x34` | 1 byte | `data_type` | The type of the data. | no | `0x00` |
|
||||||
| `0x36` | determined by data type | `data` | The actual data. | no | |
|
| `0x35` | determined by data type | `data` | The actual data. | no | |
|
||||||
|
|
||||||
### `0x12` - Reset property
|
### `0x12` - Reset property
|
||||||
|
|
||||||
|
@ -188,4 +188,4 @@ Get a properties value
|
||||||
|
|
||||||
| offset | size | name | description | reserved | example |
|
| offset | size | name | description | reserved | example |
|
||||||
|--------|----------|-----------------|---------------------------------------------|----------|---------|
|
|--------|----------|-----------------|---------------------------------------------|----------|---------|
|
||||||
| `0x15` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
| `0x14` | 32 bytes | `property_name` | The name of the property as a UTF-8 string. | no | "Power" |
|
Loading…
Reference in a new issue