summaryrefslogtreecommitdiff
path: root/tools/btgatt-client.c
diff options
context:
space:
mode:
authorArman Uguray <armansito@chromium.org>2014-12-03 11:32:27 -0800
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-12-03 23:16:47 +0200
commit9513f74ce01901406bc1bb7b6ef5826595a801ca (patch)
tree72d71675f0fceea72ce840af8b9dc34ae861ab5c /tools/btgatt-client.c
parent80cf4af7a1fd775b1beabc854a3c373cafd21855 (diff)
downloadbluez-9513f74ce01901406bc1bb7b6ef5826595a801ca.tar.gz
tools/btgatt-client: Observe service events
tools/btgatt-client now registers service added/removed callbacks in which it logs a message about the affected service.
Diffstat (limited to 'tools/btgatt-client.c')
-rw-r--r--tools/btgatt-client.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/btgatt-client.c b/tools/btgatt-client.c
index 2a2067b24..fe94ae8bb 100644
--- a/tools/btgatt-client.c
+++ b/tools/btgatt-client.c
@@ -99,6 +99,31 @@ static void ready_cb(bool success, uint8_t att_ecode, void *user_data);
static void service_changed_cb(uint16_t start_handle, uint16_t end_handle,
void *user_data);
+static void log_service_event(struct gatt_db_attribute *attr, const char *str)
+{
+ char uuid_str[MAX_LEN_UUID_STR];
+ bt_uuid_t uuid;
+ uint16_t start, end;
+
+ gatt_db_attribute_get_service_uuid(attr, &uuid);
+ bt_uuid_to_string(&uuid, uuid_str, sizeof(uuid_str));
+
+ gatt_db_attribute_get_service_handles(attr, &start, &end);
+
+ PRLOG("%s - UUID: %s start: 0x%04x end: 0x%04x\n", str, uuid_str,
+ start, end);
+}
+
+static void service_added_cb(struct gatt_db_attribute *attr, void *user_data)
+{
+ log_service_event(attr, "Service Added");
+}
+
+static void service_removed_cb(struct gatt_db_attribute *attr, void *user_data)
+{
+ log_service_event(attr, "Service Removed");
+}
+
static struct client *client_create(int fd, uint16_t mtu)
{
struct client *cli;
@@ -150,6 +175,9 @@ static struct client *client_create(int fd, uint16_t mtu)
return NULL;
}
+ gatt_db_register(cli->db, service_added_cb, service_removed_cb,
+ NULL, NULL);
+
if (verbose) {
bt_att_set_debug(att, att_debug_cb, "att: ", NULL);
bt_gatt_client_set_debug(cli->gatt, gatt_debug_cb, "gatt: ",