#include "bt-request-sender.h"
#include "bt-event-handler.h"
-#ifdef TIZEN_DPM_ENABLE
+#ifdef TIZEN_FEATURE_BT_DPM
#include "bt-dpm.h"
#endif
+BT_EXPORT_API int bluetooth_disconnect_device(const bluetooth_device_address_t *remote_address)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(remote_address, return);
+ BT_CHECK_ENABLED(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, remote_address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DISCONNECT_DEVICE,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
BT_EXPORT_API int bluetooth_bond_device(const bluetooth_device_address_t *device_address)
{
int result;
return BLUETOOTH_ERROR_PERMISSION_DEINED;
}
-#ifdef TIZEN_DPM_ENABLE
+#ifdef TIZEN_FEATURE_BT_DPM
if (_bt_check_dpm(BT_DPM_PAIRING, NULL) == BT_DPM_RESTRICTED) {
BT_ERR("Not allow to pair the device");
- return BLUETOOTH_ERROR_ACCESS_DENIED;
+ return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
}
if (_bt_check_dpm(BT_DPM_ADDRESS, (void *)device_address) == BT_DPM_RESTRICTED) {
BT_ERR("Blacklist device");
- return BLUETOOTH_ERROR_ACCESS_DENIED;
+ return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
}
#endif
bt_user_info_t *user_info;
BT_CHECK_PARAMETER(device_address, return);
- if(conn_type == BLUETOOTH_DEV_CONN_BREDR)
- BT_CHECK_ENABLED(return);
- else if(conn_type == BLUETOOTH_DEV_CONN_LE)
- BT_CHECK_ENABLED_LE(return);
- else if(conn_type == BLUETOOTH_DEV_CONN_DEFAULT) {
- BT_CHECK_ENABLED(return);
- BT_CHECK_ENABLED_LE(return);
- }
+ BT_CHECK_ENABLED(return);
if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_BOND_DEVICE_BY_TYPE)
== BLUETOOTH_ERROR_PERMISSION_DEINED) {
{
int result;
- BT_CHECK_ENABLED_ANY(return);
+ BT_CHECK_ENABLED(return);
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
bt_user_info_t *user_info;
BT_CHECK_PARAMETER(device_address, return);
- BT_CHECK_ENABLED_ANY(return);
+ BT_CHECK_ENABLED(return);
if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_UNBOND_DEVICE)
== BLUETOOTH_ERROR_PERMISSION_DEINED) {
BT_CHECK_PARAMETER(device_address, return);
BT_CHECK_PARAMETER(dev_info, return);
- BT_CHECK_ENABLED_ANY(return);
+ BT_CHECK_ENABLED(return);
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
return result;
}
+BT_EXPORT_API int bluetooth_get_is_alias_set(const bluetooth_device_address_t *device_address,
+ gboolean *is_alias_set)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(device_address, return);
+ BT_CHECK_PARAMETER(is_alias_set, return);
+ BT_CHECK_ENABLED(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_IS_ALIAS_SET,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE)
+ *is_alias_set = g_array_index(out_param, gboolean, 0);
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
BT_EXPORT_API int bluetooth_get_remote_device(const bluetooth_device_address_t *device_address)
{
return BLUETOOTH_ERROR_NONE;
bt_user_info_t *user_info;
BT_CHECK_PARAMETER(device_address, return);
- BT_CHECK_ENABLED_ANY(return);
+ BT_CHECK_ENABLED(return);
if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_SEARCH_SERVICE)
== BLUETOOTH_ERROR_PERMISSION_DEINED) {
{
int result;
- BT_CHECK_ENABLED_ANY(return);
+ BT_CHECK_ENABLED(return);
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
BT_CHECK_PARAMETER(device_address, return);
BT_CHECK_PARAMETER(alias, return);
- BT_CHECK_ENABLED_ANY(return);
+ BT_CHECK_ENABLED(return);
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
int result;
BT_CHECK_PARAMETER(device_address, return);
- BT_CHECK_ENABLED_ANY(return);
+ BT_CHECK_ENABLED(return);
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
BT_CHECK_PARAMETER(device_address, return);
BT_CHECK_PARAMETER(is_connected, return);
- BT_CHECK_ENABLED_ANY(return);
+ BT_CHECK_ENABLED(return);
-#ifdef RFCOMM_DIRECT
+#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
if (type & BLUETOOTH_RFCOMM_SERVICE) {
result = bluetooth_rfcomm_client_is_connected(device_address, is_connected);
if (*is_connected == FALSE)
result = _bt_send_request(BT_BLUEZ_SERVICE, BT_IS_DEVICE_CONNECTED,
in_param1, in_param2, in_param3, in_param4, &out_param);
- if (result == BLUETOOTH_ERROR_NONE) {
+ if (result == BLUETOOTH_ERROR_NONE)
*is_connected = g_array_index(out_param, gboolean, 0);
- }
BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
return result;
}
+#ifdef TIZEN_GATT_CLIENT
+BT_EXPORT_API int bluetooth_connect_le(const bluetooth_device_address_t *device_address,
+ gboolean auto_connect, int client_id)
+#else
BT_EXPORT_API int bluetooth_connect_le(const bluetooth_device_address_t *device_address, gboolean auto_connect)
+#endif
{
int result;
bt_user_info_t *user_info;
BT_CHECK_PARAMETER(device_address, return);
BT_CHECK_ENABLED_ANY(return);
+ if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_CONNECT_LE)
+ == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+ BT_ERR("Don't have a privilege to use this API");
+ return BLUETOOTH_ERROR_PERMISSION_DEINED;
+ }
+
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
g_array_append_vals(in_param2, &auto_connect, sizeof(gboolean));
+#ifdef TIZEN_GATT_CLIENT
+ g_array_append_vals(in_param3, &client_id, sizeof(int));
+#endif
+
user_info = _bt_get_user_data(BT_COMMON);
retv_if(user_info == NULL, BLUETOOTH_ERROR_INTERNAL);
+ BT_INFO_C("### Connect LE");
result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_CONNECT_LE,
in_param1, in_param2, in_param3, in_param4,
user_info->cb, user_info->user_data);
return result;
}
+#ifdef TIZEN_GATT_CLIENT
+BT_EXPORT_API int bluetooth_disconnect_le(const bluetooth_device_address_t *device_address,
+ int client_id)
+#else
BT_EXPORT_API int bluetooth_disconnect_le(const bluetooth_device_address_t *device_address)
+#endif
{
int result;
bt_user_info_t *user_info;
BT_CHECK_PARAMETER(device_address, return);
BT_CHECK_ENABLED_ANY(return);
+ if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_DISCONNECT_LE)
+ == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+ BT_ERR("Don't have a privilege to use this API");
+ return BLUETOOTH_ERROR_PERMISSION_DEINED;
+ }
+
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
-
+#ifdef TIZEN_GATT_CLIENT
+ BT_DBG("Send GATT disconnect using Client Interface [%d]", client_id);
+ g_array_append_vals(in_param2, &client_id, sizeof(int));
+#endif
user_info = _bt_get_user_data(BT_COMMON);
retv_if(user_info == NULL, BLUETOOTH_ERROR_INTERNAL);
+ BT_INFO_C("### Disconnect LE");
result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_DISCONNECT_LE,
in_param1, in_param2, in_param3, in_param4,
user_info->cb, user_info->user_data);
return result;
}
+BT_EXPORT_API int bluetooth_get_gatt_data_batching_available_packets(
+ int *available_packets)
+{
+ int result;
+ int available;
+
+ BT_CHECK_PARAMETER(available_packets, return);
+ BT_CHECK_ENABLED_ANY(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_GATT_DATA_BATCHING_AVAILABLE_PACKETS,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ available = g_array_index(out_param, guint, 0);
+ BT_DBG("available_packets: %d", available);
+ *available_packets = available;
+ }
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_enable_gatt_data_batching(
+ const bluetooth_device_address_t *device_address, int packet_threshold, int timeout)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(device_address, return);
+ BT_CHECK_ENABLED_ANY(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
+ g_array_append_vals(in_param2, &packet_threshold, sizeof(int));
+ g_array_append_vals(in_param3, &timeout, sizeof(int));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_ENABLE_GATT_DATA_BATCHING,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_disable_gatt_data_batching(
+ const bluetooth_device_address_t *device_address)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(device_address, return);
+ BT_CHECK_ENABLED_ANY(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DISABLE_GATT_DATA_BATCHING,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
BT_EXPORT_API int bluetooth_enable_rssi(const bluetooth_device_address_t *remote_address,
int link_type, bt_rssi_threshold_t *rssi_threshold)
{
+#ifdef __BROADCOM_PATCH__
int result;
- BT_CHECK_ENABLED_ANY(return);
+ BT_CHECK_ENABLED(return);
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
return result;
+#else
+ BT_ERR("Current chipset does not support this function.");
+ return BLUETOOTH_ERROR_NOT_SUPPORT;
+#endif
}
BT_EXPORT_API int bluetooth_get_rssi_strength(const bluetooth_device_address_t *remote_address, int link_type)
{
+#ifdef __BROADCOM_PATCH__
int result;
- BT_CHECK_ENABLED_ANY(return);
+ BT_CHECK_ENABLED(return);
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
return result;
+#else
+ BT_ERR("Current chipset does not support this function.");
+ return BLUETOOTH_ERROR_NOT_SUPPORT;
+#endif
}
BT_EXPORT_API int bluetooth_le_conn_update(const bluetooth_device_address_t *address,
{
int result;
- BT_CHECK_ENABLED_ANY(return);
+ BT_CHECK_ENABLED(return);
BT_CHECK_PARAMETER(address, return);
BT_CHECK_PARAMETER(parameters, return);
int result;
BT_CHECK_PARAMETER(device_address, return);
- BT_CHECK_ENABLED_ANY(return);
+ BT_CHECK_ENABLED(return);
BT_INIT_PARAMS();
BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_CONNECTED_LINK_TYPE,
in_param1, in_param2, in_param3, in_param4, &out_param);
- if (result == BLUETOOTH_ERROR_NONE) {
+ if (result == BLUETOOTH_ERROR_NONE)
*connected = g_array_index(out_param, guint, 0);
- }
BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
return result;
}
+BT_EXPORT_API int bluetooth_request_att_mtu(const bluetooth_device_address_t *device_address, unsigned int mtu)
+{
+ int result;
+ bt_user_info_t *user_info;
+
+ BT_CHECK_PARAMETER(device_address, return);
+ BT_CHECK_ENABLED_ANY(return);
+
+ if (mtu > BLUETOOTH_MAX_ATT_MTU)
+ return BLUETOOTH_ERROR_INVALID_PARAM;
+
+ if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_REQ_ATT_MTU)
+ == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+ BT_ERR("Don't have a privilege to use this API");
+ return BLUETOOTH_ERROR_PERMISSION_DEINED;
+ }
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
+ g_array_append_vals(in_param2, &mtu, sizeof(unsigned int));
+
+ user_info = _bt_get_user_data(BT_COMMON);
+ retv_if(user_info == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_REQ_ATT_MTU,
+ in_param1, in_param2, in_param3, in_param4,
+ user_info->cb, user_info->user_data);
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_get_att_mtu(const bluetooth_device_address_t *device_address,
+ unsigned int *mtu)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(device_address, return);
+ BT_CHECK_PARAMETER(mtu, return);
+ BT_CHECK_ENABLED(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_ATT_MTU,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE)
+ *mtu = g_array_index(out_param, unsigned int, 0);
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_get_device_ida(const bluetooth_device_address_t *device_rpa,
+ bluetooth_device_address_t *id_address)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(device_rpa, return);
+ BT_CHECK_PARAMETER(id_address, return);
+ BT_CHECK_ENABLED_ANY(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, device_rpa, sizeof(bluetooth_device_address_t));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_DEVICE_IDA,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ *id_address = g_array_index(out_param,
+ bluetooth_device_address_t, 0);
+ }
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_force_hcidump(int timeout)
+{
+ int result;
+
+ BT_CHECK_ENABLED_ANY(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, &timeout, sizeof(int));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_ENABLE_FORCE_HCI_DUMP,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_set_profile_trusted(
+ const bluetooth_device_address_t *device_address,
+ int profile, int trust)
+{
+ int result;
+
+ BT_CHECK_PARAMETER(device_address, return);
+ BT_CHECK_ENABLED(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
+ g_array_append_vals(in_param2, &profile, sizeof(int));
+ g_array_append_vals(in_param3, &trust, sizeof(int));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_SET_PROFILE_TRUSTED,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE)
+ BT_DBG("SUCCESSFUL");
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
+BT_EXPORT_API int bluetooth_get_profile_trusted(
+ const bluetooth_device_address_t *device_address,
+ int profile, int *trust)
+{
+ int result;
+ int trust_profile = 0;
+ BT_CHECK_PARAMETER(device_address, return);
+ BT_CHECK_ENABLED(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
+ g_array_append_vals(in_param2, &profile, sizeof(int));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_PROFILE_TRUSTED,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ trust_profile = g_array_index(out_param, guint, 0);
+ BT_DBG("SUCCESSFUL");
+ }
+ BT_DBG("TRUST %d", trust_profile);
+ *trust = trust_profile;
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
+}
+
BT_EXPORT_API int bluetooth_passkey_reply(char *passkey, gboolean reply)
{
int result;