Multiple connections for CS

Hi,

I am currently working on making it possible to connect with different devices sequentially. It was told to me that it is possible to first scan all devices, and then connect to them one by one. I am currently working on that and i made it possible to store all the connections in my connections array. This is what i get:



So we get behind the semaphores of the SCANNING and hus behind the LOG_INF of the MAIN():



I thought it was possible to then just use a for loop and the reconnect to the devices one by one, but maybe i am missing something. 

Can someone help me with this please?

Kind Regards,

Nick De Leenheer

Parents
  • Hello,

    When you're done with a connection, you should:
    Call bt_conn_disconnect() with an appropriate reason code (like BT_HCI_ERR_REMOTE_USER_TERM_CONN)
    Call bt_conn_unref() to release your reference to the connection object

    It's important to understand that connection objects are reference counted. As explained in this DevZone thread:
    "Connection objects are reference counted, and the application is expected to use the bt_conn_ref() API whenever storing a connection pointer for a longer period of time, since this ensures that the object remains valid (even if the connection would get disconnected). Similarly the bt_conn_unref() API is to be used when releasing a reference to a connection."

    I expect in this case that you are not using bt_conn_ref() and bt_conn_unref() for each connections.

    Kenneth

Reply
  • Hello,

    When you're done with a connection, you should:
    Call bt_conn_disconnect() with an appropriate reason code (like BT_HCI_ERR_REMOTE_USER_TERM_CONN)
    Call bt_conn_unref() to release your reference to the connection object

    It's important to understand that connection objects are reference counted. As explained in this DevZone thread:
    "Connection objects are reference counted, and the application is expected to use the bt_conn_ref() API whenever storing a connection pointer for a longer period of time, since this ensures that the object remains valid (even if the connection would get disconnected). Similarly the bt_conn_unref() API is to be used when releasing a reference to a connection."

    I expect in this case that you are not using bt_conn_ref() and bt_conn_unref() for each connections.

    Kenneth

Children
No Data
Related