diff --git a/tools/gatt-service.c b/tools/gatt-service.c
index 624b835..e319163 100644
--- a/tools/gatt-service.c
+++ b/tools/gatt-service.c
char *path;
uint8_t *value;
int vlen;
+ const char **props;
};
+/*
+ * Alert Level support Write Without Response only. Supported
+ * properties are defined at doc/gatt-api.txt. See "Flags"
+ * property of the GattCharacteristic1.
+ */
+static const char const *ias_alert_level_props[] = {
+ "write-without-response",
+ NULL };
+
static gboolean chr_get_uuid(const GDBusPropertyTable *property,
DBusMessageIter *iter, void *user_data)
{
return TRUE;
}
+static gboolean chr_get_props(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct characteristic *chr = data;
+ DBusMessageIter array;
+ int i;
+
+ dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_STRING_AS_STRING, &array);
+
+ for (i = 0; chr->props[i]; i++)
+ dbus_message_iter_append_basic(&array,
+ DBUS_TYPE_STRING, &chr->props[i]);
+
+ dbus_message_iter_close_container(iter, &array);
+
+ return TRUE;
+}
+
static void chr_set_value(const GDBusPropertyTable *property,
DBusMessageIter *iter,
GDBusPendingPropertySet id, void *user_data)
static const GDBusPropertyTable chr_properties[] = {
{ "UUID", "s", chr_get_uuid },
{ "Value", "ay", chr_get_value, chr_set_value, NULL },
+ { "Flags", "as", chr_get_props, NULL, NULL },
{ }
};
static gboolean register_characteristic(DBusConnection *conn, const char *uuid,
const uint8_t *value, int vlen,
+ const char **props,
const char *service_path)
{
struct characteristic *chr;
chr->value = g_memdup(value, vlen);
chr->vlen = vlen;
chr->path = path;
+ chr->props = props;
if (!g_dbus_register_interface(conn, path, GATT_CHR_IFACE,
NULL, NULL, chr_properties,
if (!service_path)
return;
- /* Add Alert Level Characteristic to Immediate Alert Service
- * According to the IAS SPEC, reading <<Alert level>> is not allowed.
- * "Value" is readable for testing purpose only.
- */
- if (!register_characteristic(connection, ALERT_LEVEL_CHR_UUID, &level,
- sizeof(level), service_path)) {
+ /* Add Alert Level Characteristic to Immediate Alert Service */
+ if (!register_characteristic(connection, ALERT_LEVEL_CHR_UUID,
+ &level, sizeof(level),
+ ias_alert_level_props,
+ service_path)) {
printf("Couldn't register Alert Level characteristic (IAS)\n");
g_dbus_unregister_interface(connection, service_path,
GATT_SERVICE_IFACE);