Bluetooth: Add bt_conn_get_info

Change-Id: I32fd5b1c159623c59a353e1084f47f3cc9f704e6
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2015-11-27 15:00:52 +02:00 committed by Anas Nashif
commit c05ea4c21c
3 changed files with 64 additions and 8 deletions

View file

@ -726,6 +726,29 @@ const bt_addr_le_t *bt_conn_get_dst(const struct bt_conn *conn)
return &conn->le.dst;
}
int bt_conn_get_info(const struct bt_conn *conn, struct bt_conn_info *info)
{
if (conn->state != BT_CONN_CONNECTED) {
return -ENOTCONN;
}
info->type = conn->type;
switch (conn->type) {
case BT_CONN_TYPE_LE:
if (conn->role == BT_HCI_ROLE_MASTER) {
info->le.src = &conn->le.init_addr;
info->le.dst = &conn->le.resp_addr;
} else {
info->le.src = &conn->le.resp_addr;
info->le.dst = &conn->le.init_addr;
}
return 0;
}
return -EINVAL;
}
void bt_conn_set_auto_conn(struct bt_conn *conn, bool auto_conn)
{
if (auto_conn) {