NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

CC256x STM32 TI Bluetooth Stack HFPDemo App

From Texas Instruments Wiki
Jump to: navigation, search

Return to CC256x MSP432 TI’s Bluetooth stack Basic Demo APPS

Return to CC256x STM32F4 TI’s Bluetooth stack Basic Demo APPS

Demo Overview[edit]

NoteNote: The same instructions can be used to run this demo on the MSP432 Platform.

NoteNote: An external codec MUST be connected to the CC256x I2S/PCM interface to play and record audio.


The Hands-free profile allows the user to demonstrate the use of Hands-free profile on embedded device. The Hands-free profile is used to connect a headset or speakerphone with a mobile device to provide remote control and voice connections. The Hands-free profile supports two roles, Hands-free and Audio Gateway. This document demonstrates how to use the Hands-free role of the profile. The provided sample application can be connected to two HFP Audio Gateways simultaneously, but audio can be heard just from one of them.

It is recommended that the user visits the kit setup Getting Started Guide for MSP432 or Getting Started Guide for STM32F4 pages before trying the application described on this page.

Running the Bluetooth Code[edit]

Once the code is flashed, connect the board to a PC using a miniUSB or microUSB cable. Once connected, wait for the driver to install. It will show up as XDS110 Class Application/User UART (COM x) for MSP432 under Ports (COM & LPT) in the Device manager. Attach a Terminal program like PuTTY to the serial port x for the board. The serial parameters to use are 115200 Baud, 8, n, 1. Once connected, reset the device and you should see the stack getting initialized on the terminal and the help screen will be displayed, which shows all of the commands.


Demo Application[edit]

This section provides a description of how to use the demo application to connect smart phone over Bluetooth HFP profile, the same for the second smart phone. Bluetooth HFP is a simple Client-Server connection process with one side, the Client, operating in the Audio-Gateway role and the other, the Server, operating in the Hands-free role. We will setup the boards as a Hands-free Server and use an android phone as the Client. Once connected, we can use the STM3240G-EVAL board as headset, with audio connected to the earphone jack.


Server setup on the demo application[edit]

a) Perform the steps mentioned earlier in Running the Bluetooth Code section to initialize the application.

StartPrint2.png

b) Optional: Give a name for the STM3240G-EVAL board by issuing the SetLocalName command. In our example we give it a name of hfpserver.

NoteNote: The default application name is HFPDemo.

SetNamePrint.png

c) Open a HFPServer using the command: OpenHFServer. Here we use OpenHFServer to open the first port (use this command again in order to open the second port with another port number).

The picture below shoes opening of two HFP Server for two phones.

Open2Servers.png


Client setup and device discovery[edit]

d) Open the bluetooth settings menu on the android phone Settings->Bluetooth. The menu should look similar to the picture below in section e.

e) Hit on search for devices. The phone should begin looking for other bluetooth devices.

Bluetooth Settings

f) The Demo device should appear like shown below in the picture with the given name from section b. or the default name HFPDemo. Click on the device name to begin pairing.

Search

g) After the devices are paired (In legacy pairing the Android will prompt for four digits code and then the terminal prompts for PINCodeResponse that should be answered with PINCodeResponse <Android four digit code>, the device should show connected on the phone side and print Open Service Level Connection Indication on the terminal .

SS1 MSP430 HFP 10.png
HFPconnection.png

h) If only one Server opened from section c. Open the HFP Server for the second phone connection by repeating the same procedure from section c, just change the first command to hfpServer 2.


Hands-free Options[edit]

i) To Manage the audio connection to the headset. We use ManageAudio 0 to release the SCO connection and ManageAudio 1 to Setup the SCO connection. If second phone is connected, add the phone index to the command, Ex) ManageAudio 0 1 to release audio, for phone index 1.

MangeAudio1.png

j) To Answer an Incoming Call use AnswerCall and to hang up a call use HangUpCall. If a second phone is connected append the phone index to the command.
Ex) AnswerCall 1, to answer the call on phone index 1 and HangUpCall 1 to hang-up the call on phone index 1.

AnswerCall.png
HangUpCall.png

k) To place an active call on issue the command PlaceCallOnHold <phone index number>. If only one phone connected, the index can be omitted.

l) To place all active calls or other functionality use the HoldingMultipartyCall command with the parameters:

  0 = Release All Held Calls, 
  1 = Release All Active Calls Accept Waiting Call, 
  2 = Place All Active Calls On Hold Accept The Other, 
  3 = Add A Held Call To Conversation, 
  4 = Connect Two Calls And Disconnect, 
  5 = Release Specified Call Index, 
  6 = Private Consultation Mode.

m) Use the holdingMultipPhoneCall command as explained:

  - When using only one connection, this function is responsible for sending the HoldingMultipartyCall command to held a waiting Call on the Remote phone. 
  - When using two connection and one connection has a waiting call or a call in hold and an active connection, this function responsible for sending the HoldingMultipartycall
  command allowing the user to change the active call in this phone but, the user can't return to the second phone without releasing one of those calls. 
  - When using two connections, one is in active call and the other is in waiting call or in on hold call, this function responsible for answering and switching between the active call
   (Which phone has the WBS active). CVSD air coding in the voice call can be enabled in the Second line using PlaceCallOnHold (Port ID of the call on hold)

Note: When using PlaceCallOnHold, the switch between the calls is disabled.


n) To Close the HFserver issue the CloseHFServer command with the port number: CloseHFServer 1 for closing Server on channel 1.

CloseServer.png



Application Commands[edit]

TI’s Bluetooth stack is implementation of the upper layers of the Bluetooth protocol stack. TI’s Bluetooth stack provides a robust and flexible software development tool that implements the Bluetooth Protocols and Profiles above the Host Controller Interface (HCI). TI’s Bluetooth stack's Application Programming Interface (API) provides access to the upper-layer protocols and profiles and can interface directly with the Bluetooth chips.

Generic Access Profile Commands[edit]

The Generic Access Profile defines standard procedures related to the discovery and connection of Bluetooth devices. It defines modes of operation that are generic to all devices and allows for procedures which use those modes to decide how a device can be interacted with by other Bluetooth devices. Discoverability, Connectability, Pairability, Bondable Modes, and Security Modes can all be changed using Generic Access Profile procedures. All of these modes affect the interaction two devices may have with one another. GAP also defines the procedures for how bond two Bluetooth devices.

Help (DisplayHelp)[edit]

Description
The DisplayHelp command will display the Command Options menu. Depending on the UI_MODE of the device (Server or Client), different commands will be used in certain situations. The Open and Close commands change their use depending on the mode the device is in.

Parameters
It is not necessary to include parameters when using this command. A parameter will have no effect on the outcome of the Help Menu.

Possible Return Values
The return value is always 0



Inquiry[edit]

Description
The Inquiry command is responsible for performing a General Inquiry for discovering Bluetooth Devices. The command requires that a valid Bluetooth Stack ID exists before running. This command returns zero on a successful call or a negative value if an error occurred during execution. The inquiry will last 10 seconds unless 20 devices (MAX_INQUIRY_RESULTS) are found before that time limit.

Parameters
It is not necessary to include parameters when using this command. A parameter will have no effect on the outcome of the Inquiry.

Possible Return Values
(0) Successful Inquiry Procedure
(-1) BTPS_ERROR_INVALID_PARAMETER
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-57) BTPS_ERROR_DEVICE_HCI_ERROR
(-58) BTPS_ERROR_INVALID_MODE

API Call
GAP_Perform_Inquiry(BluetoothStackID, itGeneralInquiry, 0, 0, 10, MAX_INQUIRY_RESULTS, GAP_Event_Callback, (unsigned long) NULL);

API Prototype
int BTPSAPI GAP_Perform_Inquiry(unsigned int BluetoothStackID, GAP_Inquiry_Type_t GAP_Inquiry_Type, unsigned int MinimumPeriodLength, unsigned int MaximumPeriodLength, unsigned int InquiryLength, unsigned int MaximumResponses, GAP_Event_Callback_t GAP_Event_Callback, unsigned long CallbackParameter);

Description of API
This function is provided to allow a mechanism for starting an Inquiry Scan Procedure. The first parameter to this function is the Bluetooth Protocol Stack of the Bluetooth Device that is to perform the Inquiry. The second parameter is the type of Inquiry to perform. The third and fourth parameters are the Minimum and Maximum Period Lengths which are specified in seconds (only valid in case a Periodic Inquiry is to be performed). The fifth parameter is the Length of Time to perform the Inquiry, specified in seconds. The sixth parameter is the Number of Responses to wait for. The final two parameters represent the Callback Function (and parameter) that is to be called when the specified Inquiry has completed. This function returns zero is successful, or a negative return error code if an Inquiry was unable to be performed. Only ONE Inquiry can be performed at any given time. Calling this function with an outstanding Inquiry is in progress will fail. The caller can call the GAP_Cancel_Inquiry() function to cancel a currently executing Inquiry procedure. The Minimum and Maximum Inquiry Parameters are optional and, if specified, represent the Minimum and Maximum Periodic Inquiry Periods. The called should set BOTH of these values to zero if a simple Inquiry Procedure is to be used (Non-Periodic). If these two parameters are specified, then these two parameters must satisfy the following formula:
MaximumPeriodLength > MinimumPeriodLength > InquiryLength



Pair[edit]

Description
The Pair command is responsible for initiating bonding with a remote Bluetooth Device. The function returns zero on a successful execution and a negative value on all errors. A Bluetooth Stack ID must exist before attempting to pair and the device must not already be connected to any device (including the one it tries to pair with). It is also important to note that the use of the Inquiry command before calling Pair is necessary to connect to a remote device. Both General and Dedicated bonding are supported.

Parameters
The Pair command requires one or two parameters with specific values in order to work successfully. The first parameter is the Inquiry Index of the remote Bluetooth Device. This parameter is always necessary. This can be found after an Inquiry or displayed when the command DisplayInquiryList is used. If the desired remote device does not appear in the list, it cannot be paired with. The second parameter is the bonding type used for the pairing procedure. It is an optional parameter which is only required if General Bonding is desired for the connection. This must be specified as either 0 (for Dedicated Bonding) or 1 (for General Bonding). If only one parameter is given, the Bonding Type will be Dedicated Bonding.

Command Call Examples
"Pair 5 0" Attempts to pair with the remote device at the fifth Inquiry Index using Dedicated Bonding.
"Pair 5" Is the exact same as the above example. If no parameters, the Bonding Type will be Dedicated.
"Pair 8 1" Attempts to pair with the remote device at the eighth Inquiry Index using General Bonding.

Possible Return Values
(0) Successful Pairing
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1) BTPS_ERROR_INVALID_PARAMETER
(-59) BTPS_ERROR_ADDING_CALLBACK_INFORMATION
(-8) BTPS_ERROR_DEVICE_HCI_ERROR

API Call
GAP_Initiate_Bonding(BluetoothStackID, InquiryResultList[(TempParam->Params[0].intParam – 1)], BondingType, GAP_Event_Callback, (unsigned long)0);

API Prototype
int BTPSAPI GAP_Initiate_Bonding(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, GAP_Bonding_Type_t GAP_Bonding_Type, GAP_Event_Callback_t GAP_Event_Callback, unsigned long CallbackParameter);

Description of API
This function is provided to allow a means to Initiate a Bonding Procedure. This function can perform both General and Dedicated Bonding based upon the type of Bonding requested. This function accepts as input, the Bluetooth Protocol Stack ID of the Local Bluetooth device that is perform the Bonding, the Remote Bluetooth address of the Device to Bond with, the type of bonding to perform, and the GAP Event Callback Information that will be used to handle Authentication Events that will follow if this function is successful. If this function is successful, then all further information will be returned through the Registered GAP Event Callback. It should be noted that if this function returns success that it does NOT mean that the Remote Device has successfully Bonded with the Local Device, ONLY that the Remote Device Bonding Process has been started. This function will only succeed if a Physical Connection to the specified Remote Bluetooth device does NOT already exist. This function will connect to the Bluetooth device and begin the Bonding Process. If General Bonding is specified, then the Link is maintained, and will NOT be terminated until the GAP_End_Bonding function has been called. This will allow any higher level initialization that is needed on the same physical link. If Dedicated Bonding is performed, then the Link is terminated automatically when the Authentication Process has completed.Due to the asynchronous nature of this process, the GAP Event Callback that is specified will inform the caller of any Events and/or Data that is part of the Authentication Process. The GAP_Cancel_Bonding function can be called at any time to end the Bonding Process and terminate the link (regardless of which Bonding method is being performed).When using General Bonding, if an L2CAP Connection is established over the Bluetooth Link that was initiated with this function, the Bluetooth Protocol Stack MAY or MAY NOT terminate the Physical Link when (and if) an L2CAP Disconnect Request (or Response) is issued. If this occurs, then calling the GAP_End_Bonding function will have no effect (the GAP_End_Bonding function will return an error code in this case).



EndPairing[edit]

Description
The EndPairing command is responsible for ending a previously initiated bonding session with a remote device. The function returns zero on a successful execution and a negative value on all errors. A Bluetooth Stack ID must exist before attempting to end pairing and the device must already be connected to a remote device. It is also important to note that the use of the Pair and Inquiry commands before calling EndPairing are necessary to disconnect from a remote device.

Parameters
The EndPairing command requires one parameter which is the Inquiry Index of the Remote Bluetooth Device. This value can be found after an Inquiry or displayed when the command DisplayInquiryList is used. It should be the same value as the first parameter used in the Pair command, unless a new Inquiry has been called after pairing. If this is the case, find the Bluetooth Address of the device used in the Pair command.

Command Call Examples
"EndPairing 5" Attempts to end pairing with the remote device at the fifth Inquiry Index.
"EndPairing 8" Attempts to end pairing with the remote device at the eighth Inquiry Index.

Possible Return Values
(0) Successful End Pairing
(-2)BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1)BTPS_ERROR_INVALID_PARAMETER
(-58)BTPS_ERROR_INVALID_MODE
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR

API Call
GAP_End_Bonding(BluetoothStackID, InquiryResultList[(TempParam->Params[0].intParam – 1)]);
API Prototype
int BTPSAPI GAP_Initiate_Bonding(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, GAP_Bonding_Type_t GAP_Bonding_Type, GAP_Event_Callback_t GAP_Event_Callback, unsigned long CallbackParameter);

Description of API
This function is provided to allow a means to terminate a connection that was established via a call to the GAP_Initiate_Bonding function (that specified general bonding as the bonding type to perform). This function has NO effect if the bonding procedure was initiated using dedicated bonding (or the device is already disconnected). This function accepts the Bluetooth device address of the remote Bluetooth device that was specified to be bonded with (general bonding). This function terminates the ACL connection that was established and it guarantees that NO GAP Event Callbacks will be issued to the GAP Event Callback that was specified in the original GAP_Initiate_Bonding function call (if this function returns success).



PINCodeResponse[edit]

Description
The PINCodeResponse command is responsible for issuing a GAP Authentication Response with a PIN Code value specified via the input parameter. This function returns zero on a successful execution and a negative value on all errors. A Bluetooth Stack ID must exist before attempting to call this function. The device must also be in the middle of an on-going Pairing operation that was started by the local device or a remote device.

Parameters
The PINCodeResponse command requires one parameter which is the PIN Code used for authenticating the connection. This is a string value which can be up to 16 digits long. The initiator of the Pairing will see a message displayed during the Pairing Procedure to call this command. A responder will receive a message to call this command after the initiator has put in the PIN Code.

Command Call Examples
"PINCodeResponse 1234" Attempts to set the PIN Code to "1234."
"PINCodeResponse 5921302312564542 Attempts to set the PIN Code to "5921302312564542." This value represents the longest PIN Code value of 16 digits.

Possible Return Values
(0) Successful PIN Code Response
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1) BTPS_ERROR_INVALID_PARAMETER
(-57) BTPS_ERROR_DEVICE_HCI_ERROR

API Call
GAP_Authentication_Response(BluetoothStackID, CurrentRemoteBD_ADDR, &GAP_Authentication_Information);

API Prototype
int BTPSAPI GAP_Authentication_Response(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, GAP_Authentication_Information_t *GAP_Authentication_Information);

Description of API
This function is provided to allow a mechanism for the local device to respond to GAP authentication events. This function is used to specify the authentication information for the specified Bluetooth device. This function accepts as input, the Bluetooth protocol stack ID of the Bluetooth device that has requested the authentication action, and the authentication response information (specified by the caller).



PassKeyResponse[edit]

Description
The PassKeyResponse command is responsible for issuing a GAP Authentication Response with a Pass Key value via the input parameter. This function returns zero on a successful execution and a negative value on all errors. A Bluetooth Stack ID must exist before attempting to call this function. The device must also be in the middle of an on-going Pairing operation that was started by the local device or a remote device.

Parameters
The PassKeyResponse command requires one parameter which is the Pass Key used for authenticating the connection. This is a string value which can be up to 6 digits long (with a value between 0 and 999999).

Command Call Examples
"PassKeyResponse 1234" Attempts to set the Pass Key to "1234."
"PassKeyResponse 999999" Attempts to set the Pass Key to "999999." This value represents the longest Pass Key value of 6 digits.

Possible Return Values
(0) Successful Pass Key Response
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1) BTPS_ERROR_INVALID_PARAMETER
(-57) BTPS_ERROR_DEVICE_HCI_ERROR

API Call
GAP_Authentication_Response(BluetoothStackID, CurrentRemoteBD_ADDR, &GAP_Authentication_Information);

API Prototype
int BTPSAPI GAP_Authentication_Response(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, GAP_Authentication_Information_t *GAP_Authentication_Information);

Description of API
This function is provided to allow a mechanism for the local device to respond to GAP authentication events. This function is used to specify the authentication information for the specified Bluetooth device. This function accepts as input, the Bluetooth protocol stack ID of the Bluetooth device that has requested the authentication action, and the authentication response information (specified by the caller).



UserConfirmationResponse[edit]

Description
The UserConfirmationResponse command is responsible for issuing a GAP Authentication Response with a User Confirmation value via the input parameter. This function returns zero on a successful execution and a negative value on all errors. A Bluetooth Stack ID must exist before attempting to call this function. The device must also be in the middle of an on-going Pairing operation that was started by the local device or a remote device.

Parameters
The UserConfirmationResponse command requires one parameter which is the User Confirmation value used for authenticating the connection. This is an integer value that must be either 1, to confirm the connection, or 0 to NOT confirm the Authentication and stop the Pairing Procedure.
Command Call Examples
"UserConfirmationResponse 0" Attempts to decline the connection made with a remote Bluetooth Device and cancels the Authentication Procedure.
"UserConfirmationResponse 1" Attempts to accept the connection made with a remote Bluetooth Device and confirm the Authentication Procedure.
Possible Return Values
(0) Successful User Confirmation Response
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1) BTPS_ERROR_INVALID_PARAMETER
(-57) BTPS_ERROR_DEVICE_HCI_ERROR

API Call
GAP_Authentication_Response(BluetoothStackID, CurrentRemoteBD_ADDR, &GAP_Authentication_Information);

API Prototype
int BTPSAPI GAP_Authentication_Response(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, GAP_Authentication_Information_t *GAP_Authentication_Information);

Description of API
This function is provided to allow a mechanism for the local device to respond to GAP authentication events. This function is used to specify the authentication information for the specified Bluetooth device. This function accepts as input, the Bluetooth protocol stack ID of the Bluetooth device that has requested the authentication action, and the authentication response information (specified by the caller).



SetDiscoverabilityMode[edit]

Description
The SetDiscoverabilityMode command is responsible for setting the Discoverability Mode of the local device. This command returns zero on successful execution and a negative value on all errors. A Bluetooth Stack ID must exist before attempting to call this function. If setting the device as Limited Discoverable, the device will be discoverable for 60 seconds; a General Discoverable device will always be discoverable.

Parameters
This command requires only one parameter which is an integer value that represents a Discoverability Mode. This value must be specified as 0 (for Non-Discoverable Mode), 1 (for Limited Discoverable Mode), or 2 (for General Discoverable Mode).

Command Call Examples
"SetDiscoverabilityMode 0" Attempts to change the Discoverability Mode of the Local Device to Non-Discoverable.
"SetDiscoverabilityMode 1" Attempts to change the Discoverability Mode of the Local Device to Limited Discoverable.
"SetDiscoverabilityMode 2" Attempts to change the Discoverability Mode of the Local Device to General Discoverable.

Possible Return Values
(0) Successfully Set Discoverability Mode
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-5) BTPS_ERROR_GAP_NOT_INITIALIZED
(-58) BTPS_ERROR_INVALID_MODE
(-57) BTPS_ERROR_DEVICE_HCI_ERROR
(-64) BTPS_ERROR_INTERNAL_ERROR
(-1) BTPS_ERROR_INVALID_PARAMETER

API Call
GAP_Set_Discoverability_Mode(BluetoothStackID, DiscoverabilityMode, (DiscoverabilityMode == dmLimitedDiscoverableMode)?60:0);

API Prototype
int BTPSAPI GAP_Set_Discoverability_Mode(unsigned int BluetoothStackID, GAP_Discoverability_Mode_t GAP_Discoverability_Mode, unsigned int Max_Discoverable_Time);

Description of API
This function is provided to set the discoverability mode of the local Bluetooth device specified by the Bluetooth Protocol Stack that is specified by the Bluetooth protocol stack ID. The second parameter specifies the discoverability mode to place the local Bluetooth device into, and the third parameter species the length of time (in seconds) that the local Bluetooth device is to be placed into the specified discoverable mode (if mode is not specified as non-discoverable). At the end of this time (provided the time is not infinite), the local Bluetooth device will return to non-discoverable mode.



SetConnectabilityMode[edit]

Description
The SetConnectabilityMode command is responsible for setting the Connectability Mode of the local device. This command returns zero on successful execution and a negative value on all errors. A Bluetooth Stack ID must exist before attempting to call this function.

Parameters
This command requires only one parameter which is an integer value that represents a Discoverability Mode. This value must be specified as 0 (for Non-Connectable) or 1 (for Connectable).

Command Call Examples
"SetConnectabilityMode 0" Attempts to set the Local Device's Connectability Mode to Non-Connectable.
"SetConnectabilityMode 1" Attempts to set the Local Device's Connectability Mode to Connectable.

Possible Return Values
(0) Successfully Set Connectability Mode
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-5) BTPS_ERROR_GAP_NOT_INITIALIZED
(-58) BTPS_ERROR_INVALID_MODE
(-57) BTPS_ERROR_DEVICE_HCI_ERROR

API Call
GAP_Set_Connectability_Mode(BluetoothStackID, ConnectableMode);

API Prototype
int BTPSAPI GAP_Set_Connectability_Mode(unsigned int BluetoothStackID, GAP_Connectability_Mode_t GAP_Connectability_Mode);

Description of API
This function is provided to set the connectability mode of the local Bluetooth device specified by the Bluetooth protocol stack that is specified by the Bluetooth protocol stack ID. The second parameter specifies the connectability mode to place the local Bluetooth device into.



SetPairabilityMode[edit]

Description
The SetPairabilityMode command is responsible for setting the Pairability Mode of the local device. This command returns zero on successful execution and a negative value on all errors. A Bluetooth Stack ID must exist before attempting to call this function.

Parameters
This command requires only one parameter which is an integer value that represents a Pairability Mode. This value must be specified as 0 (for Non-Pairable), 1 (for Pairable), or 2 (for Secure Simple Pairing).

Command Call Examples
"SetPairabilityMode 0" Attempts to set the Pairability Mode of the Local Device to Non-Pairable.
"SetPairabilityMode 1" Attempts to set the Pairability Mode of the Local Device to Pairable.
"SetPairabilityMode 2" Attempts to set the Pairability Mode of the Local Device to Secure Simple Pairing.

Possible Return Values
(0) Successfully Set Pairability Mode
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-5) BTPS_ERROR_GAP_NOT_INITIALIZED
(-58) BTPS_ERROR_INVALID_MODE

API Call
GAP_Set_Pairability_Mode(BluetoothStackID, PairabilityMode);

API Prototype
int BTPSAPI GAP_Set_Pairability_Mode(unsigned int BluetoothStackID, GAP_Pairability_Mode_t GAP_Pairability_Mode);

Description of API
This function is provided to set the pairability mode of the local Bluetooth device. The second parameter specifies the pairability mode to place the local Bluetooth device into. If secure simple pairing (SSP) pairing mode is specified, then SSP *MUST* be used for all pairing operations. The device can be placed into non pairable mode after this, however, if pairing is re-enabled, it *MUST* be set to pairable with SSP enabled.



ChangeSimplePairingParameters[edit]

Description
The ChangeSimplePairingParameters command is responsible for changing the Secure Simple Pairing Parameters that are exchanged during the Pairing procedure whenSecure Simple Pairing (Security Level 4) is used. This function returns zero on a successful execution and a negative value on all errors. A Bluetooth Stack ID must exist before attempting to call this function. The IOCapability and MITMProtection values are stored in static global variables which are used for Secure Simple Pairing.

Parameters
This command requires two parameters which are the I/O Capability and the MITM Requirement. The first parameter must be specified as 0 (for Display Only), 1 (for Display Yes/No), 2 (for Keyboard Only), or 3 (for No Input/Output). The second parameter must be specified as 0 (for No MITM) or 1 (for MITM required).

Command Call Examples
"ChangeSimplePairingParameters 3 0" Attempts to set the I/O Capability to No Input/Output and turns off MITM Protection.
"ChangeSimplePairingParameters 2 1" Attempts to set the I/O Capability to Keyboard Only and activates MITM Protection.
"ChangeSimplePairingParameters 1 1" Attempts to set the I/O Capability to Display Yes/No and activates MITM Protection.

Possible Return Values
(0) Successfully Pairing Parameters Change
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR


GetLocalAddress[edit]

Description
The GetLocalAddress command is responsible for querying the Bluetooth Device Address of the local Bluetooth Device. This function returns zero on a successful execution and a negative value on all errors. A Bluetooth Stack ID must exist before attempting to call this function.

Parameters
It is not necessary to include parameters when using this command. A parameter will have no effect on the outcome of the Query.

Possible Return Values
(0) Successfully Query Local Address
(-1) BTPS_ERROR_INVALID_PARAMETER
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-8) INVALID_STACK_ID_ERROR
(-4) FUNCTION_ERROR

API Call
GAP_Query_Local_BD_ADDR(BluetoothStackID, &BD_ADDR);

API Prototype
int BTPSAPI GAP_Query_Local_BD_ADDR(unsigned int BluetoothStackID, BD_ADDR_t *BD_ADDR);

Description of API
This function is responsible for querying (and reporting) the device address of the local Bluetooth device. The second parameter is a pointer to a buffer that is to receive the device address of the local Bluetooth device. If this function is successful, the buffer that the BD_ADDR parameter points to will be filled with the device address read from the local Bluetooth device. If this function returns a negative value, then the device address of the local Bluetooth device was NOT able to be queried (error condition).



SetLocalName[edit]

Description
The SetLocalName command is responsible for setting the name of the local Bluetooth Device to a specified name. This function returns zero on a successful execution and a negative value on all errors. A Bluetooth Stack ID must exist before attempting to call this function.

Parameters
One parameter is necessary for this command. The specified device name must be the only parameter (which means there should not be spaces in the name or only the first section of the name will be set).

Command Call Examples
"SetLocalName New_Bluetooth_Device_Name" Attempts to set the Local Device Name to "New_Bluetooth_Device_Name."
"SetLocalName New Bluetooth Device Name" Attempts to set the Local Device Name to "New Bluetooth Device Name" but only sets the first parameter, which would make the Local Device Name "New."
"SetLocalName STM32" Attempts to set the Local Device Name to "STM32."

Possible Return Values
(0) Successfully Set Local Device Name
(-1) BTPS_ERROR_INVALID_PARAMETER
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-8) INVALID_STACK_ID_ERROR
(-4) FUNCTION_ERROR
(-57) BTPS_ERROR_DEVICE_HCI_ERROR

API Call
GAP_Set_Local_Device_Name(BluetoothStackID, TempParam->Params[0].strParam);

API Prototype
int BTPSAPI GAP_Set_Local_Device_Name(unsigned int BluetoothStackID, char *Name);

Description of API
This function is provided to allow the changing of the device name of the local Bluetooth device. The Name parameter must be a pointer to a NULL terminated ASCII string of at most MAX_NAME_LENGTH (not counting the trailing NULL terminator). This function will return zero if the local device name was successfully changed, or a negative return error code if there was an error condition.




GetLocalName[edit]

Description
This function is responsible for querying the name of the local Bluetooth Device. This function returns zero on a successful execution and a negative value on all errors. A Bluetooth Stack ID must exist before attempting to call this function.

Parameters
It is not necessary to include parameters when using this command. A parameter will have no effect on the outcome of the Query.

Possible Return Values
(0) Successfully Queried Local Device Name
(-8) INVALID_STACK_ID_ERROR
(-4) FUNCTION_ERROR
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1) BTPS_ERROR_INVALID_PARAMETER
(-57) BTPS_ERROR_DEVICE_HCI_ERROR
(-65) BTPS_ERROR_INSUFFICIENT_BUFFER_SPACE

API Call
GAP_Query_Local_Device_Name(BluetoothStackID, 257, (char *)LocalName);

API Prototype
int BTPSAPI GAP_Query_Local_Device_Name(unsigned int BluetoothStackID, unsigned int NameBufferLength, char *NameBuffer);

Description of API
This function is responsible for querying (and reporting) the user friendly name of the local Bluetooth device. The final parameters to this function specify the buffer and buffer length of the buffer that is to receive the local device name. The NameBufferLength parameter should be at least (MAX_NAME_LENGTH+1) to hold the maximum allowable device name (plus a single character to hold the NULL terminator). If this function is successful, this function returns zero, and the buffer that NameBuffer points to will be filled with a NULL terminated ASCII representation of the local device name. If this function returns a negative value, then the local device name was NOT able to be queried (error condition).



SetClassOfDevice[edit]

Description
The SetClassOfDevice command is responsible for setting the Class of Device of the local Bluetooth Device to a Class of Device value. This function returns zero on a successful execution and a negative value on all errors. A Bluetooth Stack ID must exist before attempting to call this function.

Parameters
The only parameter needed is the new Class of Device value. It is preferred to start the value with “0x” and use a six digit value after that. Without doing this, the Class of Device written will be assumed decimal and will be converted to hexadecimal format and change the values given.

Command Call Examples
"SetClassOfDevice 0x123456" Attempts to set the Class of Device for the local Bluetooth Device to "0x123456."
"SetClassOfDevice 123456" Attempts to set the Class of Device for the local Bluetooth Device to "0x01E240" which is equivalent to the decimal value of 123456.

Possible Return Values
(0) Successfully Set Local Class of Device
(-57) BTPS_ERROR_DEVICE_HCI_ERROR
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-8) INVALID_STACK_ID_ERROR
(-4) FUNCTION_ERROR
(-5) BTPS_ERROR_GAP_NOT_INITIALIZED

API Call
GAP_Set_Class_of_Device(BluetoothStackID, Class_of_Device);

API Prototype
int BTPSAPI GAP_Set_Class_Of_Device(unsigned int BluetoothStackID, Class_of_Device_t Class_of_Device);

Description of API
This function is provided to allow the changing of the class of device of the local Bluetooth device. The Class_of_Device parameter represents the class of device value that is to be written to the local Bluetooth device. This function will return zero if the class of device was successfully changed, or a negative return error code if there was an error condition.



GetClassOfDevice[edit]

Description
The GetClassOfDevice command is responsible for querying the Bluetooth Class of Device of the local Bluetooth Device. This function returns zero on a successful execution and a negative value on all errors. A Bluetooth Stack ID must exist before attempting to call this function.

Parameters
It is not necessary to include parameters when using this command. A parameter will have no effect on the outcome of the Query.

Possible Return Values
(0) Successfully Queried Local Class of Device
(-57) BTPS_ERROR_DEVICE_HCI_ERROR
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-8) INVALID_STACK_ID_ERROR
(-4) FUNCTION_ERROR
(-1) BTPS_ERROR_INVALID_PARAMETER

API Call
GAP_Query_Class_Of_Device(BluetoothStackID, &Class_of_Device);

API Prototype
int BTPSAPI GAP_Query_Class_Of_Device(unsigned int BluetoothStackID, Class_of_Device_t *Class_of_Device);

Description of API
This function is responsible for querying (and reporting) the class of device of the local Bluetooth device. The second parameter is a pointer to a class of device buffer that is to receive the Bluetooth class of device of the local device. If this function is successful, this function returns zero, and the buffer that Class_Of_Device points to will be filled with the Class of Device read from the local Bluetooth device. If there is an error, this function returns a negative value, and the class of device of the local Bluetooth device is NOT copied into the specified input buffer.



GetRemoteName[edit]

Description
The GetRemoteName command is responsible for querying the Bluetooth Device Name of a Remote Device. This function returns zero on a successful execution and a negative value on all errors. The command requires that a valid Bluetooth Stack ID exists before running and it should be called after using the Inquiry command. The DisplayInquiryList command would be useful in this situation to find which Remote Device goes with which Inquiry Index.

Parameters
The GetRemoteName command requires one parameter which is the Inquiry Index of the Remote Bluetooth Device. This value can be found after an Inquiry or displayed when the command DisplayInquiryList is used.

Command Call Examples
"GetRemoteName 5" Attempts to query the Device Name for the Remote Device that is at the fifth Inquiry Index.
"GetRemoteName 8" Attempts to query the Device Name for the Remote Device that is at the eighth Inquiry Index.

Possible Return Values
(0) Successfully Queried Remote Name
(-6) INVALID_PARAMETERS_ERROR
(-4) FUNCTION_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1) BTPS_ERROR_INVALID_PARAMETER
(-59) BTPS_ERROR_ADDING_CALLBACK_INFORMATION
(-57) BTPS_ERROR_DEVICE_HCI_ERROR

API Call
GAP_Query_Remote_Device_Name(BluetoothStackID, InquiryResultList[(TempParam->Params[0].intParam – 1)], GAP_Event_Callback, (unsigned long)0);

API Prototype
int BTPSAPI GAP_Query_Remote_Device_Name(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, GAP_Event_Callback_t GAP_Event_Callback, unsigned long CallbackParameter);

Description of API
This function is provided to allow a mechanism to query the user-friendly Bluetooth device name of the specified remote Bluetooth device. This function accepts as input the Bluetooth device address of the remote Bluetooth device to query the name of and the GAP event callback information that is to be used when the remote device name process has completed. This function returns zero if successful, or a negative return error code if the remote name request was unable to be submitted. If this function returns success, then the caller will be notified via the specified callback when the remote name information has been determined (or there was an error). This function cannot be used to determine the user-friendly name of the local Bluetooth device. The GAP_Query_Local_Name function should be used to query the user-friendly name of the local Bluetooth device. Because this function is asynchronous in nature (specifying a remote device address), this function will notify the caller of the result via the specified callback. The caller is free to cancel the remote name request at any time by issuing the GAP_Cancel_Query_Remote_Name function and specifying the Bluetooth device address of the Bluetooth device that was specified in the original call to this function. It should be noted that when the callback is cancelled, the operation is attempted to be cancelled and the callback is cancelled (i.e. the GAP module still might perform the remote name request, but no callback is ever issued).



Hands-free Profile Commands[edit]

OpenHFServer[edit]

Description
The following function is responsible for opening a Serial Port Server on the Local Device. This function opens the Serial Port Server on the specified RFCOMM Channel. This function returns the opened port number (1-31) if successful, or a negative return value if an error occurred.
Parameters
None.

Possible Return Values
(1-32) HFP port opened successfully
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) BTHFRE_ERROR_INVALID_PARAMETER
(-1001) BTHFRE_ERROR_NOT_INITIALIZED
(-1002) BTHFRE_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTHFRE_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTHFRE_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTHFRE_ERROR_INVALID_OPERATION
(-1006) BTHFRE_ERROR_INVALID_CODEC_ID
API Call
HFRE_Open_Hands-free_Server_Port(unsigned int BluetoothStackID, unsigned int ServerPort, unsigned long SupportedFeaturesMask, unsigned int NumberAdditionalIndicators, char *AdditionalSupportedIndicators[], HFRE_Event_Callback_t EventCallback, unsigned long CallbackParameter)
API Prototype
int BTPSAPI HFRE_Open_Hands-free_Server_Port(unsigned int BluetoothStackID, unsigned int ServerPort, unsigned long SupportedFeaturesMask, unsigned int NumberAdditionalIndicators, char *AdditionalSupportedIndicators[], HFRE_Event_Callback_t EventCallback, unsigned long CallbackParameter)
Description of API
The following function is responsible for Opening a Hands-Free Server on the specified Bluetooth SPP Serial Port. This function accepts as input the Bluetooth Stack ID of the Bluetooth Stack Instance to use for the Hands-Free Server, the Local Serial Port Server Number to use, a bit mask that specifies the features in which the Hands-Free unit supports, the Number of Additional Indicators, a list of Additional Indicators to Support, and the HFRE Event Callback function (and parameter) to associate with the specified Hands-Free Port. The ServerPort parameter *MUST* be between SPP_PORT_NUMBER_MINIMUM and SPP_PORT_NUMBER_MAXIMUM. This function returns a positive, non-zero, value if successful or a negative return error code if an error occurs. A successful return code will be a HFRE Port ID that can be used to reference the Opened HFRE Port in ALL other functions in this module except for the HFRE_Register_Audio_Gateway_SDP_Record() function which is specific to an Audio Gateway Server NOT a Hands-Free Server. Once a Server HFRE Port is opened, it can only be Un-Registered via a call to the HFRE_Close_Server_Port() function (passing the return value from this function). The HFRE_Close_Port() function can be used to Disconnect a Client from the Server Port (if one is connected, it will NOT Un-Register the Server Port however).

  • NOTE * The Mandatory Hands-Free Indicators (call, service, and call_setup) are automatically added to the list and need not be specified as additional indicators.


CloseHFServer[edit]

Description
The following function is responsible for closing a Serial Port Server that was previously opened via a successful call to the OpenServer() function. If the last Server is closed, the function also unregisters the SDP record. This function returns zero if successful or a negative return error code if there was an error.
Parameters
It is not necessary to include parameters when using this command and only one Server opened. If two HFP servers opened add the port index as the input.
Possible Return Values
(0) HFP Server closed successfully
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) BTHFRE_ERROR_INVALID_PARAMETER
(-1001) BTHFRE_ERROR_NOT_INITIALIZED
(-1002) BTHFRE_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTHFRE_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTHFRE_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTHFRE_ERROR_INVALID_OPERATION
(-1006) BTHFRE_ERROR_INVALID_CODEC_ID
API Call
HFRE_Close_Server_Port(BluetoothStackID, HFServerPortID)
API Prototype
int BTPSAPI HFRE_Close_Server_Port(unsigned int BluetoothStackID, unsigned int HFREPortID)
Description of API
The following function is responsible for Un-Registering a HFRE Port Server (which was Registered by a successful call to either the HFRE_Open_Hands-free_Server_Port() or the HFRE_Open_Audio_Gateway_Server_Port() function). This functionaccepts as input the Bluetooth Stack ID of the Bluetooth Protocol Stack that the HFRE Port specified by the Second Parameter is valid for. This function returns zero if successful, or a negative return error code if an error occurred (see BTERRORS.H). Note that this function does NOT delete any SDP Service Record Handles.


ManageAudio[edit]

Description
The following function is responsible for setting up or releasing an audio connection. This function returns zero on successful execution and a negative value on all errors.
Parameters
The Manage Audio command requires only one parameter, with one HFP Server connected, for the ManageAudio mode. This value must be specified as 0 (for Release) or 1 (for Setup). If second HFP Server is connected, add the Server port index as the second input
Command Call Examples
"ManageAudio 0 1" Attempts to Release the Audio Connection from Server with port index 1.
"ManageAudio 1 2" Attempts to Setup the Audio Connection with Server portr index 2.
Possible Return Values
(0) command sent successfully
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) BTHFRE_ERROR_INVALID_PARAMETER
(-1001) BTHFRE_ERROR_NOT_INITIALIZED
(-1002) BTHFRE_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTHFRE_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTHFRE_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTHFRE_ERROR_INVALID_OPERATION
(-1006) BTHFRE_ERROR_INVALID_CODEC_ID
API Call
HFRE_Setup_Audio_Connection(BluetoothStackID, HFServerPortID)
or HFRE_Release_Audio_Connection(BluetoothStackID, HFServerPortID)
API Prototype
int BTPSAPI HFRE_Setup_Audio_Connection(unsigned int BluetoothStackID, unsigned int HFREPortID)
or int BTPSAPI HFRE_Release_Audio_Connection(unsigned int BluetoothStackID, unsigned int HFREPortID)

Description of API
This function is responsible for Setting Up an Audio Connection between the Local and Remote Device. This function may be used by either an Audio Gateway or a Hands-Free unit for which a valid Service Level Connection Exists. This function accepts as its input parameters the Bluetooth Stack ID for which the HFRE Port ID is valid as well as the HFRE Port ID. This function returns zero if successful or a negative return error code if there was an error.
(or) This function is responsible for Releasing an Audio Connection which was previously established by the Remote Device or by a call to the HFRE_Setup_Audio_Connection() function. This function may be used by either an Audio Gateway or a Hands-Free unit. This function accepts as its input parameters the Bluetooth Stack ID for which the HFRE Port ID is valid as well as the HFRE Port ID. This function returns zero if successful or a negative return error code if there was an error.


AnswerCall[edit]

Description
The following function is responsible for sending the command to Anwser an Incoming Call on the Remote Audio Gateway. This function returns zero on successful execution and a negative value on all errors.
Parameters
It is not necessary to include parameters when using this command with one connection. When two connections are active (The two HFP Server ports are connected), Add the Server port index (1 or 2) as input.
Possible Return Values
(0) command sent successfully
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) BTHFRE_ERROR_INVALID_PARAMETER
(-1001) BTHFRE_ERROR_NOT_INITIALIZED
(-1002) BTHFRE_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTHFRE_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTHFRE_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTHFRE_ERROR_INVALID_OPERATION
(-1006) BTHFRE_ERROR_INVALID_CODEC_ID
API Call
HFRE_Answer_Incoming_Call(BluetoothStackID, HFServerPortID)
API Prototype
int BTPSAPI HFRE_Answer_Incoming_Call(unsigned int BluetoothStackID, unsigned int HFREPortID)
Description of API
This function is responsible for sending the command to Answer an Incoming call on a Remote Audio Gateway. This function may only be performed by Hands-Free units for which a valid Service Level Connection exists. This function accepts as its input parameters the Bluetooth Stack ID for which the HFRE Port ID is valid as well as the HFRE Port ID. This function return zero if successful or a negative return error code if there was an error.


HangupCall[edit]

Description
The following function is responsible for sending the command to HangUp ongoing calls or reject incoming calls on the Remote Audio Gateway. This function returns zero on successful execution and a negative value on all errors.
Parameters
It is not necessary to include parameters when using this command with one connection. When two connections are active (The two HFP Server ports are connected), Add the Server port index (1 or 2) as input
Possible Return Values
(0) Command sent successfully
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) BTHFRE_ERROR_INVALID_PARAMETER
(-1001) BTHFRE_ERROR_NOT_INITIALIZED
(-1002) BTHFRE_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTHFRE_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTHFRE_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTHFRE_ERROR_INVALID_OPERATION
(-1006) BTHFRE_ERROR_INVALID_CODEC_ID
API Call
HFRE_Hang_Up_Call(BluetoothStackID, HFServerPortID)
API Prototype
int BTPSAPI HFRE_Hang_Up_Call(unsigned int BluetoothStackID, unsigned int HFREPortID)
Description of API
This function is responsible for sending a Hang-Up Command to the Remote Audio Gateway. This function may be used to Reject an incoming call, or to terminate an ongoing call. This function may only be performed by Hands-Free units for which a valid Service Level Connection exists. This function accepts as its input parameters the Bluetooth Stack ID for which the HFRE Port ID is valid as well as the HFRE Port ID. This function returns zero if successful or a negative return error code if there was an error.


PlaceCallOnHold[edit]

Description
The following function is responsible for sending the command to Hold a connected Call on the Remote Audio Gateway, This function Can be sent without any parameter if the HF device has only one connection available, if not it needs the port ID parameter. This function returns zero on successful execution and a negative value on all errors.
Parameters
It is not necessary to include parameters when using this command with one connection. When two connections are active (The two HFP Server ports are connected), Add the Server port index (1 or 2) as input
Possible Return Values
(0) Command sent successfully
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) BTHFRE_ERROR_INVALID_PARAMETER
(-1001) BTHFRE_ERROR_NOT_INITIALIZED
(-1002) BTHFRE_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTHFRE_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTHFRE_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTHFRE_ERROR_INVALID_OPERATION
(-1006) BTHFRE_ERROR_INVALID_CODEC_ID
API Call
HFRE_Send_Call_Holding_Multiparty_Selection(BluetoothStackID, HFServerPortID, HFRE_Call_Hold_Multiparty_Handling_Type_t CallHoldMultipartyHandling, unsigned int Index)
API Prototype
int BTPSAPI HFRE_Send_Call_Holding_Multiparty_Selection(BluetoothStackID, HFServerPortID, HFRE_Call_Hold_Multiparty_Handling_Type_t CallHoldMultipartyHandling, unsigned int Index)
Description of API
This function is responsible for allowing the control of multiple concurrent calls and provides a means for holding calls, releasing calls, switching between two calls and adding a call to a multiparty conference. This function may only be performed by Hands-Free units that support call waiting and multiparty services as well as have a valid Service Level Connection. The selection which is made should be one that is supported by the remote Audio Gateway as queried via a call to the HFRE_Query_Remote_Call_Holding_Multiparty_Service_Support() function. This function accepts as its first input parameter the HFRE Port ID. The final parameter is the selection of how to handle the call index (the last parameter). When sent from PlaceCallOnHold() function, the parameter sent is- chPlaceAllActiveCallsOnHoldAcceptTheOther. This function returns zero if successful or a negative return error code if there was an error.


HoldingMultipartyCall[edit]

Description
The following function is responsible for sending the HoldingMultipartyCall command to a waiting Call on the Remote Audio Gateway. This function returns zero on successful execution and a negative value on all errors. *Note* Using this function can cause undesirable effects if not used carefully - mostly used in order to dismiss the waiting call on the secondary device.
Parameters
1) When two connections are active (The two HFP Server ports are connected), Add the Server port index (1 or 2) as input. 2) The CallHoldMultipartyHandling command. 3) The call index.
Possible Return Values
(0) Command sent successfully
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) BTHFRE_ERROR_INVALID_PARAMETER
(-1001) BTHFRE_ERROR_NOT_INITIALIZED
(-1002) BTHFRE_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTHFRE_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTHFRE_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTHFRE_ERROR_INVALID_OPERATION
(-1006) BTHFRE_ERROR_INVALID_CODEC_ID
API Call
HFRE_Send_Call_Holding_Multiparty_Selection(BluetoothStackID, HFServerPortID, HFRE_Call_Hold_Multiparty_Handling_Type_t CallHoldMultipartyHandling, unsigned int Index)
API Prototype
int BTPSAPI HFRE_Send_Call_Holding_Multiparty_Selection(BluetoothStackID, HFServerPortID, HFRE_Call_Hold_Multiparty_Handling_Type_t CallHoldMultipartyHandling, unsigned int Index)
Description of API
This function is responsible for allowing the control of multiple concurrent calls and provides a means for holding calls, releasing calls, switching between two calls and adding a call to a multiparty conference. This function may only be performed by Hands-Free units that support call waiting and multiparty services as well as have a valid Service Level Connection. The selection which is made should be one that is supported by the remote Audio Gateway as queried via a call to the HFRE_Query_Remote_Call_Holding_Multiparty_Service_Support() function. This function accepts as its first input parameter the HFRE Port ID. The final parameter is the selection of how to handle the call index (the last parameter). This function returns zero if successful or a negative return error code if there was an error.


HoldingMultiPhonesCall[edit]

Description
The following function has the following responsibilities: 1) When using only one connection this function responsible for sending the HoldingMultipartyCall command to a call with index on the Remote Audio Gateway. 2) When using two connection and one connection has waiting call or call on-hold and an active connection this function responsible for sending the HoldingMultipartycall command so the user can change the call state in this phone but he can't rout the audio. 3) When using two connection and one is in active call while the other is in waiting call or in on hold call, this function can answer the waiting call or set the active call on hold. This function returns zero on successful execution and a negative value on all errors.
Parameters
1) When two connections are active (The two HFP Server ports are connected), Add the Server port index (1 or 2) as input. 2) The CallHoldMultipartyHandling command. 3) The call index.
Possible Return Values
(0) Command sent successfully
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) BTHFRE_ERROR_INVALID_PARAMETER
(-1001) BTHFRE_ERROR_NOT_INITIALIZED
(-1002) BTHFRE_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTHFRE_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTHFRE_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTHFRE_ERROR_INVALID_OPERATION
(-1006) BTHFRE_ERROR_INVALID_CODEC_ID
API Call
HFRE_Send_Call_Holding_Multiparty_Selection(BluetoothStackID, HFServerPortID, HFRE_Call_Hold_Multiparty_Handling_Type_t CallHoldMultipartyHandling, unsigned int Index)
API Prototype
int BTPSAPI HFRE_Send_Call_Holding_Multiparty_Selection(BluetoothStackID, HFServerPortID, HFRE_Call_Hold_Multiparty_Handling_Type_t CallHoldMultipartyHandling, unsigned int Index)
Description of API
This function is responsible for allowing the control of multiple concurrent calls and provides a means for holding calls, releasing calls, switching between two calls and adding a call to a multiparty conference. This function may only be performed by Hands-Free units that support call waiting and multiparty services as well as have a valid Service Level Connection. The selection which is made should be one that is supported by the remote Audio Gateway as queried via a call to the HFRE_Query_Remote_Call_Holding_Multiparty_Service_Support() function. This function accepts as its first input parameter the HFRE Port ID. The final parameter is the selection of how to handle the call index (the last parameter). This function returns zero if successful or a negative return error code if there was an error.


SwitchAudioFor2PhonesWithActiveCall[edit]

Description
The following function switch the audio between two phones with two active calls. When the first call answered and the SCO/eSCO channel is connected, also the PCM audio from the BT device is routed to the evaluation board CODEC and the MIC is routed to ADC and then to the BT PCM. If the other phone also answer an incoming call and open another SCO/eSCO channel, the audio stays with the first phone that started his active call. When calling this function, first check that there are two phones with active calls, then check also that there are no more calls in the phone (on hold or waiting). After the checks, send to the phone with the audio active call, to hold the call and release the SCO/eSCO channel. After the SCO/eSCO released, uninitialize the audio routing. Then wait 10ms and disconnect the SCO/eSCO of the second phone for connect again with audio routing.
Parameters
It is not necessary to include parameters when using this command.
Possible Return Values
(0) Command sent successfully
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) BTHFRE_ERROR_INVALID_PARAMETER
(-1001) BTHFRE_ERROR_NOT_INITIALIZED
(-1002) BTHFRE_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTHFRE_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTHFRE_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTHFRE_ERROR_INVALID_OPERATION
(-1006) BTHFRE_ERROR_INVALID_CODEC_ID


AnswerSeconePhoneIncomingCallAndSwitchAudio[edit]

Description
The following function switch the audio between two phones, that one in active call with audio and the second with waiting call. The waiting call is answered and the audio is routed to the new active call. When the first call answered and the SCO/eSCO channel is connected, also the PCM audio from the BT device is routed to the evaluation board CODEC and the MIC is routed to ADC and then to the BT PCM. If the other phone has an incoming call the audio will stays with the first phone that started his active call even if the user will answer the call. When calling this function, first check that there are two phones with active and waiting calls, then check also that there are no more calls in the phone (on hold or waiting or active). After the checks, send to the phone with the audio active call, to hold the call and release the SCO/eSCO channel. After the SCO/eSCO released, uninitialize the audio routing. Then wait 10ms and disconnect the SCO/eSCO of the second phone for connect again with audio routing after answering the waiting call.
Parameters
It is not necessary to include parameters when using this command.
Possible Return Values
(0) Command sent successfully
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) BTHFRE_ERROR_INVALID_PARAMETER
(-1001) BTHFRE_ERROR_NOT_INITIALIZED
(-1002) BTHFRE_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTHFRE_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTHFRE_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTHFRE_ERROR_INVALID_OPERATION
(-1006) BTHFRE_ERROR_INVALID_CODEC_ID

E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article CC256x STM32 TI Bluetooth Stack HFPDemo App here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article CC256x STM32 TI Bluetooth Stack HFPDemo App here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article CC256x STM32 TI Bluetooth Stack HFPDemo App here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article CC256x STM32 TI Bluetooth Stack HFPDemo App here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article CC256x STM32 TI Bluetooth Stack HFPDemo App here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article CC256x STM32 TI Bluetooth Stack HFPDemo App here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article CC256x STM32 TI Bluetooth Stack HFPDemo App here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article CC256x STM32 TI Bluetooth Stack HFPDemo App here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article CC256x STM32 TI Bluetooth Stack HFPDemo App here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity