46#define LOG_MODULE "TSCH"
47#define LOG_LEVEL LOG_LEVEL_MAC
50#if BUILD_WITH_ORCHESTRA
52#define TSCH_MAX_ROOT_NODES 5
53#define ROOT_ALIVE_TIME_SECONDS (2 * 60 * 60)
54#define PERIODIC_PROCESSING_TICKS (60 * CLOCK_SECOND)
58struct tsch_root_info {
59 struct tsch_root_info *next;
61 clock_time_t last_seen_seconds;
64MEMB(tsch_root_memb,
struct tsch_root_info, TSCH_MAX_ROOT_NODES);
66static struct ctimer periodic_timer;
71 struct tsch_root_info *root;
73 LOG_INFO(
"add root address ");
74 LOG_INFO_LLADDR(new_root_address);
88 if((root =
memb_alloc(&tsch_root_memb)) == NULL) {
89 LOG_ERR(
"failed to add root ");
90 LOG_ERR_LLADDR(new_root_address);
98 TSCH_CALLBACK_ROOT_NODE_UPDATED(&root->address, 1);
114 struct tsch_root_info *root;
115 if(address == NULL) {
120 while(root != NULL) {
132 struct tsch_root_info *root;
133 struct tsch_root_info *next;
138 while(root != NULL) {
140 if((int32_t)(root->last_seen_seconds + ROOT_ALIVE_TIME_SECONDS - now) < 0) {
142 LOG_INFO(
"remove root address ");
143 LOG_INFO_LLADDR(&root->address);
145 TSCH_CALLBACK_ROOT_NODE_UPDATED(&root->address, 0);
154 ctimer_set(&periodic_timer, PERIODIC_PROCESSING_TICKS, periodic, NULL);
162 ctimer_set(&periodic_timer, PERIODIC_PROCESSING_TICKS, periodic, NULL);
unsigned long clock_seconds(void)
Get the current value of the platform seconds.
static void ctimer_set(struct ctimer *c, clock_time_t t, void(*f)(void *), void *ptr)
Set a callback timer.
linkaddr_t linkaddr_node_addr
The link-layer address of the node.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a link-layer address.
bool linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2)
Compare two link-layer addresses.
static void list_init(list_t list)
Initialize a list.
#define LIST(name)
Declare a linked list.
void list_add(list_t list, void *item)
Add an item at the end of a list.
void list_remove(list_t list, const void *item)
Remove a specific element from a list.
static void * list_head(const_list_t list)
Get a pointer to the first element of a list.
int memb_free(struct memb *m, void *ptr)
Deallocate a memory block from a memory block previously declared with MEMB().
void * memb_alloc(struct memb *m)
Allocate a memory block from a block of memory declared with MEMB().
void memb_init(struct memb *m)
Initialize a memory block that was declared with MEMB().
#define MEMB(name, structure, num)
Declare a memory block.
Linked list manipulation routines.
Header file for the logging system.
Memory block allocation routines.
int tsch_roots_is_root(const linkaddr_t *address)
Tests whether a given address belongs to a single-hop reachable root node in this network.
void tsch_roots_set_self_to_root(uint8_t is_root)
Set the root status of the local node.
void tsch_roots_add_address(const linkaddr_t *root_address)
Add address as a potential RPL root that is a single-hop neighbor in the TSCH network.
void tsch_roots_init(void)
Initialize the list of RPL network roots.
Main API declarations for TSCH.