aboutsummaryrefslogtreecommitdiffstats
path: root/thermometer
diff options
context:
space:
mode:
authorSantiago Carot-Nemesio <sancane@gmail.com>2011-10-13 17:29:18 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2011-10-17 11:08:33 +0300
commit62d4daf26a90a5e5d8db91861c1e3adf18044735 (patch)
tree9e5d7dc979e87c37594dfc232915e5ecdc977eed /thermometer
parent2d2e3a412cb59dc1261c0303d6066f415eb003fe (diff)
downloadbluez-62d4daf26a90a5e5d8db91861c1e3adf18044735.tar.gz
bluez-62d4daf26a90a5e5d8db91861c1e3adf18044735.tar.xz
bluez-62d4daf26a90a5e5d8db91861c1e3adf18044735.zip
Add handler function to manage GATT indications
Diffstat (limited to 'thermometer')
-rw-r--r--thermometer/thermometer.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index 33a2b7bd..1e2caf5e 100644
--- a/thermometer/thermometer.c
+++ b/thermometer/thermometer.c
@@ -41,6 +41,7 @@ struct thermometer {
GAttrib *attrib; /* GATT connection */
struct att_range *svc_range; /* Thermometer range */
guint attioid; /* Att watcher id */
+ guint attindid; /* Att incications id */
};
static GSList *thermometers = NULL;
@@ -52,6 +53,9 @@ static void destroy_thermometer(gpointer user_data)
if (t->attioid > 0)
btd_device_remove_attio_callback(t->dev, t->attioid);
+ if (t->attindid > 0)
+ g_attrib_unregister(t->attrib, t->attindid);
+
if (t->attrib != NULL)
g_attrib_unref(t->attrib);
@@ -136,11 +140,19 @@ static GDBusSignalTable thermometer_signals[] = {
{ }
};
+static void ind_handler(const uint8_t *pdu, uint16_t len, gpointer user_data)
+{
+ /* TODO: Process indication */
+}
+
static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
{
struct thermometer *t = user_data;
t->attrib = g_attrib_ref(attrib);
+
+ t->attindid = g_attrib_register(t->attrib, ATT_OP_HANDLE_IND,
+ ind_handler, t, NULL);
}
static void attio_disconnected_cb(gpointer user_data)
@@ -149,6 +161,11 @@ static void attio_disconnected_cb(gpointer user_data)
DBG("GATT Disconnected");
+ if (t->attindid > 0) {
+ g_attrib_unregister(t->attrib, t->attindid);
+ t->attindid = 0;
+ }
+
g_attrib_unref(t->attrib);
t->attrib = NULL;
}