#include "bt-service-avrcp-tg.h"
#include "bt-service-avrcp-ctrl.h"
#include "bt-service-hf.h"
+#include "bt-service-hf-client.h"
+#include "oal-hf-client.h"
#ifdef TIZEN_SUPPORT_DUAL_HF
#define VCONF_KEY_BT_HOST_BT_MAC_ADDR "db/wms/host_bt_mac"
return FALSE;
}
+
+gboolean _bt_is_headset_address_type_connected(int type, const char *address)
+{
+ GList *node;
+
+ node = g_list_first(g_connected_list);
+ while (node != NULL) {
+ bt_connected_headset_data_t *connected_device = node->data;
+
+ if (connected_device && (connected_device->type & type)) {
+ if (memcmp(connected_device->device_address, address, 19) == 0)
+ return TRUE;
+ }
+
+ node = g_list_next(node);
+ }
+ return FALSE;
+}
+
static void __bt_set_headset_disconnection_type(const char *address)
{
bt_connected_headset_data_t *connected_device;
case BT_AUDIO_A2DP_SOURCE:
return _bt_a2dp_connect_remote_source(address);
break;
+ case BT_AUDIO_AG:
+ return _bt_connect_remote_ag(address);
default:
BT_ERR("Unknown role");
return BLUETOOTH_ERROR_INTERNAL;
//_bt_headset_set_local_connection(TRUE);
/* Add data to the connected list */
_bt_add_headset_to_list(type, BT_STATE_CONNECTING, addr);
+ BT_PERMANENT_LOG("Connect %d", type);
} else {
BT_ERR("Profile [%d] connect failed!!", type);
}
/* Update device status in connected list */
_bt_add_headset_to_list(type, BT_STATE_DISCONNECTING, addr);
+ BT_PERMANENT_LOG("Disconnect %d", type);
} else {
BT_ERR("Profile [%d] connect failed!!", type);
}
break;
}
case BT_HFP_MODULE: {
- return BLUETOOTH_ERROR_NOT_SUPPORT;
+ status = hf_client_enable();
+ if (OAL_STATUS_SUCCESS != status) {
+ BT_ERR("Failed to initialize Bluetooth HFP client Profile, status: %d", status);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+ /* Register Audio module event handler */
+ _bt_service_register_event_handler_callback(module, _bt_hf_client_event_handler);
+ break;
}
case BT_AG_MODULE: {
status = hfp_enable(1);
goto fail;
}
+ BT_PERMANENT_LOG("Connect %d", info->type);
/* If multiple profiles are supported, queue pending connection info */
if ((info->is_hfp_supported && info->is_a2dp_sink_supported) ||
(info->is_hfp_supported && info->is_a2dp_src_supported)) {
}
} else if (ret == BLUETOOTH_ERROR_NONE) {
BT_INFO("Waiting for disconnection...");
- /*
- * It means, we dont need pending connect info as only A2DP (Src/Snk) or
- * HFP will be connected for present device, so lets free pending info.
- */
- g_free(info->address);
- g_free(info);
+
+ if ((info->is_hfp_supported && info->is_a2dp_sink_supported) ||
+ (info->is_hfp_supported && info->is_a2dp_src_supported)) {
+ BT_INFO("[%s] Supports HFP and (A2DP_Src or, A2DP_Snk)", info->address);
+ pending_audio_conn_list = g_slist_append(pending_audio_conn_list, (gpointer)info);
+ } else {
+ BT_INFO("[%s] Supports one profile only", info->address);
+ /*
+ * It means, we dont need pending connect info as only A2DP (Src/Snk) or
+ * HFP will be connected for present device, so lets free pending info.
+ */
+ g_free(info->address);
+ g_free(info);
+ }
}
BT_DBG("-");
BT_DBG("+");
/* Get method invocation context */
- for (l = _bt_get_invocation_list(); l != NULL; l = g_slist_next(l)) {
+ for (l = _bt_get_invocation_list(); l != NULL; ) {
req_info = l->data;
+ l = g_slist_next(l);
if (req_info == NULL || req_info->service_function != service_function)
continue;
BT_INFO("role: %s", (role == BLUETOOTH_A2DP_SINK) ? "AUDIO_SINK" : "AUDIO_SOURCE");
curr_audio_role = role;
}
+
+int _bt_hf_connect(bluetooth_device_address_t *device_address)
+{
+ int result = BLUETOOTH_ERROR_NONE;
+ BT_INFO("+");
+
+ result = _bt_connect_remote_ag(device_address);
+ if (result != BLUETOOTH_ERROR_NONE)
+ BT_ERR("HF Client connect to remote AG failed");
+ else
+ BT_PERMANENT_LOG("Connect AG");
+
+ return result;
+}
+
+int _bt_hf_disconnect(bluetooth_device_address_t *device_address)
+{
+ int result = BLUETOOTH_ERROR_NONE;
+ BT_INFO("+");
+
+ result = _bt_disconnect_remote_ag(device_address);
+ if (result != BLUETOOTH_ERROR_NONE)
+ BT_ERR("HF Client disconnect to remote AG failed");
+ else
+ BT_PERMANENT_LOG("Disconnect AG");
+
+ return result;
+}