{
GDBusConnection *conn;
char *handle;
+ GVariantBuilder *builder = NULL;
+ guint16 offset = 0;
BT_CHECK_PARAMETER(characteristic, return);
BT_CHECK_ENABLED(return);
handle = g_strdup(characteristic);
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+ /*offset*/
+ g_variant_builder_add(builder, "{sv}", "offset",
+ g_variant_new("q", offset));
+
+ /* Device Object path*/
+// g_variant_builder_add(builder, "{sv}", "device",
+// g_variant_new_object("o", NULL));
+
g_dbus_connection_call(conn,
BT_BLUEZ_NAME,
characteristic,
GATT_CHAR_INTERFACE,
"ReadValue",
- NULL,
+ g_variant_new("(a{sv})", builder),
G_VARIANT_TYPE("(ay)"),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
(GAsyncReadyCallback)__bluetooth_internal_read_cb,
(gpointer)handle);
+ g_variant_builder_unref(builder);
return BLUETOOTH_ERROR_NONE;
}
BT_EXPORT_API int bluetooth_gatt_set_characteristics_value(
const char *char_handle, const guint8 *value, int length)
{
- GVariant *val;
- GVariantBuilder *builder;
+ GVariant *val, *options;
+ GVariantBuilder *builder1;
+ GVariantBuilder *builder2;
GError *error = NULL;
GDBusConnection *conn;
int i = 0;
+ guint16 offset = 0;
BT_DBG("+");
BT_CHECK_PARAMETER(char_handle, return);
conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
- builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
-
+ builder1 = g_variant_builder_new(G_VARIANT_TYPE("ay"));
for (i = 0; i < length; i++)
- g_variant_builder_add(builder, "y", value[i]);
+ g_variant_builder_add(builder1, "y", value[i]);
+
+ val = g_variant_new("ay", builder1);
+
+ builder2 = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ /*offset*/
+ g_variant_builder_add(builder2, "{sv}", "offset",
+ g_variant_new_uint16(offset));
- val = g_variant_new("(ay)", builder);
+ /* Device Object path*/
+// 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",
- val,
+ g_variant_new("(@ay@a{sv})", val, options),
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (error) {
BT_ERR("Set value Failed: %s", error->message);
g_clear_error(&error);
- g_variant_builder_unref(builder);
+ g_variant_builder_unref(builder1);
return BLUETOOTH_ERROR_INTERNAL;
}
-
- g_variant_builder_unref(builder);
+ g_variant_builder_unref(builder1);
+ g_variant_builder_unref(builder2);
BT_DBG("-");
return BLUETOOTH_ERROR_NONE;
BT_EXPORT_API int bluetooth_gatt_set_characteristics_value_by_type(
const char *char_handle, const guint8 *value, int length, guint8 write_type)
{
- GVariant *val;
- GVariantBuilder *builder;
+ GVariant *val, *options;
+ GVariantBuilder *builder1;
+ GVariantBuilder *builder2;
GDBusConnection *conn;
+ guint16 offset = 0;
int i = 0;
int ret = BLUETOOTH_ERROR_NONE;
conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
- builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
+ builder1 = g_variant_builder_new(G_VARIANT_TYPE("ay"));
for (i = 0; i < length; i++)
- g_variant_builder_add(builder, "y", value[i]);
+ g_variant_builder_add(builder1, "y", value[i]);
+
+ val = g_variant_new("ay", builder1);
+
+ builder2 = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ /*offset*/
+ g_variant_builder_add(builder2, "{sv}", "offset",
+ g_variant_new_uint16(offset));
+
+ /* Device Object path*/
+// g_variant_builder_add(builder2, "{sv}", "device",
+// g_variant_new_object("o", NULL));
+
+ options = g_variant_new("a{sv}", builder2);
- val = g_variant_new("ay", builder);
g_dbus_connection_call(conn,
BT_BLUEZ_NAME,
char_handle,
GATT_CHAR_INTERFACE,
"WriteValuebyType",
- g_variant_new("(y@ay)", write_type, val),
+ g_variant_new("(y@ay@a{sv})",
+ write_type, val, options),
G_VARIANT_TYPE("(y)"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL,
(GAsyncReadyCallback)__bluetooth_internal_write_cb,
NULL);
- g_variant_builder_unref(builder);
+ g_variant_builder_unref(builder1);
+ g_variant_builder_unref(builder2);
return ret;
}
BT_EXPORT_API int bluetooth_gatt_set_characteristics_value_request(
const char *char_handle, const guint8 *value, int length)
{
- GVariant *val;
+ GVariant *val, *options;
GDBusConnection *conn;
- GVariantBuilder *builder;
+ GVariantBuilder *builder1;
+ GVariantBuilder *builder2;
+ guint offset = 0;
int i;
BT_DBG("+");
conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
- builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
+ builder1 = g_variant_builder_new(G_VARIANT_TYPE("ay"));
for (i = 0; i < length; i++) {
- g_variant_builder_add(builder, "y", value[i]);
+ g_variant_builder_add(builder1, "y", value[i]);
BT_DBG("value [] = %d", value[i]);
}
- val = g_variant_new("(ay)", builder);
+ val = g_variant_new("ay", builder1);
+
+ builder2 = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ /*offset*/
+ g_variant_builder_add(builder2, "{sv}", "offset",
+ g_variant_new_uint16(offset));
+
+ /* Device Object path*/
+// g_variant_builder_add(builder2, "{sv}", "device",
+// g_variant_new_object("o", NULL));
+
+ options = g_variant_new("a{sv}", builder2);
g_dbus_connection_call(conn,
BT_BLUEZ_NAME,
char_handle,
GATT_CHAR_INTERFACE,
"WriteValue",
- val,
+ g_variant_new("(@ay@a{sv})",
+ val, options),
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1, NULL,
(GAsyncReadyCallback)__bluetooth_internal_write_cb,
NULL);
- g_variant_builder_unref(builder);
+ g_variant_builder_unref(builder1);
+ g_variant_builder_unref(builder2);
BT_DBG("-");
return BLUETOOTH_ERROR_NONE;
BT_EXPORT_API int bluetooth_gatt_read_descriptor_value(const char *char_descriptor)
{
GDBusConnection *conn;
+ GVariantBuilder *builder;
+ guint offset = 0;
char *handle;
BT_DBG("+");
handle = g_strdup(char_descriptor);
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+ /*offset*/
+ g_variant_builder_add(builder, "{sv}", "offset",
+ g_variant_new("q", offset));
+ /* Device Object path*/
+// g_variant_builder_add(builder, "{sv}", "device",
+// g_variant_new("o", serv_info->serv_path));
+
g_dbus_connection_call(conn,
BT_BLUEZ_NAME,
char_descriptor,
GATT_DESC_INTERFACE,
"ReadValue",
- NULL,
+ g_variant_new("(a{sv})", builder),
G_VARIANT_TYPE("(ay)"),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
(GAsyncReadyCallback)__bluetooth_internal_read_desc_cb,
(gpointer)handle);
+ g_variant_builder_unref(builder);
BT_DBG("-");
return BLUETOOTH_ERROR_NONE;
BT_EXPORT_API int bluetooth_gatt_write_descriptor_value(
const char *desc_handle, const guint8 *value, int length)
{
- GVariant *val;
+ GVariant *val, *options;
GDBusConnection *conn;
- GVariantBuilder *builder;
+ GVariantBuilder *builder1;
+ GVariantBuilder *builder2;
+ guint offset = 0;
int i;
BT_DBG("+");
conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
- builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
+ builder1 = g_variant_builder_new(G_VARIANT_TYPE("ay"));
for (i = 0; i < length; i++)
- g_variant_builder_add(builder, "y", value[i]);
+ g_variant_builder_add(builder1, "y", value[i]);
- val = g_variant_new("(ay)", builder);
+ val = g_variant_new("ay", builder1);
+
+ builder2 = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ /*offset*/
+ g_variant_builder_add(builder2, "{sv}", "offset",
+ g_variant_new_uint16(offset));
+
+ /* Device Object path*/
+// g_variant_builder_add(builder2, "{sv}", "device",
+// g_variant_new_object("o", NULL));
+
+ options = g_variant_new("a{sv}", builder2);
g_dbus_connection_call(conn,
BT_BLUEZ_NAME,
desc_handle,
GATT_DESC_INTERFACE,
"WriteValue",
- val,
+ g_variant_new("(@ay@a{sv})",
+ val, options),
G_VARIANT_TYPE("(y)"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL,
(GAsyncReadyCallback)__bluetooth_internal_write_desc_cb,
NULL);
- g_variant_builder_unref(builder);
+ g_variant_builder_unref(builder1);
+ g_variant_builder_unref(builder2);
BT_DBG("-");
return BLUETOOTH_ERROR_NONE;