Collect-view Code Details
Introduction
This tutorial covers the main features of Collect-view Protocol (CTP) available on ContikiOS 2.7. There are many different section of CTP codes that are distributed over different folders. In this tutorial we will cover the codes and their interdependence in brief details.
You will learn
Through this tutorial you will learn about different code components of CTP. This will help you in any projects that require deep understanding of the code or need modification of some portion of the code.
Source Codes
~/contiki-2.7/core/net/rime/collect.c
~/contiki-2.7/core/net/rime/collect.h
~/contiki-2.7/core/net/rime/collect-neighbor.c
~/contiki-2.7/core/net/rime/collect-neighbor.c
~/contiki-2.7/apps/collect-view/
Description
This function opens a unicast channel in each node with the channel being (channels+1) and initialize all the parameters needed for the channel.
unicast_open(&tc->unicast_conn, channels + 1, &unicast_callbacks);
There is a function called collect_neighbor_init(void) which initializes a memory to store the information about the collect neighbors. This function also starts the neighbor discovery process along with other other initialization.
neighbor_discovery_open(&tc->neighbor_discovery_conn, channels, CLOCK_SECOND * 4, CLOCK_SECOND * 60,
- ifdef COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME
COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME,
- else
CLOCK_SECOND * 600UL,
- endif
&neighbor_discovery_callbacks);
This portion of code opens a broadcast channel to start the neighbor discovery process. The if else condition is used to choose the max_interval of running the discovery process. if
void collect_close(struct collect_conn *c);
int collect_send(struct collect_conn *c, int rexmits);
void collect_set_sink(struct collect_conn *c, int should_be_sink);
int collect_depth(struct collect_conn *c);
const rimeaddr_t *collect_parent(struct collect_conn *c);
void collect_set_keepalive(struct collect_conn *c, clock_time_t period);
void collect_print_stats(void);