gboolean auto_connect;
} bt_pending_le_conn_info_s;
+typedef struct {
+ char *address;
+ float interval_min;
+ float interval_max;
+ GSList *senders;
+} bt_connected_le_dev_t;
+
+typedef struct {
+ char *sender;
+ float interval_min;
+ float interval_max;
+ guint16 latency;
+ guint16 time_out;
+ float key;
+} bt_le_conn_param_t;
+
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 *le_connected_dev_list = NULL;
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;
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)) {
g_variant_get(tmp_value, "s", &address);
g_variant_unref(tmp_value);
- dev_info->address = g_strdup(address);
- dev_info->name = g_strdup(name);
- g_free(name);
+ dev_info->address = address;
+ dev_info->name = name;
g_variant_unref(value);
} else {
BT_ERR("result is NULL\n");
return dev_info;
}
-char *_bt_get_bonded_device_name(char *address)
+char *_bt_get_device_name(const char *bdaddress)
{
- bluetooth_device_address_t device_address = { {0} };
- bluetooth_device_info_t dev_info;
+ char *device_path = NULL;
+ const gchar *name = NULL;
+ gchar *dev_name = NULL;
+ gsize name_len = 0;
+ GVariant *result = NULL;
+ GError *err = NULL;
+ GDBusProxy *device_proxy;
+ GDBusConnection *conn;
- retv_if(address == NULL, strdup(""));
+ retv_if(bdaddress == NULL, NULL);
- _bt_convert_addr_string_to_type(device_address.addr, address);
+ device_path = _bt_get_device_object_path((char *)bdaddress);
+ retv_if(device_path == NULL, NULL);
- memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
+ conn = _bt_gdbus_get_system_gconn();
+ retv_if(conn == NULL, NULL);
+ INFO_SECURE("Device_path %s", device_path);
+ device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+ NULL, BT_BLUEZ_NAME, device_path,
+ BT_PROPERTIES_INTERFACE, NULL, &err);
- _bt_get_bonded_device_info(&device_address, &dev_info);
+ g_free(device_path);
+ retv_if(device_proxy == NULL, NULL);
- return g_strdup(dev_info.device_name.name);
+ result = g_dbus_proxy_call_sync(device_proxy, "Get",
+ g_variant_new("(ss)", BT_DEVICE_INTERFACE, "Alias"),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+ if (err) {
+ BT_ERR("DBus Error : %s", err->message);
+ g_clear_error(&err);
+ } else {
+ GVariant *value;
+ g_variant_get(result, "(v)", &value);
+ name = g_variant_get_string(value, &name_len);
+ INFO_SECURE("Alias Name [%s]", name);
+ if (name_len)
+ dev_name = g_strdup(name);
+ g_variant_unref(value);
+ g_variant_unref(result);
+ }
+
+ if (name_len == 0) {
+ GVariant *value;
+ result = g_dbus_proxy_call_sync(device_proxy, "Get",
+ g_variant_new("(ss)", BT_DEVICE_INTERFACE, "Name"),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+ if (err) {
+ ERR("DBus Error : %s", err->message);
+ g_clear_error(&err);
+ } else {
+ g_variant_get(result, "(v)", &value);
+ name = g_variant_get_string(value, &name_len);
+ INFO_SECURE("Name = %s", name);
+ if (name_len)
+ dev_name = g_strdup(name);
+ g_variant_unref(value);
+ g_variant_unref(result);
+ }
+ }
+
+ g_object_unref(device_proxy);
+ return dev_name;
}
static gboolean __ignore_auto_pairing_request(const char *address)
}
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) {
NULL,
&err);
g_free(device_path);
- if (err != NULL) {
- BT_ERR("UnpairDevice Fail: %s", err->message);
- g_error_free(err);
+ if (result == NULL) {
+ if (err != NULL) {
+ BT_ERR("UnpairDevice Fail: %s", err->message);
+ g_error_free(err);
+ }
return BLUETOOTH_ERROR_INTERNAL;
}
/* 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;
GDBusProxy *device_proxy;
GError *error = NULL;
GVariant *value;
- GVariant *tmp_value;
GDBusConnection *conn;
GVariant *result = NULL;
int ret = BLUETOOTH_ERROR_NONE;
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);
GDBusProxy *device_proxy;
GError *error = NULL;
GDBusConnection *conn;
- GVariant *tmp_value = NULL;
GVariant *value = NULL;
GVariant *result = NULL;
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,
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");
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;
}
g_timeout_add(1000, __bt_connect_le_timer_cb, NULL);
return BLUETOOTH_ERROR_NONE;
+ } else if (ret != BLUETOOTH_ERROR_NOT_IN_OPERATION) {
+ BT_ERR("Unable to hold advertising");
}
- BT_ERR("Unable to hold advertising");
-
return __bt_connect_le_device_internal(req_id, bd_addr, auto_connect);
}
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");
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;
}
return ret;
}
-int _bt_le_conn_update(unsigned char *device_address,
+static int __bt_le_set_conn_parameter(const char *address,
float interval_min, float interval_max,
guint16 latency, guint16 time_out)
{
- char address[BT_ADDRESS_STRING_SIZE] = { 0 };
gchar *device_path = NULL;
GError *error = NULL;
GDBusProxy *device_proxy = NULL;
GDBusConnection *conn;
GVariant *reply;
guint32 min, max, to;
- guint32 min_supervision_to;
int ret = BLUETOOTH_ERROR_NONE;
- BT_CHECK_PARAMETER(device_address, return);
+ BT_CHECK_PARAMETER(address, return);
BT_INFO("Min interval: %f, Max interval: %f, Latency: %u, Supervision timeout: %u",
interval_min, interval_max, latency, time_out);
- if (interval_min > interval_max ||
- interval_min < BT_LE_CONN_INTERVAL_MIN ||
- interval_max > BT_LE_CONN_INTERVAL_MAX) {
- ret = BLUETOOTH_ERROR_INVALID_PARAM;
- goto fail;
- }
-
- if (time_out < BT_LE_CONN_SUPER_TO_MIN ||
- time_out > BT_LE_CONN_SUPER_TO_MAX) {
- ret = BLUETOOTH_ERROR_INVALID_PARAM;
- goto fail;
- }
-
- if (latency > BT_LE_CONN_SLAVE_LATENCY_MAX) {
- ret = BLUETOOTH_ERROR_INVALID_PARAM;
- goto fail;
- }
-
- /*
- * The Supervision_Timeout in milliseconds shall be larger than
- * (1 + Conn_Latency) * Conn_Interval_Max * 2,
- * where Conn_Interval_Max is given in milliseconds.
- */
- min_supervision_to = (1 + latency) * interval_max * 2;
- if (time_out <= min_supervision_to) {
- ret = BLUETOOTH_ERROR_INVALID_PARAM;
- goto fail;
- }
-
- _bt_convert_addr_type_to_string(address, device_address);
-
- BT_DBG("Remote device address: %s", address);
-
- device_path = _bt_get_device_object_path(address);
+ device_path = _bt_get_device_object_path((char *)address);
if (device_path == NULL) {
BT_ERR("device_path NULL");
return ret;
}
+static void __bt_le_conn_param_free(void *data)
+{
+ bt_le_conn_param_t *param = (bt_le_conn_param_t *)data;
+
+ BT_DBG("%s", param->sender);
+ g_free(param->sender);
+ g_free(param);
+}
+
+static gint __bt_compare_le_conn_param_key(gpointer *a, gpointer *b)
+{
+ bt_le_conn_param_t *parama = (bt_le_conn_param_t *)a;
+ bt_le_conn_param_t *paramb = (bt_le_conn_param_t *)b;
+
+ return parama->key > paramb->key;
+}
+
+static bt_connected_le_dev_t *__bt_get_le_connected_dev_info(const char *address)
+{
+ GSList *l = NULL;
+ bt_connected_le_dev_t *dev;
+
+ if (!address)
+ return NULL;
+
+ for (l = le_connected_dev_list; l; l = g_slist_next(l)) {
+ dev = l->data;
+
+ if (g_strcmp0(dev->address, address) == 0)
+ return dev;
+ }
+ return NULL;
+}
+
+static bt_le_conn_param_t *__bt_get_le_conn_param_info(bt_connected_le_dev_t *dev, const char *sender)
+{
+ GSList *l = NULL;
+ bt_le_conn_param_t *param = NULL;
+
+ if (!dev || !sender)
+ return NULL;
+
+ for (l = dev->senders; l; l = g_slist_next(l)) {
+ param = l->data;
+ if (g_strcmp0(param->sender, sender) == 0)
+ return param;
+ }
+
+ return NULL;
+}
+
+int _bt_add_le_conn_param_info(const char *address, const char *sender,
+ float interval_min, float interval_max, guint16 latency, guint16 time_out)
+{
+ bt_connected_le_dev_t *dev = NULL;
+ bt_le_conn_param_t *param = NULL;
+ bt_le_conn_param_t *data = NULL;
+
+ if (!address || !sender)
+ return BLUETOOTH_ERROR_INVALID_PARAM;
+
+ dev = __bt_get_le_connected_dev_info(address);
+ if (!dev)
+ return BLUETOOTH_ERROR_INTERNAL;
+
+ param = __bt_get_le_conn_param_info(dev, sender);
+
+ data = g_malloc0(sizeof(bt_le_conn_param_t));
+ data->sender = g_strdup(sender);
+ data->interval_min = interval_min;
+ data->interval_max = interval_max;
+ data->latency = latency;
+ data->time_out = time_out;
+ data->key = interval_min + (interval_max - interval_min)/2;
+
+ if (param == NULL) {
+ BT_DBG("Add param %s %s %f %f", address, sender, interval_min, interval_max);
+ dev->senders = g_slist_append(dev->senders, data);
+ } else {
+ BT_DBG("Update param %s %s %f %f", address, sender, interval_min, interval_max);
+ dev->senders = g_slist_remove(dev->senders, param);
+ g_free(param->sender);
+ g_free(param);
+ dev->senders = g_slist_append(dev->senders, data);
+ }
+
+ /* Sorting. First element have the minimum interval */
+ dev->senders = g_slist_sort(dev->senders,
+ (GCompareFunc)__bt_compare_le_conn_param_key);
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+int _bt_remove_le_conn_param_info(const char *address, const char *sender, gboolean *is_removed)
+{
+ bt_connected_le_dev_t *dev = NULL;
+ bt_le_conn_param_t *param = NULL;
+
+ if (!address || !sender)
+ return BLUETOOTH_ERROR_INVALID_PARAM;
+
+ dev = __bt_get_le_connected_dev_info(address);
+ if (!dev)
+ return BLUETOOTH_ERROR_INTERNAL;
+
+ param = __bt_get_le_conn_param_info(dev, sender);
+ if (param) {
+ BT_DBG("Remove param %s %s ", address, sender);
+ dev->senders = g_slist_remove(dev->senders, param);
+ g_free(param->sender);
+ g_free(param);
+ *is_removed = TRUE;
+ } else
+ *is_removed = FALSE;
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+int _bt_remove_all_le_conn_param_info(const char *sender)
+{
+ GSList *l = NULL;
+ bt_connected_le_dev_t *dev = NULL;
+ bt_le_conn_param_t *param = NULL;
+ gboolean is_removed = FALSE;
+ char *sender_new = NULL;
+ unsigned char addr[BLUETOOTH_ADDRESS_LENGTH];
+ int ret = BLUETOOTH_ERROR_NONE;
+
+ if (!sender)
+ return BLUETOOTH_ERROR_INVALID_PARAM;
+
+ for (l = le_connected_dev_list; l; l = g_slist_next(l)) {
+ dev = l->data;
+ _bt_remove_le_conn_param_info(dev->address, sender, &is_removed);
+
+ if (is_removed) {
+ BT_INFO("Sender terminated. Update le conn interval [senders %d]",
+ g_slist_length(dev->senders));
+ if (g_slist_length(dev->senders) > 0) {
+ param = dev->senders->data;
+ BT_DBG("dev %f %f, param %f %f", dev->interval_min, dev->interval_max,
+ param->interval_min, param->interval_max);
+
+ if (dev->interval_min != param->interval_min ||
+ dev->interval_max != param->interval_max) {
+ sender_new = g_strdup(param->sender);
+
+ _bt_convert_addr_string_to_type(addr, dev->address);
+ ret = _bt_le_conn_update(sender_new, addr,
+ param->interval_min, param->interval_max,
+ param->latency, param->time_out);
+ g_free(sender_new);
+
+ if (ret != BLUETOOTH_ERROR_NONE)
+ BT_ERR("Unable to set le connection parameter");
+ }
+ } else {
+ BT_INFO("Set the default interval");
+
+ bluetooth_le_connection_param_t param = { 0 };
+ _bt_get_le_connection_parameter(
+ BLUETOOTH_LE_CONNECTION_MODE_LOW_POWER,
+ ¶m);
+
+ ret = __bt_le_set_conn_parameter(dev->address,
+ param.interval_min, param.interval_max,
+ param.latency, param.timeout);
+ if (ret == BLUETOOTH_ERROR_NONE) {
+ dev->interval_min = param.interval_min;
+ dev->interval_max = param.interval_max;
+ }
+ }
+ }
+ }
+
+ return ret;
+}
+
+void _bt_add_le_connected_dev_info(const char *address)
+{
+ bt_connected_le_dev_t *dev = NULL;
+
+ if (!address)
+ return;
+
+ dev = g_malloc0(sizeof(bt_connected_le_dev_t));
+ dev->address = g_strdup(address);
+
+ le_connected_dev_list = g_slist_append(le_connected_dev_list, dev);
+
+ return;
+}
+
+void _bt_remove_le_connected_dev_info(const char *address)
+{
+ bt_connected_le_dev_t *dev = NULL;
+
+ if (!address)
+ return;
+
+ dev = __bt_get_le_connected_dev_info(address);
+ if (!dev)
+ return;
+
+ g_slist_free_full(dev->senders, __bt_le_conn_param_free);
+ le_connected_dev_list = g_slist_remove(le_connected_dev_list, dev);
+ g_free(dev->address);
+ g_free(dev);
+
+ return;
+}
+
+int _bt_le_conn_update(const char *sender,
+ unsigned char *device_address,
+ float interval_min, float interval_max,
+ guint16 latency, guint16 time_out)
+{
+ char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+ guint32 min_supervision_to;
+ bt_connected_le_dev_t *dev = NULL;
+ bt_le_conn_param_t *param = NULL;
+ gboolean is_removed = FALSE;
+ int ret = BLUETOOTH_ERROR_NONE;
+
+ BT_CHECK_PARAMETER(device_address, return);
+
+ BT_INFO("Sender %s, Min interval: %f, Max interval: %f, Latency: %u, Supervision timeout: %u",
+ sender, interval_min, interval_max, latency, time_out);
+
+ if (interval_min > interval_max ||
+ interval_min < BT_LE_CONN_INTERVAL_MIN ||
+ interval_max > BT_LE_CONN_INTERVAL_MAX) {
+ ret = BLUETOOTH_ERROR_INVALID_PARAM;
+ goto fail;
+ }
+
+ if (time_out < BT_LE_CONN_SUPER_TO_MIN ||
+ time_out > BT_LE_CONN_SUPER_TO_MAX) {
+ ret = BLUETOOTH_ERROR_INVALID_PARAM;
+ goto fail;
+ }
+
+ if (latency > BT_LE_CONN_SLAVE_LATENCY_MAX) {
+ ret = BLUETOOTH_ERROR_INVALID_PARAM;
+ goto fail;
+ }
+
+ /*
+ * The Supervision_Timeout in milliseconds shall be larger than
+ * (1 + Conn_Latency) * Conn_Interval_Max * 2,
+ * where Conn_Interval_Max is given in milliseconds.
+ */
+ min_supervision_to = (1 + latency) * interval_max * 2;
+ if (time_out <= min_supervision_to) {
+ ret = BLUETOOTH_ERROR_INVALID_PARAM;
+ goto fail;
+ }
+
+ _bt_convert_addr_type_to_string(address, device_address);
+ BT_DBG("Remote device address: %s", address);
+
+ _bt_add_le_conn_param_info(address, sender, interval_min, interval_max, 0, 2000);
+
+ dev = __bt_get_le_connected_dev_info(address);
+ if (dev == NULL) {
+ ret = BLUETOOTH_ERROR_NOT_CONNECTED;
+ goto fail;
+ }
+
+ if (g_slist_length(dev->senders) == 1)
+ goto update;
+ else {
+ param = dev->senders->data;
+
+ BT_DBG("dev %f, param %f, input %f", dev->interval_min, param->interval_min, interval_min);
+
+ if (dev->interval_min == param->interval_min && dev->interval_max == param->interval_max) {
+ BT_DBG("Skip due to same interval");
+ return ret;
+ }
+
+ interval_min = param->interval_min;
+ interval_max = param->interval_max;
+ }
+
+update:
+ ret = __bt_le_set_conn_parameter(address, interval_min, interval_max, latency, time_out);
+
+ if (ret != BLUETOOTH_ERROR_NONE) {
+ _bt_remove_le_conn_param_info(address, sender, &is_removed);
+ return ret;
+ }
+
+ dev->interval_min = interval_min;
+ dev->interval_max = interval_max;
+
+fail:
+ return ret;
+}
+
int _bt_set_pin_code(bluetooth_device_address_t *device_address,
bluetooth_device_pin_code_t *pin_code)
{
g_free(device_path);
retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
- if (device_path == NULL) {
- BT_DBG("device_path NULL");
- ret = BLUETOOTH_ERROR_INTERNAL;
- goto fail;
- }
-
att_mtu_req_info = g_malloc0(sizeof(bt_funcion_data_t));
att_mtu_req_info->addr = (char *)g_strdup(address);
att_mtu_req_info->req_id = request_id;
NULL,
(GAsyncReadyCallback)__bt_request_att_mtu_device_cb,
NULL);
-fail:
+
return ret;
}
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);
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,
retv_if(device_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
- NULL, BT_BLUEZ_NAME,
- device_path, BT_DEVICE_INTERFACE, NULL, NULL);
+ NULL, BT_BLUEZ_NAME,
+ device_path, BT_DEVICE_INTERFACE, NULL, NULL);
g_free(device_path);
if (!device_proxy) {
BT_ERR("Unable to get proxy");
return BLUETOOTH_ERROR_INTERNAL;
}
- result = g_dbus_proxy_call_sync(device_proxy, "GetIDAddress",
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error);
-
+ result = g_dbus_proxy_call_sync(device_proxy, "GetIDAddress", NULL,
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
if (result == NULL) {
BT_ERR("Failed to get device ID address");
if (error != NULL) {
return BLUETOOTH_ERROR_INTERNAL;
}
- g_variant_get(result , "(s)", &idaddress);
- g_variant_unref(result);
-
+ g_variant_get(result , "(&s)", &idaddress);
if (idaddress == NULL) {
BT_ERR("No paired device");
- g_object_unref(device_proxy);
- return BLUETOOTH_ERROR_NOT_PAIRED;
- }
-
- BT_DBG("ID Address:%s", idaddress);
-
- if (idaddress)
+ ret = BLUETOOTH_ERROR_NOT_PAIRED;
+ } else {
+ DBG_SECURE("ID Address : %s", idaddress);
_bt_convert_addr_string_to_type(id_address->addr, idaddress);
- else
- ret = BLUETOOTH_ERROR_INTERNAL;
+ }
+ g_variant_unref(result);
g_object_unref(device_proxy);
return ret;