device: Better error when no BR/EDR profiles can be connected to
Add a more precise error when there are no BR/EDR profiles to connect
to. This is useful when trying to connect to a particular device, and
there are no relevant profiles to connect to on the bearer.
diff --git a/src/error.c b/src/error.c
index 1214516..41dd904 100644
--- a/src/error.c
+++ b/src/error.c
@@ -128,6 +128,14 @@
"%s", str);
}
+DBusMessage *btd_error_profile_unavailable(DBusMessage *msg)
+{
+ return g_dbus_create_error(msg, ERROR_INTERFACE
+ ".ProfileUnavailable",
+ "Exhausted the list of BR/EDR "
+ "profiles to connect to");
+}
+
DBusMessage *btd_error_failed(DBusMessage *msg, const char *str)
{
return g_dbus_create_error(msg, ERROR_INTERFACE
@@ -142,8 +150,6 @@
return ERR_BREDR_CONN_ALREADY_CONNECTED;
case EHOSTDOWN:
return ERR_BREDR_CONN_PAGE_TIMEOUT;
- case ENOPROTOOPT:
- return ERR_BREDR_CONN_PROFILE_UNAVAILABLE;
case EIO:
return ERR_BREDR_CONN_CREATE_SOCKET;
case EINVAL:
@@ -220,7 +226,12 @@
DBusMessage *btd_error_bredr_errno(DBusMessage *msg, int err)
{
- return btd_error_failed(msg, btd_error_bredr_str(err));
+ switch (err) {
+ case ENOPROTOOPT:
+ return btd_error_profile_unavailable(msg);
+ default:
+ return btd_error_failed(msg, btd_error_bredr_str(err));
+ }
}
DBusMessage *btd_error_le_errno(DBusMessage *msg, int err)
diff --git a/src/error.h b/src/error.h
index 8ac521a..64297f4 100644
--- a/src/error.h
+++ b/src/error.h
@@ -19,8 +19,6 @@
#define ERR_BREDR_CONN_ALREADY_CONNECTED "br-connection-already-"\
"connected"
#define ERR_BREDR_CONN_PAGE_TIMEOUT "br-connection-page-timeout"
-#define ERR_BREDR_CONN_PROFILE_UNAVAILABLE "br-connection-profile-"\
- "unavailable"
#define ERR_BREDR_CONN_SDP_SEARCH "br-connection-sdp-search"
#define ERR_BREDR_CONN_CREATE_SOCKET "br-connection-create-socket"
#define ERR_BREDR_CONN_INVALID_ARGUMENTS "br-connection-invalid-"\
@@ -85,6 +83,7 @@
DBusMessage *btd_error_agent_not_available(DBusMessage *msg);
DBusMessage *btd_error_not_ready(DBusMessage *msg);
DBusMessage *btd_error_not_ready_str(DBusMessage *msg, const char *str);
+DBusMessage *btd_error_profile_unavailable(DBusMessage *msg);
DBusMessage *btd_error_failed(DBusMessage *msg, const char *str);
DBusMessage *btd_error_bredr_errno(DBusMessage *msg, int err);
DBusMessage *btd_error_le_errno(DBusMessage *msg, int err);