_bt_convert_addr_type_to_string(remote_address, conn_info->dev_info.device_address.addr);
if (p_connection_list == NULL) {
BT_INFO("None of device connected and this hasbeen triggered");
+ g_free(conn_info);
return FALSE;
}
if (conn_info->connection_type == BT_AUDIO_A2DP) {
if (list == NULL) {
BT_INFO("Head Set didn't initiated a2dp connection");
BT_INFO("local device initiating A2DP connection");
+
_bt_audio_connect(0, BT_AUDIO_A2DP,
&conn_info->dev_info.device_address, NULL);
} else {
if (list == NULL) {
BT_INFO("Headset didn't initiated HFP connection");
BT_INFO("local device intiating HFP Connection");
+
_bt_audio_connect(0, BT_AUDIO_HSP,
&conn_info->dev_info.device_address, NULL);
} else {
void _bt_get_bluetooth_device_info(char *remote_address, bluetooth_device_info_t *device)
{
GArray *dev_list = NULL;
- int size,i=0;
- bluetooth_device_info_t info;
+ int size = 0;
+ int i = 0;
+ bluetooth_device_info_t *info;
char bond_address[BT_ADDRESS_STRING_SIZE] = { 0 };
- dev_list = g_array_new (FALSE, FALSE, sizeof(gchar));
+
if (device == NULL)
return;
+
+ dev_list = g_array_new(FALSE, FALSE, sizeof(gchar));
+
_bt_get_bonded_devices(&dev_list);
size = (dev_list->len) / sizeof(bluetooth_device_info_t);
- for (i=0; i < size; i++) {
- info = g_array_index(dev_list, bluetooth_device_info_t, i);
- _bt_convert_addr_type_to_string(bond_address, info.device_address.addr);
+ for (i = 0; i < size; i++) {
+ info = &g_array_index(dev_list, bluetooth_device_info_t, i);
+ _bt_convert_addr_type_to_string(bond_address, info->device_address.addr);
if (strcmp(bond_address, remote_address) == 0) {
BT_INFO("Match found");
- memcpy(device, &info, sizeof(bluetooth_device_info_t));
+ memcpy(device, info, sizeof(bluetooth_device_info_t));
g_array_free(dev_list, TRUE);
return;
}
void _bt_start_timer_for_connection(char *remote_address, int connection_type)
{
GArray *dev_list = NULL;
- int size,i=0,j;
- bluetooth_device_info_t info;
+ int size;
+ int i;
+ int j;
+ bluetooth_device_info_t *info;
char bond_address[BT_ADDRESS_STRING_SIZE] = { 0 };
- dev_list = g_array_new (FALSE, FALSE, sizeof(gchar));
+ dev_list = g_array_new(FALSE, FALSE, sizeof(gchar));
_bt_get_bonded_devices(&dev_list);
size = (dev_list->len) / sizeof(bluetooth_device_info_t);
- for (i=0; i < size; i++) {
- info = g_array_index(dev_list, bluetooth_device_info_t, i);
+ for (i = 0; i < size; i++) {
+ info = &g_array_index(dev_list, bluetooth_device_info_t, i);
j = 0;
_bt_convert_addr_type_to_string(bond_address,
- info.device_address.addr);
+ info->device_address.addr);
if (strcmp(bond_address, remote_address) != 0)
continue;
BT_INFO("Device address Matched");
- while (j != info.service_index) {
- BT_INFO("UUID %s", info.uuids[j]);
+ while (j != info->service_index) {
+ BT_INFO("UUID %s", info->uuids[j]);
if (connection_type == BT_AUDIO_A2DP) {
- if (strcmp(info.uuids[j], A2DP_SINK_UUID) == 0) {
+ if (strcmp(info->uuids[j], A2DP_SINK_UUID) == 0) {
BT_INFO("Remote Device has A2DP Sink Support start timer");
- _bt_headset_add_timer_function(BT_AUDIO_A2DP, &info);
+ _bt_headset_add_timer_function(BT_AUDIO_A2DP, info);
goto end;
}
} else {
- if (strcmp(info.uuids[j], HFP_HS_UUID) == 0) {
+ if (strcmp(info->uuids[j], HFP_HS_UUID) == 0) {
BT_INFO("Remote Device has HFP Sink Support start timer");
- _bt_headset_add_timer_function(BT_AUDIO_HSP, &info);
+ _bt_headset_add_timer_function(BT_AUDIO_HSP, info);
goto end;
}
}
void __bt_connection_manager_set_state(char *remote_address, int event)
{
- bt_connection_node_info_t *info = g_new0(bt_connection_node_info_t, 1);
+ bt_connection_node_info_t *info;
char bond_address[BT_ADDRESS_STRING_SIZE] = { 0 };
if (event == BLUETOOTH_EVENT_AG_CONNECTED) {
+ info = g_new0(bt_connection_node_info_t, 1);
info->state = BLUETOOTH_HFP_CONNECTED;
_bt_get_bluetooth_device_info(remote_address, &info->dev_info);
_bt_convert_addr_type_to_string(bond_address,
info->dev_info.device_address.addr);
BT_INFO("Adding HFP Connected device to list");
p_connection_list = g_list_append(p_connection_list, info);
- }
- else if (event == BLUETOOTH_EVENT_AG_DISCONNECTED) {
+ } else if (event == BLUETOOTH_EVENT_AG_DISCONNECTED) {
/* Delete coresponding node */
BT_INFO("Deleting HFP Connected device from list");
GList *list = NULL;
p_connection_list = g_list_remove(p_connection_list, h_conn);
g_free(h_conn);
} else if (event == BLUETOOTH_EVENT_AV_CONNECTED) {
+ info = g_new0(bt_connection_node_info_t, 1);
info->state = BLUETOOTH_A2DP_CONNECTED;
_bt_get_bluetooth_device_info(remote_address, &info->dev_info);
_bt_convert_addr_type_to_string(bond_address,