Skip to content

Commit

Permalink
gattlib_connect: Set the device has DISCONNECTED on error
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviermartin committed Apr 4, 2024
1 parent 67ff1de commit a587aa9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dbus/gattlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ int gattlib_connect(void *adapter, const char *dst,
if (device == NULL) {
ret = GATTLIB_ERROR_DBUS;
if (error) {
ret = GATTLIB_ERROR_DBUS_WITH_ERROR(error);;
ret = GATTLIB_ERROR_DBUS_WITH_ERROR(error);
GATTLIB_LOG(GATTLIB_ERROR, "Failed to connect to DBus Bluez Device: %s", error->message);
g_error_free(error);
} else {
Expand Down Expand Up @@ -258,6 +258,10 @@ int gattlib_connect(void *adapter, const char *dst,
}

g_error_free(error);

// Fail to connect. Mark the device has disconnected to be able to reconnect
gattlib_device_set_state(connection->adapter, connection->device_id, DISCONNECTED);

goto FREE_DEVICE;
}

Expand Down

0 comments on commit a587aa9

Please sign in to comment.