From a587aa9dfa08bfceb9b59b5340f738e23e96871a Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Thu, 4 Apr 2024 21:54:28 +0200 Subject: [PATCH] gattlib_connect: Set the device has DISCONNECTED on error --- dbus/gattlib.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dbus/gattlib.c b/dbus/gattlib.c index d4ee3cc..0bf3fe7 100644 --- a/dbus/gattlib.c +++ b/dbus/gattlib.c @@ -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 { @@ -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; }