当前时间服务

[English]

当前时间服务定义了蓝牙设备如何向其他蓝牙设备展示日期和时间信息。

示例

bluetooth/ble_services/ble_cts.

API 参考

Header File

Functions

esp_err_t esp_ble_cts_get_current_time(esp_ble_cts_cur_time_t *out_val)

Read the value of Current Time characteristic.

参数

out_val[in] The pointer to store the Current Time Increment.

返回

  • ESP_OK on successful

  • ESP_ERR_INVALID_ARG on wrong parameter

esp_err_t esp_ble_cts_set_current_time(esp_ble_cts_cur_time_t *in_val, bool need_send)

Set the Current Time characteristic value.

参数
  • in_val[in] The pointer to store the Current Time.

  • need_send[in] send the current time to remote client.

返回

  • ESP_OK on successful

  • ESP_ERR_INVALID_ARG on wrong initialization

  • ESP_FAIL on error

esp_err_t esp_ble_cts_get_local_time(esp_ble_cts_local_time_t *out_val)

Read the value of Local Time characteristic.

参数

out_val[in] The pointer to store the Local Time Increment.

返回

  • ESP_OK on successful

  • ESP_ERR_INVALID_ARG on wrong parameter

esp_err_t esp_ble_cts_set_local_time(esp_ble_cts_local_time_t *in_val)

Set the Local Time characteristic value.

参数

in_val[in] The pointer to store the Local Time.

返回

  • ESP_OK on successful

esp_err_t esp_ble_cts_get_reference_time(esp_ble_cts_ref_time_t *out_val)

Read the value of Reference Time characteristic.

参数

out_val[in] The pointer to store the Reference Time Increment.

返回

  • ESP_OK on successful

  • ESP_ERR_INVALID_ARG on wrong parameter

esp_err_t esp_ble_cts_set_reference_time(esp_ble_cts_ref_time_t *in_val)

Set the Reference Time characteristic value.

参数

in_val[in] The pointer to store the Reference Time.

返回

  • ESP_OK on successful

esp_err_t esp_ble_cts_init(void)

Initialization Current Time Service.

返回

  • ESP_OK on successful

  • ESP_ERR_INVALID_ARG on wrong initialization

  • ESP_FAIL on error

Structures

struct esp_ble_cts_cur_time_t

Current Time.

Public Members

uint16_t year

Year as defined by the Gregorian calendar, Valid range 1582 to 9999

uint8_t month

Month of the year as defined by the Gregorian calendar, Valid range 1 (January) to 12 (December)

uint8_t day

Day of the month as defined by the Gregorian calendar, Valid range 1 to 31

uint8_t hours

Number of hours past midnight, Valid range 0 to 23

uint8_t minutes

Number of minutes since the start of the hour. Valid range 0 to 59

uint8_t seconds

Number of seconds since the start of the minute. Valid range 0 to 59

struct esp_ble_cts_cur_time_t::[anonymous] timestamp

The date and time

uint8_t day_of_week

Day_of_week. valid range : 1(Monday) - 7(Sunday), 0 means day of week not known

uint8_t fractions_256

Fractions_256. the number of 1 / 256 fractions of second, valid range : 0 - 255

uint8_t adjust_reason

This field represents reason(s) for adjusting time

struct esp_ble_cts_local_time_t

Local Time Information.

Public Members

int8_t timezone

Time zone

uint8_t dst_offset

dst_offset. allowed values : 0, 2, 4, 8, 255 Dst offset

struct esp_ble_cts_ref_time_t

reference time information

Public Members

uint8_t time_source

time_source. valid range : 0 - 253 255 means not known Time source

uint8_t time_accuracy

Time accuracy

uint8_t days_since_update

days_since_update. valid range : 0 - 254 A value of 255 is used when the time span is greater than or equal to 255 days Days since update

uint8_t hours_since_update

hours_since_update. valid range : 0 - 23 A value of 255 is used when the time span is greater than or equal to 255 days Hours since update

Macros

BLE_CTS_UUID16
BLE_CTS_CHR_UUID16_CURRENT_TIME
BLE_CTS_CHR_UUID16_LOCAL_TIME
BLE_CTS_CHR_UUID16_REFERENCE_TIME
BLE_CTS_MANUAL_TIME_UPDATE_MASK
BLE_CTS_EXTERNAL_REFERENCE_TIME_UPDATE_MASK
BLE_CTS_CHANGE_OF_TIME_ZONE_MASK
BLE_CTS_CHANGE_OF_DST_MASK