I have since gotten the wiced_bt_rfcomm_init() function and have been able to compile and load the code from the hci_audio_gateway to the device. When using client control I am able to find a device and connect, but when I attempt to have the AG connect it fails. Looking at the BTspy it seems that the AG is not working properly. Here are a few lines:
18:04:28.481 1 hci_control_ag_sdp_cback status:0x0
18:04:28.481 1 Looking for HFP service
18:04:28.481 1 hci_control_ag_sdp_find_attr( ) - could not find AG service
18:04:28.481 1 hci_control_ag_rfcomm_start_server: rfcomm_create Res: 0x0 Port: 0x0006
18:04:28.481 1 hci_control_send_ag_event: Sending Event: 3585 to UART
18:04:28.481 [Handle: 1] Rcvd HCI_CONTROL_AG_EVENT_OPEN BDA: 00:01:00:20:fb:b8 Status: 1
18:04:28.497 INVALID HCI_INX 65525 FOR HCI_HANDLE 0x0000. channel ID = 0x0001 controller_id 1
18:04:28.497 RCVD  ACL Data from HCI. Handle: 0x00b Boundary: 2 Brdcst: 0 Len: 12 Data: 0x08 0x00 0x01 ...
18:04:28.497 0000: 08 00 01 00 07 06 04 00 49 00 4d 00 ........I.M.
18:04:28.497 RCVD  Event from HCI. Name: HCI_Number_Of_Completed_Packets (Hex Code: 0x13 Param Len: 5)
18:04:28.497 0 : 11 (0x000b) - 2
18:04:31.498 SENT  Command to HCI. Name: HCI_Disconnect (Hex Code: 0x0406 Param Len: 3)
18:04:31.498 Connection Handle : 11 (0x000b)
18:04:31.498 Reason : 19 (0x13)
18:04:31.498 RCVD  Event from HCI. Name: HCI_Command_Status (Hex Code: 0x0f Param Len: 4)
18:04:31.498 Status : Success (0x00)
18:04:31.498 Num HCI Cmd Packets : 1 (0x01)
18:04:31.498 Cmd Code : 0x0406 (HCI_Disconnect)
18:04:31.639 RCVD  Event from HCI. Name: HCI_Disconnection_Complete (Hex Code: 0x05 Param Len: 4)
18:04:31.639 Status : Success (0x00)
18:04:31.639 Connection Handle : 11 (0x000b)
18:04:31.639 Reason : 22 (0x16)
18:04:31.639 Connection Terminated by Local Host
1 of 2 people found this helpful
Good to know that you were able to compile the code.!
I would suggest you to go through /20719-B1_Bluetooth/apps/demo/hci_audio_gateway for implementation of the profile and check if you are missing something in your code. Looks like some invalid HCI command is being sent and soon disconnection is happening.
I actually didn't rewrite any code, I simply took the files from github, changed the modus.mk file to allow my device to compile, and then built and downloaded it to the board. I noticed that the help in the client control for the ag suggests that the peer device to connect to should be a "headset, speaker, car-kit supporting hands-free profile". This suggests that the device is not supposed to be the phone which would receive the commands? In which case the AG is setup for the device to act as the cellular receiver, rather than the command initiator. Is this correct? This would not seem to fit the role so I would assume this is just improperly documented/recommended.
I attempted to connect to bluetooth headphones with hfp and the connection was allowed, although audio connection was not. This was one step closer than connecting to a cellphone, but obviously still short of the mark. Looking at the BT spy, I see that there is a line which says
10:49:42.785 1 hci_control_send_ag_event: Sending Event: 3585 to UART
10:53:32.629 Connect to a peer device supporting the HF profile
10:57:31.242 SENT  Command to HCI. Name: HCI_IO_Capability_Request_Reply (Hex Code: 0x042b Param Len: 9)
10:57:31.242 BD_ADDR of remote : 40-4e-36-3d-67-f5
10:57:31.242 IO Capability : 0x03 [NoInputNoOutput]
10:57:31.242 OOB Data Present Flag : 0 (0x00)
10:57:31.242 MITM Protection Flag : 4 (0x04)(GB no)
Does the IO capability of NoInputNoOutput mean that it is unable to work in this state? This is a cellphone which has been used plenty with other embedded bluetooth hfp so it should work appropriately if given the correct setup.
Let me know if you have a recommendations!
1 of 1 people found this helpful
The IO capability of the device is defined in the application using event BTM_PAIRING_IO_CAPABILITIES_BR_EDR_REQUEST_EVT and BTM_PAIRING_IO_CAPABILITIES_BLE_REQUEST_EVT. Here BTM_IO_CAPABILITIES_NONE means no input, no output functionality.
This should not be the reason for non-working of code.
Can you send me the link from where you ported this example code so that I can try testing it?
Hmm okay good to know. Here is a link to a github directory where I simply copied the entire folder over.
It includes the entire folder, with the included libraries in the event any of those are the problem. The main application file is the empty_wiced_bt.c file and it contains the examples main code from file hci_control.c
Let me know how your test goes!