}
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-static bool is_otp_operation(bt_uuid_t *uuid)
+static uint8_t dbus_error_to_att_ecode(const char *error_message)
{
- bt_uuid_t u1, u2;
- uint16_t start = 0x2ABD;
- uint16_t end = 0x2AC8;
+ uint8_t att_ecode = 0;
+ int len;
+ char *str = NULL;
- bt_uuid16_create(&u1, start);
- bt_uuid16_create(&u2, end);
-
- /* check whether the given uuid is in
- * OTP characteristics range or not.
- */
- if ((bt_uuid_cmp(uuid, &u1) >= 0) &&
- (bt_uuid_cmp(uuid, &u2) <= 0))
- return true;
-
- return false;
-}
-
-static uint8_t dbus_error_to_otp_ecode(const char *error_msg)
-{
- /* OTP error codes */
- if (strcmp(error_msg, "Write Request Rejected") == 0)
- return BT_ATT_ERROR_WRITE_REQUEST_REJECTED;
-
- if (strcmp(error_msg, "Object Not Selected") == 0)
- return BT_ATT_ERROR_OBJECT_NOT_SELECTED;
-
- if (strcmp(error_msg, "Concurrency Limit Exceeded") == 0)
- return BT_ATT_ERROR_CONCURRENCY_LIMIT_EXCEEDED;
-
- if (strcmp(error_msg, "Object Name Already Exists") == 0)
- return BT_ATT_ERROR_OBJECT_NAME_EXISTS;
-
- if (strcmp(error_msg, "CCC Improperly Configured") == 0)
- return BT_ERROR_CCC_IMPROPERLY_CONFIGURED;
+ str = g_strrstr(error_message, "ATT error: 0x");
+ if (str) {
+ len = strlen(str);
+ att_ecode = g_ascii_xdigit_value(str[len - 2]) << 4;
+ att_ecode += g_ascii_xdigit_value(str[len - 1]);
+ } else
+ att_ecode = BT_ATT_ERROR_UNLIKELY;
- return 0x80; /* Default application error code */
+ return att_ecode;
}
-#endif
-
+#else
static uint8_t dbus_error_to_att_ecode(const char *error_name)
{
if (strcmp(error_name, "org.bluez.Error.Failed") == 0)
return 0;
}
+#endif
static void read_reply_cb(DBusMessage *message, void *user_data)
{
if (dbus_set_error_from_message(&err, message) == TRUE) {
DBG("Failed to read value: %s: %s", err.name, err.message);
- ecode = dbus_error_to_att_ecode(err.name);
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
- if (is_otp_operation(uuid) && ecode == 0x80)
- ecode = dbus_error_to_otp_ecode(err.message);
-#endif
+ ecode = dbus_error_to_att_ecode(err.message);
+#else
+ ecode = dbus_error_to_att_ecode(err.name);
ecode = ecode ? ecode : BT_ATT_ERROR_READ_NOT_PERMITTED;
+#endif
dbus_error_free(&err);
goto done;
}
if (dbus_set_error_from_message(&err, message) == TRUE) {
DBG("Failed to write value: %s: %s", err.name, err.message);
- ecode = dbus_error_to_att_ecode(err.name);
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
- if (is_otp_operation(uuid) && ecode == 0x80)
- ecode = dbus_error_to_otp_ecode(err.message);
-#endif
+ ecode = dbus_error_to_att_ecode(err.message);
+#else
+ ecode = dbus_error_to_att_ecode(err.name);
ecode = ecode ? ecode : BT_ATT_ERROR_WRITE_NOT_PERMITTED;
+#endif
dbus_error_free(&err);
goto done;
}