Bluetooth: Move bt_connect_le to conn.c and rename it appropriately
This function operates on bt_conn so it should be in conn.c and exported through conn.h. Rename it with the appropriate bt_conn_* prefix. Change-Id: Id17c67f0e95cc1afb10aa7742b2d2ce0110ea616 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
e0e6416065
commit
a33047f7a5
5 changed files with 41 additions and 41 deletions
|
@ -120,17 +120,6 @@ int bt_start_scanning(uint8_t filter_dups, bt_le_scan_cb_t cb);
|
||||||
*/
|
*/
|
||||||
int bt_stop_scanning(void);
|
int bt_stop_scanning(void);
|
||||||
|
|
||||||
/** @brief Initiate an LE connection to a remote device.
|
|
||||||
*
|
|
||||||
* Allows initiate new LE link to remote peer using its address.
|
|
||||||
* Returns a new reference that the the caller is responsible for managing.
|
|
||||||
*
|
|
||||||
* @param peer Remote address.
|
|
||||||
*
|
|
||||||
* @return Valid connection object on success or NULL otherwise.
|
|
||||||
*/
|
|
||||||
struct bt_conn *bt_connect_le(const bt_addr_le_t *peer);
|
|
||||||
|
|
||||||
/** Security level. */
|
/** Security level. */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BT_SECURITY_LOW, /** No encryption and no authentication. */
|
BT_SECURITY_LOW, /** No encryption and no authentication. */
|
||||||
|
|
|
@ -91,6 +91,17 @@ const bt_addr_le_t *bt_conn_get_dst(const struct bt_conn *conn);
|
||||||
*/
|
*/
|
||||||
int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason);
|
int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason);
|
||||||
|
|
||||||
|
/** @brief Initiate an LE connection to a remote device.
|
||||||
|
*
|
||||||
|
* Allows initiate new LE link to remote peer using its address.
|
||||||
|
* Returns a new reference that the the caller is responsible for managing.
|
||||||
|
*
|
||||||
|
* @param peer Remote address.
|
||||||
|
*
|
||||||
|
* @return Valid connection object on success or NULL otherwise.
|
||||||
|
*/
|
||||||
|
struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer);
|
||||||
|
|
||||||
/** Connection callback structure */
|
/** Connection callback structure */
|
||||||
struct bt_conn_cb {
|
struct bt_conn_cb {
|
||||||
void (*connected)(struct bt_conn *conn);
|
void (*connected)(struct bt_conn *conn);
|
||||||
|
|
|
@ -538,3 +538,32 @@ int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason)
|
||||||
return -ENOTCONN;
|
return -ENOTCONN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer)
|
||||||
|
{
|
||||||
|
struct bt_conn *conn;
|
||||||
|
|
||||||
|
conn = bt_conn_lookup_addr_le(peer);
|
||||||
|
if (conn) {
|
||||||
|
switch (conn->state) {
|
||||||
|
case BT_CONN_CONNECT_SCAN:
|
||||||
|
case BT_CONN_CONNECT:
|
||||||
|
case BT_CONN_CONNECTED:
|
||||||
|
return conn;
|
||||||
|
default:
|
||||||
|
bt_conn_put(conn);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
conn = bt_conn_add(peer, BT_HCI_ROLE_MASTER);
|
||||||
|
if (!conn) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bt_conn_set_state(conn, BT_CONN_CONNECT_SCAN);
|
||||||
|
|
||||||
|
bt_le_scan_update();
|
||||||
|
|
||||||
|
return conn;
|
||||||
|
}
|
||||||
|
|
|
@ -1558,35 +1558,6 @@ int bt_hci_le_conn_update(uint16_t handle, uint16_t min, uint16_t max,
|
||||||
return bt_hci_cmd_send(BT_HCI_OP_LE_CONN_UPDATE, buf);
|
return bt_hci_cmd_send(BT_HCI_OP_LE_CONN_UPDATE, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct bt_conn *bt_connect_le(const bt_addr_le_t *peer)
|
|
||||||
{
|
|
||||||
struct bt_conn *conn;
|
|
||||||
|
|
||||||
conn = bt_conn_lookup_addr_le(peer);
|
|
||||||
if (conn) {
|
|
||||||
switch (conn->state) {
|
|
||||||
case BT_CONN_CONNECT_SCAN:
|
|
||||||
case BT_CONN_CONNECT:
|
|
||||||
case BT_CONN_CONNECTED:
|
|
||||||
return conn;
|
|
||||||
default:
|
|
||||||
bt_conn_put(conn);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
conn = bt_conn_add(peer, BT_HCI_ROLE_MASTER);
|
|
||||||
if (!conn) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bt_conn_set_state(conn, BT_CONN_CONNECT_SCAN);
|
|
||||||
|
|
||||||
bt_le_scan_update();
|
|
||||||
|
|
||||||
return conn;
|
|
||||||
}
|
|
||||||
|
|
||||||
int bt_hci_le_start_encryption(uint16_t handle, uint64_t rand, uint16_t ediv,
|
int bt_hci_le_start_encryption(uint16_t handle, uint64_t rand, uint16_t ediv,
|
||||||
const uint8_t *ltk)
|
const uint8_t *ltk)
|
||||||
{
|
{
|
||||||
|
|
|
@ -174,7 +174,7 @@ static void cmd_connect_le(int argc, char *argv[])
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
conn = bt_connect_le(&addr);
|
conn = bt_conn_create_le(&addr);
|
||||||
|
|
||||||
if (!conn) {
|
if (!conn) {
|
||||||
printk("Connection failed\n");
|
printk("Connection failed\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue