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

what's the error generated when ble disconnect due to distance

I'm connecting my nrf51 with my phone and when I move far from the microcontroller (long distance) the connection is lost what's the function witch rise this error and what's the error code?

Parents
  • There is obviously no "distance" detection. What will happen is that packets get lost and at some point supervision timeout expires without any connection event completed. That's why this parameter of LE Logical Link (LL) layer exists and is part of connection parameters negotiated by Master and Slave (GAP Central and Peripheral if you want). I believe you will get from Soft Device

    BLE_GAP_EVT_TIMEOUT,                          /**< Timeout expired.                                \n See @ref ble_gap_evt_timeout_t.              */
    

    event with

    p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_CONN
    

    which is defined as

    #define BLE_GAP_TIMEOUT_SRC_CONN                       0x03 /**< Connection timeout. */
    

    See ble_gap.h file and SDK examples for more.

    Note that you will get the same event if the counter part simply drop connection without proper termination on LE LE layer (e.g. when there is POWER OFF, Reset, you put it to metal box etc.) So you should know that this isn't 100% indication that device is out of reach due to distance (there is no such magic in BLE;).

    Cheers Jan

  • the reset is happened only when notification is activated for a single characteristic. I think the error is rised from sd_ble_gatts_hvx but I'm not sure. I followed all where BLE_GAP_EVT_TIMEOUT is called, I put a flag to see if this code is executed but nothing happened

Reply Children
No Data
Related