Add response_needed parameter in the write value requested callback 53/101653/6
authorDoHyun Pyun <dh79.pyun@samsung.com>
Fri, 2 Dec 2016 01:40:55 +0000 (10:40 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 5 Dec 2016 01:46:19 +0000 (10:46 +0900)
Change-Id: I24a0b80967e0d6f21136571fd75d1a0acf1c81bb
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
include/mobile/bluetooth_type.h
include/tv/bluetooth_type.h
include/wearable/bluetooth_type.h
src/bluetooth-common.c
test/bt_unit_test.c

index c49bc704c026a7bee1bfdff9fca900393e91076e..aa81ff5bd4b4828078a029f1902ee12364830022 100644 (file)
@@ -1818,6 +1818,7 @@ typedef void (*bt_gatt_connection_state_changed_cb)(int result, bool connected,
  * @param[in] request_id The identification of this request. It will be used to send a response.
  * @param[in] server The GATT server handle
  * @param[in] gatt_handle The characteristic or descriptor's GATT handle which has an old value
+ * @param[in] response_needed Indicates whether a response is required by the remote device - @c true if required, @c false if not
  * @param[in] offset The requested offset from where the @a gatt_handle value will be updated
  * @param[in] value The new value
  * @param[in] len The length of @a value
@@ -1828,7 +1829,7 @@ typedef void (*bt_gatt_connection_state_changed_cb)(int result, bool connected,
  */
 typedef void (*bt_gatt_server_write_value_requested_cb) (const char *remote_address,
                                int request_id, bt_gatt_server_h server,
-                               bt_gatt_h gatt_handle, int offset,
+                               bt_gatt_h gatt_handle, bool response_needed, int offset,
                                const char *value, int len, void *user_data);
 
 /**
index d4af7a916573a0ff484f1411c310939af6770ff4..f71fd37fc1ca36f2612dcbe94ecd01b1077b4868 100644 (file)
@@ -1819,6 +1819,7 @@ typedef void (*bt_gatt_connection_state_changed_cb)(int result, bool connected,
  * @param[in] request_id The identification of this request. It will be used to send a response.
  * @param[in] server The GATT server handle
  * @param[in] gatt_handle The characteristic or descriptor's GATT handle which has an old value
+ * @param[in] response_needed Indicates whether a response is required by the remote device - @c true if required, @c false if not
  * @param[in] offset The requested offset from where the @a gatt_handle value will be updated
  * @param[in] value The new value
  * @param[in] len The length of @a value
@@ -1829,7 +1830,7 @@ typedef void (*bt_gatt_connection_state_changed_cb)(int result, bool connected,
  */
 typedef void (*bt_gatt_server_write_value_requested_cb) (const char *remote_address,
                                int request_id, bt_gatt_server_h server,
-                               bt_gatt_h gatt_handle, int offset,
+                               bt_gatt_h gatt_handle, bool response_needed, int offset,
                                const char *value, int len, void *user_data);
 
 /**
index c146f53f89e202f6e7eaa80f391031b3710a6b31..9c4402d72e091fef843155cbcba33f853d0294ad 100644 (file)
@@ -1694,6 +1694,7 @@ typedef void (*bt_gatt_connection_state_changed_cb)(int result, bool connected,
  * @param[in] request_id The identification of this request. It will be used to send a response.
  * @param[in] server The GATT server handle
  * @param[in] gatt_handle The characteristic or descriptor's GATT handle which has an old value
+ * @param[in] response_needed Indicates whether a response is required by the remote device - @c true if required, @c false if not
  * @param[in] offset The requested offset from where the @a gatt_handle value will be updated
  * @param[in] value The new value
  * @param[in] len The length of @a value
@@ -1704,7 +1705,7 @@ typedef void (*bt_gatt_connection_state_changed_cb)(int result, bool connected,
  */
 typedef void (*bt_gatt_server_write_value_requested_cb) (const char *remote_address,
                                int request_id, bt_gatt_server_h server,
-                               bt_gatt_h gatt_handle, int offset,
+                               bt_gatt_h gatt_handle, bool response_needed, int offset,
                                const char *value, int len, void *user_data);
 
 /**
index 790d9c7aa29df02595175b5c4797d5c34066de47..9e284995f90854aeb31fd4c85817a581229902a2 100644 (file)
@@ -2042,6 +2042,9 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
 
                BT_INFO("BLUETOOTH_EVENT_GATT_SERVER_VALUE_CHANGE");
                if (cb == NULL) {
+                       if (value_change->response_needed == FALSE)
+                               return;
+
                        bluetooth_gatt_send_response(value_change->req_id,
                                                                BLUETOOTH_GATT_ATT_REQUEST_TYPE_WRITE,
                                                                BLUETOOTH_ERROR_INTERNAL, 0, NULL, 0);
@@ -2049,7 +2052,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
                }
 
                cb(value_change->address, value_change->req_id, value_change->service_handle,
-                                       gatt_handle, value_change->offset,
+                                       gatt_handle, value_change->offset, value_change->response_needed,
                                        (char *)value_change->att_value, value_change->val_len, user_data);
                break;
        }
@@ -2131,7 +2134,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
                                                /* TODO : Fix build error temporary */
                                                if (chr->write_value_requested_cb)
                                                        chr->write_value_requested_cb(NULL, 0, (bt_gatt_server_h)serv, (bt_gatt_h)chr,
-                                                                                       0, (char*)char_val->char_value, char_val->val_len,
+                                                                                       0, TRUE, (char*)char_val->char_value, char_val->val_len,
                                                                                        chr->write_value_requested_user_data);
                                        }
                                }
index e9c6ad3caf36662db15781536e4d1aadb0c4b9a5..7918c2e22c763ca35a88aa71ddd36b3dc4503389 100644 (file)
@@ -2561,11 +2561,12 @@ void __bt_gatt_server_notification_sent_cb(int result,
 
 void __bt_gatt_server_write_value_requested_cb(const char *remote_address,
                                int request_id, bt_gatt_server_h server,
-                               bt_gatt_h gatt_handle, int offset,
+                               bt_gatt_h gatt_handle, bool response_needed, int offset,
                                const char *value, int len, void *user_data)
 {
        int i, resp_status =  BT_ERROR_NONE;
        TC_PRT("remote_address : %s", remote_address);
+       TC_PRT("Response needed : %d", response_needed);
        TC_PRT("offset : %d", offset);
        TC_PRT("len [%d] : ", len);
        for (i = 0; i < len; i++)