Collect-view Code Details

From Contiki
Jump to: navigation, search

Back to Contiki Tutorials


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







             void collect_open(struct collect_conn *c, uint16_t channels, uint8_t is_router,
                                                                const struct collect_callbacks *callbacks);

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.

               #if !COLLECT_ANNOUNCEMENTS
                   neighbor_discovery_start(&tc->neighbor_discovery_conn, tc->rtmetric);
               #else /* !COLLECT_ANNOUNCEMENTS */
                   announcement_register(&tc->announcement, channels,received_announcement);
                   #if ! COLLECT_CONF_WITH_LISTEN
                         if(tc->is_router) {
                             announcement_set_value(&tc->announcement, RTMETRIC_MAX);
                   #endif /* COLLECT_CONF_WITH_LISTEN */
               #endif /* !COLLECT_ANNOUNCEMENTS */

The portion of code implies that if COLLECT_ANNOUNCEMENTS is not defined, the node should start the the neighbor discovery process, otherwise the node should prepare for collecting announcements from its neighbors. The details of the functions neighbor_discovery_open(...), neighbor_discovery_start(...) are discussed separately.

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);