From: Amit Purwar Date: Thu, 24 Jan 2019 13:22:41 +0000 (+0530) Subject: fixed gatt server notification event for acquire notify X-Git-Tag: accepted/tizen/unified/20190129.064355~1^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git;a=commitdiff_plain;h=5618b5e8e900ae4fc0ac938bcff648b6a005d346 fixed gatt server notification event for acquire notify Change-Id: I2b99788b188b3df5f4e64c2966fb1a64bf7ab0ca Signed-off-by: Amit Purwar --- diff --git a/bt-api/bt-event-handler.c b/bt-api/bt-event-handler.c index 6a3ce72..47acff3 100644 --- a/bt-api/bt-event-handler.c +++ b/bt-api/bt-event-handler.c @@ -3852,7 +3852,7 @@ static void __bt_gatt_server_event_filter(GDBusConnection *connection, } 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; diff --git a/bt-api/bt-gatt-service.c b/bt-api/bt-gatt-service.c index 49e2f46..0f0f906 100644 --- a/bt-api/bt-gatt-service.c +++ b/bt-api/bt-gatt-service.c @@ -391,10 +391,14 @@ static void bluetooth_characteristic_info_free(bluetooth_gatt_acquire_notify_inf 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);; @@ -3207,7 +3211,7 @@ void bluetooth_gatt_server_send_acquire_write_response(GVariant * parameters) -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; @@ -3220,18 +3224,21 @@ void bluetooth_gatt_server_send_acquire_notify_response(GVariant * parameters) 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) { @@ -3292,4 +3299,24 @@ void bluetooth_gatt_server_send_acquire_notify_response(GVariant * parameters) 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; + + _bt_gatt_server_event_cb(BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED, + result, &info, + event_info->cb, event_info->user_data); + + } } diff --git a/bt-api/include/bt-gatt-server.h b/bt-api/include/bt-gatt-server.h index bcc5dfe..0877e90 100644 --- a/bt-api/include/bt-gatt-server.h +++ b/bt-api/include/bt-gatt-server.h @@ -9,7 +9,7 @@ extern "C" { 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); #ifdef __cplusplus } diff --git a/bt-service-adaptation/services/gatt/bt-service-gatt.c b/bt-service-adaptation/services/gatt/bt-service-gatt.c index 0395d7c..4ba0750 100644 --- a/bt-service-adaptation/services/gatt/bt-service-gatt.c +++ b/bt-service-adaptation/services/gatt/bt-service-gatt.c @@ -1705,10 +1705,18 @@ static void __bt_handle_gatt_server_acquire_notify_requested(event_gatts_srvc_ac 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; @@ -1717,11 +1725,12 @@ static void __bt_handle_gatt_server_acquire_notify_requested(event_gatts_srvc_ac 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 : ");