Bluetooth: Move all bt_conn related APIs to conn.h
To have some proper split of conn.h and bluetooth.h APIs make sure all bt_conn related ones are in conn.h. This also helps avoid forward declarations for some upcoming patches where we need bluetooth.h defines from within conn.h. Change-Id: Ief3d32118a6749fb5785dab6cb3fee4ebb86ddb4 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
41e7ebfb72
commit
25f6579016
9 changed files with 98 additions and 93 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <bluetooth/bluetooth.h>
|
#include <bluetooth/bluetooth.h>
|
||||||
|
#include <bluetooth/conn.h>
|
||||||
|
|
||||||
int bt_enable(bt_ready_cb_t cb)
|
int bt_enable(bt_ready_cb_t cb)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <bluetooth/hci.h>
|
#include <bluetooth/hci.h>
|
||||||
#include <bluetooth/conn.h>
|
|
||||||
|
|
||||||
/** @brief Callback for notifying that Bluetooth has been enabled.
|
/** @brief Callback for notifying that Bluetooth has been enabled.
|
||||||
*
|
*
|
||||||
|
@ -224,97 +223,6 @@ int bt_le_scan_start(const struct bt_le_scan_param *param, bt_le_scan_cb_t cb);
|
||||||
*/
|
*/
|
||||||
int bt_le_scan_stop(void);
|
int bt_le_scan_stop(void);
|
||||||
|
|
||||||
#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 addr Remote Bluetooth address.
|
|
||||||
* @param param If non-NULL, auto connect is enabled with the given
|
|
||||||
* parameters. If NULL, auto connect is disabled.
|
|
||||||
*
|
|
||||||
* @return Zero on success or error code otherwise.
|
|
||||||
*/
|
|
||||||
int bt_le_set_auto_conn(bt_addr_le_t *addr,
|
|
||||||
const struct bt_le_conn_param *param);
|
|
||||||
|
|
||||||
#endif /* CONFIG_BLUETOOTH_CENTRAL */
|
|
||||||
|
|
||||||
#if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR)
|
|
||||||
/** Authenticated pairing callback structure */
|
|
||||||
struct bt_auth_cb {
|
|
||||||
void (*passkey_display)(struct bt_conn *conn, unsigned int passkey);
|
|
||||||
void (*passkey_entry)(struct bt_conn *conn);
|
|
||||||
void (*passkey_confirm)(struct bt_conn *conn, unsigned int passkey);
|
|
||||||
void (*cancel)(struct bt_conn *conn);
|
|
||||||
#if defined(CONFIG_BLUETOOTH_BREDR)
|
|
||||||
void (*pincode_entry)(struct bt_conn *conn, bool highsec);
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @brief Register authentication callbacks.
|
|
||||||
*
|
|
||||||
* Register callbacks to handle authenticated pairing. Passing NULL unregisters
|
|
||||||
* previous callbacks structure.
|
|
||||||
*
|
|
||||||
* @param cb Callback struct.
|
|
||||||
*
|
|
||||||
* @return Zero on success or negative error code otherwise
|
|
||||||
*/
|
|
||||||
int bt_auth_cb_register(const struct bt_auth_cb *cb);
|
|
||||||
|
|
||||||
/** @brief Reply with entered passkey.
|
|
||||||
*
|
|
||||||
* This function should be called only after passkey_entry callback from
|
|
||||||
* bt_auth_cb structure was called.
|
|
||||||
*
|
|
||||||
* @param conn Connection object.
|
|
||||||
* @param passkey Entered passkey.
|
|
||||||
*
|
|
||||||
* @return Zero on success or negative error code otherwise
|
|
||||||
*/
|
|
||||||
int bt_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey);
|
|
||||||
|
|
||||||
/** @brief Cancel ongoing authenticated pairing.
|
|
||||||
*
|
|
||||||
* This function allows to cancel ongoing authenticated pairing.
|
|
||||||
*
|
|
||||||
* @param conn Connection object.
|
|
||||||
*
|
|
||||||
* @return Zero on success or negative error code otherwise
|
|
||||||
*/
|
|
||||||
int bt_auth_cancel(struct bt_conn *conn);
|
|
||||||
|
|
||||||
/** @brief Reply if passkey was confirmed by user.
|
|
||||||
*
|
|
||||||
* This function should be called only after passkey_confirm callback from
|
|
||||||
* bt_auth_cb structure was called. If passkey is confirmed to match then match
|
|
||||||
* should be true. Otherwise match should be false.
|
|
||||||
*
|
|
||||||
* @param conn Connection object.
|
|
||||||
* @param match True if passkey was confirmed to match, false otherwise.
|
|
||||||
*
|
|
||||||
* @return Zero on success or negative error code otherwise
|
|
||||||
*/
|
|
||||||
int bt_auth_passkey_confirm(struct bt_conn *conn, bool match);
|
|
||||||
|
|
||||||
#if defined(CONFIG_BLUETOOTH_BREDR)
|
|
||||||
/** @brief Reply with entered PIN code.
|
|
||||||
*
|
|
||||||
* This function should be called only after PIN code callback from
|
|
||||||
* bt_auth_cb structure was called. It's for legacy 2.0 devices.
|
|
||||||
*
|
|
||||||
* @param conn Connection object.
|
|
||||||
* @param pin Entered PIN code.
|
|
||||||
*
|
|
||||||
* @return Zero on success or negative error code otherwise
|
|
||||||
*/
|
|
||||||
int bt_auth_pincode_entry(struct bt_conn *conn, const char *pin);
|
|
||||||
#endif /* CONFIG_BLUETOOTH_BREDR */
|
|
||||||
#endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */
|
|
||||||
|
|
||||||
/** @def BT_ADDR_STR_LEN
|
/** @def BT_ADDR_STR_LEN
|
||||||
*
|
*
|
||||||
* @brief Recommended length of user string buffer for Bluetooth address
|
* @brief Recommended length of user string buffer for Bluetooth address
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#if defined(CONFIG_BLUETOOTH_CENTRAL) || defined(CONFIG_BLUETOOTH_PERIPHERAL)
|
#if defined(CONFIG_BLUETOOTH_CENTRAL) || defined(CONFIG_BLUETOOTH_PERIPHERAL)
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include <bluetooth/bluetooth.h>
|
||||||
#include <bluetooth/hci.h>
|
#include <bluetooth/hci.h>
|
||||||
|
|
||||||
/** Opaque type representing a connection to a remote device */
|
/** Opaque type representing a connection to a remote device */
|
||||||
|
@ -166,7 +167,22 @@ int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason);
|
||||||
*/
|
*/
|
||||||
struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer,
|
struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer,
|
||||||
const struct bt_le_conn_param *param);
|
const struct bt_le_conn_param *param);
|
||||||
#endif
|
|
||||||
|
/** @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 addr Remote Bluetooth address.
|
||||||
|
* @param param If non-NULL, auto connect is enabled with the given
|
||||||
|
* parameters. If NULL, auto connect is disabled.
|
||||||
|
*
|
||||||
|
* @return Zero on success or error code otherwise.
|
||||||
|
*/
|
||||||
|
int bt_le_set_auto_conn(bt_addr_le_t *addr,
|
||||||
|
const struct bt_le_conn_param *param);
|
||||||
|
#endif /* CONFIG_BLUETOOTH_CENTRAL */
|
||||||
|
|
||||||
/** Security level. */
|
/** Security level. */
|
||||||
typedef enum __packed {
|
typedef enum __packed {
|
||||||
|
@ -235,4 +251,78 @@ struct bt_conn_cb {
|
||||||
void bt_conn_cb_register(struct bt_conn_cb *cb);
|
void bt_conn_cb_register(struct bt_conn_cb *cb);
|
||||||
|
|
||||||
#endif /* CONFIG_BLUETOOTH_CENTRAL || CONFIG_BLUETOOTH_PERIPHERAL */
|
#endif /* CONFIG_BLUETOOTH_CENTRAL || CONFIG_BLUETOOTH_PERIPHERAL */
|
||||||
|
|
||||||
|
#if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR)
|
||||||
|
/** Authenticated pairing callback structure */
|
||||||
|
struct bt_auth_cb {
|
||||||
|
void (*passkey_display)(struct bt_conn *conn, unsigned int passkey);
|
||||||
|
void (*passkey_entry)(struct bt_conn *conn);
|
||||||
|
void (*passkey_confirm)(struct bt_conn *conn, unsigned int passkey);
|
||||||
|
void (*cancel)(struct bt_conn *conn);
|
||||||
|
#if defined(CONFIG_BLUETOOTH_BREDR)
|
||||||
|
void (*pincode_entry)(struct bt_conn *conn, bool highsec);
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
/** @brief Register authentication callbacks.
|
||||||
|
*
|
||||||
|
* Register callbacks to handle authenticated pairing. Passing NULL unregisters
|
||||||
|
* previous callbacks structure.
|
||||||
|
*
|
||||||
|
* @param cb Callback struct.
|
||||||
|
*
|
||||||
|
* @return Zero on success or negative error code otherwise
|
||||||
|
*/
|
||||||
|
int bt_auth_cb_register(const struct bt_auth_cb *cb);
|
||||||
|
|
||||||
|
/** @brief Reply with entered passkey.
|
||||||
|
*
|
||||||
|
* This function should be called only after passkey_entry callback from
|
||||||
|
* bt_auth_cb structure was called.
|
||||||
|
*
|
||||||
|
* @param conn Connection object.
|
||||||
|
* @param passkey Entered passkey.
|
||||||
|
*
|
||||||
|
* @return Zero on success or negative error code otherwise
|
||||||
|
*/
|
||||||
|
int bt_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey);
|
||||||
|
|
||||||
|
/** @brief Cancel ongoing authenticated pairing.
|
||||||
|
*
|
||||||
|
* This function allows to cancel ongoing authenticated pairing.
|
||||||
|
*
|
||||||
|
* @param conn Connection object.
|
||||||
|
*
|
||||||
|
* @return Zero on success or negative error code otherwise
|
||||||
|
*/
|
||||||
|
int bt_auth_cancel(struct bt_conn *conn);
|
||||||
|
|
||||||
|
/** @brief Reply if passkey was confirmed by user.
|
||||||
|
*
|
||||||
|
* This function should be called only after passkey_confirm callback from
|
||||||
|
* bt_auth_cb structure was called. If passkey is confirmed to match then match
|
||||||
|
* should be true. Otherwise match should be false.
|
||||||
|
*
|
||||||
|
* @param conn Connection object.
|
||||||
|
* @param match True if passkey was confirmed to match, false otherwise.
|
||||||
|
*
|
||||||
|
* @return Zero on success or negative error code otherwise
|
||||||
|
*/
|
||||||
|
int bt_auth_passkey_confirm(struct bt_conn *conn, bool match);
|
||||||
|
|
||||||
|
#if defined(CONFIG_BLUETOOTH_BREDR)
|
||||||
|
/** @brief Reply with entered PIN code.
|
||||||
|
*
|
||||||
|
* This function should be called only after PIN code callback from
|
||||||
|
* bt_auth_cb structure was called. It's for legacy 2.0 devices.
|
||||||
|
*
|
||||||
|
* @param conn Connection object.
|
||||||
|
* @param pin Entered PIN code.
|
||||||
|
*
|
||||||
|
* @return Zero on success or negative error code otherwise
|
||||||
|
*/
|
||||||
|
int bt_auth_pincode_entry(struct bt_conn *conn, const char *pin);
|
||||||
|
#endif /* CONFIG_BLUETOOTH_BREDR */
|
||||||
|
#endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */
|
||||||
|
|
||||||
#endif /* __BT_CONN_H */
|
#endif /* __BT_CONN_H */
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <bluetooth/log.h>
|
#include <bluetooth/log.h>
|
||||||
#include <bluetooth/hci.h>
|
#include <bluetooth/hci.h>
|
||||||
#include <bluetooth/bluetooth.h>
|
#include <bluetooth/bluetooth.h>
|
||||||
|
#include <bluetooth/conn.h>
|
||||||
#include <bluetooth/driver.h>
|
#include <bluetooth/driver.h>
|
||||||
|
|
||||||
#include "hci_core.h"
|
#include "hci_core.h"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include <bluetooth/log.h>
|
#include <bluetooth/log.h>
|
||||||
#include <bluetooth/bluetooth.h>
|
#include <bluetooth/bluetooth.h>
|
||||||
|
#include <bluetooth/conn.h>
|
||||||
#include <bluetooth/hci.h>
|
#include <bluetooth/hci.h>
|
||||||
#include <bluetooth/driver.h>
|
#include <bluetooth/driver.h>
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <bluetooth/log.h>
|
#include <bluetooth/log.h>
|
||||||
#include <bluetooth/bluetooth.h>
|
#include <bluetooth/bluetooth.h>
|
||||||
|
#include <bluetooth/conn.h>
|
||||||
#include <bluetooth/hci.h>
|
#include <bluetooth/hci.h>
|
||||||
|
|
||||||
#include "hci_core.h"
|
#include "hci_core.h"
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <bluetooth/log.h>
|
#include <bluetooth/log.h>
|
||||||
#include <bluetooth/hci.h>
|
#include <bluetooth/hci.h>
|
||||||
#include <bluetooth/bluetooth.h>
|
#include <bluetooth/bluetooth.h>
|
||||||
|
#include <bluetooth/conn.h>
|
||||||
#include <bluetooth/driver.h>
|
#include <bluetooth/driver.h>
|
||||||
|
|
||||||
#include "hci_core.h"
|
#include "hci_core.h"
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <bluetooth/log.h>
|
#include <bluetooth/log.h>
|
||||||
#include <bluetooth/hci.h>
|
#include <bluetooth/hci.h>
|
||||||
#include <bluetooth/bluetooth.h>
|
#include <bluetooth/bluetooth.h>
|
||||||
|
#include <bluetooth/conn.h>
|
||||||
|
|
||||||
#if defined(CONFIG_TINYCRYPT_AES)
|
#if defined(CONFIG_TINYCRYPT_AES)
|
||||||
#include <tinycrypt/aes.h>
|
#include <tinycrypt/aes.h>
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <bluetooth/log.h>
|
#include <bluetooth/log.h>
|
||||||
#include <bluetooth/bluetooth.h>
|
#include <bluetooth/bluetooth.h>
|
||||||
|
#include <bluetooth/conn.h>
|
||||||
|
|
||||||
#include "hci_core.h"
|
#include "hci_core.h"
|
||||||
#include "conn_internal.h"
|
#include "conn_internal.h"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue