Add fd param to check fd is valid 94/240294/2
authorWootak Jung <wootak.jung@samsung.com>
Wed, 5 Aug 2020 06:03:03 +0000 (15:03 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Thu, 6 Aug 2020 00:40:44 +0000 (09:40 +0900)
Change-Id: I4dbf3c8576b2b8df8146cfaeaa008e5efc89967d
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
bt-api/bt-gatt-service.c
include/bluetooth-gatt-server-api.h

index 8e55440..ae26396 100644 (file)
@@ -2934,7 +2934,7 @@ BT_EXPORT_API int bluetooth_gatt_server_send_response(const bluetooth_gatt_serve
 }
 
 BT_EXPORT_API int bluetooth_gatt_server_send_indication(bluetooth_device_address_t *addr_hex,
-               const bluetooth_gatt_server_indication_params_t *param,
+               bluetooth_gatt_server_indication_params_t *param,
                const bluetooth_gatt_att_data_t *att_value)
 {
        BT_CHECK_PARAMETER(param, return);
@@ -2954,11 +2954,13 @@ BT_EXPORT_API int bluetooth_gatt_server_send_indication(bluetooth_device_address
        _bt_convert_addr_type_to_string(addr, addr_hex->addr);
        fd =  bluetooth_get_characteristic_fd(param->atrribute_handle, addr);
 
-       if (fd > -1)
+       if (fd > -1) {
                result  = bluetooth_gatt_write_characteristics_value_to_fd_(fd, att_value->data, att_value->length, NULL);
-       else
+               param->fd = fd;
+       } else {
                result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GATT_SERVER_SEND_INDICATION,
                                in_param1, in_param2, in_param3, in_param4, &out_param);
+       }
 
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
index 89100ab..6265219 100644 (file)
@@ -81,6 +81,7 @@ typedef struct {
        bluetooth_device_address_t device_address;      /**< device address */
        gboolean need_confirmation;
        int instance_id;
+       int fd; /**< handle fd if existing */
 } bluetooth_gatt_server_indication_params_t;
 
 /**
@@ -299,7 +300,7 @@ int bluetooth_gatt_server_stop_service(int service_handle, int instance_id);
 int bluetooth_gatt_server_delete_service(int service_handle, int instance_id);
 
 int bluetooth_gatt_server_send_indication(bluetooth_device_address_t *addr_hex,
-               const bluetooth_gatt_server_indication_params_t *param,
+               bluetooth_gatt_server_indication_params_t *param,
                const bluetooth_gatt_att_data_t *att_value);
 
 int bluetooth_gatt_server_send_response(const bluetooth_gatt_server_response_params_t *param,