From c77ac1ef1da78a29776db3bdbec45294fdf4d787 Mon Sep 17 00:00:00 2001 From: "injun.yang" Date: Mon, 13 Jan 2020 13:51:30 +0900 Subject: [PATCH] Code clean up for debug message Change-Id: Ic49ccf5c49657210fd68e88823111ac4d6b9077f --- bt-api/bt-event-handler.c | 26 +- bt-api/bt-gatt-client.c | 81 +++--- bt-core/bt-core-dbus-handler.c | 2 - bt-oal/bluez_hal/src/bt-hal-event-receiver.c | 22 +- bt-oal/bluez_hal/src/bt-hal-gatt-client.c | 212 ++++++---------- bt-oal/bluez_hal/src/bt-hal-internal.h | 20 ++ bt-service-adaptation/services/bt-service-common.c | 279 +++++++++++++++++++++ .../services/gatt/bt-service-gatt.c | 30 +-- .../services/include/bt-service-common.h | 2 + .../services/obex/bt-service-obex-event-receiver.c | 17 +- 10 files changed, 445 insertions(+), 246 deletions(-) diff --git a/bt-api/bt-event-handler.c b/bt-api/bt-event-handler.c index 0827627..7223b57 100644 --- a/bt-api/bt-event-handler.c +++ b/bt-api/bt-event-handler.c @@ -3571,8 +3571,6 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, GVariant *parameters, gpointer user_data) { - BT_DBG("GATT Client event handler Entry >>"); - bt_event_info_t *event_info; int result = BLUETOOTH_ERROR_NONE; @@ -3581,7 +3579,7 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, if (strcasecmp(signal_name, BT_GATT_CHAR_VAL_CHANGED) == 0) { /* Done */ /* Event: BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED */ - BT_INFO("GATT Client event[BT_GATT_CHAR_VAL_CHANGED]"); + BT_DBG("GATT Client event[BT_GATT_CHAR_VAL_CHANGED]"); bt_gatt_char_property_t char_prop; const char *address = NULL; GVariant *data_var = NULL; @@ -3590,7 +3588,6 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, GVariant *char_uuid_var = NULL; int svc_uuid_len = 0; int char_uuid_len = 0; - unsigned int i; memset(&char_prop, 0x00, sizeof(bt_gatt_char_property_t)); @@ -3623,15 +3620,15 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, char_prop.svc_prop.instance_id = svc_inst; /* DEBUG */ - for (i = 0; i < char_prop.val_len; i++) - BT_INFO("Data[%d] = [0x%x]", i, char_prop.value[i]); + // for (i = 0; i < char_prop.val_len; i++) + // BT_INFO("Data[%d] = [0x%x]", i, char_prop.value[i]); _bt_gatt_client_event_cb(BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED, result, &char_prop, event_info->cb, event_info->user_data); } else if (strcasecmp(signal_name, BT_GATT_CLIENT_READ_CHAR) == 0) { /* Done */ /* Event: BLUETOOTH_EVENT_GATT_READ_CHAR */ - BT_INFO("GATT Client event[BT_GATT_CLIENT_READ_CHAR]"); + BT_DBG("GATT Client event[BT_GATT_CLIENT_READ_CHAR]"); bt_gatt_char_property_t char_prop; const char *address = NULL; GVariant *data_var = NULL; @@ -3640,7 +3637,6 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, GVariant *char_uuid_var = NULL; int svc_uuid_len = 0; int char_uuid_len = 0; - unsigned int i; memset(&char_prop, 0x00, sizeof(bt_gatt_char_property_t)); @@ -3658,11 +3654,10 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, &data_var); g_strlcpy(char_prop.address, address, BT_ADDRESS_STRING_SIZE); - BT_INFO("GATT Client Read Callback from [%s] svc inst [%d] char val len [%d] char inst [%d]", + BT_DBG("GATT Client Read Callback from [%s] svc inst [%d] char val len [%d] char inst [%d]", address, svc_inst, char_prop.val_len, char_prop.prop.instance_id); if (char_prop.val_len > 0) { - BT_INFO("Get the read data"); /* Copy Data */ memcpy(&char_prop.value, g_variant_get_data(data_var), char_prop.val_len); } @@ -3674,15 +3669,15 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, char_prop.svc_prop.instance_id = svc_inst; /* DEBUG */ - for (i = 0; i < char_prop.val_len; i++) - BT_INFO("Data[%d] = [0x%x]", i, char_prop.value[i]); + // for (i = 0; i < char_prop.val_len; i++) + // BT_INFO("Data[%d] = [0x%x]", i, char_prop.value[i]); _bt_gatt_client_event_cb(BLUETOOTH_EVENT_GATT_READ_CHAR, result, &char_prop, event_info->cb, event_info->user_data); } else if (strcasecmp(signal_name, BT_GATT_CLIENT_WRITE_CHAR) == 0) { /* Done */ /* Event: BLUETOOTH_EVENT_GATT_WRITE_CHAR */ - BT_INFO("GATT Client event[BT_GATT_CLIENT_WRITE_CHAR]"); + BT_DBG("GATT Client event[BT_GATT_CLIENT_WRITE_CHAR]"); bt_gatt_char_property_t char_prop; const char *address = NULL; GVariant *svc_uuid_var = NULL; @@ -3720,7 +3715,7 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, event_info->cb, event_info->user_data); } else if (strcasecmp(signal_name, BT_GATT_CLIENT_READ_DESC) == 0) { /* Done */ /* Event: BLUETOOTH_EVENT_GATT_READ_DESC */ - BT_INFO("GATT Client event[BT_GATT_CLIENT_READ_DESC]"); + BT_DBG("GATT Client event[BT_GATT_CLIENT_READ_DESC]"); bt_gatt_char_descriptor_property_t desc_prop; const char *address = NULL; GVariant *data_var = NULL; @@ -3781,7 +3776,7 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, event_info->cb, event_info->user_data); } else if (strcasecmp(signal_name, BT_GATT_CLIENT_WRITE_DESC) == 0) { /* Done */ /* Event: BLUETOOTH_EVENT_GATT_WRITE_DESC */ - BT_INFO("GATT Client event[BT_GATT_CLIENT_WRITE_DESC]"); + BT_DBG("GATT Client event[BT_GATT_CLIENT_WRITE_DESC]"); bt_gatt_char_descriptor_property_t desc_prop; const char *address = NULL; GVariant *svc_uuid_var = NULL; @@ -3830,7 +3825,6 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection, event_info->cb, event_info->user_data); } - BT_DBG("GATT Client event handler Exit <<"); } #endif diff --git a/bt-api/bt-gatt-client.c b/bt-api/bt-gatt-client.c index d400804..749088e 100755 --- a/bt-api/bt-gatt-client.c +++ b/bt-api/bt-gatt-client.c @@ -2155,10 +2155,8 @@ static gboolean bluetooth_gatt_client_notify_channel_watch_cb(GIOChannel *gio, { bt_gatt_characteristic_notify_info_t *chr_info = (bt_gatt_characteristic_notify_info_t *)data; - BT_INFO(" FD io NOTIFICATION recived\n"); - if (!chr_info) { - BT_ERR("char INFO nort recieved"); + BT_ERR("chr_info is invalid"); return FALSE; } if (cond & G_IO_IN) { @@ -2194,10 +2192,8 @@ static gboolean bluetooth_gatt_client_notify_channel_watch_cb(GIOChannel *gio, } if (len > 0 && len < chr_info->mtu) { - bt_gatt_char_property_t char_val; - BT_INFO("FD io sending value changed %x %x %x %x %x %x %x %zd \n", buffer[0], buffer[1], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], len); - +// BT_DBG("FD io sending value changed %x %x %x %x %x %x %x %zd \n", buffer[0], buffer[1], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], len); memcpy(char_val.prop.uuid, chr_info->UUID, 16); memcpy(char_val.value, buffer, len); @@ -2205,22 +2201,22 @@ static gboolean bluetooth_gatt_client_notify_channel_watch_cb(GIOChannel *gio, memcpy(char_val.address, chr_info->address, 18); event_info = _bt_event_get_cb_data(BT_GATT_CLIENT_EVENT); - if (event_info) { - _bt_common_event_cb(BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED, BLUETOOTH_ERROR_NONE, &char_val, - event_info->cb, event_info->user_data); + event_info->cb, event_info->user_data); } else { - BT_ERR("eventinfo failed"); + BT_ERR("event_info failed"); } } else BT_ERR("Packet corrupted"); + g_free(buffer); return TRUE; } + if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) { BT_ERR("Error : GIOCondition %d, [%s]", cond, chr_info->UUID); g_io_channel_shutdown(gio, TRUE, NULL); @@ -2289,8 +2285,6 @@ BT_EXPORT_API int bluetooth_gatt_client_watch_characteristics( bluetooth_gatt_client_char_prop_info_t param; bt_gatt_characteristic_notify_info_t *chr_info; - BT_DBG("+"); - BT_CHECK_PARAMETER(address, return); BT_CHECK_PARAMETER(service_handle, return); BT_CHECK_PARAMETER(char_handle, return); @@ -2349,13 +2343,21 @@ BT_EXPORT_API int bluetooth_gatt_client_watch_characteristics( #endif GUnixFDList *out_fd_list = NULL; + char *svc_name = NULL; + char str_uuid[37]; + + _bt_convert_uuid_type_to_string(str_uuid, param.svc.uuid); + bluetooth_get_uuid_name(str_uuid, &svc_name); + + _bt_convert_uuid_type_to_string(str_uuid, param.characteristic.uuid); + + BT_INFO_C("### Request subscription Notify : %s [%s]", str_uuid, svc_name); + g_free(svc_name); result = _bt_send_request_with_unix_fd_list(BT_BLUEZ_SERVICE, BT_GATT_WATCH_CHARACTERISTIC, in_param1, in_param2, in_param3, in_param4, NULL, &out_param, &out_fd_list); - BT_DBG("result: %x", result); - if (result != BLUETOOTH_ERROR_NONE) { - BT_ERR("Fail to send request"); + BT_ERR("Fail to get Nofify FD. result %d", result); BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); return result; } @@ -2375,6 +2377,7 @@ BT_EXPORT_API int bluetooth_gatt_client_watch_characteristics( fd = fd_list_array[0]; mtu = g_array_index(out_param, int, 0); + BT_INFO("Acquired characteristic Notify FD %d, mtu %d", fd, mtu); chr_info = bluetooth_gatt_client_create_watch_io(fd, char_handle->instance_id, mtu, (char *)address, char_handle->uuid); gatt_characteristic_notify_list = g_slist_append(gatt_characteristic_notify_list, chr_info); @@ -2390,7 +2393,6 @@ BT_EXPORT_API int bluetooth_gatt_client_watch_characteristics( BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); - BT_INFO("Result [%d]", result); return result; } @@ -2402,7 +2404,6 @@ BT_EXPORT_API int bluetooth_gatt_client_read_characteristic_value( int result = BLUETOOTH_ERROR_NONE; bt_user_info_t *user_info; bluetooth_gatt_client_char_prop_info_t param; - BT_DBG("+"); BT_CHECK_PARAMETER(address, return); BT_CHECK_PARAMETER(service_handle, return); @@ -2429,13 +2430,10 @@ BT_EXPORT_API int bluetooth_gatt_client_read_characteristic_value( g_array_append_vals(in_param1, ¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)); - result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_GATT_READ_CHARACTERISTIC, in_param1, in_param2, in_param3, in_param4, user_info->cb, user_info->user_data); - - BT_INFO("result = [%d]", result); BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); return result; } @@ -2449,7 +2447,6 @@ BT_EXPORT_API int bluetooth_gatt_client_read_descriptor_value( int result = BLUETOOTH_ERROR_NONE; bt_user_info_t *user_info; bluetooth_gatt_client_desc_prop_info_t param; - BT_DBG("+"); BT_CHECK_PARAMETER(address, return); BT_CHECK_PARAMETER(service_handle, return); @@ -2479,12 +2476,10 @@ BT_EXPORT_API int bluetooth_gatt_client_read_descriptor_value( g_array_append_vals(in_param1, ¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t)); - result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_GATT_READ_DESCRIPTOR_VALUE, in_param1, in_param2, in_param3, in_param4, user_info->cb, user_info->user_data); - BT_INFO("result = [%d]", result); BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); return result; } @@ -2494,15 +2489,16 @@ static bt_gatt_characteristic_write_info_t * bluetooth_gatt_client_get_characte { GSList *l; char str[37]; - _bt_convert_uuid_type_to_string(str, handle); - BT_INFO("request found UUID [%s], sid [ %d]", str, id); + for (l = gatt_characteristic_write_list; l != NULL; l = l->next) { bt_gatt_characteristic_write_info_t *info = l->data; - _bt_convert_uuid_type_to_string(str, info->UUID); - BT_INFO("UUID [%s], sid [ %d]" , str, info->id); + if (memcmp(info->UUID, handle, 16) == 0 && info->id == id) return info; } + + _bt_convert_uuid_type_to_string(str, handle); + BT_ERR("Unable to get characteristic fd. [%s] id [ %d]", str, id); return NULL; } @@ -2532,17 +2528,16 @@ static int bluetooth_gatt_client_write_characteristics_value_to_fd( int fd, const guint8 *value, int length, int mtu, gpointer user_data) { - int written; - int att_result = BLUETOOTH_ERROR_NONE; - BT_CHECK_PARAMETER(value, return); - written = write(fd, value, length); - if (written != length) { - att_result = BLUETOOTH_ERROR_INTERNAL; - BT_INFO("write data failed %d is ", written); - } else - BT_INFO("write data %s is sucess ", value); + int written; + int att_result = BLUETOOTH_ERROR_NONE; + BT_CHECK_PARAMETER(value, return); + written = write(fd, value, length); + if (written != length) { + att_result = BLUETOOTH_ERROR_INTERNAL; + BT_ERR("write data failed. ret : %d ", written); + } - return att_result; + return att_result; } static void bluetooth_gatt_client_create_write_io_channel(int fd, unsigned char * uuid, int id, int mtu) @@ -2578,7 +2573,6 @@ BT_EXPORT_API int bluetooth_gatt_client_write_characteristic_value_by_type( int result = BLUETOOTH_ERROR_NONE; bt_user_info_t *user_info; bluetooth_gatt_client_char_prop_info_t param; - BT_DBG("+"); BT_CHECK_PARAMETER(address, return); BT_CHECK_PARAMETER(service_handle, return); @@ -2627,12 +2621,11 @@ BT_EXPORT_API int bluetooth_gatt_client_write_characteristic_value_by_type( result = _bt_send_request_with_unix_fd_list(BT_BLUEZ_SERVICE, BT_GATT_ACQUIRE_WRITE, in_param1, in_param2, in_param3, in_param4, NULL, &out_param, &out_fd_list); - BT_DBG("result: %x", result); mtu = g_array_index(out_param, int, 0); if (result != BLUETOOTH_ERROR_NONE) { - BT_ERR("Fail to send request"); + BT_ERR("Fail to get Write FD. result %d", result); BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); return result; } else if (NULL == out_fd_list) { @@ -2654,7 +2647,7 @@ BT_EXPORT_API int bluetooth_gatt_client_write_characteristic_value_by_type( g_free(fd_list_array); g_object_unref(out_fd_list); } - BT_INFO("Acquired characteristic fd %d --------------- mtu %d, ", fd, mtu); + BT_INFO("Acquired characteristic Write FD %d, mtu %d", fd, mtu); if (fd > -1) { @@ -2663,12 +2656,11 @@ BT_EXPORT_API int bluetooth_gatt_client_write_characteristic_value_by_type( result = bluetooth_gatt_client_write_characteristics_value_to_fd(fd, data->data, data->length, mtu, NULL); } else { - BT_INFO(" characteristic info FD is invalid\n"); + BT_ERR("characteristic info FD is invalid"); goto done; } } else { - BT_INFO("Acquired characteristic fd %d --------------- mtu %d, ", fd, mtu); result = bluetooth_gatt_client_write_characteristics_value_to_fd(fd, data->data, data->length, mtu, NULL); } @@ -2696,7 +2688,6 @@ BT_EXPORT_API int bluetooth_gatt_client_write_descriptor_value( int result = BLUETOOTH_ERROR_NONE; bt_user_info_t *user_info; bluetooth_gatt_client_desc_prop_info_t param; - BT_DBG("+"); BT_CHECK_PARAMETER(address, return); BT_CHECK_PARAMETER(service_handle, return); @@ -2828,7 +2819,7 @@ BT_EXPORT_API int bluetooth_gatt_client_deinit( in_param1, in_param2, in_param3, in_param4, &out_param); if (result != BLUETOOTH_ERROR_NONE) - BT_INFO("GATT Client Unregistration failed result [%d]", result); + BT_ERR("GATT Client Unregistration failed result [%d]", result); else BT_INFO("GATT Client Unregistration successful"); diff --git a/bt-core/bt-core-dbus-handler.c b/bt-core/bt-core-dbus-handler.c index 5eb2894..8f393e9 100755 --- a/bt-core/bt-core-dbus-handler.c +++ b/bt-core/bt-core-dbus-handler.c @@ -448,8 +448,6 @@ static void __handle_name_owner_changed(const char *name) { gboolean flight_mode_status; - BT_DBG(""); - flight_mode_status = _bt_core_is_flight_mode_enabled(); if (flight_mode_status == FALSE && _bt_is_flightmode_request() == TRUE) { diff --git a/bt-oal/bluez_hal/src/bt-hal-event-receiver.c b/bt-oal/bluez_hal/src/bt-hal-event-receiver.c index 4da1bf2..470154f 100644 --- a/bt-oal/bluez_hal/src/bt-hal-event-receiver.c +++ b/bt-oal/bluez_hal/src/bt-hal-event-receiver.c @@ -1064,7 +1064,7 @@ static gboolean __bt_hal_event_manager(gpointer data) g_variant_get(param->parameters, "(&o@a{sa{sv}})", &obj_path, &value); if (obj_path == NULL) { - DBG("obj_path is NULL"); + ERR("obj_path is NULL"); return FALSE; } @@ -1106,7 +1106,7 @@ static gboolean __bt_hal_event_manager(gpointer data) /* TODO: Handle Name Owener changed Signal */ if (__bt_hal_get_owner_info(param->parameters, &name, &previous, ¤t)) { - DBG("Fail to get the owner info"); + ERR("Fail to get the owner info"); return FALSE; } @@ -1120,7 +1120,7 @@ static gboolean __bt_hal_event_manager(gpointer data) struct hal_ev_adapter_state_changed ev; struct hal_ev_le_state_changed le_ev; - DBG("Bluetoothd is terminated"); + INFO("Bluetoothd is terminated"); /* Send the disable event in here */ @@ -2054,7 +2054,7 @@ static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *me _bt_hal_convert_device_path_to_address(path, address); DBG("Member: [%s]", member); - ERR_C("Connected [%s] [%s]", !addr_type ? "BREDR" : "LE", address); + ERR_C("### Connected [%s] [%s]", !addr_type ? "BREDR" : "LE", address); if (!addr_type) __bt_hal_send_device_acl_connection_state_event(BT_STATUS_SUCCESS, TRUE, address); else @@ -2070,11 +2070,9 @@ static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *me address = g_malloc0(BT_HAL_ADDRESS_STRING_SIZE); _bt_hal_convert_device_path_to_address(path, address); - DBG("Member: [%s]", member); + ERR_C("### Disconnected [%s] [%d : %s] [%s] [%s]", !addr_type ? "BREDR" : "LE", + disc_reason, _bt_hal_convert_disc_reason_to_string(disc_reason), address, name); - ERR_C("DisConnected [%s] [%s]", !addr_type ? "BREDR" : "LE", address); - DBG("Disconnected Reason [%d : %s]", disc_reason, _bt_hal_convert_disc_reason_to_string(disc_reason)); - DBG("Name: %s", name); if (!addr_type) __bt_hal_send_device_acl_connection_state_event(_bt_hal_convert_disc_reason_to_status(disc_reason), FALSE, address); else @@ -2088,10 +2086,8 @@ static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *me address = g_malloc0(BT_HAL_ADDRESS_STRING_SIZE); _bt_hal_convert_device_path_to_address(path, address); - DBG("Address: %s", address); - DBG("Profile UUID: %s", profile_uuid); - DBG("State: %d", state); - if (strcmp(profile_uuid, HID_UUID) == 0) { + DBG("[%s] %s, state %d", address, profile_uuid, state); + if (strncmp(profile_uuid, HID_UUID, strlen(HID_UUID)) == 0) { DBG("HID Host Profile state: %d", state); if (state == BT_HAL_PROFILE_STATE_CONNECTED) __bt_hal_send_hid_connection_state_event(TRUE, address); @@ -2193,7 +2189,6 @@ static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *me g_free(address); } else if (strcasecmp(member, "AdvReport") == 0) { - DBG("Member: [%s]", member); __bt_hal_handle_adv_report(msg, path); } } @@ -2242,7 +2237,6 @@ static void __bt_hal_handle_adv_report(GVariant *msg, const char *path) memcpy(ev->adv_data, buffer, data_len); size += data_len; - DBG("Send le scan result event to HAL, size: [%zd]", size); gatt_event_cb(HAL_EV_GATT_CLIENT_SCAN_RESULT, buf, size); g_variant_unref(value); } diff --git a/bt-oal/bluez_hal/src/bt-hal-gatt-client.c b/bt-oal/bluez_hal/src/bt-hal-gatt-client.c index 25e371e..ac96d5f 100644 --- a/bt-oal/bluez_hal/src/bt-hal-gatt-client.c +++ b/bt-oal/bluez_hal/src/bt-hal-gatt-client.c @@ -606,7 +606,7 @@ static hal_gattc_service_t* _hal_gatt_client_add_service(hal_gattc_server_info_t conn_info->gatt_list_services = g_slist_append(conn_info->gatt_list_services, gattc_service); - DBG("svc path {%s] svc uuid [%s]", object_path, uuid_str); + DBG("svc path [%s] svc uuid [%s]", object_path, uuid_str); return gattc_service; } @@ -718,11 +718,9 @@ static void browse_service_char(int conn_id) hal_gattc_char_t *char_info = NULL; hal_gattc_desc_t *desc_info = NULL; - DBG("+"); - conn_info = __bt_find_gatt_conn_info_from_conn_id(conn_id); if (conn_info == NULL) { - DBG("conn_info is NULL"); + ERR("conn_info is NULL"); return; } @@ -733,7 +731,7 @@ static void browse_service_char(int conn_id) if (svc_info == NULL) continue; - DBG("svc path [%s]", svc_info->svc_path); + DBG("[%s]", svc_info->svc_path); /* find characteristic object path */ for (k = svc_info->gatt_list_chars; k != NULL; k = g_slist_next(k)) { @@ -741,7 +739,7 @@ static void browse_service_char(int conn_id) if (char_info == NULL) continue; - DBG("char path[%s]", char_info->chr_path); + DBG("[%s]", char_info->chr_path); /* descriptor */ for (m = char_info->gatt_list_descs; m != NULL; m = g_slist_next(m)) { @@ -749,7 +747,7 @@ static void browse_service_char(int conn_id) if (desc_info == NULL) continue; - DBG("desc path[%s]", desc_info->desc_path); + DBG("[%s]", desc_info->desc_path); } } } @@ -792,7 +790,7 @@ static bt_status_t _gattc_client_search_service(int conn_id) conn_info = __bt_find_gatt_conn_info_from_conn_id(conn_id); if (NULL == conn_info) { - DBG("Failed to get the conn_info"); + ERR("Failed to get the conn_info"); return BT_STATUS_FAIL; } @@ -984,8 +982,6 @@ static bt_status_t _hal_gattc_get_characteristic_info(hal_gattc_char_t *gattc_ch gchar* permission; unsigned int char_permission = 0 ; - DBG("+"); - if (gattc_char->chr_path == NULL) { DBG("char path is NULL"); return BT_STATUS_FAIL; @@ -1048,7 +1044,7 @@ static bt_status_t _hal_gattc_get_characteristic_info(hal_gattc_char_t *gattc_ch } else if (!g_strcmp0(key, "Descriptors")) { g_variant_get(value, "ao", &char_desc_iter); while (g_variant_iter_loop(char_desc_iter, "&o", &char_desc_handle)) { - DBG("char descriptor handle : %s", char_desc_handle); + DBG("char descriptor : %s", char_desc_handle); g_ptr_array_add(gp_desc_array, (gpointer)char_desc_handle); } @@ -1076,26 +1072,23 @@ static bt_status_t _gattc_get_all_characteristic(int conn_id, char svc_uuid_str[BT_HAL_UUID_STRING_LEN]; int status = BT_STATUS_FAIL; - DBG("+"); DBG("conn_id[%d]", conn_id); conn_info = __bt_find_gatt_conn_info_from_conn_id(conn_id); if (NULL == conn_info) { - DBG("Failed to get the conn_info for conn_id[%d]", conn_id); + ERR("Failed to get the conn_info for conn_id[%d]", conn_id); return BT_STATUS_FAIL; } /* find service */ gattc_service = _gattc_find_service_from_uuid(conn_info, &srvc_id->id.uuid); if (NULL == gattc_service) { - DBG("Failed to get the gatt service"); + ERR("Failed to get the gatt service"); return BT_STATUS_FAIL; } - DBG("service path [%s]", gattc_service->svc_path); - _bt_hal_convert_uuid_type_to_string(svc_uuid_str, gattc_service->svc_uuid.uu); - DBG("service uuid [%s]", svc_uuid_str); + INFO("%s %s", gattc_service->svc_path + 37, svc_uuid_str); /* find characteristic object path */ for (l = gattc_service->gatt_list_chars; l != NULL; l = g_slist_next(l)) { @@ -1261,24 +1254,21 @@ static bt_status_t _hal_gattc_get_all_descriptor(int conn_id, char char_uuid_str[BT_HAL_UUID_STRING_LEN]; int status = BT_STATUS_FAIL; - DBG("+"); - conn_info = __bt_find_gatt_conn_info_from_conn_id(conn_id); if (NULL == conn_info) { - DBG("Failed to get the conn_info for conn_id[%d]", conn_id); + ERR("Failed to get the conn_info for conn_id[%d]", conn_id); return BT_STATUS_FAIL; } /* find service */ gattc_service = _gattc_find_service_from_uuid(conn_info, &srvc_id->id.uuid); if (NULL == gattc_service) { - DBG("Failed to get the gatt service"); + ERR("Failed to get the gatt service"); return BT_STATUS_FAIL; } - DBG("service path [%s]", gattc_service->svc_path); _bt_hal_convert_uuid_type_to_string(svc_uuid_str, gattc_service->svc_uuid.uu); - DBG("service uuid [%s]", svc_uuid_str); + INFO("%s %s", gattc_service->svc_path + 37, svc_uuid_str); /* find characteristics */ /* a service can have two char with same uuid */ @@ -1288,10 +1278,8 @@ static bt_status_t _hal_gattc_get_all_descriptor(int conn_id, continue; if (!memcmp(&gattc_char->chr_uuid, &char_id->uuid, sizeof(bt_uuid_t))) { - INFO("Found GATT char uuid"); - DBG("char path [%s]", gattc_char->chr_path); _bt_hal_convert_uuid_type_to_string(char_uuid_str, gattc_char->chr_uuid.uu); - DBG("char uuid [%s]", char_uuid_str); + INFO("%s %s", gattc_char->chr_path + 37, char_uuid_str); /* get descriptor uuid */ for (m = gattc_char->gatt_list_descs; m != NULL; m = g_slist_next(m)) { @@ -1384,7 +1372,6 @@ static void __hal_internal_read_char_cb(GObject *source_object, guint8 g_byte; hal_gatt_resp_data_t *resp_data = user_data; int result = BT_STATUS_SUCCESS; - int i; DBG("+"); @@ -1408,10 +1395,11 @@ static void __hal_internal_read_char_cb(GObject *source_object, while (g_variant_iter_loop(iter, "y", &g_byte)) g_byte_array_append(gp_byte_array, &g_byte, 1); - //print the value +/* DBG("value is"); for (i = 0; i < gp_byte_array->len; i++) DBG("%02x", gp_byte_array->data[i]); +*/ //send value event __hal_send_char_read_event(resp_data, result, gp_byte_array->data, gp_byte_array->len); @@ -1440,38 +1428,33 @@ static bt_status_t _hal_read_characteristic_value(int conn_id, btgatt_srvc_id_t char char_uuid_str[BT_HAL_UUID_STRING_LEN]; char* char_handle = NULL; - DBG("+"); - /* get the connection info */ conn_info = __bt_find_gatt_conn_info_from_conn_id(conn_id); if (NULL == conn_info) { - DBG("Failed to get the conn_info for conn_id[%d]", conn_id); + ERR("Failed to get the conn_info for conn_id[%d]", conn_id); return BT_STATUS_FAIL; } /* find service */ gattc_service = _gattc_find_service_from_uuid(conn_info, &srvc_id->id.uuid); if (NULL == gattc_service) { - DBG("Failed to get the gatt service"); + ERR("Failed to get the gatt service"); return BT_STATUS_FAIL; } - DBG("service path [%s]", gattc_service->svc_path); _bt_hal_convert_uuid_type_to_string(svc_uuid_str, gattc_service->svc_uuid.uu); - DBG("service uuid [%s]", svc_uuid_str); - + DBG("%s %s", gattc_service->svc_path + 37, svc_uuid_str); /* find characteristic */ gattc_char = _gattc_find_char_from_uuid(gattc_service, &char_id->uuid, HAL_GATT_CHARACTERISTIC_PROPERTY_READ); if (NULL == gattc_char) { - DBG("Failed to get the gatt char"); + ERR("Failed to get the gatt char"); return BT_STATUS_FAIL; } - DBG("char path [%s]", gattc_char->chr_path); _bt_hal_convert_uuid_type_to_string(char_uuid_str, gattc_char->chr_uuid.uu); - DBG("char uuid [%s]", char_uuid_str); + INFO("%s %s", gattc_char->chr_path + 37, char_uuid_str); g_conn = _bt_hal_get_system_gconn(); if (NULL == g_conn) { @@ -1723,31 +1706,29 @@ static bt_status_t _hal_write_characteristic_value(int conn_id, btgatt_srvc_id_t /* get the connection info */ conn_info = __bt_find_gatt_conn_info_from_conn_id(conn_id); if (NULL == conn_info) { - DBG("Failed to get the conn_info for conn_id[%d]", conn_id); + ERR("Failed to get the conn_info for conn_id[%d]", conn_id); return BT_STATUS_FAIL; } /* find service */ gattc_service = _gattc_find_service_from_uuid(conn_info, &srvc_id->id.uuid); if (NULL == gattc_service) { - DBG("Failed to get the gatt service"); + ERR("Failed to get the gatt service"); return BT_STATUS_FAIL; } - DBG("service path [%s]", gattc_service->svc_path); _bt_hal_convert_uuid_type_to_string(svc_uuid_str, gattc_service->svc_uuid.uu); - DBG("service uuid [%s]", svc_uuid_str); + DBG("%s %s", gattc_service->svc_path + 37, svc_uuid_str); /* find characteristic */ gattc_char = _gattc_find_char_from_uuid(gattc_service, &char_id->uuid, write_prop); if (NULL == gattc_char) { - DBG("Failed to get the gatt char"); + ERR("Failed to get the gatt char"); return BT_STATUS_FAIL; } - DBG("char path [%s]", gattc_char->chr_path); _bt_hal_convert_uuid_type_to_string(char_uuid_str, gattc_char->chr_uuid.uu); - DBG("char uuid [%s]", char_uuid_str); + DBG("%s %s", gattc_char->chr_path + 37, char_uuid_str); g_conn = _bt_hal_get_system_gconn(); if (NULL == g_conn) { @@ -1796,11 +1777,6 @@ bt_status_t btif_get_acquire_write_fd(int conn_id, { CHECK_BTGATT_INIT(); - DBG("+"); - - DBG("svc isntance id:[%d]", srvc_id->id.inst_id); - - hal_gattc_service_t *gattc_service = NULL; hal_gattc_server_info_t * conn_info = NULL; hal_gattc_char_t *gattc_char = NULL; @@ -1810,40 +1786,37 @@ bt_status_t btif_get_acquire_write_fd(int conn_id, int ret = BT_STATUS_SUCCESS; DBG("+"); + DBG("svc isntance id:[%d]", srvc_id->id.inst_id); - /* get the connection info */ + /* get the connection info */ conn_info = __bt_find_gatt_conn_info_from_conn_id(conn_id); if (NULL == conn_info) { - DBG("Failed to get the conn_info for conn_id[%d]", conn_id); + ERR("Failed to get the conn_info for conn_id[%d]", conn_id); return BT_STATUS_FAIL; } /* find service */ gattc_service = _gattc_find_service_from_uuid(conn_info, &srvc_id->id.uuid); if (NULL == gattc_service) { - DBG("Failed to get the gatt service"); + ERR("Failed to get the gatt service"); return BT_STATUS_FAIL; } gattc_char = _gattc_find_char_from_uuid(gattc_service, &char_id->uuid, write_prop); - if (NULL == gattc_char) { - DBG("Failed to get the gatt char"); - return BT_STATUS_FAIL; - } + if (NULL == gattc_char) { + ERR("Failed to get the gatt char"); + return BT_STATUS_FAIL; + } - DBG("char path [%s]", gattc_char->chr_path); _bt_hal_convert_uuid_type_to_string(char_uuid_str, gattc_char->chr_uuid.uu); - DBG("char uuid [%s]", char_uuid_str); - + INFO("%s %s", gattc_char->chr_path + 37, char_uuid_str); ret = __bluetooth_gatt_acquire_write_fd(gattc_char->chr_path, fd, mtu); if (ret != BT_STATUS_SUCCESS) return ret; - - ERR("Characterstics FD erite characterstics fd is %d", *fd); - - return ret; + INFO("Characterstics FD erite characterstics fd is %d", *fd); + return ret; } bt_status_t btif_get_acquire_notify_fd(int conn_id, @@ -1851,11 +1824,6 @@ bt_status_t btif_get_acquire_notify_fd(int conn_id, { CHECK_BTGATT_INIT(); - DBG("+"); - - DBG("svc isntance id:[%d]", srvc_id->id.inst_id); - - hal_gattc_service_t *gattc_service = NULL; hal_gattc_server_info_t * conn_info = NULL; hal_gattc_char_t *gattc_char = NULL; @@ -1865,41 +1833,38 @@ bt_status_t btif_get_acquire_notify_fd(int conn_id, int ret = BT_STATUS_SUCCESS; DBG("+"); + DBG("svc isntance id:[%d]", srvc_id->id.inst_id); - /* get the connection info */ - conn_info = __bt_find_gatt_conn_info_from_conn_id(conn_id); - if (NULL == conn_info) { - DBG("Failed to get the conn_info for conn_id[%d]", conn_id); - return BT_STATUS_FAIL; - } + /* get the connection info */ + conn_info = __bt_find_gatt_conn_info_from_conn_id(conn_id); + if (NULL == conn_info) { + ERR("Failed to get the conn_info for conn_id[%d]", conn_id); + return BT_STATUS_FAIL; + } /* find service */ gattc_service = _gattc_find_service_from_uuid(conn_info, &srvc_id->id.uuid); if (NULL == gattc_service) { - DBG("Failed to get the gatt service"); + ERR("Failed to get the gatt service"); return BT_STATUS_FAIL; } gattc_char = _gattc_find_char_from_uuid(gattc_service, &char_id->uuid, write_prop); - if (NULL == gattc_char) { - DBG("Failed to get the gatt char"); - return BT_STATUS_FAIL; - } + if (NULL == gattc_char) { + ERR("Failed to get the gatt char"); + return BT_STATUS_FAIL; + } - DBG("char path [%s]", gattc_char->chr_path); _bt_hal_convert_uuid_type_to_string(char_uuid_str, gattc_char->chr_uuid.uu); - DBG("char uuid [%s]", char_uuid_str); - + INFO("%s %s", gattc_char->chr_path + 37, char_uuid_str); ret = __bluetooth_gatt_acquire_notify_fd(gattc_char->chr_path, fd, mtu); if (ret != BT_STATUS_SUCCESS) return ret; + INFO("Characterstics FD write characterstics fd is %d", *fd); - ERR("Characterstics FD write characterstics fd is %d", *fd); - - return ret; - + return ret; } @@ -2025,20 +1990,19 @@ static bt_status_t _hal_read_descriptor_value(int conn_id, btgatt_srvc_id_t *srv /* get the connection info */ conn_info = __bt_find_gatt_conn_info_from_conn_id(conn_id); if (NULL == conn_info) { - DBG("Failed to get the conn_info for conn_id[%d]", conn_id); + ERR("Failed to get the conn_info for conn_id[%d]", conn_id); return BT_STATUS_FAIL; } /* find service */ gattc_service = _gattc_find_service_from_uuid(conn_info, &srvc_id->id.uuid); if (NULL == gattc_service) { - DBG("Failed to get the gatt service"); + ERR("Failed to get the gatt service"); return BT_STATUS_FAIL; } - DBG("service path [%s]", gattc_service->svc_path); _bt_hal_convert_uuid_type_to_string(svc_uuid_str, gattc_service->svc_uuid.uu); - DBG("service uuid [%s]", svc_uuid_str); + DBG("%s %s", gattc_service->svc_path + 37, svc_uuid_str); /* find characteristic */ /* service can have two char with same uuid */ @@ -2048,24 +2012,21 @@ static bt_status_t _hal_read_descriptor_value(int conn_id, btgatt_srvc_id_t *srv continue; if (!memcmp(&gattc_char->chr_uuid, &char_id->uuid, sizeof(bt_uuid_t))) { - INFO("Found GATT char uuid"); - DBG("char path [%s]", gattc_char->chr_path); _bt_hal_convert_uuid_type_to_string(char_uuid_str, gattc_char->chr_uuid.uu); - DBG("char uuid [%s]", char_uuid_str); + DBG("%s %s", gattc_char->chr_path + 37, char_uuid_str); /* find descriptor */ gattc_desc = _gattc_find_desc_from_uuid(gattc_char, &desc_id->uuid); if (gattc_desc) { - DBG("desc path [%s]", gattc_desc->desc_path); _bt_hal_convert_uuid_type_to_string(desc_uuid_str, gattc_desc->desc_uuid.uu); - DBG("desc uuid [%s]", desc_uuid_str); + DBG("%s %s", gattc_desc->desc_path + 37, desc_uuid_str); break; } } } if (NULL == gattc_desc) { - DBG("Failed to get the gatt desc"); + ERR("Failed to get the gatt desc"); return BT_STATUS_FAIL; } @@ -2198,27 +2159,26 @@ static bt_status_t _hal_write_descriptor_value(int conn_id, btgatt_srvc_id_t *sr ret = __hal_get_write_prop(write_type, &write_prop); if (BT_STATUS_FAIL == ret) { - DBG("received invalid write type:[%d] ", write_type); + ERR("received invalid write type:[%d] ", write_type); return BT_STATUS_FAIL; } /* get the connection info */ conn_info = __bt_find_gatt_conn_info_from_conn_id(conn_id); if (NULL == conn_info) { - DBG("Failed to get the conn_info for conn_id[%d]", conn_id); + ERR("Failed to get the conn_info for conn_id[%d]", conn_id); return BT_STATUS_FAIL; } /* find service */ gattc_service = _gattc_find_service_from_uuid(conn_info, &srvc_id->id.uuid); if (NULL == gattc_service) { - DBG("Failed to get the gatt service"); + ERR("Failed to get the gatt service"); return BT_STATUS_FAIL; } - DBG("service path [%s]", gattc_service->svc_path); _bt_hal_convert_uuid_type_to_string(svc_uuid_str, gattc_service->svc_uuid.uu); - DBG("service uuid [%s]", svc_uuid_str); + DBG("%s %s", gattc_service->svc_path + 37, svc_uuid_str); /* find characteristic */ /* service can have two char with same uuid */ @@ -2228,24 +2188,21 @@ static bt_status_t _hal_write_descriptor_value(int conn_id, btgatt_srvc_id_t *sr continue; if (!memcmp(&gattc_char->chr_uuid, &char_id->uuid, sizeof(bt_uuid_t))) { - INFO("Found GATT char uuid"); - DBG("char path [%s]", gattc_char->chr_path); _bt_hal_convert_uuid_type_to_string(char_uuid_str, gattc_char->chr_uuid.uu); - DBG("char uuid [%s]", char_uuid_str); + DBG("%s %s", gattc_char->chr_path + 37, char_uuid_str); /* find descriptor */ gattc_desc = _gattc_find_desc_from_uuid(gattc_char, &descr_id->uuid); if (gattc_desc) { - DBG("desc path [%s]", gattc_desc->desc_path); _bt_hal_convert_uuid_type_to_string(desc_uuid_str, gattc_desc->desc_uuid.uu); - DBG("desc uuid [%s]", desc_uuid_str); + DBG("%s %s", gattc_desc->desc_path + 37, desc_uuid_str); break; } } } if (NULL == gattc_desc) { - DBG("Failed to get the gatt desc"); + ERR("Failed to get the gatt desc"); return BT_STATUS_FAIL; } @@ -2382,25 +2339,23 @@ static bt_status_t _hal_register_for_notification(int client_if, /* find service */ gattc_service = _gattc_find_service_from_uuid(conn_info, &srvc_id->id.uuid); if (NULL == gattc_service) { - DBG("Failed to get the gatt service"); + ERR("Failed to get the gatt service"); return BT_STATUS_FAIL; } - DBG("service path [%s]", gattc_service->svc_path); _bt_hal_convert_uuid_type_to_string(svc_uuid_str, gattc_service->svc_uuid.uu); - DBG("service uuid [%s]", svc_uuid_str); + DBG("%s %s", gattc_service->svc_path + 15, svc_uuid_str); /* find characteristic */ gattc_char = _gattc_find_char_from_uuid_for_notify(gattc_service, &char_id->uuid); if (NULL == gattc_char) { - DBG("Failed to get the gatt char"); + ERR("Failed to get the gatt char"); return BT_STATUS_FAIL; } - DBG("char path [%s]", gattc_char->chr_path); _bt_hal_convert_uuid_type_to_string(char_uuid_str, gattc_char->chr_uuid.uu); - DBG("char uuid [%s]", char_uuid_str); + DBG("%s %s", gattc_char->chr_path + 15, char_uuid_str); char_handle = gattc_char->chr_path; @@ -2412,7 +2367,8 @@ static bt_status_t _hal_register_for_notification(int client_if, resp_data = g_malloc0(sizeof(hal_gatt_resp_data_t)); - DBG("#StartNotify"); + INFO_C("### Request StartNotify : %s [%s]", gattc_char->chr_path + 15, char_uuid_str); + g_dbus_connection_call_sync(g_conn, BT_HAL_BLUEZ_NAME, char_handle, @@ -2425,7 +2381,7 @@ static bt_status_t _hal_register_for_notification(int client_if, if (error) { g_dbus_error_strip_remote_error(error); - ERR("### Watch Failed: %s", error->message); + ERR("### StartNotify Failed: %s", error->message); if (g_strrstr(error->message, "Already notifying")) result = BT_STATUS_SUCCESS; else if (g_strrstr(error->message, "In Progress")) @@ -2543,25 +2499,23 @@ static bt_status_t _hal_deregister_for_notification(int client_if, /* find service */ gattc_service = _gattc_find_service_from_uuid(conn_info, &srvc_id->id.uuid); if (NULL == gattc_service) { - DBG("Failed to get the gatt service"); + ERR("Failed to get the gatt service"); return BT_STATUS_FAIL; } - DBG("service path [%s]", gattc_service->svc_path); _bt_hal_convert_uuid_type_to_string(svc_uuid_str, gattc_service->svc_uuid.uu); - DBG("service uuid [%s]", svc_uuid_str); + DBG("%s %s", gattc_service->svc_path + 15, svc_uuid_str); /* find characteristic */ gattc_char = _gattc_find_char_from_uuid_for_notify(gattc_service, &char_id->uuid); if (NULL == gattc_char) { - DBG("Failed to get the gatt char"); + ERR("Failed to get the gatt char"); return BT_STATUS_FAIL; } - DBG("char path [%s]", gattc_char->chr_path); _bt_hal_convert_uuid_type_to_string(char_uuid_str, gattc_char->chr_uuid.uu); - DBG("char uuid [%s]", char_uuid_str); + DBG("%s %s", gattc_char->chr_path + 15, char_uuid_str); char_handle = gattc_char->chr_path; @@ -2573,7 +2527,7 @@ static bt_status_t _hal_deregister_for_notification(int client_if, resp_data = g_malloc0(sizeof(hal_gatt_resp_data_t)); - DBG("#StartNotify"); + INFO("### Request StopNotify : %s [%s]", gattc_char->chr_path + 15, char_uuid_str); g_dbus_connection_call_sync(g_conn, BT_HAL_BLUEZ_NAME, char_handle, @@ -2585,7 +2539,7 @@ static bt_status_t _hal_deregister_for_notification(int client_if, BT_HAL_MAX_DBUS_TIMEOUT, NULL, &error); if (error) { - ERR("### Watch Failed: %s", error->message); + ERR("### StopNotify Failed: %s", error->message); g_clear_error(&error); result = BT_STATUS_FAIL; } @@ -2670,7 +2624,7 @@ static bt_status_t __hal_update_conn_parameter(bt_bdaddr_t *bd_addr, return BT_STATUS_FAIL; } - INFO("### LeConnUpdate"); + INFO("Request LeConnUpdate"); reply = g_dbus_proxy_call_sync(device_proxy, "LeConnUpdate", g_variant_new("(uuuu)", min_int, max_int, latency, timeout), G_DBUS_CALL_FLAGS_NONE, @@ -2692,7 +2646,7 @@ static bt_status_t __hal_update_conn_parameter(bt_bdaddr_t *bd_addr, } g_variant_unref(reply); - INFO("LE Connection parameter Updated"); + DBG("LE Connection parameter Updated"); return ret; } @@ -3359,8 +3313,6 @@ static hal_gattc_client_info_t *__bt_find_gatt_client_info(bt_bdaddr_t *serv_add static hal_gattc_client_info_t *__bt_find_gatt_client_info_from_conn_id(int conn_id) { - DBG("+"); - GSList *l; hal_gattc_client_info_t *info = NULL; @@ -3379,15 +3331,13 @@ static hal_gattc_client_info_t *__bt_find_gatt_client_info_from_conn_id(int conn static hal_gattc_server_info_t *__bt_find_gatt_conn_info_from_conn_id(int conn_id) { - DBG("+"); - GSList *l; hal_gattc_server_info_t *info = NULL; hal_gattc_client_info_t *gattc_client = NULL; gattc_client = __bt_find_gatt_client_info_from_conn_id(conn_id); if (gattc_client == NULL) { - INFO("GATT client conn info not found"); + ERR("GATT client conn info not found"); return NULL; } diff --git a/bt-oal/bluez_hal/src/bt-hal-internal.h b/bt-oal/bluez_hal/src/bt-hal-internal.h index 55430c8..077b081 100644 --- a/bt-oal/bluez_hal/src/bt-hal-internal.h +++ b/bt-oal/bluez_hal/src/bt-hal-internal.h @@ -73,6 +73,26 @@ typedef enum { #define HFP_HF_UUID "0000111e-0000-1000-8000-00805f9b34fb" #define HFP_AG_UUID "0000111f-0000-1000-8000-00805f9b34fb" +/** + * Device disconnection reasons; received from stack + */ +#define BLUETOOTH_ERROR_PAGE_TIMEOUT 0x04 +#define BLUETOOTH_ERROR_AUTH_FAILURE 0x05 +#define BLUETOOTH_ERROR_PIN_OR_KEY_MISSING 0x06 +#define BLUETOOTH_ERROR_CONNECTION_TIMEOUT 0x08 +#define BLUETOOTH_ERROR_CONNECTION_REJECTED_DUE_TO_SECURITY_REASONS 0x0e +#define BLUETOOTH_ERROR_REMOTE_USER_TERM 0x13 +#define BLUETOOTH_ERROR_REMOTE_LOW_RESOURCES 0x14 +#define BLUETOOTH_ERROR_REMOTE_POWER_OFF 0x15 +#define BLUETOOTH_ERROR_LOCAL_HOST_TERM 0x16 +#define BLUETOOTH_ERROR_REPEATED_ATTEMPTS 0x17 +#define BLUETOOTH_ERROR_LMP_RESPONSE_TIMEOUT 0x22 +#define BLUETOOTH_ERROR_LMP_TRANSACTION_COLLISION 0x23 +#define BLUETOOTH_ERROR_INSTANT_PASSED 0x28 +#define BLUETOOTH_ERROR_INSUFFICIENT_SECURITY 0x2f +#define BLUETOOTH_ERROR_CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE 0x3d +#define BLUETOOTH_ERROR_CONNECTION_FAILED_TO_BE_ESTABLISHED 0x3e + /* TODO More declarations to be added in subsequent patches */ #ifdef __cplusplus } diff --git a/bt-service-adaptation/services/bt-service-common.c b/bt-service-adaptation/services/bt-service-common.c index 2aa4800..2ee265c 100644 --- a/bt-service-adaptation/services/bt-service-common.c +++ b/bt-service-adaptation/services/bt-service-common.c @@ -697,6 +697,285 @@ char *_bt_get_profile_uuid128(bt_profile_type_t profile_type) }; } +const char *_bt_convert_uuid_to_string(const char *uuid) +{ +#define SHORT_UUID_COUNT 199 +#define LONG_UUID_COUNT 17 + + if (!uuid) + return NULL; + + int offset = 0; + int uuid_len = 4; + typedef struct { + const char *uuid; + const char *specification_name; + } uuid_name_s; + static uuid_name_s short_uuid_name[SHORT_UUID_COUNT] = { + // List should be sorted by UUID + /* BT Classic Services */ + {"1101", "Serial Port Service"}, + {"1102", "LAN Access Using PPP Service"}, + {"1103", "Dialup Networking Service"}, + {"1104", "IrMCSync Service"}, + {"1105", "OBEX Object Push Service"}, + {"1106", "OBEX File Transfer Service"}, + {"1107", "IrMC Sync Command Service"}, + {"1108", "Headset Service"}, + {"1109", "Cordless Telephony Service"}, + {"110A", "Audio Source Service"}, + {"110B", "Audio Sink Service"}, + {"110C", "AV Remote Control Target Service"}, + {"110D", "Advanced Audio Distribution Profile"}, + {"110E", "AV Remote Control Service"}, + {"110F", "Video Conferencing Service"}, + {"1110", "Intercom Service"}, + {"1111", "Fax Service"}, + {"1112", "Headset Audio Gateway Service"}, + {"1113", "WAP Service"}, + {"1114", "WAP Client Service"}, + {"1115", "PANU Service"}, + {"1116", "NAP Service"}, + {"1117", "GN Service"}, + {"1118", "Direct Printing Service"}, + {"1119", "Reference Printing Service"}, + {"111A", "Basic Imaging Profile"}, + {"111B", "Imaging Responder Service"}, + {"111C", "Imaging Automatic Archive Service"}, + {"111D", "Imaging Reference Objects Service"}, + {"111E", "Handsfree Service"}, + {"111F", "Handsfree Audio Gateway Service"}, + {"1120", "Direct Printing Reference Objects Service"}, + {"1121", "Reflected UI Service"}, + {"1122", "Basic Printing Profile"}, + {"1123", "Printing Status Service"}, + {"1124", "Human Interface Device Service"}, + {"1125", "Hardcopy Cable Replacement Profile"}, + {"1126", "HCR Print Service"}, + {"1127", "HCR Scan Service"}, + {"112D", "SIM Access Service"}, + {"112E", "Phonebook Access PCE Service"}, + {"112F", "Phonebook Access PSE Service"}, + {"1130", "Phonebook Access Profile"}, + {"1132", "Message Access Server Service"}, + {"1133", "Message Notification Server Service"}, + {"1134", "Message Access Profile"}, + {"1200", "PnP Information Service"}, + {"1201", "Generic Networking Service"}, + {"1202", "Generic File Transfer Service"}, + {"1203", "Generic Audio Service"}, + {"1204", "Generic Telephony Service"}, + {"1205", "UPnP Service"}, + {"1206", "UPnP Ip Service"}, + {"1303", "Video Source Service"}, + {"1304", "Video Sink Service"}, + {"1305", "Video Distribution Profile"}, + {"1400", "Health Device Profile"}, + {"1401", "HDP Source Service"}, + {"1402", "HDP Sink Service"}, + + /* GATT Services */ + {"1800", "Generic Access"}, + {"1801", "Generic Attribute"}, + {"1802", "Immediate Alert"}, + {"1803", "Link Loss"}, + {"1804", "Tx Power"}, + {"1805", "Current Time Service"}, + {"1806", "Reference Time Update Service"}, + {"1807", "Next DST Change Service"}, + {"1808", "Glucose"}, + {"1809", "Health Thermometer"}, + {"180A", "Device Information"}, + {"180D", "Heart Rate"}, + {"180F", "Battery Service"}, + {"1810", "Blood Pressure"}, + {"1811", "Alert Notification Service"}, + {"1812", "Human Interface Device"}, + {"1813", "Scan Parameters"}, + {"1814", "Running Speed and Cadence"}, + {"1815", "Automation IO"}, + {"1816", "Cycling Speed and Cadence"}, + {"1818", "Cycling Power"}, + {"1819", "Location and Navigation"}, + {"181A", "Environmental Sensing"}, + {"181B", "Body Composition"}, + {"181C", "User Data"}, + {"181D", "Weight Scale"}, + {"181E", "Bond Management"}, + {"181F", "Continuous Glucose Monitoring"}, + {"1820", "Internet Protocol Support Service"}, + {"1821", "Indoor Positioning"}, + {"1822", "Pulse Oximeter Service"}, + {"1823", "HTTP Proxy"}, + {"1824", "Transport Discovery"}, + {"1825", "Object Transfer Service"}, + {"1826", "Fitness Machine"}, + {"1827", "Mesh Provisioning Service"}, + {"1828", "Mesh Proxy Service"}, + {"1829", "Reconnection Configuration"}, + {"183A", "Insulin Delivery"}, + + /* GATT Declarations */ + {"2800", "Primary Service Declaration"}, + {"2801", "Secondary Service Declaration"}, + {"2802", "Include Declaration"}, + {"2803", "Characteristic Declaration"}, + + /* GATT Descriptors */ + {"2900", "Characteristic Extended Properties"}, + {"2901", "Characteristic User Description"}, + {"2902", "Client Characteristic Configuration"}, + {"2903", "Server Characteristic Configuration"}, + {"2904", "Characteristic Format"}, + {"2905", "Characteristic Aggregate Formate"}, + {"2906", "Valid Range"}, + {"2907", "External Report Reference"}, + {"2908", "Report Reference"}, + + /* GATT Characteristics */ + {"2A00", "Device Name"}, + {"2A01", "Appearance"}, + {"2A02", "Peripheral Privacy Flag"}, + {"2A03", "Reconnection Address"}, + {"2A04", "Peripheral Preferred Connection Parameters"}, + {"2A05", "Service Changed"}, + {"2A06", "Alert Level"}, + {"2A07", "Tx Power Level"}, + {"2A08", "Date Time"}, + {"2A09", "Day of Week"}, + {"2A0A", "Day Date Time"}, + {"2A11", "Time with DST"}, + {"2A12", "Time Accuracy"}, + {"2A13", "Time Source"}, + {"2A14", "Reference Time Information"}, + {"2A16", "Time Update Control Point"}, + {"2A17", "Time Update State"}, + {"2A18", "Glucose Measurement"}, + {"2A19", "Battery Level"}, + {"2A1C", "Temperature Measurement"}, + {"2A1D", "Temperature Type"}, + {"2A1E", "Intermediate Temperature"}, + {"2A21", "Measurement Interval"}, + {"2A23", "System ID"}, + {"2A24", "Model Number String"}, + {"2A25", "Serial Number String"}, + {"2A26", "Firmware Revision String"}, + {"2A27", "Hardware Revision String"}, + {"2A28", "Software Revision String"}, + {"2A29", "Manufacturer Name String"}, + {"2A2A", "IEEE 11073-20601 Regulatory Certification Data List"}, + {"2A2B", "Current Time"}, + {"2A34", "Glucose Measurement Context"}, + {"2A35", "Blood Pressure Measurement"}, + {"2A37", "Heart Rate Measurement"}, + {"2A38", "Body Sensor Location"}, + {"2A39", "Heart Rate Control Point"}, + {"2A3F", "Alert Status"}, + {"2A46", "New Alert"}, + {"2A49", "Blood Pressure Feature"}, + {"2A4A", "HID Information"}, + {"2A4C", "HID Control Point"}, + {"2A50", "PnP ID"}, + {"2A51", "Glucose Feature"}, + {"2A52", "Record Access Control Point"}, + {"2A53", "RSC Measurement"}, + {"2A54", "RSC Feature"}, + {"2A55", "SC Control Point"}, + {"2A56", "Digital"}, + {"2A58", "Analog"}, + {"2A5A", "Aggregate"}, + {"2A5B", "CSC Measurement"}, + {"2A5C", "CSC Feature"}, + {"2A5D", "Sensor Location"}, + {"2A63", "Cycling Power Measurement"}, + {"2A64", "Cycling Power Vector"}, + {"2A65", "Cycling Power Feature"}, + {"2A66", "Cycling Power Control Point"}, + {"2A67", "Location and Speed"}, + {"2A68", "Navigation"}, + {"2A6D", "Pressure"}, + {"2A6E", "Temperature"}, + {"2A8E", "Height"}, + {"2A90", "Last Name"}, + {"2A91", "Maximum Recommended Heart Rate"}, + {"2A92", "Resting Heart Rate"}, + {"2A98", "Weight"}, + {"2A9B", "Body Composition Feature"}, + {"2A9C", "Body Composition Measurement"}, + {"2A9D", "Weight Measurement"}, + {"2AA2", "Language"}, + {"2AA4", "Bond Management Control Point"}, + {"2AA5", "Bond Management Features"}, + {"2AA6", "Central Address Resolution"}, + {"2AAD", "Indoor Positioning Configuration"}, + {"2AB5", "Location Name"}, + {"2AB6", "URI"}, + {"2ABC", "TDS Control Point"}, + {"2AC9", "Resolvable Private Address Only"}, + {"2ACC", "Fitness Machine Feature"}, + {"2ACE", "Cross Trainer Data"}, + {"2AD3", "Training Status"}, + {"2AD7", "Supported Heart Rate Range"}, + {"2AD9", "Fitness Machine Control Point"}, + {"2ADA", "Fitness Machine Status"}, + {"2B1D", "RC Feature"}, + {"2B1E", "RC Settings"}, + {"2B1F", "Reconnection Configuration Control Point"}, + }; + static uuid_name_s long_uuid_name[LONG_UUID_COUNT] = { + // List should be sorted by UUID + /* Custom uuids */ + {"1AB7C24D-185A-45B9-90D4-F7AB1A71949A", "Samsung Health Service"}, + {"22EAC6E9-24D6-4BB5-BE44-B36ACE7C7BFB", "Data Source"}, + {"2F7CABCE-808D-411F-9A0C-BB92BA96C102", "Entity Update"}, + {"32D1955A-E5AA-4A96-9A49-08538DA8B8F6", "Samsung Gear Fit Manager Service"}, + {"69D1D8F3-45E1-49A8-9821-9BBDFDAAD9D9", "Control Point"}, + {"7905F431-B5CE-4E99-A40F-4B1E122D00D0", "Apple Notification Center Service"}, + {"89D3502B-0F36-433A-8EF4-C502AD55F8DC", "Apple Media Service"}, + {"9A3F68E0-86CE-11E5-A309-0002A5D5C51B", "Samsung Gear Manager Service"}, + {"9B3C81D8-57B1-4A8A-B8DF-0E56F7CA51C2", "Remote Command"}, + {"9FBF120D-6301-42D9-8C58-25E699A21DBD", "Notifications Source"}, + {"A49EB41E-CB06-495C-9F4F-BB80A90CDF00", "Samsung Gear Manager Service"}, + {"ADE3D529-C784-4F63-A987-EB69F70EE816", "IoT OIC Service"}, + {"C2051EE0-804D-4D50-A12C-15E243852100", "Notifications Source"}, + {"C2F2CC0F-C085-4DD4-BE5A-ACA3074BBC72", "Control Point"}, + {"C6B2F38C-23AB-46D8-A6AB-A3A870BBD5D7", "Entity Attribute"}, + {"CECE518B-28D7-4171-92D5-76A1E249A3B9", "Notifications Source"}, + {"FE53FF98-B259-4337-B56A-0EC9F82C6BAD", "Control Point"}, + }; + const uuid_name_s *uuid_name = short_uuid_name; + static const char *unknown_name = "Unknown"; + int start = 0; + int end = SHORT_UUID_COUNT - 1; + int p; + int ret; + + if (strlen(uuid) == 36) { + if (!g_ascii_strncasecmp(uuid + 9, "0000-1000-8000-00805F9B34FB", 27)) + offset = 4; + else { + offset = 0; + uuid_len = 36; + end = LONG_UUID_COUNT - 1; + uuid_name = long_uuid_name; + } + } else if (strlen(uuid) >= 8) + offset = 4; + + while (start <= end) { + p = start + (end - start) / 2; + ret = g_ascii_strncasecmp(uuid + offset, uuid_name[p].uuid, uuid_len); + if (ret == 0) + return uuid_name[p].specification_name; + else if (ret < 0) + end = p - 1; + else + start = p + 1; + } + + return unknown_name; +} + const char *_bt_convert_error_to_string(int error) { switch (error) { diff --git a/bt-service-adaptation/services/gatt/bt-service-gatt.c b/bt-service-adaptation/services/gatt/bt-service-gatt.c index 5365660..21eb17d 100644 --- a/bt-service-adaptation/services/gatt/bt-service-gatt.c +++ b/bt-service-adaptation/services/gatt/bt-service-gatt.c @@ -2702,9 +2702,8 @@ static void __bt_build_service_browse_info(int conn_id, service_uuid_t uuid; struct gatt_server_info_t *conn_info = NULL; - int count = 0; + int count = 1; char uuid_string[BLUETOOTH_UUID_STRING_MAX]; - BT_INFO("+"); conn_info = __bt_find_remote_gatt_server_info_from_conn_id(conn_id); @@ -2719,7 +2718,7 @@ static void __bt_build_service_browse_info(int conn_id, return; info->count = g_slist_length(svc_info_list->services); - BT_INFO("Total services present in the svc info list for this conn id [%d] is [%d]", + BT_DBG("Total services present in the svc info list for this conn id [%d] is [%d]", conn_id, info->count); for (l = svc_info_list->services; l != NULL; l = g_slist_next(l)) { @@ -2730,14 +2729,12 @@ static void __bt_build_service_browse_info(int conn_id, memcpy(&uuid.uuid, &svc_info->uuid, BLUETOOTH_UUID_HEX_MAX_LEN); _bt_uuid_to_string(&uuid, uuid_string); - BT_INFO("Service UUID formed [%s] strlen [%zd]", uuid_string, strlen(uuid_string)); + BT_INFO("[%d] %s [%s]", count, uuid_string, _bt_convert_uuid_to_string(uuid_string)); /* Fill UUID of service */ g_strlcpy(info->uuids[count], uuid_string, BLUETOOTH_UUID_STRING_MAX); - BT_INFO("Service UUID formed TO be sent [%s] strlen [%zd]", - info->uuids[count], strlen(info->uuids[count])); /* Fill instance ID of service */ info->inst_id[count] = svc_info->inst_id; @@ -2747,8 +2744,6 @@ static void __bt_build_service_browse_info(int conn_id, /* Increment count of services browsed */ count++; } - - BT_INFO("Total services browsed [%d]", count); } static void __bt_build_char_browse_info(int conn_id, @@ -2876,8 +2871,6 @@ static void __bt_cleanup_remote_services(struct gatt_server_info_t *conn_info) bt_gatt_descriptor_info_t *desc = NULL; bt_gatt_included_service_info_t *incl_svc = NULL; - BT_INFO("Start Cleanup of all services"); - svc_info_list = __bt_get_service_info_list(conn_info->connection_id); if (!svc_info_list) { BT_INFO("Could not find Svc Info list for the connection ID [%d]", @@ -2885,16 +2878,15 @@ static void __bt_cleanup_remote_services(struct gatt_server_info_t *conn_info) return; } - BT_INFO("Num Services [%d]", g_slist_length(svc_info_list->services)); + BT_INFO("Start Cleanup of all services. Num Services [%d]", g_slist_length(svc_info_list->services)); for (l = svc_info_list->services; l;) { svc = (bt_gatt_service_info_t*)l->data; l = g_slist_next(l); if (svc == NULL) continue; - BT_INFO("Service info Is Prim[%d] Inst ID [%d]", + BT_DBG("Service info Is Prim[%d] Inst ID [%d]", svc->is_primary, svc->inst_id); - BT_INFO("Num chars [%d]", g_slist_length(svc->chars)); /* Delete all chars and its descriptors */ for (ll = svc->chars; ll;) { chr = (bt_gatt_char_info_t*)ll->data; @@ -2902,7 +2894,6 @@ static void __bt_cleanup_remote_services(struct gatt_server_info_t *conn_info) if (chr == NULL) continue; - BT_INFO("Num descs [%d]", g_slist_length(chr->descs)); for (lll = chr->descs; lll;) { desc = (bt_gatt_descriptor_info_t *)lll->data; lll = g_slist_next(lll); @@ -2915,7 +2906,6 @@ static void __bt_cleanup_remote_services(struct gatt_server_info_t *conn_info) g_free(chr); } - BT_INFO("Num incl svcs [%d]", g_slist_length(svc->included_svcs)); /* Delete all included services */ for (llll = svc->included_svcs; llll;) { incl_svc = (bt_gatt_included_service_info_t*)llll->data; @@ -2932,7 +2922,6 @@ static void __bt_cleanup_remote_services(struct gatt_server_info_t *conn_info) list_gatt_info = g_slist_remove(list_gatt_info, svc_info_list); g_free(svc_info_list); - BT_INFO("Cleanup of all services done"); } int _bt_register_gatt_client_instance(const char *sender, @@ -3177,7 +3166,6 @@ static void __bt_handle_client_disconnected(event_gattc_conn_t *event_data) static void __bt_handle_client_service_search_result( event_gattc_service_result_t *event_data) { - BT_INFO("+"); BT_INFO("received the gatt service search result"); /* Pre: status is never fail from OAL */ @@ -3450,11 +3438,8 @@ static void __bt_handle_client_characteristic_read_data( char *read_val = NULL; char *svc_uuid = NULL; char *char_uuid = NULL; - int i; int uuid_len = 16; - BT_INFO("+"); - //memset(&read_info, 0x00, sizeof(bt_gatt_handle_property_t)); memset(&read_info, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t)); @@ -3483,11 +3468,10 @@ Note: Even in case of failure, address, handles and result code should be return if (event_data->uuid_status.conn_status.status != OAL_STATUS_SUCCESS) result = BLUETOOTH_ERROR_INTERNAL; else { - BT_ERR("read data len is [%d]", event_data->data_len); if (event_data->data_len > 0) { /* DEBUG */ - for (i = 0; i < event_data->data_len; i++) - BT_INFO("Data[%d] = [0x%x]", i, event_data->data[i]); + // for (i = 0; i < event_data->data_len; i++) + // BT_INFO("Data[%d] = [0x%x]", i, event_data->data[i]); /* Read data */ read_val = g_memdup(&event_data->data[0], event_data->data_len); diff --git a/bt-service-adaptation/services/include/bt-service-common.h b/bt-service-adaptation/services/include/bt-service-common.h index 14454b4..bb32986 100644 --- a/bt-service-adaptation/services/include/bt-service-common.h +++ b/bt-service-adaptation/services/include/bt-service-common.h @@ -364,6 +364,8 @@ char *_bt_get_device_object_path(char *address); char *_bt_get_profile_uuid128(bt_profile_type_t profile_type); +const char *_bt_convert_uuid_to_string(const char *uuid); + const char *_bt_convert_error_to_string(int error); const char * _bt_convert_disc_reason_to_string(int reason); diff --git a/bt-service-adaptation/services/obex/bt-service-obex-event-receiver.c b/bt-service-adaptation/services/obex/bt-service-obex-event-receiver.c index d91c48c..286e37e 100644 --- a/bt-service-adaptation/services/obex/bt-service-obex-event-receiver.c +++ b/bt-service-adaptation/services/obex/bt-service-obex-event-receiver.c @@ -429,16 +429,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path _bt_convert_device_path_to_address(path, address); - /* 0x00 BDADDR_BRDER - 0x01 BDADDR_LE_PUBLIC - 0x02 BDADDR_LE_RANDOM */ - _bt_convert_addr_string_to_secure_string(secure_address, address); - BT_INFO("Address : %s Type : %d", secure_address, addr_type); - BT_ERR_C("### Disconnected [%s] [%d : %s] [%s]", !addr_type ? "BREDR" : "LE", - disc_reason, _bt_convert_disc_reason_to_string(disc_reason), - !addr_type ? dev_name : secure_address); - g_free(dev_name); - if (!addr_type) { /*Check for any OPP transfer on the device and cancel * the transfer @@ -450,6 +440,7 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path /* TODO: MAP? see above */ } g_free(address); + g_free(dev_name); } else if (strcasecmp(member, "ProfileStateChanged") == 0) { int state = 0; char *profile_uuid = NULL; @@ -463,9 +454,7 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path _bt_convert_addr_string_to_type(bd_addr.addr, address); _bt_convert_addr_string_to_secure_string(secure_address, address); - BT_DBG("Address: %s", secure_address); - BT_DBG("Profile UUID: %s", profile_uuid); - BT_DBG("State: %d", state); + BT_DBG("[%s] [%s] [%d]", secure_address, profile_uuid, state); g_free(address); } } @@ -579,7 +568,6 @@ static void __bt_obexd_event_filter(GDBusConnection *connection, BT_ERR("Fail to get the path"); return; } - BT_INFO("object_path = [%s]", obj_path); /*Handle OPP_SERVER_CONNECTED_EVENT here */ /* TODO: MAP? see above */ @@ -601,7 +589,6 @@ static void __bt_obexd_event_filter(GDBusConnection *connection, BT_ERR("Fail to get the path"); return; } - BT_INFO("object_path = [%s]", obj_path); if (strncmp(obj_path, BT_SESSION_BASEPATH_CLIENT, strlen(BT_SESSION_BASEPATH_CLIENT)) == 0) { -- 2.7.4