Skip to content

Commit 6527e05

Browse files
author
Jarkko Paso
committed
MAC: Fixed multi csma
1 parent 0306276 commit 6527e05

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

source/MAC/IEEE802_15_4/mac_mcps_sap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,7 @@ static int8_t mcps_pd_data_cca_trig(protocol_interface_rf_mac_setup_s *rf_ptr, m
18311831
// Use double CCA check with FHSS for data packets only
18321832
if (rf_ptr->fhss_api && !rf_ptr->mac_ack_tx_active && !rf_ptr->active_pd_data_request->asynch_request) {
18331833
if ((buffer->tx_time - (rf_ptr->multi_cca_interval * (rf_ptr->number_of_csma_ca_periods - 1))) > mac_mcps_sap_get_phy_timestamp(rf_ptr)) {
1834-
buffer->csma_periods_left = rf_ptr->number_of_csma_ca_periods;
1834+
buffer->csma_periods_left = rf_ptr->number_of_csma_ca_periods - 1;
18351835
buffer->tx_time -= (rf_ptr->multi_cca_interval * (rf_ptr->number_of_csma_ca_periods - 1));
18361836
}
18371837
}

source/MAC/IEEE802_15_4/mac_pd_sap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
// Measured 3750us with 1280 byte secured packet from calculating TX time to starting CSMA timer on PHY.
4242
// Typically varies from 500us to several milliseconds depending on packet size and the platform.
4343
// MAC should learn and make this dynamic by sending first few packets with predefined CSMA period.
44-
#define MIN_FHSS_CSMA_PERIOD_US 4000
44+
#define MIN_FHSS_CSMA_PERIOD_US 5000
4545

4646
static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *rf_ptr, phy_link_tx_status_e status, uint8_t cca_retry, uint8_t tx_retry);
4747
static void mac_sap_cca_fail_cb(protocol_interface_rf_mac_setup_s *rf_ptr);
@@ -448,7 +448,8 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
448448
mac_tx_done_state_set(rf_ptr, MAC_UNKNOWN_DESTINATION);
449449
return PHY_TX_NOT_ALLOWED;
450450
}
451-
if (--active_buf->csma_periods_left > 0) {
451+
if (active_buf->csma_periods_left > 0) {
452+
active_buf->csma_periods_left--;
452453
active_buf->tx_time += rf_ptr->multi_cca_interval;
453454
mac_pd_sap_set_phy_tx_time(rf_ptr, active_buf->tx_time, true);
454455
return PHY_RESTART_CSMA;

0 commit comments

Comments
 (0)