Current Time Service
The Current Time service defines how a Bluetooth device can expose date and time information to other Bluetooth devices.
Examples
API Reference
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. - Parameters
- out_val – [in] The pointer to store the Current Time Increment. 
- Returns
- 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. - Parameters
- in_val – [in] The pointer to store the Current Time. 
- need_send – [in] send the current time to remote client. 
 
- Returns
- 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. - Parameters
- out_val – [in] The pointer to store the Local Time Increment. 
- Returns
- 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. - Parameters
- in_val – [in] The pointer to store the Local Time. 
- Returns
- 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. - Parameters
- out_val – [in] The pointer to store the Reference Time Increment. 
- Returns
- 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. - Parameters
- in_val – [in] The pointer to store the Reference Time. 
- Returns
- ESP_OK on successful 
 
 
- 
esp_err_t esp_ble_cts_init(void)
- Initialization Current Time Service. - Returns
- 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 
 
- 
uint16_t year
- 
struct esp_ble_cts_local_time_t
- Local Time Information. 
- 
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 
 
- 
uint8_t time_source
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