mgmt: add support for connect failed event

This commit is contained in:
Johan Hedberg 2011-01-21 10:57:09 +02:00
parent 1d87257dc5
commit d6fda82e31
3 changed files with 45 additions and 0 deletions

View File

@ -334,3 +334,11 @@ Device Disconnected Event
Event Code 0x000C
Event Parameters Controller_Index (2 Octets)
Address (6 Octets)
Connect Failed Event
====================
Event Code 0x000D
Event Parameters Controller_Index (2 Octets)
Address (6 Octets)
Status (1 Octet)

View File

@ -193,3 +193,10 @@ struct mgmt_ev_device_disconnected {
uint16_t index;
bdaddr_t bdaddr;
} __packed;
#define MGMT_EV_CONNECT_FAILED 0x000D
struct mgmt_ev_connect_failed {
uint16_t index;
bdaddr_t bdaddr;
uint8_t status;
} __packed;

View File

@ -481,6 +481,33 @@ static void mgmt_device_disconnected(int sk, void *buf, size_t len)
btd_event_disconn_complete(&info->bdaddr, &ev->bdaddr);
}
static void mgmt_connect_failed(int sk, void *buf, size_t len)
{
struct mgmt_ev_connect_failed *ev = buf;
struct controller_info *info;
uint16_t index;
char addr[18];
if (len < sizeof(*ev)) {
error("Too small connect_failed event");
return;
}
index = btohs(bt_get_unaligned(&ev->index));
ba2str(&ev->bdaddr, addr);
DBG("hci%u %s status %u", index, addr, ev->status);
if (index > max_index) {
error("Unexpected index %u in connect_failed event", index);
return;
}
info = &controllers[index];
btd_event_conn_complete(&info->bdaddr, ev->status, &ev->bdaddr);
}
static void uuid_to_uuid128(uuid_t *uuid128, const uuid_t *uuid)
{
if (uuid->type == SDP_UUID16)
@ -970,6 +997,9 @@ static gboolean mgmt_event(GIOChannel *io, GIOCondition cond, gpointer user_data
case MGMT_EV_DEVICE_DISCONNECTED:
mgmt_device_disconnected(sk, buf + MGMT_HDR_SIZE, len);
break;
case MGMT_EV_CONNECT_FAILED:
mgmt_connect_failed(sk, buf + MGMT_HDR_SIZE, len);
break;
default:
error("Unknown Management opcode %u", opcode);
break;