Skip to content

Commit 2a5ae7c

Browse files
author
Mika Tervonen
committed
Fixed eapol target selection sort algorithm
Sorting did not check correctly the RSSI threshold values Pan cost did not check correctly and assumed better as equal
1 parent 9b283cb commit 2a5ae7c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ static void ws_bootstrap_pan_advertisement_analyse_active(struct protocol_interf
892892
static parent_info_t *ws_bootstrap_candidate_parent_get_best(protocol_interface_info_entry_t *cur)
893893
{
894894
ns_list_foreach_safe(parent_info_t, entry, &cur->ws_info->parent_list_reserved) {
895-
tr_info("candidate list a:%s panid:%x rssi:%d age:%"PRIu32, trace_array(entry->addr, 8), entry->pan_id, entry->signal_dbm, protocol_core_monotonic_time - entry->age);
895+
tr_info("candidate list a:%s panid:%x cost:%d size:%d rssi:%d age:%"PRIu32, trace_array(entry->addr, 8), entry->pan_id, entry->pan_information.routing_cost, entry->pan_information.pan_size, entry->signal_dbm, protocol_core_monotonic_time - entry->age);
896896
}
897897

898898
return ns_list_get_first(&cur->ws_info->parent_list_reserved);
@@ -988,12 +988,19 @@ static bool ws_bootstrap_candidate_parent_compare(parent_info_t *p1, parent_info
988988
// above threshold is always better than not.
989989
return true;
990990
}
991+
if (ws_neighbor_class_rsl_from_dbm_calculate(p2->signal_dbm) < (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS) &&
992+
ws_neighbor_class_rsl_from_dbm_calculate(p1->signal_dbm) > (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS)) {
993+
// P2 is less than threshold and P1 is larger so P1 is always better.
994+
return false;
995+
}
991996

992997
// Select the lowest PAN cost
993998
uint16_t p1_pan_cost = (p1->pan_information.routing_cost / PRC_WEIGHT_FACTOR) + (p1->pan_information.pan_size / PS_WEIGHT_FACTOR);
994999
uint16_t p2_pan_cost = (p2->pan_information.routing_cost / PRC_WEIGHT_FACTOR) + (p2->pan_information.pan_size / PS_WEIGHT_FACTOR);
9951000
if (p1_pan_cost > p2_pan_cost) {
9961001
return true;
1002+
} else if (p1_pan_cost < p2_pan_cost) {
1003+
return false;
9971004
}
9981005

9991006
// If pan cost is the same then we select the one we hear highest

0 commit comments

Comments
 (0)