aboutsummaryrefslogtreecommitdiffstats
path: root/attrib/client.c
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2010-07-20 19:22:39 -0300
committerJohan Hedberg <johan.hedberg@nokia.com>2010-08-09 18:06:44 -0400
commit17b9256fbd64bab88901b056f2998bda772d9957 (patch)
tree7319edce89caff279a29d005e37bbf8a8c058371 /attrib/client.c
parent70a6091ccf356ea56f46220b007675b80f6c58cf (diff)
downloadbluez-17b9256fbd64bab88901b056f2998bda772d9957.tar.gz
bluez-17b9256fbd64bab88901b056f2998bda772d9957.tar.xz
bluez-17b9256fbd64bab88901b056f2998bda772d9957.zip
Store discovered primary services information
Information (start handle, end handle and uuid) about the discovered primary services are stored (in memory) in the gatt_service struct.
Diffstat (limited to 'attrib/client.c')
-rw-r--r--attrib/client.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/attrib/client.c b/attrib/client.c
index b0a063d3..2f1698eb 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -32,6 +32,7 @@
#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>
+#include "glib-helper.h"
#include "log.h"
#include "gdbus.h"
#include "btio.h"
@@ -59,6 +60,13 @@ struct characteristic {
char *path;
};
+struct primary {
+ uuid_t *uuid;
+ uint16_t start;
+ uint16_t end;
+ char *path;
+};
+
static int service_id = 0;
static int char_id = 0;
static GSList *services = NULL;
@@ -73,12 +81,21 @@ static void characteristic_free(void *user_data)
g_free(chr);
}
+static void primary_free(void *user_data)
+{
+ struct primary *prim = user_data;
+
+ g_free(prim->path);
+ g_free(prim->uuid);
+ g_free(prim);
+}
+
static void gatt_service_free(void *user_data)
{
struct gatt_service *gatt = user_data;
g_slist_foreach(gatt->chars, (GFunc) characteristic_free, NULL);
- g_slist_foreach(gatt->primary, (GFunc) bt_free, NULL);
+ g_slist_foreach(gatt->primary, (GFunc) primary_free, NULL);
g_attrib_unref(gatt->attrib);
g_free(gatt->path);
g_free(gatt);
@@ -139,8 +156,8 @@ static void primary_cb(guint8 status, const guint8 *pdu, guint16 plen,
{
struct gatt_service *gatt = user_data;
unsigned int i;
- uint16_t start, end;
uint8_t length;
+ uint16_t end, start;
if (status == ATT_ECODE_ATTR_NOT_FOUND) {
DBG("Discover all primary services finished.");
@@ -163,6 +180,7 @@ static void primary_cb(guint8 status, const guint8 *pdu, guint16 plen,
length = pdu[1];
for (i = 2, end = 0; i < plen; i += length) {
+ struct primary *prim;
uuid_t *uuid;
uint16_t *p16;
@@ -186,7 +204,12 @@ static void primary_cb(guint8 status, const guint8 *pdu, guint16 plen,
goto fail;
}
- gatt->primary = g_slist_append(gatt->primary, uuid);
+ prim = g_new0(struct primary, 1);
+ prim->start = start;
+ prim->end = end;
+ prim->uuid = uuid;
+
+ gatt->primary = g_slist_append(gatt->primary, prim);
}
if (end == 0) {