Bluetooth: Track role for connections
When a connection is made, track its role. Only peripherial/slave role may trigger update of L2CAP connection parameters. Change-Id: I72244581650248c7b020c9e5673b73ce46e7399d Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
parent
875d519948
commit
df4257f174
4 changed files with 11 additions and 4 deletions
|
@ -315,6 +315,9 @@ struct bt_hci_evt_le_meta_event {
|
|||
uint8_t subevent;
|
||||
} __packed;
|
||||
|
||||
#define BT_HCI_ROLE_MASTER 0x00
|
||||
#define BT_HCI_ROLE_SLAVE 0x01
|
||||
|
||||
#define BT_HCI_EVT_LE_CONN_COMPLETE 0x01
|
||||
struct bt_hci_evt_le_conn_complete {
|
||||
uint8_t status;
|
||||
|
|
|
@ -243,7 +243,7 @@ static void conn_tx_fiber(int arg1, int arg2)
|
|||
bt_conn_put(conn);
|
||||
}
|
||||
|
||||
struct bt_conn *bt_conn_add(struct bt_dev *dev, uint16_t handle)
|
||||
struct bt_conn *bt_conn_add(struct bt_dev *dev, uint16_t handle, uint8_t role)
|
||||
{
|
||||
struct bt_conn *conn = NULL;
|
||||
int i;
|
||||
|
@ -265,13 +265,16 @@ struct bt_conn *bt_conn_add(struct bt_dev *dev, uint16_t handle)
|
|||
conn->state = BT_CONN_CONNECTED;
|
||||
conn->handle = handle;
|
||||
conn->dev = dev;
|
||||
conn->role = role;
|
||||
|
||||
nano_fifo_init(&conn->tx_queue);
|
||||
|
||||
fiber_start(conn->tx_stack, sizeof(conn->tx_stack), conn_tx_fiber,
|
||||
(int)bt_conn_get(conn), 0, 7, 0);
|
||||
|
||||
bt_l2cap_update_conn_param(conn);
|
||||
if (role == BT_HCI_ROLE_SLAVE) {
|
||||
bt_l2cap_update_conn_param(conn);
|
||||
}
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ struct bt_conn_l2cap {
|
|||
struct bt_conn {
|
||||
struct bt_dev *dev;
|
||||
uint16_t handle;
|
||||
uint8_t role;
|
||||
|
||||
bt_addr_le_t src;
|
||||
bt_addr_le_t dst;
|
||||
|
@ -79,7 +80,7 @@ void bt_conn_recv(struct bt_conn *conn, struct bt_buf *buf, uint8_t flags);
|
|||
void bt_conn_send(struct bt_conn *conn, struct bt_buf *buf);
|
||||
|
||||
/* Add a new connection */
|
||||
struct bt_conn *bt_conn_add(struct bt_dev *dev, uint16_t handle);
|
||||
struct bt_conn *bt_conn_add(struct bt_dev *dev, uint16_t handle, uint8_t role);
|
||||
|
||||
/* Delete an existing connection */
|
||||
void bt_conn_del(struct bt_conn *conn);
|
||||
|
|
|
@ -588,7 +588,7 @@ static void le_conn_complete(struct bt_buf *buf)
|
|||
return;
|
||||
}
|
||||
|
||||
conn = bt_conn_add(&dev, handle);
|
||||
conn = bt_conn_add(&dev, handle, evt->role);
|
||||
if (!conn) {
|
||||
BT_ERR("Unable to add new conn for handle %u\n", handle);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue