From: injun.yang Date: Thu, 11 Jun 2020 00:42:36 +0000 (+0900) Subject: Send a gatt event to sender X-Git-Tag: accepted/tizen/unified/20200710.114128~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F17%2F237717%2F1;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git Send a gatt event to sender [Model] All [BinType] AP [Customer] OPEN [Issue#] N/A [Request] Internal [Occurrence Version] N/A [Problem] All gatt client app receive a gatt read/write completed event. [Cause & Measure] Send dbus signal to all. Just send it to sender only [Checking Method] gatt read / write request [Team] Convergence BT [Developer] Injun Yang [Solution company] Samsung [Change Type] Specification change Change-Id: I66a40b9d5fa087532faacf0ec73032ecf0fa131f Signed-off-by: Wootak Jung --- diff --git a/bt-service/services/bt-service-event-sender.c b/bt-service/services/bt-service-event-sender.c index 6789771..6ccac27 100644 --- a/bt-service/services/bt-service-event-sender.c +++ b/bt-service/services/bt-service-event-sender.c @@ -507,18 +507,6 @@ int _bt_send_event(int event_type, int event, GVariant *param) break; #endif #ifdef TIZEN_GATT_CLIENT - case BLUETOOTH_EVENT_GATT_READ_CHAR: /* GATT Client */ - signal = BT_GATT_CLIENT_READ_CHAR; - break; - case BLUETOOTH_EVENT_GATT_WRITE_CHAR: /* GATT Client */ - signal = BT_GATT_CLIENT_WRITE_CHAR; - break; - case BLUETOOTH_EVENT_GATT_READ_DESC: /* GATT Client */ - signal = BT_GATT_CLIENT_READ_DESC; - break; - case BLUETOOTH_EVENT_GATT_WRITE_DESC: /* GATT Client */ - signal = BT_GATT_CLIENT_WRITE_DESC; - break; case BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED: /* GATT Client */ signal = BT_GATT_CLIENT_SERVICE_CHANGED; break; @@ -608,6 +596,11 @@ int _bt_send_event_to_dest(const char* dest, int event_type, case BT_HDP_EVENT: path = BT_HDP_DEVICE_PATH; break; +#ifdef TIZEN_GATT_CLIENT + case BT_GATT_CLIENT_EVENT: + path = BT_GATT_CLIENT_PATH; + break; +#endif default: BT_ERR("Unknown event"); return BLUETOOTH_ERROR_INTERNAL; @@ -668,6 +661,21 @@ int _bt_send_event_to_dest(const char* dest, int event_type, case BLUETOOTH_EVENT_HDP_DISCONNECTED: signal = BT_HDP_DISCONNECTED; break; +#ifdef TIZEN_GATT_CLIENT + case BLUETOOTH_EVENT_GATT_READ_CHAR: /* GATT Client */ + signal = BT_GATT_CLIENT_READ_CHAR; + break; + case BLUETOOTH_EVENT_GATT_WRITE_CHAR: /* GATT Client */ + signal = BT_GATT_CLIENT_WRITE_CHAR; + break; + case BLUETOOTH_EVENT_GATT_READ_DESC: /* GATT Client */ + signal = BT_GATT_CLIENT_READ_DESC; + break; + case BLUETOOTH_EVENT_GATT_WRITE_DESC: /* GATT Client */ + signal = BT_GATT_CLIENT_WRITE_DESC; + break; +#endif + default: BT_ERR("Unknown event"); return BLUETOOTH_ERROR_INTERNAL; diff --git a/bt-service/services/gatt/bt-service-gatt.c b/bt-service/services/gatt/bt-service-gatt.c index e6460af..59c5867 100644 --- a/bt-service/services/gatt/bt-service-gatt.c +++ b/bt-service/services/gatt/bt-service-gatt.c @@ -212,7 +212,6 @@ typedef struct { } bt_gatt_included_service_info_t; static GSList *list_gatt_info = NULL; - #endif /* App Information structure */ @@ -892,6 +891,24 @@ int _bt_register_server_instance(const char *sender, int adv_handle) } /* Event handlers */ +static void __bt_gatt_get_pending_request_info(int service_function, + char **sender) +{ + GSList *l; + invocation_info_t *req_info = NULL; + + for (l = _bt_get_invocation_list(); l != NULL; l = g_slist_next(l)) { + req_info = l->data; + if (req_info == NULL) + continue; + + if (req_info->service_function == service_function) { + *sender = req_info->sender; + break; + } + } +} + static void __bt_gatt_handle_pending_request_info(int result, int service_function, void *data, unsigned int size) { @@ -3629,7 +3646,9 @@ Note: Even in case of failure, address, handles and result code should be return data); /* Send Event */ - _bt_send_event(BT_GATT_CLIENT_EVENT, + char *sender = NULL; + __bt_gatt_get_pending_request_info(BT_GATT_READ_CHARACTERISTIC, &sender); + _bt_send_event_to_dest(sender, BT_GATT_CLIENT_EVENT, BLUETOOTH_EVENT_GATT_READ_CHAR, param); } @@ -3674,7 +3693,7 @@ static void __bt_handle_client_descriptor_read_data( conn_info = __bt_find_remote_gatt_server_info_from_conn_id( event_data->uuid_status.conn_status.conn_id); - BT_INFO("Descriptor Read result from addr [%s] status [%d]", + BT_DBG("Descriptor Read result from addr [%s] status [%d]", conn_info->addr, event_data->uuid_status.conn_status.status); /* Fill descriptor informations in buffer */ @@ -3699,7 +3718,6 @@ static void __bt_handle_client_descriptor_read_data( if (event_data->uuid_status.conn_status.status != OAL_STATUS_SUCCESS) result = BLUETOOTH_ERROR_INTERNAL; else { - BT_INFO("desc data len:%d", event_data->data_len); if (event_data->data_len > 0) { /* DEBUG */ for (i = 0; i < event_data->data_len; i++) @@ -3764,11 +3782,13 @@ static void __bt_handle_client_descriptor_read_data( data); /* Send Event */ - _bt_send_event(BT_GATT_CLIENT_EVENT, + char *sender = NULL; + __bt_gatt_get_pending_request_info(BT_GATT_READ_DESCRIPTOR_VALUE, &sender); + _bt_send_event_to_dest(sender, BT_GATT_CLIENT_EVENT, BLUETOOTH_EVENT_GATT_READ_DESC, param); } - BT_INFO("Send DBUS rpely for GATT Read Descriptor"); + /* Send DBUS return */ __bt_gatt_handle_pending_request_info(result, BT_GATT_READ_DESCRIPTOR_VALUE, @@ -3855,7 +3875,9 @@ static void __bt_handle_client_characteristic_write_data( event_data->char_id.inst_id); /* Send Event */ - _bt_send_event(BT_GATT_CLIENT_EVENT, + char *sender = NULL; + __bt_gatt_get_pending_request_info(BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE, &sender); + _bt_send_event_to_dest(sender, BT_GATT_CLIENT_EVENT, BLUETOOTH_EVENT_GATT_WRITE_CHAR, param); @@ -3864,6 +3886,7 @@ static void __bt_handle_client_characteristic_write_data( g_free(svc_uuid); if (char_uuid) g_free(char_uuid); + done: /* Send DBUS return */ __bt_gatt_handle_pending_request_info(result, @@ -3901,7 +3924,7 @@ static void __bt_handle_client_descriptor_write_data( return; } - BT_INFO("Descriptor Write callback from addr [%s] status [%d]", + BT_DBG("Descriptor Write callback from addr [%s] status [%d]", conn_info->addr, event_data->conn_status.status); /* Fill descriptor informations in buffer */ @@ -3968,7 +3991,9 @@ static void __bt_handle_client_descriptor_write_data( event_data->descr_id.inst_id); /* Send Event */ - _bt_send_event(BT_GATT_CLIENT_EVENT, + char *sender = NULL; + __bt_gatt_get_pending_request_info(BT_GATT_WRITE_DESCRIPTOR_VALUE, &sender); + _bt_send_event_to_dest(sender, BT_GATT_CLIENT_EVENT, BLUETOOTH_EVENT_GATT_WRITE_DESC, param);