From 9286c517190f4e5502636bc6db83d53a6f986de1 Mon Sep 17 00:00:00 2001 From: "injun.yang" Date: Tue, 25 Jul 2017 20:24:13 +0530 Subject: [PATCH] [GATT Server] Delivery the specific error code to central device [Problem] Unalbe to pass application error code to central device [Cause & Measure] Pass the specific error code to central device [Checking Method] Reponse with the specific error to central device Change-Id: I72fdfdef011f7f357e95eb4932e703e0cae08480 Signed-off-by: Gowtham Anandha Babu --- bt-api/bt-gatt-service.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/bt-api/bt-gatt-service.c b/bt-api/bt-gatt-service.c index dee2963..2cd555e 100644 --- a/bt-api/bt-gatt-service.c +++ b/bt-api/bt-gatt-service.c @@ -2612,31 +2612,29 @@ BT_EXPORT_API int bluetooth_gatt_send_response(int request_id, guint req_type, if (resp_state != BLUETOOTH_ATT_ERROR_NONE) { BT_ERR("resp_state is 0x%X", resp_state); + char err_msg[20] = { 0, }; + g_snprintf(err_msg, sizeof(err_msg), "ATT error: 0x%02x", resp_state); + g_dbus_method_invocation_return_dbus_error(req_info->context, + "org.bluez.Error.Failed", err_msg); switch (resp_state) { case BLUETOOTH_ATT_ERROR_WRITE_REQUEST_REJECTED: - g_dbus_method_invocation_return_dbus_error(req_info->context, - "org.bluez.Error.Failed", "Write Request Rejected"); + BT_ERR("Write Request Rejected"); break; case BLUETOOTH_ATT_ERROR_OBJECT_NOT_SELECTED: - g_dbus_method_invocation_return_dbus_error(req_info->context, - "org.bluez.Error.Failed", "Object Not Selected"); + BT_ERR("Object Not Selected"); break; case BLUETOOTH_ATT_ERROR_CONCURRENCY_LIMIT_EXCEEDED: - g_dbus_method_invocation_return_dbus_error(req_info->context, - "org.bluez.Error.Failed", "Concurrency Limit Exceeded"); + BT_ERR("Concurrency Limit Exceeded"); break; case BLUETOOTH_ATT_ERROR_OBJECT_NAME_EXISTS: - g_dbus_method_invocation_return_dbus_error(req_info->context, - "org.bluez.Error.Failed", "Object Name Already Exists"); + BT_ERR("Object Name Already Exists"); break; case BLUETOOTH_ATT_ERROR_CCCD_IMPROPERLY_CONFIGURED: - g_dbus_method_invocation_return_dbus_error(req_info->context, - "org.bluez.Error.Failed", "CCC Improperly Configured"); + BT_ERR("CCC Improperly Configured"); break; default: - g_dbus_method_invocation_return_dbus_error(req_info->context, - "org.bluez.Error.Failed", "Application Error"); + BT_ERR("Application Error"); break; } -- 2.7.4