From 5c34373d6d184253c514d9a299442dd541cc7d1c Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Sun, 20 Mar 2016 21:13:27 +0100 Subject: [PATCH] nrf5x: drop advs with crc error, avoids bug in ad_parser --- port/nrf5x/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/port/nrf5x/main.c b/port/nrf5x/main.c index 801184ee3..697809b78 100755 --- a/port/nrf5x/main.c +++ b/port/nrf5x/main.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "app_uart.h" #include "app_error.h" @@ -263,10 +264,10 @@ void RADIO_IRQHandler(void){ NRF_RADIO->EVENTS_END = 0; if (ll_state == LL_STATE_SCANNING){ - // adv received - // check if outgoing buffer available - if (hci_outgoing_event_free){ + // check if outgoing buffer available and if CRC was ok + if (hci_outgoing_event_free && + ((NRF_RADIO->CRCSTATUS & RADIO_CRCSTATUS_CRCSTATUS_Msk) == (RADIO_CRCSTATUS_CRCSTATUS_CRCOk << RADIO_CRCSTATUS_CRCSTATUS_Pos))){ hci_outgoing_event_free = 0; int len = rx_adv_buffer[1] & 0x3f; hci_outgoing_event[0] = HCI_EVENT_LE_META; @@ -365,7 +366,6 @@ uint8_t ll_set_scan_enable(uint8_t le_scan_enable, uint8_t filter_duplicates){ } } - static int transport_run(btstack_data_source_t * ds){ // deliver hci packet on main thread if (hci_outgoing_event_ready){