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 |
Board target |
---|---|---|---|
PCA10175 |
|
||
PCA10095 |
|
||
PCA10040 |
|
||
PCA10056 |
|
||
PCA10100 |
|
When built for a board target with the */ns
variant, 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 a board target with the */ns
variant, 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, follow the instructions in Building an application for your preferred building environment. See also Programming an application for programming steps and Testing and optimization for general information about testing and debugging in the nRF Connect SDK.
Note
When building repository applications in the SDK repositories, building with sysbuild is enabled by default.
If you work with out-of-tree freestanding applications, you need to manually pass the --sysbuild
parameter to every build command or configure west to always use it.
Testing
After programming the sample to your development kit, connect to a smartphone with the nRF Toolbox installed to test it as follows:
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.
Reset the development kit.
Open the nRF Toolbox app and select the Continuous Glucose module.
Click the name of the development kit to connect to it.
Authentication is required. The device prints the pairing key in the terminal.
Enter the pairing key on the client side.
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
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
API:
include/bluetooth/bluetooth.h
include/bluetooth/conn.h
include/bluetooth/uuid.h
include/bluetooth/gatt.h
include/bluetooth/services/cgms.h