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

why sometimes the nrf_ble_gatt_on_ble_evt function can't trigger?

I used the nrf52840 as the central device, use SDK15.0, scan then connect the peripheral toys. 

sometimes i found the central can scanned some ble peripheral  but can't connected them.

I trace it found at this time the nrf_ble_gatt_on_ble_evt  can't trigger,  while the function can triggered if the other peripheral toys can be connected.

anybody can tell me why? thanks!

Parents
  • It would be nice with some more information. Which example in the SDK are you using? Some debug logging would also be helpful.

    You said that nrf_ble_gatt_on_ble_evt(..) is not called, and a reason for this may be that the devices never connects and a BLE_GAP_EVT_CONNECTED event is never generated.

    In order to locate the problem you would have to look somewhere else. First you could try setting a break point inside the function nrf_ble_scan_on_adv_report(..) to see if the device actually receives the advertising packets. If it does, then you could check if the function nrf_ble_scan_connect_with_target(..) is called. Eventually, if everything is all good up until this point, check if sd_ble_gap_connect(..) is called and if the value of the error code is equal to BLE_GAP_EVT_CONNECTED.

    I just realized that it may save you time to perform these step in the opposite order.

    When you have done this, and if you are still stuck, please ask and I will help you further.

    Best regards,

    Simon

  • hi, Simon, thanks very much for your kindly reply!

    I trace the code function on_adv_report() and found  it can get advertise data, the sd_ble_gap_connect() return code is NRF_SUCCESS, but the next event BLE_GAP_EVT_CONNECTED havn't occur in the on_ble_evt() function.

  • It seems like the error happens on the peripheral side, since sd_ble_gap_connect() returns NRF_SUCCESS, which means that a connection procedure is successfully initiated by the central device.

    Are you able to access the source code of the peripherals or debug it? Do you have any information about the peripheral devices you are trying to connect to? Maybe there are some filtering or whitelisting that makes it reject the connection request sent from the central device.

    Best regards,

    Simon

Reply
  • It seems like the error happens on the peripheral side, since sd_ble_gap_connect() returns NRF_SUCCESS, which means that a connection procedure is successfully initiated by the central device.

    Are you able to access the source code of the peripherals or debug it? Do you have any information about the peripheral devices you are trying to connect to? Maybe there are some filtering or whitelisting that makes it reject the connection request sent from the central device.

    Best regards,

    Simon

Children
Related