Skip to content

Commit

Permalink
Disconnect bluetooth device before retrying bluetooth connection
Browse files Browse the repository at this point in the history
  • Loading branch information
nisargjhaveri committed Mar 27, 2024
1 parent 6e6a1da commit 8b76527
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions aa_wireless_dongle/package/aawg/src/bluetoothHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,15 @@ void BluetoothHandler::connectDevice() {

std::shared_ptr<DBus::ObjectProxy> bluezDevice = m_connection->create_object_proxy(BLUEZ_BUS_NAME, device_path);
DBus::MethodProxy connectProfile = *(bluezDevice->create_method<void(std::string)>(INTERFACE_BLUEZ_DEVICE, "ConnectProfile"));
DBus::MethodProxy disconnect = *(bluezDevice->create_method<void()>(INTERFACE_BLUEZ_DEVICE, "Disconnect"));

std::shared_ptr<DBus::PropertyProxy<bool>> deviceConnected = bluezDevice->create_property<bool>(INTERFACE_BLUEZ_DEVICE, "Connected");

try {
if (deviceConnected) {
Logger::instance()->info("Bluetooth device already connected, disconnecting\n");
disconnect();
}
connectProfile(HSP_AG_UUID);
Logger::instance()->info("Bluetooth connected to the device\n");
return;
Expand Down

0 comments on commit 8b76527

Please sign in to comment.