diff mbox series

[BlueZ,v2,1/2] client: Add client-side error decoding

Message ID 20250122113256.1107629-2-hadess@hadess.net (mailing list archive)
State New
Headers show
Series device: Better "Connect" debug | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Bastien Nocera Jan. 22, 2025, 11:31 a.m. UTC
The D-Bus errors returned in a number of cases aren't in human-readable
form, but instead exist as "codes" (listed in src/error.h).

This new function will allow us to convert those to human-readable form.
---
 Makefile.tools |  2 ++
 client/error.c | 36 ++++++++++++++++++++++++++++++++++++
 client/error.h | 11 +++++++++++
 3 files changed, 49 insertions(+)
 create mode 100644 client/error.c
 create mode 100644 client/error.h

Comments

bluez.test.bot@gmail.com Jan. 22, 2025, 12:30 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=927506

---Test result---

Test Summary:
CheckPatch                    PENDING   0.22 seconds
GitLint                       PENDING   0.20 seconds
BuildEll                      PASS      20.35 seconds
BluezMake                     PASS      1541.57 seconds
MakeCheck                     PASS      13.32 seconds
MakeDistcheck                 PASS      159.16 seconds
CheckValgrind                 PASS      214.70 seconds
CheckSmatch                   PASS      270.60 seconds
bluezmakeextell               PASS      98.24 seconds
IncrementalBuild              PENDING   0.25 seconds
ScanBuild                     PASS      858.86 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/Makefile.tools b/Makefile.tools
index 0dca43327fdd..41b4b4f0545f 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -10,6 +10,8 @@  client_bluetoothctl_SOURCES = client/main.c \
 					client/advertising.c \
 					client/adv_monitor.h \
 					client/adv_monitor.c \
+					client/error.h \
+					client/error.c \
 					client/gatt.h client/gatt.c \
 					client/admin.h client/admin.c \
 					client/player.h client/player.c \
diff --git a/client/error.c b/client/error.c
new file mode 100644
index 000000000000..975e4030dfc0
--- /dev/null
+++ b/client/error.c
@@ -0,0 +1,36 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2025 Bastien Nocera <hadess@hadess.net>
+ *
+ *
+ */
+
+#include <stddef.h>
+#include <glib.h>
+#include "error.h"
+
+struct {
+	const char *error_code;
+	const char *str;
+} error_codes[] = {
+	{ "br-connection-profile-unavailable", "Exhausted the list of BR/EDR profiles to connect to" },
+	{ "br-connection-busy", "Cannot connect, connection busy" },
+	{ "br-connection-adapter-not-powered", "Cannot connect, adapter is not powered" },
+};
+
+const char *error_code_to_str(const char *error_code)
+{
+	unsigned int i;
+
+	if (error_code == NULL)
+		return NULL;
+
+	for (i = 0; i < G_N_ELEMENTS(error_codes); i++) {
+		if (g_str_equal(error_codes[i].error_code, error_code))
+			return error_codes[i].str;
+	}
+	return error_code;
+}
diff --git a/client/error.h b/client/error.h
new file mode 100644
index 000000000000..402117f3305b
--- /dev/null
+++ b/client/error.h
@@ -0,0 +1,11 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2025 Bastien Nocera <hadess@hadess.net>
+ *
+ *
+ */
+
+const char *error_code_to_str(const char *error_code);