Skip to content

Commit 587add5

Browse files
author
Jarkko Paso
authored
MAC: Validate TX time (ARMmbed#2429)
1 parent a1bfed4 commit 587add5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

source/MAC/IEEE802_15_4/mac_pd_sap.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,14 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
507507
}
508508
}
509509
VALIDATE_TX_TIME:
510-
// TODO: Validate TX time here
510+
if (rf_ptr->active_pd_data_request && rf_ptr->active_pd_data_request->tx_time && !rf_ptr->mac_ack_tx_active && !rf_ptr->mac_edfe_tx_active) {
511+
int32_t tx_time_error_us = mac_mcps_sap_get_phy_timestamp(rf_ptr) - rf_ptr->active_pd_data_request->tx_time;
512+
// Positive error means that TX is too late. Do not allow transmit if transmission is delayed over 5ms
513+
if (tx_time_error_us > 5000) {
514+
mac_sap_cca_fail_cb(rf_ptr, 0xffff);
515+
return PHY_TX_NOT_ALLOWED;
516+
}
517+
}
511518
#ifdef TIMING_TOOL_TRACES
512519
tr_info("%u TX_start %u", mac_mcps_sap_get_phy_timestamp(rf_ptr), rf_ptr->mac_channel);
513520
#endif

0 commit comments

Comments
 (0)