diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2012-10-22 13:01:12 +0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-10-22 17:36:38 +0300 |
commit | f45ee9ff351880f673a5ce7f7644477e0a7df826 (patch) | |
tree | ee134818dd883581297ccbd386cbadadc198f79d | |
parent | 6386e2d2c94779651718d0a558ecbdbd40e27696 (diff) |
btmgmt: Add basic EIR parsing
-rw-r--r-- | Makefile.tools | 2 | ||||
-rw-r--r-- | tools/btmgmt.c | 16 |
2 files changed, 15 insertions, 3 deletions
diff --git a/Makefile.tools b/Makefile.tools index e1f693c7..ec79cea6 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -43,7 +43,7 @@ tools_hcieventmask_LDADD = lib/libbluetooth-private.la noinst_PROGRAMS += tools/btmgmt monitor/btmon emulator/btvirt emulator/b1ee -tools_btmgmt_SOURCES = tools/btmgmt.c src/glib-helper.c +tools_btmgmt_SOURCES = tools/btmgmt.c src/glib-helper.c src/eir.c tools_btmgmt_LDADD = lib/libbluetooth-private.la @GLIB_LIBS@ monitor_btmon_SOURCES = monitor/main.c monitor/bt.h \ diff --git a/tools/btmgmt.c b/tools/btmgmt.c index f06f0bff..2084b59f 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -43,6 +43,7 @@ #include <glib.h> #include "glib-helper.h" +#include "eir.h" static bool monitor = false; static bool discovery = false; @@ -462,6 +463,7 @@ static int mgmt_device_found(int mgmt_sk, uint16_t index, { uint32_t flags; uint16_t eir_len; + struct eir_data eir; if (len < sizeof(*ev)) { fprintf(stderr, @@ -478,14 +480,24 @@ static int mgmt_device_found(int mgmt_sk, uint16_t index, return -EINVAL; } + memset(&eir, 0, sizeof(eir)); + eir_parse(&eir, ev->eir, eir_len); + if (monitor || discovery) { char addr[18]; ba2str(&ev->addr.bdaddr, addr); printf("hci%u dev_found: %s type %s rssi %d " - "flags 0x%04x eir_len %u\n", index, addr, - typestr(ev->addr.type), ev->rssi, flags, eir_len); + "flags 0x%04x ", index, addr, + typestr(ev->addr.type), ev->rssi, flags); + + if (eir.name) + printf("name %s\n", eir.name); + else + printf("eir_len %u\n", eir_len); } + eir_data_free(&eir); + if (discovery && (flags & MGMT_DEV_FOUND_CONFIRM_NAME)) { struct mgmt_cp_confirm_name cp; |