@@ -394,8 +394,7 @@ uint16_t etx_local_etx_read(int8_t interface_id, uint8_t attribute_index)
394394
395395 if (etx_info .cache_sample_requested && entry -> etx_samples < etx_info .init_etx_sample_count ) {
396396 if (!entry -> etx_samples ) {
397- //Return configured MAX value
398- return etx_info .max_etx >> 4 ;
397+ return 0 ;
399398 }
400399 }
401400
@@ -455,7 +454,12 @@ uint16_t etx_lqi_dbm_update(int8_t interface_id, uint8_t lqi, int8_t dbm, uint8_
455454 if (!entry -> etx ) {
456455 etx = etx_dbm_lqi_calc (lqi , dbm );
457456 entry -> etx = etx ;
457+ entry -> stored_diff_etx = etx ;
458458 entry -> tmp_etx = true;
459+ if (etx_info .callback_ptr ) {
460+ etx_info .callback_ptr (etx_info .interface_id , 0 , entry -> etx >> 4 ,
461+ attribute_index );
462+ }
459463 }
460464 // If local ETX has been calculated without remote incoming IDR and
461465 // remote incoming IDR is available update it by remote incoming IDR value
@@ -470,11 +474,7 @@ uint16_t etx_lqi_dbm_update(int8_t interface_id, uint8_t lqi, int8_t dbm, uint8_
470474 entry -> etx = etx >> 12 ;
471475
472476 local_incoming_idr >>= 4 ;
473- }
474-
475- // If local ETX has been calculated indicates new neighbor
476- if (etx ) {
477- etx_neighbor_add (interface_id , attribute_index );
477+ etx_value_change_callback_needed_check (entry -> etx , & (entry -> stored_diff_etx ), entry -> accumulated_failures , attribute_index );
478478 }
479479 }
480480
@@ -808,35 +808,6 @@ void etx_neighbor_remove(int8_t interface_id, uint8_t attribute_index)
808808 }
809809}
810810
811- /**
812- * \brief A function to add ETX neighbor
813- *
814- * Notifies ETX module that neighbor has been added. Calls ETX value change callback
815- * if that is set.
816- *
817- * \param mac64_addr_ptr long MAC address
818- *
819- */
820- void etx_neighbor_add (int8_t interface_id , uint8_t attribute_index )
821- {
822-
823- //tr_debug("Add attribute %u", attribute_index);
824- uint16_t stored_diff_etx ;
825- etx_storage_t * entry = etx_storage_entry_get (interface_id , attribute_index );
826- if (entry && etx_info .callback_ptr ) {
827- // Gets table entry
828-
829- if (entry -> etx ) {
830- stored_diff_etx = entry -> stored_diff_etx ;
831- if (!stored_diff_etx ) {
832- stored_diff_etx = entry -> etx ;
833- }
834- etx_info .callback_ptr (etx_info .interface_id , stored_diff_etx >> 4 , entry -> etx >> 4 ,
835- attribute_index );
836- }
837- }
838- }
839-
840811void etx_cache_timer (int8_t interface_id , uint16_t seconds_update )
841812{
842813 if (!etx_info .cache_sample_requested ) {
0 commit comments