Zephyr API Documentation 4.0.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
18#include <stdint.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
28 /* Unknown reason of update no bit is set */
30 /* When time is changed manually e.g. through UI */
32 /* If time is changed through external reference */
34 /* time changed due to timezone adjust */
36 /* time changed due to dst offset change */
38};
39
55
57struct bt_cts_cb {
62 void (*notification_changed)(bool enabled);
63
74 int (*cts_time_write)(struct bt_cts_time_format *cts_time);
75
88 int (*fill_current_cts_time)(struct bt_cts_time_format *cts_time);
89};
90
100int bt_cts_init(const struct bt_cts_cb *cb);
101
112
124int bt_cts_time_to_unix_ms(const struct bt_cts_time_format *ct_time, int64_t *unix_ms);
125
138
139#ifdef __cplusplus
140}
141#endif
142
147#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)
Helper API to decode CTS formatted time into milliseconds since epoch.
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_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)
Helper API to encode milliseconds since epoch to CTS formatted time.
bt_cts_update_reason
CTS time update reason bits as defined in the specification.
Definition cts.h:27
@ BT_CTS_UPDATE_REASON_TIME_ZONE_CHANGE
Definition cts.h:35
@ BT_CTS_UPDATE_REASON_EXTERNAL_REF
Definition cts.h:33
@ BT_CTS_UPDATE_REASON_DAYLIGHT_SAVING
Definition cts.h:37
@ BT_CTS_UPDATE_REASON_UNKNOWN
Definition cts.h:29
@ BT_CTS_UPDATE_REASON_MANUAL
Definition cts.h:31
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
__INT64_TYPE__ int64_t
Definition stdint.h:75
Current Time Service callback structure.
Definition cts.h:57
int(* cts_time_write)(struct bt_cts_time_format *cts_time)
The Current Time has been updated by a peer.
Definition cts.h:74
void(* notification_changed)(bool enabled)
Current Time Service notifications changed.
Definition cts.h:62
int(* fill_current_cts_time)(struct bt_cts_time_format *cts_time)
When current time Read request or notification is triggered, CTS uses this callback to retrieve curre...
Definition cts.h:88
Current Time service data format, Please refer to specifications for more details.
Definition cts.h:44
uint8_t mon
Definition cts.h:46
uint8_t min
Definition cts.h:49
uint8_t reason
Definition cts.h:53
uint8_t mday
Definition cts.h:47
uint8_t hours
Definition cts.h:48
uint16_t year
Definition cts.h:45
uint8_t sec
Definition cts.h:50
uint8_t wday
Definition cts.h:51
uint8_t fractions256
Definition cts.h:52