aboutsummaryrefslogtreecommitdiffstats
path: root/attrib/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'attrib/client.c')
-rw-r--r--attrib/client.c63
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 */