cgms.h File Reference

Continuous Glucose Monitoring Service API. More...

#include "gr_includes.h"
#include "custom_config.h"
#include "cgms_racp.h"

Go to the source code of this file.

Classes

struct  __attribute__
 
struct  __attribute__
 
struct  __attribute__
 
union  cgms_get_info_req_t
 
struct  cgms_cp_cmd_req_t
 
struct  cgms_cp_cmd_rsp_t
 
struct  cgms_meas_rec_t
 Glucose Measurement structure. This contains glucose measurement value. More...
 
struct  cgms_init_t
 CGM Service init stucture. This contains all option and data needed for initialization of the service. More...
 

Macros

#define CGMS_CONNECTION_MAX   10
 
#define CGMS_MEASUREMENT_VAL_LEN_MAX   15
 
#define CGMS_FEATURE_VAL_LEN_MAX   6
 
#define CGMS_STATUS_VAL_LEN_MAX   7
 
#define CGMS_RUN_TIME_VAL_LEN_MAX   4
 
#define CGMS_START_TIME_VAL_LEN_MAX   11
 
#define CGMS_RACP_VAL_LEN_MAX   7
 
#define CGMS_RACP_VAL_LEN_MIN   2
 
#define CGMS_ERROR_MISSING_CRC   0x80
 
#define CGMS_ERROR_INVALID_CRC   0x81
 
#define CGMS_ERROR_CCCD_NOT_CFG   0xFD
 
#define CGMS_ERROR_PRO_IN_PROCESS   0xFE
 
#define CGMS_FEAT_CALIBRATION   (0x01 << 0)
 
#define CGMS_FEAT_PATIENT_HIGH_LOW_ALERT   (0x01 << 1)
 
#define CGMS_FEAT_HYPO_ALERT   (0x01 << 2)
 
#define CGMS_FEAT_HYPER_ALERT   (0x01 << 3)
 
#define CGMS_FEAT_RATE_INC_DEC_ALERT   (0x01 << 4)
 
#define CGMS_FEAT_DEV_SPEC_ALERT   (0x01 << 5)
 
#define CGMS_FEAT_SENSOR_MAL_DET   (0x01 << 6)
 
#define CGMS_FEAT_TEMP_HIGH_LOW_DET   (0x01 << 7)
 
#define CGMS_FEAT_RESULT_HIGH_LOW_DET   (0x01 << 8)
 
#define CGMS_FEAT_LOW_BATTERY_DET   (0x01 << 9)
 
#define CGMS_FEAT_SENSOR_TYPE_ERR_DET   (0x01 << 10)
 
#define CGMS_FEAT_GENERAL_DEV_FAULT_DET   (0x01 << 11)
 
#define CGMS_FEAT_E2E_CRC   (0x01 << 12)
 
#define CGMS_FEAT_MULTIPLE_BOND   (0x01 << 13)
 
#define CGMS_FEAT_MULTIPLE_SESSION   (0x01 << 14)
 
#define CGMS_FEAT_TREND_INFORMATION   (0x01 << 15)
 
#define CGMS_FEAT_QUALITY   (0x01 << 16)
 
#define CGMS_FEAT_FULL   (0x1ffff)
 
#define CGMS_MEAS_FLAG_TREND_INFO_PRESENT   (0x01 << 0)
 
#define CGMS_MEAS_FLAG_QUALITY_PRESENT   (0x01 << 1)
 
#define CGMS_MEAS_FLAG_WARING_PRESENT   (0x01 << 5)
 
#define CGMS_MEAS_FLAG_CAL_TEMP_PRESENT   (0x01 << 6)
 
#define CGMS_MEAS_FLAG_STATUS_PRESENT   (0x01 << 7)
 
#define CGMS_MEAS_FLAG_FULL   (0xe3)
 
#define CGMS_ANN_STATUS_SESSION_STOPPED   (0x01 << 0)
 
#define CGMS_ANN_STATUS_DEV_BATTERY_LOW   (0x01 << 1)
 
#define CGMS_ANN_STATUS_SENSOR_TYPE_INCORRECT   (0x01 << 2)
 
#define CGMS_ANN_STATUS_SENSOR_MALFUNCTION   (0x01 << 3)
 
#define CGMS_ANN_STATUS_DEV_SPEC_ALERT   (0x01 << 4)
 
#define CGMS_ANN_STATUS_GEN_DEV_FAULT   (0x01 << 5)
 
#define CGMS_ANN_CAL_TEMP_TIME_SYNC_REQ   (0x01 << 0)
 
#define CGMS_ANN_CAL_TEMP_CAL_NOT_ALLOWED   (0x01 << 1)
 
#define CGMS_ANN_CAL_TEMP_CAL_RECOMMENED   (0x01 << 2)
 
#define CGMS_ANN_CAL_TEMP_CAL_REQ   (0x01 << 3)
 
#define CGMS_ANN_CAL_TEMP_TEMP_TOO_HIGH   (0x01 << 4)
 
#define CGMS_ANN_CAL_TEMP_TEMP_TOO_LOW   (0x01 << 5)
 
#define CGMS_ANN_CAL_TEMP_CAL_PROCESS_PENDING   (0x01 << 6)
 
#define CGMS_ANN_WARN_RESULT_LOWER_THAN_PATIENT_LOW_LVL   (0x01 << 0)
 
#define CGMS_ANN_WARN_RESULT_HIGHER_THAN_PATIENT_HIGH_LVL   (0x01 << 1)
 
#define CGMS_ANN_WARN_RESULT_LOWER_THAN_HYPO_LVL   (0x01 << 2)
 
#define CGMS_ANN_WARN_RESULT_HIGHER_THAN_HYPER_LVL   (0x01 << 3)
 
#define CGMS_ANN_WARN_RATE_OF_DECREASE_EXCEEDED   (0x01 << 4)
 
#define CGMS_ANN_WARN_RATE_OF_INCREASE_EXCEEDED   (0x01 << 5)
 
#define CGMS_ANN_WARN_RESULT_LOWER_THAN_DEV_CAN_PROCESS   (0x01 << 6)
 
#define CGMS_ANN_WARN_RESULT_HIGHER_THAN_DEV_CAN_PROCESS   (0x01 << 7)
 

Typedefs

typedef void(* cgms_cccd_change_handler_t) (uint8_t conn_idx, cgms_cccd_status_t cccd_status)
 
typedef void(* cgms_get_info_req_handler_t) (uint8_t conn_idx, cgms_get_info_code_t code, cgms_get_info_req_t *data_out)
 
typedef void(* cgms_cp_cmd_req_handler_t) (uint8_t conn_idx, cgms_cp_cmd_req_t *req)
 
typedef void(* cgms_racp_req_handler_t) (uint8_t conn_idx, cgms_racp_req_t *req)
 
typedef uint16_t(* cgms_rec_num_get_func_t) (void)
 
typedef void(* cgms_db_rec_delete_func_t) (uint8_t rec_idx)
 
typedef void(* cgms_db_rec_get_func_t) (uint8_t rec_idx, cgms_meas_rec_t *p_rec)
 

Enumerations

enum  cgms_meas_type_t {
  CGMS_MEAS_TYPE_CAP_BLOOD = 0x01,
  CGMS_MEAS_TYPE_CAP_PLASMA,
  CGMS_MEAS_TYPE_VEN_BLOOD,
  CGMS_MEAS_TYPE_VEN_PLASMA,
  CGMS_MEAS_TYPE_ART_BLOOD,
  CGMS_MEAS_TYPE_ART_PLASMA,
  CGMS_MEAS_TYPE_UNDET_BLOOD,
  CGMS_MEAS_TYPE_UNDET_PLASMA,
  CGMS_MEAS_TYPE_FLUID,
  CGMS_MEAS_TYPE_CONTROL
}
 CGM measurement type. More...
 
enum  cgms_meas_loc_t {
  CGMS_MEAS_LOC_FINGER = 0x01,
  CGMS_MEAS_LOC_AST,
  CGMS_MEAS_LOC_EAR,
  CGMS_MEAS_LOC_CONTROL,
  CGMS_MEAS_LOC_SUB_TISSUE
}
 CGM measurement location. More...
 
enum  cgms_cal_status_t {
  CGMS_CAL_STATUS_REJECT,
  CGMS_CAL_STATUS_OUT_OF_RANGE,
  CGMS_CAL_STATUS_PROCESS_PENGDING
}
 
enum  cgms_cccd_status_t {
  CGMS_CCCD_STATUS_MEAS_ENABLED,
  CGMS_CCCD_STATUS_MEAS_DISABLED,
  CGMS_CCCD_STATUS_RACP_ENABLED,
  CGMS_CCCD_STATUS_RACP_DISABLED,
  CGMS_CCCD_STATUS_SPCP_ENABLED,
  CGMS_CCCD_STATUS_SPCP_DISABLED,
  CGMS_CCCD_STATUS_FEAT_ENABLED,
  CGMS_CCCD_STATUS_FEAT_DISABLED
}
 
enum  cgms_get_info_code_t {
  CGMS_GET_INFO_NONE,
  CGMS_GET_INFO_ANN_STATUS,
  CGMS_GET_INFO_SES_START_TIME,
  CGMS_GET_INFO_SES_RUN_TIME
}
 
enum  cgms_cp_cmd_code_t {
  CGMS_CP_CODE_NONE,
  CGMS_CP_CODE_SET_COM_INTERVAL,
  CGMS_CP_CODE_GET_COM_INTERVAL,
  CGMS_CP_CODE_SET_CAL_VALUE = 0x04,
  CGMS_CP_CODE_GET_CAL_VALUE,
  CGMS_CP_CODE_SET_PATIENT_HIGHT_LVL = 0x07,
  CGMS_CP_CODE_GET_PATIENT_HIGHT_LVL,
  CGMS_CP_CODE_SET_PATIENT_LOW_LVL = 0x0a,
  CGMS_CP_CODE_GET_PATIENT_LOW_LVL,
  CGMS_CP_CODE_SET_HYPO_LVL = 0x0d,
  CGMS_CP_CODE_GET_HYPO_LVL,
  CGMS_CP_CODE_SET_HYPER_LVL = 0x10,
  CGMS_CP_CODE_GET_HYPER_LVL,
  CGMS_CP_CODE_SET_RATE_OF_DEC_LVL = 0x13,
  CGMS_CP_CODE_GET_RATE_OF_DEC_LVL,
  CGMS_CP_CODE_SET_RATE_OF_INC_LVL = 0x16,
  CGMS_CP_CODE_GET_RATE_OF_INC_LVL,
  CGMS_CP_CODE_RESET_DEV_SPEC_ALERT = 0x19,
  CGMS_CP_CODE_START_THE_SESSION,
  CGMS_CP_CODE_STOP_THE_SESSION,
  CGMS_CP_CODE_SET_SES_START_TIME
}
 
enum  cgms_cp_cmd_ret_t {
  CGMS_CMD_RET_CODE_RESERVED = 0x00,
  CGMS_CMD_RET_CODE_SUCESS,
  CGMS_CMD_RET_CODE_NOT_SUPPORT,
  CGMS_CMD_RET_CODE_INVALID_OPERAND,
  CGMS_CMD_RET_CODE_PROCEDURE_NOT_COMPLETED,
  CGMS_CMD_RET_CODE_PARAM_OUT_OF_RANGE
}
 

Functions

sdk_err_t cgms_service_init (cgms_init_t *p_cgms_init)
 Initialize a Continuous Glucose Monitoring Service instance and add in the DB. More...
 
sdk_err_t cgms_cp_cmd_rsp_send (uint8_t conn_idx, cgms_cp_cmd_rsp_t *p_rsp)
 Send cgms control point cmd response. More...
 
sdk_err_t cgms_feature_update (uint32_t feature)
 Update cgms feature. More...
 
sdk_err_t cgms_meas_val_send (uint8_t conn_idx, cgms_meas_rec_t *p_rec)
 Send cgms measurement value. More...
 

Detailed Description

Continuous Glucose Monitoring 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 cgms.h.