Bluetooth: Fast Pair input device
The Fast Pair input device 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.
The sample supports the following development kits:
When built for an
_ns build target, the sample is configured to compile and run as a non-secure application with Cortex-M Security Extensions enabled.
Therefore, it automatically includes Trusted Firmware-M that prepares the required peripherals and secure services to be available for the application.
If you use nRF5340 DK, the additional configuration of the network core will be taken from the
For more details, see Image-specific variables.
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 normal Bluetooth LE bonding can be used only if the Fast Pair discoverable advertising mode is selected. In other Fast Pair advertising modes, the device rejects the normal Bluetooth LE bonding.
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.
Before you can use your device as a Fast Pair Provider, the device model must be registered with Google. This is required to obtain Model ID and Anti-Spoofing Private Key. You can register your own device or use the debug Model ID and Anti-Spoofing Public/Private Key pair obtained by Nordic for development purposes. By default, if Model ID and Anti-Spoofing Private Key are not specified, the following debug Fast Pair provider is used:
NCS input device - The input device Fast Pair provider:
Device Name: NCS input device
Anti-Spoofing Private Key (base64, uncompressed):
Device Type: Input Device
Notification Type: Fast Pair
Data-Only connection: true
No Personalized Name: false
See Provisioning the device in the Fast Pair user guide for details.
This is the debug Fast Pair provisioning data obtained by Nordic for the development purposes. It should not be used in production.
To test with the debug mode Model ID, you must configure the Android device to include the debug results while displaying the nearby Fast Pair Providers. For details, see Verifying Fast Pair in the GFPS documentation.
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 or HFP) option when registering the 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, you must configure the Android device 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.
The sample supports a simple user interface. You can control the sample using predefined buttons, while LEDs are used to display information.
- 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.
See Configuring and building an application for information about how to permanently or temporarily change the configuration.
This sample can be found under
samples/bluetooth/fast_pair/input_device in the nRF Connect SDK folder structure.
When built as firmware image for the
_ns build target, the sample has Cortex-M Security Extensions (CMSE) enabled and separates the firmware between Non-Secure Processing Environment (NSPE) and Secure Processing Environment (SPE).
Because of this, it automatically includes the Trusted Firmware-M (TF-M).
To read more about CMSE, see Processing environments.
To build the sample with Visual Studio Code, follow the steps listed on the How to build an application page in the nRF Connect for VS Code extension documentation. See Configuring and building an application for other building scenarios, Programming an application for programming steps, and Testing for general information about testing and debugging in the nRF Connect SDK.
When building the sample, you can provide the Fast Pair Model ID (
FP_MODEL_ID) and the Fast Pair Anti-Spoofing Key (
FP_ANTI_SPOOFING_KEY) as CMake options.
If the data is not provided, the sample uses the default provisioning data obtained for the NCS input device (the input device debug Fast Pair provider).
See Provisioning the device for detailed guide.
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.
After programming the sample to your development kit, complete the following steps to test it:
Connect to the kit that runs this sample with a terminal emulator (for example, nRF Connect Serial Terminal). See Testing and optimization for the required settings and steps. The sample provides Fast Pair debug logs to inform about state of the Fast Pair procedure.
Reset the kit.
Observe that LED 1 is blinking (firmware is running) and LED 3 is lit (device is Fast Pair discoverable). This means that the device is now working as Fast Pair Provider and is advertising.
On the Android device, go to Settings > Google > Devices & sharing (or Device connections, depending on your Android device configuration) > Devices.
Move the Android device close to the Fast Pair Provider that is advertising.
Wait for Android device’s notification about the detected Fast Pair Provider. If you use the Model ID certified by Google, the notification is similar to the following:
The device model name and displayed logo depend on the data provided during the device model registration.
If you use the debug Model ID (for example, the default is NCS input device), the notification is similar to the following:
The device model name is covered by asterisks and the default Fast Pair logo is displayed instead of the one specified during the device model registration.
Tap the Connect button to initiate the connection and trigger the Fast Pair procedure. After the procedure has completed, the pop-up is updated to inform about successfully completed Fast Pair procedure. LED 2 is lit to indicate that the device is connected with the Bluetooth Central.
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.
You can now use the connected Fast Pair Provider to control audio volume of the Bluetooth Central.
Press Button 2 to increase the audio volume.
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:
Disconnect the Android device that was used during the default Testing:
Go to Settings > Bluetooth.
Tap on the connected device name to disconnect it.
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.
Make sure that the Fast Pair Provider is added to Saved devices on the Android device that was used for Testing:
Go to Settings > Google > Devices & sharing (or Device connections) > Devices > Saved devices.
Verify that the paired device is appearing on the list.
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.
Wait until the Fast Pair Provider is added to Saved devices on the second Android device:
Go to Settings > Google > Devices & sharing (or Device connections) > Devices > Saved devices. The paired device appears on the list.
If the device does not appear on the list, wait until the data is synced between phones.
Move the second Android device close to the Fast Pair Provider. If you use the Model ID certified by Google and the device is in the show UI indication advertising mode, a notification similar to the following one appears:
If you use the debug Model ID (for example, the default is NCS input device) and the device is in the show UI indication advertising mode, a notification similar to the following one appears:
The Nordic name is replaced by your own Google account name as this is a default name created by the Fast Pair Seeker during the initial pairing.
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.
In the show UI indication mode, when the notification appears, tap on it to trigger the Fast Pair procedure.
Wait for the notification about successful Fast Pair procedure. LED 2 is lit to inform that the device is connected with the Bluetooth Central.
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.
You can now use the connected Fast Pair Provider to control the audio volume of the Bluetooth Central.
Press Button 2 to increase the audio volume.
Press Button 4 to decrease the audio volume.
Personalized Name extension
Testing Personalized Name extension is described in Fast Pair Certification Guidelines for Personalized Name.
To mitigate Android Personalized Name write issues, whenever you change the Personalized Name on an Android phone, perform the following:
Write the new Personalized Name.
Disconnect the phone from the Fast Pair Provider.
Put the Fast Pair Provider in not discoverable advertising mode.
The phone reconnects and sends new Personalized Name to the Fast Pair Provider.
Battery Notification extension
Complete the following steps to test Fast Pair Battery Notification extension:
Pair the Fast Pair Provider with at least one Fast Pair Seeker.
Set the Fast Pair Provider in not discoverable advertising mode.
Verify that the Provider is advertising sample battery data using the nRF Connect for Mobile application.
Currently, Android phones have trouble with the Battery Notification extension and sometimes do not display battery information as a user indication.
The sample uses subsystems and firmware components available in the nRF Connect SDK. For details, see the sections below.
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 Google Fast Pair integration 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 Bluetooth LE advertising providers are used to generate Bluetooth advertising and scan response data. The sample uses the following providers to generate the advertising packet payload:
Advertising flags provider (
TX power provider (
Google Fast Pair provider (
Sample-specific provider that appends UUID16 values of GATT Human Interface Device Service (HIDS) and GATT Battery Service (BAS)
The sample uses the following providers to generate the scan response data:
The sample also uses the following secure firmware component: