Diff between 82a210f6593405040f5bce8f5a9a03addf39d364 and c7ba11f2483cc4a3efb3e82e1e8faef54871d4f4

Changed Files

File Additions Deletions Status
src/gatt-database.c +22 -1 modified

Full Patch

diff --git a/src/gatt-database.c b/src/gatt-database.c
index 5ba3fcd..3f3ab3d 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -497,6 +497,11 @@ struct not_data {
 	bool indicate;
 };
 
+static void conf_cb(void *user_data)
+{
+	DBG("GATT server received confirmation");
+}
+
 static void send_notification_to_device(void *data, void *user_data)
 {
 	struct device_state *device_state = data;
@@ -518,8 +523,24 @@ static void send_notification_to_device(void *data, void *user_data)
 		return;
 
 	/*
-	 * TODO: Notify device via bt_gatt_server
+	 * TODO: If the device is not connected but bonded, send the
+	 * notification/indication when it becomes connected.
 	 */
+	if (!not_data->indicate) {
+		DBG("GATT server sending notification");
+		bt_gatt_server_send_notification(
+					btd_device_get_gatt_server(device),
+					not_data->handle, not_data->value,
+					not_data->len);
+		return;
+	}
+
+	DBG("GATT server sending indication");
+	bt_gatt_server_send_indication(btd_device_get_gatt_server(device),
+							not_data->handle,
+							not_data->value,
+							not_data->len, conf_cb,
+							NULL, NULL);
 }
 
 static void send_notification_to_devices(struct btd_gatt_database *database,