Handling characteristics properties Indicate and Notify functionality 29/188129/3
authorAvichal Agarwal <avichal.a@samsung.com>
Fri, 31 Aug 2018 12:37:33 +0000 (18:07 +0530)
committerPyun DoHyun <dh79.pyun@samsung.com>
Fri, 7 Sep 2018 06:10:35 +0000 (06:10 +0000)
in case of property Indicate StartNotify will be called
in case of property Notify AcquireNotify will be called

Change-Id: Ice299d23be8e68c44f6b0a6746bafa8169529102
Signed-off-by: Avichal Agarwal <avichal.a@samsung.com>
bt-api/bt-gatt-client.c
bt-service-adaptation/services/bt-request-handler.c
include/bluetooth-gatt-client-api.h

index 7e9c2e76b8952032e6aed228c6019106bfc1c484..3a7d8427ab688cf37efe4f8055ca03ae98e3ec4a 100755 (executable)
@@ -2264,7 +2264,7 @@ static bt_gatt_characteristic_notify_info_t *  bluetooth_gatt_client_create_watc
        channel = g_io_channel_unix_new(fd);
        g_io_channel_set_encoding(channel, NULL, NULL);
        g_io_channel_set_buffered(channel, FALSE);
-       g_io_channel_set_close_on_unref(channel, TRUE);
+       g_io_channel_set_close_on_unref(channel, FALSE);
        g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL);
        g_io_add_watch(channel, (G_IO_IN | G_IO_ERR | G_IO_HUP),
                         bluetooth_gatt_client_notify_channel_watch_cb, chr_info);
@@ -2278,7 +2278,8 @@ BT_EXPORT_API int bluetooth_gatt_client_watch_characteristics(
                        bt_gatt_handle_property_t *service_handle,
                        bt_gatt_handle_property_t *char_handle,
                        int client_id,
-                       gboolean is_notify)
+                       gboolean is_notify,
+                       gboolean is_indicate)
 {
        int result = BLUETOOTH_ERROR_NONE;
        bluetooth_gatt_client_char_prop_info_t param;
@@ -2291,13 +2292,11 @@ BT_EXPORT_API int bluetooth_gatt_client_watch_characteristics(
        BT_CHECK_PARAMETER(char_handle, return);
 
        chr_info = bluetooth_gatt_client_get_characteristic_notify_info(char_handle->uuid , char_handle->instance_id);
-       if (chr_info) {
+       if (chr_info && !is_notify) {
                BT_INFO("Already CCCD enabled. fd %d", chr_info->notify_fd);
 
-               if (!is_notify)
-                         close(chr_info->notify_fd);
-
-                       return result;
+               close(chr_info->notify_fd);
+               return result;
        }
 
        /* ASync Function, result expected in callback from bt-service */
@@ -2319,6 +2318,7 @@ BT_EXPORT_API int bluetooth_gatt_client_watch_characteristics(
        g_array_append_vals(in_param1, &param, sizeof(bluetooth_gatt_client_char_prop_info_t));
        g_array_append_vals(in_param2, &client_id, sizeof(int));
        g_array_append_vals(in_param3, &is_notify, sizeof(gboolean));
+       g_array_append_vals(in_param4, &is_indicate, sizeof(gboolean));
 
 
        GUnixFDList *out_fd_list = NULL;
index b9cf2215af3e3a0707dc894ef846c7bac48b880e..2acfa314abc189cfcf0f8ffd7887d8253a4f0528 100644 (file)
@@ -2689,6 +2689,7 @@ int __bt_bluez_request(int function_name,
                gboolean is_notify;
                int fd = -1;
                int mtu = 0;
+               gboolean is_indicate;
 
 
                memset(&param, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
@@ -2701,9 +2702,10 @@ int __bt_bluez_request(int function_name,
                                sizeof(int));
                __bt_service_get_parameters(in_param3, &is_notify,
                                sizeof(gboolean));
+               __bt_service_get_parameters(in_param4, &is_indicate,
+                               sizeof(gboolean));
 
-
-               if (is_notify == true) {
+               if (is_indicate == false) {
                        result   = _bt_gatt_acquire_notify(&param , &fd, &mtu);
                        if (BLUETOOTH_ERROR_NONE == result && fd > -1) {
                                BT_INFO("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
index 01f456380a0a2270f1d9d1235747ab982716c644..ef1b632dda9c4756a6436ee2b7bd1987dcb756bb 100644 (file)
@@ -176,11 +176,12 @@ int bluetooth_gatt_client_set_service_change_watcher(
                gboolean enable);
 
 int bluetooth_gatt_client_watch_characteristics(
-                        const char *address,
-                        bt_gatt_handle_property_t *service_handle,
-                        bt_gatt_handle_property_t *char_handle,
-                        int client_id,
-                        gboolean is_notify);
+                       const char *address,
+                       bt_gatt_handle_property_t *service_handle,
+                       bt_gatt_handle_property_t *char_handle,
+                       int client_id,
+                       gboolean is_notify,
+                       gboolean is_indicate);
 
 #ifdef __cplusplus
 }