diff --git a/src/adapter.c b/src/adapter.c
index bd61396..28e1d19 100644
--- a/src/adapter.c
+++ b/src/adapter.c
mgmt_version = rp->version;
mgmt_revision = btohs(rp->revision);
+ info("Bluetooth management interface %u.%u initialized",
+ mgmt_version, mgmt_revision);
+
+ if (mgmt_version < 1) {
+ error("Version 1.0 or later of management interface required");
+ abort();
+ }
+
DBG("version %u.%u", mgmt_version, mgmt_revision);
mgmt_register(mgmt_master, MGMT_EV_INDEX_ADDED, MGMT_INDEX_NONE,
diff --git a/src/mgmt.c b/src/mgmt.c
index ef93b98..c280fe3 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
static int mgmt_sock = -1;
static guint mgmt_watch = 0;
-static uint8_t mgmt_version = 0;
-static uint16_t mgmt_revision = 0;
-
static bool get_adapter_and_device(uint16_t index,
struct mgmt_addr_info *addr,
struct btd_adapter **adapter,
return true;
}
-static void read_version_complete(void *buf, size_t len)
-{
- struct mgmt_hdr hdr;
- struct mgmt_rp_read_version *rp = buf;
-
- if (len < sizeof(*rp)) {
- error("Too small read version complete event"
- " (probably an old kernel)");
- abort();
- }
-
- mgmt_revision = bt_get_le16(&rp->revision);
- mgmt_version = rp->version;
-
- info("Bluetooth management interface %u.%u initialized",
- mgmt_version, mgmt_revision);
-
- if (mgmt_version < 1) {
- error("Version 1.0 or later of management interface is needed");
- abort();
- }
-
- memset(&hdr, 0, sizeof(hdr));
- hdr.opcode = htobs(MGMT_OP_READ_INDEX_LIST);
- hdr.index = htobs(MGMT_INDEX_NONE);
-
- if (write(mgmt_sock, &hdr, sizeof(hdr)) < 0)
- error("Unable to read controller index list: %s (%d)",
- strerror(errno), errno);
-}
-
static void add_controller(uint16_t index)
{
struct controller_info *info;
switch (opcode) {
case MGMT_OP_READ_VERSION:
- read_version_complete(ev->data, len);
+ DBG("read_version complete");
break;
case MGMT_OP_READ_INDEX_LIST:
read_index_list_complete(ev->data, len);
}
memset(&hdr, 0, sizeof(hdr));
- hdr.opcode = htobs(MGMT_OP_READ_VERSION);
+ hdr.opcode = htobs(MGMT_OP_READ_INDEX_LIST);
hdr.index = htobs(MGMT_INDEX_NONE);
if (write(dd, &hdr, sizeof(hdr)) < 0) {
err = -errno;