From 17fff52ab12fe874468cf455795c42f42341ab89 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 18 Feb 2013 11:32:50 +0200 Subject: [PATCH] tools: btmgmt: Add initial stubs for converting to new mgmt API --- Makefile.tools | 4 +++- tools/btmgmt.c | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Makefile.tools b/Makefile.tools index bda4465e1..4d4568203 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -168,7 +168,9 @@ tools_hcieventmask_LDADD = lib/libbluetooth-private.la tools_hwdb_LDADD = lib/libbluetooth-private.la -tools_btmgmt_SOURCES = tools/btmgmt.c src/glib-helper.c src/eir.c +tools_btmgmt_SOURCES = tools/btmgmt.c src/glib-helper.c src/eir.c \ + src/shared/util.h src/shared/util.c \ + src/shared/mgmt.h src/shared/mgmt.c tools_btmgmt_LDADD = lib/libbluetooth-private.la @GLIB_LIBS@ tools_btiotest_SOURCES = tools/btiotest.c btio/btio.h btio/btio.c diff --git a/tools/btmgmt.c b/tools/btmgmt.c index 6cde49e6d..55cf9adcd 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -42,6 +42,7 @@ #include +#include "src/shared/mgmt.h" #include "glib-helper.h" #include "lib/mgmt.h" #include "eir.h" @@ -1974,6 +1975,7 @@ int main(int argc, char *argv[]) int opt, i, mgmt_sk; uint16_t index = MGMT_INDEX_NONE; struct pollfd pollfd; + struct mgmt *mgmt; while ((opt = getopt_long(argc, argv, "+hvi:", main_options, NULL)) != -1) { @@ -2024,6 +2026,13 @@ int main(int argc, char *argv[]) return -1; } + mgmt = mgmt_new_default(); + if (!mgmt) { + fprintf(stderr, "Unable to open mgmt_socket\n"); + close(mgmt_sk); + return -1; + } + pollfd.fd = mgmt_sk; pollfd.events = POLLIN; pollfd.revents = 0; @@ -2038,6 +2047,10 @@ int main(int argc, char *argv[]) pollfd.revents = 0; } + mgmt_cancel_all(mgmt); + mgmt_unregister_all(mgmt); + mgmt_unref(mgmt); + close(mgmt_sk); return 0; -- 2.11.0