GDBusConnection *__bt_hal_get_system_gconn(void)
{
- DBG("+");
if (system_conn == NULL)
system_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
- DBG("-");
return system_conn;
}
{ GDBusProxy *proxy;
GDBusConnection *conn;
- DBG("+");
conn = __bt_hal_get_system_gconn();
if (!conn)
return NULL;
core_proxy = proxy;
- DBG("-");
return proxy;
}
proxy = __bt_get_core_proxy();
if (!proxy) {
- DBG("_bt_hal_dbus_enable_adapter: Core proxy get failed!!!");
+ ERR("_bt_hal_dbus_enable_adapter: Core proxy get failed!!!");
return BT_STATUS_FAIL;
}
G_DBUS_CALL_FLAGS_NONE, BT_ENABLE_TIMEOUT,
NULL, &error);
if (error) {
- DBG("EnableAdapter failed: %s", error->message);
+ ERR("EnableAdapter failed: %s", error->message);
g_clear_error(&error);
error = NULL;
_bt_hal_set_adapter_request_state(FALSE);
&error);
if (error != NULL) {
- DBG("Bt core call failed(Error: %s)", error->message);
+ ERR("Bt core call failed(Error: %s)", error->message);
g_clear_error(&error);
}
g_variant_unref(result);
return BT_STATUS_FAIL;
}
- DBG("-");
g_variant_unref(result);
return BT_STATUS_SUCCESS;
}
DBG("+");
proxy = __bt_get_core_proxy();
-
if (!proxy) {
- DBG("_bt_hal_dbus_enable_adapter: Core proxy get failed!!!");
+ ERR("_bt_hal_dbus_enable_adapter: Core proxy get failed!!!");
return BT_STATUS_FAIL;
}
G_DBUS_CALL_FLAGS_NONE, -1,
NULL, &error);
if (error) {
- DBG("DisableAdapter failed: %s", error->message);
+ ERR("DisableAdapter failed: %s", error->message);
g_clear_error(&error);
error = NULL;
g_variant_unref(result);
return BT_STATUS_FAIL;
}
- DBG("-");
g_variant_unref(result);
return BT_STATUS_SUCCESS;
}
DBG("+");
proxy = __bt_get_core_proxy();
-
if (!proxy) {
- DBG("_bt_hal_dbus_recover_adapter: Core proxy get failed!!!");
+ ERR("_bt_hal_dbus_recover_adapter: Core proxy get failed!!!");
return BT_STATUS_FAIL;
}
G_DBUS_CALL_FLAGS_NONE, -1,
NULL, &error);
if (error) {
- DBG("RecoverAdapter failed: %s", error->message);
+ ERR("RecoverAdapter failed: %s", error->message);
g_clear_error(&error);
error = NULL;
return BT_STATUS_FAIL;
}
- DBG("-");
g_variant_unref(result);
return BT_STATUS_SUCCESS;
}
GDBusProxy *proxy;
GError *error = NULL;
GVariant *result;
+ struct hal_ev_discovery_state_changed ev;
DBG("+");
+ memset(&ev, 0, sizeof(ev));
+
proxy = _bt_hal_get_adapter_proxy();
if (!proxy) {
DBG("_bt_hal_dbus_stop_discovery: Adapter proxy get failed!!!");
return BT_STATUS_FAIL;
}
+ /* Stop success */
+ ev.state = HAL_DISCOVERY_STATE_STOPPED;
+
+ if (!event_cb)
+ event_cb = _bt_hal_get_stack_message_handler();
+ if (event_cb) {
+ DBG("Sending HAL_EV_DISCOVERY_STATE_CHANGED event");
+ event_cb(HAL_EV_DISCOVERY_STATE_CHANGED, (void*)&ev, sizeof(ev));
+ }
+
/* discovery status will be change in event */
DBG("-");
g_variant_unref(result);
return BT_STATUS_SUCCESS;
}
+int _bt_hal_dbus_get_energy_info(uint32_t *tx_time, uint32_t *rx_time,
+ uint32_t *idle_time, uint32_t *energy_used)
+{
+ GDBusProxy *proxy;
+ GError *error = NULL;
+ GVariant *result;
+
+ if (!tx_time || !rx_time || !idle_time || !energy_used) {
+ ERR("Invalid parameter");
+ return BT_STATUS_FAIL;
+ }
+
+ proxy = _bt_hal_get_adapter_proxy();
+ if (!proxy) {
+ DBG("_bt_hal_dbus_get_energy_info: Adapter proxy get failed!!!");
+ return BT_STATUS_FAIL;
+ }
+
+ result = g_dbus_proxy_call_sync(proxy,
+ "GetEnergyInfo",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+
+ if (!result) {
+ if (error != NULL) {
+ ERR("GetEnergyInfo failed (Error: %s)", error->message);
+ g_clear_error(&error);
+ } else {
+ ERR("GetEnergyInfo failed");
+ }
+ return BT_STATUS_FAIL;
+ }
+
+ g_variant_get(result, "(uuuu)", tx_time, rx_time, idle_time, energy_used);
+
+ DBG("Tx time: %d, Rx time: %d, Idle time: %d", *tx_time, *rx_time, *idle_time);
+
+ g_variant_unref(result);
+ return BT_STATUS_SUCCESS;
+}
+
+int _bt_hal_dbus_get_profile_connected_devices(const char *profile_uuid)
+{
+ GDBusConnection *conn;
+ GDBusProxy *manager_proxy;
+ GVariant *result = NULL;
+ GVariant *result1 = NULL;
+ GVariantIter *iter = NULL;
+ GError *error = NULL;
+ char *object_path = NULL;
+ GVariantIter *interface_iter;
+ char *interface_str = NULL;
+ GDBusProxy *device_proxy = NULL;
+ gboolean is_connected = FALSE;
+ struct hal_ev_adapter_profile_connected_devices ev;
+
+ DBG("Get Profile Connected Devices. UUID: %s", profile_uuid);
+ memset(&ev, 0, sizeof(ev));
+
+ conn = __bt_hal_get_system_gconn();
+ if (conn == NULL)
+ return BT_STATUS_FAIL;
+
+ manager_proxy = _bt_hal_get_manager_proxy();
+ if (manager_proxy == NULL)
+ return BT_STATUS_FAIL;
+
+ result = g_dbus_proxy_call_sync(manager_proxy, "GetManagedObjects",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+
+ if (!result) {
+ if (error != NULL) {
+ ERR("GetManagedObjects failed (Error: %s)", error->message);
+ g_clear_error(&error);
+ error = NULL;
+ } else
+ ERR("GetManagedObjects failed");
+ return BT_STATUS_FAIL;
+ }
+
+ /* signature of GetManagedObjects: a{oa{sa{sv}}} */
+ g_variant_get(result, "(a{oa{sa{sv}}})", &iter);
+
+ /* Parse the signature: oa{sa{sv}}} */
+ while (g_variant_iter_loop(iter, "{&oa{sa{sv}}}", &object_path, &interface_iter)) {
+ if (object_path == NULL)
+ continue;
+
+ while (g_variant_iter_loop(interface_iter, "{sa{sv}}",
+ &interface_str, NULL)) {
+ if (g_strcmp0(interface_str, "org.bluez.Device1") == 0) {
+ DBG("Found a device: %s", object_path);
+ g_free(interface_str);
+
+ device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+ NULL, BT_HAL_BLUEZ_NAME,
+ object_path, BT_HAL_DEVICE_INTERFACE, NULL, NULL);
+
+ if (device_proxy == NULL) {
+ DBG("Device don't have this service");
+ break;
+ }
+
+ result1 = g_dbus_proxy_call_sync(device_proxy, "IsConnectedProfile",
+ g_variant_new("(s)", profile_uuid),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+
+ if (result1 == NULL) {
+ if (error) {
+ ERR("Error occured in Proxy call [%s]", error->message);
+ g_error_free(error);
+ error = NULL;
+ }
+ g_object_unref(device_proxy);
+ break;
+ }
+ g_variant_get(result1, "(b)", &is_connected);
+
+ if (is_connected == TRUE) {
+ char address[BT_HAL_ADDRESS_STRING_SIZE];
+ _bt_hal_convert_device_path_to_address(object_path, address);
+ DBG("Address: %s", address);
+ if (ev.count >= 10) {
+ INFO("Too many address");
+ break;
+ }
+ _bt_hal_convert_addr_string_to_type(ev.bdaddr_list[ev.count], address);
+ ev.count++;
+ }
+
+ g_variant_unref(result1);
+ g_object_unref(device_proxy);
+ break;
+ }
+ }
+ }
+
+ if (!event_cb)
+ event_cb = _bt_hal_get_stack_message_handler();
+ if (event_cb) {
+ DBG("Sending HAL_EV_ADAPTER_PROFILE_CONNECTED_DEVICES event");
+ event_cb(HAL_EV_ADAPTER_PROFILE_CONNECTED_DEVICES, (void *)&ev, sizeof(ev));
+ }
+
+ g_variant_unref(result);
+ g_variant_iter_free(iter);
+
+ DBG("-");
+ return BT_STATUS_SUCCESS;
+}
+
static gboolean __bt_adapter_all_properties_cb(gpointer user_data)
{
GVariant *result = user_data;
_bt_hal_update_le_feature_support(name, val, &le_features);
le_features_present = TRUE;
}
+ g_free(val);
g_variant_iter_free(iter);
if (le_features_present) {
}
done:
g_variant_unref(result);
+ g_variant_iter_free(property_iter);
return FALSE;
}
adapter_path = _bt_hal_get_adapter_path();
if (adapter_path == NULL) {
- INFO("Adapter is not powered");
+ INFO("adapter_path is NULL");
g_free(adapter_path);
*state = 0;
return ret;
return ret;
}
+ g_free(adapter_path);
+
if (powered)
*state = 1;
else
int _bt_hal_dbus_get_scan_mode(void)
{
GDBusProxy *proxy;
- gboolean discoverable;
- gboolean connectable;
+ gboolean discoverable = FALSE;
+ gboolean connectable = FALSE;
GVariant *result;
GVariant *temp;
GError *error = NULL;
GVariant *result;
GVariant *temp;
GError *error = NULL;
- DBG("+");
proxy = _bt_hal_get_adapter_properties_proxy();
if (!proxy) {
- DBG("_bt_hal_dbus_get_local_name: Adapter Properties proxy get failed!!!");
+ DBG("Adapter Properties proxy get failed!!!");
return BT_STATUS_FAIL;
}
*/
g_idle_add(__bt_adapter_local_name_cb, (gpointer) name);
- DBG("-");
return BT_STATUS_SUCCESS;
}
GVariant *result;
GVariant *temp;
- DBG("+");
-
proxy = _bt_hal_get_adapter_properties_proxy();
if (!proxy) {
DBG("_bt_hal_dbus_get_local_address: Adapter Properties proxy get failed!!!");
*/
g_idle_add(__bt_adapter_local_address_cb, (gpointer) address);
- DBG("-");
return BT_STATUS_SUCCESS;
}
GError *error = NULL;
GVariant *result;
- DBG("+");
-
proxy = _bt_hal_get_adapter_properties_proxy();
-
if (!proxy) {
- DBG("_bt_hal_dbus_get_local_name: Adapter Properties proxy get failed!!!");
+ DBG("Adapter Properties proxy get failed!!!");
return BT_STATUS_FAIL;
}
*/
g_idle_add(__bt_adapter_service_uuids_cb, (gpointer)result);
- DBG("-");
return BT_STATUS_SUCCESS;
}
/* Buffer and propety count management */
uint8_t buf[BT_HAL_MAX_PROPERTY_BUF_SIZE];
uint8_t addresses[BT_HAL_MAX_PROPERTY_BUF_SIZE];
- struct hal_ev_adapter_props_changed *ev = (void*) buf;;
+ struct hal_ev_adapter_props_changed *ev = (void *)buf;
size_t size = 0;
size_t count = 0;
break;
}
}
+
+ if (count >= (int)(sizeof(addresses) / BT_HAL_ADDRESS_LENGTH_MAX)) {
+ DBG("Reached the max length of addresses. do not stored anymore");
+ break;
+ }
}
g_variant_iter_free(iter);
GDBusProxy *manager_proxy;
GVariant *result = NULL;
- DBG("+");
-
manager_proxy = _bt_hal_get_manager_proxy();
if (manager_proxy == NULL)
return BT_STATUS_FAIL;
*/
g_idle_add(__bt_adapter_bonded_devices_cb, (gpointer) result);
- DBG("-");
return BT_STATUS_SUCCESS;
}
int _bt_hal_dbus_get_adapter_property(bt_property_type_t property_type)
{
- DBG("+");
-
- INFO("property_type: %d", property_type);
+ DBG("property_type: %d", property_type);
switch (property_type) {
case BT_PROPERTY_BDADDR:
default:
return BT_STATUS_UNSUPPORTED;
}
-
- DBG("-");
}
static int __bt_hal_dbus_set_local_name(void *data)
GVariant *result;
GError *error = NULL;
- DBG("+");
DBG("Local Name: [%s]", name);
proxy = _bt_hal_get_adapter_properties_proxy();
if (!proxy) {
}
g_variant_unref(result);
- DBG("-");
return BT_STATUS_SUCCESS;
}
gboolean pg_scan;
gboolean inq_scan;
- DBG("+");
DBG("Scan mode: [%d]", *mode);
proxy = _bt_hal_get_adapter_properties_proxy();
if (!proxy) {
}
g_variant_unref(result);
- DBG("-");
return BT_STATUS_SUCCESS;
}
GVariant *result;
GError *error = NULL;
-
- DBG("+");
-
DBG("Discovery Timeout: [%d]", *timeout);
proxy = _bt_hal_get_adapter_properties_proxy();
if (!proxy) {
}
g_variant_unref(result);
- DBG("-");
return BT_STATUS_SUCCESS;
}
{
int result;
- DBG("");
-
if (property == NULL || property->val == NULL) {
ERR("Invalid parameters received");
return BT_STATUS_FAIL;
result = BT_STATUS_UNSUPPORTED;
}
- DBG("Result= [%d]", result);
return result;
}