Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
ets.h File Reference

Elapsed Time Service (ETS). More...

#include <stdint.h>
#include <stdbool.h>
#include <zephyr/sys/util.h>

Go to the source code of this file.

Data Structures

struct  bt_ets_elapsed_time
 Elapsed Time data structure as defined in GATT Specification Supplement Section 3.82. More...
struct  bt_ets_cb
 Elapsed Time Service callback structure. More...

Macros

#define BT_ETS_SUPPORTED_FLAGS_MASK
 Combined supported flags mask based on configuration.
#define BT_ETS_CLOCK_CAPABILITIES_VALUE
 Clock capabilities (Elapsed Time Service - Section 3.1.1.3).
Elapsed Time Service Flags

Elapsed Time Service flags field bits (GATT Specification Supplement Section 3.82)

#define BT_ETS_FLAG_TICK_COUNTER   BIT(0)
 Time Value reports a counter (tick counter).
#define BT_ETS_FLAG_UTC   BIT(1)
 Time is UTC.
#define BT_ETS_FLAG_RESOLUTION_MASK   (BIT(2) | BIT(3))
 Time resolution mask (bits 2-3).
#define BT_ETS_FLAG_TZ_DST_USED   BIT(4)
 TZ/DST offset is used.
#define BT_ETS_FLAG_CURRENT_TIMELINE   BIT(5)
 Time stamp is from current timeline.
#define BT_ETS_FLAG_RESERVED_MASK   (BIT(6) | BIT(7))
 Reserved bits (6-7).
Time Source Values

Time synchronization source values (GATT Specification Supplement Section 3.243)

#define BT_ETS_TIME_SOURCE_UNKNOWN   0
 Unknown time source.
#define BT_ETS_TIME_SOURCE_NTP   1
 Network Time Protocol.
#define BT_ETS_TIME_SOURCE_GPS   2
 GPS/GNSS.
#define BT_ETS_TIME_SOURCE_RADIO   3
 Radio Time Signal.
#define BT_ETS_TIME_SOURCE_MANUAL   4
 Manually set.
#define BT_ETS_TIME_SOURCE_ATOMIC   5
 Atomic Clock.
#define BT_ETS_TIME_SOURCE_CELLULAR   6
 Cellular Network.
#define BT_ETS_TIME_SOURCE_NOT_SYNCHRONIZED   7
 Not synchronized.
Clock Status Flags

Clock Status flags (Elapsed Time Service - Section 3.1.1.2)

#define BT_ETS_CLOCK_STATUS_NEEDS_SET   BIT(0)
 Clock needs to be set.
#define BT_ETS_CLOCK_STATUS_RFU_MASK   0xFE
 Clock Status RFU mask (bits 1-7).
Clock Capabilities flags (Elapsed Time Service - Section 3.1.1.3)

#define BT_ETS_CLOCK_CAP_DST_AUTO   BIT(0)
 Clock autonomously applies DST rules.
#define BT_ETS_CLOCK_CAP_TZ_AUTO   BIT(1)
 Clock autonomously manages TZ changes.
#define BT_ETS_CLOCK_CAP_RFU_MASK   0xFC
 Clock Capabilities RFU mask (bits 2-7).

Enumerations

enum  bt_ets_time_resolution { BT_ETS_RESOLUTION_1_SEC = 0 , BT_ETS_RESOLUTION_100_MS = 1 , BT_ETS_RESOLUTION_1_MS = 2 , BT_ETS_RESOLUTION_100_US = 3 }
 Time resolution values for bits 2-3 of flags field. More...
enum  bt_ets_write_result { BT_ETS_WRITE_SUCCESS = 0 , BT_ETS_WRITE_TIME_SOURCE_TOO_LOW = 1 , BT_ETS_WRITE_OUT_OF_RANGE = 2 , BT_ETS_WRITE_INCORRECT_FORMAT = 3 }
 Write result codes for write_elapsed_time callback. More...

Functions

int bt_ets_init (const struct bt_ets_cb *cb)
 Initialize Elapsed Time Service.
int bt_ets_indicate (const struct bt_ets_elapsed_time *elapsed_time, uint8_t clock_status)
 Send indication to subscribed clients.
int bt_ets_time_to_unix_ms (const struct bt_ets_elapsed_time *et_time, int64_t *unix_ms)
 Decode ETS formatted time into milliseconds since Unix epoch.
int bt_ets_time_from_unix_ms (struct bt_ets_elapsed_time *et_time, int64_t unix_ms, uint8_t time_src, int8_t tz_dst_offset)
 Encode Unix milliseconds into ETS formatted time.

Detailed Description

Elapsed Time Service (ETS).