Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Current Time Service (CTS)

Current Time Service (CTS) . More...

Data Structures

struct  bt_cts_time_format
 Current Time service data format, Please refer to specifications for more details. More...
 
struct  bt_cts_cb
 Current Time Service callback structure. More...
 

Enumerations

enum  bt_cts_update_reason {
  BT_CTS_UPDATE_REASON_UNKNOWN = 0 , BT_CTS_UPDATE_REASON_MANUAL = BIT(0) , BT_CTS_UPDATE_REASON_EXTERNAL_REF = BIT(1) , BT_CTS_UPDATE_REASON_TIME_ZONE_CHANGE = BIT(2) ,
  BT_CTS_UPDATE_REASON_DAYLIGHT_SAVING = BIT(3)
}
 CTS time update reason bits as defined in the specification. More...
 

Functions

int bt_cts_init (const struct bt_cts_cb *cb)
 This API should be called at application init.
 
int bt_cts_send_notification (enum bt_cts_update_reason reason)
 Notify all connected clients that have enabled the current time update notification.
 
int bt_cts_time_to_unix_ms (const struct bt_cts_time_format *ct_time, int64_t *unix_ms)
 Helper API to decode CTS formatted time into milliseconds since epoch.
 
int bt_cts_time_from_unix_ms (struct bt_cts_time_format *ct_time, int64_t unix_ms)
 Helper API to encode milliseconds since epoch to CTS formatted time.
 

Detailed Description

Current Time Service (CTS) .

Enumeration Type Documentation

◆ bt_cts_update_reason

#include <zephyr/bluetooth/services/cts.h>

CTS time update reason bits as defined in the specification.

Enumerator
BT_CTS_UPDATE_REASON_UNKNOWN 
BT_CTS_UPDATE_REASON_MANUAL 
BT_CTS_UPDATE_REASON_EXTERNAL_REF 
BT_CTS_UPDATE_REASON_TIME_ZONE_CHANGE 
BT_CTS_UPDATE_REASON_DAYLIGHT_SAVING 

Function Documentation

◆ bt_cts_init()

int bt_cts_init ( const struct bt_cts_cb * cb)

#include <zephyr/bluetooth/services/cts.h>

This API should be called at application init.

it is safe to call this API before or after bt_enable API

Parameters
cbpointer to required callback
Returns
0 on success
negative error codes on failure

◆ bt_cts_send_notification()

int bt_cts_send_notification ( enum bt_cts_update_reason reason)

#include <zephyr/bluetooth/services/cts.h>

Notify all connected clients that have enabled the current time update notification.

Parameters
reasonupdate reason to be sent to the clients
Returns
0 on success
negative error codes on failure

◆ bt_cts_time_from_unix_ms()

int bt_cts_time_from_unix_ms ( struct bt_cts_time_format * ct_time,
int64_t unix_ms )

#include <zephyr/bluetooth/services/cts.h>

Helper API to encode milliseconds since epoch to CTS formatted time.

Note
CONFIG_BT_CTS_HELPER_API 
needs to be enabled to use this API.
Parameters
ct_time[OUT] Pointer to store CTS formatted time
unix_ms[IN] milliseconds since epoch to be converted
Returns
0 on success
negative error codes on failure

◆ bt_cts_time_to_unix_ms()

int bt_cts_time_to_unix_ms ( const struct bt_cts_time_format * ct_time,
int64_t * unix_ms )

#include <zephyr/bluetooth/services/cts.h>

Helper API to decode CTS formatted time into milliseconds since epoch.

Note
CONFIG_BT_CTS_HELPER_API 
needs to be enabled to use this API.
Parameters
ct_time[IN] cts time formatted time
unix_ms[OUT] pointer to store parsed millisecond since epoch
Returns
0 on success
negative error codes on failure