Pārlūkot izejas kodu

README: Document GetSalt packet.

Mathias Gottschlag 5 gadus atpakaļ
vecāks
revīzija
255cb55f3c
1 mainītis faili ar 16 papildinājumiem un 15 dzēšanām
  1. 16
    15
      README.md

+ 16
- 15
README.md Parādīt failu

@@ -49,17 +49,14 @@ For an Ubuntu host, the following steps can be used:
49 49
 
50 50
 # Protocol
51 51
 
52
-Packets are up to 32 bytes long. Most bytes are encrypted via XXTEA, except for
53
-one packet sent to the base station from a device to request a random number. The
54
-base station then replies with an encrypted packet containing a random salt
55
-value, and the device uses this salt for all further communication until the next
56
-reset, increasing the salt value by one for each packet sent. This scheme removes
57
-the need for the device to generate random numbers, as microcontrollers commonly
58
-are not capable of generation of high-quality random numbers.
59
-
60
-The packet sent from the device to the base station to request a salt consists of
61
-a single byte with the sender ID and is recognized by the base station by its
62
-length.
52
+Packets are up to 32 bytes long. All bytes are encrypted via XXTEA. First, the
53
+device requests a salt from the base station requests (using salt 0 for the
54
+packet). The base station then replies with an encrypted packet containing a
55
+random salt value, and the device uses this salt for all further communication
56
+until the next reset, increasing the salt value by one for each packet sent.
57
+This scheme removes the need for the device to generate random numbers, as
58
+microcontrollers commonly are not capable of generation of high-quality random
59
+numbers.
63 60
 
64 61
 ### Packet Format
65 62
 
@@ -74,6 +71,8 @@ fields being encoded as little-endian:
74 71
    The most significant bit of the salt value is 0 for packets from the device
75 72
    to the base station and 1 for packets from the base station to the device.
76 73
 
74
+   For GetSalt packets, the remainder of the salt is 0.
75
+
77 76
 All fields from here on are encrypted with XXTEA, using the first 8 bytes of the
78 77
 packet as the salt.
79 78
 
@@ -82,15 +81,17 @@ packet as the salt.
82 81
    The 5 least significant bits of the field encode the packet type, with the
83 82
    following possible values:
84 83
 
85
-   0. Salt: The packet is sent by the base station to the device whenever a
84
+   0. GetSalt: The packet is sent by the device when no salt is available. The
85
+      base station replies with a Salt packet.
86
+   1. Salt: The packet is sent by the base station to the device whenever a
86 87
       1-byte packet containing the device ID is received.
87
-   1. Report: The packet contains values measured by _this_ node. The element
88
+   2. Report: The packet contains values measured by _this_ node. The element
88 89
       count signals the number of values (of different types) reported by the
89 90
       device.
90
-   2. GetValues: Sent by a device to request values generated by _other_ sensor
91
+   3. GetValues: Sent by a device to request values generated by _other_ sensor
91 92
       nodes from the base station, or to request the current time. The element
92 93
       count signals the number of different values requested.
93
-   3. Values: Reply to a `GetValues` packet containing the requested information.
94
+   4. Values: Reply to a `GetValues` packet containing the requested information.
94 95
 
95 96
    The 3 most significant bits of the field encode the element count for packets
96 97
    which can hold multiple elements (as described below).

Notiek ielāde…
Atcelt
Saglabāt