Force call of subscriber_callback when the ETX of a link is estimated for the first time. Otherwise, it was not called in case of NO_ACK.

This commit is contained in:
simonduq 2012-10-05 17:24:23 +02:00
parent 621790f156
commit dbd4f1c579

View file

@ -61,12 +61,14 @@ update_metric(const rimeaddr_t *dest, int packet_metric)
link_metric_t *metricp;
link_metric_t recorded_metric, new_metric;
unsigned long time;
int first_update = 0;
metricp = (link_metric_t *)neighbor_attr_get_data(&attr_etx, dest);
packet_metric = NEIGHBOR_INFO_ETX2FIX(packet_metric);
if(metricp == NULL || *metricp == 0) {
recorded_metric = NEIGHBOR_INFO_ETX2FIX(ETX_LIMIT);
new_metric = packet_metric;
first_update = 1;
} else {
recorded_metric = *metricp;
/* Update the EWMA of the ETX for the neighbor. */
@ -84,7 +86,7 @@ update_metric(const rimeaddr_t *dest, int packet_metric)
time = clock_seconds();
neighbor_attr_set_data(&attr_etx, dest, &new_metric);
neighbor_attr_set_data(&attr_timestamp, dest, &time);
if(new_metric != recorded_metric && subscriber_callback != NULL) {
if((first_update || new_metric != recorded_metric) && subscriber_callback != NULL) {
subscriber_callback(dest, 1, new_metric);
}
}