Zephyr API Documentation 4.3.99
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_local_time
 CTS Local Time Information. More...
struct  bt_cts_cb
 Current Time Service callback structure. More...

Macros

#define BT_CTS_ATT_ERR_VALUES_IGNORED   0x80U
 ATT error code for ignored values during CTS write operations.
#define BT_CTS_FRACTION_256_MAX_VALUE   255U
 Maximum value for the 1/256-second fractions field in CTS time format.
#define BT_CTS_TIMEZONE_DEFAULT_VALUE   -128
 Default timezone offset value indicating the timezone is unknown (15-minute increments).
#define BT_CTS_TIMEZONE_INCREMENT_MIN   15U
 Timezone offset increment in minutes.
#define BT_CTS_DST_INCREMENT_MIN   15U
 DST offset increment in minutes.
#define BT_CTS_TIMEZONE_MIN   -48
 Minimum valid timezone offset in 15-minute increments (-48 means UTC-12:00).
#define BT_CTS_TIMEZONE_MAX   56
 Maximum valid timezone offset in 15-minute increments (56 means UTC+14:00).

Enumerations

enum  bt_cts_dst_offset {
  BT_CTS_DST_OFFSET_STANDARD_TIME = 0 , BT_CTS_DST_OFFSET_HALF_HOUR_DAYLIGHT_TIME = 2 , BT_CTS_DST_OFFSET_DAYLIGHT_TIME = 4 , BT_CTS_DST_OFFSET_DOUBLE_DAYLIGHT_TIME = 8 ,
  BT_CTS_DST_OFFSET_UNKNOWN = 255
}
 Daylight Saving Time (DST) offsets as defined in the specification. More...
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 with CTS enabled.
int bt_cts_time_to_unix_ms (const struct bt_cts_time_format *ct_time, int64_t *unix_ms)
 Convert CTS formatted time to milliseconds since epoch.
int bt_cts_time_from_unix_ms (struct bt_cts_time_format *ct_time, int64_t unix_ms)
 Convert milliseconds since epoch to CTS formatted time.
int bt_cts_local_time_to_ms (const struct bt_cts_local_time *local_time, int32_t *relative_ms)
 Convert CTS local time to milliseconds.

Detailed Description

Current Time Service (CTS).

Macro Definition Documentation

◆ BT_CTS_ATT_ERR_VALUES_IGNORED

#define BT_CTS_ATT_ERR_VALUES_IGNORED   0x80U

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

ATT error code for ignored values during CTS write operations.

◆ BT_CTS_DST_INCREMENT_MIN

#define BT_CTS_DST_INCREMENT_MIN   15U

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

DST offset increment in minutes.

◆ BT_CTS_FRACTION_256_MAX_VALUE

#define BT_CTS_FRACTION_256_MAX_VALUE   255U

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

Maximum value for the 1/256-second fractions field in CTS time format.

◆ BT_CTS_TIMEZONE_DEFAULT_VALUE

#define BT_CTS_TIMEZONE_DEFAULT_VALUE   -128

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

Default timezone offset value indicating the timezone is unknown (15-minute increments).

◆ BT_CTS_TIMEZONE_INCREMENT_MIN

#define BT_CTS_TIMEZONE_INCREMENT_MIN   15U

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

Timezone offset increment in minutes.

◆ BT_CTS_TIMEZONE_MAX

#define BT_CTS_TIMEZONE_MAX   56

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

Maximum valid timezone offset in 15-minute increments (56 means UTC+14:00).

◆ BT_CTS_TIMEZONE_MIN

#define BT_CTS_TIMEZONE_MIN   -48

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

Minimum valid timezone offset in 15-minute increments (-48 means UTC-12:00).

Enumeration Type Documentation

◆ bt_cts_dst_offset

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

Daylight Saving Time (DST) offsets as defined in the specification.

Enumerator
BT_CTS_DST_OFFSET_STANDARD_TIME 

Standard Time.

BT_CTS_DST_OFFSET_HALF_HOUR_DAYLIGHT_TIME 

Half an hour daylight saving time.

BT_CTS_DST_OFFSET_DAYLIGHT_TIME 

One hour daylight saving time.

BT_CTS_DST_OFFSET_DOUBLE_DAYLIGHT_TIME 

Two hour daylight saving time.

BT_CTS_DST_OFFSET_UNKNOWN 

Offset unknown.

◆ 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 code on failure

◆ bt_cts_local_time_to_ms()

int bt_cts_local_time_to_ms ( const struct bt_cts_local_time * local_time,
int32_t * relative_ms )

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

Convert CTS local time to milliseconds.

Parameters
[in]local_timePointer to local time information containing timezone and DST offset
[out]relative_msPointer to variable containing the result value in milliseconds
Returns
0 on success, negative error code 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 with CTS enabled.

Parameters
reasonupdate reason to be sent to the clients
Returns
0 on success, negative error code 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>

Convert milliseconds since epoch to CTS formatted time.

Parameters
[out]ct_timePointer to store CTS formatted time
[in]unix_msmilliseconds since epoch to be converted
Returns
0 on success, negative error code 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>

Convert CTS formatted time to milliseconds since epoch.

Parameters
[in]ct_timeCTS formatted time
[out]unix_mspointer to store parsed millisecond since epoch
Returns
0 on success, negative error code on failure