This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How can i know all connected handles?

Hi. I'm using SDK12.2.0, S130 ver2.0.1, nRF51822AC as central. After connection, if i use "ble_conn_state_n_centrals" function, i can get the number of connected peripherals. Is there any function to know all connection handle values for connected peripherals?

I hope your reply.

Parents
  • Hi,

    Yes, with the ble_conn_state module you can use the function ble_conn_state_central_handles() to get a list of all connection handles where the local device is the central.

    sdk_mapped_flags_key_list_t conn_central_handles = ble_conn_state_central_handles();
    
    //You can iterate through the list of connection handles:
    for (uint32_t i = 0; i < conn_central_handles.len; i++)
    {
    		uint16_t conn_handle = conn_central_handles.flag_keys[i];
    }
    

    Note: Make sure that sdk_mapped_flags.c is added to your project, and that ble events are dispatched to the ble_conn_state module( add ble_conn_state_on_ble_evt(p_ble_evt); to ble_evt_dispatch()).

Reply
  • Hi,

    Yes, with the ble_conn_state module you can use the function ble_conn_state_central_handles() to get a list of all connection handles where the local device is the central.

    sdk_mapped_flags_key_list_t conn_central_handles = ble_conn_state_central_handles();
    
    //You can iterate through the list of connection handles:
    for (uint32_t i = 0; i < conn_central_handles.len; i++)
    {
    		uint16_t conn_handle = conn_central_handles.flag_keys[i];
    }
    

    Note: Make sure that sdk_mapped_flags.c is added to your project, and that ble events are dispatched to the ble_conn_state module( add ble_conn_state_on_ble_evt(p_ble_evt); to ble_evt_dispatch()).

Children
Related