nRF5 SDK v15.0.0
Current Time 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 Current Time Application is an example that implements the client role of the Current Time Profile using the hardware delivered in the nRF5 Development Kit.

This application utilizes the client implementation of the Current Time Service:

Note
This application is not power optimized!

The purpose of this example is to use the Current Time Service to read the current time. The time is printed on the UART in the following format:

Date:
  Day of week   Saturday
  Day of month  15
  Month of year November
  Year          1986

Time:
    Hours     13
    Minutes   37
    Seconds   42
    Fractions 254/256 of a second

Adjust Reason:
    Daylight savings 1
    Time zone        0
    External update  0
    Manual update    0

Bonding is usually initiated by the central device. If it is not initiated within a specific time-out period, the application initiates bonding.

The current implementation requires security to be established before service discovery. After service discovery has been completed, Button 1 can be used to read the current time (if the Current Time Service and Characteristic are found on the central side).

Setup

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

Button assignments - in addition to those defined in BSP BLE Button Assignments:

The Current Time Application does fast advertising for 30 seconds at power up and also after a disconnection. It will then switch to slow advertising mode for 180 seconds. After 180 seconds of slow advertising, the board will go to system-off. If the device is bonded, fast advertising and slow advertising are done with the whitelist.

The application uses the following UART settings:

Testing

Test the Current Time Application with nRF Connect by performing the following steps:

  1. Compile and download the application. Observe that the BSP_INDICATE_ADVERTISING state is indicated.
  2. In nRF Connect, create the Current Time Service (CTS) server by performing the following steps:
    1. In Server Setup, click the settings button and select "Load setup".
    2. In the resulting window, navigate to the <InstallFolder>\examples\ble_peripheral\ble_app_cts_c folder. Load the file cts_central.ncs.
    3. Click "Apply to device" and navigate back to Connection Map.
  3. Bond to the device from nRF Connect (the device is advertising as 'Nordic_CTS'). To bond, click the settings button for the server in nRF Connect, select "Security parameters", check "Perform Bonding", and click "Apply". Then connect to the device. Observe that the BSP_INDICATE_CONNECTED state is indicated.
  4. After the security procedure is complete, verify that the Current Time Service on the server has been discovered. The message "Current Time Service discovered on server." will be printed on the UART.
  5. On the connecting device, set the values of the Current Time characteristic (UUID 0x2A2B) to 'C2 07 0B 0F 0D 25 2A 06 FE 08' and click 'Write'.
  6. Press Button 1 on the board. Verify that the current time printed on the UART matches the time that was input in the Current Time characteristic (UUID 0x2A2B) (see the example UART output).
  7. Disconnect the device in nRF Connect and observe that the BSP_INDICATE_ADVERTISING state is indicated.
  8. Wait until the application goes to system-off (BSP_INDICATE_IDLE).
  9. Press Button 1 and reconnect to nRF Connect. Observe that the BSP_INDICATE_CONNECTED state is indicated.
  10. Disconnect from nRF Connect.

Documentation feedback | Developer Zone | Subscribe | Updated