From 0628449e0c754a1efdc3d180aae451caf0febf0a Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Tue, 5 Apr 2016 17:27:39 +0300 Subject: [PATCH] doc/gatt-api: Make Notifying property optional If the characteristic does not support nofications nor indications the Notifying property can be omitted as it will never going to be used. --- doc/gatt-api.txt | 2 +- src/gatt-client.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/gatt-api.txt b/doc/gatt-api.txt index 232ffa090..ad2ab1676 100644 --- a/doc/gatt-api.txt +++ b/doc/gatt-api.txt @@ -119,7 +119,7 @@ Properties string UUID [read-only] when a notification or indication is received, upon which a PropertiesChanged signal will be emitted. - boolean Notifying [read-only] + boolean Notifying [read-only, optional] True, if notifications or indications on this characteristic are currently enabled. diff --git a/src/gatt-client.c b/src/gatt-client.c index a018c8c94..52add1db9 100644 --- a/src/gatt-client.c +++ b/src/gatt-client.c @@ -707,6 +707,15 @@ static gboolean characteristic_get_notifying(const GDBusPropertyTable *property, return TRUE; } +static gboolean +characteristic_notifying_exists(const GDBusPropertyTable *property, void *data) +{ + struct characteristic *chrc = data; + + return (chrc->props & BT_GATT_CHRC_PROP_NOTIFY || + chrc->props & BT_GATT_CHRC_PROP_INDICATE); +} + struct chrc_prop_data { uint8_t prop; char *str; @@ -1225,7 +1234,8 @@ static const GDBusPropertyTable characteristic_properties[] = { { "Value", "ay", characteristic_get_value, NULL, characteristic_value_exists, G_DBUS_PROPERTY_FLAG_EXPERIMENTAL }, - { "Notifying", "b", characteristic_get_notifying, NULL, NULL, + { "Notifying", "b", characteristic_get_notifying, NULL, + characteristic_notifying_exists, G_DBUS_PROPERTY_FLAG_EXPERIMENTAL }, { "Flags", "as", characteristic_get_flags, NULL, NULL, G_DBUS_PROPERTY_FLAG_EXPERIMENTAL }, -- 2.47.3