Bluetooth: Add initial auto connect support

Calling bt_conn_set_auto_conn one can decide if auto connect shall
be used. If so, everytime the connection is lost, passive scanning
will be enabled to listen for connectable advertisements from
remote device and re-establish the connection.

Auto connect can be disabled if one decide to disconnect from
this device using bt_disconnect or call bt_conn_set_auto_conn
with auto_conn flag set to false.

Change-Id: Ic9952e313cb8612ea6c72838be0755805daeffcf
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
This commit is contained in:
Mariusz Skamra 2015-07-13 12:43:02 +02:00 committed by Anas Nashif
commit b210d53172
4 changed files with 44 additions and 0 deletions

View file

@ -34,6 +34,8 @@
#ifndef __BT_CONN_H
#define __BT_CONN_H
#include <stdbool.h>
#include <bluetooth/hci.h>
/** Opaque type representing a connection to a remote device */
@ -93,4 +95,18 @@ struct bt_conn_cb {
*/
void bt_conn_cb_register(struct bt_conn_cb *cb);
/** @brief Automatically connect to remote device if it's in range.
*
* This function enables/disables automatic connection initiation.
* Everytime the device looses the connection with peer, this connection
* will be re-established if connectable advertisement from peer is received.
*
* @param conn Existing connection object.
* @param auto_conn boolean value. If true, auto connect is enabled,
* if false, auto connect is disabled.
*
* @return none
*/
void bt_conn_set_auto_conn(struct bt_conn *conn, bool auto_conn);
#endif /* __BT_CONN_H */