@@ -1387,6 +1387,12 @@ static void ws_bootstrap_candidate_parent_store(parent_info_t *parent, const str
1387
1387
parent -> signal_dbm = data -> signal_dbm ;
1388
1388
memcpy (parent -> addr , data -> SrcAddr , 8 );
1389
1389
1390
+ if (ws_neighbor_class_rsl_from_dbm_calculate (parent -> signal_dbm ) > (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS )) {
1391
+ parent -> link_acceptable = true;
1392
+ }
1393
+ if (ws_neighbor_class_rsl_from_dbm_calculate (parent -> signal_dbm ) < (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD - CAND_PARENT_HYSTERISIS )) {
1394
+ parent -> link_acceptable = false;
1395
+ }
1390
1396
parent -> age = protocol_core_monotonic_time ;
1391
1397
}
1392
1398
@@ -1421,6 +1427,7 @@ static parent_info_t *ws_bootstrap_candidate_parent_allocate(protocol_interface_
1421
1427
}
1422
1428
if (entry ) {
1423
1429
entry -> tx_fail = 0 ;
1430
+ entry -> link_acceptable = false;
1424
1431
}
1425
1432
return entry ;
1426
1433
}
@@ -1442,13 +1449,11 @@ static void ws_bootstrap_candidate_parent_mark_failure(protocol_interface_info_e
1442
1449
{
1443
1450
parent_info_t * entry = ws_bootstrap_candidate_parent_get (cur , addr , false);
1444
1451
if (entry ) {
1445
- ns_list_remove (& cur -> ws_info -> parent_list_reserved , entry );
1446
1452
if (entry -> tx_fail >= 2 ) {
1453
+ ns_list_remove (& cur -> ws_info -> parent_list_reserved , entry );
1447
1454
ns_list_add_to_end (& cur -> ws_info -> parent_list_free , entry );
1448
1455
} else {
1449
1456
entry -> tx_fail ++ ;
1450
- //New last
1451
- ns_list_add_to_end (& cur -> ws_info -> parent_list_reserved , entry );
1452
1457
ws_bootstrap_candidate_parent_sort (cur , entry );
1453
1458
}
1454
1459
@@ -1466,14 +1471,12 @@ static bool ws_bootstrap_candidate_parent_compare(parent_info_t *p1, parent_info
1466
1471
return false;
1467
1472
}
1468
1473
1469
- if (ws_neighbor_class_rsl_from_dbm_calculate (p1 -> signal_dbm ) < (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS ) &&
1470
- ws_neighbor_class_rsl_from_dbm_calculate (p2 -> signal_dbm ) > (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS )) {
1471
- // above threshold is always better than not.
1474
+ if (p1 -> link_acceptable && !p2 -> link_acceptable ) {
1475
+ // Link acceptable is always better than not
1472
1476
return true;
1473
1477
}
1474
- if (ws_neighbor_class_rsl_from_dbm_calculate (p2 -> signal_dbm ) < (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS ) &&
1475
- ws_neighbor_class_rsl_from_dbm_calculate (p1 -> signal_dbm ) > (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS )) {
1476
- // P2 is less than threshold and P1 is larger so P1 is always better.
1478
+ if (!p1 -> link_acceptable && p2 -> link_acceptable ) {
1479
+ // Link acceptable is always better than not
1477
1480
return false;
1478
1481
}
1479
1482
@@ -1498,6 +1501,7 @@ static void ws_bootstrap_candidate_list_clean(struct protocol_interface_info_ent
1498
1501
int pan_count = 0 ;
1499
1502
1500
1503
ns_list_foreach_safe (parent_info_t , entry , & cur -> ws_info -> parent_list_reserved ) {
1504
+
1501
1505
if ((current_time - entry -> age ) > WS_PARENT_LIST_MAX_AGE ) {
1502
1506
ns_list_remove (& cur -> ws_info -> parent_list_reserved , entry );
1503
1507
ns_list_add_to_end (& cur -> ws_info -> parent_list_free , entry );
@@ -1534,6 +1538,9 @@ static void ws_bootstrap_candidate_parent_sort(struct protocol_interface_info_en
1534
1538
return ;
1535
1539
}
1536
1540
}
1541
+ // This is the last entry
1542
+ ns_list_remove (& cur -> ws_info -> parent_list_reserved , new_entry );
1543
+ ns_list_add_to_end (& cur -> ws_info -> parent_list_reserved , new_entry );
1537
1544
}
1538
1545
1539
1546
static void ws_bootstrap_pan_information_store (struct protocol_interface_info_entry * cur , const struct mcps_data_ind_s * data , ws_utt_ie_t * ws_utt , ws_us_ie_t * ws_us , ws_pan_information_t * pan_information )
@@ -1560,6 +1567,14 @@ static void ws_bootstrap_pan_information_store(struct protocol_interface_info_en
1560
1567
}
1561
1568
// Safe the information
1562
1569
ws_bootstrap_candidate_parent_store (new_entry , data , ws_utt , ws_us , pan_information );
1570
+ if (!new_entry -> link_acceptable ) {
1571
+ // This entry is either poor quality or changed to poor quality link so we will remove this
1572
+ // Todo in future possibility to try poor link parents if we have not found any good link parents
1573
+ tr_info ("neighbour not accepted: addr:%s panid:%x rsl:%d device_min_sens: %d" , trace_array (new_entry -> addr , 8 ), new_entry -> pan_id , ws_neighbor_class_rsl_from_dbm_calculate (new_entry -> signal_dbm ), DEVICE_MIN_SENS );
1574
+ ns_list_remove (& cur -> ws_info -> parent_list_reserved , new_entry );
1575
+ ns_list_add_to_end (& cur -> ws_info -> parent_list_free , new_entry );
1576
+ return ;
1577
+ }
1563
1578
// set to the correct place in list
1564
1579
ws_bootstrap_candidate_parent_sort (cur , new_entry );
1565
1580
0 commit comments