[Problem] ATT error code is not passed to application.
[Cause & Measure] GATT application need to know ATT
error code to handling error case. Specially application
error code defined by a higher layer specification.
[Checking Method] GATT error handling
Change-Id: Ic7c8f14f107dd65bae925c2e424b3bd71e04f8b8
Signed-off-by: Gowtham Anandha Babu <gowtham.ab@samsung.com>
BT_ADAPTER_LE_ENABLED, /**< Bluetooth le is enabled */
} bt_adapter_le_state_e;
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_GATT_MODULE
+ * @brief Enumerations of the ATT error codes.
+ * @since_tizen 4.0
+ */
+typedef enum {
+ BT_ATT_ERROR_INTERNAL = -1,
+ BT_ATT_ERROR_NONE = 0x00,
+
+ /* Attribute error codes */
+ BT_ATT_ERROR_INVALID_HANDLE = 0x01,
+ BT_ATT_ERROR_READ_NOT_PERMITTED = 0x02,
+ BT_ATT_ERROR_WRITE_NOT_PERMITTED = 0x03,
+ BT_ATT_ERROR_INVALID_PDU = 0x04,
+ BT_ATT_ERROR_AUTHENTICATION = 0x05,
+ BT_ATT_ERROR_REQUEST_NOT_SUPPORTED = 0x06,
+ BT_ATT_ERROR_INVALID_OFFSET = 0x07,
+ BT_ATT_ERROR_AUTHORIZATION = 0x08,
+ BT_ATT_ERROR_PREPARE_QUEUE_FULL = 0x09,
+ BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND = 0x0A,
+ BT_ATT_ERROR_ATTRIBUTE_NOT_LONG = 0x0B,
+ BT_ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE = 0x0C,
+ BT_ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LEN = 0x0D,
+ BT_ATT_ERROR_UNLIKELY = 0x0E,
+ BT_ATT_ERROR_INSUFFICIENT_ENCRYPTION = 0x0F,
+ BT_ATT_ERROR_UNSUPPORTED_GROUP_TYPE = 0x10,
+ BT_ATT_ERROR_INSUFFICIENT_RESOURCES = 0x11,
+
+ /* Common profile error codes */
+ BT_ATT_ERROR_WRITE_REQUEST_REJECTED = 0x80,
+ BT_ATT_ERROR_CCCD_IMPROPERLY_CONFIGURED = 0xFD,
+ BT_ATT_ERROR_PROCEDURE_ALREADY_IN_PROGRESS = 0xFE,
+ BT_ATT_ERROR_OUT_OF_RANGE = 0xFF,
+
+ /* Bluetooth OTP error codes */
+ BT_ATT_ERROR_OBJECT_NOT_SELECTED = 0x81,
+ BT_ATT_ERROR_CONCURRENCY_LIMIT_EXCEEDED = 0x82,
+ BT_ATT_ERROR_OBJECT_NAME_EXISTS = 0x83,
+
+} bt_att_error_e;
+
/**
* @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_LE_MODULE
* @brief Called when the Bluetooth adapter le state changes.
(*dest_dev)->manufacturer_data_len = source_dev->manufacturer_data.data_len;
if (source_dev->manufacturer_data.data_len > 0) {
(*dest_dev)->manufacturer_data = (char *)malloc(source_dev->manufacturer_data.data_len);
- memcpy((*dest_dev)->manufacturer_data, source_dev->manufacturer_data.data, source_dev->manufacturer_data.data_len);
+ if ((*dest_dev)->manufacturer_data)
+ memcpy((*dest_dev)->manufacturer_data, source_dev->manufacturer_data.data,
+ source_dev->manufacturer_data.data_len);
+ else
+ return BT_ERROR_OUT_OF_MEMORY;
} else {
(*dest_dev)->manufacturer_data = (char *)malloc(1);
- (*dest_dev)->manufacturer_data[0] = 0;
+ if ((*dest_dev)->manufacturer_data)
+ (*dest_dev)->manufacturer_data[0] = 0;
+ else
+ return BT_ERROR_OUT_OF_MEMORY;
}
return BT_ERROR_NONE;
break;
}
_bt_unset_cb(BT_EVENT_GATT_CLIENT_READ_CHARACTERISTIC);
- ret = _bt_get_error_code(param->result);
- if (ret == BT_ERROR_NONE) {
+ ret = param->result;
+ if (ret == BT_ATT_ERROR_NONE) {
char_val = (bt_gatt_char_value_t *)(param->param_data);
bt_gatt_set_value(cb_data->gatt_handle,
(char *)char_val->char_value, (int)char_val->val_len);
}
_bt_unset_cb(BT_EVENT_GATT_CLIENT_WRITE_CHARACTERISTIC);
- /* Send actual ATT error code to Application
- * if param->result is not BLUETOOTH_ERROR_INTERNAL.
- */
- if (param->result == BLUETOOTH_ERROR_INTERNAL)
- ret = _bt_get_error_code(param->result);
- else
- ret = param->result;
+ ret = param->result;
- if (ret != BT_ERROR_NONE)
+ if (ret != BT_ATT_ERROR_NONE)
BT_ERR("BLUETOOTH_EVENT_GATT_WRITE_CHAR - ret [%d]", ret);
cb(ret, cb_data->gatt_handle, cb_data->user_data);
BT_INFO("BLUETOOTH_EVENT_GATT_READ_DESC");
_bt_unset_cb(BT_EVENT_GATT_CLIENT_READ_DESCRIPTOR);
- ret = _bt_get_error_code(param->result);
- if (ret == BT_ERROR_NONE) {
+ ret = param->result;
+ if (ret == BT_ATT_ERROR_NONE) {
desc_val = (bt_gatt_char_property_t *)(param->param_data);
bt_gatt_set_value(cb_data->gatt_handle,
desc_val->description, (int)desc_val->val_len);
BT_INFO("BLUETOOTH_EVENT_GATT_WRITE_DESC");
_bt_unset_cb(BT_EVENT_GATT_CLIENT_WRITE_DESCRIPTOR);
- ret = _bt_get_error_code(param->result);
+ ret = param->result;
cb(ret, cb_data->gatt_handle, cb_data->user_data);
g_free(cb_data);
bluetooth_otp_resp_info_t *info = NULL;
char *handle = NULL;
- if (_bt_get_error_code(param->result) == BT_ERROR_NONE) {
+ if (param->result == BT_ATT_ERROR_NONE) {
info = (bluetooth_otp_resp_info_t *)(param->param_data);
BT_ERR("Read Success Handle [%s]", info->handle);
- _bt_otp_client_read_value_response(_bt_get_error_code(param->result),
+ _bt_otp_client_read_value_response(param->result,
info->handle, info->data, info->data_length);
} else {
handle = (char *)(param->param_data);
BT_ERR("Read Fail Handle [%s]", handle);
- _bt_otp_client_read_value_response(_bt_get_error_code(param->result),
+ _bt_otp_client_read_value_response(param->result,
handle, NULL, 0);
}
break;
BT_DBG("BLUETOOTH_EVENT_OTP_WRITE_CHAR_VAL"); /* LCOV_EXCL_LINE */
char *handle = (char *)(param->param_data);
BT_ERR("Handle [%s]", handle);
- _bt_otp_client_write_value_response(_bt_get_error_code(param->result), handle);
+ _bt_otp_client_write_value_response(param->result, handle);
break;
}
case BLUETOOTH_EVENT_OTP_NOTIFICATION_ENABLED: {
BT_CHECK_INIT_STATUS();
if (request_type == BT_GATT_REQUEST_TYPE_READ &&
- resp_status == BT_ERROR_NONE) {
+ resp_status == BT_ATT_ERROR_NONE) {
BT_CHECK_INPUT_PARAMETER(value);
if (value_length < 0)
int offset, void *user_data)
{
char char_value_1[3] = {0, 1, 2};
- int resp_status = BT_ERROR_NONE;
+ int resp_status = BT_ATT_ERROR_NONE;
TC_PRT("__bt_gatt_server_read_value_requested_cb");
TC_PRT("remote_address %s", remote_address);
bt_get_uuid_name(uuid, &str);
TC_PRT("Write %s for %s (%s)",
- result == BT_ERROR_NONE ? "Success" : "Fail",
+ result == BT_ATT_ERROR_NONE ? "Success" : "Fail",
str ? str : "Unknown", uuid);
g_free(str);
bt_get_uuid_name(uuid, &str);
TC_PRT("Read %s for %s (%s)",
- result == BT_ERROR_NONE ? "Success" : "Fail",
+ result == BT_ATT_ERROR_NONE ? "Success" : "Fail",
str ? str : "Unknown", uuid);
g_free(str);
g_free(uuid);
- if (result != BT_ERROR_NONE)
+ if (result != BT_ATT_ERROR_NONE)
return;
__bt_gatt_client_print_value(gatt_handle);
bt_gatt_h gatt_handle, bool response_needed, int offset,
const char *value, int len, void *user_data)
{
- int i, resp_status = BT_ERROR_NONE;
+ int i, resp_status = BT_ATT_ERROR_NONE;
TC_PRT("remote_address : %s", remote_address);
TC_PRT("Response needed : %d", response_needed);
TC_PRT("offset : %d", offset);