return true;
}
-static uint8_t dbus_error_to_att_ecode(const char *error_name)
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+static bool is_otp_operation(bt_uuid_t *uuid)
+{
+ bt_uuid_t u1, u2;
+ uint16_t start = 0x2ABD;
+ uint16_t end = 0x2AC8;
+
+ 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;
+ return 0x80; /* Default application error code */
+}
+#endif
+
+static uint8_t dbus_error_to_att_ecode(const char *error_name)
+{
if (strcmp(error_name, "org.bluez.Error.Failed") == 0)
return 0x80; /* For now return this "application error" */
static void read_reply_cb(DBusMessage *message, void *user_data)
{
struct pending_op *op = user_data;
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ struct gatt_db_attribute *attrib = op->attrib;
+ bt_uuid_t *uuid = gatt_db_attribute_get_type(attrib);
+#endif
DBusError err;
DBusMessageIter iter, array;
uint8_t ecode = 0;
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 = ecode ? ecode : BT_ATT_ERROR_READ_NOT_PERMITTED;
dbus_error_free(&err);
goto done;
static void write_reply_cb(DBusMessage *message, void *user_data)
{
struct pending_op *op = user_data;
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ struct gatt_db_attribute *attrib = op->attrib;
+ bt_uuid_t *uuid = gatt_db_attribute_get_type(attrib);
+#endif
DBusError err;
DBusMessageIter iter;
uint8_t ecode = 0;
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 = ecode ? ecode : BT_ATT_ERROR_WRITE_NOT_PERMITTED;
dbus_error_free(&err);
goto done;
#define BT_ATT_ERROR_UNSUPPORTED_GROUP_TYPE 0x10
#define BT_ATT_ERROR_INSUFFICIENT_RESOURCES 0x11
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+/*
+ * OTP ATT error codes. Refer OTS specification,
+ * section 1.10 Application Error Codes
+ */
+#define BT_ATT_ERROR_WRITE_REQUEST_REJECTED 0x80
+#define BT_ATT_ERROR_OBJECT_NOT_SELECTED 0x81
+#define BT_ATT_ERROR_CONCURRENCY_LIMIT_EXCEEDED 0x82
+#define BT_ATT_ERROR_OBJECT_NAME_EXISTS 0x83
+#endif
+
/*
* Common Profile and Service Error Code descriptions (see Supplement to the
* Bluetooth Core Specification, sections 1.2 and 2). The error codes within