static void stop_le_discovery_complete(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
- struct btd_adapter *adapter = user_data;
+ struct watch_client *client = user_data;
+ struct btd_adapter *adapter = client->adapter;
+ DBusMessage *reply;
DBG("status 0x%02x", status);
- if (status == MGMT_STATUS_SUCCESS) {
- adapter->discovery_type &= (~0x06);
- DBG("Discovery Type 0x%02x", adapter->discovery_type);
+ if (status != MGMT_STATUS_SUCCESS) {
+ if (client->msg) {
+ reply = btd_error_busy(client->msg);
+ g_dbus_send_message(dbus_conn, reply);
+ }
- adapter->filtered_discovery = false;
- adapter->no_scan_restart_delay = false;
- adapter->le_discovering = false;
- g_dbus_emit_property_changed(dbus_conn, adapter->path,
- ADAPTER_INTERFACE, "LEDiscovering");
+ goto done;
+ }
- if (adapter->discovery_list == NULL && adapter->le_discovery_list == NULL) {
- adapter->discovery_enable = 0x00;
- trigger_passive_scanning(adapter);
- }
+ if (client->msg) {
+ reply = g_dbus_create_reply(client->msg, DBUS_TYPE_INVALID);
+ g_dbus_send_message(dbus_conn, reply);
+ }
+
+ adapter->discovery_type &= (~0x06);
+ DBG("Discovery Type 0x%02x", adapter->discovery_type);
+
+ adapter->filtered_discovery = false;
+ adapter->no_scan_restart_delay = false;
+ adapter->le_discovering = false;
+ g_dbus_emit_property_changed(dbus_conn, adapter->path,
+ ADAPTER_INTERFACE, "LEDiscovering");
+
+ if (adapter->discovery_list == NULL && adapter->le_discovery_list == NULL) {
+ adapter->discovery_enable = 0x00;
+ trigger_passive_scanning(adapter);
}
+
+done:
+ /*
+ * The destroy function will cleanup the client information and
+ * also remove it from the list of discovery clients.
+ */
+ g_dbus_remove_watch(dbus_conn, client->watch);
}
#else
DBG("cp.type %d", cp.type);
/*
- * The destroy function will cleanup the client information and
- * also remove it from the list of discovery clients.
- */
- g_dbus_remove_watch(dbus_conn, client->watch);
-
- /*
* As long as other discovery clients are still active, just
- * return success.
+ * clenup client info and return success.
*/
- DBG("cp.type %d", cp.type);
- DBG("adapter->le_discovery_list %d", adapter->discovery_type);
- if (adapter->le_discovery_list)
+ DBG("adapter->le_discovery_list %p", adapter->le_discovery_list);
+ if (g_slist_next(adapter->le_discovery_list)) {
+ /*
+ * The destroy function will cleanup the client information and
+ * also remove it from the list of discovery clients.
+ */
+ g_dbus_remove_watch(dbus_conn, client->watch);
return dbus_message_new_method_return(msg);
+ }
/*
* In the idle phase of a discovery, there is no need to stop it
ADAPTER_INTERFACE, "LEDiscovering");
trigger_passive_scanning(adapter);
-
return dbus_message_new_method_return(msg);
}
+
DBG("adapter->discovery_type %d", adapter->discovery_type);
cp.type = 0x06;
DBG("cp.type %d", cp.type);
mgmt_send(adapter->mgmt, MGMT_OP_STOP_LE_DISCOVERY,
adapter->dev_id, sizeof(cp), &cp,
- stop_le_discovery_complete, adapter, NULL);
+ stop_le_discovery_complete, client, NULL);
- return dbus_message_new_method_return(msg);
+ client->msg = dbus_message_ref(msg);
+ return NULL;
}
static DBusMessage *adapter_set_advertising(DBusConnection *conn,