14#ifndef BT_MESH_TIME_SRV_H__
15#define BT_MESH_TIME_SRV_H__
35#define BT_MESH_TIME_SRV_INIT(_time_update_cb) \
37 .time_update_cb = _time_update_cb, \
38 .pub = { .update = _bt_mesh_time_srv_update_handler, \
39 .msg = NET_BUF_SIMPLE(BT_MESH_MODEL_BUF_LEN( \
40 BT_MESH_TIME_OP_TIME_SET, \
41 BT_MESH_TIME_MSG_LEN_TIME_SET)) }, \
53#define BT_MESH_MODEL_TIME_SRV(_srv, ...) \
54 BT_MESH_MODEL_METADATA_CB( \
55 BT_MESH_MODEL_ID_TIME_SRV, _bt_mesh_time_srv_op, &(_srv)->pub, \
56 BT_MESH_MODEL_USER_DATA(struct bt_mesh_time_srv, _srv), \
57 &_bt_mesh_time_srv_cb, __VA_ARGS__), \
58 BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_TIME_SETUP_SRV, \
59 _bt_mesh_time_setup_srv_op, \
61 BT_MESH_MODEL_USER_DATA( \
62 struct bt_mesh_time_srv, _srv), \
63 &_bt_mesh_time_setup_srv_cb)
66#define BT_MESH_CLOCK_ACCURACY_METADATA_ID 0x0007
69#define BT_MESH_TIMEKEEPING_RESERVE_METADATA_ID 0x0008
76#define BT_MESH_CLOCK_ACCURACY_METADATA(clock_accuracy) \
77 BT_MESH_MODELS_METADATA_ENTRY(3, BT_MESH_CLOCK_ACCURACY_METADATA_ID, \
78 ((uint8_t[]){BT_BYTES_LIST_LE24(clock_accuracy)}))
85#define BT_MESH_TIMEKEEPING_RESERVE_METADATA(timekeeping_reserve) \
86 BT_MESH_MODELS_METADATA_ENTRY(3, BT_MESH_TIMEKEEPING_RESERVE_METADATA_ID, \
87 ((uint8_t[]){BT_BYTES_LIST_LE24(timekeeping_reserve)}))
128 struct bt_mesh_model_pub
pub;
156 struct bt_mesh_msg_ctx *ctx,
174 struct bt_mesh_msg_ctx *ctx);
250 int64_t uptime,
struct tm *timeptr);
333extern const struct bt_mesh_model_op _bt_mesh_time_srv_op[];
334extern const struct bt_mesh_model_op _bt_mesh_time_setup_srv_op[];
335extern const struct bt_mesh_model_cb _bt_mesh_time_srv_cb;
336extern const struct bt_mesh_model_cb _bt_mesh_time_setup_srv_cb;
337int _bt_mesh_time_srv_update_handler(
const struct bt_mesh_model *model);
int bt_mesh_time_srv_status(struct bt_mesh_time_srv *srv, uint64_t uptime, struct bt_mesh_time_status *status)
Get the time status at a given uptime.
uint64_t bt_mesh_time_srv_uncertainty_get(struct bt_mesh_time_srv *srv, int64_t uptime)
Get the device time uncertainty at a given uptime.
void bt_mesh_time_srv_time_zone_change_set(struct bt_mesh_time_srv *srv, const struct bt_mesh_time_zone_change *data)
Set the zone change parameters for the server.
int64_t bt_mesh_time_srv_mktime(struct bt_mesh_time_srv *srv, struct tm *timeptr)
Get the device uptime at a given local time.
struct tm * bt_mesh_time_srv_localtime(struct bt_mesh_time_srv *srv, int64_t uptime)
Get the device local time at a given uptime.
int bt_mesh_time_srv_time_status_send(struct bt_mesh_time_srv *srv, struct bt_mesh_msg_ctx *ctx)
Publish an unsolicited Time Status message.
void bt_mesh_time_srv_role_set(struct bt_mesh_time_srv *srv, enum bt_mesh_time_role role)
Set the role parameter for the server.
void bt_mesh_time_srv_time_set(struct bt_mesh_time_srv *srv, int64_t uptime, const struct bt_mesh_time_status *status)
Set the TAI status parameters for the server.
void bt_mesh_time_srv_tai_utc_change_set(struct bt_mesh_time_srv *srv, const struct bt_mesh_time_tai_utc_change *data)
Set the TAI UTC change parameters for the server.
struct tm * bt_mesh_time_srv_localtime_r(struct bt_mesh_time_srv *srv, int64_t uptime, struct tm *timeptr)
Get the device local time at a given uptime.
bt_mesh_time_update_types
Definition: time_srv.h:90
@ BT_MESH_TIME_SRV_STATUS_UPDATE
Definition: time_srv.h:92
@ BT_MESH_TIME_SRV_SET_UPDATE
Definition: time_srv.h:94
@ BT_MESH_TIME_SRV_ZONE_UPDATE
Definition: time_srv.h:96
@ BT_MESH_TIME_SRV_UTC_UPDATE
Definition: time_srv.h:98
bt_mesh_time_role
Definition: time.h:25
struct bt_mesh_time_tai_utc_change tai_utc_change
Definition: time_srv.h:113
int64_t uptime
Definition: time_srv.h:106
enum bt_mesh_time_role role
Definition: time_srv.h:115
int64_t timestamp
Definition: time_srv.h:117
struct bt_mesh_time_srv_data::@164 sync
struct bt_mesh_time_status status
Definition: time_srv.h:108
struct bt_mesh_time_zone_change time_zone_change
Definition: time_srv.h:111
Definition: time_srv.h:102
const struct bt_mesh_model * model
Definition: time_srv.h:126
bool is_unsolicited
Definition: time_srv.h:138
struct bt_mesh_model_pub setup_pub
Definition: time_srv.h:130
uint8_t cached_ttl
Definition: time_srv.h:141
struct k_work_delayable status_delay
Definition: time_srv.h:136
void(*const time_update_cb)(struct bt_mesh_time_srv *srv, struct bt_mesh_msg_ctx *ctx, enum bt_mesh_time_update_types type)
Update callback.
Definition: time_srv.h:155
struct bt_mesh_msg_ack_ctx ack_ctx
Definition: time_srv.h:132
struct bt_mesh_time_srv_data data
Definition: time_srv.h:134
struct bt_mesh_model_pub pub
Definition: time_srv.h:128
Definition: time_srv.h:124