cts.h File Reference

Current Time Service API. More...

#include "gr_includes.h"
#include "custom_config.h"
#include "ble_prf_utils.h"
#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Classes

struct  cts_exact_time_256_t
 CTS Exact Time 256. More...
 
struct  cts_cur_time_t
 CTS Current Time value. More...
 
struct  cts_loc_time_info_t
 CTS Local Time Information. More...
 
struct  cts_ref_time_info_t
 CTS Reference Time Information. More...
 
struct  cts_updata_ref_time_info_t
 CTS Reference Time Updata Information. More...
 
struct  cts_adj_info_t
 CTS Adjust information. More...
 
struct  cts_evt_t
 Current Time Service event. More...
 
struct  cts_init_t
 Current Time Service init structure. This contains all option and data needed for initialization of the service. More...
 

Macros

#define CTS_CONNECTION_MAX   10
 
#define CTS_CUR_TIME_VAL_LEN   10
 
#define TOTAL_CTS_CUR_TIME_VAL_LEN   27
 
#define CTS_LOC_TIME_INFO_VAL_LEN   2
 
#define TOTAL_CTS_LOC_TIME_INFO_VAL_LEN   6
 
#define CTS_REF_TIME_INFO_VAL_LEN   4
 
#define CTS_TIME_YEAR_VALID_VAL_MIN   1582
 
#define CTS_TIME_YEAR_VALID_VAL_MAX   9999
 
#define CTS_TIME_ZONE_OFFSET_MIN   -48
 
#define CTS_TIME_ZONE_OFFSET_MAX   56
 
#define CTS_TIME_ACCURACY_OUT_RANGE   254
 
#define CTS_TIME_ACCURACT_UNKNOWN   255
 
#define CTS_ERROR_FIELDS_IGNORED   0x80
 
#define CTS_CHAR_MANDATORY   0x0f
 
#define CTS_CHAR_LOC_TIME_INFO_SUP   0x30
 
#define CTS_CHAR_REF_TIME_INFO_SUP   0xc0
 
#define CTS_CHAR_FULL   0xff
 
#define CTS_AR_NO_CHANGE   (0x00 << 0)
 
#define CTS_AR_MAUAL_TIME_UPDATE   (0x01 << 0)
 
#define CTS_AR_EXT_REF_TIME_UPDATE   (0x01 << 1)
 
#define CTS_AR_TIME_ZONE_CHANGE   (0x01 << 2)
 
#define CTS_AR_DST_CHANGE   (0x01 << 3)
 

Typedefs

typedef void(* cts_evt_handler_t) (cts_evt_t *p_evt)
 Current Time Service event handler type. More...
 

Enumerations

enum  cts_week_day_t {
  CTS_WEEK_UNKNOWN_DAY,
  CTS_WEEK_MONDAY,
  CTS_WEEK_TUSEDAY,
  CTS_WEEK_WEDNESDAY,
  CTS_WEEK_THURSDAT,
  CTS_WEEK_FRIDAY,
  CTS_WEEK_SATURDAY,
  CTS_WEEK_SUNDAY
}
 Current Time Day of week. More...
 
enum  cts_dst_offset_t {
  CTS_DST_OFFSET_STANDAR_TIME = 0x00,
  CTS_DST_OFFSET_HALF_HOUR = 0x02,
  CTS_DST_OFFSET_DAYLIGHT_TIME = 0x04,
  CTS_DST_OFFSET_DOUB_DAYLIGHT_TIME = 0x08,
  CTS_DST_OFFSET_DOUB_UNKNOWED_TIME = 0xff
}
 Local time information:Daylight Saving Time Offset. More...
 
enum  cts_ref_time_source_t {
  CTS_REF_TIME_SRC_UNKNOWN,
  CTS_REF_TIME_SRC_NET_TIME_PROTOCOL,
  CTS_REF_TIME_SRC_GPS,
  CTS_REF_TIME_SRC_RADIO_TIME_SIGNAL,
  CTS_REF_TIME_SRC_MANUAL,
  CTS_REF_TIME_SRC_ATOMIC_CLOCK,
  CTS_REF_TIME_SRC_CELLUAR_NET
}
 Reference time information:Time Source. More...
 
enum  cts_evt_type_t {
  CTS_EVT_INVALID = 0x00,
  CTS_EVT_CUR_TIME_NOTIFICATION_ENABLED,
  CTS_EVT_CUR_TIME_NOTIFICATION_DISABLED,
  CTS_EVT_CUR_TIME_SET_BY_PEER,
  CTS_EVT_LOC_TIME_INFO_SET_BY_PEER
}
 Current Time Service event type. More...
 

Functions

sdk_err_t cts_service_init (cts_init_t *p_cts_init)
 Initialize a Current Time Service instance and add in the DB. More...
 
void cts_exact_time_get (cts_init_t *p_exact_time)
 Get exact time for user. More...
 
void cts_exact_time_update (cts_init_t *p_cts_exact_time)
 Update exact time. More...
 
void cts_cur_time_adjust (cts_adj_info_t *p_adj_info)
 Adjust current time. More...
 
sdk_err_t cts_cur_time_send (uint8_t conn_idx, cts_cur_time_t *p_cur_time)
 Send Current Time if its notification has been enabled. More...
 
void cts_c_data_parse (uint8_t *p_data, uint16_t length)
 Data accepts data and processing functions. More...
 
void reference_time_encode (uint8_t *p_data, uint16_t length)
 Serial port data is converted into reference time. More...
 
void local_time_encode (uint8_t *p_data, uint8_t length)
 Serial port data is converted into local time. More...
 
void current_time_encode (uint8_t *p_data, uint16_t length)
 Serial port data is converted into current time. More...
 
uint8_t local_time_universal_decode (ble_gatts_write_cfm_t *p_cfm, cts_evt_t *p_evt)
 Handle Local Time Information conversion. More...
 
uint8_t current_time_universal_decode (ble_gatts_write_cfm_t *p_cfm, cts_evt_t *p_evt)
 Decode for a Current Time. More...
 

Detailed Description

Current Time Service API.

Attention
#####Copyright (c) 2019 GOODIX All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of GOODIX nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file cts.h.