Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
cts.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Croxel Inc.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_CTS_H_
8#define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_CTS_H_
9
17
18#include <stdint.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
27#define BT_CTS_ATT_ERR_VALUES_IGNORED 0x80U
28
32#define BT_CTS_FRACTION_256_MAX_VALUE 255U
33
37#define BT_CTS_TIMEZONE_DEFAULT_VALUE -128
38
42#define BT_CTS_TIMEZONE_INCREMENT_MIN 15U
43
47#define BT_CTS_DST_INCREMENT_MIN 15U
48
52#define BT_CTS_TIMEZONE_MIN -48
53
57#define BT_CTS_TIMEZONE_MAX 56
58
74
79 /* Unknown reason of update no bit is set */
81 /* When time is changed manually e.g. through UI */
83 /* If time is changed through external reference */
85 /* time changed due to timezone adjust */
87 /* time changed due to dst offset change */
89};
90
106
126
128struct bt_cts_cb {
134 void (*notification_changed)(bool enabled);
135
145 int (*cts_time_write)(struct bt_cts_time_format *cts_time);
146
160
171 int (*cts_local_time_write)(const struct bt_cts_local_time *cts_local_time);
172
184};
185
195int bt_cts_init(const struct bt_cts_cb *cb);
196
205
214int bt_cts_time_to_unix_ms(const struct bt_cts_time_format *ct_time, int64_t *unix_ms);
215
225
234int bt_cts_local_time_to_ms(const struct bt_cts_local_time *local_time, int32_t *relative_ms);
235
236#ifdef __cplusplus
237}
238#endif
239
243
244#endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_CTS_H_ */
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_send_notification(enum bt_cts_update_reason reason)
Notify all connected clients with CTS enabled.
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.
int bt_cts_init(const struct bt_cts_cb *cb)
This API should be called at application init.
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.
bt_cts_update_reason
CTS time update reason bits as defined in the specification.
Definition cts.h:78
bt_cts_dst_offset
Daylight Saving Time (DST) offsets as defined in the specification.
Definition cts.h:62
@ BT_CTS_UPDATE_REASON_TIME_ZONE_CHANGE
Definition cts.h:86
@ BT_CTS_UPDATE_REASON_EXTERNAL_REF
Definition cts.h:84
@ BT_CTS_UPDATE_REASON_DAYLIGHT_SAVING
Definition cts.h:88
@ BT_CTS_UPDATE_REASON_UNKNOWN
Definition cts.h:80
@ BT_CTS_UPDATE_REASON_MANUAL
Definition cts.h:82
@ BT_CTS_DST_OFFSET_HALF_HOUR_DAYLIGHT_TIME
Half an hour daylight saving time.
Definition cts.h:66
@ BT_CTS_DST_OFFSET_STANDARD_TIME
Standard Time.
Definition cts.h:64
@ BT_CTS_DST_OFFSET_DOUBLE_DAYLIGHT_TIME
Two hour daylight saving time.
Definition cts.h:70
@ BT_CTS_DST_OFFSET_UNKNOWN
Offset unknown.
Definition cts.h:72
@ BT_CTS_DST_OFFSET_DAYLIGHT_TIME
One hour daylight saving time.
Definition cts.h:68
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44
__INT32_TYPE__ int32_t
Definition stdint.h:74
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
__INT64_TYPE__ int64_t
Definition stdint.h:75
__INT8_TYPE__ int8_t
Definition stdint.h:72
Current Time Service callback structure.
Definition cts.h:128
int(* cts_time_write)(struct bt_cts_time_format *cts_time)
The Current Time has been requested to update by a peer.
Definition cts.h:145
int(* fill_current_cts_local_time)(struct bt_cts_local_time *local_time)
Request to get current local time.
Definition cts.h:183
int(* cts_local_time_write)(const struct bt_cts_local_time *cts_local_time)
The Local Time Information has been requested to update by a peer.
Definition cts.h:171
void(* notification_changed)(bool enabled)
Current Time Service notifications changed.
Definition cts.h:134
int(* fill_current_cts_time)(struct bt_cts_time_format *cts_time)
Callback to get current time.
Definition cts.h:159
CTS Local Time Information.
Definition cts.h:110
int8_t timezone_offset
Represents the offset from UTC in number in 15-minute increments.
Definition cts.h:120
enum bt_cts_dst_offset dst_offset
Represents the daylight saving time offset in 15-minute increments.
Definition cts.h:124
Current Time service data format, Please refer to specifications for more details.
Definition cts.h:95
uint8_t mon
Definition cts.h:97
uint8_t min
Definition cts.h:100
uint8_t reason
Definition cts.h:104
uint8_t mday
Definition cts.h:98
uint8_t hours
Definition cts.h:99
uint16_t year
Definition cts.h:96
uint8_t sec
Definition cts.h:101
uint8_t wday
Definition cts.h:102
uint8_t fractions256
Definition cts.h:103