SWRA769 august   2023 CC2564C

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1Demo Application
  5. 2Running the Bluetooth Code
  6. 3Server Set-Up Using HFP Demo Application
  7. 4Client Set-Up on the Demo Application
  8. 5Example: Audio Gateway with a Commercial Headset
  9. 6Application Commands
    1. 6.1  Generic Access Profile Commands
    2. 6.2  Help (DisplayHelp)
    3. 6.3  Inquiry
    4. 6.4  Pair
    5. 6.5  End Pairing
    6. 6.6  PIN Code Response
    7. 6.7  Pass Key Response
    8. 6.8  User Confirmation Response
    9. 6.9  Set Discoverability Mode
    10. 6.10 Set Connectability Mode
    11. 6.11 Set Pairability Mode
    12. 6.12 Change Simple Pairing Parameters
    13. 6.13 Get Local Address
    14. 6.14 Set Local Name
    15. 6.15 Get Local Name
    16. 6.16 Set Class of Device
    17. 6.17 Get Class of Device
    18. 6.18 Get Remote Name
  10. 7Hands-Free Profile Commands
    1. 7.1  Service Discovery
    2. 7.2  Open Audio Gateway Client
    3. 7.3  Manage Audio
    4. 7.4  Update Control Indicators
    5. 7.5  Call Waiting
    6. 7.6  Set Voice Recognition Activation
    7. 7.7  Set Speaker Gain
    8. 7.8  Set Microphone Gain
    9. 7.9  Disable Remote Sound Enhancement
    10. 7.10 Send Caller ID Notification
    11. 7.11 Set Ring Indication
    12. 7.12 Ring Indication
    13. 7.13 Send Incoming Call State
    14. 7.14 Close AG Client
    15. 7.15 Send Operator Info
    16. 7.16 Send Sub Number
    17. 7.17 Send Call List
  11. 8References
  12. 9Revision History

Pair

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 the device attempts 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.

Parameter

The Pair command requires one or two parameters with specific values 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, this cannot be paired with the device. 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 is 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" Attempts the exact same as the above example. If no parameters, the bonding type is 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);

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. If this function returns successfully 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 PhysicalConnection 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 onthe 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 Pair 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 Connectionis 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 L2CAPDisconnect 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 inthis case).