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 TI Bluetooth Stack AUDDemo App

From Texas Instruments Wiki
Jump to: navigation, search

Return to CC256x Tiva TI’s Bluetoth stack Basic Demo APPS

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

Demo Overview[edit]

NoteNote: These instructions can be used to run this demo on the either the STM32 (AUD Demo) or Tiva (A2DP Demo) Platforms, but the STM32F4 only supports the SINK role.

The Advanced Audio Distribution Profile (A2DP) Sink and Audio Video Remote Control Profile (AVRCP) allows a device to act as an Audio sink and can control and stream audio on an Audio source.
It is recommended that the user visits the kit setup Getting Started Guide for STM32 or Getting Started Guide for TIVA pages before trying the application described on this page.

Running the Bluetooth Code[edit]

Once the code is flashed. Look at the Device manager for Communications Port (COM x) under Ports (COM & LPT). Attach a terminal program like PuTTY to the serial port (COM x) for the board, x means which COM is open for Communications Port in Device Manager. The serial parameter to use is 115200 Baud rate. Once connected, reset the device using Reset button (The black button near the blue buttons) and you should see the stack getting initialized on the terminal and the help screen will be displayed, which shows all of the commands. This device will become the server.

Initial Screen of AUDDemo application

NoteNote: The yellow square holds the FW and BTPS versions for future use.



Demo Application[edit]

This section provides a description of how to use the demo application to connect an audio source to it and communicate over Bluetooth.

Device (sink) setup on the demo application[edit]

The STM32 board is ready to connect right after it starts, to create this connection, either the source or the sink can initialize it.

Initiating connection from the source[edit]

The A2DP source can be any application that can transmit audio. For our example, we will use an android phone as the demo.
In order to connect to the sink, the source needs the sink bluetooth address or name.
  • Sink terminal
a) The Bluetooth address can be found at the beginning of the demo application or by typing GetLocalAddress, in this case we can see the bluetooth address.
b) The Sink name can be found by typing GetLocalName and the terminal will print the default name of the application AUDDemo
Initial Screen of AUDDemo application
  • Source Phone

After the data of the sink for the connection is known

c) Open the bluetooth settings menu on the android phone(Settings->Bluetooth).
d) Hit on search for devices. The phone should begin looking for other bluetooth devices.
Search for devices
e) An AUDDemo or A2DPDemo should appear like shown below in the picture. Click on the device to begin pairing.
Select TI Audio Demo
f) Enter PIN password and remember it, In the example we use 0000.
PIN password
  • Sink terminal
g) In the Sink terminal there is a request for PIN code that to allow the pairing to complete, enter PINCodeResponse 0000.
Pin Response
h) After the devices are paired, the device should show connected on the phone side and on the STM32.
Paired Phone
Connected STM32
i) You can now control the audio of the phone from the STM32 board.


Initiating connection from the sink[edit]

  • Sink terminal

NoteNote: Make sure that the source is in discoverable mode

j) In Order to connect to the source, the sink must find it first with inquiry command, type inquiry.
Inquiry
k) The inquiry command generates a list of all the devices in range.
l) In order to connect to the source use the OpenRemoteSteam command with the index of the bluetooth address you want, in our case we connect to index 2, so we type OpenRemoteStream 2.
Open Remote Stream
  • Source Phone
m) enter PIN password and remember it, In the example we use 0000.
PIN password
  • Sink terminal
n) In the Sink terminal there is a request for PIN code that to allow the pairing to complete, enter PINCodeResponse 0000.
Pin Response
o) After the devices are paired, the device should show connected on the phone side and on the STM32.
Paired Phone
Connected STM32

A2DP+AVRCP Commands[edit]

Now, After the sink and the source are connected we can start controlling the audio of the source from the sink.
p) Open any music application in the source, in the sink, in order to control the audio use SendPassThroughCommand Command and a parameter for the command. the command can be Pause = 0, Play = 1, Stop = 2, Vol. up = 3 and Vol. Down = 4.

NoteNote: Volume (Vol.) commands might not work with your device.

Send Pass Through Command Usage
q) Type SendPassThroughCommand 1. A track will start playing on the devices.
Play Music
r) Type SendPassThroughCommand 2. A track will stop playing on the devices.
Stop Music
s) In order to change the Stream format: Sample rate and Mono/Stereo, use the ChangeStreamFormat command and a value which represent the supported format index that is needed.
t) The supported sink formats and their indexes can be displayed by typing QuerySupportedFormats.

NoteNote: The connection must be in suspend in order to work.
NoteNote: ChangeStreamFormat might not work with your device.

The First Number is the index that you choose, the second number is the sample rate in Hz and the third number represents 1 = Mono, 2 = Stereo.
Change Stream Format


u) In order to change the Stream State: Stopped or Started, use the Changestreamstate command and a value which represent the stream state 0 = Stopped, 1 = Started.
When the Command Changestreamstate 0 is sent, the devices will enter to suspend mode of A2DP.

NoteNote: Changestreamstate might not work with your device.

Change Stream State
v) The command ChangeConnectionMode enable the sink to allow automatically or manual connections or disallow connection, use the ChangeConnectionMode command and a value which represent the connection mode Automatic Accept = 0, Automatic Reject = 1, Manual Accept = 2.
Change connection mode

Application Commands[edit]

TI’s Bluetooth stack is an 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 a Bluetooth controller chip.

The basic Bluetooth application included with STM3240G-eval is a Cycling Speed and Cadence Application.

An overview of the application and other applications can be read at the Getting Started Guide for STM32 or Getting Started Guide for Tiva M4.

This page describes the various commands that a user of the application can use. Each command is a wrapper over a TI’s Bluetooth stack API which gets invoked with the parameters selected by the user. This is a subset of the APIs available to the user. TI’s Bluetooth stack API documentation (TI_Bluetooth_Stack_Version-Number\Documentation or for STM32F4, TI_Bluetooth_Stack_Version-Number\RTOS_VERSION\Documentation) describes all of the API's in detail.

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



DisplayInquiryList[edit]

Description
The DisplayInquiryList command exists to display the current Inquiry List with indexes. This command is useful for when a user has forgotten the Inquiry Index for a particular Bluetooth Device the user may want to interact with. 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, since the list would be empty without already discovering devices.

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

Possible Return Values
(0) Successful Display of the Inquiry List
(-8) INVALID_STACK_ID_ERROR



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 MSP430" Attempts to set the Local Device Name to "MSP430."

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).



A2DP Profile Commands[edit]

OpenRemoteStream[edit]

Description
The following function is responsible for initializing AUD if necessary, and initializing the A2DP and AVRCP subsystems.

Parameters
This command takes Inquiry Index number to work which can be found using the DisplayInquiryList command after an Inquiry has been completed

Possible Return Values
(0) AUD Sink opened successfully
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2000) BTAUD_ERROR_INVALID_PARAMETER
(-2001) BTAUD_ERROR_NOT_INITIALIZED
(-2002) BTAUD_ERROR_INVALID_BLUETOOTH_STACK_ID
(-2009) BTAUD_ERROR_STREAM_NOT_INITIALIZED
(-2010) BTAUD_ERROR_UNABLE_TO_CONNECT_REMOTE_STREAM
(-2011) BTAUD_ERROR_STREAM_ALREADY_CONNECTED
(-2013) BTAUD_ERROR_STREAM_CONNECTION_IN_PROGRESS

API Call
AUD_Open_Remote_Stream(BluetoothStackID, InquiryResultList[(TempParam->Params[0].intParam - 1)], astSNK)

API Prototype
int BTPSAPI AUD_Open_Remote_Stream(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, AUD_Stream_Type_t StreamType)

Description of API
The following function is responsible for opening a remote streaming endpoint on the specified remote device.This function accepts as input the Bluetooth stack ID of the Bluetooth protocol stack that the requested Audio Manager is present, followed by the remote Bluetooth device AND the local Stream type.
This function returns zero if successful or a negative return error code if there was an error.



CloseStream[edit]

Description
The following function is responsible for closing an opened stream.

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) AUD Sink closed successfully
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2000) BTAUD_ERROR_INVALID_PARAMETER
(-2001) BTAUD_ERROR_NOT_INITIALIZED
(-2002) BTAUD_ERROR_INVALID_BLUETOOTH_STACK_ID
(-2012) BTAUD_ERROR_STREAM_NOT_CONNECTED

API Call
AUD_Close_Stream(BluetoothStackID, ConnectedBD_ADDR, astSNK)

API Prototype
int BTPSAPI AUD_Close_Stream(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, AUD_Stream_Type_t StreamType)

Description of API
The following function is responsible for Closing a currently open stream endpoint on the local device.This function accepts as input the Bluetooth stack ID of the Bluetooth protocol stack that the requested Audio Manager is present, followed by the remote device address of the connected stream, followed by the stream endpoint type to close (local Stream Endpoint).
This function returns zero if successful or a negative return error code if there was an error.



OpenRemoteControl[edit]

Description
The following function is responsible for opening a remote control connection to a remote Bluetooth Device, AVRCP subsystem.

Parameters
This command takes Inquiry Index number to work which can be found using the DisplayInquiryList command after an Inquiry has been completed

Possible Return Values
(0) AVRCP opened successfully
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2001) BTAUD_ERROR_NOT_INITIALIZED
(-2000) BTAUD_ERROR_INVALID_PARAMETER
(-2026) BTAUD_ERROR_REMOTE_CONTROL_NOT_CONNECTED
(-2028) BTAUD_ERROR_REMOTE_CONTROL_ALREADY_CONNECTED
(-2029) BTAUD_ERROR_REMOTE_CONTROL_CONNECTION_IN_PROGRESS
(-2030) BTAUD_ERROR_REMOTE_CONTROL_NOT_INITIALIZED

API Call
AUD_Open_Remote_Control(BluetoothStackID, InquiryResultList[(TempParam->Params[0].intParam - 1)])

API Prototype
int BTPSAPI AUD_Open_Remote_Control(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR)

Description of API
The following function is responsible for opening a remote control connection to the specified remote device. This function accepts as input the Bluetooth stack ID of the Bluetooth protocol stack that the requested Audio Manager is present, followed by the remote Bluetooth device address of the device to connect with. This function returns zero if successful or a negative return error code if there was an error.
NoteNote: If this function is called to establish a remote control connection (and the connection is successful), the caller *MUST* call the AUD_Close_Remote_Control() function to disconnect the remote control connection.



CloseRemoteControl[edit]

Description
The following function is responsible for closing an opened remote control.

Parameters
This command takes Inquiry Index number to work which can be found using the DisplayInquiryList command after an Inquiry has been completed.

Possible Return Values
(0) AVRCP closed successfully
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-103) BTPS_ERROR_FEATURE_NOT_AVAILABLE
(-2000) BTAUD_ERROR_INVALID_PARAMETER
(-2001) BTAUD_ERROR_NOT_INITIALIZED
(-2002) BTAUD_ERROR_INVALID_BLUETOOTH_STACK_ID
(-2005) BTAUD_ERROR_INVALID_OPERATION
(-2026) BTAUD_ERROR_REMOTE_CONTROL_NOT_CONNECTED
(-2030) BTAUD_ERROR_REMOTE_CONTROL_NOT_INITIALIZED

API Call
AUD_Close_Remote_Control(BluetoothStackID, InquiryResultList[(TempParam->Params[0].intParam - 1)])

API Prototype
int BTPSAPI AUD_Close_Remote_Control(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR)

Description of API
The following function is responsible for closing a currently open remote control connection on the local device.This function accepts as input the Bluetooth stack ID of the Bluetooth protocol stack that the requested Audio Manager is present, followed by the device address of the remote control connection close.This function returns zero if successful or a negative return error code if there was an error.
NoteNote: This function should only be called if the local device previously issued a call to the AUD_Open_Remote_Control() function and a remote control connection was successfully established.



ChangeStreamState[edit]

Description
The following function is responsible for changing the state of an open stream.

Parameters

This function required one parameter, stream state (0 = Stopped, 1 = Started).

Possible Return Values
(0) Successful
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2000) BTAUD_ERROR_INVALID_PARAMETER
(-2001) BTAUD_ERROR_NOT_INITIALIZED
(-2002) BTAUD_ERROR_INVALID_BLUETOOTH_STACK_ID
(-2012) BTAUD_ERROR_STREAM_NOT_CONNECTED
(-2016) BTAUD_ERROR_STREAM_STATE_ALREADY_CURRENT
(-2017) BTAUD_ERROR_UNABLE_TO_CHANGE_STREAM_STATE
(-2018) BTAUD_ERROR_STREAM_STATE_CHANGE_IN_PROGRESS
(-2019) BTAUD_ERROR_STREAM_FORMAT_CHANGE_IN_PROGRESS
API Call
AUD_Change_Stream_State(BluetoothStackID, ConnectedBD_ADDR, astSNK, (TempParam->Params[0].intParam)?astStreamStarted:astStreamStopped)
API Prototype
int BTPSAPI AUD_Change_Stream_State(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, AUD_Stream_Type_t StreamType, AUD_Stream_State_t StreamState)
Description of API
The following function is responsible for Changing the Stream State of a currently opened stream endpoint on the local device. This function accepts as input the Bluetooth stack ID of the Bluetooth protocol stack that the requested Audio Manager is present, followed by the remote device address of the connected stream, followed by the stream endpoint type to change the state of (local Stream Endpoint), followed by the new Stream Endpoint state.
This function returns zero if successful or a negative return error code if there was an error.



QueryStreamState[edit]

Description
The following function is responsible for determining and displaying an open stream's current state.
Parameters
This function required one parameter, Local Stream Type (0 = SNK, 1 = SRC).

Possible Return Values
(0) Successful
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2000) BTAUD_ERROR_INVALID_PARAMETER
(-2001) BTAUD_ERROR_NOT_INITIALIZED
(-2002) BTAUD_ERROR_INVALID_BLUETOOTH_STACK_ID
(-2012) BTAUD_ERROR_STREAM_NOT_CONNECTED
API Call
AUD_Query_Stream_State(BluetoothStackID, ConnectedBD_ADDR, astSNK, &StreamState)

API Prototype
int BTPSAPI AUD_Query_Stream_State(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, AUD_Stream_Type_t StreamType, AUD_Stream_State_t *StreamState)

Description of API
The following function is responsible for querying the current Stream State of a currently opened stream endpoint on the local device.This function accepts as input the Bluetooth stack ID of the Bluetooth protocol stack that the requested Audio Manager is present, followed by the remote device address of the connected stream, followed by the stream endpoint type to query the state of (local Stream Endpoint), followed by a pointer to a buffer that is receive the current Stream Endpoint state.
This function returns zero if successful or a negative return error code if there was an error.



ChangeStreamFormat[edit]

Description
The following function is responsible for changing the format of a currently open stream. The Supported Formats Index should be determined by the displayed list from a call to QuerySupportedFormats.

Parameters
This function required one parameter, Supported Formats Index (fron the list in QuerySupportedFormats).

Possible Return Values
(0) Successful
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2000) BTAUD_ERROR_INVALID_PARAMETER
(-2001) BTAUD_ERROR_NOT_INITIALIZED
(-2002) BTAUD_ERROR_INVALID_BLUETOOTH_STACK_ID
(-2012) BTAUD_ERROR_STREAM_NOT_CONNECTED
(-2014) BTAUD_ERROR_STREAM_IS_ACTIVE
(-2018) BTAUD_ERROR_STREAM_STATE_CHANGE_IN_PROGRESS
(-2019) BTAUD_ERROR_STREAM_FORMAT_CHANGE_IN_PROGRESS
(-2020) BTAUD_ERROR_UNSUPPORTED_FORMAT
(-2021) BTAUD_ERROR_UNABLE_TO_CHANGE_STREAM_FORMAT
(-2032) BTAUD_ERROR_SAME_FORMAT

API Call
AUD_Change_Stream_Format(BluetoothStackID, ConnectedBD_ADDR, astSNK, &AudioSNKSupportedFormats[(TempParam->Params[0].intParam - 1)])

API Prototype
int BTPSAPI AUD_Change_Stream_Format(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, AUD_Stream_Type_t StreamType, AUD_Stream_Format_t *StreamFormat)

Description of API
The following function is responsible for Changing the Stream Format of a currently opened stream endpoint on the local device. This function accepts as input the Bluetooth stack ID of the Bluetooth protocol stack that the requested Audio Manager is present, followed by the remote device address of the connected stream, followed by the stream endpoint type to change the format of (local Stream Endpoint), followed by the new Stream Endpoint format.
This function returns zero if successful or a negative return error code if there was an error.
NoteNote: The Stream Format can ONLY be changed when the stream state is stopped.
NoteNote: The stream codec type cannot be changed.If a stream has been configured for a specific codec type, this function cannot be used to change the codec type.The stream must be disconnected and reconnected and the alternate codec type must be selected.In fact, the codec type bit mask value is ignored by this function.



QueryStreamFormat[edit]

Description
The following function is responsible for determining and displaying the format of a currently opened stream.

Parameters
This function required one parameter, Local Stream Type (0 = SNK, 1 = SRC).

Possible Return Values
(0) Successful
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2000) BTAUD_ERROR_INVALID_PARAMETER
(-2001) BTAUD_ERROR_NOT_INITIALIZED
(-2002) BTAUD_ERROR_INVALID_BLUETOOTH_STACK_ID
(-2012) BTAUD_ERROR_STREAM_NOT_CONNECTED

API Call
AUD_Query_Stream_Format(BluetoothStackID, ConnectedBD_ADDR, astSNK, &StreamFormat)

API Prototype
int BTPSAPI AUD_Query_Stream_Format(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, AUD_Stream_Type_t StreamType, AUD_Stream_Format_t *StreamFormat)

Description of API
The following function is responsible for querying the current Stream Format of a currently opened stream endpoint on the local device.This function accepts as input the Bluetooth stack ID of the Bluetooth protocol stack that the requested Audio Manager is present, followed by the remote device address of the connected stream, followed by the stream endpoint type to query the format of (local Stream Endpoint), followed by a pointer to a buffer that is receive the current Stream Endpoint format.
This function returns zero if successful or a negative return error code if there was an error.



QuerySupportedFormats[edit]

Description
The following function is responsible for displaying the local supported formats to the user. The indices displayed should be used with the ChangeStreamFormat 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) Successful
(-8) INVALID_STACK_ID_ERROR



QueryStreamConfiguration[edit]

Description
The following function is responsible for determining and displaying the configuration of a currently opened stream.

Parameters
This function required one parameter, Local Stream Type (0 = SNK, 1 = SRC).

Possible Return Values
(0) Successful
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2000) BTAUD_ERROR_INVALID_PARAMETER
(-2001) BTAUD_ERROR_NOT_INITIALIZED
(-2002) BTAUD_ERROR_INVALID_BLUETOOTH_STACK_ID
(-2012) BTAUD_ERROR_STREAM_NOT_CONNECTED

API Call
AUD_Query_Stream_Configuration(BluetoothStackID, ConnectedBD_ADDR, astSNK, &StreamConfiguration)

API Prototype
int BTPSAPI AUD_Query_Stream_Configuration(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, AUD_Stream_Type_t StreamType, AUD_Stream_Configuration_t *StreamConfiguration)

Description of API
The following function is responsible for querying the current Stream Configuration of a currently opened stream endpoint on the local device.This function accepts as input the Bluetooth stack ID of the Bluetooth protocol stack that the requested Audio Manager is present, followed by the remote device address of the connected stream, followed by the stream endpoint type to query the configuration of (local Stream Endpoint), followed by a pointer to a buffer that is receive the current Stream Endpoint configuration.
This function returns zero if successful or a negative return error code if there was an error.
NoteNote: This function is used to query the low level A2DP configuration that is currently active for the specified stream.



ChangeConnectionMode[edit]

Description
The following function is responsible for changing how incoming connections are handled.

Parameters
This function required one parameter, Connection Mode (0 = Automatic Accept, 1 = Automatic Reject, 2 = Manual Accept).

Possible Return Values
(0) Successful
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2000) BTAUD_ERROR_INVALID_PARAMETER
(-2001) BTAUD_ERROR_NOT_INITIALIZED
(-2002) BTAUD_ERROR_INVALID_BLUETOOTH_STACK_ID

API Call
AUD_Set_Server_Connection_Mode(BluetoothStackID, (!(TempParam->Params[0].intParam))?ausAutomaticAccept:(TempParam->Params[0].intParam == 1)?ausAutomaticReject:ausManualAccept)

API Prototype
int BTPSAPI AUD_Set_Server_Connection_Mode(unsigned int BluetoothStackID, AUD_Server_Connection_Mode_t ServerConnectionMode)

Description of API
The following function is responsible for setting the Audio Manager Server Connection Mode.This function accepts as its first parameter the Bluetooth stack ID of the Bluetooth stack in which the server exists.The second parameter to this function is the new Server Connection Mode to set the Server to use. Connection requests will not be dispatched unless the Server Mode (second parameter) is set to ausManualAccept. In this case the Callback that was registered with the server will be invoked whenever a Remote Bluetooth device attempts to connect to the local device.If the Server Mode (second parameter) is set to anything other than ausManualAccept then no open request indication events will be dispatched.
This function returns zero if successful, or a negative return error code if an error occurred.
NoteNote: The Default Server Connection Mode is AutomaticAccept.
NoteNote: This function is used for Bluetooth devices operating in Bluetooth Security Mode 2.



QueryConnectionMode[edit]

Description
The following function is responsible for determining and displaying how incoming connections are handled.

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) Successful
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2000) BTAUD_ERROR_INVALID_PARAMETER
(-2001) BTAUD_ERROR_NOT_INITIALIZED
(-2002) BTAUD_ERROR_INVALID_BLUETOOTH_STACK_ID

API Call
AUD_Get_Server_Connection_Mode(BluetoothStackID, &ServerConnectionMode)

API Prototype
int BTPSAPI AUD_Get_Server_Connection_Mode(unsigned int BluetoothStackID, AUD_Server_Connection_Mode_t *ServerConnectionMode)

Description of API
The following function is responsible for retrieving the current Audio Manager Connection Mode.This function accepts as its first parameter the Bluetooth stack ID of the Bluetooth stack on which the server exists.The final parameter to this function is a pointer to a Server Connection Mode variable which will receive the current Server Connection Mode.
This function returns zero if successful, or a negative return error code if an error occurred.
NoteNote: The Default Server Connection Mode is ausAutomaticAccept.
NoteNote: This function is used for Bluetooth devices operating in Bluetooth Security Mode 2.



SendPassThroughCommand[edit]

Description
The following function is responsible for sending Remote Control Pass Through Commands.

Parameters
This function required one or two parameters, Commands (0 = Pause, 1 = Play, 2 = Stop, 3 = Vol. Up, 4 = Vol. Down, 5 = Specify Command with value parameter (the second parameter)).

Possible Return Values
(0) Successful
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-103) BTPS_ERROR_FEATURE_NOT_AVAILABLE
(-2000) BTAUD_ERROR_INVALID_PARAMETER
(-2001) BTAUD_ERROR_NOT_INITIALIZED
(-2002) BTAUD_ERROR_INVALID_BLUETOOTH_STACK_ID
(-2004) BTAUD_ERROR_INSUFFICIENT_RESOURCES
(-2023) BTAUD_ERROR_UNABLE_TO_SEND_REMOTE_CONTROL_COMMAND
(-2025) BTAUD_ERROR_REMOTE_DEVICE_NOT_CONNECTED
(-2026) BTAUD_ERROR_REMOTE_CONTROL_NOT_CONNECTED
(-2033) BTAUD_ERROR_REMOTE_CONTROL_ROLE_NOT_INITIALIZED

API Call
AUD_Send_Remote_Control_Command(BluetoothStackID, ConnectedBD_ADDR, &RemoteControlCommandData, 0)
AUD_Send_Remote_Control_Command(BluetoothStackID, ConnectedBD_ADDR, &RemoteControlCommandData, DEFAULT_PASS_THROUGH_COMMAND_TIMEOUT)

API Prototype
int BTPSAPI AUD_Send_Remote_Control_Command(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, AUD_Remote_Control_Command_Data_t *RemoteControlCommandData, unsigned long ResponseTimeout)

Description of API
The following function is responsible for sending the specified Remote Control Command to the remote device.This function accepts as input the Bluetooth stack ID of the Bluetooth protocol stack that the requested Audio Manager is present, followed by the Bluetooth device address of the device that is to receive the command, followed by the Remote Control information itself. The final parameter represents the Timeout value (in milliseconds) to wait for a response (confirmation) from the remote device.
This function returns a positive (non-zero) return value if successful which represents the internal Transaction ID of the Remote Control Command. This ID can be used to match responses (confirmations) with outgoing commands.This function returns a negative return error code if there was an error.
NoteNote: Currently this function is ONLY applicable for local SNK devices (i.e. if there is a SRC connected and no SNK connected then this call will fail).
NoteNote: Specifying a Timeout of zero will cause the Audio Manager to not track the command (and thus, not dispatch a response/confirmation event).

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 TI Bluetooth Stack AUDDemo 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 TI Bluetooth Stack AUDDemo 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 TI Bluetooth Stack AUDDemo App here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article CC256x TI Bluetooth Stack AUDDemo App here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article CC256x TI Bluetooth Stack AUDDemo App here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article CC256x TI Bluetooth Stack AUDDemo App here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article CC256x TI Bluetooth Stack AUDDemo 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 TI Bluetooth Stack AUDDemo App here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article CC256x TI Bluetooth Stack AUDDemo 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