|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
|
|
|
2
|
+# Protocol
|
|
|
3
|
+
|
|
|
4
|
+The base station communicates with the sensor nodes via radio. This document
|
|
|
5
|
+describes the different layers of the protocol used. The names of the layers
|
|
|
6
|
+roughly follow the OSI model, although some of the OSI layers are not required
|
|
|
7
|
+for the scenario.
|
|
|
8
|
+
|
|
|
9
|
+## Physical Layer
|
|
|
10
|
+
|
|
|
11
|
+The devices communicate via NRF24L01 radio modules.
|
|
|
12
|
+
|
|
|
13
|
+TODO:
|
|
|
14
|
+* Data rate?
|
|
|
15
|
+* Frequency?
|
|
|
16
|
+
|
|
|
17
|
+## Data Link Layer
|
|
|
18
|
+
|
|
|
19
|
+The protocol uses the NRF24L01 Enhanced ShockBurst mode for reliable
|
|
|
20
|
+transmission of packets. To ensure minimum power consumption in all nodes
|
|
|
21
|
+(including the base station), the nodes are synchronized and wake up only once
|
|
|
22
|
+per update period and transition back to sleep as quickly as possible. The
|
|
|
23
|
+following protocol is used to implement such a behavior:
|
|
|
24
|
+
|
|
|
25
|
+### Base Station
|
|
|
26
|
+
|
|
|
27
|
+The base station wakes up once per update period and executes the following:
|
|
|
28
|
+
|
|
|
29
|
+1. The base station sends one packet to each known connected sensor node and
|
|
|
30
|
+ then waits at most TODO microseconds for a reply from the node. If no reply
|
|
|
31
|
+ arrives, the node is marked as inactive, which might trigger updates to the
|
|
|
32
|
+ user interface to signal the connection state. Inactive nodes may be dropped
|
|
|
33
|
+ if new nodes connect.
|
|
|
34
|
+
|
|
|
35
|
+2. The base station may send further packets to the connected sensor nodes.
|
|
|
36
|
+
|
|
|
37
|
+3. The base station optionally sends a packet to signal that it listens for new
|
|
|
38
|
+ unknown sensor nodes and then listens for packets for TODO microseconds. If,
|
|
|
39
|
+ during this interval, a packet from a new node is received, the procedure for
|
|
|
40
|
+ a new node as described below is executed. After a new node is connected, the
|
|
|
41
|
+ base station repeats step 3 and sends another packet signaling that it
|
|
|
42
|
+ listens for connections.
|
|
|
43
|
+
|
|
|
44
|
+ The base station may always listen for new nodes,
|
|
|
45
|
+ letting the user afterwards select which connections to keep
|
|
|
46
|
+ and which to drop again, or listening for new nodes may be dependend on a
|
|
|
47
|
+ button press, after which the base station accepts new nodes for a
|
|
|
48
|
+ pre-defined time.
|
|
|
49
|
+
|
|
|
50
|
+##### Connection Setup
|
|
|
51
|
+
|
|
|
52
|
+TODO
|
|
|
53
|
+
|
|
|
54
|
+### Sensor Node
|
|
|
55
|
+
|
|
|
56
|
+As long as a sensor node is not synchronized to a base station, it executes the
|
|
|
57
|
+following steps:
|
|
|
58
|
+
|
|
|
59
|
+1. The sensor node continuously listens for packets.
|
|
|
60
|
+
|
|
|
61
|
+2. If a packet is received which indicates that a base station listens for new
|
|
|
62
|
+ connections, the sensor node waits for a random time between TODO and TODO
|
|
|
63
|
+ microseconds and then sends a packet back to initiate connection setup. The
|
|
|
64
|
+ node proceeds as described below.
|
|
|
65
|
+
|
|
|
66
|
+3. If the node has previously stored connection information and receives a
|
|
|
67
|
+ packet from the corresponding base station directed at the node, the node
|
|
|
68
|
+ uses the arrival time of the packet to synchronize with the base station and
|
|
|
69
|
+ then responds to the packet, proceeding with the protocol for synchronized
|
|
|
70
|
+ nodes below.
|
|
|
71
|
+
|
|
|
72
|
+4. The node may implement duty cycling to reduce power consumption during long
|
|
|
73
|
+ periods without synchronization to a base station: Between phases of
|
|
|
74
|
+ listening for packets, the node may sleep for some time. Each period of
|
|
|
75
|
+ listening must last longer than an update period to ensure that no available
|
|
|
76
|
+ base stations are missed. In setups where base stations only listen for new
|
|
|
77
|
+ devices when activated by the user, the sleeping period must not be longer
|
|
|
78
|
+ than the duration during which the base station listens for new nodes.
|
|
|
79
|
+
|
|
|
80
|
+Once a sensor node is synchronized to a base station, it repeatedly executes the
|
|
|
81
|
+following steps:
|
|
|
82
|
+
|
|
|
83
|
+1. The node takes the time of the first packet received during the last update
|
|
|
84
|
+ period and calculates the expected time of the next packet by adding the
|
|
|
85
|
+ update period to the time. The node then subtracts 1% of an update period to
|
|
|
86
|
+ compensate any clock skew. The node then sleeps until the calculated time and
|
|
|
87
|
+ starts to listen for packets for 5% of the update period. The arrival time of
|
|
|
88
|
+ the first packet directed at the node received during this time is taken as
|
|
|
89
|
+ the basis for the next wakeup time calculation.
|
|
|
90
|
+
|
|
|
91
|
+2. If the node receives a packet directed at the node, it processes the packet.
|
|
|
92
|
+ If no packet was received for TODO microseconds, the node continues with step
|
|
|
93
|
+ 1 to go to sleep again.
|
|
|
94
|
+
|
|
|
95
|
+3. If no packet directed at the node was received during the time span, the node
|
|
|
96
|
+ assumes that it lost synchronization to the base station and starts again
|
|
|
97
|
+ with the steps above for this situation.
|
|
|
98
|
+
|
|
|
99
|
+##### Connection Setup
|
|
|
100
|
+
|
|
|
101
|
+TODO
|
|
|
102
|
+
|
|
|
103
|
+## Presentation Layer
|
|
|
104
|
+
|
|
|
105
|
+TODO:
|
|
|
106
|
+* Encryption?
|
|
|
107
|
+
|
|
|
108
|
+
|