NOTICE: The Processors Wiki will End-of-Life in December of 2020. 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 PBAPDemo App

From Texas Instruments Wiki
Jump to: navigation, search

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

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 Tiva, MSP432 or STM32F4 Platforms.

This demo allows users to evaluate TI's CC256x Bluetooth device by using the Tiva DK-TM4C129X, MSP432 or STM32F4. The Phone Book Access Profile (PBAP) sample application code is provided to enable a rich out-of-box experience to the user. The application allows the user to use a console to send Bluetooth commands, setup a Bluetooth Device to accept connections, connect to a remote Bluetooth device and communicate over Bluetooth.

It is recommended that the user visits the kit setup Getting Started Guide for TIVA, 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 Tiva Virtual COM Port (COM x), 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 using Reset S3 button and you should see the stack getting initialized on the terminal and the help screen will be displayed, which shows all of the commands.


Initial Screen of PBAP application


Demo Application[edit]

This section provides a description of how to use the demo application to connect two configured board and communicate over Bluetooth. Bluetooth PBAP is a simple Client-Server connection process. We will setup one of the boards as a Server and the other board as a Client. We will then initiate a connection from the Client to the Server. Once connected, we can transmit data between the two devices over Bluetooth.


Server setup on the demo application[edit]

a) We will setup the first board as a Server. Perform the steps mentioned earlier in Running the Bluetooth Code section to initialize the application. Once initialized, note the Bluetooth address of the Server. We will later use this to initiate a connection from the Client.
b) On the Choose mode> prompt, issue the Server command.
c) You will see a list of all possible commands at this time for a Server. You can see this list at any time by entering Help at the Server> prompt.
d) Now we are ready to open a Server. To open a Server, at the Server> prompt, issue the Open 1. You can replace 1 with any number between 1 and 30, as long as there is no Server open on that port. Once you see PBAP_Register_Server_SDP_Record() success, you have a PBAP Server open on port 1.
Server Setup


Client setup and device discovery on the demo application[edit]

e) We will setup the second board as a Client. Perform the steps mentioned earlier in "Running the Bluetooth Code" section to initialize the application. On the Choose mode> prompt, enter Client.
f) You will see a list of all possible commands at this time for a Client. You can see this list at any time by issuing the Help at the Client> prompt.
g) At the Client> prompt, issue the Inquiry command. This will initiate the Inquiry process. Once it is complete, you will get a list of all discovered devices.
h) You can access this list any time by issuing the DisplayInquiryList at the Client prompt.
Client Setup


Initiating connection from the Client[edit]

i) Note the index number of the first board that was configured as a Server. [If the list is not on the screen, issue DisplayInquiryList command on the Client to display the list of discovered devices again.]
j) Issue a Open <index number> <Server port number> command at the command prompt.

NoteNote: Port 19 must be used when connecting to Android phones and port 13 for IPhones.

k) Wait for the PBAP Open confirmation.
l) When a Client successfully connects to a Server, the Server will see the open indication.
Client Connection


Server Connection



Data Transfer between Client and Server[edit]

m) Now we have a PBAP connection established and both devices are ready to transmit data to each other.
n) We can Set Directories and Pull Phonebooks from Client by issuing the SetPhonebook <Path Change> <Path Name> and PullPhonebook <Max List Count> <List Start Offset> <Phonebook Path> commands.
Client Connection
O) We can also get vCardListings and individual vCard Entries by issuing the PullvCardList <Max List Count> <List Start Offset> <Phonebook Path> and PullvCardEntry <vCard Name>
Client Connection
Client Connection

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.

An overview of the application and other applications can be read at the Getting Started Guide for TIVA M4, Getting Started Guide for MSP432 and Getting Started Guide for STM32F4.

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.

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.



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

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



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



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


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



SetBaudRate[edit]

Description
The SetBaudRate command is responsible for changing the current Baud Rate used to talk to the Radio. This function ONLY configures the Baud Rate for a TI Bluetooth chipset. This command requires that a valid Bluetooth Stack ID exists.

Parameters
This command requires one parameter. The value is an integer representing a value used for the Baud Rate. The options are 0 (for Baud Rate of 115200), 1 (for Baud Rate 230400), 2 (for Baud Rate 460800), 3 (for Baud Rate 921600), 4 (for Baud Rate 1843200), or 5 (for Baud Rate 3686400). The maximum baud rate default is 921600 so options 4 and 5 are disable.

Command Call Examples
"SetBaudRate 0" Attempts to set the Baud Rate to 115200.
"SetBaudRate 1" Attempts to set the Baud Rate to 230400.
"SetBaudRate 2" Attempts to set the Baud Rate to 460800.
"SetBaudRate 3" Attempts to set the Baud Rate to 921600.

Possible Return Values
(0) Successfully Set Baud Rate
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID

API Call
HCI_Reconfigure_Driver(BluetoothStackID, FALSE, &(Data.DriverReconfigureData));

API Prototype
int BTPSAPI HCI_Reconfigure_Driver(unsigned int BluetoothStackID,Boolean_t ResetStateMachines,HCI_Driver_Reconfigure_Data_t *DriverReconfigureData);

Description of API
This function issues the appropriate call to an HCI driver to request the HCI Driver to reconfigure itself with the corresponding configuration information.




MemoryUsage (QueryMemory)[edit]

Description
The MemoryUsage command is responsible for querying the memory usage. This function will return zero.

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

Possible Return Values
The return value is always 0

Phone Book Access Profile Commands[edit]

Open (OpenServer)[edit]

Description
The following function is responsible for creating a local PBAP Server. This function returns zero if successful and a negative value if an error occurred.

Parameters
The command only requires one parameter. This parameter is the Port Number.

Command Call Examples
"Open 1" Attempts to Open a PBA Port Server at Port Number #1".


Possible Return Values

(0)PBAP_Register_Server_SDP_Record
(-4) FUNCTION_ERROR
(-9) UNABLE_TO_REGISTER_SERVER
(-67) BTPS_ERROR_RFCOMM_NOT_INITIALIZED
(-85) BTPS_ERROR_SPP_NOT_INITIALIZED
(-1000) BTPBAP_ERROR_INVALID_PARAMETER
(-1001) BTPBAP_ERROR_NOT_INITIALIZED
(-1002) BTPBAP_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTPBAP_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTPBAP_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTPBAP_ERROR_REQUEST_ALREADY_OUTSTANDING
(-1006) BTPBAP_ERROR_ACTION_NOT_ALLOWED
API Call
PBAP_Open_Server_Port(BluetoothStackID, TempParam->Params[0].intParam, (PBAP_SUPPORTED_REPOSITORIES_LOCAL_PHONEBOOK), PBAP_Event_Callback_Server, 0)

API Prototype
int BTPSAPI PBAP_Open_Server_Port(unsigned int BluetoothStackID, unsigned int ServerPort, Byte_t SupportedRepositories, PBAP_Event_Callback_t EventCallback, unsigned long CallbackParameter)

Description of API
The following function is responsible for opening a local PBAP Server. The first parameter is the Bluetooth Stack ID on which to open the Server. The second parameter is the Port on which to open this Server, and *MUST* be between PBAP_PORT_NUMBER_MINIMUM and PBAP_PORT_NUMBER_MAXIMUM. The third parameter is a bitmask which determines which repositories are supported by this Server instance. The fourth parameter is the Callback function to call when an event occurs on this Server Port. The final parameter is a user-defined callback parameter that will be passed to the callback function with each event. 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 PBAP Profile ID that can be used to reference the Opened PBAP Profile Server Port in ALL other PBAP Server functions in this module. Once an PBAP Profile Server is opened, it can only be Un-Registered via a call to the PBAP_Close_Server() function (passing the return value from this function).



Close[edit]

Description
The following function is responsible for deleting a local PBAP Server that was created via a successful call to the OpenServer() function. This function returns zero if successful and a negative value if an error occurred.

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

Possible Return Values
(0) Successfully Closed Server
(-4) FUNCTION_ERROR
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-67) BTPS_ERROR_RFCOMM_NOT_INITIALIZED
(-85) BTPS_ERROR_SPP_NOT_INITIALIZED
(-1000) BTPBAP_ERROR_INVALID_PARAMETER
(-1001) BTPBAP_ERROR_NOT_INITIALIZED
(-1002) BTPBAP_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTPBAP_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTPBAP_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTPBAP_ERROR_REQUEST_ALREADY_OUTSTANDING
(-1006) BTPBAP_ERROR_ACTION_NOT_ALLOWED

API Call
PBAP_Close_Server_Port(BluetoothStackID, PBAPID);

API Prototype
int BTPSAPI PBAP_Close_Server_Port(unsigned int BluetoothStackID, unsigned int PBAPID)

Description of API
The following function is responsible for closing a PBAP Profile Server (which was opened by a successful call to the PBAP_Open_Server_Port() function). The first parameter is the Bluetooth Stack ID of the previously opened Server port. The second parameter is the PBAP ID returned from the previous call to PBAP_Open_Server_Port(). 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.



Client Commands

Open(OpenRemoteServer)[edit]

Description
The following function is responsible for initiating a connection with a Remote PBAP Server. This function returns zero if successful and a negative value if an error occurred.

Parameters
The command takes two parameters to work. The first is the Inquiry Index which can be found using the DisplayInquiryList command after an Inquiry has been completed. The second is the RFCOMM Server Port which will be used to open a Remote PBAP Port.

Command Call Examples
"Open 12 4" Attempts to Open a Remote PhoneBook Port Server with the Remote Bluetooth Device whose address is found at the twelfth Inquiry Index using RFCOMM Server Port #4."
"Open 1 1" Attempts to Open a Remote PhoneBook Port Server with the Remote Bluetooth Device whose address is found at the first Inquiry Index using RFCOMM Server Port #1."
"Open 19 3" Attempts to Open a Remote PhoneBook Port Server with the Remote Bluetooth Device whose address is found at the nineteenth Inquiry Index using RFCOMM Server Port #3. "



Possible Return Values
(0) PBAP_Open_Remote_Server_Port: Function Successful
(-67) BTPS_ERROR_RFCOMM_NOT_INITIALIZED
(-72) BTPS_ERROR_RFCOMM_UNABLE_TO_CONNECT_TO_REMOTE_DEVICE
(-73) BTPS_ERROR_RFCOMM_UNABLE_TO_COMMUNICATE_WITH_REMOTE_DEVICE
(-85) BTPS_ERROR_SPP_NOT_INITIALIZED
(-1000) BTPBAP_ERROR_INVALID_PARAMETER
(-1001) BTPBAP_ERROR_NOT_INITIALIZED
(-1002) BTPBAP_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTPBAP_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTPBAP_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTPBAP_ERROR_REQUEST_ALREADY_OUTSTANDING
(-1006) BTPBAP_ERROR_ACTION_NOT_ALLOWED

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

API Prototype
int BTPSAPI PBAP_Open_Remote_Server_Port(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, unsigned int ServerPort, PBAP_Event_Callback_t EventCallback, unsigned long CallbackParameter)

Description of API
The following function is responsible for opening a connection to a remote PBAP Server. The first parameter is the Bluetooth Stack ID of the local Bluetooth stack. The second parameter is the remote Bluetooth Device Address of the Bluetooth PBAP Profile Server with which to connect. The third parameter specifies the remote Server port with which to connect. The final two parameters specify the PBAP Profile Event Callback Function and the Callback Parameter to associate with this PBAP Profile Client. The ServerPort parameter *MUST* be between PBAP_PORT_NUMBER_MINIMUM and PBAP_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 PBAP ID that can be used to reference the remote opened PBAP Profile Server in ALL other PBAP Profile Client functions in this module. Once a remote Server is opened, it can only be closed via a call to the PBAP_Close_Connection() function (passing the return value from this function).



Close(CloseConnection)[edit]

Description
The following function is responsible for terminating a connection with a remote PBAP Client or Server. This function returns zero if successful and a negative value if an error occurred.

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


Possible Return Values
(0) PBAP_Open_Remote_Server_Port: Function Successful
(-4) FUNCTION_ERROR
(-67) BTPS_ERROR_RFCOMM_NOT_INITIALIZED
(-73) BTPS_ERROR_RFCOMM_UNABLE_TO_COMMUNICATE_WITH_REMOTE_DEVICE
(-85) BTPS_ERROR_SPP_NOT_INITIALIZED
(-1000) BTPBAP_ERROR_INVALID_PARAMETER
(-1001) BTPBAP_ERROR_NOT_INITIALIZED
(-1002) BTPBAP_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTPBAP_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTPBAP_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTPBAP_ERROR_REQUEST_ALREADY_OUTSTANDING
(-1006) BTPBAP_ERROR_ACTION_NOT_ALLOWED

API Call
PBAP_Close_Connection(BluetoothStackID, PBAPID);

API Prototype
BTPSAPI PBAP_Close_Connection(unsigned int BluetoothStackID, unsigned int PBAPID)

Description of API
The following function is responsible for closing a currently ongoing PBAP Profile connection. The first parameter is the Bluetooth Stack ID of the Bluetooth Protocol Stack Instance that is associated with the PBAP Profile connection being closed. The second parameter to this function is the PBAP ID of the PBAP Profile connection to be closed. This function returns zero if successful, or a negative return value if there was an error.

  • NOTE * If this function is called with a Server PBAP ID (a value returned from a call to PBAP_Open_Server_Port()) any clients currently connected to this Server will be terminated, but the Server will remained open and registered. If this function is called using a Client PBAP ID (a value returned from a call to PBAP_Open_Remote_Server_Port()), the Client connection will be terminated/closed entirely.



OBEXDisconnect[edit]

Description
The following function is responsible for terminating a connection with a remote PBAP Server by issuing an OBEX Disconnect. This function returns zero if successful and a negative value if an error occurred.

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



Possible Return Values
(0) PBAP_Disconnect_Request: Function Successful
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-73) BTPS_ERROR_RFCOMM_UNABLE_TO_COMMUNICATE_WITH_REMOTE_DEVICE
(-1000) BTPBAP_ERROR_INVALID_PARAMETER
(-1001) BTPBAP_ERROR_NOT_INITIALIZED
(-1002) BTPBAP_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTPBAP_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTPBAP_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTPBAP_ERROR_REQUEST_ALREADY_OUTSTANDING
(-1006) BTPBAP_ERROR_ACTION_NOT_ALLOWED

API Call
PBAP_Disconnect_Request(BluetoothStackID, PBAPID);

API Prototype
int BTPSAPI PBAP_Disconnect_Request(unsigned int BluetoothStackID, unsigned int PBAPID)

Description of API
The following function is responsible for sending an Disconnect Request to the remote device/entity. The first parameter to this function is the Bluetooth Stack ID of the Bluetooth Protocol Stack Instance that is associated with the PBAP Profile connection being disconnected. The second parameter to this function is the PBAP ID of the PBAP Profile connection to be disconnected (that was returned by a call to PBAP_Open_Remote_Server_Port()). This function returns zero if successful, or a negative return value if there was an error.

  • NOTE * Use of this function is optional and is provided for full compliance with some OBEX applications. Calling the PBAP_Close_Connection() function will achieve the same results without sending the OBEX disconnect packet beforehand. If is also possible to call this function and then immediately call PBAP_Close_Connection() without waiting for a confirmation because a Disconnect Request cannot be failed. Calling this function by itself and waiting for a response will cause the underlying connection to automatically be closed once the response is received. This will generate a Close Port Indication.



PullPhonebook[edit]

Description
The following function is responsible for issuing a PBAP Pull Phonebook Request with a remote PBAP Server. This function returns zero if successful and a negative value if an error occurred.

Parameters
The command requires 3 parameters, the Max List Count, the List Start Offset and the Phonebook Path.

Command Call Examples
"PullPhonebook 65535 0 telecom/pb.vcf has 65535 as the Max List Count, 0 as the List Start Offset and telecom/pb.vcf as the Phonebook Path.

Possible Return Values
(0) PBAP_Pull_Phonebook_Request: Function Successful
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) BTPBAP_ERROR_INVALID_PARAMETER
(-1001) BTPBAP_ERROR_NOT_INITIALIZED
(-1002) BTPBAP_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTPBAP_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTPBAP_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTPBAP_ERROR_REQUEST_ALREADY_OUTSTANDING
(-1006) BTPBAP_ERROR_ACTION_NOT_ALLOWED

API Call
PBAP_Set_Phonebook_Request(BluetoothStackID, PBAPID, (PBAP_Set_Path_Option_t)TempParam->Params[0].intParam, TempParam->Params[1].strParam);

API Prototype
int BTPSAPI PBAP_Pull_Phonebook_Request(unsigned int BluetoothStackID, unsigned int PBAPID, char *ObjectName, DWord_t FilterLow, DWord_t FilterHigh, PBAP_Format_t Format, Word_t MaxListCount, Word_t ListStartOffset)

Description of API

The following function generates a PBAP Pull Phonebook Request to the specified remote PBAP Server. The BluetoothStackID parameter the ID of the Bluetooth Stack that is associated with this PBAP Client. The PBAPID parameter specifies the PBAP ID for the local PBAP Client (returned from a successful call to the PBAP_Connect_Remote_Server_Port() function). The ObjectName parameter contains the Name/Path of the Phonebook being requested by this Pull Phonebook operation. The FilterLow parameter contains the lower 32 bits of the 64-bit filter attribute. The FilterHigh parameter contains the higher 32 bits of the 64-bit filter attribute. The Format parameter is an enumeration which specifies the vCard format requested in this Pull Phonebook request. If pfDefault is specified then the format will not be included in the request (note that the Server will default to pfvCard21 in this case). The MaxListCount parameter is an unsigned integer that specifies the maximum number of entries the Client can handle. A value of 65535 means that the number of entries is not restricted. A MaxListCount of ZERO (0) indicates that this is a request for the number of used indexes in the Phonebook specified by the ObjectName parameter. The ListStartOffset parameter specifies the index requested by the Client in this PullPhonebookRequest. This function returns zero if successful or a negative return error code if there was an error.

  • NOTE * A successful return code does not mean that the remote PBAP Profile Server successfully processed the command. The caller needs to check the confirmation result to determine if the remote PBAP Profile Server successfully executed the Request.
  • NOTE * There can only be one outstanding PBAP Profile Request active at any one time. Because of this, another PBAP Profile Request cannot be issued until either the current request is Aborted (by calling the PBAP_Abort_Request() function) or the current Request is completed (this is signified by receiving a Confirmation Event in the PBAP Profile Event Callback that was registered when the PBAP Profile Port was opened).



SetPhonebook[edit]

Description
The following function is responsible for issuing a PBAP Set Phonebook Request with a remote PBAP Server. This function returns zero if successful and a negative value if an error occurred.

Parameters
This functions requires two parameters; the path change requested and the path name. E.g If down is selected as the path option then we require an additional paramters which is the path.

Command Call Examples
"SetPhonebook 1 telecom goes down a level to the telecom folder.

Possible Return Values
(0) PBAP_Set_Phonebook_Request: Function Successful
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) BTPBAP_ERROR_INVALID_PARAMETER
(-1001) BTPBAP_ERROR_NOT_INITIALIZED
(-1002) BTPBAP_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTPBAP_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTPBAP_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTPBAP_ERROR_REQUEST_ALREADY_OUTSTANDING
(-1006) BTPBAP_ERROR_ACTION_NOT_ALLOWED

API Call
PBAP_Set_Phonebook_Request(BluetoothStackID, PBAPID, (PBAP_Set_Path_Option_t)TempParam->Params[0].intParam, TempParam->Params[1].strParam);

API Prototype
int BTPSAPI PBAP_Set_Phonebook_Request(unsigned int BluetoothStackID, unsigned int PBAPID, PBAP_Set_Path_Option_t PathOption, char *ObjectName)

Description of API
The following function generates a PBAP Set Phonebook Request to the specified remote PBAP Server. The BluetoothStackID parameter the ID of the Bluetooth Stack that is associated with this PBAP Client. The PBAPID parameter specifies the PBAP ID for the local PBAP Client (returned from a successful call to the PBAP_Connect_Remote_Server_Port() function). The PathOption parameter contains an enumerated value that indicates the type of path change to request. The ObjectName parameter contains the folder name to include with this Set Phonebook request. This value can be NULL if no name is required for the selected PathOption. See the PBAP specification for more information. This function returns zero if successful or a negative return error code if there was an error.

  • NOTE * A successful return code does not mean that the remote PBAP Profile Server successfully processed the command. The caller needs to check the confirmation result to determine if the remote PBAP Profile Server successfully executed the Request.
  • NOTE * There can only be one outstanding PBAP Profile Request active at any one time. Because of this, another PBAP Profile Request cannot be issued until either the current request is Aborted (by calling the PBAP_Abort_Request() function) or the current Request is completed (this is signified by receiving a Confirmation Event in the PBAP Profile Event Callback that was registered when the PBAP Profile Port was opened).



PullvCardList[edit]

Description
The following function is responsible for issuing a PBAP Pull vCARD Listing Request with a remote PBAP Server. This function returns zero if successful and a negative value if an error occurred.

Parameters
The command requires 3 parameters, the Max List Count, the List Start Offset and the Phonebook Path.



Command Call Examples
"PullPhonebook 65535 0 pb has 65535 as the Max List Count, 0 as the List Start Offset and pb as the Phonebook Path. "

Possible Return Values
(0) PBAP_Pull_vCard_Listing_Request: Function Successful
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) BTPBAP_ERROR_INVALID_PARAMETER
(-1001) BTPBAP_ERROR_NOT_INITIALIZED
(-1002) BTPBAP_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTPBAP_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTPBAP_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTPBAP_ERROR_REQUEST_ALREADY_OUTSTANDING
(-1006) BTPBAP_ERROR_ACTION_NOT_ALLOWED

API Call
PBAP_Pull_vCard_Listing_Request(BluetoothStackID, PBAPID, Phonebook, loDefault, saDefault, NULL, (Word_t)TempParam->Params[0].intParam, (Word_t)TempParam->Params[1].intParam);

API Prototype
int BTPSAPI PBAP_Pull_vCard_Listing_Request(unsigned int BluetoothStackID, unsigned int PBAPID, char *ObjectName, PBAP_List_Order_t ListOrder, PBAP_Search_Attribute_t SearchAttribute, char *SearchValue, Word_t MaxListCount, Word_t ListStartOffset)

Description of API
The following function generates a PBAP Pull vCard Listing Request to the specified remote PBAP Server. The BluetoothStackID parameter the ID of the Bluetooth Stack that is associated with this PBAP Client. The PBAPID parameter specifies the PBAP ID for the local PBAP Client (returned from a successful call to the PBAP_Connect_Remote_Server_Port() function). The ObjectName parameter contains the folder of the Phonebook being requested by this Pull vCard Listing operation. This value can be NULL if a PhonebookSize request is being performed. The ListOrder parameter is an enumerated type that determines the optionally requested order of the listing. Using the 'loDefault' value for this parameter will prevent this field from being added to the request (note that the Server will default to loIndexed in this case). The SearchAttribute is an enumerated type that determines the optionally requested attribute used to filter this request. Using the 'saDefault' value for this parameter will prevent this field from being added to the request (note that the Server will default to saIndexed in this case). The SearchValue parameter contains an optional ASCII, Null-terminated character string that contains the string requested for search/filter. If this parameter is NULL, this field will be excluded from the request. The MaxListCount parameter is an unsigned integer that specifies the maximum number of list entries the Client can handle. A value of 65535 means that the number of entries is not restricted. A MaxListCount of ZERO (0) indicates that this is a request for the number of used indexes in the Phonebook specified by the ObjectName parameter. The ListStartOffset parameter specifies the index requested by the Client in this Pull vCard Listing. This function returns zero if successful or a negative return error code if there was an error.

  • NOTE * A successful return code does not mean that the remote PBAP Profile Server successfully processed the command. The caller needs to check the confirmation result to determine if the remote PBAP Profile Server successfully executed the Request.
  • NOTE * There can only be one outstanding PBAP Profile Request active at any one time. Because of this, another PBAP Profile Request cannot be issued until either the current request is Aborted (by calling the PBAP_Abort_Request() function) or the current Request is completed (this is signified by receiving a Confirmation Event in the PBAP Profile Event Callback that was registered when the PBAP

Profile Port was opened).



PullvCARDEntry[edit]

Description
The following function is responsible for issuing a PBAP Pull vCARD Entry Request with a remote PBAP Server. This function returns zero if successful and a negative value if an error occurred.

Parameters
This function requires only one parameters, the vCard Name.

Command Call Examples
"PullvCARDEntry 0.vcf pulls the vcf file named 0."

Possible Return Values
(0) PBAP_Pull_vCard_Entry_Request: Function Successful
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) BTPBAP_ERROR_INVALID_PARAMETER
(-1001) BTPBAP_ERROR_NOT_INITIALIZED
(-1002) BTPBAP_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTPBAP_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTPBAP_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTPBAP_ERROR_REQUEST_ALREADY_OUTSTANDING
(-1006) BTPBAP_ERROR_ACTION_NOT_ALLOWED

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

API Prototype
int BTPSAPI PBAP_Pull_vCard_Entry_Request(unsigned int BluetoothStackID, unsigned int PBAPID, char *ObjectName, DWord_t FilterLow, DWord_t FilterHigh, PBAP_Format_t Format)

Description of API
The following function generates a PBAP Pull vCard Entry Request to the specified remote PBAP Server. The BluetoothStackID parameter the ID of the Bluetooth Stack that is associated with this PBAP Client. The PBAPID parameter specifies the PBAP ID for the local PBAP Client (returned from a successful call to the PBAP_Connect_Remote_Server_Port() function). The ObjectName parameter contains the name of the Phonebook entry being requested by this Pull vCard Entry operation. The FilterLow parameter contains the lower 32 bits of the 64-bit filter attribute. The FilterHigh parameter contains the higher 32 bits of the 64-bit filter attribute. The Format parameter is an enumeration which specifies the vCard format requested in this Pull vCard Entry request. If pfDefault is specified then the format will not be included in the request (note that in this case the Server will default to pfvCard21 in this case). This function returns zero if successful or a negative return error code if there was an error.

  • NOTE * A successful return code does not mean that the remote PBAP Profile Server successfully processed the command. The caller needs to check the confirmation result to determine if the remote PBAP Profile Server successfully executed the Request.
  • NOTE * There can only be one outstanding PBAP Profile Request active at any one time. Because of this, another PBAP Profile Request cannot be issued until either the current request is Aborted (by calling the PBAP_Abort_Request()function) or the current Request is completed (this is signified by receiving a Confirmation Event in the PBAP Profile Event Callback that was registered when the PBAP

Profile Port was opened).



Abort[edit]

Description
The following function is responsible for issuing an Abort with a remote PBAP Server by issuing an OBEX Abort Command. This function returns zero if successful and a negative value if an error occurred.

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

Possible Return Values
(0) PBAP_Abort_Request: Function Successful
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-1000) BTPBAP_ERROR_INVALID_PARAMETER
(-1001) BTPBAP_ERROR_NOT_INITIALIZED
(-1002) BTPBAP_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1003) BTPBAP_ERROR_LIBRARY_INITIALIZATION_ERROR
(-1004) BTPBAP_ERROR_INSUFFICIENT_RESOURCES
(-1005) BTPBAP_ERROR_REQUEST_ALREADY_OUTSTANDING
(-1006) BTPBAP_ERROR_ACTION_NOT_ALLOWED

API Call
PBAP_Abort_Request(BluetoothStackID, PBAPID);

API Prototype
int BTPSAPI PBAP_Abort_Request(unsigned int BluetoothStackID, unsigned int PBAPID)

Description of API
The following function is responsible for Aborting ANY currently outstanding PBAP Profile Client Request. The first parameter is the Bluetooth Stack ID of the Bluetooth Stack for which the PBAP Profile Client is valid. The second parameter to this function specifies the PBAP ID (returned from a successful call to the PBAP_Open_Remote_Server_Port() function). This function returns zero if successful, or a negative return error code if there was an error.

  • NOTE * There can only be one outstanding PBAP Profile Request active at any one time. Because of this, another PBAP Profile Request cannot be issued until either the current request is Aborted (by calling the PBAP_Abort_Request() function) or the current Request is completed (this is signified by receiving a Confirmation Event in the PBAP Profile Event Callback that was registered when the PBAP

Profile Port was opened).

  • NOTE * Because of transmission latencies, it may be possible that a PBAP Profile Client Request that is to be aborted may have completed before the Server was able to Abort the request. In either case, the caller will be notified via PBAP Profile Callback of the status of the previous Request.



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 PBAPDemo 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 PBAPDemo 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 PBAPDemo 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 PBAPDemo 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 PBAPDemo 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 PBAPDemo 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 PBAPDemo 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 PBAPDemo 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 PBAPDemo 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