Skip to content

Commit

Permalink
Force call of subscriber_callback when the ETX of a link is estimated…
Browse files Browse the repository at this point in the history
… for the first time. Otherwise, it was not called in case of NO_ACK.
  • Loading branch information
simonduq committed Oct 5, 2012
1 parent 621790f commit dbd4f1c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/net/neighbor-info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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);
}
}
Expand Down

0 comments on commit dbd4f1c

Please sign in to comment.