Difference between revisions of "Collect-view Code Details"
(→Description) |
(→Description) |
||
Line 36: | Line 36: | ||
This function also starts the neighbor discovery process along with other other initialization. | This function also starts the neighbor discovery process along with other other initialization. | ||
− | + | '''#if !COLLECT_ANNOUNCEMENTS | |
+ | 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); | ||
+ | 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 */''' | ||
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 | 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 |
Revision as of 15:22, 4 November 2014
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.
#if !COLLECT_ANNOUNCEMENTS 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);
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 */
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);