[GATT] Fix ATT application ecode 22/140722/2
authorGowtham Anandha Babu <gowtham.ab@samsung.com>
Wed, 26 Jul 2017 06:58:56 +0000 (12:28 +0530)
committerGowtham Anandha Babu <gowtham.ab@samsung.com>
Wed, 26 Jul 2017 07:25:48 +0000 (12:55 +0530)
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 <gowtham.ab@samsung.com>
bt-api/bt-gatt-service.c
bt-otp/bt-otpserver.c
include/bluetooth-api.h

index 2cd555e..a99a5da 100644 (file)
@@ -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;
index 358d1ec..761b6af 100644 (file)
@@ -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;
                }
        }
 
index 2b43f87..8cbbd7b 100644 (file)
@@ -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