bt_connected_headset_data_t *device;
GList *node;
- BT_DBG("_bt_add_headset_to_list \n");
+ BT_INFO("_bt_add_headset_to_list: Address [%s] Profile Type [%d] Connect status [%d]\n",
+ address, type, status);
node = g_list_first(g_connected_list);
while (node != NULL) {
return BLUETOOTH_ERROR_NONE;
}
+int _bt_audio_is_profile_connection_in_progress(int service_function,
+ bluetooth_device_address_t *address)
+{
+ invocation_info_t *req_info;
+ char addr[BT_ADDRESS_STRING_SIZE] = { 0 };
+
+ BT_INFO("+");
+
+ if (!address)
+ return BLUETOOTH_ERROR_INTERNAL;
+
+ _bt_convert_addr_type_to_string(addr,
+ (unsigned char *)address->addr);
+
+ /* Check if any application has posted same Connection Request already */
+ req_info = _bt_get_request_info_data(service_function, (char*) addr);
+ if (!req_info) {
+ BT_INFO("Connection can proceed");
+ return BLUETOOTH_ERROR_NONE;
+ }
+
+ BT_INFO("Got Pending Audio Profile Connect Request[%d] for addr[%s]",
+ service_function, addr);
+
+ return BLUETOOTH_ERROR_IN_PROGRESS;
+}
+
static int __bt_is_headset_connected(int current_conn_type, const char *address)
{
gboolean connected = FALSE;
/* Check if any other headset is connected */
GList *node = NULL;
- BT_DBG("Checking if any Headset connected or not: current device [%s] current audio type [%s]",
+ BT_INFO("Checking if any Headset connected or not: current device [%s] current audio type [%s]",
address, __convert_audio_type_to_string(current_conn_type));
node = g_list_first(g_connected_list);
while (node != NULL) {
connected_device = node->data;
- BT_DBG("A Device is already connected found in list [%s] audio type [%s]",
+ BT_INFO("A Device is already connected found in list [%s] audio type [%s]",
connected_device->device_address, __convert_audio_type_to_string(connected_device->type));
if ((connected_device->type & current_conn_type)) {
g_strlcpy(connected_address, connected_device->device_address,
}
if (result == BLUETOOTH_ERROR_NONE) {
+ BT_INFO("Set Profile Connecting state");
_bt_headset_set_local_connection(TRUE);
/* Add data to the connected list */
_bt_add_headset_to_list(type, BT_STATE_CONNECTING, addr);
if (ret == BLUETOOTH_ERROR_NONE) {
BT_INFO("Waiting for disconnection...");
} else if (ret == BLUETOOTH_ERROR_NOT_CONNECTED) {
+ BT_INFO("Proceed for connection: Type [%d] Address [%s]",
+ type, address);
ret = __bt_process_audio_profile_connect(type, device_address);
if (ret != BLUETOOTH_ERROR_NONE) {
BT_ERR("Failed with %d", ret);
__bt_service_get_parameters(in_param1,
&address, sizeof(bluetooth_device_address_t));
- result = _bt_audio_connect(BT_AUDIO_A2DP, &address);
+ result = _bt_audio_is_profile_connection_in_progress(BT_AV_CONNECT, &address);
+
+ if (result == BLUETOOTH_ERROR_NONE)
+ result = _bt_audio_connect(BT_AUDIO_A2DP, &address);
if (result != BLUETOOTH_ERROR_NONE) {
+ BT_ERR("AV Connect Request has failed to execute");
char addr[BT_ADDRESS_STRING_SIZE];
_bt_convert_addr_type_to_string(addr, address.addr);
g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
__bt_service_get_parameters(in_param1,
&address, sizeof(bluetooth_device_address_t));
- result = _bt_audio_connect(BT_AUDIO_ALL, &address);
+ result = _bt_audio_is_profile_connection_in_progress(BT_AUDIO_CONNECT, &address);
+
+ if (result == BLUETOOTH_ERROR_NONE)
+ result = _bt_audio_connect(BT_AUDIO_ALL, &address);
if (result != BLUETOOTH_ERROR_NONE) {
+ BT_ERR("Audio All Connect Request has failed to execute");
char addr[BT_ADDRESS_STRING_SIZE];
_bt_convert_addr_type_to_string(addr, address.addr);
g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
__bt_service_get_parameters(in_param1,
&address, sizeof(bluetooth_device_address_t));
- result = _bt_audio_connect(BT_AUDIO_HSP, &address);
+ result = _bt_audio_is_profile_connection_in_progress(BT_AG_CONNECT, &address);
+
+ if (result == BLUETOOTH_ERROR_NONE)
+ result = _bt_audio_connect(BT_AUDIO_HSP, &address);
if (result != BLUETOOTH_ERROR_NONE) {
+ BT_ERR("AG Connect Request has failed to execute");
char addr[BT_ADDRESS_STRING_SIZE];
_bt_convert_addr_type_to_string(addr, address.addr);
g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
__bt_service_get_parameters(in_param1,
&address, sizeof(bluetooth_device_address_t));
- result = _bt_audio_connect(BT_AUDIO_A2DP_SOURCE, &address);
+ result = _bt_audio_is_profile_connection_in_progress(BT_AV_SOURCE_CONNECT,
+ &address);
+
+ if (result == BLUETOOTH_ERROR_NONE)
+ result = _bt_audio_connect(BT_AUDIO_A2DP_SOURCE, &address);
+
if (result != BLUETOOTH_ERROR_NONE) {
+ BT_ERR("A2DP Source Connect Request has failed to execute");
char addr[BT_ADDRESS_STRING_SIZE];
_bt_convert_addr_type_to_string(addr, address.addr);
g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
__bt_service_get_parameters(in_param1,
&address, sizeof(bluetooth_device_address_t));
- result = _bt_hf_connect(&address);
+ result = _bt_audio_is_profile_connection_in_progress(BT_HF_CONNECT,
+ &address);
+
+ if (result == BLUETOOTH_ERROR_NONE)
+ result = _bt_hf_connect(&address);
+
if (result != BLUETOOTH_ERROR_NONE) {
+ BT_ERR("HF Connect Request has failed to execute");
char addr[BT_ADDRESS_STRING_SIZE];
_bt_convert_addr_type_to_string(addr, address.addr);
g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
__bt_service_get_parameters(in_param1,
&address, sizeof(bluetooth_device_address_t));
- result = _bt_audio_connect(BT_AVRCP_TARGET, &address);
+ result = _bt_audio_is_profile_connection_in_progress(BT_AVRCP_TARGET_CONNECT,
+ &address);
+
+ if (result == BLUETOOTH_ERROR_NONE)
+ result = _bt_audio_connect(BT_AVRCP_TARGET, &address);
+
if (result != BLUETOOTH_ERROR_NONE) {
+ BT_ERR("AVRCP Target Connect Request has failed to execute");
char addr[BT_ADDRESS_STRING_SIZE];
_bt_convert_addr_type_to_string(addr, address.addr);
g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
__bt_service_get_parameters(in_param1,
&address, sizeof(bluetooth_device_address_t));
- result = _bt_audio_connect(BT_AVRCP, &address);
+ result = _bt_audio_is_profile_connection_in_progress(BT_AVRCP_CONTROL_CONNECT,
+ &address);
+
+ if (result == BLUETOOTH_ERROR_NONE)
+ result = _bt_audio_connect(BT_AVRCP, &address);
+
if (result != BLUETOOTH_ERROR_NONE) {
+ BT_ERR("AVRCP Control Connect Request has failed to execute");
char addr[BT_ADDRESS_STRING_SIZE];
_bt_convert_addr_type_to_string(addr, address.addr);
g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);