Procházet zdrojové kódy

More protocol description, enough to implement sensor reports.

Mathias Gottschlag před 5 roky
rodič
revize
1dde4df49d
1 změnil soubory, kde provedl 24 přidání a 7 odebrání
  1. 24
    7
      README.md

+ 24
- 7
README.md Zobrazit soubor

61
 a single byte with the sender ID and is recognized by the base station by its
61
 a single byte with the sender ID and is recognized by the base station by its
62
 length.
62
 length.
63
 
63
 
64
+### Packet Format
65
+
64
 All encrypted packets follow the same scheme, with everything following after the
66
 All encrypted packets follow the same scheme, with everything following after the
65
 salt being encrypted using a per-device XXTEA key hardcoded on the device and
67
 salt being encrypted using a per-device XXTEA key hardcoded on the device and
66
 known to the base station. The packet fields are as follows, with multi-byte
68
 known to the base station. The packet fields are as follows, with multi-byte
67
 fields being encoded as little-endian:
69
 fields being encoded as little-endian:
68
 
70
 
69
 1. Device ID (1 byte)
71
 1. Device ID (1 byte)
70
-2. Salt (8 bytes)
72
+2. Remainder of salt (7 bytes)
71
 
73
 
72
    The most significant bit of the salt value is 0 for packets from the device
74
    The most significant bit of the salt value is 0 for packets from the device
73
    to the base station and 1 for packets from the base station to the device.
75
    to the base station and 1 for packets from the base station to the device.
74
 
76
 
75
-All fields from here on are encrypted with XXTEA, using the salt value contained
76
-in the packet.
77
-
78
-
77
+All fields from here on are encrypted with XXTEA, using the first 8 bytes of the
78
+packet as the salt.
79
 
79
 
80
 3. Packet type and element count (1 byte)
80
 3. Packet type and element count (1 byte)
81
 
81
 
92
       count signals the number of different values requested.
92
       count signals the number of different values requested.
93
    3. Values: Reply to a `GetValues` packet containing the requested information.
93
    3. Values: Reply to a `GetValues` packet containing the requested information.
94
 
94
 
95
-4. Packet payload (variable)
95
+   The 3 most significant bits of the field encode the element count for packets
96
+   which can holt multiple elements (as described below).
97
+
98
+4. Packet payload (always 21 bytes, padded with zero bytes)
96
 
99
 
97
-   TODO
100
+   The payload field holds the packet content, with a variable format depending
101
+   on the packet type:
102
+
103
+   * Salt: The first 7 bytes of the payload hold the salt used by the sensor node
104
+     from this time on.
105
+   * Report: The payload consists of a number of (value type, value)-tuples. The
106
+     possible value types and the corresponding value suze are listed below.
98
 
107
 
99
 5. CRC-16-CCITT checksum
108
 5. CRC-16-CCITT checksum
100
 
109
 
110
+### Value types:
111
+
112
+0. Time (4 bytes): The value is a unix time in seconds.
113
+1. Temperature (2 bytes): The value is a temperature value in tenths of degrees
114
+   celsius.
115
+2. Pressure (4 bytes): The value is a pressure in pascal.
116
+3. Humidity (2 bytes): The value is the relative humidity in tenths of a percent.
117
+
101
 # License
118
 # License
102
 
119
 
103
 The hardware contained in this repository is licensed under the [CERN Open Hardware Licence Version 2 - Weakly Reciprocal](cern_ohl_w_v2.txt), and the software is licensed under the [GNU General Public License v3](gpl-3.0.md).
120
 The hardware contained in this repository is licensed under the [CERN Open Hardware Licence Version 2 - Weakly Reciprocal](cern_ohl_w_v2.txt), and the software is licensed under the [GNU General Public License v3](gpl-3.0.md).

Loading…
Zrušit
Uložit