aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2010-07-29 19:48:32 -0300
committerJohan Hedberg <johan.hedberg@nokia.com>2010-08-09 18:06:47 -0400
commit739afe307c33ce7524842002a807d55eafa5aecb (patch)
treed7e6394739aa28e9b3cef9ec814f29ff7d40bae3
parent978b5c17073bebb7c4f14345f19d3900856b3fad (diff)
downloadbluez-739afe307c33ce7524842002a807d55eafa5aecb.tar.gz
bluez-739afe307c33ce7524842002a807d55eafa5aecb.tar.xz
bluez-739afe307c33ce7524842002a807d55eafa5aecb.zip
Add support for storing essential characteristic info
This would allow for each characteristic DBus object path to be registered.
-rw-r--r--attrib/client.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/attrib/client.c b/attrib/client.c
index fb89f62c..4cbcfd68 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -155,6 +155,48 @@ static void register_characteristics(struct gatt_service *gatt)
}
}
+static char *characteristic_list_to_string(GSList *chars)
+{
+ GString *characteristics;
+ GSList *l;
+
+ characteristics = g_string_new(NULL);
+
+ for (l = chars; l; l = l->next) {
+ struct characteristic *chr = l->data;
+ uuid_t *uuid128;
+ char chr_str[64];
+ char uuidstr[MAX_LEN_UUID_STR];
+
+ memset(chr_str, 0, sizeof(chr_str));
+
+ uuid128 = sdp_uuid_to_uuid128(&chr->type);
+ sdp_uuid2strn(uuid128, uuidstr, MAX_LEN_UUID_STR);
+
+ bt_free(uuid128);
+
+ snprintf(chr_str, sizeof(chr_str), "%04X#%02X#%04X#%s ",
+ chr->handle, chr->perm, chr->end, uuidstr);
+
+ characteristics = g_string_append(characteristics, chr_str);
+ }
+
+ return g_string_free(characteristics, FALSE);
+}
+
+static void store_characteristics(struct gatt_service *gatt,
+ struct primary *prim)
+{
+ char *characteristics;
+
+ characteristics = characteristic_list_to_string(prim->chars);
+
+ write_device_characteristics(&gatt->sba, &gatt->dba, prim->start,
+ characteristics);
+
+ g_free(characteristics);
+}
+
static void char_discovered_cb(guint8 status, const guint8 *pdu, guint16 plen,
gpointer user_data)
{
@@ -170,6 +212,8 @@ static void char_discovered_cb(guint8 status, const guint8 *pdu, guint16 plen,
return;
}
+ store_characteristics(gatt, gatt->cur_prim->data);
+
gatt->cur_prim = gatt->cur_prim->next;
/* Fetch characteristics of the NEXT primary service */