Skip to content

Commit

Permalink
device: Consider service state on device_is_connected
Browse files Browse the repository at this point in the history
This checks if there is any service connected on device_is_connected
since some profiles maybe probed using advertising data which doesn't
require a connection.
  • Loading branch information
Vudentz committed Feb 27, 2024
1 parent ade2b97 commit 44d3f67
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/device.c
Expand Up @@ -3225,7 +3225,11 @@ uint8_t btd_device_get_bdaddr_type(struct btd_device *dev)

bool btd_device_is_connected(struct btd_device *dev)
{
return dev->bredr_state.connected || dev->le_state.connected;
if (dev->bredr_state.connected || dev->le_state.connected)
return true;

return find_service_with_state(dev->services,
BTD_SERVICE_STATE_CONNECTED);
}

static void clear_temporary_timer(struct btd_device *dev)
Expand Down Expand Up @@ -3276,6 +3280,13 @@ static bool device_disappeared(gpointer user_data)
{
struct btd_device *dev = user_data;

if (btd_device_is_connected(dev)) {
char addr[18];
ba2str(&dev->bdaddr, addr);
DBG("Device %s is marked as connected", dev->path);
return TRUE;
}

/* If there are services connecting restart the timer to give more time
* for the service to either complete the connection or disconnect.
*/
Expand Down

0 comments on commit 44d3f67

Please sign in to comment.