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

Client unable to receive notification after 0x3002 from SoftDevice

Hi,

I am having a problem where the client is unable to receive notification from a peripheral after the softdevice in the peripheral returns 0x3002 after a disconnect. The peripheral is running a modified "ble_app_uart" example with the following modifications/design specs

1. PCA10040

2. SDK_17.0.2

3. SoftDevice 7.2.0

4. Modified Nordic Uart Service: Data Length Extension, MTU SIZE = 247, Connection Length Interval Enabled, HW UART functionality removed, min connection interval = max connection interval = 15 (18.75ms)

5. 32-bit timer set to send a random 244 byte packet every 20ms using the "ble_nus_data_send()" as follows

do
{
    err_code = ble_nus_data_send(&m_nus, (uint8_t*)ble_queue[blerdptr], &nus_data_length, m_conn_handle);
} while (err_code == NRF_ERROR_RESOURCES);

if(err_code != NRF_SUCCESS)
{
    //err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
    //NRF_LOG_INFO("BLE_ERROR_GATTS_SYS_ATTR_MISSING_LOOP");

    NRF_LOG_INFO("ERROR_CODE IS %u", err_code);
};

6. Timer does not send packets until it receives a 'b' character from the client from its RX interface. Also, timer stops sending packets when peripheral receives a disconnection event.

7. Client is a modified "ble_app_uart_c" running on another PCA10040 to support the modifications from the peripheral or an Android App using modified NUS services.

The above setup works fine and we are able to transfer our 244 byte payload in the 20ms interval without any issues. The problem arises when there is a disconnection. For the most part, If we suddenly disconnect the client (kill Android App or disconnect usb cable of PCA10040 running "ble_app_uart_c") the SoftDevice returns 0x0005 and when we reconnect back to the peripheral everything is fine and we can continue streaming. In a few cases, SoftDevice returns 0x3002. In this particular case after reconnecting with the peripheral, we cannot receive any notification from the peripheral although the peripheral receives commands from the client. Also, the "ble_nus_data_send()" function returns "NRF_SUCCESS" and the "BLE_NUS_EVT_TX_RDY" event is also triggered. I tried enabling/disabling notifications using the nrfConnect App without success.

My questions are as follows:

1. How do I recover from an 0x3002 error such that when there is a reconnection and we can continue to stream data just like in the 0x0005 error case?

2. Is there a better way to send data from the peripheral such that data is not sent when there is a disconnect so as to avoid error 0x3002?

3. Is there a clean up that needs to be done when there is a disconnect from the client using NUS?

4. Is there a better way to use/modify NUS than what we have done?

Thanks You

Parents Reply Children
No Data
Related