GDBusConnection *conn;
char *address = NULL;
bt_tds_data_read_req_info *info = NULL;
+ GVariantBuilder *builder = NULL;
+ guint16 offset = 0;
BT_CHECK_PARAMETER(handle, return);
BT_CHECK_PARAMETER(sender, return);
return BLUETOOTH_ERROR_IN_PROGRESS;
}
- g_dbus_connection_call(conn,
- BT_BLUEZ_NAME,
- handle,
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ /*offset*/
+ g_variant_builder_add(builder, "{sv}", "offset",
+ g_variant_new("q", offset));
+
+ g_dbus_connection_call(conn, BT_BLUEZ_NAME, handle,
GATT_DESC_INTERFACE,
"ReadValue",
- NULL,
+ g_variant_new("(a{sv})", builder),
G_VARIANT_TYPE("(ay)"),
G_DBUS_CALL_FLAGS_NONE,
-1,
(GAsyncReadyCallback)__bt_tds_transport_data_read_desc_cb,
(gpointer)address);
+ g_variant_builder_unref(builder);
+
/* Save Info in pending list */
info = g_malloc0(sizeof(bt_tds_data_read_req_info));
info->remote_address = g_strdup(address);
return BLUETOOTH_ERROR_NONE;
}
+static int __bluetooth_get_att_error_code(GError *error)
+{
+ int att_ecode = 0;
+ int len;
+ char *str = NULL;
+
+ BT_ERR("Error : %s", error->message);
+ 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
+ return BLUETOOTH_ATT_ERROR_INTERNAL;
+
+ return att_ecode;
+}
+
static void __bluetooth_internal_activation_request_cb(GObject *source_object,
GAsyncResult *res, gpointer user_data)
{
GVariant *param = NULL;
GVariant *out_param1 = NULL;
int result = BLUETOOTH_ERROR_NONE;
- guint8 att_ecode = 0;
char *address = NULL;
bt_tds_activation_info *info = NULL;
request_info_t *req_info = NULL;
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);
- result = BLUETOOTH_ERROR_INTERNAL;
- } else {
- g_variant_get(value, "(y)", &att_ecode);
- if (att_ecode) {
- result = BLUETOOTH_ERROR_INTERNAL;
- BT_ERR("ATT Error code: %d \n", att_ecode);
- }
- }
+ if (error)
+ result = __bluetooth_get_att_error_code(error);
address = (char *)user_data;
info = __bt_tds_activation_info_by_address(address);
char *handle, unsigned char *param, int length)
{
GVariant *val;
- GVariantBuilder *builder;
+ GVariantBuilder *builder1;
+ GVariant *options;
+ GVariantBuilder *builder2;
+ guint16 offset = 0;
int i;
bt_tds_activation_info *info = NULL;
GDBusConnection *conn;
return BLUETOOTH_ERROR_IN_PROGRESS;
}
- 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", param[i]);
+ g_variant_builder_add(builder1, "y", param[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);
+ options = g_variant_new("a{sv}", builder2);
/* Activate Control Point */
g_dbus_connection_call(conn,
handle,
GATT_CHAR_INTERFACE,
"WriteValue",
- val,
- G_VARIANT_TYPE("(y)"),
+ g_variant_new("(@ay@a{sv})",
+ val, options),
+ NULL,
G_DBUS_CALL_FLAGS_NONE,
-1, NULL,
(GAsyncReadyCallback)__bluetooth_internal_activation_request_cb,
(gpointer)address);
- g_variant_builder_unref(builder);
+ g_variant_builder_unref(builder1);
+ g_variant_builder_unref(builder2);
if (info == NULL) {
info = g_malloc0(sizeof(bt_tds_activation_info));