From f728d559205c9b09d1964694deb562733eec3d73 Mon Sep 17 00:00:00 2001 From: Juha Heiskanen Date: Wed, 12 Feb 2020 18:26:29 +0200 Subject: [PATCH] Support for handle CRC error which will automatically change a channel. If Driver call data ind with zero length we can then handle that like CRC error which will change a FHHS channel if is pending. Change-Id: Iba0cdce8dabf20f1640e63b33c116d7d3c0a9254 --- source/MAC/IEEE802_15_4/mac_pd_sap.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/MAC/IEEE802_15_4/mac_pd_sap.c b/source/MAC/IEEE802_15_4/mac_pd_sap.c index dc6b91e5c873..1b8eda122918 100644 --- a/source/MAC/IEEE802_15_4/mac_pd_sap.c +++ b/source/MAC/IEEE802_15_4/mac_pd_sap.c @@ -890,6 +890,11 @@ int8_t mac_pd_sap_data_cb(void *identifier, arm_phy_sap_msg_t *message) if (message->id == MAC15_4_PD_SAP_DATA_IND) { arm_pd_sap_generic_ind_t *pd_data_ind = &(message->message.generic_data_ind); + mac_pre_parsed_frame_t *buffer = NULL; + if (pd_data_ind->data_len == 0) { + goto ERROR_HANDLER; + } + if (pd_data_ind->data_len < 3) { return -1; } @@ -897,7 +902,7 @@ int8_t mac_pd_sap_data_cb(void *identifier, arm_phy_sap_msg_t *message) mac_fcf_sequence_t fcf_read; const uint8_t *ptr = mac_header_parse_fcf_dsn(&fcf_read, pd_data_ind->data_ptr); - mac_pre_parsed_frame_t *buffer = mac_pd_sap_allocate_receive_buffer(rf_ptr, &fcf_read, pd_data_ind); + buffer = mac_pd_sap_allocate_receive_buffer(rf_ptr, &fcf_read, pd_data_ind); if (buffer && mac_filter_modify_link_quality(rf_ptr->mac_interface_id, buffer) == 1) { goto ERROR_HANDLER; } @@ -935,7 +940,9 @@ int8_t mac_pd_sap_data_cb(void *identifier, arm_phy_sap_msg_t *message) } ERROR_HANDLER: mcps_sap_pre_parsed_frame_buffer_free(buffer); - sw_mac_stats_update(rf_ptr, STAT_MAC_RX_DROP, 0); + if (pd_data_ind->data_len >= 3) { + sw_mac_stats_update(rf_ptr, STAT_MAC_RX_DROP, 0); + } if (rf_ptr->fhss_api) { rf_ptr->fhss_api->data_tx_done(rf_ptr->fhss_api, false, false, 0); }