Skip to content

Commit

Permalink
gattlib: Catch connectio timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviermartin committed Mar 5, 2024
1 parent 00cbc1a commit ea1fe15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dbus/gattlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions gattlib-py/gattlib/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def __init__(self, domain: int, code: int) -> None:
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:
Expand Down

0 comments on commit ea1fe15

Please sign in to comment.