@@ -202,40 +202,63 @@ class LoRaPHY : private mbed::NonCopyable<LoRaPHY> {
202
202
203
203
/* * Computing Receive Windows
204
204
*
205
- * For more details please consult the following document, chapter 3.1.2.
206
- * http://www.semtech.com/images/datasheet/SX1272_settings_for_LoRaWAN_v2.0.pdf
207
- * or
208
- * http://www.semtech.com/images/datasheet/SX1276_settings_for_LoRaWAN_v2.0.pdf
209
- *
210
- * Downlink start: T = Tx + 1s (+/- 20 us)
211
- * |
212
- * TRxEarly | TRxLate
213
- * | | |
214
- * | | +---+---+---+---+---+---+---+---+
215
- * | | | Latest Rx window |
216
- * | | +---+---+---+---+---+---+---+---+
217
- * | | |
205
+ * The algorithm tries to calculate the length of receive windows (i.e.,
206
+ * the minimum time it should remain to acquire a lock on the Preamble
207
+ * for synchronization) and the error offset which compensates for the system
208
+ * timing errors. Basic idea behind the algorithm is to optimize for the
209
+ * reception of last 'min_rx_symbols' symbols out of transmitted Premable
210
+ * symbols. The algorithm compensates for the clock drifts, tick granularity
211
+ * and system wake up time (from sleep state) by opening the window early for
212
+ * the lower SFs. For higher SFs, the symbol time is large enough that we can
213
+ * afford to open late (hence the positive offset).
214
+ * The table below shows the calculated values for SF7 to SF12 with 125 kHz
215
+ * bandwidth.
216
+ *
217
+ * +----+-----+----------+---------+-------------------------+----------------------+-------------------------+
218
+ * | SF | BW (kHz) | rx_error (ms) | wake_up (ms) | min_rx_symbols | window_timeout(symb) | window_offset(ms) |
219
+ * +----+-----+----------+---------+-------------------------+----------------------+-------------------------+
220
+ * | 7 | 125 | 5 | 5 | 5 | 18 | -7 |
221
+ * | 8 | 125 | 5 | 5 | 5 | 10 | -4 |
222
+ * | 9 | 125 | 5 | 5 | 5 | 6 | 2 |
223
+ * | 10 | 125 | 5 | 5 | 5 | 6 | 14 |
224
+ * | 11 | 125 | 5 | 5 | 5 | 6 | 39 |
225
+ * | 12 | 125 | 5 | 5 | 5 | 6 | 88 |
226
+ * +----+-----+----------+---------+-------------------------+----------------------+-------------------------+
227
+ *
228
+ * For example for SF7, the receive window will open at downlink start time
229
+ * plus the offset calculated and will remain open for the length window_timeout.
230
+ *
231
+ * Symbol time = 1.024 ms
232
+ * Downlink start: T = Tx + 1s (+/- 20 us)
233
+ * |
234
+ * |
235
+ * |
236
+ * |
237
+ * |
238
+ * +---+---+---+---+---+---+---+---+
239
+ * | 8 Preamble Symbols |
240
+ * +---+---+---+---+---+---+---+---+
241
+ * | RX Window start time = T +/- Offset
242
+ * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
243
+ * | | | | | | | | | | | | | | | | | | |
244
+ * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
245
+ *
246
+ * Similarly for SF12:
247
+ *
248
+ * Symbol time = 32.768 ms
249
+ * Downlink start: T = Tx + 1s (+/- 20 us)
250
+ * |
251
+ * |
252
+ * |
253
+ * |
254
+ * |
218
255
* +---+---+---+---+---+---+---+---+
219
- * | Earliest Rx window |
256
+ * | 8 Preamble Symbols |
220
257
* +---+---+---+---+---+---+---+---+
221
- * |
222
- * +---+---+---+---+---+---+---+---+
223
- *Downlink preamble 8 symbols | | | | | | | | |
224
- * +---+---+---+---+---+---+---+---+
225
- *
226
- * Worst case Rx window timings
227
- *
228
- * TRxLate = DEFAULT_MIN_RX_SYMBOLS * tSymbol - RADIO_WAKEUP_TIME
229
- * TRxEarly = 8 - DEFAULT_MIN_RX_SYMBOLS * tSymbol - RxWindowTimeout - RADIO_WAKEUP_TIME
230
- *
231
- * TRxLate - TRxEarly = 2 * DEFAULT_SYSTEM_MAX_RX_ERROR
232
- *
233
- * RxOffset = ( TRxLate + TRxEarly ) / 2
234
- *
235
- * RxWindowTimeout = ( 2 * DEFAULT_MIN_RX_SYMBOLS - 8 ) * tSymbol + 2 * DEFAULT_SYSTEM_MAX_RX_ERROR
236
- * RxOffset = 4 * tSymbol - RxWindowTimeout / 2 - RADIO_WAKE_UP_TIME
237
- *
238
- * The minimum value of RxWindowTimeout must be 5 symbols which implies that the system always tolerates at least an error of 1.5 * tSymbol.
258
+ * | RX Window start time = T +/- Offset
259
+ * +---+---+---+---+---+---+
260
+ * | | | | | | |
261
+ * +---+---+---+---+---+---+
239
262
*/
240
263
/* !
241
264
* Computes the RX window timeout and offset.
0 commit comments