[GATT Server] Delivery the specific error code to central device
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-gatt-service.c
index dee2963..2cd555e 100644 (file)
@@ -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;
                }