|
|
|
|
|
|
49
|
|
49
|
|
|
50
|
# Protocol
|
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
|
### Packet Format
|
61
|
### Packet Format
|
|
65
|
|
62
|
|
|
|
|
|
|
|
74
|
The most significant bit of the salt value is 0 for packets from the device
|
71
|
The most significant bit of the salt value is 0 for packets from the device
|
|
75
|
to the base station and 1 for packets from the base station to the device.
|
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
|
All fields from here on are encrypted with XXTEA, using the first 8 bytes of the
|
76
|
All fields from here on are encrypted with XXTEA, using the first 8 bytes of the
|
|
78
|
packet as the salt.
|
77
|
packet as the salt.
|
|
79
|
|
78
|
|
|
|
|
|
|
|
82
|
The 5 least significant bits of the field encode the packet type, with the
|
81
|
The 5 least significant bits of the field encode the packet type, with the
|
|
83
|
following possible values:
|
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
|
1-byte packet containing the device ID is received.
|
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
|
count signals the number of values (of different types) reported by the
|
89
|
count signals the number of values (of different types) reported by the
|
|
89
|
device.
|
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
|
nodes from the base station, or to request the current time. The element
|
92
|
nodes from the base station, or to request the current time. The element
|
|
92
|
count signals the number of different values requested.
|
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
|
The 3 most significant bits of the field encode the element count for packets
|
96
|
The 3 most significant bits of the field encode the element count for packets
|
|
96
|
which can hold multiple elements (as described below).
|
97
|
which can hold multiple elements (as described below).
|