/******************************************************************************** * Copyright: (C) guowenxue * All rights reserved. * * Filename: module.h * Description: This is the GPRS module head file * * Version: 1.0.0(02/02/2012~) * Author: Guo Wenxue * ChangeLog: 1, Release initial version on "02/02/2012 11:33:33 AM" * ********************************************************************************/ #ifndef __CP_GPRS_H #define __CP_GPRS_H #include #include #include #include #include "cp_common.h" #include "cp_logger.h" #include "cp_comport.h" #include "cp_atcmd.h" #include "cp_time.h" #define YES 1 #define NO 0 #define OFF 0 #define ON 1 #define GSM_CTRLPORT "/dev/gprs" #define GSM_DATAPORT "/dev/ttyS2" #define MAX_DATAPORT 4 /* CMUX driver will generate 4 TTY port */ #define CMUX_PORT_START_INDEX 1 #define CMUX_DATAPORT "/dev/gsmtty" /*GPRS module power status control request event*/ enum { REQ_EVENT_NONE = 0, REQ_POWER_OFF, REQ_POWER_ON, REQ_POWER_RESET, }; /* GPRS Module Ready status */ enum { NOT_READY, MODULE_READY, /* GPRS AT command active and SIM card valid */ CHECK_HWINFO, /* Get GPRS hardware Information */ CHECK_REGISTRY, /* Check GPRS register network information */ ALL_READY, }; /* AT+CREG? command show SIM card register status */ enum { REG_UNREGIST = 0, /* not registered, ME is not currently searching a new operator to register to */ REG_HOMEWORK, /* registered, home network */ REG_SEARCHING, /* not registered, but ME is currently searching a new operator to register to */ REG_DENIED, /* registration denied */ REG_UNKNOW, /* unknow */ REG_ROAMING, /* registered, roaming */ }; /* AT+CNMP=? command to set GPRS module work on which mode */ #define MODE_AUTO 2 /* Automatic */ #define MODE_GSM 13 /* GSM Only */ #define MODE_WCDMA 14 /* WCDMA Only */ /* AT+CNSMOD? command show network system mode */ enum { NS_NONE = 0, /* No service */ NS_GSM, /* GSM */ NS_GPRS, /* GPRS */ NS_EGPRS, /* EGPRS(EDGE) */ NS_WCDMA, /* WCDMA */ NS_HSDPA, /* HSDPA only */ NS_HSUPA, /* HSUPA only */ NS_HSPA, /* HSDPA and HSUPA */ }; typedef struct modinfo_s { int users; /* How many users use the module now */ unsigned char ready; /* SIM card regist and can work or not */ unsigned char event; /* Request to set GPRS power REQ_POWER_ON, REQ_POWER_OFF or REQ_POWER_RESET */ unsigned char pwr_status; /* Current module power status */ pthread_mutex_t lock; /* Module control mutex lock */ hwinfo_t hw; /* GPRS Hardware information */ reginfo_t reg; /* SIM card register network information */ comport_t *gsmport; /* The GSM hardware UART port */ int comport_cnt; /* GPRS data channel count */ comport_t *comport[MAX_DATAPORT]; /* CMUX driver generate CMUX port */ } modinfo_t; extern int init_gsm_module(modinfo_t *module); extern int open_gsm_dataport(modinfo_t *module); extern void close_gsm_dataport(modinfo_t *module); extern comport_t *alloc_gsm_dataport(char *who, modinfo_t *module); extern void free_gsm_dataport(char *who, modinfo_t *module, comport_t **comport); extern int power_on_module(modinfo_t *module); extern int power_off_module(modinfo_t *module); extern int atcmd_check_ready(modinfo_t *module); extern int atcmd_inspect_status(modinfo_t *module); extern int atcmd_check_power_on(comport_t *comport); //unsigned char atcmd_inspect(modinfo_t *module, comport_t *comport); extern void set_module_event(modinfo_t *module, int request); extern int set_module_event_power(modinfo_t *module); extern void ctrl_thread_start(void *thread_arg); extern void ctrl_thread_term(void *thread_arg); #endif /* End of __CP_GPRS_H */