OSDN Git Service

mgmt: add support for connect failed event
authorJohan Hedberg <johan.hedberg@nokia.com>
Fri, 21 Jan 2011 08:57:09 +0000 (10:57 +0200)
committerJohan Hedberg <johan.hedberg@nokia.com>
Fri, 21 Jan 2011 08:57:41 +0000 (10:57 +0200)
doc/mgmt-api.txt
lib/mgmt.h
plugins/mgmtops.c

index 4ee23ff..00b2b37 100644 (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)
index b40b8fc..11811cd 100644 (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;
index 8950cf9..d80f29d 100644 (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;