#include "bt-service-pbap.h"
#include "bt-service-oob.h"
+#include "bt-service-battery-monitor.h"
+
#ifdef TIZEN_FEATURE_BT_PAN_NAP
#include "bt-service-network.h"
#endif
static guint owner_sig_id = 0;
static gboolean is_le_intended = FALSE;
-
static cynara *p_cynara;
static cynara_configuration *conf;
{
GSList *l;
invocation_info_t *info;
-
ret_if(NULL == req_info);
ret_if(NULL == req_info->sender);
|| service_function == BT_GET_IS_ALIAS_SET
|| service_function == BT_GET_CONNECTED_LINK_TYPE
|| service_function == BT_IS_SERVICE_USED
+ || service_function == BT_RFCOMM_LISTEN_AND_ACCEPT
|| service_function == BT_RFCOMM_LISTEN
|| service_function == BT_HDP_REGISTER_SINK_APP
|| service_function == BT_HDP_UNREGISTER_SINK_APP
|| service_function == BT_GATT_WATCH_CHARACTERISTIC
|| service_function == BT_GATT_ACQUIRE_WRITE
#endif
- || service_function == BT_AUDIO_SELECT_ROLE
- || service_function == BT_OBEX_SERVER_ACCEPT_CONNECTION)
+ || service_function == BT_AUDIO_SELECT_ROLE)
return TRUE;
else
return FALSE;
}
+static int __bt_bm_request_data(_bt_battery_data_t *latest)
+{
+ int ret = _bt_bm_read_data(latest);
+ if (ret == BLUETOOTH_ERROR_NONE) {
+ BT_DBG("Received data from bluetooth battery monitor: %ld %ld %d %d",
+ latest->session_start_time, latest->session_end_time,
+ latest->session_scan_time, latest->session_connected_time);
+
+ if (latest->atm_list == NULL) {
+ BT_DBG("No app data transaction for this session");
+ return ret;
+ }
+
+ for (GSList *l = latest->atm_list; l != NULL; l = g_slist_next(l)) {
+ _bt_battery_app_data_t *t = (_bt_battery_app_data_t *)(l->data);
+ BT_DBG("%ld %ld %d %d", (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes);
+ }
+ }
+ else
+ BT_ERR("Error encountered");
+ return ret;
+}
+
static void __bt_service_method(GDBusConnection *connection,
const gchar *sender,
const gchar *object_path,
case BT_RESET_ADAPTER:
result = _bt_reset_adapter();
break;
+ case BT_BATTERY_READ_DATA: {
+ _bt_battery_data_t *data = NULL;
+ data = g_malloc0(sizeof(_bt_battery_data_t));
+ result = __bt_bm_request_data(data);
+
+ bt_battery_dbus_data_t dbus_data;
+ memset(&dbus_data, 0, sizeof(bt_battery_dbus_data_t));
+ dbus_data.session_start_time = data->session_start_time;
+ dbus_data.session_end_time = data->session_end_time;
+ dbus_data.session_scan_time = data->session_scan_time;
+ dbus_data.session_connected_time = data->session_connected_time;
+
+ /*Populating app data*/
+ int n = 0;
+ for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) {
+ bt_battery_app_data *t = (bt_battery_app_data *)(l->data);
+ memcpy(&dbus_data.app_data[n], t, sizeof(bt_battery_app_data));
+ n++;
+ }
+ dbus_data.num_app = n;
+ g_array_append_vals(*out_param1, &dbus_data, sizeof(bt_battery_dbus_data_t));
+ g_slist_free(data->atm_list);
+ g_free(data);
+ data = NULL;
+ break;
+ }
case BT_CHECK_ADAPTER: {
int enabled = BT_ADAPTER_DISABLED;
result = _bt_check_adapter(&enabled);
result = _bt_set_authorization(&address, authorize);
break;
}
+ case BT_SET_LE_PRIVACY: {
+ gboolean set_privacy;
+ __bt_service_get_parameters(in_param1, &set_privacy,
+ sizeof(gboolean));
+ result = _bt_set_le_privacy(set_privacy);
+ break;
+ }
+ case BT_ADD_WHITE_LIST: {
+ bluetooth_device_address_t address = { {0} };
+ int address_type = 0;
+ bool is_add = true;
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &address_type, sizeof(int));
+ result = _bt_set_white_list(&address, address_type, is_add);
+ break;
+ }
+ case BT_REMOVE_WHITE_LIST: {
+ bluetooth_device_address_t address = { {0} };
+ int address_type = 0;
+ bool is_add = false;
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &address_type, sizeof(int));
+ result = _bt_set_white_list(&address, address_type, is_add);
+ break;
+ }
case BT_IS_DEVICE_CONNECTED: {
bluetooth_device_address_t address = { {0} };
gboolean connected = FALSE;
result = BLUETOOTH_ERROR_NONE;
break;
}
+ case BT_RFCOMM_LISTEN_AND_ACCEPT: {
+ char *uuid;
+ int socket_fd = -1;
+
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+ uuid = (char *)g_variant_get_data(in_param1);
+
+ result = _bt_rfcomm_socket_listen(sender, uuid, true);
+ if (result > 0) {
+ BT_ERR("BT_RFCOMM_LISTEN_AND_ACCEPT success, save context");
+
+ result = BLUETOOTH_ERROR_NONE;
+ _bt_save_invocation_context(context,
+ result, sender, function_name, NULL);
+ } else {
+ g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
+ }
+ break;
+ }
case BT_RFCOMM_LISTEN: {
char *uuid;
int socket_fd = -1;
sender = (char *)g_dbus_method_invocation_get_sender(context);
uuid = (char *)g_variant_get_data(in_param1);
- result = _bt_rfcomm_socket_listen(sender, uuid);
+ result = _bt_rfcomm_socket_listen(sender, uuid, false);
if (result > 0) {
BT_ERR("BT_RFCOMM_LISTEN success, save context");
result = BLUETOOTH_ERROR_NONE;
break;
}
+ case BT_RFCOMM_SEND_RX_DETAILS: {
+ uid_t uid;
+ pid_t pid;
+ int size;
+ __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
+ __bt_service_get_parameters(in_param2, &pid, sizeof(pid_t));
+ __bt_service_get_parameters(in_param3, &size, sizeof(int));
+ BT_DBG("Sending details to bluetooth battery monitor: %ld, %ld, %d", (long int)uid, (long int)pid, size);
+ _bt_bm_add_transaction_details(uid, pid, size, RX_DATA);
+ break;
+ }
+ case BT_RFCOMM_SEND_TX_DETAILS: {
+ uid_t uid;
+ pid_t pid;
+ int size;
+ __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
+ __bt_service_get_parameters(in_param2, &pid, sizeof(pid_t));
+ __bt_service_get_parameters(in_param3, &size, sizeof(int));
+ BT_DBG("Sending details to bluetooth battery monitor: %ld, %ld, %d", (long int)uid, (long int)pid, size);
+ _bt_bm_add_transaction_details(uid, pid, size, TX_DATA);
+ break;
+ }
case BT_AUDIO_SELECT_ROLE: {
bluetooth_audio_role_t role;
result = _bt_avrcp_control_cmd(key_code);
break;
}
+ case BT_AVRCP_HANDLE_CONTROL_TO_DEST: {
+ int key_code;
+ bluetooth_device_address_t address = { { 0 } };
+
+ __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
+ __bt_service_get_parameters(in_param2,
+ &address, sizeof(bluetooth_device_address_t));
+
+ result = _bt_avrcp_control_cmd_to_dest(key_code, &address);
+ break;
+ }
case BT_AVRCP_CONTROL_SET_PROPERTY: {
int type;
unsigned int value;
break;
}
+ case BT_LE_OOB_READ_LOCAL_DATA: {
+ bt_oob_data_t local_oob_data;
+
+ memset(&local_oob_data, 0x00, sizeof(bt_oob_data_t));
+ result = _bt_le_oob_read_local_data(&local_oob_data);
+
+ g_array_append_vals(*out_param1, &local_oob_data,
+ sizeof(bt_oob_data_t));
+
+ break;
+ }
+ case BT_LE_OOB_ADD_REMOTE_DATA: {
+ bluetooth_device_address_t address = { {0} };
+ unsigned short address_type;
+ bt_oob_data_t remote_oob_data;
+
+ __bt_service_get_parameters(in_param1,
+ &address, sizeof(bluetooth_device_address_t));
+ __bt_service_get_parameters(in_param2,
+ &address_type, sizeof(unsigned short));
+ __bt_service_get_parameters(in_param3,
+ &remote_oob_data, sizeof(bt_oob_data_t));
+
+ result = _bt_oob_add_remote_data(&address, address_type, &remote_oob_data);
+
+ break;
+ }
case BT_AVRCP_SET_TRACK_INFO: {
media_metadata_t data;
media_metadata_attributes_t meta_data;
__bt_service_get_parameters(in_param4, &use_reserved_slot,
sizeof(gboolean));
- BT_DBG("bluetooth_advertising_params_t [%f %f %d %d]",
+ BT_DBG("bluetooth_advertising_params_t [%f %f %d %d %d]",
adv_params.interval_min, adv_params.interval_max,
- adv_params.filter_policy, adv_params.type);
+ adv_params.filter_policy, adv_params.type, adv_params.tx_power_level);
result = _bt_set_custom_advertising(app, *adv_handle,
enable, &adv_params, use_reserved_slot);
if (result != BLUETOOTH_ERROR_NONE) {
}
break;
}
+ case BT_SET_LE_STATIC_RANDOM_ADDRESS: {
+ gboolean is_enable;
+
+ __bt_service_get_parameters(in_param1, &is_enable,
+ sizeof(gboolean));
+
+ result = _bt_set_le_static_random_address(is_enable);
+
+ break;
+ }
#ifdef TIZEN_GATT_CLIENT
/* Local Async */
case BT_GATT_CLIENT_REGISTER: {
}
case BT_SET_SCAN_PARAMETERS: {
bluetooth_le_scan_params_t scan_params;
-
__bt_service_get_parameters(in_param1, &scan_params,
sizeof(bluetooth_le_scan_params_t));
+
BT_DBG("bluetooth_le_scan_params_t [%f %f %d]",
scan_params.interval, scan_params.window,
scan_params.type);
- result = _bt_set_scan_parameters(&scan_params);
+
+ result = _bt_prepare_scan_parameters(&scan_params, 0);
+ break;
+ }
+ case BT_SET_SCAN_TYPE: {
+ int scan_type = 0;
+ __bt_service_get_parameters(in_param1, &scan_type, sizeof(int));
+
+ BT_DBG("bluetooth_le_scan_type [%d]", scan_type);
+ result = _bt_prepare_scan_parameters(NULL, scan_type);
break;
}
#ifdef TIZEN_FEATURE_BT_PAN_NAP
BT_DBG("BT_OPP_PUSH_FILES");
int i;
bluetooth_device_address_t address = { {0} };
- bt_file_path_t path;
+ bt_file_path_t *path;
char **file_path;
int file_count;
GArray *param2;
__bt_fill_garray_from_variant(in_param2, param2);
for (i = 0; i < file_count; i++) {
- path = g_array_index(param2, bt_file_path_t, i);
- file_path[i] = g_strdup(path.path);
+ path = &g_array_index(param2, bt_file_path_t, i);
+ file_path[i] = g_strdup(path->path);
}
BT_DBG("_bt_opp_client_push_files");
result = _bt_opp_client_push_files(request_id, context,
case BT_ENABLE_ADAPTER:
{
bt_status_t status;
-
+ _bt_set_adapter_request_state(TRUE);
status = _bt_adapter_get_status();
if (status == BT_ACTIVATING) {
result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
} else {
_bt_adapter_set_status(BT_ACTIVATING);
-
-#if TODO_40 /* Need to add this function */
- _bt_adapter_start_enable_timer();
-#endif
result = BLUETOOTH_ERROR_NONE;
}
case BT_DISABLE_ADAPTER:
{
bt_status_t status;
-
status = _bt_adapter_get_status();
if (status == BT_DEACTIVATING) {
BT_DBG("Disabling in progress");
case BT_ENABLE_ADAPTER_LE:
{
bt_le_status_t le_status;
-
+ _bt_set_le_request_state(TRUE);
le_status = _bt_adapter_get_le_status();
if (le_status == BT_LE_ACTIVATING) {
BT_DBG("Enabling in progress");
result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
} else {
_bt_adapter_set_le_status(BT_LE_ACTIVATING);
-
-#if TODO_40 /* Need to add this function */
- _bt_adapter_start_le_enable_timer();
-#endif
result = BLUETOOTH_ERROR_NONE;
}
case BT_CANCEL_DISCOVERY:
case BT_OOB_ADD_REMOTE_DATA:
case BT_OOB_REMOVE_REMOTE_DATA:
+ case BT_OOB_READ_LOCAL_DATA:
case BT_SET_ADVERTISING:
case BT_SET_CUSTOM_ADVERTISING:
case BT_SET_ADVERTISING_PARAMETERS:
case BT_START_LE_DISCOVERY:
case BT_STOP_LE_DISCOVERY:
case BT_SET_SCAN_PARAMETERS:
+ case BT_SET_SCAN_TYPE:
case BT_BOND_DEVICE:
case BT_CANCEL_BONDING:
case BT_GATT_SERVER_UPDATE_VALUE:
case BT_GATT_SERVER_DEREGISTER:
#endif
+ case BT_REQ_ATT_MTU:
case BT_PBAP_CONNECT:
case BT_PBAP_DISCONNECT:
case BT_PBAP_GET_PHONEBOOK_SIZE:
case BT_PBAP_PULL_VCARD:
case BT_PBAP_PHONEBOOK_SEARCH:
+ case BT_RFCOMM_LISTEN_AND_ACCEPT:
+
ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
BT_PRIVILEGE_PUBLIC);
}
break;
+ case BT_RFCOMM_SEND_RX_DETAILS:
+ case BT_RFCOMM_SEND_TX_DETAILS:
case BT_ENABLE_ADAPTER:
case BT_DISABLE_ADAPTER:
case BT_RESET_ADAPTER:
case BT_RECOVER_ADAPTER:
+ case BT_BATTERY_READ_DATA:
case BT_ENABLE_ADAPTER_LE:
case BT_DISABLE_ADAPTER_LE:
case BT_SET_CONNECTABLE:
case BT_AVRCP_CONTROL_GET_PROPERTY:
case BT_AVRCP_GET_TRACK_INFO:
case BT_AVRCP_TRANSPORT_SET_PROPERTY:
-
+ case BT_AVRCP_HANDLE_CONTROL_TO_DEST:
case BT_SET_CONTENT_PROTECT:
case BT_BOND_DEVICE_BY_TYPE:
case BT_SET_LE_STATIC_RANDOM_ADDRESS:
case BT_LE_CONN_UPDATE:
case BT_UPDATE_LE_CONNECTION_MODE:
- case BT_REQ_ATT_MTU:
case BT_GET_DEVICE_IDA:
case BT_LE_READ_MAXIMUM_DATA_LENGTH:
case BT_LE_WRITE_HOST_SUGGESTED_DATA_LENGTH:
case BT_LE_READ_HOST_SUGGESTED_DATA_LENGTH:
case BT_LE_SET_DATA_LENGTH:
-
- case BT_GET_ATT_MTU:
+ case BT_LE_OOB_READ_LOCAL_DATA:
+ case BT_LE_OOB_ADD_REMOTE_DATA:
case BT_LE_IPSP_INIT:
case BT_LE_IPSP_DEINIT:
case BT_GET_PROFILE_TRUSTED:
case BT_GET_SPEAKER_GAIN:
case BT_SET_SPEAKER_GAIN:
- case BT_OOB_READ_LOCAL_DATA:
case BT_RFCOMM_CLIENT_IS_CONNECTED:
case BT_RFCOMM_IS_UUID_AVAILABLE:
case BT_GET_ADVERTISING_DATA:
case BT_UNREGISTER_SCAN_FILTER:
case BT_UNREGISTER_ALL_SCAN_FILTERS:
case BT_IS_SCAN_FILTER_SUPPORTED:
+ case BT_GET_ATT_MTU:
case BT_OBEX_SERVER_ALLOCATE:
case BT_OBEX_SERVER_DEALLOCATE: