hc
2023-02-13 e440ec23c5a540cdd3f7464e8779219be6fd3d95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From 524a39a5e52ac284818900053802ab40f2a507b1 Mon Sep 17 00:00:00 2001
From: ctf <ctf@rock-chips.com>
Date: Fri, 27 Dec 2019 15:18:22 +0800
Subject: [PATCH 13/19] fix support indicate and notification property,
 notification is not available
 
Signed-off-by: ctf <ctf@rock-chips.com>
---
 src/gatt-database.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
 
diff --git a/src/gatt-database.c b/src/gatt-database.c
index 99c8ea2..af89dc3 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -1132,8 +1132,10 @@ static void send_notification_to_device(void *data, void *user_data)
     if (!ccc)
         return;
 
-    if (!ccc->value[0] || (notify->conf && !(ccc->value[0] & 0x02)))
+    if (!ccc->value[0]) {
+        DBG("ccc->value[0]: 0x%2x", ccc->value[0]);
         return;
+    }
 
     device = btd_adapter_get_device(notify->database->adapter,
                         &device_state->bdaddr,
@@ -1153,7 +1155,7 @@ static void send_notification_to_device(void *data, void *user_data)
      * TODO: If the device is not connected but bonded, send the
      * notification/indication when it becomes connected.
      */
-    if (!notify->conf) {
+    if(ccc->value[0] & 0x01) {
         DBG("GATT server sending notification");
         bt_gatt_server_send_notification(server,
                     notify->handle, notify->value,
@@ -1161,10 +1163,12 @@ static void send_notification_to_device(void *data, void *user_data)
         return;
     }
 
-    DBG("GATT server sending indication");
-    bt_gatt_server_send_indication(server, notify->handle, notify->value,
-                        notify->len, notify->conf,
-                        notify->user_data, NULL);
+    if(notify->conf && (ccc->value[0] & 0x02)) {
+        DBG("GATT server sending indication");
+        bt_gatt_server_send_indication(server, notify->handle, notify->value,
+                            notify->len, notify->conf,
+                            notify->user_data, NULL);
+    }
 
     return;
 
-- 
2.20.1