nRF51 SDK - S130 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Current Time Application

The Current Time Application is an example that implements the client role of the Current Time Profile using the hardware delivered in the nRF51 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 11
  Year          86

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

The name of the example is ble_app_cts_c_s130_pca10028. If you are not using the Keil Pack Installer, you can find the source code and 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:

  • During Connection:
    • Button 1: Read the current time from the connected central.

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.

The application uses the following UART settings:

  • Baud rate: 38.400
  • 8 data bits
  • 1 stop bit
  • No parity
  • HW flow control: RTS/CTS

Testing

Test the Current Time Application with the Master Control Panel by performing the following steps:

  1. Compile and download the application. Observe that the BSP_INDICATE_ADVERTISING state is indicated.
  2. In the Master Control Panel, create the Current Time Service (CTS) server by performing the following steps:
    1. Click File -> Server Setup. In the window that opens up, click File -> Load setup.
    2. In the resulting window, navigate to the <InstallFolder>\examples\ble_peripheral\ble_app_cts_c folder. If you are using Keil packs, this folder is located at <KeilFolder>\ARM\Pack\NordicSemiconductor\nRF_Examples\<version>\ble_peripheral\ble_app_cts_c. Load the file cts_central.bin.
    3. Click 'Stop server' and then 'Start server'.
    4. You must keep the 'Server Setup' window opened.
  3. Select the device from Master Control Panel (the device will be advertising as 'Nordic_CTS'), connect and bond. 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. In the 'Server Setup' window, set the values of characteristics with UUID 0x2A2B to C2-07-0B-0F-0D-25-2A-06-FE-08 and press 'update'.
  6. Press button 1. 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 from the Master Control Panel 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 connect to the Master Control Panel. Observe that the BSP_INDICATE_CONNECTED state is indicated.
  10. Disconnect from the Master Control Panel.