diff options
author | Mikel Astiz <mikel.astiz@bmw-carit.de> | 2012-08-17 11:10:55 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-08-17 12:26:30 +0300 |
commit | 902e9f2de2ac6d0a96fdeca9858e15738b1ff5d7 (patch) | |
tree | b6b5bf42f0b1c5c6941993598007ffb8f1b9757c /tools | |
parent | ee3b0b2b3326e883790685e51ebb0c9a9f8332c9 (diff) | |
download | bluez-902e9f2de2ac6d0a96fdeca9858e15738b1ff5d7.tar.gz |
mgmt: Add reason to device disconnect event
Extend the management API with the disconnect reason, as now reported
by the Kernel in MGMT_EV_DEVICE_DISCONNECTED.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/btmgmt.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/btmgmt.c b/tools/btmgmt.c index c6d48d31d..f06f0bff0 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -343,9 +343,10 @@ static int mgmt_connected(int mgmt_sk, uint16_t index, } static int mgmt_disconnected(int mgmt_sk, uint16_t index, - struct mgmt_addr_info *ev, uint16_t len) + struct mgmt_ev_device_disconnected *ev, + uint16_t len) { - if (len != sizeof(*ev)) { + if (len < sizeof(struct mgmt_addr_info)) { fprintf(stderr, "Invalid disconnected event length (%u bytes)\n", len); return -EINVAL; @@ -353,9 +354,16 @@ static int mgmt_disconnected(int mgmt_sk, uint16_t index, if (monitor) { char addr[18]; - ba2str(&ev->bdaddr, addr); - printf("hci%u %s type %s disconnected\n", index, addr, - typestr(ev->type)); + uint8_t reason; + + if (len < sizeof(*ev)) + reason = MGMT_DEV_DISCONN_UNKNOWN; + else + reason = ev->reason; + + ba2str(&ev->addr.bdaddr, addr); + printf("hci%u %s type %s disconnected with reason %u\n", + index, addr, typestr(ev->addr.type), reason); } return 0; |