_bt_hal_set_le_request_state(enable);
return BT_STATUS_SUCCESS;
}
+
+static int dev_disconnect(const bt_bdaddr_t *bd_addr)
+{
+ DBG("+");
+ return _bt_hal_device_disconnect(bd_addr);
+}
#endif
static const bt_interface_t bluetooth_if = {
.set_hal_le_request_state = set_hal_le_request_state,
.adapter_le_set_white_list = _bt_hal_adapter_le_set_white_list,
.adapter_le_set_privacy = _bt_hal_adapter_le_set_privacy,
+ .device_disconnect = dev_disconnect,
#endif
};
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
int low_threshold, int in_range_threshold, int high_threshold);
int _bt_hal_device_get_connected_link_rssi_strength(const bt_bdaddr_t *bd_addr, uint32_t link_type);
+
+int _bt_hal_device_disconnect(const bt_bdaddr_t *bd_addr);
#endif
#ifdef __cplusplus
* Sets the privacy functionality of the adapter
*/
int (*adapter_le_set_privacy)(uint8_t set_privacy);
+
+ /*
+ * disconnect the device
+ */
+ int (*device_disconnect)(const bt_bdaddr_t *bd_addr);
#endif
} bt_interface_t;
*/
oal_status_t device_enable_gap_auth_notifications(oal_gap_auth_type_e type, gboolean enable);
+/**
+ * @brief Disconnect the device
+ *
+ * @details This API is used to ACL disconnect the device
+ *
+ * @param[in] addr: Remote device address.
+ *
+ * @return TRUE if adapter has accepted the ACL Disconnect request FALSE otherwise.
+ *
+ * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
+ */
+oal_status_t device_disconnect(bt_address_t * addr);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
}
+oal_status_t device_disconnect(bt_address_t * addr)
+{
+ int res;
+ bdstr_t bdstr;
+
+ CHECK_OAL_INITIALIZED();
+
+ OAL_CHECK_PARAMETER(addr, return);
+
+ API_TRACE("[%s]", bdt_bd2str(addr, &bdstr));
+
+ res = blued_api->device_disconnect((bt_bdaddr_t *)addr);
+ if (res != BT_STATUS_SUCCESS) {
+ BT_ERR("device_disconnect error: [%s]", status2string(res));
+ return convert_to_oal_status(res);
+ }
+
+ return OAL_STATUS_SUCCESS;
+}
+
void cb_device_properties(bt_status_t status, bt_bdaddr_t *bd_addr,
int num_properties, bt_property_t *properties)
{
ev, sizeof(event_dev_rssi_info_t), (bt_address_t*)bd_addr);
BT_DBG("-");
}
+
#endif
g_array_append_vals(*out_param1, &is_coded_phy_supported, sizeof(gboolean));
break;
}
+ case BT_DISCONNECT_DEVICE: {
+ bluetooth_device_address_t address = { {0} };
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_disconnect_device(&address);
+ break;
+ }
default:
BT_INFO("UnSupported function [%d]", function_name);
result = BLUETOOTH_ERROR_NOT_SUPPORT;
case BT_CANCEL_SEARCH_SERVICE:
case BT_ENABLE_RSSI:
+ case BT_DISCONNECT_DEVICE:
case BT_RFCOMM_ACCEPT_CONNECTION:
case BT_RFCOMM_REJECT_CONNECTION:
return ret;
}
+int _bt_disconnect_device(bluetooth_device_address_t *device_address)
+{
+ int result = OAL_STATUS_SUCCESS;
+
+ BT_DBG("+");
+
+ retv_if(!device_address, BLUETOOTH_ERROR_INVALID_PARAM);
+
+ result = device_disconnect((bt_address_t *)device_address);
+ if (result != OAL_STATUS_SUCCESS) {
+ BT_DBG("Failed to disconnect device");
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ BT_DBG("-");
+ return BLUETOOTH_ERROR_NONE;
+}
+
#endif
int _bt_unset_pin_code(bluetooth_device_address_t *device_address);
+int _bt_disconnect_device(bluetooth_device_address_t *device_addr);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */