diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2023-01-05 13:52:15 -0800 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2023-01-05 13:52:15 -0800 |
commit | 6e3059ae8cac28b8eefd6e55b47a6e39278d6410 (patch) | |
tree | f97baf11bbba1c570b55260fddfe6bcc7c97d1ed /src/shared | |
parent | 4e2ae14ea31178ebbbcb0bc81dfe74bd56b4885f (diff) | |
download | bluez-6e3059ae8cac28b8eefd6e55b47a6e39278d6410.tar.gz |
shared/gatt-client: Use parent debug_callback if not set on clone
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.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/gatt-client.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index cb2e64b6c..4aa5d7d92 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -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); } |