Fixed disable notification for acquire notification 10/198610/3
authorAmit Purwar <amit.purwar@samsung.com>
Mon, 28 Jan 2019 05:19:15 +0000 (10:49 +0530)
committerAmit Purwar <amit.purwar@samsung.com>
Mon, 28 Jan 2019 06:03:43 +0000 (11:33 +0530)
Change-Id: I8b870f29ec3c71d6a0b75e915307b76e57d33ad7
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
bt-api/bt-event-handler.c
bt-api/bt-gatt-service.c
bt-api/include/bt-gatt-server.h

index 47acff3..105d1cc 100644 (file)
@@ -3898,6 +3898,9 @@ static void __bt_gatt_server_event_filter(GDBusConnection *connection,
                BT_INFO("GATT Server: Notification Enabled?? Handle: [%d] address [%s] Is Enabled [%d] result [%d]",
                                info.handle, address, info.notification, result);
 
+               if (info.notification == FALSE)
+                       cleanup_gatt_acquire_fd(info.handle);
+
                _bt_gatt_server_event_cb(BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED,
                                result, &info,
                                event_info->cb, event_info->user_data);
index 0f0f906..91149a8 100644 (file)
@@ -3272,6 +3272,7 @@ void  bluetooth_gatt_server_send_acquire_notify_response(GVariant * parameters,
                                        chr_info->write_fd = fd;
 
 
+                               BT_INFO("setting up g_io channel");
                                channel = g_io_channel_unix_new(fd);
                                g_io_channel_set_encoding(channel, NULL, NULL);
                                g_io_channel_set_buffered(channel, FALSE);
@@ -3313,6 +3314,7 @@ void  bluetooth_gatt_server_send_acquire_notify_response(GVariant * parameters,
                                                        dev_address.addr,
                                                        BLUETOOTH_ADDRESS_LENGTH);
                                        info.handle = att_han;
+                                       info.notification = TRUE;
 
                                        _bt_gatt_server_event_cb(BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED,
                                                        result, &info,
@@ -3320,3 +3322,21 @@ void  bluetooth_gatt_server_send_acquire_notify_response(GVariant * parameters,
 
                                }
 }
+
+void cleanup_gatt_acquire_fd(int handle)
+{
+       bluetooth_gatt_acquire_notify_info_t *chr_info = NULL;
+
+       BT_INFO("+");
+
+       chr_info = bluetooth_get_characteristic_info_from_path(handle);
+
+       if (chr_info != NULL) {
+               BT_INFO("GATT Server: acquire notification char info found");
+
+               if (chr_info->write_fd >= 0) {
+                       BT_INFO("closing fd");
+                       close(chr_info->write_fd);
+               }
+       }
+}
index 0877e90..89c9b86 100644 (file)
@@ -11,6 +11,9 @@ void  bluetooth_gatt_server_send_acquire_write_response(GVariant * parameter);
 
 void  bluetooth_gatt_server_send_acquire_notify_response(GVariant * parameter, bt_event_info_t *event_info);
 
+void cleanup_gatt_acquire_fd(int handle);
+
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */