char *pin_code;
} bt_pin_code_info_t;
+typedef struct {
+ int req_id;
+ bluetooth_device_address_t bd_addr;
+ gboolean auto_connect;
+} bt_pending_le_conn_info_s;
+
gboolean is_device_creating;
bt_funcion_data_t *bonding_info;
bt_funcion_data_t *searching_info;
bt_funcion_data_t *att_mtu_req_info;
static GSList *pin_info_list = NULL;
+static bt_pending_le_conn_info_s *pending_le_conn_info = NULL;
+static guint pending_le_conn_timer_id = 0;
/* This HID Mouse does not support pairing precedure. need to skip it. */
#define SMB_MOUSE_LAP_ADDR "00:12:A1"
bundle *b = NULL;
GDBusConnection *conn;
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
if (conn == NULL)
return FALSE;
retv_if(object_path == NULL, NULL);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
if (conn == NULL) {
BT_ERR("conn == NULL");
return NULL;
g_variant_unref(tmp_value);
}
- tmp_value = g_variant_lookup_value (value, "IsAliasSet", G_VARIANT_TYPE_BOOLEAN);
+ tmp_value = g_variant_lookup_value(value, "IsAliasSet", G_VARIANT_TYPE_BOOLEAN);
if (tmp_value) {
dev_info->is_alias_set = g_variant_get_boolean(tmp_value);
g_variant_unref(tmp_value);
g_variant_unref(tmp_value);
}
- tmp_value = g_variant_lookup_value(value, "ManufacturerDataLen", G_VARIANT_TYPE_UINT16);
+ tmp_value = g_variant_lookup_value(value, "LegacyManufacturerDataLen", G_VARIANT_TYPE_UINT16);
if (tmp_value) {
dev_info->manufacturer_data_len = g_variant_get_uint16(tmp_value);
if (dev_info->manufacturer_data_len > BLUETOOTH_MANUFACTURER_DATA_LENGTH_MAX) {
} else
dev_info->manufacturer_data_len = 0;
- tmp_value = g_variant_lookup_value(value, "ManufacturerData", G_VARIANT_TYPE_ARRAY);
+ tmp_value = g_variant_lookup_value(value, "LegacyManufacturerData", G_VARIANT_TYPE_ARRAY);
if (tmp_value) {
if ((dev_info->manufacturer_data_len == 0) ||
dev_info->manufacturer_data_len != g_variant_get_size(tmp_value)) {
}
buffer = g_malloc0(sizeof(char) * size);
- /* Fix : NULL_RETURNS */
- if (buffer == NULL) {
- BT_ERR("Memory allocation error\n");
- fclose(fp);
- return FALSE;
- }
result = fread((char *)buffer, 1, size, fp);
fclose(fp);
if (result != size) {
{
int result = BLUETOOTH_ERROR_NONE;
GError *err = NULL;
+ GVariant *reply;
GVariant *out_param1;
request_info_t *req_info;
bluetooth_device_info_t dev_info;
/* Terminate ALL system popup */
syspopup_destroy_all();
- g_dbus_proxy_call_finish(proxy, res, &err);
+ reply = g_dbus_proxy_call_finish(proxy, res, &err);
+ if (reply)
+ g_variant_unref(reply);
is_device_creating = FALSE;
result = BLUETOOTH_ERROR_HOST_DOWN;
} else if (g_strrstr(err->message, BT_DBUS_TIMEOUT_MESSAGE)) {
BT_INFO("Cancel already running bonding");
- if(__bt_cancel_bonding() != BLUETOOTH_ERROR_NONE) {
+ if (__bt_cancel_bonding() != BLUETOOTH_ERROR_NONE) {
BT_INFO("Error while Cancelling bonding");
/* we need to unref proxy so continue */
}
}
remote_dev_info = _bt_get_remote_device_info(bonding_info->addr);
- if(!remote_dev_info)
+ if (!remote_dev_info)
goto dbus_return;
GVariant *uuids = NULL;
return BLUETOOTH_ERROR_DEVICE_BUSY;
}
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
_bt_convert_addr_type_to_string(address, device_address->addr);
gpointer user_data)
{
GError *err = NULL;
+ GVariant *reply;
GVariant *out_param1;
int result = BLUETOOTH_ERROR_NONE;
bt_funcion_data_t *unbonding_info;
bluetooth_device_info_t dev_info;
request_info_t *req_info;
- g_dbus_proxy_call_finish(proxy, res, &err);
+ reply = g_dbus_proxy_call_finish(proxy, res, &err);
+ if (reply)
+ g_variant_unref(reply);
unbonding_info = user_data;
/* allocate user data so that it can be retrieved in callback */
unbonding_info = g_malloc0(sizeof(bt_funcion_data_t));
- /* Fix : NULL_RETURNS */
- if (unbonding_info == NULL) {
- BT_ERR("Memory not allocated !");
- return BLUETOOTH_ERROR_MEMORY_ALLOCATION;
- }
-
unbonding_info->addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
unbonding_info->req_id = request_id;
goto fail;
}
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
if (conn == NULL) {
BT_ERR("conn is NULL");
result = BLUETOOTH_ERROR_INTERNAL;
gpointer user_data)
{
GError *err = NULL;
+ GVariant *reply;
GVariant *out_param1;
int result = BLUETOOTH_ERROR_NONE;
bluetooth_device_info_t dev_info;
GVariantBuilder *builder = NULL;
int i = 0;
- g_dbus_proxy_call_finish(proxy, res, &err);
+ reply = g_dbus_proxy_call_finish(proxy, res, &err);
+ if (reply)
+ g_variant_unref(reply);
g_object_unref(proxy);
g_dbus_error_strip_remote_error(err);
BT_ERR("Error occured in Proxy call [%s]\n", err->message);
- if (g_strrstr("Operation canceled", err->message)) {
+ if (g_strrstr("Operation canceled", err->message))
result = BLUETOOTH_ERROR_CANCEL_BY_USER;
- } else if (g_strrstr("In Progress", err->message)) {
+ else if (g_strrstr("In Progress", err->message))
result = BLUETOOTH_ERROR_IN_PROGRESS;
- } else if (g_strrstr("Host is down", err->message)) {
+ else if (g_strrstr("Host is down", err->message))
result = BLUETOOTH_ERROR_HOST_DOWN;
- } else {
+ else
result = BLUETOOTH_ERROR_CONNECTION_ERROR;
- }
if (result == BLUETOOTH_ERROR_HOST_DOWN ||
result == BLUETOOTH_ERROR_CONNECTION_ERROR) {
}
remote_dev_info = _bt_get_remote_device_info(searching_info->addr);
- if(!remote_dev_info)
+ if (!remote_dev_info)
goto dbus_return;
event:
_bt_convert_addr_type_to_string(searching_info->addr,
device_address->addr);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
adapter_proxy = _bt_get_adapter_proxy();
retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
_bt_convert_addr_type_to_string(address, device_address->addr);
BT_CHECK_PARAMETER(device_address, return);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
_bt_convert_addr_type_to_string(address, device_address->addr);
}
result = g_dbus_proxy_call_sync(device_proxy, "Set",
- g_variant_new("(ssv)", BT_DEVICE_INTERFACE, "Trusted", g_variant_new("b",authorize)),
+ g_variant_new("(ssv)", BT_DEVICE_INTERFACE, "Trusted", g_variant_new("b", authorize)),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
GDBusProxy *device_proxy;
GError *error = NULL;
GVariant *value;
- GVariant *tmp_value;
GDBusConnection *conn;
GVariant *result = NULL;
int ret = BLUETOOTH_ERROR_NONE;
BT_CHECK_PARAMETER(device_address, return);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
_bt_convert_addr_type_to_string(address, device_address->addr);
g_free(object_path);
retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
- result = g_dbus_proxy_call_sync(device_proxy, "GetAll",
- g_variant_new("(s)", BT_DEVICE_INTERFACE),
+ result = g_dbus_proxy_call_sync(device_proxy, "Get",
+ g_variant_new("(ss)", BT_DEVICE_INTERFACE,
+ "GattConnected"),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
return BLUETOOTH_ERROR_INTERNAL;
}
- g_variant_get(result , "(@a{sv})", &value);
+ g_variant_get(result, "(v)", &value);
+ *is_connected = g_variant_get_boolean(value);
g_variant_unref(result);
- tmp_value = g_variant_lookup_value(value, "GattConnected", G_VARIANT_TYPE_BOOLEAN);
- if (tmp_value == NULL) {
- g_object_unref(device_proxy);
- g_variant_unref(value);
- return BLUETOOTH_ERROR_INTERNAL;
- }
-
- *is_connected = g_variant_get_boolean(tmp_value);
-
BT_DBG("gatt is connected : %d", *is_connected);
- g_variant_unref(tmp_value);
g_variant_unref(value);
g_object_unref(device_proxy);
{
char *object_path = NULL;
char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+ char secure_address[BT_ADDRESS_STRING_SIZE] = { 0 };
GDBusProxy *device_proxy = NULL;
GDBusProxy *adapter_proxy = NULL;
GDBusConnection *conn;
retv_if(device_address == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
retv_if(is_connected == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
+ _bt_convert_addr_type_to_string(address, device_address->addr);
+ _bt_convert_addr_string_to_secure_string(secure_address, address);
+
*is_connected = FALSE;
- BT_DBG("connection_type: %d", connection_type);
+ BT_DBG("%s connection_type: 0x%02x", secure_address, connection_type);
+
if (connection_type == BLUETOOTH_RFCOMM_SERVICE)
return _bt_rfcomm_is_device_connected(device_address,
is_connected);
adapter_proxy = _bt_get_adapter_proxy();
retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
_bt_convert_addr_type_to_string(address, device_address->addr);
} else {
uuid = _bt_get_profile_uuid128(connection_type);
if (uuid == NULL) {
- BT_ERR("uuid is NULL");
+ BT_ERR("connection_type: %d, uuid is NULL", connection_type);
return BLUETOOTH_ERROR_INTERNAL;
}
-
- BT_DBG("uuid: %s", uuid);
+ BT_DBG("uuid %s [%s]", uuid, _bt_convert_uuid_to_string(uuid));
object_path = _bt_get_device_object_path(address);
retv_if(object_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
GDBusProxy *device_proxy;
GError *error = NULL;
GDBusConnection *conn;
- GVariant *tmp_value = NULL;
GVariant *value = NULL;
GVariant *result = NULL;
BT_CHECK_PARAMETER(device_address, return);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
_bt_convert_addr_type_to_string(address, device_address->addr);
return BLUETOOTH_ERROR_NONE;
}
- result = g_dbus_proxy_call_sync(device_proxy, "GetAll",
- g_variant_new("(s)", BT_DEVICE_INTERFACE),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error);
+ result = g_dbus_proxy_call_sync(device_proxy, "Get",
+ g_variant_new("(ss)", BT_DEVICE_INTERFACE, "Connected"),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
if (error != NULL) {
BT_ERR("Error occured in Proxy call [%s]\n", error->message);
g_error_free(error);
g_object_unref(device_proxy);
return BLUETOOTH_ERROR_INTERNAL;
+ } else {
+ g_variant_get(result, "(v)", &value);
+ *connected = g_variant_get_byte(value);
+ g_variant_unref(value);
+ g_variant_unref(result);
}
- g_variant_get(result , "(@a{sv})", &value);
- g_variant_unref(result);
-
- tmp_value = g_variant_lookup_value(value, "Connected", G_VARIANT_TYPE_BYTE);
- if (tmp_value != NULL) {
- *connected = g_variant_get_byte(tmp_value);
- g_variant_unref(tmp_value);
- g_object_unref(device_proxy);
- return BLUETOOTH_ERROR_NONE;
- } else {
- BT_ERR("g_variant value is NULL");
- return BLUETOOTH_ERROR_INTERNAL;
- }
+ g_object_unref(device_proxy);
+ return BLUETOOTH_ERROR_NONE;
}
static void __le_connection_req_cb(GDBusProxy *proxy, GAsyncResult *res,
}
}
-int _bt_connect_le_device(int req_id, const bluetooth_device_address_t *bd_addr,
- gboolean auto_connect)
+static int __bt_connect_le_device_internal(int req_id, const bluetooth_device_address_t *bd_addr,
+ gboolean auto_connect)
{
char device_address[BT_ADDRESS_STRING_SIZE] = { 0 };
+ char secure_address[BT_ADDRESS_STRING_SIZE] = { 0 };
gchar *device_path = NULL;
GDBusProxy *device_proxy = NULL;
GDBusConnection *conn;
BT_CHECK_PARAMETER(bd_addr, return);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
_bt_convert_addr_type_to_string(device_address,
retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
func_data = g_malloc0(sizeof(bt_function_data_t));
- if (func_data == NULL) {
- BT_ERR("Unable to allocate memory for address");
- ret = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
- goto fail;
- }
-
func_data->address = g_strdup(device_address);
if (func_data->address == NULL) {
BT_ERR("Unable to allocate memory for address");
goto fail;
}
- func_data->req_id = req_id;
+ _bt_convert_addr_string_to_secure_string(secure_address, device_address);
+ BT_INFO("Connect LE [%s]", secure_address);
- ret = _bt_hold_current_advertising();
- if (ret != BLUETOOTH_ERROR_NONE) {
- BT_ERR("Unable to hold advertising");
- }
+ func_data->req_id = req_id;
g_dbus_proxy_call(device_proxy, "ConnectLE",
g_variant_new("(b)", auto_connect),
fail:
if (device_proxy)
g_object_unref(device_proxy);
- if (func_data) {
- g_free(func_data->address);
- g_free(func_data);
- }
+
+ g_free(func_data->address);
+ g_free(func_data);
+
return ret;
}
+static gboolean __bt_connect_le_timer_cb(gpointer user_data)
+{
+ BT_INFO("Try to initiate pending LE connection");
+
+ pending_le_conn_timer_id = 0;
+
+ __bt_connect_le_device_internal(pending_le_conn_info->req_id,
+ &pending_le_conn_info->bd_addr,
+ pending_le_conn_info->auto_connect);
+
+ g_free(pending_le_conn_info);
+ pending_le_conn_info = NULL;
+
+ return FALSE;
+}
+
+void _bt_pending_connect_le_device(void)
+{
+ if (pending_le_conn_timer_id > 0) {
+ g_source_remove(pending_le_conn_timer_id);
+ __bt_connect_le_timer_cb(NULL);
+ }
+}
+
+int _bt_connect_le_device(int req_id, const bluetooth_device_address_t *bd_addr,
+ gboolean auto_connect)
+{
+ int ret = BLUETOOTH_ERROR_NONE;
+
+ BT_CHECK_PARAMETER(bd_addr, return);
+
+ ret = _bt_hold_current_advertising();
+ if (ret == BLUETOOTH_ERROR_NONE) {
+ BT_INFO("Current advertising is held");
+ pending_le_conn_info = g_malloc0(sizeof(bt_pending_le_conn_info_s));
+ pending_le_conn_info->req_id = req_id;
+ memcpy(pending_le_conn_info->bd_addr.addr, bd_addr->addr,
+ BLUETOOTH_ADDRESS_LENGTH);
+ pending_le_conn_info->auto_connect = auto_connect;
+
+ pending_le_conn_timer_id =
+ g_timeout_add(1000, __bt_connect_le_timer_cb, NULL);
+
+ return BLUETOOTH_ERROR_NONE;
+ }
+
+ BT_ERR("Unable to hold advertising");
+
+ return __bt_connect_le_device_internal(req_id, bd_addr, auto_connect);
+}
+
int _bt_disconnect_le_device(int req_id,
const bluetooth_device_address_t *bd_addr)
{
char device_address[BT_ADDRESS_STRING_SIZE] = { 0 };
+ char secure_address[BT_ADDRESS_STRING_SIZE] = { 0 };
gchar *device_path;
GDBusProxy *device_proxy;
GDBusConnection *conn;
BT_CHECK_PARAMETER(bd_addr, return);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
_bt_convert_addr_type_to_string(device_address,
retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
func_data = g_malloc0(sizeof(bt_function_data_t));
- if (func_data == NULL) {
- BT_ERR("Unable to allocate memory for address");
- ret = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
- goto fail;
- }
-
func_data->address = g_strdup(device_address);
if (func_data->address == NULL) {
BT_ERR("Unable to allocate memory for address");
goto fail;
}
+ _bt_convert_addr_string_to_secure_string(secure_address, device_address);
+ BT_INFO("Disconnect LE [%s]", secure_address);
+
func_data->req_id = req_id;
g_dbus_proxy_call(device_proxy, "DisconnectLE",
fail:
if (device_proxy)
g_object_unref(device_proxy);
- if (func_data) {
- g_free(func_data->address);
- g_free(func_data);
- }
+
+ g_free(func_data->address);
+ g_free(func_data);
+
return ret;
}
_bt_convert_addr_type_to_string(device_address,
(unsigned char *)bd_addr->addr);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
adapter_proxy = _bt_get_adapter_proxy();
_bt_convert_addr_type_to_string(device_address,
(unsigned char *)bd_addr->addr);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
adapter_proxy = _bt_get_adapter_proxy();
GVariant *result = NULL;
GError *error = NULL;
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
object_path = _bt_get_device_object_path(address);
GDBusProxy *proxy;
GDBusConnection *conn;
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
object_path = _bt_get_device_object_path(address);
goto fail;
}
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
if (conn == NULL) {
BT_ERR("conn NULL");
ret = BLUETOOTH_ERROR_INTERNAL;
bluetooth_trusted_profile_t _bt_get_trusted_profile_enum(const char *uuid)
{
- if (g_strcmp0("0000112f-0000-1000-8000-00805f9b34fb", uuid) == 0) {
+ if (g_strcmp0("0000112f-0000-1000-8000-00805f9b34fb", uuid) == 0)
return TRUSTED_PROFILE_PBAP;
- } else if (g_strcmp0("00001132-0000-1000-8000-00805f9b34fb", uuid) == 0) {
+ else if (g_strcmp0("00001132-0000-1000-8000-00805f9b34fb", uuid) == 0)
return TRUSTED_PROFILE_MAP;
- } else if (g_strcmp0("0000112D-0000-1000-8000-00805f9b34fb", uuid) == 0) {
+ else if (g_strcmp0("0000112D-0000-1000-8000-00805f9b34fb", uuid) == 0)
return TRUSTED_PROFILE_SAP;
- }
+
return 0; /* 0 - Unknown Profile */
}
bd_addr->addr[4], bd_addr->addr[5],
profile, trust);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
_bt_convert_addr_type_to_string(address, bd_addr->addr);
bd_addr->addr[4], bd_addr->addr[5],
profile, *trust);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
_bt_convert_addr_type_to_string(address, bd_addr->addr);
bd_addr->addr[4], bd_addr->addr[5],
profile, restricted);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
_bt_convert_addr_type_to_string(address, bd_addr->addr);
bd_addr->addr[4], bd_addr->addr[5],
profile, *restricted);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
_bt_convert_addr_type_to_string(address, bd_addr->addr);
goto dbus_return;
if (val) {
- g_variant_get (val, "(qy)", &mtu, &status);
- g_variant_unref (val);
+ g_variant_get(val, "(qy)", &mtu, &status);
+ g_variant_unref(val);
}
BT_DBG("MTU %d, Status %d, %s", mtu, status, att_mtu_req_info->addr);
return BLUETOOTH_ERROR_DEVICE_BUSY;
}
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
adapter_proxy = _bt_get_adapter_proxy();
GDBusProxy *device_proxy;
GError *error = NULL;
GVariant *value;
- GVariant *tmp_value;
GDBusConnection *conn;
GVariant *result = NULL;
- int ret = BLUETOOTH_ERROR_NONE;
BT_CHECK_PARAMETER(device_address, return);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
_bt_convert_addr_type_to_string(address, device_address->addr);
g_free(object_path);
retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
- result = g_dbus_proxy_call_sync(device_proxy, "GetAll",
- g_variant_new("(s)", BT_DEVICE_INTERFACE),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error);
- if (result == NULL) {
- if (error != NULL) {
- BT_ERR("Error occured in Proxy call [%s]\n", error->message);
- g_error_free(error);
- }
+ result = g_dbus_proxy_call_sync(device_proxy, "Get",
+ g_variant_new("(ss)", BT_DEVICE_INTERFACE, "AttMtu"),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (error) {
+ ERR("DBus Error : %s", error->message);
+ g_clear_error(&error);
g_object_unref(device_proxy);
return BLUETOOTH_ERROR_INTERNAL;
- }
-
- g_variant_get(result , "(@a{sv})", &value);
- g_variant_unref(result);
-
- tmp_value = g_variant_lookup_value(value, "AttMtu", G_VARIANT_TYPE_UINT16);
- if (tmp_value == NULL) {
- g_object_unref(device_proxy);
+ } else {
+ g_variant_get(result, "(v)", &value);
+ *mtu = g_variant_get_uint16(value);
+ BT_DBG("ATT MTU : %d", *mtu);
g_variant_unref(value);
- return BLUETOOTH_ERROR_INTERNAL;
+ g_variant_unref(result);
}
- *mtu = g_variant_get_uint16(tmp_value);
-
- BT_DBG("ATT MTU : %d", *mtu);
-
- g_variant_unref(tmp_value);
- g_variant_unref(value);
g_object_unref(device_proxy);
-
- return ret;
+ return BLUETOOTH_ERROR_NONE;
}
int _bt_get_device_ida(bluetooth_device_address_t *device_address,
BT_CHECK_PARAMETER(device_address, return);
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
_bt_convert_addr_type_to_string(address, device_address->addr);
if (result == NULL) {
BT_ERR("Failed to get device ID address");
if (error != NULL) {
- BT_ERR("Error occured in Proxy call [%s]\n", error->message);
+ BT_ERR("Error occured in Proxy call [%s]", error->message);
g_error_free(error);
}
g_object_unref(device_proxy);
BT_DBG("ID Address:%s", idaddress);
- if (idaddress) {
+ if (idaddress)
_bt_convert_addr_string_to_type(id_address->addr, idaddress);
- } else {
+ else
ret = BLUETOOTH_ERROR_INTERNAL;
- }
g_object_unref(device_proxy);