Adding stop_discovery functionality to hciops plugin.
PATCH 1/1 Adding stop_discovery functionality to hciops plugin.
From: Alok Barsode <[email protected]>
--- plugins/hciops.c | 27 +++++++++ src/adapter.c | 51 +++++++---------- src/adapter.h | 1 + src/dbus-hci.c | 157 ------------------------------------------------------ src/dbus-hci.h | 5 -- 5 files changed, 49 insertions(+), 192 deletions(-)
plugins/hciops.c +27 -0
@@ -602,6 +602,32 @@ static int hciops_start_discovery(int index, gboolean periodic)return err; } +static int hciops_stop_discovery (int index) +{ +struct hci_dev_info di; +int dd, err =0 ; + +if (hci_devinfo (index, &di) <0 ) +return -errno; + + dd =hci_open_dev (index); +if (dd <0 ) +return -EIO ; + +if (hci_test_bit (HCI_INQUIRY , &di.flags)) + err =hci_send_cmd (dd,OGF_LINK_CTL ,OCF_INQUIRY_CANCEL , +0 ,0 ); +else + err =hci_send_cmd (dd,OGF_LINK_CTL ,OCF_EXIT_PERIODIC_INQUIRY , +0 ,0 ); +if (err <0 ) + err = -errno; + +hci_close_dev (dd); + +return err; +} +static struct btd_adapter_ops hci_ops = { .setup = hciops_setup, .cleanup = hciops_cleanup,
@@ -612,6 +638,7 @@ static struct btd_adapter_ops hci_ops = { .set_discoverable = hciops_discoverable, .set_limited_discoverable = hciops_set_limited_discoverable, .start_discovery = hciops_start_discovery, + .stop_discovery = hciops_stop_discovery, };static int hciops_init (void )
src/adapter.c +21 -30
83 lines not on this page · raw message
src/adapter.h +1 -0
@@ -161,6 +161,7 @@ struct btd_adapter_ops {int (*set_limited_discoverable) (int index,const uint8_t *cls,gboolean limited);int (*start_discovery) (int index,gboolean periodic); +int (*stop_discovery) (int index); };int btd_register_adapter_ops (struct btd_adapter_ops *btd_adapter_ops);
src/dbus-hci.c +0 -157
163 lines not on this page · raw message
src/dbus-hci.h +0 -5
@@ -52,14 +52,9 @@ int hcid_dbus_link_key_notify(bdaddr_t *local, bdaddr_t *peer,DBusMessage *new_authentication_return (DBusMessage *msg,uint8_t status); -int cancel_discovery (struct btd_adapter *adapter); -int cancel_periodic_discovery (struct btd_adapter *adapter); -int set_service_classes (int dd,const uint8_t *cls,uint8_t value);int set_major_and_minor_class (int dd,const uint8_t *cls,uint8_t major,uint8_t minor); -int inquiry_cancel (int dd,int to); -int periodic_inquiry_exit (int dd,int to);const char *class_to_icon (uint32_t class);
Signature · 1 line
1.5.6.3