@@ -2147,10 +2147,17 @@ static bool ws_rpl_new_parent_callback(uint8_t *ll_parent_address, void *handle,
21472147 }
21482148
21492149 uint8_t replacing [16 ];
2150- uint8_t mac64 [8 ];
2150+ uint8_t mac64 [10 ];
21512151 bool replace_ok = false;
21522152 bool create_ok = false;
21532153 llc_neighbour_req_t neigh_buffer ;
2154+
2155+ //Discover neigh ready here for possible ETX validate
2156+ memcpy (mac64 , ll_parent_address + 8 , 8 );
2157+ mac64 [0 ] ^= 2 ;
2158+
2159+ ws_bootstrap_neighbor_info_request (cur , mac64 , & neigh_buffer , false);
2160+
21542161 if (rpl_control_candidate_list_size (cur , instance ) < cur -> ws_info -> rpl_parent_candidate_max ) {
21552162 //Not reach max value yet accept then all go to create neigh table
21562163 goto neigh_create ;
@@ -2161,20 +2168,22 @@ static bool ws_rpl_new_parent_callback(uint8_t *ll_parent_address, void *handle,
21612168 return false;
21622169 }
21632170
2164- // if not yet probed, return false
2165- memcpy (mac64 , replacing + 8 , 8 );
2166- mac64 [0 ] ^= 2 ;
2171+ // +2 Is for PAN ID space
2172+ memcpy (mac64 + 2 , replacing + 8 , 8 );
2173+ mac64 [2 ] ^= 2 ;
21672174
2168- if (ws_bootstrap_neighbor_info_request (cur , mac64 , & neigh_buffer , false)) {
2169- //Verify that we have proped min 1 time
2170- etx_storage_t * etx_entry = etx_storage_entry_get (cur -> id , neigh_buffer .neighbor -> index );
2171- if (etx_entry && etx_entry -> etx_samples == 0 ) {
2172- return false;
2173- }
2175+ if (ws_etx_read (cur , ADDR_802_15_4_LONG , mac64 ) == 0xffff ) {
2176+ //Not proped yet because ETX is 0xffff
2177+ return false;
2178+ }
2179+
2180+ uint16_t etx = 0 ;
2181+ if (neigh_buffer .neighbor ) {
2182+ etx = etx_local_etx_read (cur -> id , neigh_buffer .neighbor -> index );
21742183 }
21752184
21762185 // Accept now only better one's when max candidates slected and max candidate list size is reached
2177- if (!rpl_possible_better_candidate (cur , instance , replacing , candidate_rank )) {
2186+ if (!rpl_possible_better_candidate (cur , instance , replacing , candidate_rank , etx )) {
21782187 return false;
21792188 }
21802189 //TODO if replacing has poor ETX, put it in blacklist as "poor ETX" to prevent reselection
@@ -2183,14 +2192,16 @@ static bool ws_rpl_new_parent_callback(uint8_t *ll_parent_address, void *handle,
21832192
21842193neigh_create :
21852194
2186- memcpy ( mac64 , ll_parent_address + 8 , 8 );
2187- mac64 [ 0 ] ^= 2 ;
2188- if ( ws_bootstrap_neighbor_info_request ( cur , mac64 , & neigh_buffer , false)) {
2195+
2196+ if ( neigh_buffer . neighbor ) {
2197+ //Use Already discovered entry
21892198 create_ok = true;
21902199 goto neigh_create_ok ;
21912200 }
21922201
2193- //Discover Multicast temporary entry
2202+ //Discover Multicast temporary entry for create neighbour table entry for new candidate
2203+ memcpy (mac64 , ll_parent_address + 8 , 8 );
2204+ mac64 [0 ] ^= 2 ;
21942205 ws_neighbor_temp_class_t * entry = ws_llc_get_multicast_temp_entry (cur , mac64 );
21952206 if (!entry ) {
21962207 return false;
0 commit comments