nRF5 SDK v15.0.0
Experimental: Continuous Glucose Monitoring Application
This example requires one of the following SoftDevices: S112, S132, S140

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

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

The application includes the three services in the Glucose Profile:

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 measurements. 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 Button 1 to restart advertising.
  • This application advertises with whitelist when it is bonded.
  • Measurement notifications are only received once a minute. Therefore, the first measurement is received one minute after measurements are started.

Setup

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

Testing

Test the Continuous 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 nRF Connect by performing the following steps:

Establishing a connection and receiving measurements

  1. Compile and program the application. Observe that the BSP_INDICATE_ADVERTISING state is indicated.
  2. Connect to the device from nRF Connect (the device is advertising as 'Nordic_CGMS'), then bond to the device. To bond, click the settings button for the device in nRF Connect, select "Pair", check "Perform Bonding", and click "Pair". Wait until the bond is established before you continue. Observe that the BSP_INDICATE_CONNECTED state is indicated.
  3. Observe that the services are shown in the connected device and that you can start receiving values by clicking the 'Play' button. Battery Level notifications are received every ten seconds.
  4. Start a CGM session by clicking the 'Play' button and then write '1A' to the Specific Operations Control Point (UUID 0x2AAC).
  5. 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)
  6. Observe that measurement notifications are received on the Measurement characteristic (UUID 0x2AA7). An example measurement is '06 00 05 00 01 00' (length 06, flags 00, Glucose Concentration 0005, offset 0001).
  7. Stop the CGM session by writing '1B' to the Specific Operations Control Point (UUID 0x2AAC).
  8. Observe that no measurement is received after stopping the session.

Testing the Session Start Time characteristic

If the application is provided with the current time, it can calculate the start time of the session based on the relative time it has been running.

  1. Write 'C2 07 0B 0F 0D 25 00 00' (Session Start Time: 1986 November 15th 13:37.42, Time Zone: UTC 0, DST-Offset: Standard Time) to the Session Start Time characteristic (0x2AAA).
  2. Read the characteristic and observe that the time is earlier than the provided time. The time difference corresponds to the duration of the session. For example, an 8 minute session will return the time 1986 November 15th 13:29.42.

Testing the Session Run Time characteristic

  1. Read the Session Run Time characteristic (0x2AAB) and observe that the value is '14 00' (20 hours).

Testing the Record Access Control Point

  1. Do a Read all records operation:
    • Write '01 01' (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).
  2. Read the number of stored records:
    • Write '04 01' (OpCode: REPORT_NUM_STORED_RECORDS, Operator: ALL_STORED_RECORDS) to the Record Access Control Point (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).
  3. Read the number of stored records with time offset greater than or equal to a specified time offset:
    • Write '04 03 01 02 00' (OpCode: REPORT_NUM_STORED_RECORDS, Operator: GREATER_OR_EQUAL, Operand: [FILTER_TYPE_TIME_OFFSET, 2 minutes]) to the Record Access Control Point (UUID 0x2A52).
    • Observe that you get an indication of the RACP giving you the number of records with time offset less or equal to the operand.
  4. Read the number of stored records with time offset less than or equal to a specified time offset:
    • Write '04 02 01 02 00' (OpCode: REPORT_NUM_STORED_RECORDS, Operator: LESS_OR_EQUAL, Operand: [FILTER_TYPE_TIME_OFFSET, 2 minutes]) to the Record Access Control Point (UUID 0x2A52).
    • Observe that you get an indication of the RACP giving you the number of records with time offset less or equal to the operand.
  5. Read all records with a time offset greater than or equal to a specified time offset:
    • Write '01 03 01 02 00' (OpCode : REPORT_STORED_RECORDS, Operator : GREATER_OR_EQUAL, Operand: [FILTER_TYPE_TIME_OFFSET, 2 minutes]) to the 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). The glucose measurements will be all measurements in the database with time offset greater than or equal to 2.
  6. Read all records with a time offset less than or equal to a specified time offset:
    • Write '01 03 01 02 00' (OpCode : REPORT_STORED_RECORDS, Operator : LESS_OR_EQUAL, Operand: [FILTER_TYPE_TIME_OFFSET, 2 minutes]) to the 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). The glucose measurements will be all measurements in the database with time offset less than or equal to 2.

Testing the Bond Management Service

Test the Bond Management Service by deleting the bond that the application has with nRF Connect:

  1. Disconnect the device and reconnect in nRF Connect. Observe that the devices are still bonded. (Link encryption is ON.)
  2. 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.
  3. Write '03 41 42 43 44' (Command to delete current bond 03, authorization code ABCD) to the Bond Management Service Control Point characteristic (0x2AA4).
  4. Disconnect the device. This will trigger the bond deletion procedures.
  5. Connect to the device again and observe that the pairing request fails, ending in a link loss. (BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION)

Documentation feedback | Developer Zone | Subscribe | Updated