summaryrefslogtreecommitdiff
path: root/src/gatt-client.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2017-07-03 10:37:52 +0300
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2017-07-05 14:26:00 +0300
commit9aedde40496950000ca58e8554e76cff1bc512dc (patch)
treea74b83bef7591ac0931417bdc71cf591bf635bfe /src/gatt-client.c
parentc6d9a1bbbe74f8e50223fcbd98bb6390513c1cb9 (diff)
downloadbluez-9aedde40496950000ca58e8554e76cff1bc512dc.tar.gz
gatt: Add implementation of WriteAcquired
This property indicate if any client has acquire write thus locking the access to WriteValue.
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 eae54197a..7e04c7db9 100644
--- a/src/gatt-client.c
+++ b/src/gatt-client.c
@@ -818,6 +818,27 @@ static gboolean characteristic_get_flags(const GDBusPropertyTable *property,
return TRUE;
}
+static gboolean
+characteristic_get_write_acquired(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct characteristic *chrc = data;
+ dbus_bool_t locked = chrc->write_io ? TRUE : FALSE;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &locked);
+
+ return TRUE;
+}
+
+static gboolean
+characteristic_write_acquired_exists(const GDBusPropertyTable *property,
+ void *data)
+{
+ struct characteristic *chrc = data;
+
+ return (chrc->props & BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP);
+}
+
static void write_characteristic_cb(struct gatt_db_attribute *attr, int err,
void *user_data)
{
@@ -1028,6 +1049,10 @@ static void characteristic_destroy_pipe(struct characteristic *chrc,
if (io == chrc->write_io) {
io_destroy(chrc->write_io);
chrc->write_io = NULL;
+ g_dbus_emit_property_changed(btd_get_dbus_connection(),
+ chrc->path,
+ GATT_CHARACTERISTIC_IFACE,
+ "WriteAcquired");
}
}
@@ -1083,8 +1108,13 @@ static DBusMessage *characteristic_create_pipe(struct characteristic *chrc,
close(pipefd[dir]);
- if (dir)
+ if (dir) {
chrc->write_io = io;
+ g_dbus_emit_property_changed(btd_get_dbus_connection(),
+ chrc->path,
+ GATT_CHARACTERISTIC_IFACE,
+ "WriteAcquired");
+ }
DBG("%s: sender %s io %p", dbus_message_get_member(msg),
dbus_message_get_sender(msg), io);
@@ -1406,6 +1436,9 @@ static const GDBusPropertyTable characteristic_properties[] = {
{ "Notifying", "b", characteristic_get_notifying, NULL,
characteristic_notifying_exists },
{ "Flags", "as", characteristic_get_flags, NULL, NULL },
+ { "WriteAcquired", "b", characteristic_get_write_acquired, NULL,
+ characteristic_write_acquired_exists,
+ G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
{ }
};