(GAsyncReadyCallback)__bt_hal_unbond_device_cb,
(gpointer)device_path);
- DBG("-");
return BT_STATUS_SUCCESS;
}
event_cb(HAL_EV_REMOTE_DEVICE_PROPS, (void*) buf, size);
g_variant_unref(result);
+ g_variant_iter_free(property_iter);
}
int __bt_hal_dbus_enquire_remote_device_services(char *address)
struct hal_ev_bond_state_changed ev;
memset(&ev, 0, sizeof(ev));
char dev_address[18];
- DBG("+");
#if TODO_40
/* Terminate ALL system popup */
g_dbus_proxy_call_finish(proxy, res, &err);
device_path = g_dbus_proxy_get_object_path(proxy);
- DBG("Device path: %s", device_path);
_bt_hal_convert_device_path_to_address(device_path, dev_address);
- DBG("Remote Device address [%s]", dev_address);
if (err != NULL) {
g_dbus_error_strip_remote_error(err);
event_cb(HAL_EV_BOND_STATE_CHANGED, (void*)&ev, sizeof(ev));
}
} else {
- DBG("Bonding Success!!");
+ DBG("Bonding Success!! [%s]", dev_address);
}
- DBG("-");
}
static void __bt_hal_unbond_device_cb(GDBusProxy *proxy, GAsyncResult *res,
int result = BT_STATUS_SUCCESS;
struct hal_ev_bond_state_changed ev;
memset(&ev, 0, sizeof(ev));
- DBG("+");
g_dbus_proxy_call_finish(proxy, res, &err);
if (err != NULL) {
}
}
g_free(device_path);
-
- DBG("-");
}
static gboolean __bt_device_bonded_device_info_cb(gpointer user_data)
uint8_t uuid[BT_HAL_STACK_UUID_SIZE];
memset(uuid, 0x00, BT_HAL_STACK_UUID_SIZE);
uuid_str = g_strdup(uuid_value[i]);
- DBG("UUID string [%s]\n", uuid_str);
+ DBG("[%d] [%s]", i, uuid_str);
_bt_hal_convert_uuid_string_to_type(uuid, uuid_str);
memcpy(uuids + i * BT_HAL_STACK_UUID_SIZE, uuid, BT_HAL_STACK_UUID_SIZE);
g_free(uuid_str);
while (g_variant_iter_loop(char_value_iter, "y", &char_value))
g_byte_array_append(manufacturer_data, &char_value, 1);
+ g_variant_iter_free(char_value_iter);
+
if (manufacturer_data) {
if (manufacturer_data->len > 0) {
size += __bt_insert_hal_properties(
HAL_PROP_DEVICE_IS_ALIAS_SET, sizeof(uint8_t), &is_alias_set);
ev->num_props++;
} else {
- ERR("Unhandled Property:[%s]", key);
+ DBG("Unhandled Property:[%s]", key);
}
}
- DBG("trust: %d, paired: %d", trust, paired);
if (!event_cb)
event_cb = _bt_hal_get_stack_message_handler();
if (!event_cb) {
done:
g_variant_unref(result);
+ g_variant_iter_free(property_iter);
return FALSE;
}
return 1;
}
-int _bt_hal_device_set_osp_server(uint32_t type, gboolean enable)
+int _bt_hal_device_register_osp_server(uint32_t type, char *uuid, char *path, int fd)
{
GapAgentPrivate *agent = _bt_hal_get_adapter_agent();
gboolean result = FALSE;
if (!agent)
return BT_STATUS_FAIL;
- if (enable)
- result = _bt_hal_gap_agent_register_osp_server(agent, type);
- else
- result = _bt_hal_gap_agent_unregister_osp_server(agent, type);
+ result = _bt_hal_gap_agent_register_osp_server(agent, type, uuid, path, fd);
+ if (!result)
+ return BT_STATUS_FAIL;
+
+ DBG("-");
+ return BT_STATUS_SUCCESS;
+}
+int _bt_hal_device_unregister_osp_server(uint32_t type, char *uuid)
+{
+ GapAgentPrivate *agent = _bt_hal_get_adapter_agent();
+ gboolean result = FALSE;
+
+ DBG("+");
+ if (!agent)
+ return BT_STATUS_FAIL;
+
+ result = _bt_hal_gap_agent_unregister_osp_server(agent, type, uuid);
if (!result)
return BT_STATUS_FAIL;
trusted_flag, trusted);
}
+int _bt_hal_device_get_ida(bt_bdaddr_t *bd_addr, bt_bdaddr_t *id_addr)
+{
+ char address[BT_HAL_ADDRESS_STRING_SIZE] = { 0 };
+ gchar *device_path = NULL;
+ const gchar *idaddress = NULL;
+ GDBusProxy *device_proxy;
+ GError *error = NULL;
+ GVariant *result = NULL;
+ GDBusConnection *conn;
+ int ret = BT_STATUS_SUCCESS;
+
+ if (bd_addr == NULL)
+ return BT_STATUS_PARM_INVALID;
+
+ conn = _bt_hal_get_system_gconn();
+
+ if (!conn) {
+ ERR("_bt_hal_get_system_gconn failed");
+ return BT_STATUS_FAIL;
+ }
+
+ _bt_hal_convert_addr_type_to_string(address, bd_addr->address);
+
+ DBG("The device_address is: [%s]", address);
+
+ device_path = _bt_hal_get_device_object_path(address);
+
+ if (!device_path) {
+ ERR("_bt_hal_get_device_object_path failed");
+ return BT_STATUS_FAIL;
+ }
+
+ device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+ NULL, BT_HAL_BLUEZ_NAME, device_path,
+ BT_HAL_DEVICE_INTERFACE, NULL, NULL);
+ g_free(device_path);
+ if (!device_proxy) {
+ ERR("Unable to get proxy");
+ return BT_STATUS_FAIL;
+ }
+
+ result = g_dbus_proxy_call_sync(device_proxy, "GetIDAddress", NULL,
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (result == NULL) {
+ ERR("Failed to get device ID address");
+
+ ret = BT_STATUS_FAIL;
+ if (error != NULL) {
+ g_dbus_error_strip_remote_error(error);
+ ERR("Error occured in Proxy call [%s]", error->message);
+ if (g_strcmp0(error->message, "Does Not Exist") == 0)
+ ERR("Device does not exist");
+ g_error_free(error);
+ }
+ g_object_unref(device_proxy);
+ return ret;
+ }
+
+ g_variant_get(result , "(&s)", &idaddress);
+
+ DBG_SECURE("ID Address : %s", idaddress);
+ _bt_hal_convert_addr_string_to_type(id_addr->address, idaddress);
+
+ g_variant_unref(result);
+ g_object_unref(device_proxy);
+
+ return ret;
+}
+
int _bt_hal_device_enable_rssi_monitoring(bt_bdaddr_t *bd_addr, uint32_t link_type,
int low_threshold, int in_range_threshold, int high_threshold)
{
DBG("-");
return BT_STATUS_SUCCESS;
}
+
+
+int _bt_hal_device_disconnect(const bt_bdaddr_t *bd_addr)
+{
+ GDBusProxy *proxy;
+ char address[BT_HAL_ADDRESS_STRING_SIZE] = { 0 };
+ GError *error = NULL;
+ GVariant *result = NULL;
+ GDBusConnection *conn;
+ char *device_path = NULL;
+ DBG("+");
+
+ conn = _bt_hal_get_system_gconn();
+ if (!conn) {
+ DBG("Could not get DBUS connection!");
+ return BT_STATUS_FAIL;
+ }
+
+ _bt_hal_convert_addr_type_to_string(address, bd_addr->address);
+ device_path = _bt_hal_get_device_object_path(address);
+
+ if (device_path == NULL) {
+ ERR("No created device with address:[%s] in statck", address);
+ return BT_STATUS_FAIL;
+ }
+ proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+ NULL, BT_HAL_BLUEZ_NAME,
+ device_path, BT_HAL_DEVICE_INTERFACE, NULL, NULL);
+
+ g_free(device_path);
+ if (proxy == NULL) {
+ ERR("Could not get Device Proxy");
+ return BT_STATUS_FAIL;
+ }
+
+ result = g_dbus_proxy_call_sync(proxy, "Disconnect",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL,
+ &error);
+
+ if (error != NULL) {
+ ERR("Dbus Call Error:[%s]", error->message);
+ g_clear_error(&error);
+ g_object_unref(proxy);
+ return BT_STATUS_FAIL;
+ }
+
+ g_object_unref(proxy);
+ if (result)
+ g_variant_unref(result);
+
+ DBG("-");
+ return BT_STATUS_SUCCESS;
+}
#endif