Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

CC256x TI Bluetooth Stack ANPDemo App

From Texas Instruments Wiki
Jump to: navigation, search

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

Return to CC256x Tiva TI’s Bluetoth 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

Contents

Demo Overview

NoteNote: : The same instructions can be used to run this demo on the Tiva, MSP432 or STM32F4 Platforms.

The Alert Notification profile allows a Client device to get alerts of different types (like Email, SMS, Voicemail) and also have separate counts of new and unread Alerts. There are two roles defined in this profile. The first is the the Server, which is typically a Bluetooth enabled phone that transmits these alerts. The second is the Client which can be a device like a smart watch, an auxillary display or even a tablet that gets an alert everytime an event happens on the Server.

This application allows the user to use a console to use Bluetooth Low Energy (BLE) to establish connection between two BLE devices, notify new and unread alerts and change the supported alert categories for new and unread alerts.

It is recommended that the user visits the kit setup Getting Started Guide for MSP430, 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

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 MSP-EXP430F5438 USB - Serial Port (COM x), 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 (9600 for MSP430), 8, n, 1. Once connected, reset the device using Reset S3 button (located next to the mini USB connector for the MSP430) 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.

ANS1.png

Demo Application

The demo application provides a description on how to use the demo application to connect two configured boards and communicate over BluetoothLE. The included application registers a custom service on a board when the stack is initialized.

Device 1 (Server) setup on the demo application


a) To start, one of the devices has to have the Alert Notification Service running on it. It can be started by running Register ANS.
b) Next, the device acting as a Server needs to advertise to other devices. This can be done by running AdvertiseLE 1.

ANS2.png


Device 2 (Client) setup on the demo application

NoteNote: : Steps c and d are optional if you already know the Bluetooth address of the device that you want to connect to.


c) The Client LE device can try to find which LE devices are in the vicinity using the command: StartScanning.


d) Once you have found the device, you can stop scanning by using the command: StopScanning.
ANS3.png


Initiating connection from device 2

e) Once the application on the Client side knows the Bluetooth address of the device that is advertising, it can connect to that device using the command: ConnectLE <Bluetooth Address>

ANS4.png


Identify supported services

f) After initialization, the Client needs to find out whether ANS services are supported and what ANS features are available. For this, DiscoverANS is run on the Client. After the service discovery operation is complete, the ANS Service Discovery Summary is shown and list of supported features is shown.

ANS5.png


g) After getting the list of supported features, the next step is to configure the ANS on the Client. We can have support for either New Alerts, Unread Alerts or both.

ANS6.png


h) In our case, we configure it with both New and Unread Alerts enabled.

ANS7.png


Alert Notification between Client and Server

i) After configuration, the Alert Notification system is active. To send alerts, first the New and Unread alerts need to be enabled on the Client. For this, EnableNewAlertNotifications and EnableUnreadAlertNotifications is used.

j) For the EnableNewAlertNotifications command, the following are the list of options. We can enable either one or all of the options.

ANS8.png


k) In our case, we enable all of them at the same time.

ANS9.png


l) Similarly, one can enable either one or all of the options for EnableUnreadAlertNotifications. In our case we enable all of them.

ANS10.png


m) After enabling the Alert notifications on the Client side, we can use NotifyNewAlerts to notify the Client from the Server side. NotifyNewAlerts has options similar to the previous menu but the accompanying parameter is a bit field and not a numerical option. For example, to send a Simple Alert we would send NotifyNewAlerts 1. To send an Email Alert, we would send NotifyNewAlerts 2 and to send a New Alert, we would send NotifyNewAlerts 4. If we wanted to send both an Email and a Simple Alert we would send NotifyNewAlerts 3.


ANS11.png


n) In our case we send a simple alert for email. Once it's complete, it shows Success.

ANS12.png


o) On the Client side, it recieves the alert from the sender and it shows New Alert Status with the category of Alert (Simple in our case) and the number of alerts (New Simple Alerts which is zero in our case).

ANS13.png

p) NotifyUnreadAlerts like NotifyNewAlerts has the accompanying parameter as a bit field.

ANS14.png

q) In this example case, we send an unread email alert. Once, its transmitted it shows success on the Server side.

ANS15.png

r) And on the Client side, it recieves the alert from the sender and it shows Unread Alert Status with the category of Alert (email in our case) and the number of alerts (Unread Emails, which is zero in our case).

ANS16.png

We can also get and set the New and Unread Alerts for the different categories, get and set the Supported categories for New and Unread Alerts, Enable and Disable New and Unread Alert notifications and Notify Immediately New and Unread Alerts.


Application Commands

TI’s Bluetooth stack is implementation of the upper layers of the Bluetooth protocol stack. TI’s Bluetooth stackprovides 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.

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.

GAP Commands

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)

Description
The Help command is responsible for displaying the current Command Options for either Serial Port Client or Serial Port Server. The input parameter to this command is completely ignored, and only needs to be passed in because all Commands that can be entered at the Prompt pass in the parsed information. This command displays the current Command Options that are available and always returns 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
This command always returns 0



GetLocalAddress

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

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



SetDiscoverabilityMode

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. The Discoverability Mode in LE is only applicable when advertising, if a device is not advertising it is not discoverable. The value set by this command will be used as a parameter in the command AdvertiseLE.

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 Parameter
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR



SetConnectabilityMode

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. The Connectability Mode in LE is only applicable when advertising, if a device is not advertising it is not connectable. The value set by this command will be used as a parameter in the command AdvertiseLE.

Parameters
This command requires only one parameter which is an integer value that represents a Connectability 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 Parameter
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR



SetPairabilityMode

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.

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 Pairable with Secure Simple Pairing).

Command Call Examples
“SetPairabilityMode 0” Attempts to set the Local Device’s Pairability Mode to Non-Pairable. “SetPairabilityMode 1” Attempts to set the Local Device’s Pairability Mode to Pairable.

Possible Return Values
(0) Successfully Set Pairability Mode
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR

API Call
GAP_LE_Set_Pairability_Mode(BluetoothStackID, PairabilityMode);

API Prototype
int BTPSAPI GAP_LE_Set_Pairability_Mode(unsigned int BluetoothStackID, GAP_LE_Pairability_Mode_t PairableMode);

Description of API
This function is provided to allow the local host the ability to change the pairability mode used by the local host. This function will return zero if successful or a negative return error code if there was an error condition.



ChangePairingParameters

Description
The ChangePairingParameters command is responsible for changing the LE Pairing Parameters that are exchanged during the Pairing procedure. This command returns zero on successful execution and a negative value on all errors.

Parameters
This command requires five parameters which are the I/O Capability, the Bonding Type, the MITM Requirement, the SC Enable and the P256 debug mode.
The first parameter must be specified as 0 (for Display Only), 1 (for Display Yes/No), 2 (for Keyboard Only), 3 (for No Input/Output) or 4 (for Keyboard/Display).
The second parameter must be specified as 0 (for No Bonding) or 1 (for Bonding), when at least one of the devices is set to No Bonding, the LTK won't be stored.
The third parameter must be specified as 0 (for No MITM) or 1 (for MITM required).
The fourth parameter must be specified as 0 (for SC disabled) or 1 (for SC enabled), when using SC disable, legacy pairing procedure will take place.
The fifth parameter must be specified as 0 (for Debug Mode disabled) or 1 (for P256 debug mode enabled), Only when using SC pairing, P256 debug mode is relevant and when it is set, the values of the P256 private and public keys will be pre-defined according to the Bluetooth specification instead of random.

Command Call Examples
"ChangeSimplePairingParameters 3 0 0 0 0" Attempts to set the I/O Capability to No Input/Output, Bonding Type set to No Bonding, turns off MITM Protection, Disable secure connections and disable debug mode.
"ChangeSimplePairingParameters 2 0 1 1 0 " Attempts to set the I/O Capability to Keyboard Only, Bonding Type set to No Bonding, activates MITM Protection, Enabling secure connections and disable debug mode.
"ChangeSimplePairingParameters 1 1 1 1 1" Attempts to set the I/O Capability to Display Yes/No, Bonding Type set to Bonding, activates MITM Protection, Enabling secure connections and enabling debug mode.

Possible Return Values
(0) Successfully Set Pairability Mode
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR



AdvertiseLE

Description
The AdvertiseLE command is responsible for enabling LE Advertisements. This command returns zero on successful execution and a negative value on all errors.

Parameters
The only parameter necessary decides whether Advertising Reports are sent or are disabled. To Disable, use 0 as the first parameter, to enable, use 1 instead.

Command Call Examples
“AdvertiseLE 1” Attempts to enable Low Energy Advertising on the local Bluetooth device. “AdvertiseLE 0” Attempts to disable Low Energy Advertising on the local Bluetooth device.

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
(-1) BTPS_ERROR_INVALID_PARAMETER
(-56) BTPS_ERROR_GAP_NOT_INITIALIZED
(-104) BTPS_ERROR_LOCAL_CONTROLLER_DOES_NOT_SUPPORT_LE
(-57) BTPS_ERROR_DEVICE_HCI_ERROR

API Calls
Depending on the First Parameter Value
GAP_LE_Advertising_Disable(BluetoothStackID);
GAP_LE_Set_Advertising_Data(BluetoothStackID, (Advertisement_Data_Buffer.AdvertisingData.Advertising_Data[0] + 1), &(Advertisement_Data_Buffer.AdvertisingData));
GAP_LE_Set_Scan_Response_Data(BluetoothStackID, (Advertisement_Data_Buffer.ScanResponseData.Scan_Response_Data[0] + 1), &(Advertisement_Data_Buffer.ScanResponseData));
GAP_LE_Advertising_Enable(BluetoothStackID, TRUE, &AdvertisingParameters, &ConnectabilityParameters, GAP_LE_Event_Callback, 0);

API Prototypes
int BTPSAPI GAP_LE_Advertising_Disable(unsigned int BluetoothStackID);
int BTPSAPI GAP_LE_Set_Advertising_Data(unsigned int BluetoothStackID, unsigned int Length, Advertising_Data_t *Advertising_Data);
int BTPSAPI GAP_LE_Set_Scan_Response_Data(unsigned int BluetoothStackID, unsigned int Length, Scan_Response_Data_t *Scan_Response_Data);
int BTPSAPI GAP_LE_Set_Advertising_Data(unsigned int BluetoothStackID, unsigned int Length, Advertising_Data_t *Advertising_Data);
int BTPSAPI GAP_LE_Set_Advertising_Data(unsigned int BluetoothStackID, unsigned int Length, Advertising_Data_t *Advertising_Data);

Description of API
The GAP_LE_Advertising_Disable function is provided to allow the local host the ability to cancel (stop) an on-going advertising procedure. This function will return zero if successful or a negative return error code if there was an error condition. The GAP_LE_Set_Advertising_Data is provided to allow the local host the ability to set the advertising data that is used during the advertising procedure (started via the GAP_LE_Advertising_Enable function). This function will return zero if successful or a negative return error code if there was an error condition. The GAP_LE_Set_Scan_Response_Data function is provided to allow the local host the ability to set the advertising data that is used during the advertising procedure (started via the GAP_LE_Advertising_Enable function). This function will return zero if successful or a negative return error code if there was an error condition. The GAP_LE_Set_Advertising_Data function is provided to allow the local host the ability to set the advertising data that is used during the advertising procedure (started via the GAP_LE_Advertising_Enable function). This function will return zero if successful or a negative return error code if there was an error condition.



StartScanning

Description
The StartScanning command is responsible for starting an LE scan procedure. This command returns zero if successful and a negative value if an error occurred. This command calls the StartScan(unsigned int BluetoothStackID) function which performs the scan.

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

Possible Return Values
(0) Successfully started the LE Scan Procedure
(-1) Bluetooth Stack ID is Invalid during the StartScan() call
(-4) FUNCTION_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1) BTPS_ERROR_INVALID_PARAMETER
(-66) BTPS_ERROR_INSUFFICIENT_RESOURCES
(-105) BTPS_ERROR_SCAN_ACTIVE
(-56) BTPS_ERROR_GAP_NOT_INITIALIZED
(-104) BTPS_ERROR_LOCAL_CONTROLLER_DOES_NOT_SUPPORT_LE
(-57) BTPS_ERROR_DEVICE_HCI_ERROR

API Call
GAP_LE_Perform_Scan(BluetoothStackID, stActive, 10, 10, latPublic, fpNoFilter, TRUE, GAP_LE_Event_Callback, 0);

API Prototype
int BTPSAPI GAP_LE_Perform_Scan(unsigned int BluetoothStackID, GAP_LE_Scan_Type_t ScanType, unsigned int ScanInterval, unsigned int ScanWindow, GAP_LE_Address_Type_t LocalAddressType, GAP_LE_Filter_Policy_t FilterPolicy, Boolean_t FilterDuplicates, GAP_LE_Event_Callback_t GAP_LE_Event_Callback, unsigned long CallbackParameter);

Description of API
The GAP_LE_Perform_Scan function is provided to allow the local host the ability to begin an LE scanning procedure. This procedure is similar in concept to the inquiry procedure in Bluetooth BR/EDR in that it can be used to discover devices that have been instructed to advertise. This function will return zero if successful, or a negative return error code if there was an error condition.



StopScanning

Description
The StopScanning command is responsible for stopping an LE scan procedure. This command returns zero if successful and a negative value if an error occurred. This command calls the StopScan(unsigned int BluetoothStackID) function which performs the scan.

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

Possible Return Values
(0) Successfully stopped the LE Scan Procedure
(-1) Bluetooth Stack ID is Invalid during the StartScan() call
(-4) FUNCTION_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1) BTPS_ERROR_INVALID_PARAMETER
(-56) BTPS_ERROR_GAP_NOT_INITIALIZED
(-104) BTPS_ERROR_LOCAL_CONTROLLER_DOES_NOT_SUPPORT_LE
(-57) BTPS_ERROR_DEVICE_HCI_ERROR

API Call
GAP_LE_Cancel_Scan(BluetoothStackID);

API Prototype
int BTPSAPI GAP_LE_Cancel_Scan(unsigned int BluetoothStackID);

Description of API
The GAP_LE_Cancel_Scan function is provided to allow the local host the ability to cancel (stop) an on-going scan procedure. This function will return zero if successful or a negative return error code if there was an error condition.



ConnectLE

Description
The ConnectLE command is responsible for connecting to an LE device. This command returns zero if successful and a negative value if an error occurred. This command calls the ConnectLEDevice(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, Boolean_t UseWhiteList) function using ConnectLEDevice(BluetoothStackID, BD_ADDR, FALSE).

Parameters
The only parameter required is the Bluetooth Address of the remote device. This can easily be found using the StartScanning command if the advertising device is in proximity during the scan.

Command Call Examples
“ConnectLE 001bdc05b617” Attempts to send a connection request to the Bluetooth Device with the BD_ADDR of 001bdc05b617. “ConnectLE 000275e126FF” Attempts to send a connection request to the Bluetooth Device with the BD_ADDR of 000275e126FF.

Possible Return Values
(0) Successfully Set Pairability Mode
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-116) BTPS_ERROR_RANDOM_ADDRESS_IN_USE
(-111) BTPS_ERROR_CREATE_CONNECTION_OUTSTANDING
(-66) BTPS_ERROR_INSUFFICIENT_RESOURCES
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1) BTPS_ERROR_INVALID_PARAMETER
(-56) BTPS_ERROR_GAP_NOT_INITIALIZED
(-104) BTPS_ERROR_LOCAL_CONTROLLER_DOES_NOT_SUPPORT_LE
(-57) BTPS_ERROR_DEVICE_HCI_ERROR
GAP_LE_ERROR_WHITE_LIST_IN_USE

API Calls
GAP_LE_Create_Connection(BluetoothStackID, 100, 100, Result?fpNoFilter:fpWhiteList, latPublic, Result?&BD_ADDR:NULL, latPublic, &ConnectionParameters, GAP_LE_Event_Callback, 0);
(these two APIs can generally be ignored unless the WhiteList is enabled in the call to ConnectLEDevice)
GAP_LE_Remove_Device_From_White_List(BluetoothStackID, 1, &WhiteListEntry, &WhiteListChanged);
GAP_LE_Add_Device_To_White_List(BluetoothStackID, 1, &WhiteListEntry, &WhiteListChanged);

API Prototypes
int BTPSAPI GAP_LE_Create_Connection(unsigned int BluetoothStackID, unsigned int ScanInterval, unsigned int ScanWindow, GAP_LE_Filter_Policy_t InitatorFilterPolicy, GAP_LE_Address_Type_t RemoteAddressType, BD_ADDR_t *RemoteDevice, GAP_LE_Address_Type_t LocalAddressType, GAP_LE_Connection_Parameters_t *ConnectionParameters, GAP_LE_Event_Callback_t GAP_LE_Event_Callback, unsigned long CallbackParameter);
int BTPSAPI GAP_LE_Remove_Device_From_White_List( unsigned int BluetoothStackID, unsigned int DeviceCount, GAP_LE_White_List_Entry_t *WhiteListEntries, unsigned int *RemovedDeviceCount);
int BTPSAPI GAP_LE_Add_Device_To_White_List(unsigned int BluetoothStackID, unsigned int DeviceCount, GAP_LE_White_List_Entry_t *WhiteListEntries, unsigned int *AddedDeviceCount);

Description of API
The GAP_LE_Create_Connection function is provided to allow the local host the ability to create a connection to a remote device using the Bluetooth LE radio. The connection process is asynchronous in nature and the caller will be notified via the GAP LE event callback function (specified in this function) when the connection completes. This function will return zero if successful, or a negative return error code if there was an error condition. The GAP_LE_Remove_Device_From_White_List function is provided to allow the local host the ability to remove one (or more) devices from the white list maintained by the local device. This function will attempt to delete as many devices as possible (from the specified list) and will return the number of devices deleted. The GAP_LE_Read_White_List_Size function can be used to determine how many devices the local device supports in the white list (simultaneously). This function will return zero if successful, or a negative return error code if there was an error condition. The GAP_LE_Add_Device_To_White_List function is provided to allow the local host the ability to add one (or more) devices to the white list maintained by the local device. This function will attempt to add as many devices as possible (from the specified list) and will return the number of devices added. The GAP_LE_Read_White_List_Size function can be used to determine how many devices the local device supports in the white list (simultaneously). This function will return zero if successful, or a negative return error code if there was an error condition.



DisconnectLE

Description
The DisconnectLE command is responsible for disconnecting from an LE device. This command returns zero on successful execution and a negative value on all errors. This command requires that a valid Bluetooth Stack ID exists before running.

Parameters
This command required one parameter which is the Bluetooth Address of the (currently connected) remote device that is to be disconnected.

Possible Return Values
(0) Successfully disconnected remote device (-4) FUNCTION_ERROR (-8) INVALID_STACK_ID_ERROR

API Call
GAP_LE_Disconnect(BluetoothStackID, BD_ADDR);

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

API Description
The GAP_LE_Disconnect function provides the ability to disconnect from a remote device. This function will return zero if successful, or a negative return error code if there was an error condition.



PairLE

Description
The PairLE command is provided to allow a mechanism of Pairing (or requesting security if a slave) to the connected device. This command calls the SendPairingRequest(BD_ADDR_t BD_ADDR, Boolean_t ConnectionMaster) function using SendPairingRequest(ConnectionBD_ADDR, LocalDeviceIsMaster).

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

Possible Return Values
(0) Successfully Set Pairability Mode
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1) BTPS_ERROR_INVALID_PARAMETER
(-56) BTPS_ERROR_GAP_NOT_INITIALIZED
(-104) BTPS_ERROR_LOCAL_CONTROLLER_DOES_NOT_SUPPORT_LE
(-66) BTPS_ERROR_INSUFFICIENT_RESOURCES
(-107) BTPS_ERROR_INVALID_DEVICE_ROLE_MODE

API Calls
GAP_LE_Pair_Remote_Device(BluetoothStackID, BD_ADDR, &Capabilities, GAP_LE_Event_Callback, 0);
GAP_LE_Request_Security(BluetoothStackID, BD_ADDR, Capabilities.Bonding_Type, Capabilities.MITM, GAP_LE_Event_Callback, 0);

API Prototypes
int BTPSAPI GAP_LE_Pair_Remote_Device(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, GAP_LE_Pairing_Capabilities_t *Capabilities, GAP_LE_Event_Callback_t GAP_LE_Event_Callback, unsigned long CallbackParameter);
int BTPSAPI GAP_LE_Request_Security(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, GAP_LE_Bonding_Type_t Bonding_Type, Boolean_t MITM, GAP_LE_Event_Callback_t GAP_LE_Event_Callback, unsigned long CallbackParameter);

Description of API
The GAP_LE_Pair_Remote_Device function is provided to allow a means to pair with a remote, connected, device. This function accepts the device address of the currently connected device to pair with, followed by the pairing capabilities of the local device. This function also accepts as input the GAP LE event callback information to use during the pairing process. This function returns zero if successful or a negative error code if there was an error. This function can only be issued by the master of the connection (the initiator of the connection). The reason is that a slave can only request a security procedure, it cannot initiate a security procedure. The GAP_LE_Request_Security function is provided to allow a means for a slave device to request that the master (of the connection) perform a pairing operation or re-establishing prior security. This function can only be called by a slave device. The reason for this is that the slave can only request for security to be initiated, it cannot initiate the security process itself. This function returns zero if successful or a negative error code if there was an error.



LEPassKeyResponse

Description
The LEPassKeyResponse command is responsible for issuing a GAP Authentication Response with a Pass Key value specified via the input parameter. This command returns zero on successful execution and a negative value on all errors.

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
(-118) BTPS_ERROR_PAIRING_NOT_ACTIVE
(-57) BTPS_ERROR_DEVICE_HCI_ERROR
(-56) BTPS_ERROR_GAP_NOT_INITIALIZED
(-104) BTPS_ERROR_LOCAL_CONTROLLER_DOES_NOT_SUPPORT_LE
(-66) BTPS_ERROR_INSUFFICIENT_RESOURCES
(-107) BTPS_ERROR_INVALID_DEVICE_ROLE_MODE

API Call
GAP_LE_Authentication_Response(BluetoothStackID, CurrentRemoteBD_ADDR, &GAP_LE_Authentication_Response_Information);

API Prototype
int BTPSAPI GAP_LE_Authentication_Response(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, GAP_LE_Authentication_Response_Information_t *GAP_LE_Authentication_Information);

Description of API
This function is provided to allow a mechanism for the local device to respond to GAP LE 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).



LEQueryEncryption

Description
The LEQueryEncryption command is responsible for quering the Encryption Mode for an LE Connection. This command returns zero on successful execution and a negative value on all errors.

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 Encryption Mode
(-4) FUNCTION_ERROR
(-8) INVALID_STACK_ID_ERROR
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID
(-1) BTPS_ERROR_INVALID_PARAMETER
(-56) BTPS_ERROR_GAP_NOT_INITIALIZED
(-104) BTPS_ERROR_LOCAL_CONTROLLER_DOES_NOT_SUPPORT_LE

API Call
GAP_LE_Query_Encryption_Mode(BluetoothStackID, ConnectionBD_ADDR, &GAP_Encryption_Mode);

API Prototype
int BTPSAPI GAP_LE_Query_Encryption_Mode(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, GAP_Encryption_Mode_t *GAP_Encryption_Mode);

Description of API
This function is provided to allow a means to query the current encryption mode for the LE connection that is specified.



SetPasskey

Description
The SetPasskey command is responsible for querying the Encryption Mode for an LE Connection. This command returns zero on successful execution and a negative value on all errors.
Note: SetPasskey Command works only when you are pairing.

Parameters
The SetPasskey 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
“SetPasskey 0” Attempts to remove the Passkey.
“SetPasskey 1 987654” Attempts to set the Passkey to 987654.
“SetPasskey 1” Attempts to set the Passkey to the default Fixed Passkey value.

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
(-56) BTPS_ERROR_GAP_NOT_INITIALIZED
(-104) BTPS_ERROR_LOCAL_CONTROLLER_DOES_NOT_SUPPORT_LE

API Calls
(Depending on the First Parameter one of these will be chosen)
GAP_LE_Set_Fixed_Passkey(BluetoothStackID, &Passkey);
GAP_LE_Set_Fixed_Passkey(BluetoothStackID, NULL);

API Prototype
int BTPSAPI GAP_LE_Set_Fixed_Passkey(unsigned int BluetoothStackID, DWord_t *Fixed_Display_Passkey);

Description of API
This function is provided to allow a means for a fixed passkey to be used whenever the local Bluetooth device is chosen to display a passkey during a pairing operation. This fixed passkey is only used when the local Bluetooth device is chosen to display the passkey, based on the remote I/O Capabilities and the local I/O capabilities.



LEUserConfirmationResponse

Description
The LEUserConfirmationResponse command is responsible for issuing a GAP LE Authentication Response with a User Confirmation value specified via the input parameter. This function returns zero on successful execution and a negative value on all errors.

Parameters
This command requires one parameter which indicates if confirmation is accepted or not. 0 = decline, 1 = accept.

Command Call Examples
“LEUserConfirmationResponse 0” Attempts to Response with a decline value.
“LEUserConfirmationResponse 1” Attempts to Response with a accept value.


Possible Return Values
(0) Success.
(-4) FUNCTION_ERROR.
(-6) INVALID_PARAMETERS_ERROR.
(-1) BTPS_ERROR_INVALID_PARAMETER.
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID.
(-56) BTPS_ERROR_GAP_NOT_INITIALIZED.
(-57) BTPS_ERROR_DEVICE_HCI_ERROR.
(-66) BTPS_ERROR_INSUFFICIENT_RESOURCES.
(-98) BTPS_ERROR_DEVICE_NOT_CONNECTED.
(-103) BTPS_ERROR_FEATURE_NOT_AVAILABLE.
(-104) BTPS_ERROR_LOCAL_CONTROLLER_DOES_NOT_SUPPORT_LE.
(-107) BTPS_ERROR_INVALID_DEVICE_ROLE_MODE.
(-118) BTPS_ERROR_PAIRING_NOT_ACTIVE.
(-119) BTPS_ERROR_INVALID_STATE.
(-120) BTPS_ERROR_FEATURE_NOT_CURRENTLY_ACTIVE.
(-122) BTPS_ERROR_NUMERIC_COMPARISON_FAILED.


API Call
GAP_LE_Authentication_Response(BluetoothStackID, CurrentLERemoteBD_ADDR, &GAP_LE_Authentication_Response_Information)

API Prototype
int BTPSAPI GAP_LE_Authentication_Response(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, GAP_LE_Authentication_Response_Information_t *GAP_LE_Authentication_Information)

Description of API
The following function is provided to allow a mechanism for the local device to respond to GAP LE authentication events. This function is used to set the authentication information for the specified Bluetooth device. This function accepts as input, the Bluetooth protocol stack ID followed by the remote Bluetooth device address that is currently executing a pairing/authentication process, followed by the authentication response information.This function returns zero if successful, or a negative return error code if there was an error.


EnableSCOnly

Description
The EnableSCOnly command enables LE Secure Connections (SC) only mode. In case this mode is enabled, pairing request from peers that support legacy pairing only will be rejected. Please note that in case this mode is enabled, the SC flag in the LE_Parameters must be set to TRUE. This function returns zero on successful execution and a negative value on all errors.

Parameters
This command requires one parameter which indicates if Secure connections only mode is set or not. 0 = SC Only mode is off, 1 = SC Only mode is on.

Command Call Examples
“EnableSCOnly 0” Disable Secure connections only mode.
“EnableSCOnly 1” Enable Secure connections only mode.


Possible Return Values
(0) Success.
(-4) FUNCTION_ERROR.
(-6) INVALID_PARAMETERS_ERROR.
(-8) INVALID_STACK_ID_ERROR.
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID.
(-56) BTPS_ERROR_GAP_NOT_INITIALIZED.
(-103) BTPS_ERROR_FEATURE_NOT_AVAILABLE.
(-104) BTPS_ERROR_LOCAL_CONTROLLER_DOES_NOT_SUPPORT_LE.
(-120) BTPS_ERROR_FEATURE_NOT_CURRENTLY_ACTIVE.

API Call
GAP_LE_SC_Only_Mode(BluetoothStackID, EnableSCOnly)

API Prototype
int BTPSAPI GAP_LE_SC_Only_Mode(unsigned int BluetoothStackID, Boolean_t EnableSCOnly)

Description of API
The following function is provided to allow a configuration of LE Secure Connecions only mode. The upper layer will use this function before the beginning of LE SC pairing, in case it asks to reject a device that supports only legacy pairing. This mode should be used when it is more important for a device to have high security than it is for it to maintain backwards compatibility with devices that do not support SC. This function accepts as parameters the Bluetooth stack ID of the Bluetooth device,and a boolean EnableSCOnly that enable or disable the SC only mode. This function should be used ones, before the first pairing process. This function returns zero if successful or a negative error code.



RegenerateP256LocalKeys

Description
The following function allows the user to generate new P256 private and local keys. This function shall NOT be used in the middle of a pairing process. It is relevant for LE Secure Conenctions pairing only! This function returns zero on successful execution and a negative value on all errors.

Parameters
No parameters are necessary.

Command Call Examples
“RegenerateP256LocalKeys” Attempts to generate new P256 private and local keys.


Possible Return Values
(0) Success.

(-4) FUNCTION_ERROR.
(-8) INVALID_STACK_ID_ERROR.
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID.
(-56) BTPS_ERROR_GAP_NOT_INITIALIZED.
(-104) BTPS_ERROR_LOCAL_CONTROLLER_DOES_NOT_SUPPORT_LE.
(-117) BTPS_ERROR_PAIRING_ACTIVE.
(-120) BTPS_ERROR_FEATURE_NOT_CURRENTLY_ACTIVE.

API Call
GAP_LE_SC_Regenerate_P256_Local_Keys(BluetoothStackID)

API Prototype
int BTPSAPI GAP_LE_SC_Regenerate_P256_Local_Keys(unsigned int BluetoothStackID)

Description of API
The following function is provided to allow a regeneration of the P-256 private and local puclic keys. This function is relevant only in case of LE SC pairing. This function accepts as parameters the Bluetooth stack ID of the Bluetooth device. This functions shall NOT be used while performing pairing. This function returns zero if successful or a negative error code.


SCGenerateOOBLocalParams

Description
In order to be able to perform LE SC pairing in OOB method we need to generate local random and confirmation values before the pairing process starts. The following function allows the user to generate OOB local parameters. This function shall NOT be used in the middle of a pairing process. It is relevant for LE SC pairing only! This function returns zero on successful execution and a negative value on all errors.

Parameters
No parameters are necessary.

Command Call Examples
“SCGenerateOOBLocalParams” Attempts to generate local random and confirmation values before the pairing process starts.


Possible Return Values
(0) Success.

(-4) FUNCTION_ERROR.
(-8) INVALID_STACK_ID_ERROR.
(-2) BTPS_ERROR_INVALID_BLUETOOTH_STACK_ID.
(-56) BTPS_ERROR_GAP_NOT_INITIALIZED.
(-104) BTPS_ERROR_LOCAL_CONTROLLER_DOES_NOT_SUPPORT_LE.
(-117) BTPS_ERROR_PAIRING_ACTIVE.
(-120) BTPS_ERROR_FEATURE_NOT_CURRENTLY_ACTIVE.

API Call
GAP_LE_SC_OOB_Generate_Parameters(BluetoothStackID, &OOBLocalRandom, &OOBLocalConfirmation)

API Prototype
int BTPSAPI GAP_LE_SC_OOB_Generate_Parameters(unsigned int BluetoothStackID, SM_Random_Value_t *OOB_Local_Rand_Result, SM_Confirm_Value_t *OOB_Local_Confirm_Result)

Description of API
The following function is provided to allow the use of LE Secure Connections (SC) pairing in Out Of Band (OOB) association method. The upper layer will use this function to generate the the local OOB random value, and OOB confirmation value (ra/rb and Ca/Cb) as defined in the Bluetooth specification. This function accepts as parameters the Bluetooth stack ID of the Bluetooth device, and pointers to buffers that will recieve the generated local OOB random, and OOB confirmation values. This function returns zero if successful or a negative error code.



DiscoverGAPS

Description
The DiscoverGAPS command is provided to allow an easy mechanism to start a service discovery procedure to discover the Generic Access Profile Service on the connected remote device.

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

Possible Return Values
(0) Successfully discovered the Generic Access Profile Service.
(-4) Function Error (on failure).

API Call
GDIS_Service_Discovery_Start(BluetoothStackID, ConnectionID, (sizeof(UUID)/sizeof(GATT_UUID_t)), UUID, GDIS_Event_Callback, sdGAPS)

API Prototypes
int BTPSAPI GDIS_Service_Discovery_Start(unsigned int BluetoothStackID, unsigned int ConnectionID, unsigned int NumberOfUUID, GATT_UUID_t *UUIDList, GDIS_Event_Callback_t ServiceDiscoveryCallback, unsigned long ServiceDiscoveryCallbackParameter)

Description of API
The GDIS_Service_Discover_Start is in an application module called GDIS that is provided to allow an easy way to perform GATT service discovery. This module can and should be modified for the customers use. This function is called to start a service discovery operation by the GDIS module.



GetLocalName

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

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



SetLocalName

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

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.



GetRemoteName

Description
The GetRemoteName command is responsible for querying the Bluetooth Device Name of a Remote Device. This command 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).



SetLocalAppearence

Description
The SetLocalAppearence command is provided to set the local device appearance that is exposed by the GAP Service (GAPS).

Parameters
The SetLocalAppearence command requires one parameter which is the Local Device Appearance you wish to be set.

Possible Return Values
(0) Success.
(-4) Function error (on failure).

API Call
GAPS_Set_Device_Appearance(BluetoothStackID, GAPSInstanceID, Appearance)

API Prototype
int BTPSAPI GAPS_Set_Device_Appearance(unsigned int BluetoothStackID, unsigned int InstanceID, Word_t DeviceAppearance);

Description of API
This function allows a mechanism of setting the local device appearance that is exposed as part of the GAP Service API (GAPS).



GetLocalAppearence

Description
The GetLocalAppearence command is provided to read the local device appearance that is exposed by the GAP Service (GAPS).

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

Possible Return Values
(0) Success.
(-4) Function error (on failure).

API Call
GAPS_Query_Device_Appearance(BluetoothStackID, GAPSInstanceID, &Appearance)

API Prototype
int BTPSAPI GAPS_Query_Device_Appearance(unsigned int BluetoothStackID, unsigned int InstanceID, Word_t *DeviceAppearance)

Description of API
This function allows a mechanism of reading the local device appearance that is exposed as part of the GAP Service API (GAPS).



GetRemoteAppearence

Description
The GetRemoteAppearence command is provided to read the device appearance from the connected remote device that is exposed as part of the GAP Service. The GAP Service on the remote device must have already been discovered using the DiscoverGAPS command.

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

Possible Return Values
(0) Success.
(-4) Function error (on failure).

API Call
GATT_Read_Value_Request(BluetoothStackID, ConnectionID, DeviceInfo->GAPSClientInfo.DeviceAppearanceHandle, GATT_ClientEventCallback_GAPS, (unsigned long)DeviceInfo->GAPSClientInfo.DeviceAppearanceHandle)

API Prototype
int BTPSAPI GATT_Read_Value_Request(unsigned int BluetoothStackID, unsigned int ConnectionID, Word_t AttributeHandle, GATT_Client_Event_Callback_t ClientEventCallback, unsigned long CallbackParameter)

Description of API
This function allows a mechanism of reading an attribute from a connected device.

Alert Notification Profile Commands



RegisterANS

Description
RegisterANS is responsible for registering a ANP Service.

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

Possible Return Values
(0) Successfully registered ANP service
(-4) Function_Error
(-1000) ANS_ERROR_INVALID_PARAMETER
(-1001)ANS_ERROR_INSUFFICIENT_RESOURCES
(-1002)ANS_ERROR_SERVICE_ALREADY_REGISTERED

API Call
ANS_Initialize_Service(BluetoothStackID, ANS_EventCallback, NULL, &ANSInstanceID)

API Prototype
int BTPSAPI ANS_Initialize_Service(unsigned int BluetoothStackID, ANS_Event_Callback_t EventCallback, unsigned long CallbackParameter, unsigned int *ServiceID)

Description of API
This function is responsible for opening a ANS Server.The first parameter is the Bluetooth Stack ID on which to open the Server. The second parameter is the Callback function to call when an event occurs on this Server Port. The third parameter is a user-defined callback parameter that will be passed to the callback function with each event. The final parameter is a pointer to store the GATT Service ID of the registered ANS service. This can be used to include the service registered by this call. This function returns the positive, non-zero, Instance ID or a negative error code.



UnRegisterANS

Description
UnRegisterANS is responsible for unregistering a ANP Service.

Parameters
It is not necessary to include parameters when using this command. A parameter will have no effect on the outcome.
Possible Return Values
(0)Successfully unregistered ANP service
(-4) Function_Error
(-1000) ANS_ERROR_INVALID_PARAMETER
(-1003) ANS_ERROR_INVALID_INSTANCE_ID

API Call
ANS_Cleanup_Service(BluetoothStackID, ANSInstanceID)

API Prototype
int BTPSAPI ANS_Cleanup_Service(unsigned int BluetoothStackID, unsigned int InstanceID)

Description of API
The following function is responsible for closing a previously opened ANS Server. The first parameter is the Bluetooth Stack ID on which to close the Server. The second parameter is the InstanceID that was returned from a successfull call to ANS_Initialize_Service(). This function returns a zero if successful or a negative return error code if an error occurs.


DiscoverANS

Description
DiscoverANS is responsible for performing a ANP Service Discovery Operation. This function will return zero on successful execution and a negative value on errors.

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

Possible Return Values
(0)Successfully unregistered ANP service
(-4) Function_Error

API Call
GDIS_Service_Discovery_Start(BluetoothStackID, ConnectionID, (sizeof(UUID)/sizeof(GATT_UUID_t)), UUID, GDIS_Event_Callback, sdANS)

API Prototype
int BTPSAPI GDIS_Service_Discovery_Start(unsigned int BluetoothStackID, unsigned int ConnectionID, unsigned int NumberOfUUID, GATT_UUID_t *UUIDList, GDIS_Event_Callback_t ServiceDiscoveryCallback, unsigned long ServiceDiscoveryCallbackParameter)

Description of API
The GDIS_Service_Discover_Start is in an application module called GDIS that is provided to allow an easy way to perform GATT service discovery. This module can and should be modified for the customers use. This function is called to start a service discovery operation by the GDIS module.



ConfigureRemoteANS

Description
ConfigureRemoteANS is responsible for configure a ANP Service on a remote device. This function will return zero on successful execution and a negative value on errors.

Parameters
There are two parameters for this command, they are [New Alert Notify (0 = disable, 1 = enable)] and [Unread Alert Status Notify (0 = disable, 1 = enable)].

Possible Return Values
(0) CCCD Configuration Success
(-4) FUNCTION_ERROR
(-6) BTPS_ERROR_INVALID_PARAMETER



NotifyNewAlerts

Description
NotifyNewAlerts is responsible for performing a New Alert notification to a connected remote device. This function will return zero on successful execution and a negative value on errors.

Parameters
[BitMask (0xXXXX)]
Category(bit values): 0 = Simple Alert, 1 = E-Mail, 2 = News, 3 = Call, 4 = Missed Call, 5 = SMS MMS, 6 = Voice Mail, 7 = Schedule, 8 = High Priority Alert, 9 = Instant Message

Possible Return Values
(0) Sending New Alert Notification for 'category'... Success
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR




NotifyUnreadAlerts

Description
NotifyUnreadAlerts is responsible for performing an Unread Alert notification to a connected remote device. This function will return zero on successful execution and a negative value on errors.

Parameters
[BitMask (0xXXXX)]
Category(bit values): 0 = Simple Alert, 1 = E-Mail, 2 = News, 3 = Call, 4 = Missed Call, 5 = SMS MMS, 6 = Voice Mail, 7 = Schedule, 8 = High Priority Alert, 9 = Instant Message

Possible Return Values
(0) Sending Unread Alert Notification for 'category'... Success
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR



GetNewAlertStatus

Description
GetNewAlertStatus is responsible for reading the New Alert Status for a specified category. It can be executed only by a Server. This function will return zero on successful execution and a negative value on errors.

Parameters
[Category]
Category(numeric values): 0 = Simple Alert, 1 = E-Mail, 2 = News, 3 = Call, 4 = Missed Call, 5 = SMS MMS, 6 = Voice Mail, 7 = Schedule, 8 = High Priority Alert, 9 = Instant Message

Possible Return Values
(0) Get New Alert Status request sent
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) ANS_ERROR_INVALID_PARAMETER
(-1003) ANS_ERROR_INVALID_INSTANCE_ID

API Call
ANS_Query_Supported_Categories(BluetoothStackID, ANSInstanceID, scNewAlert, &SupportedCategories))

API Prototype
int BTPSAPI ANS_Query_Supported_Categories(unsigned int BluetoothStackID, unsigned int InstanceID, ANS_Supported_Categories_Type_t SupportedCategoryType, Word_t *SupportedCategoriesMask)

Description of API
The following function is responsible for setting the Alert Notification Supported Categories for the specified Category Type on the specified ANS Instance. The first parameter is the Bluetooth Stack ID of the Bluetooth Device. The second parameter is the InstanceID returned from a successful call to ANS_Initialize_Server(). The next parameter specifies the Category to query the Supported Categories for. The final parameter is a pointer to store the Supported Categories bit mask for the specified ANS Instance. This function returns a zero if successful or a negative return error code if an error occurs.

  • NOTE * The SupportedCategoriesMask is a pointer to a bit mask that will be made up of bit masks of the form ANS_SUPPORTED_CATEGORIES_XXX, if this function returns success.



SetNewAlertStatus

Description
SetNewAlertStatus is responsible for writing the New Alert Status for a specified category. It can be executed only by a Server. This function will return zero on successful execution and a negative value on errors.

Parameters
[Category] [Num Alerts] [Alert String (Optional)]
Category(numeric values): 0 = Simple Alert, 1 = E-Mail, 2 = News, 3 = Call, 4 = Missed Call, 5 = SMS MMS, 6 = Voice Mail, 7 = Schedule, 8 = High Priority Alert, 9 = Instant Message

Possible Return Values
(0) Set New Alert Status success
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) ANS_ERROR_INVALID_PARAMETER
(-1003) ANS_ERROR_INVALID_INSTANCE_ID

API Call
ANS_Query_Supported_Categories(BluetoothStackID, ANSInstanceID, scNewAlert, &SupportedCategories)

API Prototype
int BTPSAPI ANS_Query_Supported_Categories(unsigned int BluetoothStackID, unsigned int InstanceID, ANS_Supported_Categories_Type_t SupportedCategoryType, Word_t *SupportedCategoriesMask)

Description of API
The following function is responsible for setting the Alert Notification Supported Categories for the specified Category Type on the specified ANS Instance. The first parameter is the Bluetooth Stack ID of the Bluetooth Device. The second parameter is the InstanceID returned from a successful call to ANS_Initialize_Server(). The next parameter specifies the Category to query the Supported Categories for. The final parameter is a pointer to store the Supported Categories bit mask for the specified ANS Instance. This function returns a zero if successful or a negative return error code if an error occurs.

  • NOTE * The SupportedCategoriesMask is a pointer to a bit mask that will be made up of bit masks of the form ANS_SUPPORTED_CATEGORIES_XXX, if this function returns success.



GetUnreadAlertStatus

Description
GetUnreadAlertStatus is responsible for reading the Unread Alert Status for a specified category. It can be executed only by a Server. This function will return zero on successful execution and a negative value on errors.

Parameters
[Category]
Category(numeric values): 0 = Simple Alert, 1 = E-Mail, 2 = News, 3 = Call, 4 = Missed Call, 5 = SMS MMS, 6 = Voice Mail, 7 = Schedule, 8 = High Priority Alert, 9 = Instant Message

Possible Return Values
(0) Get Unread Alert Status request sent
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) ANS_ERROR_INVALID_PARAMETER
(-1003) ANS_ERROR_INVALID_INSTANCE_ID

API Call
ANS_Query_Supported_Categories(BluetoothStackID, ANSInstanceID, scUnreadAlertStatus, &SupportedCategories)

API Prototype
int BTPSAPI ANS_Query_Supported_Categories(unsigned int BluetoothStackID, unsigned int InstanceID, ANS_Supported_Categories_Type_t SupportedCategoryType, Word_t *SupportedCategoriesMask)

Description of API
The following function is responsible for setting the Alert Notification Supported Categories for the specified Category Type on the specified ANS Instance. The first parameter is the Bluetooth Stack ID of the Bluetooth Device. The second parameter is the InstanceID returned from a successful call to ANS_Initialize_Server(). The next parameter specifies the Category to query the Supported Categories for. The final parameter is a pointer to store the Supported Categories bit mask for the specified ANS Instance. This function returns a zero if successful or a negative return error code if an error occurs.

  • NOTE * The SupportedCategoriesMask is a pointer to a bit mask that will be made up of bit masks of the form ANS_SUPPORTED_CATEGORIES_XXX, if this function returns success.



SetUnreadAlertStatus

Description
SetUnreadAlertStatus is responsible for writing the Unread Alert Status for a specified category. It can be executed only by a Server. This function will return zero on successful execution and a negative value on errors.

Parameters
[Category][NUM VALUES]
Category(numeric values): 0 = Simple Alert, 1 = E-Mail, 2 = News, 3 = Call, 4 = Missed Call, 5 = SMS MMS, 6 = Voice Mail, 7 = Schedule, 8 = High Priority Alert, 9 = Instant Message

Possible Return Values
(0) Set Unread Alert Status success
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-8) INVALID_STACK_ID_ERROR
(-1000) ANS_ERROR_INVALID_PARAMETER
(-1003) ANS_ERROR_INVALID_INSTANCE_ID

API Call
ANS_Query_Supported_Categories(BluetoothStackID, ANSInstanceID, scUnreadAlertStatus, &SupportedCategories)

API Prototype
int BTPSAPI ANS_Query_Supported_Categories(unsigned int BluetoothStackID, unsigned int InstanceID, ANS_Supported_Categories_Type_t SupportedCategoryType, Word_t *SupportedCategoriesMask)

Description of API
The following function is responsible for setting the Alert Notification Supported Categories for the specified Category Type on the specified ANS Instance. The first parameter is the Bluetooth Stack ID of the Bluetooth Device. The second parameter is the InstanceID returned from a successful call to ANS_Initialize_Server(). The next parameter specifies the Category to query the Supported Categories for. The final parameter is a pointer to store the Supported Categories bit mask for the specified ANS Instance. This function returns a zero if successful or a negative return error code if an error occurs.

  • NOTE * The SupportedCategoriesMask is a pointer to a bit mask that will be made up of bit masks of the form ANS_SUPPORTED_CATEGORIES_XXX, if this function returns success.



GetSupportedNewAlertCategories

Description
GetSupportedNewAlertCategories is responsible for reading the Supported New Alert Category. It can be executed by a Server or a Client with an open connection to a remote Server. If executed as a Client, a GATT read request will be generated, and the results will be returned as a response in the GATT Client event callback. This function will return zero on successful execution and a negative value on errors.

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

Possible Return Values
(0) Get Supported New Alert Category Request sent, Transaction ID = %u
(-4) FUNCTION_ERROR
(-1000) ANS_ERROR_INVALID_PARAMETER
(-1003) ANS_ERROR_INVALID_INSTANCE_ID

API Call
ANS_Query_Supported_Categories(BluetoothStackID, ANSInstanceID, scNewAlert, &SupportedCategories)

API Prototype
int BTPSAPI ANS_Query_Supported_Categories(unsigned int BluetoothStackID, unsigned int InstanceID, ANS_Supported_Categories_Type_t SupportedCategoryType, Word_t *SupportedCategoriesMask)

Description of API
The following function is responsible for setting the Alert Notification Supported Categories for the specified Category Type on the specified ANS Instance. The first parameter is the Bluetooth Stack ID of the Bluetooth Device. The second parameter is the InstanceID returned from a successful call to ANS_Initialize_Server(). The next parameter specifies the Category to query the Supported Categories for. The final parameter is a pointer to store the Supported Categories bit mask for the specified ANS Instance. This function returns a zero if successful or a negative return error code if an error occurs.

  • NOTE * The SupportedCategoriesMask is a pointer to a bit mask that will be made up of bit masks of the form ANS_SUPPORTED_CATEGORIES_XXX, if this function returns success.



SetSupportedNewAlertCategories

Description
SetSupportedNewAlertCategories is responsible for writing the Supported New Alert Category. It can be executed only by a Server. This function will return zero on successful execution and a negative value on errors.

Parameters
[BitMask (0xXXXX)]
Category(bit values): 0 = Simple Alert, 1 = E-Mail, 2 = News, 3 = Call, 4 = Missed Call, 5 = SMS MMS, 6 = Voice Mail, 7 = Schedule, 8 = High Priority Alert, 9 = Instant Message

Possible Return Values
(0) Supported New Alert Category successfully set
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-1000) ANS_ERROR_INVALID_PARAMETER
(-1003) ANS_ERROR_INVALID_INSTANCE_ID

API Call
ANS_Set_Supported_Categories(BluetoothStackID, ANSInstanceID, scNewAlert, SupportedCategories)

API Prototype
int BTPSAPI ANS_Set_Supported_Categories(unsigned int BluetoothStackID, unsigned int InstanceID, ANS_Supported_Categories_Type_t SupportedCategoryType, Word_t SupportedCategoriesMask)

Description of API
The following function is responsible for setting the Alert Notification Supported Categories for the specified Category Type on the specified ANS Instance. The first parameter is the Bluetooth Stack ID of the Bluetooth Device. The second parameter is the InstanceID returned from a successful call to ANS_Initialize_Server(). The next parameter specifies the Category to set the Supported Categories for. The final parameter is the Supported Categories bit mask to set as the supported categories for the specified ANS Instance. This function returns a zero if successful or a negative return error code if an error occurs.

  • NOTE * The SupportedCategoriesMask is a bit mask that is made up of bit masks of the form ANS_SUPPORTED_CATEGORIES_XXX.



GetSupportedUnreadAlertCategories

Description
GetSupportedUnreadAlertCategories is responsible for reading the Supported Unread Alert Category. It can be executed by a Server or a Client with an open connection to a remote Server. If executed as a Client, a GATT read request will be generated, and the results will be returned as a response in the GATT Client event callback. This function will return zero on successful execution and a negative value on errors.

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

Possible Return Values
(0) Get Supported Unread Alert Category Request sent, Transaction ID = %u
(-4) FUNCTION_ERROR
(-1000) ANS_ERROR_INVALID_PARAMETER
(-1003) ANS_ERROR_INVALID_INSTANCE_ID

API Call
ANS_Query_Supported_Categories(BluetoothStackID, ANSInstanceID, scUnreadAlertStatus, &SupportedCategories)

API Prototype
int BTPSAPI ANS_Query_Supported_Categories(unsigned int BluetoothStackID, unsigned int InstanceID, ANS_Supported_Categories_Type_t SupportedCategoryType, Word_t *SupportedCategoriesMask)

Description of API
The following function is responsible for setting the Alert Notification Supported Categories for the specified Category Type on the specified ANS Instance. The first parameter is the Bluetooth Stack ID of the Bluetooth Device. The second parameter is the InstanceID returned from a successful call to ANS_Initialize_Server(). The next parameter specifies the Category to query the Supported Categories for. The final parameter is a pointer to store the Supported Categories bit mask for the specified ANS Instance. This function returns a zero if successful or a negative return error code if an error occurs.

  • NOTE * The SupportedCategoriesMask is a pointer to a bit mask that will be made up of bit masks of the form ANS_SUPPORTED_CATEGORIES_XXX, if this function returns success.



SetSupportedUnreadAlertCategories

Description
SetSupportedUnreadAlertCategories is responsible for writing the Supported Unread Alert Category. It can be executed only by a Server. This function will return zero on successful execution and a negative value on errors.

Parameters
[BitMask (0xXXXX)]
Category(bit values): 0 = Simple Alert, 1 = E-Mail, 2 = News, 3 = Call, 4 = Missed Call, 5 = SMS MMS, 6 = Voice Mail, 7 = Schedule, 8 = High Priority Alert, 9 = Instant Message

Possible Return Values
(0) Supported Unread Alert Category successfully set
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR
(-1000) ANS_ERROR_INVALID_PARAMETER
(-1003) ANS_ERROR_INVALID_INSTANCE_ID

API Call
ANS_Set_Supported_Categories(BluetoothStackID, ANSInstanceID, scUnreadAlertStatus, SupportedCategories)

API Prototype
int BTPSAPI ANS_Set_Supported_Categories(unsigned int BluetoothStackID, unsigned int InstanceID, ANS_Supported_Categories_Type_t SupportedCategoryType, Word_t SupportedCategoriesMask)

Description of API
The following function is responsible for setting the Alert Notification Supported Categories for the specified Category Type on the specified ANS Instance. The first parameter is the Bluetooth Stack ID of the Bluetooth Device. The second parameter is the InstanceID returned from a successful call to ANS_Initialize_Server(). The next parameter specifies the Category to set the Supported Categories for. The final parameter is the Supported Categories bit mask to set as the supported categories for the specified ANS Instance. This function returns a zero if successful or a negative return error code if an error occurs.

  • NOTE * The SupportedCategoriesMask is a bit mask that is made up of bit masks of the form ANS_SUPPORTED_CATEGORIES_XXX.



EnableNewAlertNotifications

Description
EnableNewAlertNotifications is responsible for writing the Enable New Incoming Alert Notifications command to a remote Server Control Point. It can be executed only by a Client. This function will return zero on successful execution and a negative value on errors.

Parameters
[Category]
Category(numeric values): 0 = Simple Alert, 1 = E-Mail, 2 = News, 3 = Call, 4 = Missed Call, 5 = SMS MMS, 6 = Voice Mail, 7 = Schedule, 8 = High Priority Alert, 9 = Instant Message, 10 = All Categories

Possible Return Values
(0) Enable New Alert Notifications command request sent.
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR



DisableNewAlertNotifications

Description
DisableNewAlertNotifications is responsible for writing the Disable New Incoming Alert Notifications command to a remote Server Control Point. It can be executed only by a Client. This function will return zero on successful execution and a negative value on errors.

Parameters
[Category]
Category(numeric values): 0 = Simple Alert, 1 = E-Mail, 2 = News, 3 = Call, 4 = Missed Call, 5 = SMS MMS, 6 = Voice Mail, 7 = Schedule, 8 = High Priority Alert, 9 = Instant Message, 10 = All Categories

Possible Return Values
(0) Disable New Alert Notifications command request sent
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR



EnableUnreadAlertNotifications

Description
EnableUnreadAlertNotifications is responsible for writing the Enable Unread Category Status Notifications command to a remote Server Control Point. It can be executed only by a Client. This function will return zero on successful execution and a negative value on errors.

Parameters
[Category]
Category(numeric values): 0 = Simple Alert, 1 = E-Mail, 2 = News, 3 = Call, 4 = Missed Call, 5 = SMS MMS, 6 = Voice Mail, 7 = Schedule, 8 = High Priority Alert, 9 = Instant Message, 10 = All Categories

Possible Return Values
(0) Enable Unread Category Notifications command request sent
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR



DisableUnreadAlertNotifications

Description
DisableUnreadAlertNotifications is responsible for writing the Disable Unread Category Status Notifications command to a remote Server Control Point. It can be executed only by a Client. This function will return zero on successful execution and a negative value on errors.

Parameters
[Category]
Category(numeric values): 0 = Simple Alert, 1 = E-Mail, 2 = News, 3 = Call, 4 = Missed Call, 5 = SMS MMS, 6 = Voice Mail, 7 = Schedule, 8 = High Priority Alert, 9 = Instant Message, 10 = All Categories

Possible Return Values
(0) Disable Unread Category Notifications command request sent
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR



NotifyImmediatelyNewAlerts

Description
NotifyImmediatelyNewAlerts is responsible for writing the Notify New Incoming Alert Immediately command to a remote Server Control Point. It can be executed only by a Client. This function will return zero on successful execution and a negative value on errors.

Parameters
[Category]
Category(numeric values): 0 = Simple Alert, 1 = E-Mail, 2 = News, 3 = Call, 4 = Missed Call, 5 = SMS MMS, 6 = Voice Mail, 7 = Schedule, 8 = High Priority Alert, 9 = Instant Message, 10 = All Categories

Possible Return Values
(0) Notify New Alert Immediately command request sent
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR



NotifyImmediatelyUnreadAlerts

Description
NotifyImmediatelyUnreadAlerts is responsible for writing the Notify New Unread Category Status Immediately command to a remote Server Control Point. It can be executed only by a Client. This function will return zero on successful execution and a negative value on errors.

Parameters
[Category]
Category(numeric values): 0 = Simple Alert, 1 = E-Mail, 2 = News, 3 = Call, 4 = Missed Call, 5 = SMS MMS, 6 = Voice Mail, 7 = Schedule, 8 = High Priority Alert, 9 = Instant Message, 10 = All Categories

Possible Return Values
(0) Notify Unread Category Immediately command request sent
(-4) FUNCTION_ERROR
(-6) INVALID_PARAMETERS_ERROR