GByteArray *gp_byte_array = NULL;
GVariantIter *iter;
guint8 g_byte;
+ gint att_error_code;
int ret = BLUETOOTH_ERROR_NONE;
BT_DBG("+");
}
char_value.char_handle = user_data;
- gp_byte_array = g_byte_array_new();
- g_variant_get(value, "(ay)", &iter);
+ g_variant_get(value, "(yay)", &att_error_code, &iter);
+
+ if (att_error_code != 0) {
+ if (user_info) {
+ _bt_common_event_cb(BLUETOOTH_EVENT_GATT_READ_CHAR,
+ att_error_code, NULL,
+ user_info->cb, user_info->user_data);
+ }
+ g_free(char_value.char_handle);
+ g_variant_unref(value);
+ g_variant_iter_free(iter);
+ return;
+ }
+
+ gp_byte_array = g_byte_array_new();
while (g_variant_iter_loop(iter, "y", &g_byte))
g_byte_array_append(gp_byte_array, &g_byte, 1);
g_variant_new("q", offset));
/* Device Object path*/
-// g_variant_builder_add(builder, "{sv}", "device",
-// g_variant_new_object("o", NULL));
+// g_variant_builder_add(builder, "{sv}", "device",
+// g_variant_new_object("o", NULL));
g_dbus_connection_call(conn,
BT_BLUEZ_NAME,
GATT_CHAR_INTERFACE,
"ReadValue",
g_variant_new("(a{sv})", builder),
- G_VARIANT_TYPE("(ay)"),
+ G_VARIANT_TYPE("(yay)"),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
return BLUETOOTH_ERROR_NONE;
}
+static void __bluetooth_internal_write_cb(GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GError *error = NULL;
+ bt_user_info_t *user_info;
+ GDBusConnection *system_gconn = NULL;
+ GVariant *value;
+ int result = BLUETOOTH_ERROR_NONE;
+ guint8 att_ecode = 0;
+
+ user_info = _bt_get_user_data(BT_COMMON);
+
+ system_gconn = _bt_gdbus_get_system_gconn();
+ value = g_dbus_connection_call_finish(system_gconn, res, &error);
+
+ if (error) {
+ BT_ERR("Error : %s \n", error->message);
+ g_clear_error(&error);
+ result = BLUETOOTH_ERROR_INTERNAL;
+ } else {
+ g_variant_get(value, "(y)", &att_ecode);
+ if (att_ecode) {
+ result = att_ecode;
+ BT_ERR("ATT Error code: %d \n", att_ecode);
+ }
+ }
+
+ if (user_info) {
+ _bt_common_event_cb(BLUETOOTH_EVENT_GATT_WRITE_CHAR,
+ result, NULL,
+ user_info->cb, user_info->user_data);
+ } else {
+ BT_ERR("user info is null");
+ }
+
+ if (value)
+ g_variant_unref(value);
+
+ return;
+}
+
BT_EXPORT_API int bluetooth_gatt_set_characteristics_value(
const char *char_handle, const guint8 *value, int length)
{
g_variant_new_uint16(offset));
/* Device Object path*/
-// g_variant_builder_add(builder2, "{sv}", "device",
-// g_variant_new_object("o", NULL));
+// g_variant_builder_add(builder2, "{sv}", "device",
+// g_variant_new_object("o", NULL));
options = g_variant_new("a{sv}", builder2);
- g_dbus_connection_call_sync(conn,
- BT_BLUEZ_NAME,
- char_handle,
- GATT_CHAR_INTERFACE,
- "WriteValue",
- g_variant_new("(@ay@a{sv})", val, options),
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- -1, NULL, &error);
+ g_dbus_connection_call(conn,
+ BT_BLUEZ_NAME,
+ char_handle,
+ GATT_CHAR_INTERFACE,
+ "WriteValue",
+ g_variant_new("(@ay@a{sv})",
+ val, options),
+ G_VARIANT_TYPE("(y)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL,
+ (GAsyncReadyCallback)__bluetooth_internal_write_cb,
+ NULL);
+
if (error) {
BT_ERR("Set value Failed: %s", error->message);
return BLUETOOTH_ERROR_NONE;
}
-static void __bluetooth_internal_write_cb(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- GError *error = NULL;
- bt_user_info_t *user_info;
- GDBusConnection *system_gconn = NULL;
- GVariant *value;
- int result = BLUETOOTH_ERROR_NONE;
- guint8 att_ecode = 0;
-
- user_info = _bt_get_user_data(BT_COMMON);
-
- system_gconn = _bt_gdbus_get_system_gconn();
- value = g_dbus_connection_call_finish(system_gconn, res, &error);
-
- if (error) {
- BT_ERR("Error : %s \n", error->message);
- g_clear_error(&error);
- result = BLUETOOTH_ERROR_INTERNAL;
- } else {
- g_variant_get(value, "(y)", &att_ecode);
- if (att_ecode) {
- result = att_ecode;
- BT_ERR("ATT Error code: %d \n", att_ecode);
- }
- }
-
- if (user_info) {
- _bt_common_event_cb(BLUETOOTH_EVENT_GATT_WRITE_CHAR,
- result, NULL,
- user_info->cb, user_info->user_data);
- } else {
- BT_ERR("user info is null");
- }
-
- if (value)
- g_variant_unref(value);
-
- return;
-}
-
BT_EXPORT_API int bluetooth_gatt_set_characteristics_value_by_type(
const char *char_handle, const guint8 *value, int length, guint8 write_type)
{
g_variant_new_uint16(offset));
/* Device Object path*/
-// g_variant_builder_add(builder2, "{sv}", "device",
-// g_variant_new_object("o", NULL));
+// g_variant_builder_add(builder2, "{sv}", "device",
+// g_variant_new_object("o", NULL));
options = g_variant_new("a{sv}", builder2);
g_variant_new_uint16(offset));
/* Device Object path*/
-// g_variant_builder_add(builder2, "{sv}", "device",
-// g_variant_new_object("o", NULL));
+// g_variant_builder_add(builder2, "{sv}", "device",
+// g_variant_new_object("o", NULL));
options = g_variant_new("a{sv}", builder2);
"WriteValue",
g_variant_new("(@ay@a{sv})",
val, options),
- NULL,
+ G_VARIANT_TYPE("(y)"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL,
(GAsyncReadyCallback)__bluetooth_internal_write_cb,
GByteArray *gp_byte_array = NULL;
GVariantIter *iter;
guint8 g_byte;
+ gint att_error_code;
BT_DBG("+");
user_info = _bt_get_user_data(BT_COMMON);
return;
}
- gp_byte_array = g_byte_array_new();
- g_variant_get(value, "(ay)", &iter);
+ g_variant_get(value, "(yay)", &att_error_code, &iter);
+
+ if (att_error_code != 0) {
+ if (user_info) {
+ _bt_common_event_cb(BLUETOOTH_EVENT_GATT_READ_DESC,
+ att_error_code, NULL,
+ user_info->cb, user_info->user_data);
+ }
+ g_free(char_value.handle);
+ g_variant_unref(value);
+ g_variant_iter_free(iter);
+ return;
+ }
+ gp_byte_array = g_byte_array_new();
while (g_variant_iter_loop(iter, "y", &g_byte))
g_byte_array_append(gp_byte_array, &g_byte, 1);
GATT_DESC_INTERFACE,
"ReadValue",
g_variant_new("(a{sv})", builder),
- G_VARIANT_TYPE("(ay)"),
+ G_VARIANT_TYPE("(yay)"),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
g_variant_new_uint16(offset));
/* Device Object path*/
-// g_variant_builder_add(builder2, "{sv}", "device",
-// g_variant_new_object("o", NULL));
+// g_variant_builder_add(builder2, "{sv}", "device",
+// g_variant_new_object("o", NULL));
options = g_variant_new("a{sv}", builder2);