예제 #1
0
/*---------------------------------------------------------------------------*/
struct collect_neighbor *
collect_neighbor_list_best(struct collect_neighbor_list *neighbors_list)
{
    int found;
    struct collect_neighbor *n, *best;
    uint16_t rtmetric;

    rtmetric = RTMETRIC_MAX;
    best = NULL;
    found = 0;

    /*  PRINTF("%d: ", node_id);*/
    PRINTF("collect_neighbor_best: ");

    /* Find the neighbor with the lowest rtmetric + linkt estimate. */
    for(n = list_head(neighbors_list->list); n != NULL; n = list_item_next(n))
    {
        PRINTF("%d.%d %d+%d=%d, ",
               n->addr.u8[0], n->addr.u8[1],
               n->rtmetric, collect_neighbor_link_estimate(n),
               collect_neighbor_rtmetric(n));
        if(collect_neighbor_rtmetric_link_estimate(n) < rtmetric)
        {
            rtmetric = collect_neighbor_rtmetric_link_estimate(n);
            best = n;
        }
    }
    PRINTF("\n");

    return best;
}
예제 #2
0
// Collect data function.  Identical to the collect-view-data process, but a function.
void collect_data(struct shell_command *c) {
	struct collect_view_data_msg msg;
	struct collect_neighbor *n;
	uint16_t parent_etx;
	uint16_t num_neighbors;
	uint16_t beacon_interval;

	n = collect_neighbor_list_find(&shell_collect_conn.neighbor_list,
		                         &shell_collect_conn.parent);
	if(n != NULL) {
		parent_etx = collect_neighbor_link_estimate(n);
	} else {
		parent_etx = 0;
	}
	num_neighbors = collect_neighbor_list_num(&shell_collect_conn.neighbor_list);
	beacon_interval = broadcast_announcement_beacon_interval() / CLOCK_SECOND;

	collect_view_construct_message(&msg, &shell_collect_conn.parent,
		                         parent_etx, shell_collect_conn.rtmetric,
		                         num_neighbors, beacon_interval);
	shell_output(c, &msg, sizeof(msg), "", 0);
}