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

BLE connection problem

Hi,

I'm using sdk12.3.0 ble_app_uart.

My problem is BLE connection.

Sometimes(almost 50%)I tried to connect BLE but fail and I have to connect again.

I don't know why.

This image is messages that I captured when connection failed.

What is the problem?

Thank you for reading my question!

image description

  • Hi,

    Did you go into Bluetooth settings on your phone, and removed the device form the list of paired/bonded the devices? Also try to restart the phone.

    On the nRF51, you could try to enable the Service Changed characteristic so that changes in the application are indicated to the phone. Set IS_SRVC_CHANGED_CHARACT_PRESENT to 1.

    Code snippet(SDK12.3):

    // Initialize the SoftDevice handler module.
    SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);
    
    ble_enable_params_t ble_enable_params;
    err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT,
                                                    PERIPHERAL_LINK_COUNT,
                                                    &ble_enable_params);
    APP_ERROR_CHECK(err_code);
    
    ble_enable_params.gatts_enable_params.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT;
    
  • Thanks for your answer! BLE device is not paired or bonded. And If device is paired or bonded, I need software solution. Because it didn't happen always. And I tried to your code, It didn't work. I changed RX_PIN_NUMBER and TX_PIN_NUMBER to 5 and 6 (default number is 11, 9) to connect UART with my board. Is that something to do with? Because this problem didn't happen before that. Again, Thank you for answering my question!

  • Is this a custom board or the nRF51-DK ? On the nRF51-DK, the on-board Segger J-link programmer that have the Virtual COM port via UART, uses pin 9 and 11. So if you are using the DK you won't be able to send and receive data from the PC terminal if you change the pins to 5 and 6.

    So if you use the default pin numbers(11 and 9), then you don't get the Device is not supported message ?

  • Connection is like this, My custom board-(UART serial)-> Motherboard-(BLE)->Android When I tested with PC terminal with default setting, I don't get the Device is not supported message but cannot 100% sure.

  • I found out that it's not android side problem. Error occurs at BLE module. but it's not the error in nrf_error.h. Something else. But I don't know error code because SEGGER_RTT_printf() function is not working. only SEGGER_RTT_WriteString() works. So, I checked one by one using SEGGER_RTT_WriteString() And I think this error can be related with UART. How can I debug this? Thanks for reading my question.

Related