mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Destroy DeviceWatcher _after_ stopping discovery.
This lets DeviceWatcher receive InterfacesRemoved signals so that we can potentially get rid of lost devices.
This commit is contained in:
@@ -419,16 +419,17 @@ BleV2Medium::StartScanning(const Uuid &service_uuid,
|
||||
<< "' and message '" << e.getMessage() << "'";
|
||||
}
|
||||
|
||||
active_adv_monitors_.erase(service_uuid);
|
||||
|
||||
auto &adapter = adapter_.GetBluezAdapterObject();
|
||||
absl::Status status;
|
||||
try {
|
||||
adapter.StopDiscovery();
|
||||
status = absl::OkStatus();
|
||||
} catch (const sdbus::Error &e) {
|
||||
DBUS_LOG_METHOD_CALL_ERROR(&adapter, "StopDiscovery", e);
|
||||
return absl::InternalError(e.getMessage());
|
||||
status = absl::InternalError(e.getMessage());
|
||||
}
|
||||
return absl::OkStatus();
|
||||
active_adv_monitors_.erase(service_uuid);
|
||||
return status;
|
||||
}});
|
||||
}
|
||||
|
||||
|
||||
@@ -81,15 +81,16 @@ bool BluetoothClassicMedium::StopDiscovery() {
|
||||
auto &adapter = adapter_.GetBluezAdapterObject();
|
||||
NEARBY_LOGS(INFO) << __func__ << "Stopping discovery on "
|
||||
<< adapter.getObjectPath();
|
||||
device_watcher_ = nullptr;
|
||||
auto ret = true;
|
||||
try {
|
||||
adapter.StopDiscovery();
|
||||
} catch (const sdbus::Error &e) {
|
||||
DBUS_LOG_METHOD_CALL_ERROR(&adapter, "StopDiscovery", e);
|
||||
return false;
|
||||
ret = false;
|
||||
}
|
||||
device_watcher_ = nullptr;
|
||||
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
|
||||
|
||||
Reference in New Issue
Block a user