shared/gatt-client: Use parent debug_callback if not set on clone
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH 1/4 shared/gatt-client: Use parent debug_callback if not set on clone
From: Luiz Augusto von Dentz <[email protected]>
If clone don't have a dedicated callback set use its parent so users of bt_gatt_client_clone don't have to keep setting the same callback for all clone instances.
--- src/shared/gatt-client.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
src/shared/gatt-client.c +17 -3
@@ -38,7 +38,8 @@#define GATT_SVC_UUID 0x1801#define SVC_CHNGD_UUID 0x2a05 #define DBG(_client, _format, arg...) \ - gatt_log(_client, "%s:%s() " _format, __FILE__, __func__, ## arg) + gatt_log(_client, "[%p] %s:%s() " _format, _client, __FILE__, \ + __func__, ## arg)struct ready_cb {bt_gatt_client_callback_t callback;
@@ -357,15 +358,28 @@ static void discovery_op_free(struct discovery_op *op)static bool read_db_hash (struct discovery_op *op); +static void gatt_log_va (struct bt_gatt_client *client,const char *format, +va_list va) +{ +if (!client || !format) +return ; + +if (client->debug_callback) +util_debug_va (client->debug_callback, client->debug_data, + format, va); +else +gatt_log_va (client->parent, format, va); +} +static void gatt_log (struct bt_gatt_client *client,const char *format, ...) {va_list ap; -if (!client || !format || !client->debug_callback) +if (!client || !format)return ;va_start (ap, format); -util_debug_va (client->debug_callback, client->debug_data, format, ap); +gatt_log_va (client, format, ap);va_end (ap); }
Signature · 1 line
2.37.3
Luiz Augusto von Dentz
maintainerPATCH 2/4 shared/gatt-client: Allow registering with NULL callback
From: Luiz Augusto von Dentz <[email protected]>
This makes bt_gatt_client_register_notify allow registering with NULL callback which is interpreted as the CCC write has already been performed therefore it won't be written again.
--- src/shared/gatt-client.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
src/shared/gatt-client.c +12 -4
@@ -1711,8 +1711,11 @@ static unsigned int register_notify(struct bt_gatt_client *client,* descriptor. */ chrc =notify_chrc_create (client, handle); -if (!chrc) +if (!chrc) { +DBG (client,"Unable to locate characteristic at 0x%04x" , + handle);return 0 ; + } }/* Fail if we've hit the maximum allowed notify sessions */
@@ -1750,9 +1753,10 @@ static unsigned int register_notify(struct bt_gatt_client *client, }/* -* If the ref count > 1, then notifications are already enabled. +* If the ref count > 1, ccc handle cannot be found or registration +* callback is not set consider notifications are already enabled. */ -if (chrc->notify_count >1 || !chrc->ccc_handle) { +if (chrc->notify_count >1 || !chrc->ccc_handle || !callback) {complete_notify_request (notify_data);return notify_data->id; }
@@ -2176,6 +2180,9 @@ static void notify_cb(struct bt_att_chan *chan, uint8_t opcode,struct bt_gatt_client *client = user_data;struct value_data data; +if (queue_isempty (client->notify_list)) +return ; +bt_gatt_client_ref (client);memset (&data,0 ,sizeof (data));
@@ -3670,7 +3677,8 @@ unsigned int bt_gatt_client_register_notify(struct bt_gatt_client *client, void *user_data, bt_gatt_client_destroy_func_t destroy) { -if (!client || !client->db || !chrc_value_handle || !callback) +if (!client || !client->db || !chrc_value_handle || + (!callback && !notify))return 0 ;if (client->in_svc_chngd)
Signature · 1 line
2.37.3
Luiz Augusto von Dentz
maintainerPATCH 3/4 attrib: Introduce g_attrib_attach_client
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This introduces g_attrib_attach_client which can be used to attach a bt_gatt_client instance to GAttr so it can be used to register notifications.
--- Makefile.am | 6 +++--- attrib/gattrib.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ attrib/gattrib.h | 2 ++ 3 files changed, 51 insertions(+), 3 deletions(-)
Makefile.am +3 -3
@@ -565,9 +565,9 @@ unit_tests += unit/test-gattrib unit_test_gattrib_SOURCES = unit/test-gattrib.c attrib/gattrib.c \ $(btio_sources) src/log.h src/log.c -unit_test_gattrib_LDADD = lib/libbluetooth-internal.la \ - src/libshared-glib.la \ - $(GLIB_LIBS) $(DBUS_LIBS) -ldl -lrt +unit_test_gattrib_LDADD = src/libshared-glib.la \ + lib/libbluetooth-internal.la \ + $(GLIB_LIBS) $(DBUS_LIBS) -ldl -lrt unit_tests += unit/test-bap
attrib/gattrib.c +46 -0
87 lines not on this page · raw message
attrib/gattrib.h +2 -0
@@ -19,6 +19,7 @@ extern "C" {#define GATTRIB_ALL_HANDLES 0x0000struct bt_att ;/* Forward declaration for compatibility */ +struct bt_gatt_client ;/* Forward declaration for compatibility */ struct _GAttrib ;typedef struct _GAttrib GAttrib ;
@@ -53,6 +54,7 @@ guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,uint8_t *g_attrib_get_buffer (GAttrib *attrib,size_t *len);gboolean g_attrib_set_mtu (GAttrib *attrib,int mtu); +gboolean g_attrib_attach_client (GAttrib *attrib,struct bt_gatt_client *client);gboolean g_attrib_unregister (GAttrib *attrib,guint id);gboolean g_attrib_unregister_all (GAttrib *attrib);
Signature · 1 line
2.37.3
Luiz Augusto von Dentz
maintainerPATCH 4/4 hog-lib: Fix not handling BT_ATT_OP_HANDLE_NFY_MULT
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This is a temporary fix for not handling BT_ATT_OP_HANDLE_NFY_MULT in GAttr so the code will use g_attrib_attach_client to attach the bt_gatt_client instance which is then used to register notifications including those sent with BT_ATT_OP_HANDLE_NFY_MULT.
--- profiles/input/hog-lib.c | 23 +++++++++++++++++++++-- src/device.c | 1 + 2 files changed, 22 insertions(+), 2 deletions(-)
profiles/input/hog-lib.c +21 -2
@@ -374,6 +374,15 @@ static void report_value_cb(const guint8 *pdu, guint16 len, gpointer user_data)error ("bt_uhid_send: %s (%d)" ,strerror (-err), -err); } +static void report_notify_destroy (void *user_data) +{ +struct report *report = user_data; + +DBG ("" ); + + report->notifyid =0 ; +} +static void report_ccc_written_cb (guint8 status,const guint8 *pdu,guint16 plen,gpointer user_data) {
@@ -393,7 +402,13 @@ static void report_ccc_written_cb(guint8 status, const guint8 *pdu, report->notifyid =g_attrib_register (hog->attrib,ATT_OP_HANDLE_NOTIFY , report->value_handle, - report_value_cb, report,NULL ); + report_value_cb, report, + report_notify_destroy); +if (!report->notifyid) { +error ("Unable to register report notification: handle 0x%04x" , + report->value_handle); + goto remove; + }DBG ("Report characteristic descriptor written: notifications enabled" );
@@ -1798,7 +1813,11 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt) r->notifyid =g_attrib_register (hog->attrib,ATT_OP_HANDLE_NOTIFY , r->value_handle, - report_value_cb, r,NULL ); + report_value_cb, r, + report_notify_destroy); +if (!r->notifyid) +error ("Unable to register report notification: " +"handle 0x%04x" , r->value_handle); }return true;
src/device.c +1 -0
@@ -5152,6 +5152,7 @@ static void gatt_client_init(struct btd_device *device) }bt_gatt_client_set_debug (device->client, gatt_debug,NULL ,NULL ); +g_attrib_attach_client (device->attrib, device->client);/* * Notify notify existing service about the new connection so they can
Signature · 1 line
2.37.3
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=709312
---Test result---
Test Summary:
CheckPatch PASS 2.39 seconds GitLint PASS 1.39 seconds BuildEll PASS 33.02 seconds BluezMake PASS 998.52 seconds MakeCheck PASS 12.62 seconds MakeDistcheck PASS 178.17 seconds CheckValgrind PASS 289.84 seconds CheckSmatch WARNING 383.95 seconds bluezmakeextell PASS 116.46 seconds IncrementalBuild PASS 3284.64 seconds ScanBuild WARNING 1193.87 seconds
Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:src/shared/gatt-client.c:2764:33: warning: Variable length array is used.src/shared/gatt-client.c:2994:23: warning: Variable length array is used.src/shared/gatt-client.c:3075:23: warning: Variable length array is used.src/shared/gatt-client.c:3514:23: warning: Variable length array is used.src/shared/gatt-client.c:2764:33: warning: Variable length array is used.src/shared/gatt-client.c:2994:23: warning: Variable length array is used.src/shared/gatt-client.c:3075:23: warning: Variable length array is used.src/shared/gatt-client.c:3514:23: warning: Variable length array is used.src/shared/gatt-client.c:2764:33: warning: Variable length array is used.src/shared/gatt-client.c:2994:23: warning: Variable length array is used.src/shared/gatt-client.c:3075:23: warning: Variable length array is used.src/shared/gatt-client.c:3514:23: warning: Variable length array is used.src/shared/gatt-client.c:2764:33: warning: Variable length array is used.src/shared/gatt-client.c:2994:23: warning: Variab
le length array is used.src/shared/gatt-client.c:3075:23: warning: Variable length array is used.src/shared/gatt-client.c:3514:23: warning: Variable length array is used.src/shared/gatt-client.c:2764:33: warning: Variable length array is used.src/shared/gatt-client.c:2994:23: warning: Variable length array is used.src/shared/gatt-client.c:3075:23: warning: Variable length array is used.src/shared/gatt-client.c:3514:23: warning: Variable length array is used.src/shared/gatt-client.c:2764:33: warning: Variable length array is used.src/shared/gatt-client.c:2994:23: warning: Variable length array is used.src/shared/gatt-client.c:3075:23: warning: Variable length array is used.src/shared/gatt-client.c:3514:23: warning: Variable length array is used.
##############################
Test: ScanBuild - WARNING
Desc: Run Scan Build
Output:src/shared/gatt-client.c:401:21: warning: Use of memory after it is freed
gatt_db_unregister(op->client->db, op->db_id);
^~~~~~~~~~
src/shared/gatt-client.c:646:2: warning: Use of memory after it is freed
discovery_op_complete(op, false, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:943:2: warning: Use of memory after it is freed
discovery_op_complete(op, success, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1049:2: warning: Use of memory after it is freed
discovery_op_complete(op, success, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1241:2: warning: Use of memory after it is freed
discovery_op_complete(op, success, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1306:2: warning: Use of memory after it is freed
discovery_op_complete(op, success, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1577:6: warning: Use of memory after it is freed
if (read_db_hash(op)) {
^~~~~~~~~~~~~~~~
src/shared/gatt-client.c:1582:2: warning: Use of memory after it is freed
discover_all(op);
^~~~~~~~~~~~~~~~
src/shared/gatt-client.c:2088:6: warning: Use of memory after it is freed
if (read_db_hash(op)) {
^~~~~~~~~~~~~~~~
src/shared/gatt-client.c:2096:8: warning: Use of memory after it is freed
discovery_op_ref(op),
^~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:3182:2: warning: Use of memory after it is freed
complete_write_long_op(req, success, 0, false);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:3204:2: warning: Use of memory after it is freed
request_unref(req);
^~~~~~~~~~~~~~~~~~12 warnings generated.
---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz
maintainerHi Tedd,
Quoted 24 lines · On Thu, Jan 5, 2023 at 4:03 PM <[email protected]> wrote:
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=709312---Test result---
Test Summary:
CheckPatch PASS 2.39 seconds GitLint PASS 1.39 seconds BuildEll PASS 33.02 seconds BluezMake PASS 998.52 seconds MakeCheck PASS 12.62 seconds MakeDistcheck PASS 178.17 seconds CheckValgrind PASS 289.84 seconds CheckSmatch WARNING 383.95 seconds bluezmakeextell PASS 116.46 seconds IncrementalBuild PASS 3284.64 seconds ScanBuild WARNING 1193.87 seconds
Quoted 6 lines
Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:src/shared/gatt-client.c:2764:33: warning: Variable length array isused.src/shared/gatt-client.c:2994:23: warning: Variable length array isused.src/shared/gatt-client.c:3075:23: warning: Variable length array isused.src/shared/gatt-client.c:3514:23: warning: Variable length array isused.src/shared/gatt-client.c:2764:33: warning: Variable length array isused.src/shared/gatt-client.c:2994:23: warning: Variable length array isused.src/shared/gatt-client.c:3075:23: warning: Variable length array isused.src/shared/gatt-client.c:3514:23: warning: Variable length array isused.src/shared/gatt-client.c:2764:33: warning: Variable length array isused.src/shared/gatt-client.c:2994:23: warning: Variable length array isused.src/shared/gatt-client.c:3075:23: warning: Variable length array isused.src/shared/gatt-client.c:3514:23: warning: Variable length array isused.src/shared/gatt-client.c:2764:33: warning: Variable length array isused.src/shared/gatt-client.c:2994:23: warning: Variable length array isused.src/shared/gatt-client.c:3075:23: warning: Variable length array isused.src/shared/gatt-client.c:3514:23: warning: Variable length array isused.src/shared/gatt-client.c:2764:33: warning: Variable length array isused.src/shared/gatt-client.c:2994:23: warning: Variable length array isused.src/shared/gatt-client.c:3075:23: warning: Variable length array isused.src/shared/gatt-client.c:3514:23: warning: Variable length array isused.src/shared/gatt-client.c:2764:33: warning: Variable length array isused.src/shared/gatt-client.c:2994:23: warning: Variable length array isused.src/shared/gatt-client.c:3075:23: warning: Variable length array isused.src/shared/gatt-client.c:3514:23: warning: Variable length array is used.
Looks like the output of smatch is not quite right, it is probably missing new line or something.
Quoted 48 lines
##############################
Test: ScanBuild - WARNING
Desc: Run Scan Build
Output:src/shared/gatt-client.c:401:21: warning: Use of memory after it is freedgatt_db_unregister(op->client->db, op->db_id); ^~~~~~~~~~ src/shared/gatt-client.c:646:2: warning: Use of memory after it is freed discovery_op_complete(op, false, att_ecode); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/shared/gatt-client.c:943:2: warning: Use of memory after it is freed discovery_op_complete(op, success, att_ecode); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/shared/gatt-client.c:1049:2: warning: Use of memory after it is freed discovery_op_complete(op, success, att_ecode); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/shared/gatt-client.c:1241:2: warning: Use of memory after it is freed discovery_op_complete(op, success, att_ecode); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/shared/gatt-client.c:1306:2: warning: Use of memory after it is freed discovery_op_complete(op, success, att_ecode); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/shared/gatt-client.c:1577:6: warning: Use of memory after it is freed if (read_db_hash(op)) { ^~~~~~~~~~~~~~~~ src/shared/gatt-client.c:1582:2: warning: Use of memory after it is freed discover_all(op); ^~~~~~~~~~~~~~~~ src/shared/gatt-client.c:2088:6: warning: Use of memory after it is freed if (read_db_hash(op)) { ^~~~~~~~~~~~~~~~ src/shared/gatt-client.c:2096:8: warning: Use of memory after it is freed discovery_op_ref(op), ^~~~~~~~~~~~~~~~~~~~ src/shared/gatt-client.c:3182:2: warning: Use of memory after it is freed complete_write_long_op(req, success, 0, false); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/shared/gatt-client.c:3204:2: warning: Use of memory after it is freed request_unref(req); ^~~~~~~~~~~~~~~~~~12 warnings generated.
---
Regards,
Linux Bluetooth
Signature · 1 line
Luiz Augusto von Dentz
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 8 lines · On Thu, 5 Jan 2023 14:09:41 -0800 you wrote:
From: Luiz Augusto von Dentz <[email protected]>
If clone don't have a dedicated callback set use its parent so users of
bt_gatt_client_clonedon't have to keep setting the same callback for all clone instances.--- src/shared/gatt-client.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
Here is the summary with links:
- [BlueZ,1/4] shared/gatt-client: Use parent debug_callback if not set on clone
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=6e3059ae8cac - [BlueZ,2/4] shared/gatt-client: Allow registering with NULL callback https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=fde32ff9c9c0 - [BlueZ,3/4] attrib: Introduce g_attrib_attach_client https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=47b6cfeee333 - [BlueZ,4/4] hog-lib: Fix not handling BT_ATT_OP_HANDLE_NFY_MULT https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=2f4c576ad243
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html