Pairing and connection¶
Secure Simple Pairing capabilities¶
When discoverable, Audio Agent will accept any pairing request from devices in range. By default Audio Agent will use secure simple pairing (Bluetooth 2.1 and above). If the devices trying to pair are older (Bluetooth 2.0 and below), Audio Agent will accept the older pairing procedure.
For Bluetooth 2.1 devices and newer Audio Agent support different type of pairing (see SSP_CAPS configuration). By default it will accept any pairing request using the ‘Just Works’ Bluetooth 2.1 method. This means that the module will accept any connection from Smartphones and other devices. The user of the device will not be required to enter a PIN code.
If SSP_CAPS is no set to 3, you might have to use the PASSKEY command to respond to a pairing request.
For Bluetooth 2.0 devices and older Audio Agent will require a PIN code to accept a connection. The PIN code is set to 0000 by default, but can be reconfigured. This means that the phone user will be required to enter the pin code in order to pair successfully.
Pairing commands¶
You can use the PAIR command to send a pairing request. A notification will be received (PAIR_OK/PENDING/ERROR or PAIR_PASSKEY). When you pair with a device it is automatically added to the Paired Device List (PDL) that can be seen using the LIST command. Finally you can remove any device from your pairing list using the UNPAIR command.
Connection¶
Audio Agent can be put in discoverable mode using the DISCOVERABLE command. It means it will be visible to other devices. To scan for discoverable devices, you can use the INQUIRY command.
When you have the Bluetooth address of the device you want to connect to, use the OPEN command to connect and open a Bluetooth profile. If you are not paired, Audio Agent will automatically pair before connecting. Note that there are a limited number of connections allowed per profile. This can be configured by setting up the PROFILES parameter. When a connection is established, an OPEN notification is received (see Event Notifications). All connected devices are listed with their respective profiles when using the STATUS command. The CLOSE command can be used to disconnect the connected profiles.
Link loss¶
Link loss is supported for the HFP or A2DP profile. It means that if the connection is lost, Audio Agent will attempt to reconnect to the remote device for 10 minutes. A LINK_LOSS notification is sent with status=1 (ex: “LINK_LOSS 13 1”) every 10 seconds if the profile is HFP or just once if it is A2DP.
If the connection is recovered, a LINK_LOSS notification with status=0 is sent (ex: “LINK_LOSS 13 0”). Audio Agent will automatically reconnect all the profiles that have been closed due to the connection lost.
If Audio Agent cannot reconnect after the 10 minutes, the link is closed and a CLOSE notification is sent (ex: “CLOSE_OK 13 HFP”).
Note that you can check the connection status of a link (CONNECTED, LINK_LOSS or DISCONNECTED) with the STATUS command.