Bluetooth: Continuous Glucose Monitoring Service (CGMS)

The Peripheral Continuous Glucose Monitoring Service (CGMS) sample demonstrates how to use the GATT Continuous Glucose Monitoring Service (CGMS) to implement a glucose monitoring device.

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Build target

nRF54H20 DK

PCA10175

nrf54h20dk_nrf54h20_cpuapp

nrf54h20dk_nrf54h20_cpuapp

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

nRF52833 DK

PCA10100

nrf52833dk_nrf52833

nrf52833dk_nrf52833

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.

Overview

The sample demonstrates a basic Bluetooth® Low Energy Peripheral role functionality that exposes the Continuous Glucose Monitoring GATT Service. Once it connects to a Central device, it generates dummy glucose measurement values. You can use it together with the Continuous Glucose module in the nRF Toolbox app. You can also use the nRF Connect for Mobile to interact with the CGMS module.

Building and running

This sample can be found under samples/bluetooth/peripheral_cgms 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 and optimization for general information about testing and debugging in the nRF Connect SDK.

Testing

After programming the sample to your development kit, connect to a smartphone with the nRF Toolbox installed to test it as follows:

  1. 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.

  2. Reset the development kit.

  3. Open the nRF Toolbox app and select the Continuous Glucose module.

  4. Click the name of the development kit to connect to it.

    Authentication is required. The device prints the pairing key in the terminal.

  5. Enter the pairing key on the client side.

  6. If pairing is successful, in the terminal window, observe that notifications are enabled:

    <inf> cgms: CGMS Measurement: notification enabled
    <inf> cgms: CGMS RACP: indication enabled
    <inf> cgms: CGMS SOCP: indication enabled
    
  7. The glucose measurement is sent to the client using a notification. The client can also retrieve the record using the record access control point.

Dependencies

This sample uses the following Zephyr libraries:

  • include/zephyr/types.h

  • include/errno.h

  • include/zephyr.h

  • include/sys/printk.h

  • include/sys/byteorder.h

  • Bluetooth APIs:

  • include/bluetooth/bluetooth.h

  • include/bluetooth/conn.h

  • include/bluetooth/uuid.h

  • include/bluetooth/gatt.h

  • include/bluetooth/services/cgms.h