Bluetooth: Convert bt_conn_set_auto_conn to bt_le_set_auto_conn

Once we start persistently storing the addresses of devices we want to
reconnect to we also need a way to reload them to the stack. Since we
don't have a connection object at this point the API cannot take that
as a parameter. Instead rename the function and have it take
bt_addr_le_t as a parameter.

The feature was also lacking proper reference counting for the
connection, which this patch now adds (the flag itself owns a
reference). The function is now also possible to call before bt_init()
so that if we load the stack with multiple devices the HCI doesn't get
bombarded with lots of scan enable/disable commands.

Change-Id: I9072bf061eb64f2ecec96f74fb176be13e5bdaee
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2015-12-04 10:34:12 +02:00 committed by Anas Nashif
commit 5a5061ef97
4 changed files with 58 additions and 26 deletions

View file

@ -198,21 +198,5 @@ void bt_conn_cb_register(struct bt_conn_cb *cb);
*/
uint8_t bt_conn_enc_key_size(struct bt_conn *conn);
#if defined(CONFIG_BLUETOOTH_CENTRAL)
/** @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 N/A
*/
void bt_conn_set_auto_conn(struct bt_conn *conn, bool auto_conn);
#endif /* CONFIG_BLUETOOTH_CENTRAL */
#endif /* CONFIG_BLUETOOTH_CENTRAL || CONFIG_BLUETOOTH_PERIPHERAL */
#endif /* __BT_CONN_H */