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

BLE Peripheral does not connect back after BLE central disconnects the first time

Hello Everyone, 

I am facing an issue when trying to connect back BLE central again after disconnecting it from the BLE peripheral once.

The issue is reproducible as follows: 

1. Start BLE peripheral on nrf52 DK (SD v14.2) running ble_app_uart and BLE central on another nrf52 DK running ble_app_uart_c example. 

2. Disconnect the power source for central device.

3. Once disconnected, connect back the power source in order to re-establish the connection. 

Observation: Peripheral and Central donot pair back again, until and unless you power cycle the peripheral device.

From my understanding, BLE central is the one that will be requesting the pairing and in the ble_app_uart_c code, i see that once disconnected, it is trying to start the scan again for pairing up. But still, they donot pair up once disconnected. Could  you please help me suggest where i am going wrong with this? 

I am under the assumption that once it disconnects, it should reconnect again once withing range. 

Please let me know your thoughts and suggestions. Appreciate your help.

Thank you! 

Parents
  • Hi,

    Just an update here! 

    So while running the default BLE peripheral example, it runs perfectly fine. That is to say once i disconnect Central and try to connect again, peripheral and central connects. 

    Issue i am having is when i modify the BLE peripheral code. 

    I am using timer to make it go to sleep and once timer expires, it will send some random data to central. However, when i disconnect Central and then try to connect back again, it throws me with this error code: 0x3401.

    Please see the code attached.

    //inside main
    while(true)
    {
        if(timerExpires && bleConnected)
        {
            do
            {
                length=10;
                err_code = ble_nus_string_send(&m_nus, data, &length);
                if((err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_BUSY))
                {
                    APP_ERROR_CHECK(err_code);
                    timerExpires = false;
                }
            }
            
        }
        else if(bleConnected && !timerExpires)
        {
            //enter low power mode
        }
        else
        {
            //do nothing
        }
    }

    Error occurs when it tries to send data over BLE after re-connection.

    I followed this page to get to know more --> https://devzone.nordicsemi.com/f/nordic-q-a/3338/error-code-0x3401

    But, while debugging, it never comes to BLE_GATTS_EVT_SYS_ATTR_MISSING event. 

    Any suggestions on what could be the issue here? 

Reply
  • Hi,

    Just an update here! 

    So while running the default BLE peripheral example, it runs perfectly fine. That is to say once i disconnect Central and try to connect again, peripheral and central connects. 

    Issue i am having is when i modify the BLE peripheral code. 

    I am using timer to make it go to sleep and once timer expires, it will send some random data to central. However, when i disconnect Central and then try to connect back again, it throws me with this error code: 0x3401.

    Please see the code attached.

    //inside main
    while(true)
    {
        if(timerExpires && bleConnected)
        {
            do
            {
                length=10;
                err_code = ble_nus_string_send(&m_nus, data, &length);
                if((err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_BUSY))
                {
                    APP_ERROR_CHECK(err_code);
                    timerExpires = false;
                }
            }
            
        }
        else if(bleConnected && !timerExpires)
        {
            //enter low power mode
        }
        else
        {
            //do nothing
        }
    }

    Error occurs when it tries to send data over BLE after re-connection.

    I followed this page to get to know more --> https://devzone.nordicsemi.com/f/nordic-q-a/3338/error-code-0x3401

    But, while debugging, it never comes to BLE_GATTS_EVT_SYS_ATTR_MISSING event. 

    Any suggestions on what could be the issue here? 

Children
No Data
Related