This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BLE Central no read response

Hi,

I have set up a two NRF51DKs one in a central and one in a peripheral role. Using MCP and nRFConnect I have confirmed that I can send read requests to my peripheral and receive the correct response. However, when I connect to my central device and send a read request I never recieve a response. I have set a breakpoint in the ble event handler within the case for BLE_GATTC_EVT_READ_RSP and tried toggling LED, but I get no indication that there is ever a read response received.

do
 {
	err_code = sd_ble_gattc_read(conn_handle, char_handle, 0);
  } while (err_code == NRF_ERROR_BUSY);
	
APP_ERROR_CHECK(err_code);

while(!read_response_received);

I get stuck in the final while loop as I wait for a read response to set the value of read_response_receieved (it is a static global).

The strange part is that when use the nRF Sniffer to track the packet exchange a read response is sent with the correct data from the peripheral.

image description

Any idea what could causing my central to never receive the response?

Thank You!

Update: I resolved this issue by rearranging some of my code. The issue was that I was issuing a read request as a response to the BLE_GAP_EVT_CONNECTED event inside of my on_ble_evt handler and then waiting for the read response while still inside the handler. I believe the issue was that BLE events are triggered by interupts and therefore the on_ble_evt function stems from the ISR during which interupts are disabled. Therefore I could not wait for another BLE event (the read response) while still servicing a previous interupt.

I have no idea if that is correct though. Can somebody confirm?

Related