diff --git a/components/ieee802154/driver/esp_ieee802154_dev.c b/components/ieee802154/driver/esp_ieee802154_dev.c index 0b5214b661..3076ae674d 100644 --- a/components/ieee802154/driver/esp_ieee802154_dev.c +++ b/components/ieee802154/driver/esp_ieee802154_dev.c @@ -107,14 +107,9 @@ static bool stop_rx(void) static bool stop_tx_ack(void) { - ieee802154_ll_events events; - ieee802154_ll_set_cmd(IEEE802154_CMD_STOP); - events = ieee802154_ll_get_events(); - if (events & IEEE802154_EVENT_ACK_TX_DONE) { - esp_ieee802154_receive_done((uint8_t *)s_rx_frame[s_rx_index], &s_rx_frame_info[s_rx_index]); - } + esp_ieee802154_receive_done((uint8_t *)s_rx_frame[s_rx_index], &s_rx_frame_info[s_rx_index]); ieee802154_ll_clear_events(IEEE802154_EVENT_ACK_TX_DONE | IEEE802154_EVENT_RX_ABORT | IEEE802154_EVENT_TX_SFD_DONE); // ZB-81: clear TX_SFD_DONE event @@ -170,12 +165,10 @@ static bool stop_rx_ack(void) ieee802154_timer0_stop(); ieee802154_ll_disable_events(IEEE802154_EVENT_TIMER0_OVERFLOW); - if (events & IEEE802154_EVENT_TIMER0_OVERFLOW) { - esp_ieee802154_transmit_failed(s_tx_frame, ESP_IEEE802154_TX_ERR_NO_ACK); - } - if (events & IEEE802154_EVENT_ACK_RX_DONE) { esp_ieee802154_transmit_done(s_tx_frame, (uint8_t *)&s_rx_frame[s_rx_index], &s_rx_frame_info[s_rx_index]); + } else { + esp_ieee802154_transmit_failed(s_tx_frame, ESP_IEEE802154_TX_ERR_NO_ACK); } ieee802154_ll_clear_events(IEEE802154_EVENT_ACK_RX_DONE | IEEE802154_EVENT_RX_SFD_DONE | IEEE802154_EVENT_TX_ABORT); diff --git a/components/openthread/port/esp_openthread_radio.c b/components/openthread/port/esp_openthread_radio.c index a8616a7fdf..fa4dcfbe12 100644 --- a/components/openthread/port/esp_openthread_radio.c +++ b/components/openthread/port/esp_openthread_radio.c @@ -588,14 +588,16 @@ static void IRAM_ATTR convert_to_ot_frame(uint8_t *data, esp_ieee802154_frame_in #endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE } -static void IRAM_ATTR enh_ack_set_security_addr_and_key(otRadioFrame *ack_frame) +static esp_err_t IRAM_ATTR enh_ack_set_security_addr_and_key(otRadioFrame *ack_frame) { struct otMacKeyMaterial *key = NULL; uint8_t key_id; ETS_ASSERT(otMacFrameIsSecurityEnabled(ack_frame)); key_id = otMacFrameGetKeyId(ack_frame); - ETS_ASSERT(otMacFrameIsKeyIdMode1(ack_frame) && key_id != 0); + if(!(otMacFrameIsKeyIdMode1(ack_frame) && key_id != 0)) { + return ESP_FAIL; + } if (key_id == s_key_id) { key = &s_current_key; @@ -604,7 +606,7 @@ static void IRAM_ATTR enh_ack_set_security_addr_and_key(otRadioFrame *ack_frame) } else if (key_id == s_key_id + 1) { key = &s_next_key; } else { - ETS_ASSERT(false); + return ESP_FAIL; } s_ack_frame_counter = s_mac_frame_counter; s_ack_key_id = key_id; @@ -615,6 +617,7 @@ static void IRAM_ATTR enh_ack_set_security_addr_and_key(otRadioFrame *ack_frame) } esp_ieee802154_set_transmit_security(&ack_frame->mPsdu[-1], s_security_key, s_security_addr); + return ESP_OK; } esp_err_t IRAM_ATTR esp_ieee802154_enh_ack_generator(uint8_t *frame, esp_ieee802154_frame_info_t *frame_info, @@ -658,7 +661,9 @@ esp_err_t IRAM_ATTR esp_ieee802154_enh_ack_generator(uint8_t *frame, esp_ieee802 if (otMacFrameIsSecurityEnabled(&ack_frame) && !ack_frame.mInfo.mTxInfo.mIsSecurityProcessed) { otMacFrameSetFrameCounter(&ack_frame, s_mac_frame_counter++); - enh_ack_set_security_addr_and_key(&ack_frame); + if (enh_ack_set_security_addr_and_key(&ack_frame) != ESP_OK) { + return ESP_FAIL; + } } return ESP_OK; }