Add Confirm method which doesn't expect a reply so it is just
confirmation that value was received.
---
doc/gatt-api.txt | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/doc/gatt-api.txt b/doc/gatt-api.txt
index c0ad1de25..cdd15f301 100644
--- a/doc/gatt-api.txt
+++ b/doc/gatt-api.txt
@@ -162,6 +162,13 @@ Methods array{byte} ReadValue(dict options)
Possible Errors: org.bluez.Error.Failed
+ void Confirm() [optional] (Server only)
+
+ This method doesn't expect a reply so it is just a
+ confirmation that value was received.
+
+ Possible Errors: org.bluez.Error.Failed
+
Properties string UUID [read-only]
128-bit characteristic UUID.
--
2.14.1.342.g6490525c54-goog
Hi Yunhan,
On Tue, Aug 29, 2017 at 10:35 AM, Yunhan Wang <[email protected]> wrote:
> ---
> src/gatt-database.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/src/gatt-database.c b/src/gatt-database.c
> index 3b4bc7c8d..4af9b81a8 100644
> --- a/src/gatt-database.c
> +++ b/src/gatt-database.c
> @@ -867,11 +867,18 @@ struct notify {
> const uint8_t *value;
> uint16_t len;
> bool indicate;
> + GDBusProxy *proxy;
> };
>
> static void conf_cb(void *user_data)
> {
> + GDBusProxy *proxy = user_data;
> DBG("GATT server received confirmation");
> +
> + if (proxy != NULL)
> + {
> + g_dbus_proxy_method_call(proxy, "Confirm", NULL, NULL, NULL, NULL);
> + }
> }
>
> static void send_notification_to_device(void *data, void *user_data)
> @@ -917,7 +924,7 @@ static void send_notification_to_device(void *data, void *user_data)
> DBG("GATT server sending indication");
> bt_gatt_server_send_indication(server, notify->handle, notify->value,
> notify->len, conf_cb,
> - NULL, NULL);
> + notify->proxy, NULL);
>
> return;
>
> @@ -930,7 +937,7 @@ remove:
> static void send_notification_to_devices(struct btd_gatt_database *database,
> uint16_t handle, const uint8_t *value,
> uint16_t len, uint16_t ccc_handle,
> - bool indicate)
> + bool indicate, GDBusProxy *proxy)
> {
> struct notify notify;
>
> @@ -942,6 +949,7 @@ static void send_notification_to_devices(struct btd_gatt_database *database,
> notify.value = value;
> notify.len = len;
> notify.indicate = indicate;
> + notify.proxy = proxy;
>
> queue_foreach(database->device_states, send_notification_to_device,
> ¬ify);
> @@ -972,7 +980,7 @@ static void send_service_changed(struct btd_gatt_database *database,
> put_le16(end, value + 2);
>
> send_notification_to_devices(database, handle, value, sizeof(value),
> - ccc_handle, true);
> + ccc_handle, true, NULL);
> }
>
> static void gatt_db_service_added(struct gatt_db_attribute *attrib,
> @@ -1861,7 +1869,7 @@ static void property_changed_cb(GDBusProxy *proxy, const char *name,
> gatt_db_attribute_get_handle(chrc->attrib),
> value, len,
> gatt_db_attribute_get_handle(chrc->ccc),
> - chrc->props & BT_GATT_CHRC_PROP_INDICATE);
> + chrc->props & BT_GATT_CHRC_PROP_INDICATE, proxy);
> }
>
> static bool database_add_ccc(struct external_service *service,
> --
> 2.14.1.342.g6490525c54-goog
Applied, thanks.
--
Luiz Augusto von Dentz
Add Confirm implementation when indication is received.
---
client/gatt.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/client/gatt.c b/client/gatt.c
index bd6e6b0af..ca84479d7 100644
--- a/client/gatt.c
+++ b/client/gatt.c
@@ -1405,6 +1405,14 @@ static DBusMessage *chrc_stop_notify(DBusConnection *conn, DBusMessage *msg,
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
+static DBusMessage *chrc_indication_conf(DBusConnection *conn,
+ DBusMessage *msg, void *user_data)
+{
+ struct chrc *chrc = user_data;
+ rl_printf("Attribute %s indication confirm received", chrc->path);
+ return dbus_message_new_method_return(msg);
+}
+
static const GDBusMethodTable chrc_methods[] = {
{ GDBUS_ASYNC_METHOD("ReadValue", GDBUS_ARGS({ "options", "a{sv}" }),
GDBUS_ARGS({ "value", "ay" }),
@@ -1414,6 +1422,7 @@ static const GDBusMethodTable chrc_methods[] = {
NULL, chrc_write_value) },
{ GDBUS_ASYNC_METHOD("StartNotify", NULL, NULL, chrc_start_notify) },
{ GDBUS_METHOD("StopNotify", NULL, NULL, chrc_stop_notify) },
+ { GDBUS_METHOD("Confirm", NULL, NULL, chrc_indication_conf) },
{ }
};
--
2.14.1.342.g6490525c54-goog
---
src/gatt-database.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/gatt-database.c b/src/gatt-database.c
index 3b4bc7c8d..4af9b81a8 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -867,11 +867,18 @@ struct notify {
const uint8_t *value;
uint16_t len;
bool indicate;
+ GDBusProxy *proxy;
};
static void conf_cb(void *user_data)
{
+ GDBusProxy *proxy = user_data;
DBG("GATT server received confirmation");
+
+ if (proxy != NULL)
+ {
+ g_dbus_proxy_method_call(proxy, "Confirm", NULL, NULL, NULL, NULL);
+ }
}
static void send_notification_to_device(void *data, void *user_data)
@@ -917,7 +924,7 @@ static void send_notification_to_device(void *data, void *user_data)
DBG("GATT server sending indication");
bt_gatt_server_send_indication(server, notify->handle, notify->value,
notify->len, conf_cb,
- NULL, NULL);
+ notify->proxy, NULL);
return;
@@ -930,7 +937,7 @@ remove:
static void send_notification_to_devices(struct btd_gatt_database *database,
uint16_t handle, const uint8_t *value,
uint16_t len, uint16_t ccc_handle,
- bool indicate)
+ bool indicate, GDBusProxy *proxy)
{
struct notify notify;
@@ -942,6 +949,7 @@ static void send_notification_to_devices(struct btd_gatt_database *database,
notify.value = value;
notify.len = len;
notify.indicate = indicate;
+ notify.proxy = proxy;
queue_foreach(database->device_states, send_notification_to_device,
¬ify);
@@ -972,7 +980,7 @@ static void send_service_changed(struct btd_gatt_database *database,
put_le16(end, value + 2);
send_notification_to_devices(database, handle, value, sizeof(value),
- ccc_handle, true);
+ ccc_handle, true, NULL);
}
static void gatt_db_service_added(struct gatt_db_attribute *attrib,
@@ -1861,7 +1869,7 @@ static void property_changed_cb(GDBusProxy *proxy, const char *name,
gatt_db_attribute_get_handle(chrc->attrib),
value, len,
gatt_db_attribute_get_handle(chrc->ccc),
- chrc->props & BT_GATT_CHRC_PROP_INDICATE);
+ chrc->props & BT_GATT_CHRC_PROP_INDICATE, proxy);
}
static bool database_add_ccc(struct external_service *service,
--
2.14.1.342.g6490525c54-goog