diff --git a/source/MAC/IEEE802_15_4/mac_pd_sap.c b/source/MAC/IEEE802_15_4/mac_pd_sap.c index 71e201935df..6b36a7f7d69 100644 --- a/source/MAC/IEEE802_15_4/mac_pd_sap.c +++ b/source/MAC/IEEE802_15_4/mac_pd_sap.c @@ -507,7 +507,14 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r } } VALIDATE_TX_TIME: -// TODO: Validate TX time here + 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) { + int32_t tx_time_error_us = mac_mcps_sap_get_phy_timestamp(rf_ptr) - rf_ptr->active_pd_data_request->tx_time; + // Positive error means that TX is too late. Do not allow transmit if transmission is delayed over 5ms + if (tx_time_error_us > 5000) { + mac_sap_cca_fail_cb(rf_ptr, 0xffff); + return PHY_TX_NOT_ALLOWED; + } + } #ifdef TIMING_TOOL_TRACES tr_info("%u TX_start %u", mac_mcps_sap_get_phy_timestamp(rf_ptr), rf_ptr->mac_channel); #endif