36
36
#include "MAC/IEEE802_15_4/mac_mcps_sap.h"
37
37
#include "MAC/IEEE802_15_4/mac_cca_threshold.h"
38
38
#include "MAC/rf_driver_storage.h"
39
+ #include "ns_trace.h"
40
+
41
+ #define TRACE_GROUP "mPDs"
39
42
40
43
/* Define TX Timeot Period */
41
44
// Hardcoded to 1200ms. Should be changed dynamic: (FHSS) channel retries needs longer timeout
@@ -373,6 +376,9 @@ static void mac_sap_cca_fail_cb(protocol_interface_rf_mac_setup_s *rf_ptr, uint
373
376
374
377
static void mac_sap_no_ack_cb (protocol_interface_rf_mac_setup_s * rf_ptr )
375
378
{
379
+ #ifdef TIMING_TOOL_TRACES
380
+ tr_info ("%u no_ack" , mac_mcps_sap_get_phy_timestamp (rf_ptr ));
381
+ #endif
376
382
rf_ptr -> macRfRadioTxActive = false;
377
383
if (rf_ptr -> mac_tx_retry < rf_ptr -> mac_mlme_retry_max ) {
378
384
rf_ptr -> mac_cca_retry = 0 ;
@@ -438,6 +444,9 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
438
444
if (rf_ptr -> mac_ack_tx_active ) {
439
445
//Accept direct non crypted acks and crypted only if neighbor is at list
440
446
if (rf_ptr -> ack_tx_possible ) {
447
+ #ifdef TIMING_TOOL_TRACES
448
+ tr_info ("%u TX_start %u" , mac_mcps_sap_get_phy_timestamp (rf_ptr ), rf_ptr -> mac_channel );
449
+ #endif
441
450
return PHY_TX_ALLOWED ;
442
451
}
443
452
@@ -454,6 +463,9 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
454
463
}
455
464
456
465
if (mac_data_asynch_channel_switch (rf_ptr , rf_ptr -> active_pd_data_request )) {
466
+ #ifdef TIMING_TOOL_TRACES
467
+ tr_info ("%u TX_start %u" , mac_mcps_sap_get_phy_timestamp (rf_ptr ), rf_ptr -> mac_channel );
468
+ #endif
457
469
rf_ptr -> active_pd_data_request -> initial_tx_channel = rf_ptr -> mac_channel ;
458
470
int8_t channel_cca_threshold = mac_cca_thr_get_dbm (rf_ptr , rf_ptr -> mac_channel );
459
471
if (CCA_FAILED_DBM != channel_cca_threshold ) {
@@ -501,12 +513,17 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
501
513
return PHY_RESTART_CSMA ;
502
514
}
503
515
}
504
-
516
+ #ifdef TIMING_TOOL_TRACES
517
+ tr_info ("%u TX_start %u" , mac_mcps_sap_get_phy_timestamp (rf_ptr ), rf_ptr -> mac_channel );
518
+ #endif
505
519
return 0 ;
506
520
}
507
521
508
522
if (rf_ptr -> mac_ack_tx_active ) {
509
523
mac_data_ack_tx_finish (rf_ptr );
524
+ #ifdef TIMING_TOOL_TRACES
525
+ tr_info ("%u TX_done" , mac_mcps_sap_get_phy_timestamp (rf_ptr ));
526
+ #endif
510
527
return 0 ;
511
528
} else {
512
529
@@ -531,6 +548,11 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
531
548
* PHY_LINK_TX_FAIL either happened during transmission or when waiting Ack -> we must use the CCA count given by PHY.
532
549
*/
533
550
if ((cca_retry == 0 ) && (status != PHY_LINK_TX_FAIL )) {
551
+ #ifdef TIMING_TOOL_TRACES
552
+ if (status != PHY_LINK_CCA_FAIL ) {
553
+ tr_info ("%u TX_done" , mac_mcps_sap_get_phy_timestamp (rf_ptr ));
554
+ }
555
+ #endif
534
556
cca_retry = 1 ;
535
557
}
536
558
rf_ptr -> mac_tx_status .cca_cnt += cca_retry ;
@@ -970,6 +992,10 @@ int8_t mac_pd_sap_data_cb(void *identifier, arm_phy_sap_msg_t *message)
970
992
if (pd_data_ind -> data_len < 3 ) {
971
993
return -1 ;
972
994
}
995
+ #ifdef TIMING_TOOL_TRACES
996
+ tr_info ("%u RX_start" , mac_pd_sap_get_phy_rx_time (rf_ptr ));
997
+ tr_info ("%u RX_done" , mac_mcps_sap_get_phy_timestamp (rf_ptr ));
998
+ #endif
973
999
mac_cca_threshold_event_send (rf_ptr , rf_ptr -> mac_channel , pd_data_ind -> dbm );
974
1000
mac_fcf_sequence_t fcf_read ;
975
1001
const uint8_t * ptr = mac_header_parse_fcf_dsn (& fcf_read , pd_data_ind -> data_ptr );
0 commit comments