Hi,
I am trying to convert Galaxy Nexus device into a headset. I was able to successfully send/receive commands to perform Handsfree actions like Answer call, end call, etc with the connected phone.
But only thing that's missing is the Voice. I tried connecting it to SCO via Socket but I do not receive any audio data.
I am unable to figure out if the Bluetooth hardware supports routing audio to speaker or not.
This is my audio.conf file:
# Configuration file for the audio service # This section contains options which are not specific to any # particular interface # NOTE: Enable=Sink means that bluetoothd exposes Sink interface for remote # devices, and the local device is a Source [General] Enable=Media,Control,Source,Gateway,Headset #Control,Headset,Gateway,Source,Control #Disable=Headset,Gateway,Source # Switch to master role for incoming connections (defaults to true) Master=true # If we want to disable support for specific services # Defaults to supporting all implemented services #Disable=Control,Source # SCO routing. Either PCM or HCI (in which case audio is routed to/from ALSA) # Defaults to HCI #SCORouting=PCM # Automatically connect both A2DP and HFP/HSP profiles for incoming # connections. Some headsets that support both profiles will only connect the # other one automatically so the default setting of true is usually a good # idea. AutoConnect=true # Headset interface specific options (i.e. options which affect how the audio # service interacts with remote headset devices) [Headset] # Set to true to support HFP (in addition to HSP only which is the default) # Defaults to false HFP=true # Maximum number of connected HSP/HFP devices per adapter. Defaults to 1 MaxConnections=10 # Set to true to enable use of fast connectable mode (faster page scanning) # for HFP when incomming call starts. Default settings are restored after # call is answered or rejected. Page scan interval is much shorter and page # scan type changed to interlaced. Such allows faster connection initiated # by a headset. FastConnectable=false # Just an example of potential config options for the other interfaces [A2DP] SBCSources=1 MPEG12Sources=0 [AVRCP] InputDeviceName=AVRCP MetaDataEnable=true #[WBspeech] #for wide band speech hci commands arguments #WBSEnable = false #I2sEnable = 0x01 #IsMaster = 0x00 #ClockRate = 0x02 #PcmInterfaceRate = 0x00
I tried two solutions:
1. Directly connect to SCO socket using the Low level socket APIs. I am able to establish connection to SCO Socket but it's not returning any data if I do read/write on that Socket. I establish connection only after picking up a phone call with the devices connected already.
2. Use DBuS APIs for BlueZ and perform tasks as mentioned in Slide #7. http://download.tizen.org/misc/media/conference2012/wednesday/bayview/2012-05-09-0900-0940-bluez-_plugging_the_unpluggable.pdf
But I am unable to access any SCO audio data.
Hcidump shows that my Headset emulated Android phone is able to receive the data, but how can I capture this data and route it to speaker ??
shell@android:/ # hcidump
HCI sniffer - Bluetooth packet analyzer ver 2.0
device: hci0 snap_len: 1028 filter: 0xffffffff
< HCI Command: Setup Synchronous Connection (0x01|0x0028) plen 17
handle 12 voice setting 0x0060 ptype 0x003f
> HCI Event: Command Status (0x0f) plen 4
Setup Synchronous Connection (0x01|0x0028) status 0x00 ncmd 1
> HCI Event: Synchronous Connect Complete (0x2c) plen 17
status 0x00 handle 6 bdaddr 5C:3C:27:BA:4C:DC type eSCO
Air mode: CVSD
< SCO data: handle 6 flags 0x00 dlen 22
< SCO data: handle 6 flags 0x00 dlen 22
< SCO data: handle 6 flags 0x00 dlen 22
< SCO data: handle 6 flags 0x00 dlen 22
< SCO data: handle 6 flags 0x00 dlen 22
< SCO data: handle 6 flags 0x00 dlen 22
< SCO data: handle 6 flags 0x00 dlen 22
< SCO data: handle 6 flags 0x00 dlen 22
< SCO data: handle 6 flags 0x00 dlen 22
< SCO data: handle 6 flags 0x00 dlen 22
< SCO data: handle 6 flags 0x00 dlen 22
< SCO data: handle 6 flags 0x00 dlen 22
< SCO data: handle 6 flags 0x00 dlen 22
< ACL data: handle 12 flags 0x00 dlen 16
L2CAP(d): cid 0x0041 len 12 [psm 0]
< SCO data: handle 6 flags 0x00 dlen 22
> ACL data: handle 12 flags 0x02 dlen 14
L2CAP(d): cid 0x0041 len 10 [psm 0]
< SCO data: handle 6 flags 0x00 dlen 22
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 1
< SCO data: handle 6 flags 0x00 dlen 22
< SCO data: handle 6 flags 0x00 dlen 22
< SCO data: handle 6 flags 0x00 dlen 22
< SCO data: handle 6 flags 0x00 dlen 22
> HCI Event: Disconn Complete (0x05) plen 4
status 0x00 handle 6 reason 0x13
Reason: Remote User Terminated Connection
> HCI Event: Disconn Complete (0x05) plen 4
status 0x00 handle 12 reason 0x13
Reason: Remote User Terminated Connection