summaryrefslogtreecommitdiff
path: root/src/gatt-client.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2017-07-03 13:38:24 +0300
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2017-07-05 14:27:37 +0300
commit23ca5047e821c266e1092922bc40a32ee14869e1 (patch)
treef487ea7f105a6f3b51995a541ac4ac6fee5b0496 /src/gatt-client.c
parent1dba18681a4a60bcc1fe4114545c6340f32110f5 (diff)
downloadbluez-23ca5047e821c266e1092922bc40a32ee14869e1.tar.gz
gatt: Add implementation of NotifyAcquired
This property indicate if any client has acquire notify thus locking the access to StartNotify.
Diffstat (limited to 'src/gatt-client.c')
-rw-r--r--src/gatt-client.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/gatt-client.c b/src/gatt-client.c
index d09a9e336..66c231856 100644
--- a/src/gatt-client.c
+++ b/src/gatt-client.c
@@ -846,6 +846,27 @@ characteristic_write_acquired_exists(const GDBusPropertyTable *property,
return (chrc->props & BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP);
}
+static gboolean
+characteristic_get_notify_acquired(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct characteristic *chrc = data;
+ dbus_bool_t locked = chrc->notify_io ? TRUE : FALSE;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &locked);
+
+ return TRUE;
+}
+
+static gboolean
+characteristic_notify_acquired_exists(const GDBusPropertyTable *property,
+ void *data)
+{
+ struct characteristic *chrc = data;
+
+ return (chrc->props & BT_GATT_CHRC_PROP_NOTIFY);
+}
+
static void write_characteristic_cb(struct gatt_db_attribute *attr, int err,
void *user_data)
{
@@ -1075,6 +1096,10 @@ static void characteristic_destroy_pipe(struct characteristic *chrc,
} else if (chrc->notify_io) {
pipe_io_destroy(chrc->notify_io);
chrc->notify_io = NULL;
+ g_dbus_emit_property_changed(btd_get_dbus_connection(),
+ chrc->path,
+ GATT_CHARACTERISTIC_IFACE,
+ "NotifyAcquired");
}
}
@@ -1136,8 +1161,13 @@ static DBusMessage *characteristic_create_pipe(struct characteristic *chrc,
chrc->path,
GATT_CHARACTERISTIC_IFACE,
"WriteAcquired");
- } else
+ } else {
chrc->notify_io->io = io;
+ g_dbus_emit_property_changed(btd_get_dbus_connection(),
+ chrc->path,
+ GATT_CHARACTERISTIC_IFACE,
+ "NotifyAcquired");
+ }
DBG("%s: sender %s io %p", dbus_message_get_member(msg),
dbus_message_get_sender(msg), io);
@@ -1576,6 +1606,9 @@ static const GDBusPropertyTable characteristic_properties[] = {
{ "WriteAcquired", "b", characteristic_get_write_acquired, NULL,
characteristic_write_acquired_exists,
G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
+ { "NotifyAcquired", "b", characteristic_get_notify_acquired, NULL,
+ characteristic_notify_acquired_exists,
+ G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
{ }
};