return att_ecode;
}
#else
-static uint8_t dbus_error_to_att_ecode(const char *error_name, uint8_t perm_err)
+static uint8_t dbus_error_to_att_ecode(const char *name, const char *msg,
+ uint8_t perm_err)
{
- if (strcmp(error_name, ERROR_INTERFACE ".Failed") == 0)
- return 0x80; /* For now return this "application error" */
+ if (strcmp(name, ERROR_INTERFACE ".Failed") == 0) {
+ char *endptr = NULL;
+ uint32_t ecode;
- if (strcmp(error_name, ERROR_INTERFACE ".NotSupported") == 0
+ ecode = strtol(msg, &endptr, 0);
+
+ /* If message doesn't set an error code just use 0x80 */
+ if (!endptr || *endptr != '\0')
+ return 0x80;
+
+ if (ecode < 0x80 || ecode > 0x9f) {
+ error("Invalid error code: %s", msg);
+ return BT_ATT_ERROR_UNLIKELY;
+ }
+
+ return ecode;
+ }
+
+ if (strcmp(name, ERROR_INTERFACE ".NotSupported") == 0)
return BT_ATT_ERROR_REQUEST_NOT_SUPPORTED;
- if (strcmp(error_name, ERROR_INTERFACE ".NotAuthorized") == 0)
+ if (strcmp(name, ERROR_INTERFACE ".NotAuthorized") == 0)
return BT_ATT_ERROR_AUTHORIZATION;
- if (strcmp(error_name, ERROR_INTERFACE ".InvalidValueLength") == 0)
+ if (strcmp(name, ERROR_INTERFACE ".InvalidValueLength") == 0)
return BT_ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LEN;
- if (strcmp(error_name, ERROR_INTERFACE ".InvalidOffset") == 0)
+ if (strcmp(name, ERROR_INTERFACE ".InvalidOffset") == 0)
return BT_ATT_ERROR_INVALID_OFFSET;
- if (strcmp(error_name, ERROR_INTERFACE ".InProgress") == 0)
+ if (strcmp(name, ERROR_INTERFACE ".InProgress") == 0)
return BT_ERROR_ALREADY_IN_PROGRESS;
- if (strcmp(error_name, ERROR_INTERFACE ".NotPermitted") == 0)
+ if (strcmp(name, ERROR_INTERFACE ".NotPermitted") == 0)
return perm_err;
return BT_ATT_ERROR_UNLIKELY;
ecode = dbus_error_to_att_ecode(err.message,
BT_ATT_ERROR_WRITE_NOT_PERMITTED);
#else
- ecode = dbus_error_to_att_ecode(err.name,
+ ecode = dbus_error_to_att_ecode(err.name, err.message,
BT_ATT_ERROR_WRITE_NOT_PERMITTED);
#endif
dbus_error_free(&err);
ecode = dbus_error_to_att_ecode(err.message,
BT_ATT_ERROR_WRITE_NOT_PERMITTED);
#else
- ecode = dbus_error_to_att_ecode(err.name,
+ ecode = dbus_error_to_att_ecode(err.name, err.message,
BT_ATT_ERROR_WRITE_NOT_PERMITTED);
#endif
dbus_error_free(&err);
error("Failed to acquire write: %s\n", err.name);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
ecode = dbus_error_to_att_ecode(err.name,
+ BT_ATT_ERROR_WRITE_NOT_PERMITTED);
+#else
+ ecode = dbus_error_to_att_ecode(err.name, err.message,
BT_ATT_ERROR_WRITE_NOT_PERMITTED);
+#endif
dbus_error_free(&err);
if (ecode != BT_ATT_ERROR_UNLIKELY) {