diff options
author | Vinicius Costa Gomes <vinicius.gomes@openbossa.org> | 2010-08-02 14:46:39 -0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2010-08-09 18:06:48 -0400 |
commit | 79cb696f56365f7306afaa25c27870843e6f80b9 (patch) | |
tree | 7e969202a032f4c5fffc12c41866b890ad8809ef | |
parent | d7b3bbbd6e106e7009b457286827d09cae0bd936 (diff) | |
download | bluez-79cb696f56365f7306afaa25c27870843e6f80b9.tar.gz bluez-79cb696f56365f7306afaa25c27870843e6f80b9.tar.xz bluez-79cb696f56365f7306afaa25c27870843e6f80b9.zip |
Fix the last group of characteristic not being stored
The characteristic group beloging to the last service was not being stored,
because the condition to trigger the storage was missing that last group.
-rw-r--r-- | attrib/client.c | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/attrib/client.c b/attrib/client.c index b279b895..3c6f9ac2 100644 --- a/attrib/client.c +++ b/attrib/client.c @@ -162,22 +162,6 @@ static void register_primary(struct gatt_service *gatt) } } -static void register_characteristics(struct gatt_service *gatt) -{ - GSList *lp, *lc; - - for (lp = gatt->primary; lp; lp = lp->next) { - struct primary *prim = lp->data; - for (lc = prim->chars; lc; lc = lc->next) { - struct characteristic *chr = lc->data; - g_dbus_register_interface(connection, chr->path, - CHAR_INTERFACE, char_methods, - NULL, NULL, chr, NULL); - DBG("Registered: %s", chr->path); - } - } -} - static char *characteristic_list_to_string(GSList *chars) { GString *characteristics; @@ -207,6 +191,38 @@ static char *characteristic_list_to_string(GSList *chars) 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 register_characteristics(struct gatt_service *gatt) +{ + GSList *lp, *lc; + + for (lp = gatt->primary; lp; lp = lp->next) { + struct primary *prim = lp->data; + + store_characteristics(gatt, prim); + + for (lc = prim->chars; lc; lc = lc->next) { + struct characteristic *chr = lc->data; + g_dbus_register_interface(connection, chr->path, + CHAR_INTERFACE, char_methods, + NULL, NULL, chr, NULL); + DBG("Registered: %s", chr->path); + } + } +} + static GSList *string_to_characteristic_list(const char *prim_path, const char *str) { @@ -248,19 +264,6 @@ static GSList *string_to_characteristic_list(const char *prim_path, return l; } -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 load_characteristics(gpointer data, gpointer user_data) { struct primary *prim = data; @@ -305,8 +308,6 @@ 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 */ |