} else if (strcasecmp(signal_name, BT_GATT_SERVER_ACQUIRE_NOTIFICATION) == 0) {
- bluetooth_gatt_server_send_acquire_notify_response(parameters);
+ bluetooth_gatt_server_send_acquire_notify_response(parameters, event_info);
} else if (strcasecmp(signal_name, BT_GATT_SERVER_NOTIFICATION_COMPLETED) == 0) {
const char *address = NULL;
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);
static gboolean bluetooth_gatt_write_channel_watch_cb(GIOChannel *gio,
GIOCondition cond, gpointer data)
{
+ BT_INFO("+");
+
bluetooth_gatt_acquire_notify_info_t *chr_info = (bluetooth_gatt_acquire_notify_info_t *)data;
- if (!chr_info)
+ if (!chr_info) {
+ BT_INFO("chr_info is NULL");
return FALSE;
+ }
if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
BT_ERR("Error : GIOCondition %d, []", cond);;
-void bluetooth_gatt_server_send_acquire_notify_response(GVariant * parameters)
+void bluetooth_gatt_server_send_acquire_notify_response(GVariant * parameters, bt_event_info_t *event_info)
{
int con_id = -1;
int tran_id = -1;
int result = -1;
int fd = -1;
bluetooth_gatt_acquire_notify_info_t *chr_info;
+ const char *address = NULL;
- g_variant_get(parameters, "(iiiiii)",
+ g_variant_get(parameters, "(iiiiiis)",
&result,
&con_id,
&tran_id,
&att_han,
&mtu,
- &offset);
+ &offset,
+ &address);
BT_DBG("GATT ServerAcquire Conn ID: [%d]", con_id);
BT_DBG("GATT Server Acquire notify att handle:[%d]", att_han);
BT_DBG("GATT Server Acquire Notify Offset: [%d]", offset);
+ BT_DBG("GATT Server Acquire Notify address: [%s]", address);
if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipefd) < 0) {
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);
BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ //send
+ if (result == BLUETOOTH_ERROR_NONE) {
+
+ BT_INFO("sending gatt server notification state changed event");
+ bluetooth_gatt_server_notification_changed_t info;
+ bluetooth_device_address_t dev_address = { {0} };
+ memset(&info, 0x00, sizeof(bluetooth_gatt_server_notification_changed_t));
+
+ _bt_convert_addr_string_to_type(dev_address.addr, address);
+ memcpy(info.device_address.addr,
+ 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,
+ event_info->cb, event_info->user_data);
+
+ }
+}
+
+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);
+ }
+ }
}
void bluetooth_gatt_server_send_acquire_write_response(GVariant * parameter);
-void bluetooth_gatt_server_send_acquire_notify_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
}
</policy>
<policy context="default">
<deny own_prefix="org.bt.frwk"/>
- <deny send_destination_prefix="org.bt.frwk"/>
+ <allow own_prefix="org.bt.frwk"/>
+ <deny send_destination_prefix="org.bt.frwk" send_interface="org.bluez.Profile1"/>
<deny own_prefix="org.frwk.gatt_service"/>
- <deny send_destination_prefix="org.frwk.gatt_service"/>
+ <allow own_prefix="org.frwk.gatt_service"/>
+ <deny send_destination_prefix="org.frwk.gatt_service" send_interface="org.bluez.GattDescriptor1"/>
+ <deny send_destination_prefix="org.frwk.gatt_service" send_interface="org.bluez.GattCharacteristic1"/>
</policy>
</busconfig>
GVariant *param = NULL;
int result = BLUETOOTH_ERROR_NONE;
struct gatt_server_req_info *req_info = NULL;
+ bluetooth_device_address_t dev_addr;
+ char address[BT_ADDRESS_STRING_SIZE] = { 0 };
BT_INFO("GATT Server ACQUIRE Notify Req Connection ID: [%d]", event->attr_trans.conn_id);
BT_INFO("GATT Server ACQUIRE Notify Req Transaction ID:[%d]", event->attr_trans.trans_id);
BT_INFO("GATT Server ACQUIRE Notify Req Attribute Handle: [%d]", event->attr_trans.attr_handle);
+ BT_INFO("GATT Server ACQUIRE notify Req address : [%s]", address);
+
+ memcpy(dev_addr.addr, event->address.addr, 6);
+ _bt_convert_addr_type_to_string(address,
+ (unsigned char *)dev_addr.addr);
+ BT_INFO("GATT Server ACQUIRE notify Req remote address : [%s]", address);
req_info = g_new0(struct gatt_server_req_info, 1);
req_info->request_id = event->attr_trans.trans_id;
req_info->request_type = BLUETOOTH_GATT_REQUEST_TYPE_ACQUIRE_NOTIFY;
gatt_server_requests = g_slist_append(gatt_server_requests, req_info);
- param = g_variant_new("(iiiiii)", result,
+ param = g_variant_new("(iiiiiis)", result,
event->attr_trans.conn_id,
event->attr_trans.trans_id,
event->attr_trans.attr_handle,
- event->mtu, event->attr_trans.offset);
+ event->mtu, event->attr_trans.offset,
+ address);
BT_INFO("GATT Server ACQUIRE Notify Req Attribute : ");