Fix position of setting is_own GATT attribute handle 69/248069/2
authorAnupam Roy <anupam.r@samsung.com>
Fri, 20 Nov 2020 07:10:52 +0000 (12:40 +0530)
committerAnupam Roy <anupam.r@samsung.com>
Sat, 21 Nov 2020 04:08:13 +0000 (04:08 +0000)
Issue: is_own_handle variable is wrongly set when
GATT read/write callback is found for the
attribute handle. But, it is possible that, callback is
explicitly not set by application for one of its
own handle. In such case, is_own_handle will remain
false, even when the attribute is owned by the app.
This will cause to miss the GATT internal response
by CAPI, when response is needed for that attribute.

Fix: is_own_handle is set to true, when GATT attribute is
matched for an application.

Change-Id: I85be0fcc03881372c46c76c56cfc69e1952f0163
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
src/bluetooth-common.c

index 0a45a48..48e0588 100644 (file)
@@ -970,12 +970,12 @@ static bt_gatt_server_read_value_requested_cb __bt_gatt_attribute_get_read_cb(in
 
                                if (chr) {
                                        if (chr->handle == att_handle) {
+                                               *is_own_handle = true; /* Attribute matched */
                                                if (chr->read_requested_cb) {
                                                        BT_DBG("GATT Server: char handle found [%s]", chr->uuid);
                                                        *user_data = chr->read_requested_user_data;
                                                        *gatt_handle = chr;
                                                        *server = serv;
-                                                       *is_own_handle = true;
                                                        return chr->read_requested_cb;
                                                } else
                                                        return NULL;
@@ -984,11 +984,11 @@ static bt_gatt_server_read_value_requested_cb __bt_gatt_attribute_get_read_cb(in
                                                        bt_gatt_descriptor_s *desc = l4->data;
 
                                                        if (desc && desc->handle == att_handle) {
+                                                               *is_own_handle = true; /* Attribute matched */
                                                                if (desc->read_requested_cb) {
                                                                        *user_data = desc->read_requested_user_data;
                                                                        *gatt_handle = desc;
                                                                        *server = serv;
-                                                                       *is_own_handle = true;
                                                                        BT_DBG("GATT Server: desc handle found [%s]", desc->uuid);
                                                                        return desc->read_requested_cb;
                                                                } else
@@ -1025,12 +1025,12 @@ static bt_gatt_server_write_value_requested_cb __bt_gatt_attribute_get_value_cha
 
                                if (chr) {
                                        if (chr->handle == att_handle) {
+                                               *is_own_handle = true; /* Attribute matched */
                                                if (chr->write_value_requested_cb) {
                                                        BT_DBG("GATT Server: char handle found [%s]", chr->uuid);
                                                        *user_data = chr->write_value_requested_user_data;
                                                        *gatt_handle = chr;
                                                        *server = svc;
-                                                       *is_own_handle = true;
                                                        return chr->write_value_requested_cb;
                                                } else
                                                        return NULL;
@@ -1039,11 +1039,11 @@ static bt_gatt_server_write_value_requested_cb __bt_gatt_attribute_get_value_cha
                                                        bt_gatt_descriptor_s *desc = l4->data;
 
                                                        if (desc && desc->handle == att_handle) {
+                                                               *is_own_handle = true; /* Attribute matched */
                                                                if (desc->write_value_requested_cb) {
                                                                        *user_data = desc->write_value_requested_user_data;
                                                                        *gatt_handle = desc;
                                                                        *server = svc;
-                                                                       *is_own_handle = true;
                                                                        BT_DBG("GATT Server: desc handle found [%s]", desc->uuid);
                                                                        return desc->write_value_requested_cb;
                                                                } else