The Bluefruit nRF52 BSP codebase is undergoing active development based on customer feedback and testing. As such, the class documentation here is incomplete, and you should consult the Github repo for the latest code and API developments:

BLEClientCts is a helper class that implements adopted Current Time Service , which enables you to receive time from devices such as an iPhone or iPad.


// Callback Signatures
typedef void (*adjust_callback_t) (uint8_t reason);


virtual bool  begin(void);
virtual bool  discover(uint16_t conn_handle);

bool getCurrentTime(void);
bool getLocalTimeInfo(void);

bool enableAdjust(void);
void setAdjustCallback(adjust_callback_t fp);

struct ATTR_PACKED {
  uint16_t year;
  uint8_t  month;
  uint8_t  day;
  uint8_t  hour;
  uint8_t  minute;
  uint8_t  second;
  uint8_t  weekday;
  uint8_t  subsecond;
  uint8_t  adjust_reason;
} Time;

struct ATTR_PACKED {
  int8_t  timezone;
  uint8_t dst_offset;

Client CTS OLED Example

The client_cts_oled example uses the Adafruit FeatherWing OLED to display received time.

Sketch Requirements

In order to use this example sketch the following libraries must be installed on your system:

Loading the Sketch

The client_cts_oled sketch can be loaded via the examples menu under Peripheral > client_cts_oled:

With the sketch loaded, you can build the firmware and then flash it to your device via the Upload button or menu option. Once the sketch is running on the nRF52 Feather you can proceed with the one-time pairing process, described below.

Make sure that the Adafruit_SSD1306.h file has the 'SSD1306_128_32' macro enabled. Running the sketch with 'SSD1306_128_64' set will cause corrupted data to appear on the OLED display.

Pairing to your Mobile Device

Before you can start receiving notifications, you will need to 'pair' the nRF52 Feather and the mobile device.

The pairing process causes a set of keys to be exchanged and stored on the two devices so that each side knows it is talking to the same device it originally bonded with, and preventing any devices in the middle from eavesdropping on potentially sensitive data.

The one-time pairing process is described below, and assumes you are already running the ancs_oled sketch on your nRF52 device.

1. In the Settings app go to Bluetooth:

2. Scroll to the bottom of the list of 'My Devices' and click on Bluefruit52 under Other Devices:

3. When the pairing dialog box comes up, click the Pair button:

4. Wait for the pairing process to complete, at which point Bluefruit52 should appear in the My Devices list with the Connected status:

Once two devices have been paired, they will automatically reconnect to each other whenever they are in range and have their Bluetooth radios enabled.

Wait for Time Data

At this point,  time data from the mobile device will be read and display on the the OLED. For demo purpose the sketch will read time data from mobile once every second. However, in reality, nRF52 should have an internal timer that keep track of second, and only read/sync with mobile after several hours or days, similar to how IP device got time from NTP server.

This guide was first published on Mar 11, 2020. It was last updated on Jun 13, 2024.

This page (BLEClientCts) was last updated on Mar 08, 2024.

Text editor powered by tinymce.