瀏覽代碼

More protocol description, enough to implement sensor reports.

Mathias Gottschlag 5 年之前
父節點
當前提交
1dde4df49d
共有 1 個檔案被更改,包括 24 行新增7 行删除
  1. 24
    7
      README.md

+ 24
- 7
README.md 查看文件

@@ -61,21 +61,21 @@ The packet sent from the device to the base station to request a salt consists o
61 61
 a single byte with the sender ID and is recognized by the base station by its
62 62
 length.
63 63
 
64
+### Packet Format
65
+
64 66
 All encrypted packets follow the same scheme, with everything following after the
65 67
 salt being encrypted using a per-device XXTEA key hardcoded on the device and
66 68
 known to the base station. The packet fields are as follows, with multi-byte
67 69
 fields being encoded as little-endian:
68 70
 
69 71
 1. Device ID (1 byte)
70
-2. Salt (8 bytes)
72
+2. Remainder of salt (7 bytes)
71 73
 
72 74
    The most significant bit of the salt value is 0 for packets from the device
73 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 80
 3. Packet type and element count (1 byte)
81 81
 
@@ -92,12 +92,29 @@ in the packet.
92 92
       count signals the number of different values requested.
93 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 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 118
 # License
102 119
 
103 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…
取消
儲存