36
36
#include "6LoWPAN/ws/ws_mpx_header.h"
37
37
#include "6LoWPAN/ws/ws_neighbor_class.h"
38
38
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
39
+ #include "Service_Libs/etx/etx.h"
39
40
40
41
#ifdef HAVE_WS
41
42
@@ -73,8 +74,11 @@ typedef struct {
73
74
} llc_ie_params_t ;
74
75
75
76
typedef struct {
77
+ uint8_t dst_address [8 ]; /**< Destination address */
76
78
unsigned messsage_type :3 ; /**< Frame type to UTT */
77
79
unsigned mpx_id :5 ; /**< MPX sequence */
80
+ bool ack_requested :1 ; /**< ACK requested */
81
+ unsigned dst_address_type :2 ; /**< Destination address type */
78
82
uint8_t msg_handle ; /**< LLC genetaed unique MAC handle */
79
83
uint8_t mpx_user_handle ; /**< This MPX user defined handle */
80
84
ns_ie_iovec_t ie_vector_list [3 ]; /**< IE vectors: 1 for Header's, 1 for Payload and for MPX payload */
@@ -358,6 +362,8 @@ static void ws_llc_mac_confirm_cb(const mac_api_t* api, const mcps_data_conf_t *
358
362
return ;
359
363
}
360
364
365
+ protocol_interface_info_entry_t * interface = base -> interface_ptr ;
366
+
361
367
llc_message_t * message = llc_message_discover_by_mac_handle (data -> msduHandle , & base -> llc_message_list );
362
368
if (!message ) {
363
369
return ;
@@ -378,6 +384,34 @@ static void ws_llc_mac_confirm_cb(const mac_api_t* api, const mcps_data_conf_t *
378
384
mpx_user_id = MPX_KEY_MANAGEMENT_ENC_USER_ID ;
379
385
}
380
386
387
+ //ETX update
388
+ if (message -> ack_requested && messsage_type == WS_FT_DATA ) {
389
+
390
+ ws_neighbor_class_entry_t * ws_neighbor = NULL ;
391
+ mac_neighbor_table_entry_t * neighbor = NULL ;
392
+ bool success = false;
393
+
394
+ switch (data -> status ) {
395
+ case MLME_SUCCESS :
396
+ case MLME_TX_NO_ACK :
397
+ case MLME_NO_DATA :
398
+ if (data -> status == MLME_SUCCESS ) {
399
+ success = true;
400
+ }
401
+ neighbor = mac_neighbor_table_address_discover (interface -> mac_parameters -> mac_neighbor_table , message -> dst_address , message -> dst_address_type );
402
+ if (neighbor ) {
403
+ ws_neighbor = ws_neighbor_class_entry_get (& interface -> ws_info -> neighbor_storage , neighbor -> index );
404
+ }
405
+ if (ws_neighbor ) {
406
+ etx_transm_attempts_update (interface -> id , 1 + data -> tx_retries , success , neighbor -> index );
407
+ //TODO discover RSL from Enchanced ACK Header IE elements
408
+ }
409
+ break ;
410
+ default :
411
+ break ;
412
+ }
413
+ }
414
+
381
415
user_cb = ws_llc_mpx_user_discover (& base -> mpx_data_base , mpx_user_id );
382
416
if (user_cb && user_cb -> data_confirm ) {
383
417
//Call MPX registered call back
@@ -430,6 +464,7 @@ static void ws_llc_mac_indication_cb(const mac_api_t* api, const mcps_data_ind_t
430
464
if (ws_utt .message_type == WS_FT_DATA && data -> DstAddrMode && addr_check_broadcast (data -> DstAddr , data -> DstAddrMode )) {
431
465
tr_debug ("Refresh neigh index %u" , neighbor -> index );
432
466
mac_neighbor_table_neighbor_refresh (interface -> mac_parameters -> mac_neighbor_table , neighbor , neighbor -> link_lifetime );
467
+ etx_lqi_dbm_update (interface -> id , data -> mpduLinkQuality , data -> signal_dbm , neighbor -> index );
433
468
}
434
469
}
435
470
@@ -547,6 +582,11 @@ static void ws_llc_mpx_data_request(const mpx_api_t *api, const struct mcps_data
547
582
}
548
583
mcps_data_req_t data_req ;
549
584
message -> mpx_user_handle = data -> msduHandle ;
585
+ message -> ack_requested = data -> TxAckReq ;
586
+ if (data -> TxAckReq ) {
587
+ message -> dst_address_type = data -> DstAddrMode ;
588
+ memcpy (message -> dst_address , data -> DstAddr , 8 );
589
+ }
550
590
data_req = * data ;
551
591
data_req .msdu = NULL ;
552
592
data_req .msduLength = 0 ;
0 commit comments