Skip to content

Commit d40b1c7

Browse files
author
Jarkko Paso
authored
MAC: Updated calling FHSS TX done (#2295)
1 parent aeb93a1 commit d40b1c7

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

source/MAC/IEEE802_15_4/mac_pd_sap.c

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,6 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
481481
return 0;
482482
}
483483

484-
//
485-
bool waiting_ack = false;
486-
487-
488484
if (rf_ptr->mac_ack_tx_active) {
489485
mac_data_ack_tx_finish(rf_ptr);
490486
return 0;
@@ -506,11 +502,40 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
506502
timer_mac_stop(rf_ptr);
507503
}
508504

505+
if (rf_ptr->fhss_api && rf_ptr->active_pd_data_request->asynch_request == false) {
506+
/* waiting_ack == false allows FHSS to change back to RX channel after transmission
507+
* tx_completed == true allows FHSS to delete stored failure handles
508+
*/
509+
bool waiting_ack = false, tx_completed = false;
510+
if (status == PHY_LINK_TX_SUCCESS && !rf_ptr->macTxRequestAck) {
511+
waiting_ack = false;
512+
tx_completed = true;
513+
} else if (status == PHY_LINK_TX_SUCCESS && rf_ptr->macTxRequestAck) {
514+
waiting_ack = true;
515+
tx_completed = false;
516+
} else if (status == PHY_LINK_CCA_FAIL) {
517+
waiting_ack = false;
518+
tx_completed = false;
519+
} else if (status == PHY_LINK_CCA_OK) {
520+
waiting_ack = false;
521+
tx_completed = false;
522+
} else if (status == PHY_LINK_TX_FAIL) {
523+
waiting_ack = false;
524+
tx_completed = false;
525+
} else if (status == PHY_LINK_TX_DONE) {
526+
waiting_ack = false;
527+
tx_completed = true;
528+
} else if (status == PHY_LINK_TX_DONE_PENDING) {
529+
waiting_ack = false;
530+
tx_completed = true;
531+
}
532+
rf_ptr->fhss_api->data_tx_done(rf_ptr->fhss_api, waiting_ack, tx_completed, rf_ptr->active_pd_data_request->msduHandle);
533+
}
534+
509535
switch (status) {
510536
case PHY_LINK_TX_SUCCESS:
511537
if (rf_ptr->macTxRequestAck) {
512538
timer_mac_start(rf_ptr, MAC_TIMER_ACK, rf_ptr->mac_ack_wait_duration); /*wait for ACK 1 ms*/
513-
waiting_ack = true;
514539
} else {
515540
//TODO CHECK this is MAC_TX_ PERMIT OK
516541
mac_tx_done_state_set(rf_ptr, MAC_TX_DONE);
@@ -540,15 +565,6 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
540565
default:
541566
break;
542567
}
543-
if (rf_ptr->fhss_api) {
544-
bool tx_is_done = false;
545-
if (rf_ptr->mac_tx_result == MAC_TX_DONE) {
546-
tx_is_done = true;
547-
}
548-
if (rf_ptr->active_pd_data_request->asynch_request == false) {
549-
rf_ptr->fhss_api->data_tx_done(rf_ptr->fhss_api, waiting_ack, tx_is_done, rf_ptr->active_pd_data_request->msduHandle);
550-
}
551-
}
552568
return 0;
553569
}
554570

0 commit comments

Comments
 (0)