Get connection status in Zephyr

Hi,

I want to monitor the connection state of my device as I have observed situations in which the callback functions defined with bt_conn_cb_register is not fired, causing the device to no longer advertise.

I guess i somehow should update my bt_conn variable from a connection handle and read the state but I haven't found a way to do it.

Can you provide me with some information on how this should be done?

Parents
  • I guess i somehow should update my bt_conn variable from a connection handle and read the state but I haven't found a way to do it.

    I don't think you need to do anyting like this. All your connections are stored inside the array bt_conn acl_conns. When you start the connectable advertising, a new bt_conn instance is automatically added to this array using bt_conn_add_le().

    Then when an event happens for a specific connction it will go through all the callbacks added (possible to have several instances of bt_conn_cb). For example in the function notify_connected().

    I will ask some developers to look through my answer on Monday, to make sure the information I have given you is correct. I'm also interested in taking a deeper look at why the callbacks stops firing.

    Best regards,

    Simon

Reply
  • I guess i somehow should update my bt_conn variable from a connection handle and read the state but I haven't found a way to do it.

    I don't think you need to do anyting like this. All your connections are stored inside the array bt_conn acl_conns. When you start the connectable advertising, a new bt_conn instance is automatically added to this array using bt_conn_add_le().

    Then when an event happens for a specific connction it will go through all the callbacks added (possible to have several instances of bt_conn_cb). For example in the function notify_connected().

    I will ask some developers to look through my answer on Monday, to make sure the information I have given you is correct. I'm also interested in taking a deeper look at why the callbacks stops firing.

    Best regards,

    Simon

Children
No Data
Related