Zephyr API 3.6.99
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#include <zephyr/posix/time.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
29 /* Unknown reason of update no bit is set */
31 /* When time is changed manually e.g. through UI */
33 /* If time is changed through external reference */
35 /* time changed due to timezone adjust */
37 /* time changed due to dst offset change */
39};
40
55} __packed;
56
58struct bt_cts_cb {
63 void (*notification_changed)(bool enabled);
64
75 int (*cts_time_write)(struct bt_cts_time_format *cts_time);
76
89 int (*fill_current_cts_time)(struct bt_cts_time_format *cts_time);
90};
91
101int bt_cts_init(const struct bt_cts_cb *cb);
102
113
125int bt_cts_time_to_unix_ms(const struct bt_cts_time_format *ct_time, int64_t *unix_ms);
126
139
140#ifdef __cplusplus
141}
142#endif
143
148#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:28
@ BT_CTS_UPDATE_REASON_TIME_ZONE_CHANGE
Definition: cts.h:36
@ BT_CTS_UPDATE_REASON_EXTERNAL_REF
Definition: cts.h:34
@ BT_CTS_UPDATE_REASON_DAYLIGHT_SAVING
Definition: cts.h:38
@ BT_CTS_UPDATE_REASON_UNKNOWN
Definition: cts.h:30
@ BT_CTS_UPDATE_REASON_MANUAL
Definition: cts.h:32
#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:58
int(* cts_time_write)(struct bt_cts_time_format *cts_time)
The Current Time has been updated by a peer.
Definition: cts.h:75
void(* notification_changed)(bool enabled)
Current Time Service notifications changed.
Definition: cts.h:63
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:89
Current Time service data format, Please refer to specifications for more details.
Definition: cts.h:45
uint8_t mon
Definition: cts.h:47
uint8_t min
Definition: cts.h:50
uint8_t reason
Definition: cts.h:54
uint8_t mday
Definition: cts.h:48
uint8_t hours
Definition: cts.h:49
uint16_t year
Definition: cts.h:46
uint8_t sec
Definition: cts.h:51
uint8_t wday
Definition: cts.h:52
uint8_t fractions256
Definition: cts.h:53