GATT ReadValue and WriteValue API's are
modified by Bluez upstream while moving the
GATT DBUS API's from EXPERIMENTAL to STABLE.
Accordingly, TDS Seeker API's are modified in
this patch to match latest ReadValue and
WriteValue API's.
Change-Id: I94316fe1212f38bcafad0345669182b248f8a44a
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
ind_res.tds_data.length = g_variant_get_size(byte_var);
buffer = (char *) g_variant_get_data(byte_var);
ind_res.tds_data.length = g_variant_get_size(byte_var);
buffer = (char *) g_variant_get_data(byte_var);
+ BT_DBG("[len = %d]", ind_res.tds_data.length);
memcpy(ind_res.tds_data.data, buffer, ind_res.tds_data.length);
memcpy(ind_res.tds_data.data, buffer, ind_res.tds_data.length);
_bt_convert_addr_string_to_type(ind_res.rem_addr.addr, address);
_bt_convert_addr_string_to_type(ind_res.rem_addr.addr, address);
break;
case BT_TDS_ACTIVATE_CONTROL_POINT:
*event_type = BT_TDS_EVENT;
break;
case BT_TDS_ACTIVATE_CONTROL_POINT:
*event_type = BT_TDS_EVENT;
- *event = BLUETOOTH_EVENT_TDS_ACTIVATION_INDICATION;
+ *event = BLUETOOTH_EVENT_TDS_ACTIVATION_RESULT;
ret_if(output == NULL);
*param_data = &g_array_index(output,
bluetooth_device_address_t, 0);
ret_if(output == NULL);
*param_data = &g_array_index(output,
bluetooth_device_address_t, 0);
GDBusConnection *conn;
char *address = NULL;
bt_tds_data_read_req_info *info = NULL;
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);
BT_CHECK_PARAMETER(handle, return);
BT_CHECK_PARAMETER(sender, return);
return BLUETOOTH_ERROR_IN_PROGRESS;
}
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",
GATT_DESC_INTERFACE,
"ReadValue",
+ g_variant_new("(a{sv})", builder),
G_VARIANT_TYPE("(ay)"),
G_DBUS_CALL_FLAGS_NONE,
-1,
G_VARIANT_TYPE("(ay)"),
G_DBUS_CALL_FLAGS_NONE,
-1,
(GAsyncReadyCallback)__bt_tds_transport_data_read_desc_cb,
(gpointer)address);
(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);
/* 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;
}
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)
{
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;
GVariant *param = NULL;
GVariant *out_param1 = NULL;
int result = BLUETOOTH_ERROR_NONE;
char *address = NULL;
bt_tds_activation_info *info = NULL;
request_info_t *req_info = NULL;
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);
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);
address = (char *)user_data;
info = __bt_tds_activation_info_by_address(address);
char *handle, unsigned char *param, int length)
{
GVariant *val;
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;
int i;
bt_tds_activation_info *info = NULL;
GDBusConnection *conn;
return BLUETOOTH_ERROR_IN_PROGRESS;
}
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++)
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,
/* Activate Control Point */
g_dbus_connection_call(conn,
handle,
GATT_CHAR_INTERFACE,
"WriteValue",
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_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));
if (info == NULL) {
info = g_malloc0(sizeof(bt_tds_activation_info));