Bluetooth: Fast Pair

The Fast Pair sample demonstrates how to use Google Fast Pair with the nRF Connect SDK.

Google Fast Pair Service (GFPS) is a standard for pairing Bluetooth and Bluetooth LE devices with as little user interaction required as possible. Google also provides additional features built upon the Fast Pair standard. For detailed information about supported functionalities, see the official Fast Pair documentation.

Note

The Fast Pair support in the nRF Connect SDK is experimental. See Using Google Fast Pair with the nRF Connect SDK for details.

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Build target

nRF5340 DK

PCA10095

nrf5340dk_nrf5340

nrf5340dk_nrf5340_cpuapp_ns nrf5340dk_nrf5340_cpuapp

nRF52 DK

PCA10040

nrf52dk_nrf52832

nrf52dk_nrf52832

nRF52840 DK

PCA10056

nrf52840dk_nrf52840

nrf52840dk_nrf52840

When built for an _ns build target, the sample is configured to compile and run as a non-secure application. Therefore, it automatically includes Trusted Firmware-M that prepares the required peripherals and secure services to be available for the application.

Note

If you use nRF5340 DK, the additional configuration of the network core will be taken from the child_image directory. For more details, see Image-specific variables.

Overview

The sample works as a Fast Pair Provider (one of the Fast Pair roles) and a simple HID multimedia controller. Two buttons are used to control audio volume of the connected Bluetooth Central.

The device can be used to bond with the following devices:

  • Fast Pair Seeker - For example, an Android device. The bonding follows the official Fast Pair Procedure with Bluetooth man-in-the-middle (MITM) protection. The device is linked with the user’s Google account.

  • Bluetooth Central that is not a Fast Pair Seeker - Normal Bluetooth LE bonding is used in this scenario and there is no Bluetooth MITM protection.

The sample supports only one simultaneous Bluetooth connection, but it can be bonded with multiple Bluetooth Centrals.

The sample supports both the discoverable and not discoverable Fast Pair advertising. The device keeps the Bluetooth advertising active until a connection is established. While maintaining the connection, the Bluetooth advertising is disabled. The advertising is restarted after disconnection.

See Fast Pair Advertising for detailed information about discoverable and not discoverable advertising.

Fast Pair device registration

Before a device can be used as a Fast Pair Provider, you must register the device model with Google. This is required to obtain Model ID and Anti-Spoofing Private Key. See Provisioning the device in the Fast Pair user guide for details.

Tip

The sample provides TX power in the Bluetooth advertising data. There is no need to provide the TX power value during device model registration. The device is using only Bluetooth LE, so you must select Skip connecting audio profiles (e.g. A2DP, HFP) option when registering the device.

Seeker device

A Fast Pair Seeker device is required to test the Fast Pair procedure. This is one of the two Fast Pair roles.

For example, you can use an Android device as the Seeker device. To test with a debug mode Model ID, the Android device must be configured to include debug results while displaying the nearby Fast Pair Providers. For details, see Verifying Fast Pair in the GFPS documentation.

Not discoverable advertising requirements

Testing not discoverable advertising requires using at least two Android devices registered to the same Google account. The first one needs to be bonded with Fast Pair Provider before the not discoverable advertising can be detected by the second one.

User interface

The sample supports a simple user interface. You can control the sample using predefined buttons, while LEDs are used to display information.

Buttons

Button 1:

Toggles between three Fast Pair advertising modes:

  • Fast Pair discoverable advertising.

  • Fast Pair not discoverable advertising (with the show UI indication).

  • Fast Pair not discoverable advertising (with the hide UI indication).

Note

The Bluetooth advertising is active only until the Fast Pair Provider connects to a Bluetooth Central. After the connection, you can still switch the advertising modes, but the switch will come into effect only after disconnection. The discoverable advertising is automatically switched to the not discoverable advertising with the show UI indication mode in the following cases:

  • After 10 minutes of active advertising.

  • After a Bluetooth Central successfully pairs.

Button 2:

Increases audio volume of the connected Bluetooth Central.

Button 4:

Decreases audio volume of the connected Bluetooth Central.

LEDs

LED 1:

Keeps blinking with constant interval to indicate that firmware is running.

LED 2:

Depending on the Bluetooth Central connection status:

  • On if the Central is connected over Bluetooth.

  • Off if there is no Central connected.

LED 3:

Depending on the Fast Pair advertising mode setting:

  • On if the device is Fast Pair discoverable.

  • Blinks with 0.5 secs interval if the selected mode is the Fast Pair not discoverable advertising with the show UI indication.

  • Blinks with 1.5 secs interval if the selected mode is the Fast Pair not discoverable advertising with the hide UI indication.

Configuration

See Configuring your application for information about how to permanently or temporarily change the configuration.

Building and running

This sample can be found under samples/bluetooth/peripheral_fast_pair in the nRF Connect SDK folder structure.

When built as a non-secure firmware image for the _ns build target, the sample automatically includes the Trusted Firmware-M (TF-M).

See Building and programming an application for information about how to build and program the application and Testing and debugging an application for general information about testing and debugging in the nRF Connect SDK.

When building the sample, you must provide the Fast Pair Model ID (FP_MODEL_ID) and the Fast Pair Anti Spoofing Key (FP_ANTI_SPOOFING_KEY) as CMake options. See Provisioning the device for detailed guide.

Note

The sample cannot be used without the Fast Pair provisioning data. Programming device with the sample firmware without providing the proper Fast Pair provisioning data would result in assertion failure during boot.

Testing

After programming the sample to your development kit, complete the following steps to test it:

  1. Connect to the kit that runs this sample with a terminal emulator (for example, PuTTY). See How to connect with PuTTY for the required settings. The sample provides Fast Pair debug logs to inform about state of the Fast Pair procedure.

  2. Reset the kit.

  3. Observe that LED 1 is blinking (firmware is running) and LED 3 is turned on (device is Fast Pair discoverable). This means that the device is now working as Fast Pair Provider and is advertising.

  4. On the Android device, go to Settings > Google > Devices & sharing (or Device connections, depending on your Android device configuration) > Devices.

  5. Move the Android device close to the Fast Pair Provider that is advertising.

  6. Wait for Android device’s notification about the detected Fast Pair Provider. The notification is similar to the following one:

    Fast Pair discoverable advertising Android notification

    The device model name and displayed logo depend on the data provided during the device model registration.

  7. Tap the Connect button to initiate the connection and trigger the Fast Pair procedure. After the procedure is finished, the pop-up is updated to inform about successfully completed Fast Pair procedure. LED 2 turns on to indicate that the device is connected with the Bluetooth Central.

    Note

    Some Android devices might disconnect right after the Fast Pair procedure has completed. Go to Settings > Bluetooth and tap on the bonded Fast Pair Provider to reconnect.

    The connected Fast Pair Provider can now be used to control audio volume of the Bluetooth Central.

  8. Press Button 2 to increase the audio volume.

  9. Press Button 4 to decrease the audio volume.

Not discoverable advertising

Testing not discoverable advertising requires using a second Android device that is registered to the same Google account as the first Android device.

Test not discoverable advertising by completing Testing and the following additional steps:

  1. Disconnect the Android device that was used during the default Testing:

    1. Go to Settings > Bluetooth.

    2. Tap on the connected device name to disconnect it.

      Note

      Do not remove Bluetooth bond information related to the Fast Pair Provider.

      After disconnection, the provider automatically switches from the discoverable advertising to the not discoverable advertising with the show UI indication mode. LED 3 is blinking rapidly.

  2. Make sure that the Fast Pair Provider is added to Saved devices on the Android device that was used for Testing:

    1. Go to Settings > Google > Devices & sharing (or Device connections) > Devices > Saved devices.

    2. Verify that the paired device is appearing on the list.

  3. If you want to test the Fast Pair not discoverable advertising with the hide UI indication mode, press Button 1. LED 3 starts blinking slowly.

  4. Wait until the Fast Pair Provider is added to Saved devices on the second Android device:

    1. Go to Settings > Google > Devices & sharing (or Device connections) > Devices > Saved devices. The paired device appears on the list.

    2. If the device does not appear on the list, wait until the data is synced between phones.

  5. Move the second Android device close to the Fast Pair Provider. If the device is in the show UI indication advertising mode, a notification similar to the following one appears:

    Fast Pair not discoverable advertising Android notification

    If the device is in the hide UI indication advertising mode, no notification appears. This is because the device advertises, but does not want to be paired with. You can verify that the device is advertising using the nRF Connect for Mobile application.

  6. In the show UI indication mode, when the notification appears, tap on it to trigger the Fast Pair procedure.

  7. Wait for the notification about successful Fast Pair procedure. LED 2 is turned on to inform that the device is connected with the Bluetooth Central.

    Note

    Some Android devices might disconnect right after Fast Pair procedure is finished. Go to Settings > Bluetooth and tap on the bonded Fast Pair Provider to reconnect.

    The connected Fast Pair Provider can now be used to control the audio volume of the Bluetooth Central.

  8. Press Button 2 to increase the audio volume.

  9. Press Button 4 to decrease the audio volume.

Dependencies

This sample uses the Google Fast Pair Service (GFPS) and its dependencies and is configured to meet the requirements of the Fast Pair standard. See Using Google Fast Pair with the nRF Connect SDK for details about integrating Fast Pair in the nRF Connect SDK.

The Fast Pair provision script is used by the build system to automatically generate the hexadecimal file that contains Fast Pair Model ID and Anti Spoofing Private Key.

The sample also uses the following secure firmware component: