From 750ee6ef158fdd74dc1b088d2999c35d79b3c1e6 Mon Sep 17 00:00:00 2001 From: Gowtham Anandha Babu Date: Wed, 26 Jul 2017 12:28:56 +0530 Subject: [PATCH] [GATT] Fix ATT application ecode 1) Add error codes defined in Common Profile and Service Error Code descriptions (see Supplement to the Bluetooth Core Specification, sections 1.2 and 2). 2) Seperate out OTP specific application ecode. Change-Id: I666707b76f5252a7662ff8ffc295660678d964e3 Signed-off-by: Gowtham Anandha Babu --- bt-api/bt-gatt-service.c | 21 --------------------- bt-otp/bt-otpserver.c | 14 +++++++------- include/bluetooth-api.h | 9 +++++---- 3 files changed, 12 insertions(+), 32 deletions(-) diff --git a/bt-api/bt-gatt-service.c b/bt-api/bt-gatt-service.c index 2cd555e..a99a5da 100644 --- a/bt-api/bt-gatt-service.c +++ b/bt-api/bt-gatt-service.c @@ -2617,27 +2617,6 @@ BT_EXPORT_API int bluetooth_gatt_send_response(int request_id, guint req_type, 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: - BT_ERR("Write Request Rejected"); - break; - case BLUETOOTH_ATT_ERROR_OBJECT_NOT_SELECTED: - BT_ERR("Object Not Selected"); - break; - case BLUETOOTH_ATT_ERROR_CONCURRENCY_LIMIT_EXCEEDED: - BT_ERR("Concurrency Limit Exceeded"); - break; - case BLUETOOTH_ATT_ERROR_OBJECT_NAME_EXISTS: - BT_ERR("Object Name Already Exists"); - break; - case BLUETOOTH_ATT_ERROR_CCCD_IMPROPERLY_CONFIGURED: - BT_ERR("CCC Improperly Configured"); - break; - default: - BT_ERR("Application Error"); - break; - } - gatt_requests = g_slist_remove(gatt_requests, req_info); req_info->context = NULL; diff --git a/bt-otp/bt-otpserver.c b/bt-otp/bt-otpserver.c index 358d1ec..761b6af 100644 --- a/bt-otp/bt-otpserver.c +++ b/bt-otp/bt-otpserver.c @@ -1652,7 +1652,7 @@ int _bt_otp_obj_name_write_cb(char *value, int len) object = (struct object_metadata *) g_slist_nth_data(otp_object_list, curr_obj_index); if (!object) - return BLUETOOTH_ATT_ERROR_WRITE_REQUEST_REJECTED ; + return BLUETOOTH_OTP_ERROR_WRITE_REQUEST_REJECTED; filename = g_strndup(value, len); snprintf(new_abs_filepath, strlen(new_abs_filepath), "%s%s", @@ -1662,7 +1662,7 @@ int _bt_otp_obj_name_write_cb(char *value, int len) directory, object->name); if (rename(old_abs_filepath, new_abs_filepath)) { - ret = BLUETOOTH_ATT_ERROR_OBJECT_NAME_EXISTS; + ret = BLUETOOTH_OTP_ERROR_OBJECT_NAME_EXISTS; goto fail; } @@ -1685,7 +1685,7 @@ int _bt_otp_obj_first_created_write_cb(char *value, int len) object = (struct object_metadata *) g_slist_nth_data(otp_object_list, curr_obj_index); if (!object) - return BLUETOOTH_ATT_ERROR_WRITE_REQUEST_REJECTED; + return BLUETOOTH_OTP_ERROR_WRITE_REQUEST_REJECTED; year = (uint16_t)(value[1] & 0xFF) << 8 | (uint16_t)(value[0] & 0xFF); @@ -1711,7 +1711,7 @@ int _bt_otp_obj_last_modified_write_cb(char *value, int len) object = (struct object_metadata *) g_slist_nth_data(otp_object_list, curr_obj_index); if (!object) - return BLUETOOTH_ATT_ERROR_WRITE_REQUEST_REJECTED; + return BLUETOOTH_OTP_ERROR_WRITE_REQUEST_REJECTED; year = (uint16_t)(value[1] & 0xFF) << 8 | (uint16_t)(value[0] & 0xFF); @@ -1736,11 +1736,11 @@ int _bt_otp_obj_props_write_cb(char *value, int len) /* Any attempt to write RFU bits is error */ if (value[1] || value[2] || value[3]) - return BLUETOOTH_ATT_ERROR_WRITE_REQUEST_REJECTED; + return BLUETOOTH_OTP_ERROR_WRITE_REQUEST_REJECTED; object = (struct object_metadata *) g_slist_nth_data(otp_object_list, curr_obj_index); if (!object) - return BLUETOOTH_ATT_ERROR_WRITE_REQUEST_REJECTED; + return BLUETOOTH_OTP_ERROR_WRITE_REQUEST_REJECTED; props = (uint32_t)(value[3] & 0xFF) << 24 | (uint32_t)(value[2] & 0xFF) << 16 | @@ -1779,7 +1779,7 @@ int _bt_otp_read_cb(const char *obj_path, char **value, int *len) if (g_strcmp0(obj_path, otp_feature_obj_path)) { if (!selected_object) { - return BLUETOOTH_ATT_ERROR_OBJECT_NOT_SELECTED; + return BLUETOOTH_OTP_ERROR_OBJECT_NOT_SELECTED; } } diff --git a/include/bluetooth-api.h b/include/bluetooth-api.h index 2b43f87..8cbbd7b 100644 --- a/include/bluetooth-api.h +++ b/include/bluetooth-api.h @@ -207,7 +207,7 @@ extern "C" { #define BLUETOOTH_ATT_ERROR_UNSUPPORTED_GROUP_TYPE 0x10 #define BLUETOOTH_ATT_ERROR_INSUFFICIENT_RESOURCES 0x11 /* Common profile error codes */ -#define BLUETOOTH_ATT_ERROR_WRITE_REQUEST_REJECTED 0x80 +#define BLUETOOTH_ATT_ERROR_WRITE_REQUEST_REJECTED 0xFC #define BLUETOOTH_ATT_ERROR_CCCD_IMPROPERLY_CONFIGURED 0xFD #define BLUETOOTH_ATT_ERROR_PROCEDURE_ALREADY_IN_PROGRESS 0xFE #define BLUETOOTH_ATT_ERROR_OUT_OF_RANGE 0xFF @@ -215,9 +215,10 @@ extern "C" { /* * Bluetooth ATT error codes specific to OTP */ -#define BLUETOOTH_ATT_ERROR_OBJECT_NOT_SELECTED 0x81 -#define BLUETOOTH_ATT_ERROR_CONCURRENCY_LIMIT_EXCEEDED 0x82 -#define BLUETOOTH_ATT_ERROR_OBJECT_NAME_EXISTS 0x83 +#define BLUETOOTH_OTP_ERROR_WRITE_REQUEST_REJECTED 0x80 +#define BLUETOOTH_OTP_ERROR_OBJECT_NOT_SELECTED 0x81 +#define BLUETOOTH_OTP_ERROR_CONCURRENCY_LIMIT_EXCEEDED 0x82 +#define BLUETOOTH_OTP_ERROR_OBJECT_NAME_EXISTS 0x83 /* * Bluetooth OTP error codes -- 2.7.4