gattlib: Catch connectio timeout

pull/185/merge 0.4.5
Olivier Martin 2024-03-05 22:46:38 +01:00
parent 00cbc1ab87
commit ea1fe15857
2 changed files with 7 additions and 2 deletions

View File

@ -228,11 +228,14 @@ int gattlib_connect(void *adapter, const char *dst,
// pairing information about the targetted device.
GATTLIB_LOG(GATTLIB_ERROR, "Device '%s' cannot be found (%d, %d)", dst, error->domain, error->code);
ret = GATTLIB_NOT_FOUND;
} else {
} else if ((error->domain == 238) && (error->code == 60952)) {
GATTLIB_LOG(GATTLIB_ERROR, "Device '%s': %s", dst, error->message);
ret = GATTLIB_ERROR_TIMEOUT;
} else {
GATTLIB_LOG(GATTLIB_ERROR, "Device connected error (device:%s): %s",
conn_context->device_object_path,
error->message);
ret = GATTLIB_ERROR_DBUS_WITH_ERROR(error);;
ret = GATTLIB_ERROR_DBUS_WITH_ERROR(error);
}
g_error_free(error);

View File

@ -60,6 +60,8 @@ class DBusError(GattlibException):
def __str__(self) -> str:
if self.domain == 238 and self.code == 60964:
return f"DBus Error: le-connection-abort-by-local"
elif self.domain == 238 and self.code == 60952:
return f"DBus Error: Timeout was reached"
elif self.domain == 238 and self.code == 60964:
return f"DBus Error: Timeout was reached"
else: