diff options
author | Arman Uguray <armansito@chromium.org> | 2014-12-02 16:12:37 -0800 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2014-12-03 17:06:18 +0200 |
commit | c536877682fec90f1d74ee60a5851dc566e0195a (patch) | |
tree | e4c42d19d6818c647f85d2e0179cd6ae90e05988 /tools/btgatt-client.c | |
parent | 488a89814af168edf0ee1a230c4981bd09dcb58a (diff) | |
download | bluez-c536877682fec90f1d74ee60a5851dc566e0195a.tar.gz |
shared/gatt-client: Store services in gatt_db
This patch rewrites the service discovery logic inside
shared/gatt-client. The internal service_list structure has been
entirely removed and services are stored in a gatt_db instance.
Initially, gatt-client creates and owns the life-time of the gatt_db.
Diffstat (limited to 'tools/btgatt-client.c')
-rw-r--r-- | tools/btgatt-client.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/btgatt-client.c b/tools/btgatt-client.c index dadfa374d..c0306bd09 100644 --- a/tools/btgatt-client.c +++ b/tools/btgatt-client.c @@ -42,6 +42,8 @@ #include "monitor/mainloop.h" #include "src/shared/util.h" #include "src/shared/att.h" +#include "src/shared/queue.h" +#include "src/shared/gatt-db.h" #include "src/shared/gatt-client.h" #define ATT_CID 4 @@ -62,6 +64,7 @@ static bool verbose = false; struct client { int fd; + struct gatt_db *db; struct bt_gatt_client *gatt; }; @@ -130,9 +133,18 @@ static struct client *client_create(int fd, uint16_t mtu) } cli->fd = fd; - cli->gatt = bt_gatt_client_new(att, mtu); + cli->db = gatt_db_new(); + if (!cli->db) { + fprintf(stderr, "Failed to create GATT database\n"); + bt_att_unref(att); + free(cli); + return NULL; + } + + cli->gatt = bt_gatt_client_new(cli->db, att, mtu); if (!cli->gatt) { fprintf(stderr, "Failed to create GATT client\n"); + gatt_db_unref(cli->db); bt_att_unref(att); free(cli); return NULL; @@ -150,6 +162,7 @@ static struct client *client_create(int fd, uint16_t mtu) /* bt_gatt_client already holds a reference */ bt_att_unref(att); + gatt_db_unref(cli->db); return cli; } |