src.dualinventive.com/fw/dncm/libdi/include/di/drv/hl854x/structures.h

119 lines
5.1 KiB
C

#ifndef LIBDI_INCLUDE_DI_DRV_HL854X_STRUCTURES_H_
#define LIBDI_INCLUDE_DI_DRV_HL854X_STRUCTURES_H_
/** GPS context for HL854x driver */
struct di_drv_hl854x_gps {
enum di_drv_hl854x_gps_state state; /**< State of GPS chipset @see di_drv_hl854x_gps_state */
enum di_drv_hl854x_gps_state event; /**< Wait for event state to happen */
bool time_shot_enabled; /**< Enables time sync shot on next PVT time frame */
struct {
uint8_t tm_sec; /**< Seconds after the minute, range 0-59 */
uint8_t tm_min; /**< Minutes after the hour, range 0-59 */
uint8_t tm_hour; /**< Hours since midnight, range 0-23 */
uint8_t tm_mday; /**< Day of the month, range 1-31 */
uint8_t tm_mon; /**< Months since January, range 0-11 */
uint16_t tm_year; /**< Current year, e.g 2015 */
uint32_t unix; /**< UNIX time since epoch, in second granularity */
} time;
struct di_rpc_sensor_data_gps data;
enum di_rpc_sensor_data_gps_fix_state fix_state;
};
/** Single TCP session context for HL854x driver */
struct di_drv_hl854x_ctx_tcp {
int8_t state; /**< State @see di_drv_hl854x_tcp_state */
uint64_t tx_bytes; /**< Amount of bytes send with di_drv_hl854x_tcp_send */
uint64_t rx_bytes; /**< Amount of bytes send with di_drv_hl854x_tcp_recv */
char remote_addr[32]; /**< Remote address. E.g "beta.dualinventive.com" */
char remote_port[6]; /**< Remote port. E.g "3003" */
size_t recv_size; /**< Amount of bytes in receive buffer */
di_bsem_t recv_data_avail; /**< Semaphore if data is ready in receive buffer */
size_t cc_size; /**< Carbon copy buffer size for matching engine */
void *cc_data; /**< Carbon copy buffer for matching engine */
};
/** Single UDP session context for HL854x driver */
struct di_drv_hl854x_ctx_udp {
uint8_t session_id; /**< UDP session ID */
const char *local_port; /**< UDP listening local port */
const char *remote_addr; /**< Remote host address used for send */
const char *remote_port; /**< Remote host port used for send */
enum di_drv_hl854x_udp_state state; /**< Local UDP session state */
enum di_drv_hl854x_kudp_notif notif; /**< UDP session modem notification cache */
size_t ndata_available; /**< Amount of bytes in the modem UDP receive buffer */
di_bsem_t ndata_available_mu; /**< Semaphore if data is ready in receive buffer */
size_t cc_size; /**< Carbon copy buffer size for matching engine */
void *cc_data; /**< Carbon copy buffer for matching engine */
};
/**
* HL854X driver
*/
struct di_drv_hl854x_ctx {
uint8_t linebuffer[256]; /**< Linebuffer for matching engine */
uint8_t readbuffer[256]; /**< Reader for serial driver */
enum di_drv_hl854x_reply reply; /**< Last reply status @see di_drv_hl854x_reply */
enum di_drv_hl854x_error error; /**< Last error report @see di_drv_hl854x_error */
enum di_drv_hl854x_cme_error cme_error; /**< CME Error code @see di_drv_hl854x_cme_error_codes */
enum di_drv_hl854x_ktcp_notif ktcp_notif; /**< KTCP_NOTIF */
struct modem {
char revision[128]; /**< Identification Information */
char imei[17]; /**< 16 digits IMEISV (8 digits for TAC + 6 digits for SNR + 2 SVN digits) */
} modem;
struct sim {
uint8_t status; /**< Status of SIM @see di_drv_hl854x_sim_status */
char ccid[23]; /**< Integrated Circuit Card ID of the SIM card */
char imsi[20]; /**< IMSI of the SIM card */
} sim;
struct carrier {
enum di_drv_hl854x_carrier_oper_mode mode; /**< Current operator selection mode */
uint8_t status; /**< GPRS carrier status, see @see di_drv_hl854x_carrier_status */
char operator_name[17]; /**< Operator name string */
uint8_t act; /**< Access technology @see di_drv_hl854x_carrier_act */
int8_t rssi; /**< RSSI quality */
uint8_t ber; /**< Bit error rate */
} carrier;
struct di_drv_hl854x_gps gps;
struct con {
const char *gprs_apn;
enum di_drv_hl854x_con_state state; /**< State @see di_drv_hl854x_con_state */
} con;
struct di_drv_hl854x_ctx_tcp tcp; /**< Modem TCP session context */
struct di_drv_hl854x_ctx_udp udp; /**< Modem UDP session context */
/* Private */
struct di_me_ctx me; /**< HL854x driver matching engine context */
enum di_me_item_states me_items_state[DI_DRV_HL854X_ME_ITEMS_SIZE];
struct lock {
di_bsem_t ctx; /**< Context lock */
di_bsem_t reader; /**< Lowlevel reader lock */
} lock;
/* Timeouts */
struct timeout {
uint32_t read; /**< Lowlevel driver read timeout in milliseconds */
uint32_t cmd; /**< AT command reply timeout in milliseconds */
} timeout;
/* Callbacks */
size_t (*read)(void *buf, size_t n); /**< Lowlevel driver read callback */
size_t (*write)(const void *buf, size_t n); /**< Lowlevel driver writer callback */
struct cb {
di_drv_hl854x_error_cb_t error; /**< Application error handler callback */
di_drv_hl854x_cme_error_cb_t cme_error; /**< Application CME error handler callback */
} cb;
};
/** Bearer connection configuration */
struct di_drv_hl854x_apn_cfg {
uint32_t mcc_mnc;
const char *imsi;
const char *apn;
const char *login;
const char *password;
};
#endif /* LIBDI_INCLUDE_DI_DRV_HL854X_STRUCTURES_H_ */