Bluetooth: Continuous Glucose Monitoring Service
The Continuous Glucose Monitoring Service sample demonstrates how to implement the Continuous Glucose Monitoring Service profile using nRF Connect SDK Bare Metal option.
Requirements
The sample supports the following development kits:
The following board variants do not have DFU capabilities:
S115:
Hardware platform
PCA
Board target
PCA10156
bm_nrf54l15dk/nrf54l15/cpuapp/s115_softdevicenRF54L15 DK (emulating nRF54L10)
PCA10156
bm_nrf54l15dk/nrf54l10/cpuapp/s115_softdevicenRF54L15 DK (emulating nRF54L05)
PCA10156
bm_nrf54l15dk/nrf54l05/cpuapp/s115_softdevicePCA10184
bm_nrf54lm20dk/nrf54lm20a/cpuapp/s115_softdevicePCA10214
bm_nrf54ls05dk/nrf54ls05b/cpuapp/s115_softdevicenRF54LS05 DK (emulating nRF54LS05A)
PCA10214
bm_nrf54ls05dk/nrf54ls05a/cpuapp/s115_softdevicePCA10188
bm_nrf54lv10dk/nrf54lv10a/cpuapp/s115_softdevice
S145:
Hardware platform
PCA
Board target
PCA10156
bm_nrf54l15dk/nrf54l15/cpuapp/s145_softdevicenRF54L15 DK (emulating nRF54L10)
PCA10156
bm_nrf54l15dk/nrf54l10/cpuapp/s145_softdevicenRF54L15 DK (emulating nRF54L05)
PCA10156
bm_nrf54l15dk/nrf54l05/cpuapp/s145_softdevicePCA10184
bm_nrf54lm20dk/nrf54lm20a/cpuapp/s145_softdevicePCA10214
bm_nrf54ls05dk/nrf54ls05b/cpuapp/s145_softdevicenRF54LS05 DK (emulating nRF54LS05A)
PCA10214
bm_nrf54ls05dk/nrf54ls05a/cpuapp/s145_softdevicePCA10188
bm_nrf54lv10dk/nrf54lv10a/cpuapp/s145_softdevice
The following board variants have DFU capabilities:
S115:
Hardware platform
PCA
Board target
PCA10156
bm_nrf54l15dk/nrf54l15/cpuapp/s115_softdevice/mcubootnRF54L15 DK (emulating nRF54L10)
PCA10156
bm_nrf54l15dk/nrf54l10/cpuapp/s115_softdevice/mcubootnRF54L15 DK (emulating nRF54L05)
PCA10156
bm_nrf54l15dk/nrf54l05/cpuapp/s115_softdevice/mcubootPCA10184
bm_nrf54lm20dk/nrf54lm20a/cpuapp/s115_softdevice/mcubootPCA10214
bm_nrf54ls05dk/nrf54ls05b/cpuapp/s115_softdevice/mcubootnRF54LS05 DK (emulating nRF54LS05A)
PCA10214
bm_nrf54ls05dk/nrf54ls05a/cpuapp/s115_softdevice/mcubootPCA10188
bm_nrf54lv10dk/nrf54lv10a/cpuapp/s115_softdevice/mcuboot
S145:
Hardware platform
PCA
Board target
PCA10156
bm_nrf54l15dk/nrf54l15/cpuapp/s145_softdevice/mcubootnRF54L15 DK (emulating nRF54L10)
PCA10156
bm_nrf54l15dk/nrf54l10/cpuapp/s145_softdevice/mcubootnRF54L15 DK (emulating nRF54L05)
PCA10156
bm_nrf54l15dk/nrf54l05/cpuapp/s145_softdevice/mcubootPCA10184
bm_nrf54lm20dk/nrf54lm20a/cpuapp/s145_softdevice/mcubootPCA10214
bm_nrf54ls05dk/nrf54ls05b/cpuapp/s145_softdevice/mcubootnRF54LS05 DK (emulating nRF54LS05A)
PCA10214
bm_nrf54ls05dk/nrf54ls05a/cpuapp/s145_softdevice/mcubootPCA10188
bm_nrf54lv10dk/nrf54lv10a/cpuapp/s145_softdevice/mcuboot
Overview
The Continuous Glucose Monitoring Service (CGMS) is a service that exposes glucose and other data from a personal Continuous Glucose Monitoring sensor.
Allow list
By default, the sample does not use allow-list advertising, which means that any nearby device can connect and bond with the device. Bonded devices are stored in internal non-volatile memory (NVM) and are remembered across power cycles.
You can enable allow-list advertising by setting the CONFIG_BLE_ADV_USE_ALLOW_LIST Kconfig option to y in the base Kconfig fragment (prj.conf).
When enabled, only previously bonded devices are allowed to reconnect, which allows faster reconnection and prevents unknown devices from connecting.
When allow-list advertising is enabled and you want to add a new bonded device, existing bonds must first be deleted. This can be done through user interaction, as described in the user interface section.
User interface
- Button 0:
When pairing with authentication, press this button to confirm the passkey shown in the COM listener and complete pairing with the other device. See Testing.
- Button 1:
Keep the button pressed while resetting the board to delete bonding information for all peers stored on the device.
When pairing with authentication, press this button to reject the passkey shown in the COM listener to prevent pairing with the other device.
- Button 2:
Decrease the simulated glucose concentration.
- Button 3:
Increase the simulated glucose concentration.
- LED 0:
Lit when the device is initialized.
- LED 1:
Lit when a device is connected.
Security
The sample integrates Bluetooth: Peer Manager (backed by Bare Metal Zephyr Memory Storage (BM_ZMS) for persistent storage) to support pairing and bonding.
The following security parameters are configured:
Parameter |
Value |
Effect |
|---|---|---|
Bonding |
True |
Supports storing of pairing information (bonding data). |
MITM protection |
False |
Man-in-the-middle protection not required. |
LE Secure Connections |
True |
Supports LESC pairing. |
I/O capabilities |
Display and Yes/No entry |
Determines local I/O capability, actual pairing method depends on negotiation with peer. |
This sample configures the following services and their characteristics with these specific operation modes and required security levels:
Service |
Characteristic |
Operation |
Required security |
Effect |
|---|---|---|---|---|
Continuous Glucose Monitoring Service |
CGM Measurement |
Notify |
Encryption, no authentication |
Connection must be encrypted to subscribe to and receive periodic glucose measurement notifications. |
Feature |
Read |
Encryption, no authentication |
Connection must be encrypted to read which optional CGM features the sensor supports. |
|
Status |
Read |
Encryption, no authentication |
Connection must be encrypted to read the time offset and sensor status. |
|
Session Start Time |
Read/Write |
Encryption, no authentication |
Connection must be encrypted to read or set the timestamp that marks when the monitoring session started. |
|
Session Run Time |
Read |
Encryption, no authentication |
Connection must be encrypted to read the expected run time of the CGM session. |
|
Record Access Control Point |
Write/Indicate |
Encryption, no authentication |
Connection must be encrypted to retrieve, filter, or delete stored glucose measurement records. |
|
Specific Ops Control Point |
Write/Indicate |
Encryption, no authentication |
Connection must be encrypted to start or stop a monitoring session and configure settings such as the communication interval. |
|
Device Information Service |
All characteristics |
Read |
Encryption, no authentication |
Connection must be encrypted to read device information such as the manufacturer name and firmware version. |
Battery Service |
Battery Level |
Read/Notify |
Open, no security |
Any connected device can read the battery level and subscribe to battery level notifications. |
See Testing for the pairing and bonding steps.
Building and running
This sample can be found under samples/bluetooth/ble_cgms/ in the Bare Metal folder structure.
For details on how to create, configure, and program a sample, see Getting Started with the samples.
Testing
Compile and program the application.
Connect the device to the computer.
Connect to the kit with a terminal emulator (for example, the Serial Terminal app). Note that the kit has two UARTs, where only one will output the log.
Reset the kit.
In the Serial Terminal, observe that the
BLE CGMS sample initializedmessage is printed.Observe that the
Advertising as nRF_BM_CGMSmessage is printed. You can configure this name using theCONFIG_SAMPLE_BLE_DEVICE_NAMEKconfig option. For information on how to do this, see Configuring Kconfig.Connect to your device using the nRF Toolbox mobile application with the Continuous Glucose service. If the device is not advertising, reset the board with the Reset Board option in Visual Studio Code or by pressing the reset button on the development kit.
Your mobile phone should now attempt to pair with your device to encrypt the link. When prompted, check that the passkeys are the same before confirming by pressing Button 0 on the kit and confirming on the mobile phone.
Observe that the text
ConnectedandCGMS Start Sessionis printed in the COM listener.Observe that you receive the CGMS records in the mobile application. The default time between each record is one minute.