Current time service sample implementation API.
More...
|
| file | cts.h |
| | Current Time Service implementation API.
|
| |
|
| ble_service_t * | cts_init (const cts_local_time_info_t *info, const cts_callbacks_t *cb) |
| |
| void | cts_notify_time (ble_service_t *svc, uint16_t conn_idx, const cts_current_time_t *time) |
| |
| void | cts_notify_time_all (ble_service_t *svc, const cts_current_time_t *time) |
| |
| void | cts_set_local_time_info (ble_service_t *svc, const cts_local_time_info_t *info) |
| |
| void | cts_get_time_cfm (ble_service_t *svc, uint16_t conn_idx, att_error_t status, const cts_current_time_t *time) |
| |
| void | cts_set_time_cfm (ble_service_t *svc, uint16_t conn_idx, att_error_t status) |
| |
| void | cts_set_local_time_info_cfm (ble_service_t *svc, uint16_t conn_idx, att_error_t status) |
| |
| void | cts_get_ref_time_info_cfm (ble_service_t *svc, uint16_t conn_idx, att_error_t status, const cts_ref_time_info_t *info) |
| |
| __STATIC_INLINE int8_t | cts_get_time_zone (int8_t h, uint8_t m) |
| |
| __STATIC_INLINE bool | cts_get_time_zone_offset (int8_t tz, int8_t *h, int8_t *m) |
| |
| __STATIC_INLINE bool | cts_is_current_time_valid (const cts_current_time_t *time) |
| |
| __STATIC_INLINE bool | cts_is_local_time_info_valid (const cts_local_time_info_t *info) |
| |
Current time service sample implementation API.
◆ CTS_ADJUST_REASON_VALID_VALUES_MASK
| #define CTS_ADJUST_REASON_VALID_VALUES_MASK |
Value:(CTS_AR_NO_CHANGE | \
CTS_AR_CHANGE_OF_DST | \
CTS_AR_MANUAL_TIME_UPDATE | \
CTS_AR_EXTERNAL_REFERENCE_TIME_UPDATE | \
CTS_AR_CHANGE_OF_TIME_ZONE)
CTS Current Time adjust reason valid values mask
◆ cts_adjust_reason_t
CTS Current Time adjust reason
◆ cts_dst_t
CTS Local Time Information DST
◆ cts_error
CTS additional ATT error codes
◆ cts_ref_time_source_t
CTS Reference Time Source
◆ cts_get_ref_time_info_cfm()
Response for get_ref_time_info callback
- Parameters
-
| [in] | svc | service instance |
| [in] | conn_idx | connection index |
| [in] | status | ATT error |
| [in] | info | reference time information |
◆ cts_get_time_cfm()
Response for get_time callback
- Parameters
-
| [in] | svc | service instance |
| [in] | conn_idx | connection index |
| [in] | status | ATT error |
| [in] | time | current time |
◆ cts_get_time_zone()
| __STATIC_INLINE int8_t cts_get_time_zone |
( |
int8_t |
h, |
|
|
uint8_t |
m |
|
) |
| |
Helper function to calculate time zone for cts_local_time_information_t
- Note
- This will work for all current time zones, it will get incorrect result for -00:15, -00:30, -00:45 which are not valid time zones for now.
- Parameters
-
| [in] | h | hours difference to UTC (can be positive or negative) |
| [in] | m | minutes difference UTC (positive values only) |
- Returns
- time zone value
◆ cts_get_time_zone_offset()
| __STATIC_INLINE bool cts_get_time_zone_offset |
( |
int8_t |
tz, |
|
|
int8_t * |
h, |
|
|
int8_t * |
m |
|
) |
| |
Helper function to extract hour and minute from time_zone field
- Parameters
-
| [in] | tz | time zone as in cts_local_time_information_t |
| [out] | h | hours difference to UTC |
| [out] | m | minutes difference to UTC |
return true if tz is valid
◆ cts_init()
Register CTS instance
Function initializes and register Current Time Service. If local_time_info is NULL Local Time Information optional characteristic will not be available.
- Parameters
-
| [in] | info | local time information |
| [in] | cb | application callbacks |
- Returns
- service instance
◆ cts_is_current_time_valid()
Helper function to check it contents of cts_current_time_t is valid
- Parameters
-
return true if time is valid
◆ cts_is_local_time_info_valid()
Helper function to check it contents of cts_local_time_info_t is valid
- Parameters
-
| [in] | info | local time information |
return true if info is valid
◆ cts_notify_time()
Notify connected client about current time
- Parameters
-
| [in] | svc | service instance |
| [in] | conn_idx | connection index |
| [in] | time | current time with change reason |
◆ cts_notify_time_all()
Notify connected clients about current time
- Parameters
-
| [in] | svc | service instance |
| [in] | time | current time with change reason |
◆ cts_set_local_time_info()
Set local time information
- Parameters
-
| [in] | svc | service instance |
| [in] | info | local time information |
◆ cts_set_local_time_info_cfm()
Response for set_local_time_info callback
- Parameters
-
| [in] | svc | service instance |
| [in] | conn_idx | connection index |
| [in] | status | ATT error |
◆ cts_set_time_cfm()
Response for set_time callback
- Parameters
-
| [in] | svc | service instance |
| [in] | conn_idx | connection index |
| [in] | status | ATT error |