diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2019-02-13 17:05:21 +0200 |
---|---|---|
committer | himanshu <h.himanshu@samsung.com> | 2020-02-11 14:27:47 +0530 |
commit | 0fdb80e46ca1c1791d1ced5a20800da7434e13f8 (patch) | |
tree | 7785b13caeab83de918f22a6b131023949bca1bc /client | |
parent | f545d23b28d11115c0c156c14b6f98970236b350 (diff) | |
download | bluez-0fdb80e46ca1c1791d1ced5a20800da7434e13f8.tar.gz bluez-0fdb80e46ca1c1791d1ced5a20800da7434e13f8.tar.bz2 bluez-0fdb80e46ca1c1791d1ced5a20800da7434e13f8.zip |
client: Improve logging of GATT operations
This prints the UUID along with attribute path and also print the
hexdump when payload is available.
Change-Id: If48e517894a93572f0e7a19a16fe58c85a3fbfb1
Signed-off-by: himanshu <h.himanshu@samsung.com>
Diffstat (limited to 'client')
-rwxr-xr-x | client/gatt.c | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/client/gatt.c b/client/gatt.c index dee7c993..aaca5e03 100755 --- a/client/gatt.c +++ b/client/gatt.c @@ -847,8 +847,9 @@ static bool sock_read(struct io *io, void *user_data) return false; if (chrc) - bt_shell_printf("[" COLORED_CHG "] Attribute %s written:\n", - chrc->path); + bt_shell_printf("[" COLORED_CHG "] Attribute %s (%s) " + "written:\n", chrc->path, + bt_uuidstr_to_str(chrc->uuid)); else bt_shell_printf("[" COLORED_CHG "] %s Notification:\n", g_dbus_proxy_get_path(notify_io.proxy)); @@ -2029,8 +2030,9 @@ static DBusMessage *chrc_read_value(DBusConnection *conn, DBusMessage *msg, "org.bluez.Error.InvalidArguments", NULL); - bt_shell_printf("ReadValue: %s offset %u link %s\n", - path_to_address(device), offset, link); + bt_shell_printf("[%s (%s)] ReadValue: %s offset %u link %s\n", + chrc->path, bt_uuidstr_to_str(chrc->uuid), + path_to_address(device), offset, link); if (chrc->proxy) { return proxy_read_value(chrc->proxy, msg, offset); @@ -2139,7 +2141,8 @@ static void authorize_write_response(const char *input, void *user_data) goto error; } - bt_shell_printf("[" COLORED_CHG "] Attribute %s written" , chrc->path); + bt_shell_printf("[" COLORED_CHG "] Attribute %s (%s) written", + chrc->path, bt_uuidstr_to_str(chrc->uuid)); g_dbus_emit_property_changed(aad->conn, chrc->path, CHRC_INTERFACE, "Value"); @@ -2205,7 +2208,7 @@ static DBusMessage *chrc_write_value(DBusConnection *conn, DBusMessage *msg, struct chrc *chrc = user_data; uint16_t offset = 0; bool prep_authorize = false; - char *device = NULL; + char *device = NULL, *link = NULL; DBusMessageIter iter; int value_len; uint8_t *value; @@ -2218,10 +2221,17 @@ static DBusMessage *chrc_write_value(DBusConnection *conn, DBusMessage *msg, "org.bluez.Error.InvalidArguments", NULL); dbus_message_iter_next(&iter); - if (parse_options(&iter, &offset, NULL, &device, NULL, &prep_authorize)) + if (parse_options(&iter, &offset, NULL, &device, &link, + &prep_authorize)) return g_dbus_create_error(msg, "org.bluez.Error.InvalidArguments", NULL); + bt_shell_printf("[%s (%s)] WriteValue: %s offset %u link %s\n", + chrc->path, bt_uuidstr_to_str(chrc->uuid), + path_to_address(device), offset, link); + + bt_shell_hexdump(value, value_len); + if (chrc->proxy) return proxy_write_value(chrc->proxy, msg, value, value_len, offset); @@ -2255,7 +2265,8 @@ static DBusMessage *chrc_write_value(DBusConnection *conn, DBusMessage *msg, return g_dbus_create_error(msg, "org.bluez.Error.InvalidValueLength", NULL); - bt_shell_printf("[" COLORED_CHG "] Attribute %s written" , chrc->path); + bt_shell_printf("[" COLORED_CHG "] Attribute %s (%s) written", + chrc->path, bt_uuidstr_to_str(chrc->uuid)); g_dbus_emit_property_changed(conn, chrc->path, CHRC_INTERFACE, "Value"); @@ -2392,8 +2403,10 @@ static void proxy_notify_reply(DBusMessage *message, void *user_data) g_dbus_send_reply(conn, data->msg, DBUS_TYPE_INVALID); data->chrc->notifying = data->enable; - bt_shell_printf("[" COLORED_CHG "] Attribute %s notifications %s\n", + bt_shell_printf("[" COLORED_CHG "] Attribute %s (%s) " + "notifications %s\n", data->chrc->path, + bt_uuidstr_to_str(data->chrc->uuid), data->enable ? "enabled" : "disabled"); g_dbus_emit_property_changed(conn, data->chrc->path, CHRC_INTERFACE, "Notifying"); @@ -2439,8 +2452,8 @@ static DBusMessage *chrc_start_notify(DBusConnection *conn, DBusMessage *msg, return proxy_notify(chrc, msg, true); chrc->notifying = true; - bt_shell_printf("[" COLORED_CHG "] Attribute %s notifications enabled", - chrc->path); + bt_shell_printf("[" COLORED_CHG "] Attribute %s (%s) notifications " + "enabled", chrc->path, bt_uuidstr_to_str(chrc->uuid)); g_dbus_emit_property_changed(conn, chrc->path, CHRC_INTERFACE, "Notifying"); @@ -2459,8 +2472,8 @@ static DBusMessage *chrc_stop_notify(DBusConnection *conn, DBusMessage *msg, return proxy_notify(chrc, msg, false); chrc->notifying = false; - bt_shell_printf("[" COLORED_CHG "] Attribute %s notifications disabled", - chrc->path); + bt_shell_printf("[" COLORED_CHG "] Attribute %s (%s) notifications " + "disabled", chrc->path, bt_uuidstr_to_str(chrc->uuid)); g_dbus_emit_property_changed(conn, chrc->path, CHRC_INTERFACE, "Notifying"); @@ -2472,7 +2485,8 @@ static DBusMessage *chrc_confirm(DBusConnection *conn, DBusMessage *msg, { struct chrc *chrc = user_data; - bt_shell_printf("Attribute %s indication confirm received", chrc->path); + bt_shell_printf("Attribute %s (%s) indication confirm received", + chrc->path, bt_uuidstr_to_str(chrc->uuid)); return dbus_message_new_method_return(msg); } @@ -2653,7 +2667,8 @@ static DBusMessage *desc_read_value(DBusConnection *conn, DBusMessage *msg, "org.bluez.Error.InvalidArguments", NULL); - bt_shell_printf("ReadValue: %s offset %u link %s\n", + bt_shell_printf("[%s (%s)] ReadValue: %s offset %u link %s\n", + desc->path, bt_uuidstr_to_str(desc->uuid), path_to_address(device), offset, link); if (offset > desc->value_len) @@ -2689,10 +2704,12 @@ static DBusMessage *desc_write_value(DBusConnection *conn, DBusMessage *msg, return g_dbus_create_error(msg, "org.bluez.Error.InvalidValueLength", NULL); - bt_shell_printf("WriteValue: %s offset %u link %s\n", + bt_shell_printf("[%s (%s)] WriteValue: %s offset %u link %s\n", + desc->path, bt_uuidstr_to_str(desc->uuid), path_to_address(device), offset, link); - bt_shell_printf("[" COLORED_CHG "] Attribute %s written" , desc->path); + bt_shell_printf("[" COLORED_CHG "] Attribute %s (%s) written", + desc->path, bt_uuidstr_to_str(desc->uuid)); g_dbus_emit_property_changed(conn, desc->path, CHRC_INTERFACE, "Value"); |