Contiki-NG
Loading...
Searching...
No Matches
tsch-const.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, SICS Swedish ICT.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the Institute nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * This file is part of the Contiki operating system.
30 *
31 */
32
33/**
34* \addtogroup tsch
35* @{
36 * \file
37 * TSCH constants
38 * \author
39 * Simon Duquennoy <simonduq@sics.se>
40 */
41
42#ifndef TSCH_CONST_H_
43#define TSCH_CONST_H_
44
45/********** Includes **********/
46#include "net/packetbuf.h"
47#include "net/netstack.h"
48#include "net/mac/tsch/tsch-conf.h" /* Required for timestlot timing consts */
49
50/********** Constants **********/
51
52/* Link options */
53#define LINK_OPTION_TX 1
54#define LINK_OPTION_RX 2
55#define LINK_OPTION_SHARED 4
56#define LINK_OPTION_TIME_KEEPING 8
57
58/* Default IEEE 802.15.4e hopping sequences, obtained from https://gist.github.com/twatteyne/2e22ee3c1a802b685695 */
59/* 16 channels, sequence length 16 */
60#define TSCH_HOPPING_SEQUENCE_16_16 (uint8_t[]){ 16, 17, 23, 18, 26, 15, 25, 22, 19, 11, 12, 13, 24, 14, 20, 21 }
61/* 4 channels, sequence length 16 */
62#define TSCH_HOPPING_SEQUENCE_4_16 (uint8_t[]){ 20, 26, 25, 26, 15, 15, 25, 20, 26, 15, 26, 25, 20, 15, 20, 25 }
63/* 4 channels, sequence length 4 */
64#define TSCH_HOPPING_SEQUENCE_4_4 (uint8_t[]){ 15, 25, 26, 20 }
65/* 2 channels, sequence length 2 */
66#define TSCH_HOPPING_SEQUENCE_2_2 (uint8_t[]){ 20, 25 }
67/* 1 channel, sequence length 1 */
68#define TSCH_HOPPING_SEQUENCE_1_1 (uint8_t[]){ 20 }
69
70/* Max TSCH packet length equal to the length of the packet buffer */
71#define TSCH_PACKET_MAX_LEN PACKETBUF_SIZE
72
73/* The jitter to remove in ticks.
74 * This should be the sum of measurement errors on Tx and Rx nodes.
75 * */
76#define TSCH_TIMESYNC_MEASUREMENT_ERROR US_TO_RTIMERTICKS(32)
77
78/* The approximate number of slots per second */
79#define TSCH_SLOTS_PER_SECOND (1000000 / tsch_timing_us[tsch_ts_timeslot_length])
80
81/* Calculate packet tx/rx duration in rtimer ticks based on packet length in bytes. */
82#define TSCH_PACKET_DURATION(len) US_TO_RTIMERTICKS(RADIO_BYTE_AIR_TIME * ((len) + RADIO_PHY_OVERHEAD))
83
84/* Convert rtimer ticks to clock and vice versa */
85#define TSCH_CLOCK_TO_TICKS(c) (((c) * RTIMER_SECOND) / CLOCK_SECOND)
86#define TSCH_CLOCK_TO_SLOTS(c, timeslot_length) ((TSCH_CLOCK_TO_TICKS(c) + timeslot_length - 1) / timeslot_length)
87
88#endif /* TSCH_CONST_H_ */
89/** @} */
Include file for the Contiki low-layer network stack (NETSTACK)
Header file for the Packet buffer (packetbuf) management.
TSCH configuration.