| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Experimental: Continuous Glucose Monitoring Application
This example requires one of the following SoftDevices: S130, S132

Important: Before you run this example, make sure to program the SoftDevice.

The Continuos Glucose Monitoring Application is an example that implements a sensor according to the Continuos Glucose Monitoring Profile.

The application includes the three services in the Glucose Profile:

- Continuous Glucose Monitoring Service
- Bond Management Service
- Device Information Service

In addition, use of the Battery Service is also demonstrated.

When the application starts, a timer for generating battery measurements is started. A timer is also started to generate glucose measurments. That will appear after a "session" is started.

Note
  This application is not power optimized!
  The application will stop advertising after 3 minutes and go to system-off mode. Push the button 1 to restart advertising.

# Setup

You can find the source code and the project file of the example in the following folder: `<InstallFolder>\examples\ble_peripheral\ble_app_cgms`

# Testing

Test the Continuos Glucose Monitoring Application with the nRF Toolbox app, which is available on both iOS (App Store) and Android (Google Play).

You can also test the application with the Master Control Panel by performing the following steps:

1. Compile and program the application. Observe that the BSP_INDICATE_ADVERTISING state is indicated.
2. Connect and to the device from Master Control Panel (the device will be advertising as 'Nordic_CGMS')
3. Bond to the device.
4. Perform service discovery. Observe that the BSP_INDICATE_CONNECTED state is indicated.
5. Click the 'Enable services' button on the Master Control Panel.
6. Observe that Battery Level notifications are received every 10 seconds.
7. Start a CGM session by writing 1A to the Specific Operations Control Point (UUID 0x2AAC).
8. Observe that the notification 1C-1A-01 (Response code 1C - Session start 1A - Success 01) is received on the Specific Operations Control Point (UUID 0x2AAC)
9. Observe that measurments notifications are received on the Measurment characteristic (UUID 0x2AA7). An example measurment is 06-00-05-00-01-00 (length 06, flags 00, Glucose Concentration 0005, offset 0001).
10. Do a Read all records operation:
    - Write 0101 (OpCode : REPORT_STORED_RECORDS, Operator : ALL_STORED_RECORDS) to Record Access
    - Control Point Characteristic (UUID 0x2A52).
    - Observe that you receive notifications of the glucose measurements(UUID 0x2AA7) and one indication of the RACP indicating success (06000101);
11. Read the number of stored records:
    - Write 0401 (OpCode: REPORT_NUM_STORED_RECORDS, Operator: ALL_STORED_RECORDS) to Record Access Control Point
    - Characteristic (UUID 0x2A52).
    - Observe that you get an indication of the RACP giving you the number of records. For example, 05000400 is 4 records (Number of records response opcode 05, Operator 00, least significant byte of record number 04, most significant byte of record number 00).
12. Testing the bond management service. We will delete the bond that the application has with the master control panel:
13. Disconnect from the device and Connect again. Observe that the devices are still bonded. (Link encryption is ON).
14. Observe that the Feature characteristic (0x2AA5) of the Bond management Service (0x181E) displays 20-08-00. This means that the deletion of the bonds for the current connection is supported.
15. Write 03-41-42-43-44 (Command to delete current bond 03, authorization code ABCD) to the Bond Management Service Control Point characteristic (0x2AA4).
16. Disconnect from the device. This will trigger the bond deletion procedures.
17. Connect to the device again and observe that the pairing request fails, ending in a link loss. (BTLE_REMOTE_USER_TERMINATED_CONNECTION)