From 284a3d9f035bff1ba875d0fb160d99095f45c809 Mon Sep 17 00:00:00 2001 From: Firefly Date: Tue, 17 Nov 2015 10:01:55 +0800 Subject: [PATCH] [hardware/ril] add dongle --- hardware/ril/include/telephony/config.h | 29 + hardware/ril/reference-ril/Android.mk | 14 +- hardware/ril/reference-ril/atchannel.c | 452 +- hardware/ril/reference-ril/atchannel.h | 22 +- hardware/ril/reference-ril/config.h | 38 + hardware/ril/reference-ril/extend_at_func.c | 1244 ++++ hardware/ril/reference-ril/extend_at_func.h | 96 + hardware/ril/reference-ril/gsm.c | 1165 +++ hardware/ril/reference-ril/gsm.h | 177 + .../ril/reference-ril/modem_define_func.c | 233 + .../ril/reference-ril/modem_define_func.h | 7 + hardware/ril/reference-ril/modem_list.h | 1990 ++++++ hardware/ril/reference-ril/operator_table.c | 189 + hardware/ril/reference-ril/operator_table.h | 17 + .../ril/reference-ril/ril-rk29-dataonly.c | 6275 +++++++++++++++++ 15 files changed, 11930 insertions(+), 18 deletions(-) create mode 100644 hardware/ril/include/telephony/config.h create mode 100644 hardware/ril/reference-ril/config.h create mode 100644 hardware/ril/reference-ril/extend_at_func.c create mode 100644 hardware/ril/reference-ril/extend_at_func.h create mode 100644 hardware/ril/reference-ril/gsm.c create mode 100644 hardware/ril/reference-ril/gsm.h create mode 100644 hardware/ril/reference-ril/modem_define_func.c create mode 100644 hardware/ril/reference-ril/modem_define_func.h create mode 100644 hardware/ril/reference-ril/modem_list.h create mode 100644 hardware/ril/reference-ril/operator_table.c create mode 100644 hardware/ril/reference-ril/operator_table.h create mode 100644 hardware/ril/reference-ril/ril-rk29-dataonly.c diff --git a/hardware/ril/include/telephony/config.h b/hardware/ril/include/telephony/config.h new file mode 100644 index 0000000000..7468dd5896 --- /dev/null +++ b/hardware/ril/include/telephony/config.h @@ -0,0 +1,29 @@ + +/* + 当 RIL_RELEASE 被定义时,所有处于调试中的modem将不会编译进来 + 在编译RIL库并发布时,应当定义 RIL_RELEASE + */ +#define RIL_RELEASE + +/* + 当 ENABLE_DNS_CHECK 被定义时,在拨号完成后会检查所分配到的DNS + 如果DNS有异常(例如10.11.12.13)时,将会重新进行拨号 + + 使用专网的SIM卡,它本身可能不提供访问外部网络的能力,因此拨号 + 上网时不会分配DNS, 对于这种情况,应设置: + #define ENABLE_DNS_CHECK 0 + 其它正常的SIM卡都应设置: + #define ENABLE_DNS_CHECK 1 +*/ +#define ENABLE_DNS_CHECK 1 + +#define SUPPORT_SMS 0 + +/* + 当 ENABLE_STAY_AWAKE 定义时,对于CDMA/EVDO网络,拨号上网后将不会进入二级睡眠 + */ +//#define ENABLE_STAY_AWAKE + +#define MULTI_RIL_LIB 0 + +#define GET_USI_IMEI 0 diff --git a/hardware/ril/reference-ril/Android.mk b/hardware/ril/reference-ril/Android.mk index d9908c166d..bb24269b4e 100644 --- a/hardware/ril/reference-ril/Android.mk +++ b/hardware/ril/reference-ril/Android.mk @@ -6,13 +6,17 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ - reference-ril.c \ + ril-rk29-dataonly.c \ atchannel.c \ misc.c \ - at_tok.c - + at_tok.c \ + extend_at_func.c \ + modem_define_func.c \ + operator_table.c \ + gsm.c +LOCAL_MODULE_TAGS := optional LOCAL_SHARED_LIBRARIES := \ - liblog libcutils libutils libril librilutils + liblog libcutils libutils libril librilutils libhardware_legacy libnetutils # for asprinf LOCAL_CFLAGS := -D_GNU_SOURCE @@ -36,7 +40,7 @@ ifeq (foo,foo) LOCAL_SHARED_LIBRARIES += \ libcutils libutils LOCAL_CFLAGS += -DRIL_SHLIB - LOCAL_MODULE:= libreference-ril + LOCAL_MODULE:= libril-rk29-dataonly include $(BUILD_SHARED_LIBRARY) else #build executable diff --git a/hardware/ril/reference-ril/atchannel.c b/hardware/ril/reference-ril/atchannel.c index 377dfa880a..ed65b149f6 100644 --- a/hardware/ril/reference-ril/atchannel.c +++ b/hardware/ril/reference-ril/atchannel.c @@ -46,6 +46,8 @@ #define HANDSHAKE_RETRY_COUNT 8 #define HANDSHAKE_TIMEOUT_MSEC 250 +// cmy: 在发送AT命令之前加点延时,防止多个命令下发时底层处理不过来 +#define DELAY_BEFORE_AT_CMD_MS 100 static pthread_t s_tid_reader; static int s_fd = -1; /* fd of the AT channel */ static ATUnsolHandler s_unsolHandler; @@ -55,6 +57,10 @@ static ATUnsolHandler s_unsolHandler; static char s_ATBuffer[MAX_AT_RESPONSE+1]; static char *s_ATBufferCur = s_ATBuffer; +static int s_ackPowerIoctl; /* true if TTY has android byte-count + handshake for low power*/ +static int s_readCount = 0; + #if AT_DEBUG void AT_DUMP(const char* prefix, const char* buff, int len) { @@ -85,6 +91,349 @@ static void onReaderClosed(); static int writeCtrlZ (const char *s); static int writeline (const char *s); +#define LG_VL600 + +#ifdef LG_VL600 +static unsigned int send_seq = 0; +static unsigned int recv_seq = -1; +static const unsigned char VL600_CMD_HEADER[] = +{ + 0x5A, 0x48, 0x12, 0xA5, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0x11, 0xF0 +}; +static const size_t VL600_CMD_HEADER_LEN = sizeof(VL600_CMD_HEADER)*sizeof(unsigned char); + +static unsigned char vl600_attach_cmd[1908] = +{ + 0x5A, 0x48, 0x12, 0xA5, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0x21, 0xF0, +}; + +static char in_buf[MAX_AT_RESPONSE]; +static char out_buf[MAX_AT_RESPONSE]; + +static void dump_pack(unsigned char* data, int len) +{ + int i=0; + int j=0; + char bs[3]; + char out[128] = "\0"; + + int line = (len+15)/16; + for(i=0; i=len) + break; + sprintf(bs, " %02X", data[i*16+j]); + strcat(out, bs); + } + RLOGD("%s", out); + memset(out, 0, 128); +// strcat(out, "\n"); + } +} + +/* + return value: + success > 0 + failed <= 0 + */ +static int vl600_pack(const char* in, char* out, int buf_len) +{ + int len = strlen(in); + int out_len = VL600_CMD_HEADER_LEN+len; + +// LOGD("vl600 packet"); +// dump_pack(in, len); + + out_len += 4-(out_len%4); +// LOGD("in_len=%d, out_len=%d", len, out_len); + + if( out_len > buf_len ) + { + RLOGD("Out buffer not enough"); + return 0; + } + + memset(out, 0, out_len); + memcpy(out, VL600_CMD_HEADER, VL600_CMD_HEADER_LEN); + *(unsigned int*)(out+4) = send_seq; + *(unsigned int*)(out+8) = len; + memcpy(out+VL600_CMD_HEADER_LEN, in, len); + +// dump_pack(out, out_len); + + send_seq++; +// LOGD("send_seq=%d", send_seq); + + return out_len; +} + +/* + return value: + success >= 0 + failed < 0 + */ +static int vl600_unpack(const unsigned char *in, int in_len, const unsigned char *out, int max_len) +{ + unsigned char* p = in; + int p_len = in_len; + unsigned int seq = 0; + int len = 0; + int out_len; + +// LOGD("vl600 unpacket"); +// dump_pack(in, in_len); + + while(*p == 0){ + ++p; + --p_len; + } + + if(p_len<=14) + { + RLOGE("data len=%d", p_len); + return -1; + } + + if( p[0] != 0x5a || p[1] != 0x48 || p[2] != 0x12 || p[3] != 0xa5 || + p[12] != 0x11 || p[13] != 0xf0) + { + RLOGE("Invalid magic"); + return -1; + } + + seq = *(unsigned int*)(p+4); +// LOGD("seq=%d", seq); + + if(seq == recv_seq) + { + RLOGE("Invalid sequence"); + return -1; + } + + recv_seq = seq; + + len = *(unsigned int*)(p+8); +// LOGD("len=%d, p_len=%d", len, p_len); + + if(p_len < len+VL600_CMD_HEADER_LEN) + { + RLOGE("Packet incomplete"); + return -1; + } + out_len = len>max_len?max_len:len; + memcpy(out, p+VL600_CMD_HEADER_LEN, out_len); + + if(len > max_len) + { + RLOGD("packet too long"); + } + +// dump_pack(out, out_len); + + return out_len; +} + +static unsigned char* vl600_setup_attach() +{ + unsigned char* cmd = vl600_attach_cmd; + unsigned int plen = 1891; + + *(unsigned int*)(cmd+4) = send_seq; + *(unsigned int*)(cmd+8) = plen; + cmd[14] = 0xF1; + cmd[15] = 0x4A; + cmd[1908-6]=0xB1; + cmd[1908-5]=0xF3; + cmd[1908-4]=0x7E; + +// dump_pack(cmd, 1908); + + return cmd; +} + +int vl600_attach() +{ + size_t cur = 0; + ssize_t written; + + RLOGD("vl600_attach"); + + if (s_fd < 0 || s_readerClosed > 0) { + return AT_ERROR_CHANNEL_CLOSED; + } + + unsigned char *cmd = vl600_setup_attach(); + size_t len = sizeof(vl600_attach_cmd); + + /* the main string */ + while (cur < len) { + do { + written = write (s_fd, cmd + cur, len - cur); + } while (written < 0 && errno == EINTR); + + if (written < 0) { + return AT_ERROR_GENERIC; + } + + cur += written; + } + + return 0; +} +#endif + +static void sleepMsec(long long msec); +static int is_emulate = 0; +static char cur_cmd[1024] = {0}; + +int at_emulate_enter() +{ + is_emulate = 1; + sleepMsec(200); + + close(s_fd); + return 0; +} + +int at_emulate_exit() +{ + if(is_emulate) + { + s_fd = open_at_port(); + sleepMsec(1000); + + is_emulate = 0; + + if(s_fd > 0 ) + at_handshake(); + } + return 0; +} + +#if 1// UML290 + char reponse_csq[256] = "+CSQ: 21, 99\r"; + char reponse_cimi[256] = "311480009868905\r"; + char reponse_cops[256] = "+COPS: 0,0,\"Verizon Wireless\",7\r"; + char reponse_cgmm[256] = "+CGMM: UML290VW\r"; + char reponse_cgsn[256] = "+CGSN: 990000475112084\r"; + char reponse_creg[256] = "+CREG: 2,1\r"; + char reponse_cgreg[256] = "+CGREG: 2,1, FFFE, 4EEC03, 7\r"; + char reponse_sysinfo[256] = "^SYSINFO: 2,3,0,15,1,0,5\r"; + char reponse_cgact[256] = "+CGACT: 1,1\r+CGACT: 3,1\r+CGACT: 4,0\r"; + char reponse_cgdcont[256] = "+CGDCONT: 3,\"IPV4V6\",\"vzwinternet\",\"0.0.0.0\",0,0\r"; +#else + char reponse_csq[256] = "+CSQ: 10, 99\r"; + char reponse_cimi[256] = "111110001111905\r"; + char reponse_cops[256] = "+COPS: 0,0,\"TEST\",2\r"; + char reponse_cgmm[256] = "+CGMM: TEST\r"; + char reponse_cgsn[256] = "+CGSN: 110000115112084\r"; + char reponse_creg[256] = "+CREG: 2,1\r"; + char reponse_cgreg[256] = "+CGREG: 2,1, FFFE, 4EEC03\r"; + char reponse_sysinfo[256] = "^SYSINFO: 2,3,0,15,1,0,5\r"; + char reponse_cgact[256] = "+CGACT: 1,1\r"; + char reponse_cgdcont[256] = "+CGDCONT: 1,\"IP\",\"cmnet\",,,0,0\r"; +#endif + +static int read_emulate(char* buf, int len) +{ + int ret = 0; + + while(cur_cmd[0] == 0) + { + if(!is_emulate) + { + if(s_fd<0) + return -1; + else + break; + } + sleepMsec(20); + } + + if ( strcmp(cur_cmd, "AT+CSQ")==0 ) + { + strcpy(buf, reponse_csq); + ret = strlen(reponse_csq); + } + else if ( strcmp(cur_cmd, "AT+CFUN?")==0 ) + { + strcpy(buf, "+CFUN: 1\r"); + ret = strlen("+CFUN: 1\r"); + } + else if ( strcmp(cur_cmd, "AT+CPIN?")==0 ) + { + strcpy(buf, "+CPIN: READY\r"); + ret = strlen("+CPIN: READY\r"); + } + else if ( strcmp(cur_cmd, "AT+CIMI")==0 ) + { + strcpy(buf, reponse_cimi); + ret = strlen(reponse_cimi); + } + else if ( strcmp(cur_cmd, "AT+COPS?")==0 ) + { + strcpy(buf, reponse_cops); + ret = strlen(reponse_cops); + } + else if ( strcmp(cur_cmd, "AT+CGMM")==0 ) + { + strcpy(buf, reponse_cgmm); + ret = strlen(reponse_cgmm); + } + else if ( strcmp(cur_cmd, "AT^MEID")==0 ) + { + strcpy(buf, "^MEID: 12345678901234\r"); + ret = strlen("^MEID: 12345678901234\r"); + } + else if ( strcmp(cur_cmd, "AT+GSN")==0 ) + { + strcpy(buf, "+GSN: 86e5515f\r"); + ret = strlen("+GSN: 86e5515f\r"); + } + else if ( strcmp(cur_cmd, "AT+CGSN")==0 ) + { + strcpy(buf, reponse_cgsn); + ret = strlen(reponse_cgsn); + } + else if ( strcmp(cur_cmd, "AT+CREG?")==0 ) + { + strcpy(buf, reponse_creg); + ret = strlen(reponse_creg); + } + else if ( strcmp(cur_cmd, "AT+CGREG?")==0 ) + { + strcpy(buf, reponse_cgreg); + ret = strlen(reponse_cgreg); + } + else if ( strcmp(cur_cmd, "AT^SYSINFO")==0 ) + { + strcpy(buf, reponse_sysinfo); + ret = strlen(reponse_sysinfo); + } + else if ( strcmp(cur_cmd, "AT+CGACT?")==0 ) + { + strcpy(buf, reponse_cgact); + ret = strlen(reponse_cgact); + } + else if ( strcmp(cur_cmd, "AT+CGDCONT?")==0 ) + { + strcpy(buf, reponse_cgdcont); + ret = strlen(reponse_cgdcont); + } + + strcat(buf, "OK\r"); + ret += strlen("OK\r"); + + return ret; +} #ifndef USE_NP static void setTimespecRelative(struct timespec *p_ts, long long msec) { @@ -144,6 +493,10 @@ static const char * s_finalResponsesError[] = { "NO CARRIER", /* sometimes! */ "NO ANSWER", "NO DIALTONE", + +// cmy: 下面几个出错是HuaWei EM660C模块命令出错信息 + "COMMAND NOT SUPPORT", + "TOO MANY PARAMETERS", }; static int isFinalResponseError(const char *line) { @@ -369,13 +722,33 @@ static const char *readline() p_read = s_ATBuffer; } - do { - count = read(s_fd, p_read, - MAX_AT_RESPONSE - (p_read - s_ATBuffer)); - } while (count < 0 && errno == EINTR); + if(is_emulate) + { + count = read_emulate(p_read, + MAX_AT_RESPONSE - (p_read - s_ATBuffer)); + cur_cmd[0] = 0; + } + // cmy@20120105: for LG VL600 + else if(!modem_cmp(0x1004, 0x61AA, NULL)) + { + memset(in_buf, 0, MAX_AT_RESPONSE); + do { + count = read(s_fd, in_buf, MAX_AT_RESPONSE); + if(count > 0) + count = vl600_unpack(in_buf, count, p_read, MAX_AT_RESPONSE - (p_read - s_ATBuffer)); + } while (count < 0 && errno == EINTR); + } + else + { + do { + count = read(s_fd, p_read, + MAX_AT_RESPONSE - (p_read - s_ATBuffer)); + } while (count < 0 && errno == EINTR); + } if (count > 0) { AT_DUMP( "<< ", p_read, count ); + s_readCount += count; p_read[count] = '\0'; @@ -485,11 +858,43 @@ static int writeline (const char *s) AT_DUMP( ">> ", s, strlen(s) ); - /* the main string */ - while (cur < len) { - do { - written = write (s_fd, s + cur, len - cur); - } while (written < 0 && errno == EINTR); + if(is_emulate) + { + if(cur_cmd[0] == 0) + strcpy(cur_cmd, s); + } + // cmy@20120105: for LG VL600 + else if(!modem_cmp(0x1004, 0x61AA, NULL)) + { + memset(in_buf, 0, MAX_AT_RESPONSE); + memset(out_buf, 0, MAX_AT_RESPONSE); + sprintf(in_buf, "%s\r", s); + len = vl600_pack(in_buf, out_buf, MAX_AT_RESPONSE); + if(len <= 0) + return AT_ERROR_GENERIC; + + /* the main string */ + while (cur < len) { + do { + written = write (s_fd, out_buf + cur, len - cur); + } while (written < 0 && errno == EINTR); + + if (written < 0) { + return AT_ERROR_GENERIC; + } + + cur += written; + } + +// sleepMsec(500); + } + else + { + /* the main string */ + while (cur < len) { + do { + written = write (s_fd, s + cur, len - cur); + } while (written < 0 && errno == EINTR); if (written < 0) { return AT_ERROR_GENERIC; @@ -504,8 +909,9 @@ static int writeline (const char *s) written = write (s_fd, "\r" , 1); } while ((written < 0 && errno == EINTR) || (written == 0)); - if (written < 0) { - return AT_ERROR_GENERIC; + if (written < 0) { + return AT_ERROR_GENERIC; + } } return 0; @@ -680,6 +1086,7 @@ static int at_send_command_full_nolock (const char *command, ATCommandType type, goto error; } + sleepMsec(DELAY_BEFORE_AT_CMD_MS); err = writeline (command); if (err < 0) { @@ -777,6 +1184,11 @@ static int at_send_command_full (const char *command, ATCommandType type, * if non-NULL, the resulting ATResponse * must be eventually freed with * at_response_free */ +int at_send_command_t(const char *command, long long timeoutMsec, ATResponse **pp_outResponse) +{ + return at_send_command(command, pp_outResponse); +} + int at_send_command (const char *command, ATResponse **pp_outResponse) { int err; @@ -788,6 +1200,14 @@ int at_send_command (const char *command, ATResponse **pp_outResponse) } +int at_send_command_singleline_t (const char *command, + const char *responsePrefix, + long long timeoutMsec, + ATResponse **pp_outResponse) +{ + return at_send_command_singleline(command, responsePrefix, pp_outResponse); +} + int at_send_command_singleline (const char *command, const char *responsePrefix, ATResponse **pp_outResponse) @@ -857,6 +1277,14 @@ int at_send_command_sms (const char *command, } +int at_send_command_multiline_t (const char *command, + const char *responsePrefix, + long long timeoutMsec, + ATResponse **pp_outResponse) +{ + return at_send_command_multiline(command, responsePrefix, pp_outResponse); +} + int at_send_command_multiline (const char *command, const char *responsePrefix, ATResponse **pp_outResponse) @@ -908,7 +1336,7 @@ int at_handshake() for (i = 0 ; i < HANDSHAKE_RETRY_COUNT ; i++) { /* some stacks start with verbose off */ - err = at_send_command_full_nolock ("ATE0Q0V1", NO_RESULT, + err = at_send_command_full_nolock ("ATE0", NO_RESULT, NULL, NULL, HANDSHAKE_TIMEOUT_MSEC, NULL); if (err == 0) { diff --git a/hardware/ril/reference-ril/atchannel.h b/hardware/ril/reference-ril/atchannel.h index cfd49d5395..8f54680619 100644 --- a/hardware/ril/reference-ril/atchannel.h +++ b/hardware/ril/reference-ril/atchannel.h @@ -22,6 +22,14 @@ extern "C" { #endif +#if (RIL_VERSION >= 7) + #define LOGD ALOGD + #define LOGI ALOGI + #define LOGW ALOGW + #define LOGE ALOGE + #define LOGV ALOGV +#endif + /* define AT_DEBUG to send AT traffic to /tmp/radio-at.log" */ #define AT_DEBUG 0 @@ -87,6 +95,11 @@ void at_set_on_timeout(void (*onTimeout)(void)); channel is already closed */ void at_set_on_reader_closed(void (*onClose)(void)); +int at_send_command_singleline_t (const char *command, + const char *responsePrefix, + long long timeoutMsec, + ATResponse **pp_outResponse); + int at_send_command_singleline (const char *command, const char *responsePrefix, ATResponse **pp_outResponse); @@ -98,11 +111,17 @@ int at_send_command_multiline (const char *command, const char *responsePrefix, ATResponse **pp_outResponse); +int at_send_command_multiline_t (const char *command, + const char *responsePrefix, + long long timeoutMsec, + ATResponse **pp_outResponse); int at_handshake(); int at_send_command (const char *command, ATResponse **pp_outResponse); +int at_send_command_t (const char *command, long long timeoutMsec, ATResponse **pp_outResponse); + int at_send_command_sms (const char *command, const char *pdu, const char *responsePrefix, ATResponse **pp_outResponse); @@ -112,7 +131,8 @@ void at_response_free(ATResponse *p_response); typedef enum { CME_ERROR_NON_CME = -1, CME_SUCCESS = 0, - CME_SIM_NOT_INSERTED = 10 + CME_SIM_NOT_INSERTED = 10, + CME_SIM_FAILED = 13 } AT_CME_Error; AT_CME_Error at_get_cme_error(const ATResponse *p_response); diff --git a/hardware/ril/reference-ril/config.h b/hardware/ril/reference-ril/config.h new file mode 100644 index 0000000000..3492335517 --- /dev/null +++ b/hardware/ril/reference-ril/config.h @@ -0,0 +1,38 @@ + +/* + 当 RIL_RELEASE 被定义时,所有处于调试中的modem将不会编译进来 + 在编译RIL库并发布时,应当定义 RIL_RELEASE + */ +#define RIL_RELEASE + +/* + 当 ENABLE_DNS_CHECK 被定义时,在拨号完成后会检查所分配到的DNS + 如果DNS有异常(例如10.11.12.13)时,将会重新进行拨号 + + 使用专网的SIM卡,它本身可能不提供访问外部网络的能力,因此拨号 + 上网时不会分配DNS, 对于这种情况,应设置: + #define ENABLE_DNS_CHECK 0 + 其它正常的SIM卡都应设置: + #define ENABLE_DNS_CHECK 1 +*/ +#define ENABLE_DNS_CHECK 1 + +#define SUPPORT_SMS 0 + +#define GET_USI_IMEI 0 + +#define SUPPORT_MU509 0 + +#define SUPPORT_MT6229 0 + +#define SUPPORT_MW100 0 + +#define SUPPORT_STRONGRISING 0 + +/* + 当 ENABLE_STAY_AWAKE 定义时,对于CDMA/EVDO网络,拨号上网后将不会进入二级睡眠 + */ +#define ENABLE_STAY_AWAKE + + + diff --git a/hardware/ril/reference-ril/extend_at_func.c b/hardware/ril/reference-ril/extend_at_func.c new file mode 100644 index 0000000000..466db2259e --- /dev/null +++ b/hardware/ril/reference-ril/extend_at_func.c @@ -0,0 +1,1244 @@ +#include +#include "atchannel.h" +#include "at_tok.h" +#include "extend_at_func.h" + +#define LOG_TAG "RIL" +#include + +int networkType2RAT(int networkType) +{ + int response = RADIO_TECHNOLOGY_UNKNOWN; + switch(networkType) + { + case 0: + response = RADIO_TECHNOLOGY_GPRS; + break; + case 1: + response = RADIO_TECHNOLOGY_GPRS; + break; + case 2: + response = RADIO_TECHNOLOGY_UMTS; + break; + case 3: + response = RADIO_TECHNOLOGY_EDGE; + break; + case 4: + response = RADIO_TECHNOLOGY_HSDPA; + break; + case 5: + response = RADIO_TECHNOLOGY_HSUPA; + break; + case 6: + response = RADIO_TECHNOLOGY_HSPA; + break; + case 7: + response = RADIO_TECHNOLOGY_LTE; + break; + default: + response = RADIO_TECHNOLOGY_UNKNOWN; + break; + } + return response; +} + +/* + 从COPS指令中查询access technology,与 CS/PS 服务状态 + + CS/PS 服务状态: 只有当modem没有提供相应命令时,才使用COPS命令 + access technology: 只有当CREG/CGREG没有返回该值,且modem没有提供相应命令时才使用COPS + + 返回值: + 0: 命令成功 + -1: 命令失败 + */ +int queryOperator(int *network, int *restricted) +{ + int err; + char *line; + ATResponse *p_response = NULL; + int skip; + char* str_skip; + int net; + + if(restricted) *restricted = RIL_RESTRICTED_STATE_CS_ALL|RIL_RESTRICTED_STATE_PS_ALL; + if(network) *network = RADIO_TECHNOLOGY_UNKNOWN; + + err = at_send_command_singleline("AT+COPS?", "+COPS:", &p_response); + + if (err < 0 || p_response->success == 0) { + at_response_free(p_response); + return -1; + } + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + + if (err < 0) goto end; + + err = at_tok_nextint(&line, &skip); + if (err < 0) goto end; + + err = at_tok_nextint(&line, &skip); + if (err < 0) goto end; + + err = at_tok_nextstr(&line, &str_skip); + if (err < 0) goto end; + + err = at_tok_nextint(&line, &net);/*0,1,2--> GSM ,GSM-COMPACT,UTRAN*/ + if(err < 0 ) goto end; + + if(network) *network = networkType2RAT(net); + if(restricted) *restricted = RIL_RESTRICTED_STATE_NONE; + +end: + at_response_free(p_response); + return 0; +} + +// 返回值 成功: 0 失败: -1 +int querySystemInfo(AT_SYSTEM_INFO* sys_info) +{ + int err; + ATResponse *p_response = NULL; + char *line, *p; + int commas; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + memset(sys_info, 0, sizeof(AT_SYSTEM_INFO)); + + err = at_send_command_singleline("AT^SYSINFO", "^SYSINFO:", &p_response); + + if (err < 0 || p_response->success == 0) goto error; + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + if (err < 0) goto error; + + /* count number of commas */ + commas = 0; + for (p = line ; *p != '\0' ;p++) { + if (*p == ',') commas++; + } + //AT< ^SYSINFO:2,3,0,5,1,,7 + //at< ^2,255,0,8,1,,11 + LOGD("[%s]: SYSCOMMD=%d", __FUNCTION__, commas); + + if(commas < 4) goto error; + + err = at_tok_nextint(&line, &sys_info->srv_status); + if (err < 0) goto error; + err = at_tok_nextint(&line, &sys_info->srv_domain); + if (err < 0) goto error; + err = at_tok_nextint(&line, &sys_info->roam_status); + if (err < 0) goto error; + err = at_tok_nextint(&line, &sys_info->sys_mode); + if (err < 0) goto error; + err = at_tok_nextint(&line, &sys_info->sim_state); + if (err < 0) goto error; + + if(commas >= 6) + { + at_tok_nextint(&line, &sys_info->reserve); + LOGD("[%s]: RESERVE=%d", __FUNCTION__, sys_info->reserve); + err = at_tok_nextint(&line, &sys_info->sys_submode); + LOGD("[%s]: subsysmode=%d", __FUNCTION__, sys_info->sys_submode); + if (err < 0) goto error; + } + + at_response_free(p_response); + return 0; + +error: + LOGD("[%s]: err=%d", __FUNCTION__, err); + at_response_free(p_response); + return -1; +} + +// 返回值 成功: 0 失败: -1 +int checkCardStatus_zte(char* network, char* srv_domain_str) +{ + int err; + char *line; + ATResponse *p_response = NULL; + char* p_value; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + network[0]=0; + srv_domain_str[0]=0; + + err = at_send_command_singleline("AT+ZPAS?", "+ZPAS:", &p_response); + if (err < 0 || p_response->success == 0) goto error; + line = p_response->p_intermediates->line; + err = at_tok_start(&line); + if (err < 0) goto error; + + err = at_tok_nextstr(&line, &p_value); + if (err < 0) goto error; + strcpy(network, p_value); + err = at_tok_nextstr(&line, &p_value); + if (err < 0) goto error; + strcpy(srv_domain_str, p_value); + + at_response_free(p_response); + return 0; + +error: + at_response_free(p_response); + LOGE("ERROR: [%s ]failed\n", __FUNCTION__); + return -1; +} + + +/*************************************************************** +cmy@20100611: 获取首选网络类型系列函数 getPreferredNetworkType_xxx + 返回值 正常: 首选网络类型,其它错误: -1 +***************************************************************/ + +// for china mobile +extern int getCurModelRadio(); + +int getPreferredNetworkType_cnm() +{ + int err; + ATResponse *p_response = NULL; + int response = 0; + char *line; + int mode, acqorder, roam, srvdomain; + int skip; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + if( !modem_cmp(0x12D1, 0x1001, "MU509") + ||!modem_cmp(0x12d1, 0x1506, "E1220") + ||!modem_cmp(0x12d1,0x1001,"E3131") + ||!modem_cmp(0x19F5, 0x9013, "UW100") + ||!modem_cmp(0x1C9E, 0x9603, "HSPA USB MODEM") + ||!modem_cmp(0x12D1, 0x140c, "E303") + ||!modem_cmp(0x12D1, 0x1506, "E357") + ||!modem_cmp(0x12D1, 0x140C, "E1552") + ||!modem_cmp(0x12D1, 0x1001, "K3806") + ||!modem_cmp(0x12d1, 0x1001, "K3770") + ||!modem_cmp(0x12d1,0x1001,"K3773") + ||!modem_cmp(0x12d1, 0x1001, "E1750") + ||!modem_cmp(0x19F5, 0x9013, "MW160") + ||!modem_cmp(0x12d1,0x140c,"E261") + ||!modem_cmp(0x12d1,0x1003,"E160E") + ||!modem_cmp(0x12d1,0x1506,"E303C" + ||!modem_cmp(0x12d1,0x1001,"E3131C")) + ||!modem_cmp(0x12d1,0x1506,"MU609") + ||(getCurModelRadio()==3))//国外3G vodafon K3770 UM100 + { + err = at_send_command_singleline("AT^SYSCFG?", "^SYSCFG:", &p_response); + } + else + { + err = at_send_command_singleline("AT^SYSCONFIG?", "^SYSCONFIG:", &p_response); + } + + if (err < 0 || p_response->success == 0) goto error; + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + + if (err < 0) goto error; + + err = at_tok_nextint(&line, &mode); + if(err < 0) goto error; + err = at_tok_nextint(&line, &acqorder); + if(err < 0) goto error; + + switch(mode) + { + case 2:// 自动选择 + switch(acqorder) + { + case 0: response = NETWORK_MODE_GLOBAL; break; // 自动选择 + case 1: response = NETWORK_MODE_GSM_UMTS; break; // GSM PREF + case 2: default: response = NETWORK_MODE_WCDMA_PREF; break; // UTRAN PREF + } + break; + case 13: response = NETWORK_MODE_GSM_ONLY; break; // GSM ONLY + case 14:case 15: response = NETWORK_MODE_WCDMA_ONLY; break; // WCDMA/TD-SCDMA ONLY + default: goto error; break; // ERROR + } + + LOGD("[%s]: return network mode=%d", __FUNCTION__, response); + + at_response_free(p_response); + + return response; + +error: + at_response_free(p_response); + LOGE("ERROR: [%s ]failed\n", __FUNCTION__); + + return -1; +} + +/*************************************************************** +cmy@20100611: 设置首选网络类型系列函数 setPreferredNetworkType_xxx + 返回值 正常: 0,网络类型错误: -1,其它错误: -2 +xxh@ SYSCONFIG指令和SYSCFG指令分别对应TD-SCDMA和WCDMA +***************************************************************/ + +extern int getCurModelRadio(); +int setPreferredNetworkType_cnm(int rat) +{ + int err; + ATResponse *p_response = NULL; + char * cmd = NULL; + int mode, acqorder; + int roam=2, srvdomain=4; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + +// 在该函数中应该调用 getPreferredNetworkType_cnm + int cur_type = getPreferredNetworkType_cnm();// getPreferredNetworkType_zte(); + + LOGD("[%s]: new preferred network type is: %d", __FUNCTION__, rat); + LOGD("[%s]: current preferred network type is: %d", __FUNCTION__, cur_type); + + if(cur_type == rat) return 0; + + switch(rat) + { + case NETWORK_MODE_WCDMA_PREF: mode = 2; acqorder = 2; break; + case NETWORK_MODE_GSM_ONLY: mode = 13; acqorder = 1; break; + case NETWORK_MODE_WCDMA_ONLY: mode=(getCurModelRadio() == 3)?14:15; acqorder = 2; break; + case NETWORK_MODE_GSM_UMTS: mode = 2; acqorder = 1; break; + case NETWORK_MODE_GLOBAL: mode = 2; acqorder = 0; break; + default: goto error_mode; + } + + if(getCurModelRadio()==3){ //wcdma网络 + + if( !modem_cmp(0x12D1, 0x1001, "MU509") + ||!modem_cmp(0x12d1, 0x1506, "E1220") + ||!modem_cmp(0x12d1,0x140c,"E261") + ||!modem_cmp(0x12d1,0x1001,"E3131") + ||!modem_cmp(0x12d1,0x1506,"MU609") + ) + { + asprintf(&cmd, "AT^SYSCFG=%d,%d, 40000000,%d,%d", mode, acqorder, roam, srvdomain); + //asprintf(&cmd, "AT^SYSCFG=%d,%d, 3fffffff,%d,%d", mode, acqorder, roam, srvdomain); + err = at_send_command(cmd, &p_response); + free(cmd); + if (err < 0|| p_response->success == 0) goto error; + } + else if(!modem_cmp(0x19F5, 0x9013, "UW100") + || !modem_cmp(0x1C9E, 0x9603, "HSPA USB MODEM") + || !modem_cmp(0x19F5, 0x9013, "MW160"))//内置模块think mw100 + { + asprintf(&cmd, "AT^SYSCFG=%d,%d, 3FFFFFFF ,%d,%d", mode, acqorder, roam, srvdomain); + err = at_send_command(cmd, &p_response); + free(cmd); + if (err < 0|| p_response->success == 0) goto error; + } + else if(!modem_cmp(0x12D1, 0x1506, "E357") + || !modem_cmp(0x12D1, 0x140c, "E303") + ||!modem_cmp(0x12D1, 0x140C, "E1552") + ||!modem_cmp(0x12D1, 0x1001, "K3806") + ||!modem_cmp(0x12d1, 0x1001, "K3770") + ||!modem_cmp(0x12d1,0x1001,"K3772") + ||!modem_cmp(0x12d1,0x1001,"K3773") + ||!modem_cmp(0x12d1,0x1506,"E303C") + ||!modem_cmp(0x12d1,0x1001,"E3131C") + ||!modem_cmp(0x12d1,0x1003,"E160E"))//国外两个vodafone 3G dongle + { + asprintf(&cmd, "AT^SYSCFG=%d,%d, 40000000 ,%d,%d", mode, acqorder, roam, srvdomain); + err = at_send_command(cmd, &p_response); + free(cmd); + if (err < 0|| p_response->success == 0) goto error; + } + else + LOGD("WCDMA Net work to GSM network......"); + asprintf(&cmd, "AT^SYSCFG=%d,%d, 40000000,2,4", mode, acqorder); + err = at_send_command(cmd, &p_response); + free(cmd); + if (err < 0|| p_response->success == 0) goto error; + + }else //td网络 + { + /* Need to unregister from NW before changing preferred RAT */ + //err = at_send_command("AT+COPS=2", NULL); + //if (err < 0) goto error; + + asprintf(&cmd, "AT^SYSCONFIG=%d,%d,%d,%d", mode, acqorder, roam, srvdomain); + err = at_send_command(cmd, &p_response); + free(cmd); + if (err < 0|| p_response->success == 0) goto error; + + /* Register on the NW again */ + //err = at_send_command("AT+COPS=0", NULL); + //if (err < 0) goto error; + } + + at_response_free(p_response); + return 0; +error_mode: + at_response_free(p_response); + return -1; +error: + at_response_free(p_response); + return -2; +} + +/*************************************************************** +cmy@20100611: 获取网络类型系列函数 getNetworkType_xxx + 返回值 网络类型 + RADIO_TECHNOLOGY_UNKNOWN = 0, + RADIO_TECHNOLOGY_GPRS, + RADIO_TECHNOLOGY_EDGE, + RADIO_TECHNOLOGY_UMTS, +// CDMA95A/B + RADIO_TECHNOLOGY_IS95A, + RADIO_TECHNOLOGY_IS95B, +// CDMA2000 1x RTT + RADIO_TECHNOLOGY_1xRTT, +// CDMA2000 1x EVDO + RADIO_TECHNOLOGY_EVDO_0, + RADIO_TECHNOLOGY_EVDO_A, +// + RADIO_TECHNOLOGY_HSDPA, + RADIO_TECHNOLOGY_HSUPA, + RADIO_TECHNOLOGY_HSPA, + RADIO_TECHNOLOGY_TDSCDMA, +***************************************************************/ +// 对于^SYSINFO命令,其它返回值的最后两个字段reserve/sys_submode,在中国移动中,可能有也可能没有, +// 但在中国电信的AT指令集中,该命令最后两个字段不使用 +int getNetworkType_cnm() +{// 该函数可用于 China Mobile, China Telecom, China Unicom + int network_type = RADIO_TECHNOLOGY_UNKNOWN; + int err; + AT_SYSTEM_INFO sys_info; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + err = querySystemInfo(&sys_info); + + if(err < 0) goto error; + +// 获取系统模式,如CDMA/WCDMA/TD-SCDMA + switch(sys_info.sys_mode) + { + case 2: network_type = RADIO_TECHNOLOGY_1xRTT; break; // CDMA + case 3: network_type = RADIO_TECHNOLOGY_GPRS; break; // GSM/GPRS + case 4: // HDR + case 8: // CDMA/HDR HYBRID + network_type = RADIO_TECHNOLOGY_EVDO_A; + break; + case 5: // WCDMA + case 15: // TD-SCDMA + network_type = RADIO_TECHNOLOGY_UMTS; + break; + case 0: default: network_type = RADIO_TECHNOLOGY_UNKNOWN; break; // Unknown + } + LOGD("[%s]: sys_info.sys_submode: %d", __FUNCTION__, sys_info.sys_submode); + +// 获取系统子模式,如GPRS/HUDPA/HSPA等 + if(sys_info.sys_submode > 0) + {// 有sys_submode ,则使用它来确定网络类型 + LOGD("[%s]: sys_info.sys_submode: %d", __FUNCTION__, sys_info.sys_submode); + switch(sys_info.sys_submode) + { + case 1: case 2: network_type = RADIO_TECHNOLOGY_GPRS; break; // GSM/GPRS + case 3: network_type = RADIO_TECHNOLOGY_EDGE; break; // EDGE + case 4: // WCDMA + case 8: // TD-SCDMA + network_type = RADIO_TECHNOLOGY_UMTS; + break; + case 5: network_type = RADIO_TECHNOLOGY_HSDPA; break; // HSDPA + case 6: network_type = RADIO_TECHNOLOGY_HSUPA; break; // HSUPA + case 7: network_type = RADIO_TECHNOLOGY_HSPA; break; // HSPA + case 9: network_type = RADIO_TECHNOLOGY_HSPAP; break;//HSPA+ + case 11:network_type = RADIO_TECHNOLOGY_HSPA;break; + case 13:network_type = RADIO_TECHNOLOGY_EHRPD; break;//HDR HYBRID + default: network_type = RADIO_TECHNOLOGY_UNKNOWN; break; // Unknown + } + } + + LOGD("[%s]: network type: %d", __FUNCTION__, network_type); + return network_type; + +error: + LOGD("[%s]: err=%d", __FUNCTION__, err); + return RADIO_TECHNOLOGY_UNKNOWN; +} + +/* + 当前系统服务域 + 返回值: 成功: >=0, 失败: -1 + */ +int getRestrictedState_cnm() +{ + int err; + int new_restricted_state; + AT_SYSTEM_INFO sys_info; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + err = querySystemInfo(&sys_info); + + if(err < 0) goto error; + +// if(sys_info.srv_status)// 服务有效 +// { + switch(sys_info.srv_domain){ + case 1: + new_restricted_state = RIL_RESTRICTED_STATE_PS_ALL; + break; + case 2: + new_restricted_state = RIL_RESTRICTED_STATE_CS_ALL; + break; + case 3: + case 255: // CDMA not support + new_restricted_state = RIL_RESTRICTED_STATE_NONE; + break; + case 0: default: + new_restricted_state = RIL_RESTRICTED_STATE_CS_ALL|RIL_RESTRICTED_STATE_PS_ALL; + break; + } +// } + + return new_restricted_state; + +error: + LOGD("[%s]: err=%d", __FUNCTION__, err); + return -1; +} + + +// for china telecom +int getPreferredNetworkType_cnt() +{ + int err; + ATResponse *p_response = NULL; + int response = 0; + char *line; + int mode; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + err = at_send_command_singleline("AT^PREFMODE?", "^PREFMODE:", &p_response); + + if (err < 0 || p_response->success == 0) goto error; + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + + if (err < 0) goto error; + + err = at_tok_nextint(&line, &mode); + if(err < 0) goto error; + switch(mode) + { + case 2: response = NETWORK_MODE_CDMA_NO_EVDO; break; + case 4: response = NETWORK_MODE_EVDO_NO_CDMA; break; + case 8: response = NETWORK_MODE_CDMA; break; + default: goto error; break; + } + + LOGD("[%s]: return network mode=%d", __FUNCTION__, response); + + at_response_free(p_response); + return response; + +error: + at_response_free(p_response); + LOGE("ERROR: [%s ]failed\n", __FUNCTION__); + return -1; +} + +int setPreferredNetworkType_cnt(int rat) +{ + int err; + ATResponse *p_response = NULL; + char * cmd = NULL; + int mode; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + switch(rat) + { + case NETWORK_MODE_CDMA_NO_EVDO: mode = 2; break; + case NETWORK_MODE_EVDO_NO_CDMA: mode = 4; break; + case NETWORK_MODE_CDMA: case NETWORK_MODE_GLOBAL: mode = 8; break; + default: goto error_mode; + } + + asprintf(&cmd, "AT^PREFMODE=%d", mode); + err = at_send_command(cmd, &p_response); + free(cmd); + + if (err < 0|| p_response->success == 0) goto error; + + at_response_free(p_response); + return 0; +error_mode: + at_response_free(p_response); + return -1; +error: + at_response_free(p_response); + return -2; +} + +// for ZTE +int getPreferredNetworkType_zte() +{ + int err; + ATResponse *p_response = NULL; + int response = 0; + char *line; + int mode, acqorder, roam, srvdomain; + int skip; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + err = at_send_command_singleline("AT+ZSNT?", "+ZSNT:", &p_response); + + if (err < 0 || p_response->success == 0) goto error; + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + + if (err < 0) goto error; + + err = at_tok_nextint(&line, &mode); + if(err < 0) goto error; + err = at_tok_nextint(&line, &skip); + if(err < 0) goto error; + err = at_tok_nextint(&line, &acqorder); + if(err < 0) goto error; + + switch(mode) + { + case 0: + { + switch(acqorder) + { + case 0: response = NETWORK_MODE_GLOBAL; break; // 自动选择 + case 1: response = NETWORK_MODE_GSM_UMTS; break; // GSM PREF + case 2: default: response = NETWORK_MODE_WCDMA_PREF; break; // UTRAN PREF + } + } + break; + case 1:response = NETWORK_MODE_GSM_ONLY; break; // GSM ONLY + case 2:response = NETWORK_MODE_WCDMA_ONLY; break; // WCDMA/TD-SCDMA ONLY + default:goto error;break; // 错误的值 + } + + LOGD("[%s]: return network mode=%d", __FUNCTION__, response); + + at_response_free(p_response); + + return response; + +error: + at_response_free(p_response); + LOGE("ERROR: [%s ]failed\n", __FUNCTION__); + + return -1; +} + +int setPreferredNetworkType_zte(int rat) +{ + int err; + ATResponse *p_response = NULL; + char * cmd = NULL; + int mode, acqorder; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + int cur_type = getPreferredNetworkType_zte(); + + LOGD("[%s]: new preferred network type is: %d", __FUNCTION__, rat); + LOGD("[%s]: current preferred network type is: %d", __FUNCTION__, cur_type); + + if(cur_type == rat) return 0; + + switch(rat) + { + case NETWORK_MODE_WCDMA_PREF: mode = 2; acqorder = 0; break; + case NETWORK_MODE_GSM_ONLY: mode = 1; acqorder = 0; break; + case NETWORK_MODE_WCDMA_ONLY: mode = 2; acqorder = 2; break; + case NETWORK_MODE_GSM_UMTS: mode = 0; acqorder = 1; break; + case NETWORK_MODE_GLOBAL: mode = 0; acqorder = 0; break; + default: goto error_mode; + } + + /* Need to unregister from NW before changing preferred RAT */ +// err = at_send_command("AT+COPS=2", NULL); +// if (err < 0) goto error; + + asprintf(&cmd, "AT+ZSNT=%d,%d,%d", mode, 0, acqorder); + err = at_send_command(cmd, &p_response); + free(cmd); + if (err < 0|| p_response->success == 0) goto error; + + /* Register on the NW again */ +// err = at_send_command("AT+COPS=0", NULL); +// if (err < 0) goto error; + + at_response_free(p_response); + return 0; +error_mode: + at_response_free(p_response); + return -1; +error: + at_response_free(p_response); + return -2; +} + +int getNetworkType_zte() +{ + int network_type = RADIO_TECHNOLOGY_UNKNOWN; + + int err; + char network[32]; + char srv_domain_str[32]; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + err = checkCardStatus_zte(network, srv_domain_str); + if(err) goto error; + + if( !strcmp(network, "EDGE") ) + network_type = RADIO_TECHNOLOGY_EDGE; + else if( !strcmp(network, "GPRS") ) + network_type = RADIO_TECHNOLOGY_GPRS; + else if( !strcmp(network, "GSM") ) + network_type = RADIO_TECHNOLOGY_GPRS; + else if( !strcmp(network,"3G")) + network_type = RADIO_TECHNOLOGY_UMTS; + else if( !strcmp(network, "HSDPA") ) + network_type = RADIO_TECHNOLOGY_HSDPA; + else if( !strcmp(network, "HSUPA") ) + network_type = RADIO_TECHNOLOGY_HSUPA; + else if( !strcmp(network, "HSPA") ) + network_type = RADIO_TECHNOLOGY_HSPA; + else if( !strcmp(network, "UMTS") ) + network_type = RADIO_TECHNOLOGY_UMTS; + else if(!strcmp(network, "HSPA+")) + network_type=RADIO_TECHNOLOGY_HSPAP; + else if( !strcmp(network, "LTE") ) + network_type = RADIO_TECHNOLOGY_LTE; + else // "No Service"、"Limited Service"、other + network_type = RADIO_TECHNOLOGY_UNKNOWN; + + LOGD("[%s]: network type: %d", __FUNCTION__, network_type); + return network_type; + +error: + LOGD("[%s]: err=%d", __FUNCTION__, err); + return RADIO_TECHNOLOGY_UNKNOWN; +} + +int getRestrictedState_zte() +{ + int err; + int new_restricted_state; + char network[32]; + char srv_domain_str[32]; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + err = checkCardStatus_zte(network, srv_domain_str); + if(err < 0) goto error; + + if( !strcmp(srv_domain_str, "CS_ONLY") ) + new_restricted_state = RIL_RESTRICTED_STATE_PS_ALL; + else if( !strcmp(srv_domain_str, "PS_ONLY") ) + new_restricted_state = RIL_RESTRICTED_STATE_CS_ALL; + else if( !strcmp(srv_domain_str, "CS_PS") ) + new_restricted_state = RIL_RESTRICTED_STATE_NONE; + else + new_restricted_state = RIL_RESTRICTED_STATE_CS_ALL|RIL_RESTRICTED_STATE_PS_ALL; + + return new_restricted_state; + +error: + LOGD("[%s]: err=%d", __FUNCTION__, err); + return -1; +} + + +// for ZTE AD3812 +int getPreferredNetworkType_zte_ad3812() +{ + int err; + ATResponse *p_response = NULL; + int response = 0; + char *line; + int mode; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + err = at_send_command_singleline("AT+ZMDS?", "+ZMDS:", &p_response); + + if (err < 0 || p_response->success == 0) goto error; + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + + if (err < 0) goto error; + + err = at_tok_nextint(&line, &mode); + if(err < 0) goto error; + + switch(mode) + { + case 4:response = NETWORK_MODE_GLOBAL; break; // 自动选择 + case 13:response = NETWORK_MODE_GSM_ONLY; break; // GSM ONLY + case 14:response = NETWORK_MODE_WCDMA_ONLY; break; // WCDMA/TD-SCDMA ONLY + default:goto error;break; // 错误的值 + } + + LOGD("[%s]: return network mode=%d", __FUNCTION__, response); + + at_response_free(p_response); + + return response; + +error: + at_response_free(p_response); + LOGE("ERROR: [%s ]failed\n", __FUNCTION__); + + return -1; +} + +//lintao +int setPreferredNetworkType_zte_ad3812(int rat) +{ + int err; + ATResponse *p_response = NULL; + char * cmd = NULL; + int mode, acqorder; + int cur_type; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + cur_type = getPreferredNetworkType_zte_ad3812(); + + LOGD("[%s]: new preferred network type is: %d", __FUNCTION__, rat); + LOGD("[%s]: current preferred network type is: %d", __FUNCTION__, cur_type); + + if(cur_type == rat) return 0; + + switch(rat) + { + case NETWORK_MODE_WCDMA_PREF:case NETWORK_MODE_GSM_UMTS:case NETWORK_MODE_GLOBAL: + mode = 4; break; + case NETWORK_MODE_GSM_ONLY: mode = 13; break; + case NETWORK_MODE_WCDMA_ONLY: mode = 14; break; + default: goto error_mode; + } + + asprintf(&cmd, "AT+ZMDS=%d", mode); + err = at_send_command(cmd, &p_response); + free(cmd); + if (err < 0|| p_response->success == 0) goto error; + + at_response_free(p_response); + return 0; +error_mode: + at_response_free(p_response); + return -1; +error: + at_response_free(p_response); + return -2; +} + +int getNetworkType_generic() +{ +/* 通常,接入技术是由CREG/CGREG命令返回,如果那两个命令没有返回, + 则在这里可通过COPS查询 +*/ + int network_type; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + queryOperator(&network_type, NULL); + + LOGD("[%s]: network type: %d", __FUNCTION__, network_type); + return network_type; +} + +int getRestrictedState_generic() +{ + int restricted; + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + queryOperator(NULL, &restricted); + + LOGD("[%s]: restricted state: %d", __FUNCTION__, restricted); + return restricted; +} + +int getPreferredNetworkType_generic() +{// 标准指令集中并没有指令实现该功能 + LOGD("[%s]: === ENTER ===", __FUNCTION__); + return NETWORK_MODE_WCDMA_PREF; +} + +int setPreferredNetworkType_generic(int rat) +{ + int cur_type; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + cur_type = getPreferredNetworkType_generic(); + + LOGD("[%s]: new preferred network type is: %d", __FUNCTION__, rat); + LOGD("[%s]: current preferred network type is: %d", __FUNCTION__, cur_type); + + if(cur_type == rat) return 0; + +// 标准指令集中并没有指令实现该功能 + return -2; +} + +int getNetworkType_lc6341() +{// 该函数可用于 China Mobile, China Telecom, China Unicom +#if 1 + int network_type = RADIO_TECHNOLOGY_UNKNOWN; + + int err; + ATResponse *p_response = NULL; + int response[2]; + char *line, *p; + int commas; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + err = at_send_command_singleline("AT+CSQ", "+CSQ:", &p_response); + + if (err < 0 || p_response->success == 0) { + goto error; + } + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &(response[0])); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &(response[1])); + if (err < 0) goto error; + + at_response_free(p_response); + + if(response[0] <99) + { + network_type = RADIO_TECHNOLOGY_GPRS; + }else if(response[0]>100) + { + network_type = RADIO_TECHNOLOGY_UMTS; + } + + LOGD("[%s]: network type: %d", __FUNCTION__, network_type); + return network_type; + +error: + LOGD("[%s]: err=%d", __FUNCTION__, err); + at_response_free(p_response); + return RADIO_TECHNOLOGY_UNKNOWN; + +#else + return RADIO_TECHNOLOGY_UMTS; +#endif +} + +int getRestrictedState_lc6341() +{ + int err; + int new_restricted_state; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + new_restricted_state = RIL_RESTRICTED_STATE_NONE; + + return new_restricted_state; + +error: + LOGD("[%s]: err=%d", __FUNCTION__, err); + return -1; +} + +// for ARCHOS G9 +int getPreferredNetworkType_archos_g9() +{ + int err; + ATResponse *p_response = NULL; + int response = 0; + char *line; + int mode, order, roam, srvdomain; + int skip; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + err = at_send_command_singleline("AT+SYSSEL?", "+SYSSEL:", &p_response); + + if (err < 0 || p_response->success == 0) goto error; + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + + if (err < 0) goto error; + + err = at_tok_nextint(&line, &skip); + if(err < 0) goto error; + err = at_tok_nextint(&line, &mode); + if(err < 0) goto error; + err = at_tok_nextint(&line, &order); + if(err < 0) goto error; + + switch(mode) + { + case 0:// 自动选择 + switch(order) + { + case 0: response = NETWORK_MODE_GLOBAL; break; // 自动选择 + case 2: response = NETWORK_MODE_GSM_UMTS; break; // GSM PREF + case 1: default: response = NETWORK_MODE_WCDMA_PREF; break; // UTRAN PREF + } + break; + case 1: response = NETWORK_MODE_GSM_ONLY; break; // GSM ONLY + case 2: response = NETWORK_MODE_WCDMA_ONLY; break; // WCDMA/TD-SCDMA ONLY + default: goto error; break; // ERROR + } + + LOGD("[%s]: return network mode=%d", __FUNCTION__, response); + + at_response_free(p_response); + + return response; + +error: + at_response_free(p_response); + LOGE("ERROR: [%s ]failed\n", __FUNCTION__); + + return -1; +} + +int setPreferredNetworkType_archos_g9(int rat) +{ + int err; + ATResponse *p_response = NULL; + char * cmd = NULL; + int mode, acqorder; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + int cur_type = getPreferredNetworkType_archos_g9(); + + LOGD("[%s]: preferred network type %d -> %d", __FUNCTION__, cur_type, rat); + + if(cur_type == rat) return 0; + + switch(rat) + { + case NETWORK_MODE_WCDMA_PREF: mode = 0; acqorder = 1; break; + case NETWORK_MODE_GSM_ONLY: mode = 1; acqorder = -1; break; + case NETWORK_MODE_WCDMA_ONLY: mode=2; acqorder = -1; break; + case NETWORK_MODE_GSM_UMTS: mode = 0; acqorder = 2; break; + case NETWORK_MODE_GLOBAL: mode = 0; acqorder = 0; break; + default: goto error_mode; + } + +#if 0 + /* Need to unregister from NW before changing preferred RAT */ + err = at_send_command("AT+COPS=2", NULL); + if (err < 0) goto error; +#endif + + if(acqorder >= 0) + asprintf(&cmd, "AT+SYSSEL=,%d,%d,", mode, acqorder); + else + asprintf(&cmd, "AT+SYSSEL=,%d,,", mode); + err = at_send_command(cmd, &p_response); + free(cmd); + if (err < 0|| p_response->success == 0) goto error; + +#if 0 + /* Register on the NW again */ + err = at_send_command("AT+COPS=0", NULL); + if (err < 0) goto error; +#endif + + at_response_free(p_response); + return 0; +error_mode: + at_response_free(p_response); + return -1; +error: + at_response_free(p_response); + return -2; +} + + + +int getPreferredNetworkType_SCV_SPW9P() +{ + + int err; + ATResponse *p_response = NULL; + int response = 0; + char *line; + int mode; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + err = at_send_command_singleline("AT+ZMDS?", "+ZMDS:", &p_response); + + if (err < 0 || p_response->success == 0) goto error; + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + + if (err < 0) goto error; + + err = at_tok_nextint(&line, &mode); + if(err < 0) goto error; + + switch(mode) + { + case 4:response = NETWORK_MODE_GLOBAL; break; // 自动选择 + + case 13:response = NETWORK_MODE_GSM_ONLY; break; // GSM ONLY + + case 14:response = NETWORK_MODE_WCDMA_ONLY; break; // WCDMA/TD-SCDMA ONLY + + default:goto error;break; + } + + LOGD("[%s]: return network mode=%d", __FUNCTION__, response); + + at_response_free(p_response); + + return response; + +error: + at_response_free(p_response); + LOGE("ERROR: [%s ]failed\n", __FUNCTION__); + + return -1; + + + + +} + + +int setPreferredNetworkType_SCV_SPW9P(int rat) +{ + +int err; + ATResponse *p_response = NULL; + char * cmd = NULL; + int mode, acqorder; + int cur_type; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + + cur_type = getPreferredNetworkType_SCV_SPW9P(); + + LOGD("[%s]: new preferred network type is: %d", __FUNCTION__, rat); + LOGD("[%s]: current preferred network type is: %d", __FUNCTION__, cur_type); + + if(cur_type == rat) return 0; + + switch(rat) + { + case NETWORK_MODE_WCDMA_PREF:case NETWORK_MODE_GSM_UMTS:case NETWORK_MODE_GLOBAL: + mode = 4; break; + case NETWORK_MODE_GSM_ONLY: mode = 13; break; + case NETWORK_MODE_WCDMA_ONLY: mode = 14; break; + default: goto error_mode; + } + + asprintf(&cmd, "AT+ZMDS=%d", mode); + err = at_send_command(cmd, &p_response); + free(cmd); + if (err < 0|| p_response->success == 0) goto error; + + at_response_free(p_response); + return 0; +error_mode: + at_response_free(p_response); + return -1; +error: + at_response_free(p_response); + return -2; + + + + +} + +int getQualmNetworkType() +{ + int err; + ATResponse *p_response = NULL; + int response = 0; + char *line; + int networkType; + + LOGD("[%s]: === ENTER ===", __FUNCTION__); + //+NETMODE: 8,5,0,0,0,1,2,1,0,0,5 + + err = at_send_command_singleline("AT+NETMODE?", "+NETMODE:", &p_response); + + if (err < 0 || p_response->success == 0) goto error; + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + + if (err < 0) goto error; + + err = at_tok_nextint(&line, &networkType); + + switch(networkType) + { + case 0:response=RADIO_TECHNOLOGY_UNKNOWN;break; + case 1: response = RADIO_TECHNOLOGY_GPRS; break; + case 2: response = RADIO_TECHNOLOGY_EDGE; break; + case 3: response = RADIO_TECHNOLOGY_UMTS; break; + case 5: response = RADIO_TECHNOLOGY_EVDO_0; break; + case 6: response = RADIO_TECHNOLOGY_EVDO_A; break; + case 7: response = RADIO_TECHNOLOGY_1xRTT; break; + case 8: response = RADIO_TECHNOLOGY_HSDPA; break; + case 9: response = RADIO_TECHNOLOGY_HSUPA; break; + case 10: response = RADIO_TECHNOLOGY_HSPA; break; + + default: goto error; break; // ERROR + } + + LOGD("[%s]: return network type=%d", __FUNCTION__, response); + + at_response_free(p_response); + + return response; + +error: + at_response_free(p_response); + LOGE("ERROR: [%s ]failed\n", __FUNCTION__); + + return -1; +} + + + diff --git a/hardware/ril/reference-ril/extend_at_func.h b/hardware/ril/reference-ril/extend_at_func.h new file mode 100644 index 0000000000..08458faa0e --- /dev/null +++ b/hardware/ril/reference-ril/extend_at_func.h @@ -0,0 +1,96 @@ +/* + 一个模块,其所用AT指令集大致如此组成: 标准AT命令 + 扩展AT命令 + 标准AT命令大家都一样,但扩展AT命令可能不同,目前所知道的情况如下: + 中兴部分模块使用其自定义的扩展AT命令 + 中国移动、中国联通在GSM模块方面所用的扩展AT命令相同 + 中国电信在CDMA模块方面也有自己扩展AT命令 + + 注: 目前没有调过国外的模块,他们所用AT扩展指令集是如何的就不得而知了 + + cmy: 需要使用扩展AT命令实现的功能,将其集中在该文件中 + */ + +typedef enum { + NETWORK_MODE_WCDMA_PREF = 0, /* GSM/UMTS (UMTS preferred) */ + NETWORK_MODE_GSM_ONLY, /* GSM only */ + NETWORK_MODE_WCDMA_ONLY, /* UMTS only */ + NETWORK_MODE_GSM_UMTS, /* cmy: 用该值表示GSM preferred. GSM/WCDMA/TD-SCDMA (auto mode, according to PRL) */ + NETWORK_MODE_CDMA, /* CDMA and EvDo (auto mode, according to PRL) */ + NETWORK_MODE_CDMA_NO_EVDO, /* CDMA only */ + NETWORK_MODE_EVDO_NO_CDMA, /* EvDo only */ + NETWORK_MODE_GLOBAL, /* cmy: 用该值表示自动选择 GSM/WCDMA/TD-SCDMA, CDMA, and EvDo (auto mode, according to PRL) */ +} RIL_NetworkMode; + + +typedef struct{ + int srv_status; + int srv_domain; + int roam_status; + int sys_mode; + int sim_state; + int reserve; + int sys_submode; +}AT_SYSTEM_INFO; + +#if (RIL_VERSION >= 6) +typedef enum { + RADIO_TECHNOLOGY_UNKNOWN = 0, + RADIO_TECHNOLOGY_GPRS, + RADIO_TECHNOLOGY_EDGE, + RADIO_TECHNOLOGY_UMTS, +// CDMA95A/B + RADIO_TECHNOLOGY_IS95A, + RADIO_TECHNOLOGY_IS95B, +// CDMA2000 1x RTT + RADIO_TECHNOLOGY_1xRTT, +// CDMA2000 1x EVDO + RADIO_TECHNOLOGY_EVDO_0, + RADIO_TECHNOLOGY_EVDO_A, +// + RADIO_TECHNOLOGY_HSDPA, + RADIO_TECHNOLOGY_HSUPA, + RADIO_TECHNOLOGY_HSPA, + + RADIO_TECHNOLOGY_EVDO_B, + RADIO_TECHNOLOGY_EHRPD, + RADIO_TECHNOLOGY_LTE, + RADIO_TECHNOLOGY_HSPAP, // HSPA+ + + RADIO_TECHNOLOGY_TDSCDMA, +} RIL_NetworkType; +#endif + +int getPreferredNetworkType_cnm(); +int setPreferredNetworkType_cnm(int rat); +int getNetworkType_cnm(); +int getRestrictedState_cnm(); + +int getPreferredNetworkType_cnt(); +int setPreferredNetworkType_cnt(int rat); + +int getPreferredNetworkType_zte(); +int setPreferredNetworkType_zte(int rat); +int getNetworkType_zte(); +int getRestrictedState_zte(); + +int getPreferredNetworkType_zte_ad3812(); +int setPreferredNetworkType_zte_ad3812(int rat); + +int getPreferredNetworkType_generic(); +int setPreferredNetworkType_generic(int rat); +int getRestrictedState_generic(); +int getNetworkType_generic(); + +int getNetworkType_lc6341(); +int getRestrictedState_lc6341(); + +int getPreferredNetworkType_archos_g9(); +int setPreferredNetworkType_archos_g9(int rat); + +int getQualmNetworkType(); + + +int getPreferredNetworkType_SCV_SPW9P(); +int setPreferredNetworkType_SCV_SPW9P(int rat); + +int networkType2RAT(int net); diff --git a/hardware/ril/reference-ril/gsm.c b/hardware/ril/reference-ril/gsm.c new file mode 100644 index 0000000000..6bc1e27a28 --- /dev/null +++ b/hardware/ril/reference-ril/gsm.c @@ -0,0 +1,1165 @@ +#include "gsm.h" +#include + +/** UTILITIES + **/ +byte_t +gsm_int_to_bcdi( int value ) +{ + return (byte_t)((value / 10) | ((value % 10) << 4)); +} + +int +gsm_int_from_bcdi( byte_t val ) +{ + int ret = 0; + + if ((val & 0xf0) <= 0x90) + ret = (val >> 4); + + if ((val & 0x0f) <= 0x90) + ret |= (val % 0xf)*10; + + return ret; +} + + +static int +gsm_bcdi_to_ascii( cbytes_t bcd, int bcdlen, bytes_t dst ) +{ + static byte_t bcdichars[14] = "0123456789*#,N"; + + int result = 0; + int shift = 0; + + while (bcdlen > 0) { + int c = (bcd[0] >> shift) & 0xf; + + if (c == 0xf && bcdlen == 1) + break; + + if (c < 14) { + if (dst) dst[result] = bcdichars[c]; + result += 1; + } + bcdlen --; + shift += 4; + if (shift == 8) { + bcd++; + shift = 0; + } + } + return result; +} + + +static int +gsm_bcdi_from_ascii( cbytes_t ascii, int asciilen, bytes_t dst ) +{ + cbytes_t end = ascii + asciilen; + int result = 0; + int phase = 0x01; + + while (ascii < end) { + int c = *ascii++; + int d; + + if (c == '*') + c = 11; + else if (c == '#') + c = 12; + else if (c == ',') + c = 13; + else if (c == 'N') + c = 14; + else { + c -= '0'; + if ((unsigned)c >= 10) + break; + } + phase = (phase << 4) | c; + if (phase & 0x100) { + if (dst) dst[result] = (byte_t) phase; + result += 1; + phase = 0x01; + } + } + if (phase != 0x01) { + if (dst) dst[result] = (byte_t)( phase | 0xf0 ); + result += 1; + } + return result; +} + + +int +gsm_hexchar_to_int( char c ) +{ + if ((unsigned)(c - '0') < 10) + return c - '0'; + if ((unsigned)(c - 'a') < 6) + return 10 + (c - 'a'); + if ((unsigned)(c - 'A') < 6) + return 10 + (c - 'A'); + return -1; +} + +int +gsm_hexchar_to_int0( char c ) +{ + int ret = gsm_hexchar_to_int(c); + + return (ret < 0) ? 0 : ret; +} + +int +gsm_hex2_to_byte( const char* hex ) +{ + int hi = gsm_hexchar_to_int(hex[0]); + int lo = gsm_hexchar_to_int(hex[1]); + + if (hi < 0 || lo < 0) + return -1; + + return ( (hi << 4) | lo ); +} + +int +gsm_hex4_to_short( const char* hex ) +{ + int hi = gsm_hex2_to_byte(hex); + int lo = gsm_hex2_to_byte(hex+2); + + if (hi < 0 || lo < 0) + return -1; + + return ((hi << 8) | lo); +} + +int +gsm_hex2_to_byte0( const char* hex ) +{ + int hi = gsm_hexchar_to_int0(hex[0]); + int lo = gsm_hexchar_to_int0(hex[1]); + + return (byte_t)( (hi << 4) | lo ); +} + +void +gsm_hex_from_byte( char* hex, int val ) +{ + static const char hexdigits[] = "0123456789ABCDEF"; + + hex[0] = hexdigits[(val >> 4) & 15]; + hex[1] = hexdigits[val & 15]; +} + +void +gsm_hex_from_short( char* hex, int val ) +{ + gsm_hex_from_byte( hex, (val >> 8) ); + gsm_hex_from_byte( hex+2, val ); +} + + + +/** HEX + **/ +void +gsm_hex_to_bytes( cbytes_t hex, int hexlen, bytes_t dst ) +{ + int nn; + + for (nn = 0; nn < hexlen/2; nn++ ) { + dst[nn] = (byte_t) gsm_hex2_to_byte0( hex+2*nn ); + } + if (hexlen & 1) { + dst[nn] = gsm_hexchar_to_int0( hex[2*nn] ) << 4; + } +} + +void +gsm_hex_from_bytes( char* hex, cbytes_t src, int srclen ) +{ + int nn; + + for (nn = 0; nn < srclen; nn++) { + gsm_hex_from_byte( hex + 2*nn, src[nn] ); + } +} + +/** ROPES + **/ + +void +gsm_rope_init( GsmRope rope ) +{ + rope->data = NULL; + rope->pos = 0; + rope->max = 0; + rope->error = 0; +} + +void +gsm_rope_init_alloc( GsmRope rope, int count ) +{ + rope->data = rope->data0; + rope->pos = 0; + rope->max = sizeof(rope->data0); + rope->error = 0; + + if (count > 0) { + rope->data = calloc( count, 1 ); + rope->max = count; + + if (rope->data == NULL) { + rope->error = 1; + rope->max = 0; + } + } +} + +int +gsm_rope_done( GsmRope rope ) +{ + int result = rope->error; + + if (rope->data && rope->data != rope->data0) + free(rope->data); + + rope->data = NULL; + rope->pos = 0; + rope->max = 0; + rope->error = 0; + + return result; +} + + +bytes_t +gsm_rope_done_acquire( GsmRope rope, int *psize ) +{ + bytes_t result = rope->data; + + *psize = rope->pos; + if (result == rope->data0) { + result = malloc( rope->pos ); + if (result != NULL) + memcpy( result, rope->data, rope->pos ); + } + return result; +} + + +int +gsm_rope_ensure( GsmRope rope, int new_count ) +{ + if (rope->data != NULL) { + int old_max = rope->max; + bytes_t old_data = rope->data == rope->data0 ? NULL : rope->data; + int new_max = old_max; + bytes_t new_data; + + while (new_max < new_count) { + new_max += (new_max >> 1) + 4; + } + new_data = realloc( old_data, new_max ); + if (new_data == NULL) { + rope->error = 1; + return -1; + } + rope->data = new_data; + rope->max = new_max; + } else { + rope->max = new_count; + } + return 0; +} + +static int +gsm_rope_can_grow( GsmRope rope, int count ) +{ + if (!rope->data || rope->error) + return 0; + + if (rope->pos + count > rope->max) + { + if (rope->data == NULL) + rope->max = rope->pos + count; + + else if (rope->error || + gsm_rope_ensure( rope, rope->pos + count ) < 0) + return 0; + } + return 1; +} + +void +gsm_rope_add_c( GsmRope rope, char c ) +{ + if (gsm_rope_can_grow(rope, 1)) { + rope->data[ rope->pos ] = (byte_t) c; + } + rope->pos += 1; +} + +void +gsm_rope_add( GsmRope rope, const void* buf, int buflen ) +{ + if (gsm_rope_can_grow(rope, buflen)) { + memcpy( rope->data + rope->pos, (const char*)buf, buflen ); + } + rope->pos += buflen; +} + +void* +gsm_rope_reserve( GsmRope rope, int count ) +{ + void* result = NULL; + + if (gsm_rope_can_grow(rope, count)) + { + if (rope->data != NULL) + result = rope->data + rope->pos; + } + rope->pos += count; + + return result; +} + +/* skip a given number of Unicode characters in a utf-8 byte string */ +cbytes_t +utf8_skip( cbytes_t utf8, + cbytes_t utf8end, + int count) +{ + cbytes_t p = utf8; + cbytes_t end = utf8end; + + for ( ; count > 0; count-- ) { + int c; + + if (p > end) + break; + + c = *p++; + if (c > 128) { + while (p < end && (p[0] & 0xc0) == 0x80) + p++; + } + } + return p; +} + +static __inline__ int +utf8_next( cbytes_t *pp, cbytes_t end ) +{ + cbytes_t p = *pp; + int result = -1; + + if (p < end) { + int c= *p++; + if (c >= 128) { + if ((c & 0xe0) == 0xc0) + c &= 0x1f; + else if ((c & 0xf0) == 0xe0) + c &= 0x0f; + else + c &= 0x07; + + while (p < end && (p[0] & 0xc0) == 0x80) { + c = (c << 6) | (p[0] & 0x3f); + } + } + result = c; + *pp = p; + } +Exit: + return result; +} + + +__inline__ int +utf8_write( bytes_t utf8, int offset, int v ) +{ + int result; + + if (v < 128) { + result = 1; + if (utf8) + utf8[offset] = (byte_t) v; + } else if (v < 0x800) { + result = 2; + if (utf8) { + utf8[offset+0] = (byte_t)( 0xc0 | (v >> 6) ); + utf8[offset+1] = (byte_t)( 0x80 | (v & 0x3f) ); + } + } else if (v < 0x10000) { + result = 3; + if (utf8) { + utf8[offset+0] = (byte_t)( 0xe0 | (v >> 12) ); + utf8[offset+1] = (byte_t)( 0x80 | ((v >> 6) & 0x3f) ); + utf8[offset+2] = (byte_t)( 0x80 | (v & 0x3f) ); + } + } else { + result = 4; + if (utf8) { + utf8[offset+0] = (byte_t)( 0xf0 | ((v >> 18) & 0x7) ); + utf8[offset+1] = (byte_t)( 0x80 | ((v >> 12) & 0x3f) ); + utf8[offset+2] = (byte_t)( 0x80 | ((v >> 6) & 0x3f) ); + utf8[offset+3] = (byte_t)( 0x80 | (v & 0x3f) ); + } + } + return result; +} + +static __inline__ int +ucs2_write( bytes_t ucs2, int offset, int v ) +{ + if (ucs2) { + ucs2[offset+0] = (byte_t) (v >> 8); + ucs2[offset+1] = (byte_t) (v); + } + return 2; +} + +int +utf8_check( cbytes_t p, int utf8len ) +{ + cbytes_t end = p + utf8len; + int result = 0; + + if (p) { + while (p < end) { + int c = *p++; + if (c >= 128) { + int len; + if ((c & 0xe0) == 0xc0) { + len = 1; + } + else if ((c & 0xf0) == 0xe0) { + len = 2; + } + else if ((c & 0xf8) == 0xf0) { + len = 3; + } + else + goto Exit; /* malformed utf-8 */ + + if (p+len > end) /* string too short */ + goto Exit; + + for ( ; len > 0; len--, p++ ) { + if ((p[0] & 0xc0) != 0x80) + goto Exit; + } + } + } + result = 1; + } +Exit: + return result; +} + +/** UCS2 to UTF8 + **/ + +/* convert a UCS2 string into a UTF8 byte string, assumes 'buf' is correctly sized */ +int +ucs2_to_utf8( cbytes_t ucs2, + int ucs2len, + bytes_t buf ) +{ + int nn; + int result = 0; + + for (nn = 0; nn < ucs2len; ucs2 += 2, nn++) { + int c= (ucs2[0] << 8) | ucs2[1]; + result += utf8_write(buf, result, c); + } + return result; +} + +/* count the number of UCS2 chars contained in a utf8 byte string */ +int +utf8_to_ucs2( cbytes_t utf8, + int utf8len, + bytes_t ucs2 ) +{ + cbytes_t p = utf8; + cbytes_t end = p + utf8len; + int result = 0; + + while (p < end) { + int c = utf8_next(&p, end); + + if (c < 0) + break; + + result += ucs2_write(ucs2, result, c); + } + return result/2; +} + + + +/** GSM ALPHABET + **/ + +#define GSM_7BITS_ESCAPE 0x1b +#define GSM_7BITS_UNKNOWN 0 + +static const unsigned short gsm7bits_to_unicode[128] = { + '@', 0xa3, '$', 0xa5, 0xe8, 0xe9, 0xf9, 0xec, 0xf2, 0xc7, '\n', 0xd8, 0xf8, '\r', 0xc5, 0xe5, +0x394, '_',0x3a6,0x393,0x39b,0x3a9,0x3a0,0x3a8,0x3a3,0x398,0x39e, 0, 0xc6, 0xe6, 0xdf, 0xc9, + ' ', '!', '"', '#', 0xa4, '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', + 0xa1, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0xc4, 0xd6,0x147, 0xdc, 0xa7, + 0xbf, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0xe4, 0xf6, 0xf1, 0xfc, 0xe0, +}; + +static const unsigned short gsm7bits_extend_to_unicode[128] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'\f', 0, 0, 0, 0, 0, + 0, 0, 0, 0, '^', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, '{', '}', 0, 0, 0, 0, 0,'\\', + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '[', '~', ']', 0, + '|', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0,0x20ac, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + + +static int +unichar_to_gsm7( int unicode ) +{ + int nn; + for (nn = 0; nn < 128; nn++) { + if (gsm7bits_to_unicode[nn] == unicode) { + return nn; + } + } + return -1; +} + +static int +unichar_to_gsm7_extend( int unichar ) +{ + int nn; + for (nn = 0; nn < 128; nn++) { + if (gsm7bits_extend_to_unicode[nn] == unichar) { + return nn; + } + } + return -1; +} + + +/* return the number of septets needed to encode a unicode charcode */ +static int +unichar_to_gsm7_count( int unicode ) +{ + int nn; + + nn = unichar_to_gsm7(unicode); + if (nn >= 0) + return 1; + + nn = unichar_to_gsm7_extend(unicode); + if (nn >= 0) + return 2; + + return 0; +} + + +int +utf8_check_gsm7( cbytes_t utf8, + int utf8len ) +{ + cbytes_t utf8end = utf8 + utf8len; + + while (utf8 < utf8end) { + int c = utf8_next( &utf8, utf8end ); + if (unichar_to_gsm7_count(c) == 0) + return 0; + } + return 1; +} + + +int +utf8_from_gsm7( cbytes_t src, + int septet_offset, + int septet_count, + bytes_t utf8 ) +{ + int shift = (septet_offset & 7); + int escaped = 0; + int result = 0; + + src += (septet_offset >> 3); + for ( ; septet_count > 0; septet_count-- ) + { + int c = (src[0] >> shift) & 0x7f; + int v; + + if (shift > 1) { + c = ((src[1] << (8-shift)) | c) & 0x7f; + } + + if (escaped) { + v = gsm7bits_extend_to_unicode[c]; + } else if (c == GSM_7BITS_ESCAPE) { + escaped = 1; + goto NextSeptet; + } else { + v = gsm7bits_to_unicode[c]; + } + + result += utf8_write( utf8, result, v ); + + NextSeptet: + shift += 7; + if (shift >= 8) { + shift -= 8; + src += 1; + } + } + return result; +} + + +int +utf8_from_gsm8( cbytes_t src, int count, bytes_t utf8 ) +{ + int result = 0; + int escaped = 0; + + + for ( ; count > 0; count-- ) + { + int c = *src++; + int v; + + if (c == 0xff) + break; + + if (c == GSM_7BITS_ESCAPE) { + if (escaped) { /* two escape characters => one space */ + c = 0x20; + escaped = 0; + } else { + escaped = 1; + continue; + } + } + else + { + if (c >= 0x80) { + c = 0x20; + escaped = 0; + } else if (escaped) { + c = gsm7bits_extend_to_unicode[c]; + } else + c = gsm7bits_to_unicode[c]; + } + + result += utf8_write( utf8, result, c ); + } + return result; +} + +/* convert a GSM 7-bit message into a unicode character array + * the 'dst' array must contain at least 160 chars. the function + * returns the number of characters decoded + * + * assumes the 'dst' array has at least septet_count items, returns the + * number of unichars really written + */ +int +ucs2_from_gsm7( bytes_t ucs2, + cbytes_t src, + int septet_offset, + int septet_count ) +{ + const unsigned char* p = src + (septet_offset >> 3); + int shift = (septet_offset & 7); + int escaped = 0; + int result = 0; + + for ( ; septet_count > 0; septet_count-- ) + { + unsigned val = (p[0] >> shift) & 0x7f; + + if (shift > 1) + val = (val | (p[1] << (8-shift))) & 0x7f; + + if (escaped) { + int c = gsm7bits_to_unicode[val]; + + result += ucs2_write(ucs2, result, c); + escaped = 0; + } + else if (val == GSM_7BITS_ESCAPE) { + escaped = 1; + } + else { + val = gsm7bits_extend_to_unicode[val]; + if (val == 0) + val = 0x20; + + result += ucs2_write( ucs2, result, val ); + } + } + return result/2; +} + + +/* count the number of septets required to write a utf8 string */ +static int +utf8_to_gsm7_count( cbytes_t utf8, int utf8len ) +{ + cbytes_t utf8end = utf8 + utf8len; + int result = 0; + + while ( utf8 < utf8end ) { + int len; + int c = utf8_next( &utf8, utf8end ); + + if (c < 0) + break; + + len = unichar_to_gsm7_count(c); + if (len == 0) /* replace non-representables with space */ + len = 1; + + result += len; + } + return result; +} + +typedef struct { + bytes_t dst; + unsigned pad; + int bits; + int offset; +} BWriterRec, *BWriter; + +static void +bwriter_init( BWriter writer, bytes_t dst, int start ) +{ + int shift = start & 7; + + writer->dst = dst + (start >> 3); + writer->pad = 0; + writer->bits = shift; + writer->offset = start; + + if (shift > 0) { + writer->pad = writer->dst[0] & ~(0xFF << shift); + } +} + +static void +bwriter_add7( BWriter writer, unsigned value ) +{ + writer->pad |= (unsigned)(value << writer->bits); + writer->bits += 7; + if (writer->bits >= 8) { + writer->dst[0] = (byte_t)writer->pad; + writer->bits -= 8; + writer->pad >>= 8; + writer->dst += 1; + } + writer->offset += 7; +} + +static int +bwriter_done( BWriter writer ) +{ + if (writer->bits > 0) { + writer->dst[0] = (byte_t)writer->pad; + writer->pad = 0; + writer->bits = 0; + writer->dst += 1; + } + return writer->offset; +} + +/* convert a utf8 string to a gsm7 byte string - return the number of septets written */ +int +utf8_to_gsm7( cbytes_t utf8, int utf8len, bytes_t dst, int offset ) +{ + const unsigned char* utf8end = utf8 + utf8len; + BWriterRec writer[1]; + + if (dst == NULL) + return utf8_to_gsm7_count(utf8, utf8len); + + bwriter_init( writer, dst, offset ); + while ( utf8 < utf8end ) { + int c = utf8_next( &utf8, utf8end ); + int nn; + + if (c < 0) + break; + + nn = unichar_to_gsm7(c); + if (nn >= 0) { + bwriter_add7( writer, nn ); + continue; + } + + nn = unichar_to_gsm7_extend(c); + if (nn >= 0) { + bwriter_add7( writer, GSM_7BITS_ESCAPE ); + bwriter_add7( writer, nn ); + continue; + } + + /* unknown => replaced by space */ + bwriter_add7( writer, 0x20 ); + } + return bwriter_done( writer ); +} + + +int +utf8_to_gsm8( cbytes_t utf8, int utf8len, bytes_t dst ) +{ + const unsigned char* utf8end = utf8 + utf8len; + int result = 0; + + while ( utf8 < utf8end ) { + int c = utf8_next( &utf8, utf8end ); + int nn; + + if (c < 0) + break; + + nn = unichar_to_gsm7(c); + if (nn >= 0) { + if (dst) + dst[result] = (byte_t)nn; + result += 1; + continue; + } + + nn = unichar_to_gsm7_extend(c); + if (nn >= 0) { + if (dst) { + dst[result+0] = (byte_t) GSM_7BITS_ESCAPE; + dst[result+1] = (byte_t) nn; + } + result += 2; + continue; + } + + /* unknown => space */ + if (dst) + dst[result] = 0x20; + result += 1; + } + return result; +} + + +int +ucs2_to_gsm7( cbytes_t ucs2, int ucs2len, bytes_t dst, int offset ) +{ + const unsigned char* ucs2end = ucs2 + ucs2len*2; + BWriterRec writer[1]; + + bwriter_init( writer, dst, offset ); + while ( ucs2 < ucs2end ) { + int c = *ucs2++; + int nn; + + for (nn = 0; nn < 128; nn++) { + if ( gsm7bits_to_unicode[nn] == c ) { + bwriter_add7( writer, nn ); + goto NextUnicode; + } + } + for (nn = 0; nn < 128; nn++) { + if ( gsm7bits_extend_to_unicode[nn] == c ) { + bwriter_add7( writer, GSM_7BITS_ESCAPE ); + bwriter_add7( writer, nn ); + goto NextUnicode; + } + } + + /* unknown */ + bwriter_add7( writer, 0x20 ); + + NextUnicode: + ; + } + return bwriter_done( writer ); +} + + +int +ucs2_to_gsm8( cbytes_t ucs2, int ucs2len, bytes_t dst ) +{ + const unsigned char* ucs2end = ucs2 + ucs2len*2; + bytes_t dst0 = dst; + + while ( ucs2 < ucs2end ) { + int c = *ucs2++; + int nn; + + for (nn = 0; nn < 128; nn++) { + if ( gsm7bits_to_unicode[nn] == c ) { + *dst++ = (byte_t)nn; + goto NextUnicode; + } + } + for (nn = 0; nn < 128; nn++) { + if ( gsm7bits_extend_to_unicode[nn] == c ) { + dst[0] = (byte_t) GSM_7BITS_ESCAPE; + dst[1] = (byte_t) nn; + dst += 2; + goto NextUnicode; + } + } + + /* unknown */ + *dst++ = 0x20; + + NextUnicode: + ; + } + return (dst - dst0); +} + +int +gsm_bcdnum_to_ascii( cbytes_t bcd, int count, bytes_t dst ) +{ + int result = 0; + int shift = 0; + + while (count > 0) { + int c = (bcd[0] >> shift) & 0xf; + + if (c == 15 && count == 1) /* ignore trailing 0xf */ + break; + + if (c >= 14) + c = 0; + + if (dst) dst[result] = "0123456789*#,N"[c]; + result += 1; + + shift += 4; + if (shift == 8) { + shift = 0; + bcd += 1; + } + } + return result; +} + + +int +gsm_bcdnum_from_ascii( cbytes_t ascii, int asciilen, bytes_t dst ) +{ + cbytes_t end = ascii + asciilen; + int result = 0; + int phase = 0x01; + + while (ascii < end) { + int c = *ascii++; + + if (c == '*') + c = 10; + else if (c == '#') + c = 11; + else if (c == ',') + c = 12; + else if (c == 'N') + c = 13; + else { + c -= '0'; + if ((unsigned)c >= 10U) + return -1; + } + phase = (phase << 4) | c; + result += 1; + if (phase & 0x100) { + if (dst) dst[result/2] = (byte_t) phase; + phase = 0x01; + } + } + + if (result & 1) { + if (dst) dst[result/2] = (byte_t)(phase | 0xf0); + } + return result; +} + +/** ADN: Abbreviated Dialing Number + **/ + +#define ADN_FOOTER_SIZE 14 +#define ADN_OFFSET_NUMBER_LENGTH 0 +#define ADN_OFFSET_TON_NPI 1 +#define ADN_OFFSET_NUMBER_START 2 +#define ADN_OFFSET_NUMBER_END 11 +#define ADN_OFFSET_CAPABILITY_ID 12 +#define ADN_OFFSET_EXTENSION_ID 13 + +/* see 10.5.1 of 3GPP 51.011 */ +static int +sim_adn_alpha_to_utf8( cbytes_t alpha, cbytes_t end, bytes_t dst ) +{ + int result = 0; + int c, is_ucs2 = 0; + + /* ignore trailing 0xff */ + while (alpha < end && end[-1] == 0xff) + end--; + + if (alpha >= end) + return 0; + + if (alpha[0] == 0x80) { /* UCS/2 source encoding */ + int count, len; + + alpha += 1; + result = ucs2_to_utf8( alpha, (end-alpha)/2, dst ); + } + else + { + int is_ucs2 = 0; + int len = 0, base = 0; + + if (alpha+3 <= end && alpha[0] == 0x81) { + is_ucs2 = 1; + len = alpha[1]; + base = alpha[2] << 7; + alpha += 3; + if (len > end-alpha) + len = end-alpha; + } else if (alpha+4 <= end && alpha[0] == 0x82) { + is_ucs2 = 1; + len = alpha[1]; + base = (alpha[2] << 8) | alpha[3]; + alpha += 4; + if (len > end-alpha) + len = end-alpha; + } + + if (is_ucs2) { + end = alpha + len; + while (alpha < end) { + int c = alpha[0]; + if (c >= 0x80) { + result += utf8_write(dst, result, base + (c & 0x7f)); + alpha += 1; + } else { + /* GSM character set */ + int count; + for (count = 0; alpha+count < end && alpha[count] < 128; count++) + ; + result += utf8_from_gsm8(alpha, count, (dst ? dst+result : NULL)); + alpha += count; + } + } + } + else { + result = utf8_from_gsm8(alpha, end-alpha, dst); + } + } + return result; +} + +static int +sim_adn_alpha_from_utf8( cbytes_t utf8, int utf8len, bytes_t dst ) +{ + int result = 0; + + if (utf8_check_gsm7(utf8, utf8len)) { + /* GSM 7-bit compatible, encode directly as 8-bit string */ + result = utf8_to_gsm8(utf8, utf8len, dst); + } else { + /* otherwise, simply try UCS-2 encoding, nothing more serious at the moment */ + if (dst) { + dst[0] = 0x80; + } + result = 1 + utf8_to_ucs2(utf8, utf8len, dst ? (dst+1) : NULL)*2; + } + return result; +} + +int +sim_adn_record_from_bytes( SimAdnRecord rec, cbytes_t data, int len ) +{ + cbytes_t end = data + len; + cbytes_t footer = end - ADN_FOOTER_SIZE; + int num_len; + + rec->adn.alpha[0] = 0; + rec->adn.number[0] = 0; + rec->ext_record = 0xff; + + if (len < ADN_FOOTER_SIZE) + return -1; + + /* alpha is optional */ + if (len > ADN_FOOTER_SIZE) { + cbytes_t dataend = data + len - ADN_FOOTER_SIZE; + unsigned int count = sim_adn_alpha_to_utf8(data, dataend, NULL); + + if (count > sizeof(rec->adn.alpha)-1) /* too long */ + return -1; + + sim_adn_alpha_to_utf8(data, dataend, rec->adn.alpha); + rec->adn.alpha[count] = 0; + } + + num_len = footer[ADN_OFFSET_NUMBER_LENGTH]; + if (num_len > 11) + return -1; + + /* decode TON and number to ASCII, NOTE: this is lossy !! */ + { + int ton = footer[ADN_OFFSET_TON_NPI]; + bytes_t number = rec->adn.number; + int len = sizeof(rec->adn.number)-1; + int count; + + if (ton != 0x81 && ton != 0x91) + return -1; + + if (ton == 0x91) { + *number++ = '+'; + len -= 1; + } + + count = gsm_bcdnum_to_ascii( footer + ADN_OFFSET_NUMBER_START, + num_len*2, number ); + number[count] = 0; + } + return 0; +} + +int +sim_adn_record_to_bytes( SimAdnRecord rec, bytes_t data, int datalen ) +{ + bytes_t end = data + datalen; + bytes_t footer = end - ADN_FOOTER_SIZE; + int ton = 0x81; + cbytes_t number = rec->adn.number; + int len; + + if (number[0] == '+') { + ton = 0x91; + number += 1; + } + footer[0] = (strlen(number)+1)/2 + 1; + return 0; +} diff --git a/hardware/ril/reference-ril/gsm.h b/hardware/ril/reference-ril/gsm.h new file mode 100644 index 0000000000..37428eb4e0 --- /dev/null +++ b/hardware/ril/reference-ril/gsm.h @@ -0,0 +1,177 @@ +#ifndef _android_gsm_h +#define _android_gsm_h + +/** USEFUL TYPES + **/ + +typedef char byte_t; +typedef byte_t* bytes_t; +typedef const byte_t* cbytes_t; + +/** BCD + **/ + +/* convert a 8-bit value into the corresponding nibble-bcd byte */ +extern byte_t gsm_int_to_bcdi( int value ); + +/* convert a nibble-bcd byte into an int, invalid nibbles are silently converted to 0 */ +extern int gsm_int_from_bcdi( byte_t value ); + +/** HEX + **/ + +/* convert a hex string into a byte string, assumes 'dst' is properly sized, and hexlen is even */ +extern void gsm_hex_to_bytes ( cbytes_t hex, int hexlen, bytes_t dst ); + +/* convert a byte string into a hex string, assumes 'hex' is properly sized */ +extern void gsm_hex_from_bytes( char* hex, cbytes_t src, int srclen ); + +/* convert a hexchar to an int, returns -1 on error */ +extern int gsm_hexchar_to_int( char c ); + +/* convert a hexchar to an int, returns 0 on error */ +extern int gsm_hexchar_to_int0( char c ); + +/* convert a 2-char hex value into an int, returns -1 on error */ +extern int gsm_hex2_to_byte( const char* hex ); + +/* convert a 2-char hex value into an int, returns 0 on error */ +extern int gsm_hex2_to_byte0( const char* hex ); + +/* convert a 4-char hex value into an int, returns -1 on error */ +extern int gsm_hex4_to_short( const char* hex ); + +/* convert a 4-char hex value into an int, returns 0 on error */ +extern int gsm_hex4_to_short0( const char* hex ); + +/* write a byte to a 2-byte hex string */ +extern void gsm_hex_from_byte( char* hex, int val ); + +extern void gsm_hex_from_short( char* hex, int val ); + +/** UTF-8 and GSM Alphabet + **/ + +/* check that a given utf8 string is well-formed, returns 1 on success, 0 otherwise */ +extern int utf8_check( cbytes_t utf8, int utf8len ); + +/* check that all characters in a given utf8 string can be encoded into the GSM alphabet. + returns 1 if TRUE, 0 otherwise */ +extern int utf8_check_gsm7( cbytes_t utf8, int utf8len ); + +/* convert a utf-8 string into a GSM septet string, assumes 'dst' is NULL or is properly sized, + and that all characters are representable. 'offset' is the starting bit offset in 'dst'. + non-representable characters are replaced by spaces. + returns the number of septets, */ +extern int utf8_to_gsm7( cbytes_t utf8, int utf8len, bytes_t dst, int offset ); + +/* convert a utf8 string into an array of 8-bit unpacked GSM septets, + * assumes 'dst' is NULL or is properly sized, returns the number of GSM bytes */ +extern int utf8_to_gsm8( cbytes_t utf8, int utf8len, bytes_t dst ); + +/* convert a GSM septets string into a utf-8 byte string. assumes that 'utf8' is NULL or properly + sized. 'offset' is the starting bit offset in 'src', 'count' is the number of input septets. + return the number of utf8 bytes. */ +extern int utf8_from_gsm7( cbytes_t src, int offset, int count, bytes_t utf8 ); + +/* convert an unpacked 8-bit GSM septets string into a utf-8 byte string. assumes that 'utf8' + is NULL or properly sized. 'count' is the number of input bytes. + returns the number of utf8 bytes */ +extern int utf8_from_gsm8( cbytes_t src, int count, bytes_t utf8 ); + + +/** UCS-2 and GSM Alphabet + ** + ** Note that here, 'ucs2' really refers to non-aligned UCS2-BE, as used by the GSM standard + **/ + +/* check that all characters in a given ucs2 string can be encoded into the GSM alphabet. + returns 1 if TRUE, 0 otherwise */ +extern int ucs2_check_gsm7( cbytes_t ucs2, int ucs2len ); + +/* convert a ucs2 string into a GSM septet string, assumes 'dst' is NULL or properly sized, + 'offset' is the starting bit offset in 'dst'. non-representable characters are replaced + by spaces. returns the number of septets */ +extern int ucs2_to_gsm7( cbytes_t ucs2, int ucs2len, bytes_t dst, int offset ); + +/* convert a ucs2 string into a GSM septet string, assumes 'dst' is NULL or properly sized, + non-representable characters are replaced by spaces. returns the number of bytes */ +extern int ucs2_to_gsm8( cbytes_t ucs2, int ucs2len, bytes_t dst ); + +/* convert a GSM septets string into a ucs2 string. assumes that 'ucs2' is NULL or + properly sized. 'offset' is the starting bit offset in 'src', 'count' is the number + of input septets. return the number of ucs2 characters (not bytes) */ +extern int ucs2_from_gsm7( bytes_t ucs2, cbytes_t src, int offset, int count ); + +/* convert an 8-bit unpacked GSM septets string into a ucs2 string. assumes that 'ucs2' + is NULL or properly sized. 'count' is the number of input septets. return the number + of ucs2 characters (not bytes) */ +extern int ucs2_from_gsm8( bytes_t ucs2, cbytes_t src, int count ); + + +/** UCS2 to/from UTF8 + **/ + +/* convert a ucs2 string into a utf8 byte string, assumes 'utf8' NULL or properly sized. + returns the number of utf8 bytes*/ +extern int ucs2_to_utf8( cbytes_t ucs2, int ucs2len, bytes_t utf8 ); + +/* convert a utf8 byte string into a ucs2 string, assumes 'ucs2' NULL or properly sized. + returns the number of ucs2 chars */ +extern int utf8_to_ucs2( cbytes_t utf8, int utf8len, bytes_t ucs2 ); + +/* try to skip a given number of characters in a utf-8 byte string, return new position */ +extern cbytes_t utf8_skip( cbytes_t utf8, cbytes_t utf8end, int count); + +/** Dial Numbers: TON byte + 'count' bcd numbers + **/ + +/* convert a bcd-coded GSM dial number into an ASCII string (not zero-terminated) + assumes 'dst' is NULL or properly sized, returns 0 in case of success, -1 in case of error. + 'num_digits' is the number of digits, not input bytes. a trailing 0xf0 is ignored automatically + return the number of ASCII chars */ +extern int gsm_bcdnum_to_ascii ( cbytes_t bcd, int num_digits, bytes_t dst ); + +/* convert an ASCII dial-number into a bcd-coded string, returns the number of 4-bit nibbles written, */ +extern int gsm_bcdnum_from_ascii( cbytes_t ascii, int asciilen, bytes_t dst ); + +/** ADN: Abbreviated Dialing Numbers + **/ +#define SIM_ADN_MAX_ALPHA 20 /* maximum number of characters in ADN alpha tag */ +#define SIM_ADN_MAX_NUMBER 20 /* maximum digits in ADN number */ + +typedef struct { + byte_t alpha [ SIM_ADN_MAX_ALPHA*3+1 ]; /* alpha tag in zero-terminated utf-8 */ + char number[ SIM_ADN_MAX_NUMBER+1 ]; /* dialing number in zero-terminated ASCII */ +} +SimAdnRec, *SimAdn; + +typedef struct { + SimAdnRec adn; + byte_t ext_record; /* 0 or 0xFF means no extension */ +} +SimAdnRecordRec, *SimAdnRecord; + +extern int sim_adn_record_from_bytes( SimAdnRecord rec, cbytes_t data, int datalen ); +extern int sim_adn_record_to_bytes ( SimAdnRecord rec, bytes_t data, int datalen ); + +/** ROPES + **/ + +typedef struct { + bytes_t data; + int max; + int pos; + int error; + unsigned char data0[16]; +} GsmRopeRec, *GsmRope; + +extern void gsm_rope_init( GsmRope rope ); +extern void gsm_rope_init_alloc( GsmRope rope, int alloc ); +extern int gsm_rope_done( GsmRope rope ); +extern bytes_t gsm_rope_done_acquire( GsmRope rope, int *psize ); +extern void gsm_rope_add_c( GsmRope rope, char c ); +extern void gsm_rope_add( GsmRope rope, const void* str, int len ); +extern void* gsm_rope_reserve( GsmRope rope, int len ); + +#endif /* _android_gsm_h */ diff --git a/hardware/ril/reference-ril/modem_define_func.c b/hardware/ril/reference-ril/modem_define_func.c new file mode 100644 index 0000000000..4021e9fe3c --- /dev/null +++ b/hardware/ril/reference-ril/modem_define_func.c @@ -0,0 +1,233 @@ +#include +#include "atchannel.h" +#include "at_tok.h" +#include "modem_define_func.h" + +#define LOG_TAG "RIL" +#include + +/* cmy: 某些模块可能有着不同的初始化方式 + */ +void initModem_gsm() +{ + LOGD("[%s]: === Enter", __FUNCTION__); + + ATResponse *p_response = NULL; + int err; + +// 呼叫相关设置 + /* 显示主叫号码 */ + at_send_command("AT+CLIP=1", NULL); + + /* Call Waiting notifications */ + at_send_command("AT+CCWA=1", NULL); + + /* No connected line identification */ + at_send_command("AT+COLP=0", NULL); + + /* USSD unsolicited */ + at_send_command("AT+CUSD=1", NULL); + +// 短信相关设置 + /* SMS PDU mode */ + at_send_command("AT+CMGF=0", NULL); + + /* +CSSU unsolicited supp service notifications */ + at_send_command("AT+CSSN=0,1", NULL); + + // cmy: 设置新短信通知(包括+CMT、+CMTI、+CDSI3 种)上报给 TE 的方式 + at_send_command("AT+CNMI=1,2,0,0,0", NULL); + + // 选择短信服务 + at_send_command("AT+CSMS=1", NULL); + +// 其它设置 + /* HEX character set */ + at_send_command("AT+CSCS=\"IRA\"", NULL); + + /* Extra stuff */ +// at_send_command("AT+FCLASS=0", NULL); + +// 网络相关设置 + // cmy: 网络注册的状态发生改变时,上报+CREG: + /* Network registration events */ + err = at_send_command("AT+CREG=2", &p_response); + /* some handsets -- in tethered mode -- don't support CREG=2 */ + if (err < 0 || p_response->success == 0) + at_send_command("AT+CREG=1", NULL); + + at_response_free(p_response); + +// cmy: 网络注册的状态发生改变时,上报+CGREG: + /* GPRS registration events */ + err=at_send_command("AT+CGREG=2", &p_response); +// E1750(0x1614,0x800)do not support AT+CGREG=2 + if (err < 0 || p_response->success == 0) + at_send_command("AT+CGREG=1", NULL); + at_response_free(p_response); + +// 发现部分模块,在发完上述命令后,再发其它命令会有回显 +// 在此再次取消回显 + at_send_command("ATE0", NULL); + + LOGD("[%s]: === Level", __FUNCTION__); +} + +void initModem_AD3812(void) //lintao 2010-8-4 +{ + LOGD("[%s]: === Enter", __FUNCTION__); + + ATResponse *p_response = NULL; + int err; + +// 呼叫相关设置 + /* 显示主叫号码 */ + at_send_command("AT+CLIP=1", NULL); + +// 短信相关设置 + /* SMS text mode */ + /* lintao: just only support text mode*/ + at_send_command("AT+CMGF=0", NULL); + + /* lintaos: set notify for new SMS(including +CMT、+CMTI、+CDSI)*/ + at_send_command("AT+CNMI=1,2,0,0,0", NULL); + + // 选择短信服务 + at_send_command("AT+CSMS=1", NULL); + +// 网络相关设置 + // cmy: 网络注册的状态发生改变时,上报+CREG: + /* Network registration events */ + err = at_send_command("AT+CREG=2", &p_response); + /* some handsets -- in tethered mode -- don't support CREG=2 */ + if (err < 0 || p_response->success == 0) + at_send_command("AT+CREG=1", NULL); + + at_response_free(p_response); + + // cmy: 网络注册的状态发生改变时,上报+CGREG: + /* GPRS registration events */ + at_send_command("AT+CGREG=2", NULL); + +// 发现部分模块,在发完上述命令后,再发其它命令会有回显 +// 在此再次取消回显 + at_send_command("ATE0", NULL); + + LOGD("[%s]: === Level", __FUNCTION__); +} + +void initModem_cdma() +{ + LOGD("[%s]: === Enter", __FUNCTION__); + + ATResponse *p_response = NULL; + int err; + + /* 显示主叫号码 */ + //at_send_command("AT+CLIP=1", NULL); + + /* SMS text mode */ + // cmy: just only support text mode + //at_send_command("AT+CMGF=1", NULL); + +// cmy: 设置新短信通知(包括+CMT、+CMTI、+CDSI3 种)上报给 TE 的方式 + //at_send_command("AT+CNMI=1,2,0,0,0", NULL); + +// 发现部分模块,在发完上述命令后,再发其它命令会有回显 +// 在此再次取消回显 + at_send_command("ATE0", NULL); + + LOGD("[%s]: === Level", __FUNCTION__); +} + +void initModem_LC6341() //malei +{ + LOGD("[%s]: === Enter", __FUNCTION__); + + ATResponse *p_response = NULL; + int err; + + at_send_command("ATV1", NULL); + //at_send_command("AT^DCCOM=1,1,0", NULL); + + at_send_command("AT^DUSBDEG=1,1", NULL); + at_send_command("AT^DUSBDEG=2,1",NULL); + at_send_command("AT^DUSBDEG=3,1",NULL); + at_send_command("AT^DUSBDEG=4,1",NULL); + at_send_command("AT^DUSBDEG=5,1",NULL); + + + at_send_command("AT+CGMR", NULL); + + at_send_command("AT^DTSER", NULL); + + at_send_command("AT+CMER=2,0,0,2", NULL); + + at_send_command("AT+CREG=1", NULL); + + at_send_command("AT+CGREG=1", NULL); + + at_send_command("AT^DCTA=1", NULL); + + at_send_command("AT^DSCI=1", NULL); + + at_send_command("AT^DCPI=1",NULL); + + at_send_command("AT^DDTM?",NULL); + + //at_send_command("AT^DSTM=1,0,2",NULL); + +} +void initModem_QCOM(void) +{ + LOGD("[%s]: === Enter", __FUNCTION__); + + ATResponse *p_response = NULL; + int err; + + // 呼叫相关设置 + /* 显示主叫号码 */ + at_send_command("AT+CLIP=1", NULL); + + /* Call Waiting notifications */ + at_send_command("AT+CCWA=1", NULL); + + /* No connected line identification */ + at_send_command("AT+COLP=0", NULL); + + /* USSD unsolicited */ + at_send_command("AT+CUSD=1", NULL); + + // 短信相关设置 + /* SMS PDU mode */ + at_send_command("AT+CMGF=0", NULL); + + /* +CSSU unsolicited supp service notifications */ + at_send_command("AT+CSSN=0,1", NULL); + + // cmy: 设置新短信通知(包括+CMT、+CMTI、+CDSI3 种)上报给 TE 的方式 + at_send_command("AT+CNMI=1,2,0,0,0", NULL); + + // 选择短信服务 + at_send_command("AT+CSMS=1", NULL); + + // 其它设置 + /* HEX character set */ + at_send_command("AT+CSCS=\"IRA\"", NULL); + + /* Extra stuff */ +// at_send_command("AT+FCLASS=0", NULL); + + // 网络相关设置 + at_send_command("AT+CREG=1", NULL); + + /* GPRS registration events */ + at_send_command("AT+CGREG=1", NULL); + //at_send_command("AT+CGATT=1",NULL); + at_send_command("ATE0", NULL); + + LOGD("[%s]: === Level", __FUNCTION__); + + +} + diff --git a/hardware/ril/reference-ril/modem_define_func.h b/hardware/ril/reference-ril/modem_define_func.h new file mode 100644 index 0000000000..896d80cc25 --- /dev/null +++ b/hardware/ril/reference-ril/modem_define_func.h @@ -0,0 +1,7 @@ +void initModem_gsm(void); +void initModem_cdma(void); +void initModem_ET128(void); +void initModem_AD3812(void); +void initModem_A355(); +void initModem_LC6341(void); +void initModem_QCOM(void); diff --git a/hardware/ril/reference-ril/modem_list.h b/hardware/ril/reference-ril/modem_list.h new file mode 100644 index 0000000000..d73a4da0a5 --- /dev/null +++ b/hardware/ril/reference-ril/modem_list.h @@ -0,0 +1,1990 @@ +#ifndef _MODEM_LIST_H_ +#define _MODEM_LIST_H_ + +/////////////////////////////////////////////////////// +#include "config.h" + +typedef struct{ + int srv_status; + int srv_domain; + int roam_status; + int sys_mode; + int sim_state; + int reserve; + int sys_submode; +} RIL_SysInfo; + +typedef enum { + RADIO_TYPE_GSM = 0, + RADIO_TYPE_CDMA, + RADIO_TYPE_EVDO, + RADIO_TYPE_WCDMA, + RADIO_TYPE_TDSCDMA, +} RIL_RadioType; + +enum{ + EXT_AT_GENERIC=0, + EXT_AT_CNMOBILE, + EXT_AT_CNTELECOM, + EXT_AT_ZTE, + EXT_AT_ZTE_AD3812, + EXT_AT_MP_K80, + EXT_AT_LC6341, + EXT_AT_ARCHOS_G9, + EXT_AT_QULUM, + EXT_AT_SCV_SPW9P, + EXT_AT_MAX +}; + +/* + cmy: 部分功能需要用扩展的AT命令来实现,目前各个模块所用的扩展AT命令可能不同 + 以下这些函数是需要使用扩展命令来实现的 +*/ +typedef int (*RIL_GetPreferredNetworkType) (void); +typedef int (*RIL_SetPreferredNetworkType) (int); +typedef int (*RIL_GetNetworkType)(void); +typedef int (*RIL_GetRestrictedState)(void); + +typedef struct{ + RIL_GetPreferredNetworkType getPrefNetworkType; + RIL_SetPreferredNetworkType setPrefNetworkType; + RIL_GetNetworkType getNetworkType; + RIL_GetRestrictedState getRestrictedState; +} RIL_ExtendFunc; + + +enum{ + MODEM_FUNC_GSM=0, + MODEM_FUNC_CDMA, + MODEM_FUNC_AD3812, + MODEM_FUNC_LC6341,//malei + MODEM_FUNC_QCOM, + MODEM_FUNC_MAX, +}; + +typedef void (*RIL_InitModem)(void); + +typedef struct{ + RIL_InitModem initModem; +} RIL_ModemDefineFunc; + +typedef struct { + int vid; + int pid; + const char *model_id; // 不超过 2047个字符 +CGMM +} MODEM_INFO; + +/* + MU301 + +CGMI:ZTE CORPORATION + +CGMR: P905M2_LWINV1.0.0B03[Nov 05 2009 09:16:32] + EM660 + HUAWEI TECHNOLOGIES CO., LTD + */ +typedef struct { + MODEM_INFO modem_info; // Modem信息,这些信息都是通过设备查询到的 + const char* modem_name; // Modem名称,这是Modem厂家对外的名称 + RIL_RadioType radioType; // GSM/CDMA/EVDO/WCDMA/TDSCDMA +#if 1 + const char* atchannel_index; + const char* pppchannel_index; +#else + int atchannel_index; + int pppchannel_index; +#endif + int baudrate; // 通道的波特率, default is 115200 +// int need_wakeup_reconnect; // 部分Dongle,在系统从睡眠中唤醒后,数据连接不可用,需要重新连接 +// int keep_alive; // 部分Dongle的数据连接在进入睡眠后无法保持,通过设置keep_alive 使得这部分dongle不进睡眠 + int initWaitTime; + const char* connect_init_script; + const char* disconnect_script; + +/* function */ + RIL_ModemDefineFunc* modemDefFunc; // 对于某些功能各模块可能有其不同的实现 + RIL_ExtendFunc* extATFunc; // 使用扩展AT命令实现的功能函数 +// int ext_at_type; + int inner; +} RIL_ModemInterface; + +#define TD_6341 + +// modem需要约15秒的时间完成初始化 +//#define DELAY_BEFORE_OPEN_ATPORT 15 //3 +//#define DELAY_BEFORE_FIRST_ATCMD 0 //10 +#define INIT_WAIT_TIME_1S 1 +#define INIT_WAIT_TIME_5S 5 +#define INIT_WAIT_TIME_10S 10 +#define INIT_WAIT_TIME_15S 15 +#define INIT_WAIT_TIME_30S 30 + +static RIL_ExtendFunc s_extend_func[EXT_AT_MAX]={ +/*Generic*/ {getPreferredNetworkType_generic, setPreferredNetworkType_generic, getNetworkType_generic, getRestrictedState_generic}, +/*China Mobile*/ {getPreferredNetworkType_cnm, setPreferredNetworkType_cnm, getNetworkType_cnm, getRestrictedState_cnm}, +/*China Telecom*/ {getPreferredNetworkType_cnt, setPreferredNetworkType_cnt, getNetworkType_cnm, getRestrictedState_cnm}, +/*ZTE_MF210/MF200*/ {getPreferredNetworkType_zte, setPreferredNetworkType_zte, getNetworkType_zte, getRestrictedState_zte}, +/*ZTE_AD3812*/ {getPreferredNetworkType_zte_ad3812,setPreferredNetworkType_zte_ad3812,getNetworkType_generic, getRestrictedState_generic}, +/*MP_K80*/ {getPreferredNetworkType_cnm, setPreferredNetworkType_cnm, getNetworkType_generic, getRestrictedState_generic}, +/*LC6341*/ {getPreferredNetworkType_cnm, setPreferredNetworkType_cnm, getNetworkType_lc6341, getRestrictedState_lc6341}, +/*ARCHOS_G9*/ {getPreferredNetworkType_archos_g9, setPreferredNetworkType_archos_g9, getNetworkType_generic, getRestrictedState_generic}, + {getPreferredNetworkType_generic,setPreferredNetworkType_generic,getQualmNetworkType,getRestrictedState_generic}, + {getPreferredNetworkType_SCV_SPW9P,setPreferredNetworkType_SCV_SPW9P,getNetworkType_generic,getRestrictedState_generic} +}; + +static RIL_ModemDefineFunc s_modem_define_func[MODEM_FUNC_MAX]={ + {initModem_gsm}, + {initModem_cdma}, + {initModem_AD3812}, + {initModem_LC6341}, + {initModem_QCOM} + +}; +//AT+CGDCONT=1,\"IP\",\"%s\",,0,0 +#define CONNECT_INIT_SCRIPT "'' AT '' ATH0 '' " /* */ +#define CONNECT_INIT_SCRIPT_MF210 "'' AT '' " /* */ +#define CONNECT_INIT_SCRIPT_K80 "'' AT '' " /* */ +#define CONNECT_INIT_SCRIPT_E1916 "'' AT '' " +#define DISCONNECT_SCRIPT "'' +++ATH0" /* */ +#define DISCONNECT_SCRIPT_K80 "" /* */ +#define DISCONNECT_SCRIPT_UE800 "" /* */ +#define DISCONNECT_SCRIPT_TU930 "'' +++ATH" /* */ + +#define MAX_SUPPORT_MODEM 300 +#define MAX_MATCH_MODEM_ATCHANNEL 10 + +#if 0 +#define TTYUSB0 0 +#define TTYUSB1 1 +#define TTYUSB2 2 +#define TTYUSB3 3 +#define TTYUSB4 4 +#define TTYUSB5 5 + +#define TTYACM0 0 +#define TTYACM1 1 +#define TTYACM2 2 +#define TTYACM3 3 +#define TTYACM4 4 +#define TTYACM5 5 +#else +#define TTYUSB0 "/dev/ttyUSB0" +#define TTYUSB1 "/dev/ttyUSB1" +#define TTYUSB2 "/dev/ttyUSB2" +#define TTYUSB3 "/dev/ttyUSB3" +#define TTYUSB4 "/dev/ttyUSB4" +#define TTYUSB5 "/dev/ttyUSB5" +#define TTYUSB244 "/dev/ttyUSB244" +#define TTYUSB245 "/dev/ttyUSB245" +#define TTYUSB246 "/dev/ttyUSB246" + +#define TTYACM0 "/dev/ttyACM0" +#define TTYACM1 "/dev/ttyACM1" +#define TTYACM2 "/dev/ttyACM2" +#define TTYACM3 "/dev/ttyACM3" +#define TTYACM4 "/dev/ttyACM4" +#define TTYACM5 "/dev/ttyACM5" + +//USI 模块 USB+URAT +#define TTYS1 "/dev/ttyS1" + +#endif + +/* + 相同VID/PID的模块,其 INIT_WAIT_TIME 保持相同 + */ +static RIL_ModemInterface s_support_modem_lists[] = { + //begain 2102-4-25 + + { {0x12d1, 0x1506, "E1220"}, + "E1220",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_CNMOBILE,0}, + { {0x12d1, 0x1001, "K3806"}, + "vofadone K3806",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_CNMOBILE,0}, + //end 2102-4-25 + { {0x12d1, 0x1001, "K3772"}, + "vodafone K3772",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_CNMOBILE,0}, + + { {0x12d1, 0x1001, "K3770"}, + "vodafone K3770",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_CNMOBILE,0}, + + { {0x05C6, 0x6000, "S770"}, + "ASEL S770", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_QCOM, s_extend_func+EXT_AT_CNTELECOM,0}, + +{ {0x05C6, 0x6000, "HSUPA Modem"}, + "HSUPA Modem", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, +DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + { {0x05C6, 0x6000, "SP6E VER 1.1.1"}, + "SCV SEV769,SCV SEV739,SCV SEV759", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + { {0x05C6, 0x6000, "5.01.11"}, + "SENTAR ST809", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, +// 该3g的AT口与其它的3G Dongle(相同VID/PID) 不同, + { {0x05C6, 0x6000, "SEV859"}, + "SCV SEV859,EC187", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, +/**** VID = 0x12D1 ****/ +/* PID = 0x1001 */ + { {0x12D1, 0x1001, "EM660"}, + "EM660", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,1}, + + { {0x12D1, 0x1001, "EM660C"}, + "EM660C", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,1}, + + { {0x12D1, 0x1001, "EC122"}, + "EC122", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x12D1, 0x1001, "EC1261"}, + "EC1261", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x12D1, 0x1001, "EM770"}, + "EM770", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,1}, + + { {0x12D1, 0x1506, "MU609"}, + "MU609", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,1}, + +{ {0x12D1, 0x1573, "MU609"}, +"MU609", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,1}, + +{ {0x12D1, 0x1C25, "MU609"}, + "MU709", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT,DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,1}, + +{ {0x12D1, 0x1C25, "MU709"}, +"MU709", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, +DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,1}, +{ {0x12D1, 0x140C, "EM820U"}, +"EM820U", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, +DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,1}, + + { {0x12D1, 0x1001, "EM770W"}, + "EM770W", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,1}, + + { {0x12D1, 0x1404, "EM770W"}, + "EM770W", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_CNMOBILE,1}, + + { {0x12D1, 0x1404, "MC509"}, + "MC509", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+ EXT_AT_CNTELECOM,1}, +//靠E1750 靠E1750 + /* { {0x12D1, 0x1001, "E1750"}, + "E1750", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0},*/ + +{ {0x12D1, 0x1001, "E1750"}, + "E1750", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +/* PID = 0x1003 */ + { {0x12D1, 0x1003, "E180"}, + "E180", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1003, "E220"}, + "E220", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +/* PID = 0x140B */ + { {0x12D1, 0x140B, "EC1261"}, +"EC1261", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, +///xuxuehui +// { {0x12D1, 0x140C, "EC122"}, + // "EC122", RADIO_TYPE_EVDO, TTYUSB3, TTYUSB0, 115200,INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA,s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x12D1, 0x140C, "EC1261"}, + "EC1261", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + { {0x12D1, 0x140C, "EC1261-2"}, + "EC1261-2", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + { {0x12D1, 0x140C, "EC156"}, + "EC156", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x12D1, 0x140C, "E156G"}, + "E156G", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +/* PID = 0x140C */ + { {0x12D1, 0x140C, "EC122"},"EC122", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S,CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + { {0x12D1, 0x140C, "EC122"}, + "EC122", RADIO_TYPE_EVDO, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x12D1, 0x140C, "E1750"}, + "E1750", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +/* PID = 0x14AC */ + { {0x12D1, 0x14AC, "E1820"}, + "E1820", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x14AC, "E182E"}, + "E182E", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +// 可以考虑不支持E180 + { {0x12D1, 0x1001, "E180"}, + "E180", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_30S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +/**** VID = 0x19D2 ****/ + { {0x19D2, 0x0003, "P905M2_LWIN"}, + "MU301", RADIO_TYPE_TDSCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,1}, + + { {0x19D2, 0x1303, "P905M2"}, + "MU301", RADIO_TYPE_TDSCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x19D2, 0x0094, "AC200"}, + "ZiTM06", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,1}, + + { {0x19D2, 0xFFED, "MC2716"}, + "MC2716", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x19D2, 0xFFFE, "MC8630"}, + "MC8630", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_K80, DISCONNECT_SCRIPT_K80, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,1}, + + { {0x19D2, 0x0016, "MF210"}, + "MF210", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + { {0x19D2, 0x0016, "MF110"}, + "MF110", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + { {0x19D2, 0x0117, "MF210"}, + "MF210", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + { {0x19D2, 0x0117, "MF210V2"}, + "MF210V2", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200,INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210,DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + { {0x19D2, 0x0117, "MF200"}, + "MF200", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,1}, + + { {0x19D2, 0xFFEB,"AD3812"}, + "AD3812",RADIO_TYPE_WCDMA, TTYUSB0, TTYUSB3, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_AD3812, s_extend_func+EXT_AT_ZTE_AD3812,1}, + +// Vtion E1916 3G Dongle +/* + { {0x1E89, 0x1E16, "E1916"}, + "E1916", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_5S, CONNECT_INIT_SCRIPT_E1916, DISCONNECT_SCRIPT_K80, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM}, +*/ + { {0x1E89, 0x1E16, "E1916"}, + "Vtion E1916", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_E1916, DISCONNECT_SCRIPT_K80, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x1E89, 0x1E16, "E1916"}, + "Vtion E1916", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_E1916, DISCONNECT_SCRIPT_K80, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + + + /*{ {0x0685, 0x6000, " HSUPA USB Modem"}, + " HSUPA USB Modem", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_5S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE},*/ + + { {0x0685, 0x6000, "ZD6000"}, + "W567", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + + + { {0x1234, 0x0033, "LCR 3.0.0"}, + "TDM330", RADIO_TYPE_TDSCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,1}, + + + { {0x19D2, 0x0170, "ZTE-A371"}, + "ZTE-T A371", RADIO_TYPE_TDSCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x04CC, 0x2259, "TD368"}, + "TD2000", RADIO_TYPE_TDSCDMA, TTYUSB4, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + { {0x04CC, 0x2259, "TD688"}, + "TD688", RADIO_TYPE_TDSCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x04CC, 0x226E, "TD688"}, + "TD688", RADIO_TYPE_TDSCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,1}, + + { {0x04CC, 0x226E, "TD368"}, + "TD368", RADIO_TYPE_TDSCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x1BBB, 0x0000, "HSPA Data Card"}, + "AL300", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0xFEED, 0x0001, "K80"}, + "K80", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_5S, CONNECT_INIT_SCRIPT_K80, DISCONNECT_SCRIPT_K80, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_MP_K80,0}, + + { {0x19F5, 0x9909, "UE800"}, + "UE800", RADIO_TYPE_EVDO, TTYUSB3, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x07d1,0x7e11,"DMW156"}, + "DWM-156(A3)", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S,CONNECT_INIT_SCRIPT,DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x1C9E, 0x9603, "HSPA USB MODEM"}, + "W71,LONGSUNG U5501", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,1}, + + { {0x1C9E, 0x9605, "HSPA USB MODEM"}, + "W72,KR3G 100 HSPA SUB DATA CARD,LAVA 730G+", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19F5, 0x9909, "ME800"}, + "ME800", RADIO_TYPE_EVDO, TTYUSB4, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,1}, + + { {0x1A8D, 0x2005, "C339"}, + "BandLuxe C339", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_5S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1D09, "ET128"}, + "ET128", RADIO_TYPE_TDSCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x19F5, 0x9909, "119"}, + "UE608", RADIO_TYPE_EVDO, TTYUSB3, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x1BBB, 0x0017, "HSPA Data Card"}, + "ALCATEL,telcel tct mobile", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +/*YiFang*/ + { {0x19D2, 0x0117, "MF190"}, + "ZTE-MF190", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + { {0x19D2, 0x0117, "MF190S"}, + "ZTE-MF190S", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + { {0x19D2, 0x0039, "MF110"}, + "Longtail WU-872", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +/*华夏一期*/ + { {0x19D2, 0x0073, "ZTE AC580"}, + "AC560", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x19D2, 0x0094, "AC580"}, + "AC580,AC581,AC590", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x028A, 0x1006, "16"}, + "StrongRising W50,hx1,ST904,ST909", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1001, "EC189"}, + "EC189", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x12D1, 0x1001, "E1782"}, + "E1782", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1001, "E1612"}, + "E1612", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1001, "E1786"}, + "E1786", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1001, "E1552"}, + "E1552", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1001, "E1553"}, + "E1553", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1003, "E160"}, + "E160", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1003, "E160E"}, + "E160", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +// cmy@20101215: 发现一款E160,它的modem id是"E160X" + { {0x12D1, 0x1003, "E160X"}, + "E160", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x140C, "E160X"}, +"E160e", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1003, "E176"}, + "E176,movistar HUAWEI E176 HSPA USB Stick", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1003, "E17X"}, + "E172", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x140C, "E1756"}, + "E1756", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x140C, "E1550"}, + "E1550", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x140C, "E158"}, + "E158", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x140C, "E173"}, + "E173", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1414, "UMG181"}, + "UMG181", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x14AC, "E1820-0"}, + "E1820", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1D09, "ET127/158/128-2"}, + "ET127/ET128-2", RADIO_TYPE_TDSCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1D09, "ET188"}, + "ET188", RADIO_TYPE_TDSCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x19D2, 0x0031,"MF633"}, + "MF633",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_AD3812, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x0031,"MF637U"}, + "MF637",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_AD3812, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x1410, 0x4400, "Ovation MC950D Card"}, + "OVATION MC950D", RADIO_TYPE_WCDMA, TTYUSB0, TTYUSB0, 115200, INIT_WAIT_TIME_5S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x028A, 0x1006, "HSDPA Modem"}, + "W50", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, +//xuxuehui + { {0x04CC, 0x225A, "TD369"}, + "Star-Net TD2000,RX310", RADIO_TYPE_TDSCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S,CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, +{ {0x19D2, 0xFFF1, "AC27XX"}, + "AC2746, AC2787,AC2736, AC2728", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + +//ZTE 内置模块MC2718 中国版 + { {0x19D2, 0xFFF1, "MC271X"}, + "MC2718", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,1}, +//ZTE 内置模块MC2718 美国版 不需要SIM卡 + { {0x19D2, 0xFFE8, "MC2718"}, + "ZTE MC2718", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,1}, + { {0x19D2, 0xFFF1, "119"}, + "AC8710,AC2766", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + { {0x19d2, 0x0079, "ZTE_TD_LD3"}, + "ZTE A355", RADIO_TYPE_TDSCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x19F5, 0x9905, "LJ189"}, + "LJ189", RADIO_TYPE_EVDO, TTYUSB3, TTYUSB1, 115200, INIT_WAIT_TIME_15S + 5, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x05C6, 0x00A0, "ADOrA280"}, + "ASB C820", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x05C6, 0x6000, "U803-4.03.10"}, + "MSM6500", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x05C6, 0x6000, "SPV8"}, + "StrongRising H80", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x1D09, 0xAEF4, "E800"}, + "JinYuShiKong C819,A30", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x12D1, 0x1001, "EC1260"}, + "EC1260", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x12D1, 0x140C, "EC167"}, + "EC167", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x21F5, 0x2008, "154"}, + "StrongRising", RADIO_TYPE_EVDO, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x20B9, 0x1682, "119"}, + "GR,ZDX 6085", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + +// 20101120 + { {0x19D2, 0x0017,"MF100"}, + "MF100",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_AD3812, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x0031,"MF100"}, + "MF100",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_AD3812, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x0031,"MF627"}, + "MF627",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_AD3812, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1001, "E1752"}, + "E1752", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1001, "E1630"}, + "E1630", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x140C, "E1692"}, + "E1692", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1003, "E230"}, + "E230", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1003, "E226"}, + "E226", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1003, "E272"}, + "E272", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1003, "E166"}, + "E166", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1411, "E510"}, + "E510", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x19D2, 0x0015,"MF628"}, + "MF628",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_AD3812, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x05C6, 0x6000, "U803-4.03.12"}, + "E001,surfing", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x04CC, 0x2259, "NEXPERIA SY.SOL 7210 TDSCDMA"}, + "TD688", RADIO_TYPE_TDSCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1001, "E169u"}, + "E169u", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1001, "E169"}, + "E169", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1001, "K3715"}, + "K3715", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +// lt@20101123 + { {0x12D1, 0x1003, "E270"}, + "E270", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x140C, "K3715"}, + "K3715", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1003, "E160G"}, + "E160E,E160G", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x1C9E, 0x6000, "209"}, + "TXT 209", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x028A, 0x1009, "+T005"}, + "TXT EV-9A,TXT EV-88", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x05C6, 0x0015, "HD360"}, + "YiHuaRen 6280,PuLiMeng,ST HSDPA", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x1C9E, 0x6061, "HSDPA USB MODEN"}, + "LianMengKe 6260", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x1C9E, 0x6061, "HSDPA USB MODEM"}, + "HSDPA WIRELESS Mobile Connect", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x0685, 0x7000, "209"}, + "LianChen 6280", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +// lt@20101124 + + // 埃及对SIM卡有要求 + { {0x19D2, 0x0033, "MF190"}, + "ZTE-MF190", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + { {0x19D2, 0x0033, "MF636DB"}, + "ZTE-MF636", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x05C6, 0x6280, "HSDPA Modem"}, + "W80,AoXian W80,ST907", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +// lt@10101124-2 + //TXT EV-10 ,TXTX EV-100 Dongels have the same IDs with some else defined before. + + { {0x05C6, 0x6000, "U803-4.01.01"}, + "ST804", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x04CC, 0x2259, "SY-SOL 7210 TDSCDMA"}, + "ChuangPu T002", RADIO_TYPE_TDSCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x1C9E, 0x6000, "154"}, + "TXT EV-10", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x05C6, 0x0015, "WM66-TF"}, + "HongHu", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x140C, "EC1270"}, + "EC1270", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x19D2, 0x0031, "MF110"}, + "ZTE-MF110", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x05C6, 0x0015, "206"}, + "PLM7200", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +// 20101204, AT/PPP与其它同VID/PID设备的不同,暂不支持 + { {0x05C6, 0x0015, "HSPA Data Card"}, + "PuLiMeng 6246", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +// 20101216, 该Dongle与 ZTE A355相同 + { {0x19d2, 0x0079, "A356"}, + "ZTE A356", RADIO_TYPE_TDSCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19F5, 0x9013, "MW100"}, + "MW100", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,1}, + + { {0x1C9E, 0x9E00, "EVDO USB MODEM"}, + "", RADIO_TYPE_EVDO, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x12D1, 0x140C, "E261"}, + "E261", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_CNMOBILE,0}, + +// 2011-06-21 + { {0x12D1, 0x1C05, "E173"}, + "E173", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x0031, "MF170"}, + "ZTE-MF170", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x0031, "MF180"}, + "ZTE-MF180", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x1C9E, 0x9605, "Micromax MMX310G 3G USB Modem"}, + "MMX310G", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_5S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x1AB7, 0x5740, "LC5740"}, + "LC5740", RADIO_TYPE_TDSCDMA, TTYUSB5, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,1}, + + // { {0x12D1, 0x1001, "MU509"}, + // "MU509", RADIO_TYPE_WCDMA, TTYUSB246, TTYUSB244, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,1}, + + { {0x12D1, 0x1001, "MU509"}, + "MU509", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,1}, + + { {0x12D1, 0x1003, "E1750"}, + "E1750", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x140C, "E1780"}, + "E1780", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x19D2, 0x2002, "K3765-Z"}, + "K3765-Z", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x0017, "MF668"}, + "ZTE MF668A", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_AD3812, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x0031, "MF626"}, + "MF626", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x0117, "MF668A"}, + "ZTE MF668A", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x2003, "MF210"}, + "MF210", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + /*{ {0x1BBB, 0x00B7, "HSPA Data Card"}, + "ALCATEL", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC},*/ + + { {0x1AB7, 0x6341, "LC6341"}, + "LC6341", RADIO_TYPE_TDSCDMA, TTYUSB5, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_LC6341, s_extend_func+EXT_AT_LC6341,0}, + + //xuxuehui20110803 + { {0x05C6, 0x6000, "SP6E VER 1.1.0"}, + "scv759,SEV790", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x1AB7, 0x5700, "AirCard"}, + "AirCard", RADIO_TYPE_TDSCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0xffff, "MC5716"}, + "ZTE MC5716", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x1614, 0x0800, "206"}, + "WCDMA USB STICK", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +// 客户提供 + { {0x12D1, 0x1001, "E176G"}, + "E176G", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x140C, "E1752"}, + + "E1752", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, +//xuxuehui20110908 + { {0x19d2, 0x0063, "K3565-Z"}, + "ZTE CDMA Technologies MSM", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + { {0x12D1, 0x1001, "E1550"}, + "E1550", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x14AC, "E153"}, + "E153Cu-1,E153", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x0031,"MF633BP+"}, + "MF633BP+",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_AD3812, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x0117, "MF180"}, + "ZTE-MF180", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1003, "E176G"}, + "E176G", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x058f, 0x6254, "LG"}, + "LG", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, +//贝尔 + /*{ {0x04CC, 0x225A, "TD369"}, + "TD369", RADIO_TYPE_TDSCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE},*/ + { {0x1BBB, 0x00B7, "HSPA Data Card"}, + "ARCHOS G9", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ARCHOS_G9,0}, + { {0x19F5, 0xF000, "DT-8T"}, + "High Speed Wireless Broadband", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +//xxh 20111021 + { {0x05C6, 0x6000, "MSM6290 S790"}, + "SENTAR ST986 MSM6290 S790", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x05C6, 0x6000, "MSM6280 W880"}, + "SENTAR ST986 MSM6280 W880", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x05C6, 0x6000, "S790"}, + "SENTAR ST986 S790", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + { {0x19D2, 0x0152, "AC580"}, + "AC580", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNMOBILE,0}, + +//20111031 + { {0x19D2, 0x0117, "MF100"}, + "ZTE-MF100", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + { {0x12D1, 0x140C, "EC189"}, + "EC189", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, +//20111101 + { {0x12D1, 0x140C, "EC150"}, + "EC150", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x19D2, 0x0094, "AC582"}, + "AC582", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x19F5, 0x9013, "UW100"}, + "UW100", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,1}, + { {0x05C6, 0x6000, "HSDPA Modem"}, + "HSDPA Modem", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_QCOM, s_extend_func+EXT_AT_QULUM,0}, +//要验证0x19D2, 0x0121 1,2 + { {0x19D2, 0x0121,"MF637"}, + "MF637",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_AD3812, s_extend_func+EXT_AT_ZTE,0}, + + { {0x19D2, 0x0123,"MF637"}, + "MF637",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_AD3812, s_extend_func+EXT_AT_ZTE,0}, + + { {0x1D09, 0x1000, "HSDPA Modem"}, + "HSDPA Modem", RADIO_TYPE_WCDMA, TTYUSB0, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + //20111204 + { {0x19D2, 0x0152, "AC582"}, + "AC582", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNMOBILE,0}, + { {0x19D2, 0x0152, "AC591"}, "AC591", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200,INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT,DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x19d2, 0x0079, "ZTE_TD_LD4"}, + "ZTE_TD_LD4", RADIO_TYPE_TDSCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + //20111206客户提供 + { {0x12D1, 0x1001, "E261"}, + "E261", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_CNMOBILE,0}, + + //20111216 INTEX + { {0x230D, 0x000D, "HSPADataCard"}, + "intex", RADIO_TYPE_WCDMA, TTYUSB4, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x140C, "E1552"}, + "E1552",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_CNMOBILE,0}, + + { {0x05c6, 0x3100, "33"}, + "33",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_GENERIC,0}, + + { {0x05c6, 0x9002, "1, GMM-S100"}, + "1, GMM-S100",RADIO_TYPE_WCDMA, TTYUSB0, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1404, "MC509-a"}, + "MC509-a", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+ EXT_AT_CNTELECOM,1}, +// 2103 12.09 + { {0x19D2, 0x0124,"MF190"}, + "MF190",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + { {0x19D2, 0x0125,"MF190"}, + "MF190",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB5, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + { {0x19D2, 0x0126,"MF190"}, + "MF190",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + { {0x19D2, 0x0128,"MF190"}, + "MF190",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + { {0x19D2, 0x0144,"MF0144"}, + "MF0144",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + { {0x19D2, 0x0145,"MF0145"}, + "MF0145",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + { {0x12D1, 0x140C, "E1762"}, + "K3765", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, +//20120227 + {{0x12D1,0x1417,"E1752C"}, + "E1752CU",RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x2020, 0x1005, "HSPA WIRELESS MODEM"}, + "S830,Olive convergence", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x0BDB, 0x190A, "F3307"}, +// "F3307", RADIO_TYPE_WCDMA, TTYACM0, TTYACM1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_GENERIC}, + "ERICSSON F3307", RADIO_TYPE_WCDMA, TTYUSB4, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_GENERIC,1}, +// E303 AT chanle TTYUSB3/TTYUSB2 + { {0x12D1, 0x1506, "E303"}, + "Vivo E303", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x12D1, 0x1506, "E303"}, +"E303", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1506, "E3256"}, + "E3256", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x140c, "E303"}, + "Vivo E303", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + {{0x12D1, 0x1506, "E303D"}, + "India HUAWEI E303D", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1506, "E3131A"}, + "huawei E3131A", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1506, "E3331"}, + "huawei E3331", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1506, "E303Cs-1"}, + "mobifone FAST CONNECT HUAWEI", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1506, "E303s-1"}, + "ezCom MobiFone fast connect HUAWEI", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, +//验证通过 + { {0x12D1, 0x1506, "E303C"}, + "huawei E303C", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +{ {0x12D1, 0x1506, "E303F"}, + "huawei E303F", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1506, "E3131"}, + "HUAWEI E3131", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1506, "E3131"}, + "HUAWEI E3131", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1001, "E3131"}, +"HUAWEI E3131", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x151D, "E3131"}, +"HUAWEI E3131S-2 orange TM", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x12D1, 0x151D, "E3131"}, + "HUAWEI E3131 orange TM", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +//国外DOGNLE对SIM卡有要求, 需要在国外测试 + +{ {0x12D1, 0x1506, "E357"}, +"HUAWEI E357s-2", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + +{ {0x12D1, 0x1506, "E353"}, + "BSNL E353s-6 3G HSPA USB Stick", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1506, "E1100"}, + "M173", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1506, "E1731"}, + "huawei E173Cs-1 airtel 3G", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1001, "E1731"}, + "huawei airtel 3G", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT,DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, +//注册失败,怀疑运营商绑定 埃及dongle + { {0x12D1, 0x1506, "E173"}, + "HUAWEI E173Z-1", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1506, "E303C"}, + "vivo huawei E303", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1506, "E369"}, + "HUAWEI E369", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + + { {0x12D1, 0x1506, "E398"}, + "HUAWEI E398", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1506, "E1731"}, + "huawei E173Cs-1 airtel 3G", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1506,"MU739"}, + "MU739",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,1}, + + { {0x20A6, 0x1105, "HSDPA-T36"}, + "HSDPA MODEM",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x1D09, 0x1010, "HSDPA Modem"}, + "HSDPA",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, +//客户验证2012-3-20 + { {0x19D2, 0x0117, "MF631"}, + "MF631", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x2003, "MF631"}, + "MF631", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x1254, "MF190"}, + "MF190", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + { {0x1E89, 0x1A20, "USB MODEM"}, + "Vtion U1920", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x1E89, 0x1E16, "172"}, + "ZDX LKT868", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_E1916, DISCONNECT_SCRIPT_K80, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x1BBB, 0x000F, "ETCOM E300"}, + "ETCOM E300", RADIO_TYPE_EVDO, TTYUSB3, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+ EXT_AT_CNTELECOM,0}, + + { {0x19F5, 0x9909, "UE660"}, + "UE660", RADIO_TYPE_EVDO, TTYUSB3, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x19F5, 0x9013, "MW100G"}, + "MW100G", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,1}, + + //think mw100 + { {0x19F5, 0x9013, "MW160"}, + "MW100", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,1}, + + { {0x12D1, 0x140B, "EC122"}, + "EC122", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x12D1, 0x140C, "T1731"}, + "T1731", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + + + { {0x1C9E, 0x9865, "Modem"}, + "Modem", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + { {0x12D1, 0x140C, "E177"}, + "E177", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + { {0x1614, 0x0800, "E1750"}, + "HSUPA USB STICK", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1001, "E171"}, + "HUAWEI E171", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x05C6, 0x6000, "QSC6085-800/1900 EVDO REV.A"}, + "Rate EC183, SCV SEV869, SCV SEV879", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x230D, 0x0001, "HSPADataCard"}, + "BSNL 3G", RADIO_TYPE_WCDMA, TTYUSB4, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1001, "E1756"}, + "HuaWei E1756", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x140C, "E1731"}, + "HUAWEI E1731,aritel 3G", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x140C, "E1752C"}, + "HUAWEI E1752C", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x1C9E, 0x9605, "Micromax MMX353G 3G USB Modem"}, + "MMX353G", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + // 在系统睡眠唤醒时,该Dongle会自动断开 + { {0x05C6, 0x6000, "S890"}, + "Rate EC183,H880 CDMA2000 surfing", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + { {0x05C6, 0x6000, "BU580"}, + "surfing CDMA EVDO Rev.A USB Modem 800MHZ", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + // 20120524 + // { {0x05C6, 0x6000, "SP6E VER 1.1.1"}, + // "SCV SEV739", RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM}, + + + + { {0x05C6, 0x6000, "SEV759"}, + "SCV SEV769+", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x20A6, 0x1105, "209"}, + "HSDPA MODEM",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x1181, "K3772-Z"}, + "Vodafone K3772-Z", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x21f5, 0x1101, "StrongRsing"}, + "SCV strongring STD808,SCV TC156", RADIO_TYPE_TDSCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + // { {0x21f5, 0x2012, "SPW9S"}, + //"SCV strongring ", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x20A6, 0x1105, "HSUPA"}, + "SEW898 SCV RATE W100,EBODA HKC",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + //Test in india 已经OK + { {0x2077, 0xA000, "T3G72A"}, + "TERA BSNL 3G", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x2077, 0xA000, "WU260-G19A-01"}, + "beyond", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x2077, 0xA000, "HSUPA"}, + "TERA 3G",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x2077, 0xA000, "WU260-VTK"}, + "WU260-VTK",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x2077, 0xA000, "WU520-G19A-LAV"}, + "WU520-G19A-LAV",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x2077, 0xA000, "DG-BA3370"}, + "DG-BA3370",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x2077, 0xA000, "WU260"}, + "Qualcomm 6800 WU260",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + + { {0x230D, 0x0101, "HSPADataCardA"}, + "BSNL 3G", RADIO_TYPE_WCDMA, TTYUSB4, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + { {0x1c9e, 0x6061, "209"}, + "HSDPA USB Wireless Data Card", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1001, "EC169"}, + "HUAWEI EC169", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x13d3, 0x3273, "AW-NU709H"}, + "AW-NU709H",RADIO_TYPE_WCDMA, TTYUSB0, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x19d2, 0x0108, "HSPA MODEM"}, + "BSNL 3G",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, +//印度EVDO dongle 不需要SIM卡 + { {0x12D1, 0x140B, "EC156"}, + "TATA photon High-Speed Wireless Broadband Service", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + +{ {0x19D2, 0x0113, "K4505"}, + "Vodafone Mobile Broadband", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0118, "K4"}, + "Vodafone SmartCard", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x12D1, 0x140B, "EC1262"}, + "Reliance EC1262", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + +{ {0x12D1, 0x140B, "EC152"}, + "Reliance EC152", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + +{ {0x12D1, 0x140B, "EC1561"}, + "HUAWEI EC1561 MTS", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + +{ {0x12D1, 0x140B, "EC159"}, + "Reliance EC159", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x12D1, 0x140B, "EC150"}, + "Reliance Broadbad+", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + +{ {0x12D1, 0x140B, "EC1260"}, + "EC1260", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x20a6, 0x1105, "E1750"}, + "Reliance Broadbad+", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x20a6, 0x1105, "HSDPA"}, + "RTR6285", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x20a6, 0x1105, "HSPA+"}, + "SCV SPW9W", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_GENERIC,0}, + +{{0x1782, 0x3D10, "V1.0.1-B7"}, + "BEH64259A", RADIO_TYPE_TDSCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNMOBILE,0}, +//IE701 3G 模块 + { {0x201e, 0x1022, "CBP7.1"}, + "Hier ie701", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + +{ {0x12D1, 0x140C, "E1756C"}, + "HUAWEI E1750", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x140C, "E1732"}, + "HuaWei E1732", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, +//modify K3770-Z 2013-4-27 +{ {0x19D2, 0x1177, "K3770-Z"}, + "Vodafone K3770-Z", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x12D1, 0x1001, "3G HSDPA MODEM"}, + "3G HSDPA MODEM", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_QCOM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x20A6, 0x1105, "Test number"}, + "Test number",RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x12D1, 0x14AC, "E367"}, + "HUAWEI E367,E367u-2 DUBAI", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x14AC, "E1553"}, + "HUAWEI E1553", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, +//实创兴3G EVDO 模块 + { {0x21F5, 0x2009, "QSC6085-800/1900 EVDO REV.A"}, + "SCV SP8J EVDO",RADIO_TYPE_EVDO, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + +{ {0x1E89, 0x1A20, "HSPA USB MODEM"}, + "Qualocomm HSPA USB MODEM", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x230D, 0x000c, "HSPADataCard"}, + + "BSNL 3G", RADIO_TYPE_WCDMA, TTYUSB4, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x0031, "MF193"}, + "ZTE-MF193", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x0421, 0x061e, "Nokia Internet Stick CS-11"}, + "Nokia Internet Stick CS-11", RADIO_TYPE_WCDMA, TTYUSB4, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x1EE8, 0x005F, "MSA 14.4"}, + "Onda-MSA14.4", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x12D1, 0x1001, "E303"}, + "HUAWEI E303S", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1001, "EG162G"}, + "HUAWEI E1732", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x140C, "EC176-2"}, + "HUAWEI EC176", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + +{ {0x15EB, 0x0001, "CBP7.0"}, + "esia max-d EVDO Rev.a USB STICK AXACM01", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + +{ {0x15EB, 0x0001, "CBP7.1T"}, + "C218D", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + +{ {0x12D1, 0x1506, "E392"}, + "E392u-92", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +{ {0x12D1, 0x1003, "E156G"}, + "E156G", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x12D1, 0x14AC, "E353"}, + "HUAWEI E353 SHPA+ USB Stick", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x12D1, 0x14AC, "E372"}, + "du Huawei E372 WCDMA", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + +{ {0x0b3c, 0xc00a, "Olicard 160"}, +"olivetti Olicard 160 Branco", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x12D1, 0x1001, "K3520"}, + "HUAWEI K3520", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +{ {0x19D2, 0x1008, "K3570-Z"}, + "Vodafone K3570-Z", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x1C9E, 0x9605, "Micromax MMX352G 3G USB Modem"}, + "MMX352G", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x1C9E, 0x9917, "Micromax MMX144F 3G USB Modem"}, + "MMX144F", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x1C9E, 0x9605, "Micromax MMX144F 3G USB Modem"}, + "MMX144F", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, +// AT+CFUN=3 +{ {0x19D2, 0x2003, "MF180"}, + "MF180", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, +{ {0x19D2, 0x2003, "MF190"}, + "MF190", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x19D2, 0x2003, "MF190A"}, + "MF190A", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x2003, "MF193E"}, +"MF193", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x12D1, 0x1001, "HSDPA Modem"}, + "Qualocomm HSPA USB MODEM", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +//310G at+cfun=7 + {{0x1c9e, 0x9800, "Micromax MMX310G 3G USB Modem"}, + "micomax 310G", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB1, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + +//{ {0x19d2, 0x0167, "MF880T"}, +// "MF880T LTE USB MODEM", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +{ {0x19D2, 0x0031, "MF190"}, + "ZTE-MF190", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x1001, "EC169C"}, + "HUAWEI EC169", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE, 0}, +//内置模块客户提供的开发板 + +{ {0x257A, 0x1605, "HEM630"}, + "HTF EVDO",RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,1}, + + { {0x257A, 0x2601, "HWM630"}, + "HTF WCDMA",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,1}, + { {0x19D2, 0x0117, "ZTE 21Mbps"}, + "ZTE 21Mbps", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x15EB, 0x7152, "CBP7.1"}, + "MC400", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + +{ {0x19D2, 0x0017,"MF669"}, + "ZTE MF669",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x0117,"MF288"}, + "ZTE MF288",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, +{ {0x230D, 0x0003, "HSPADataCard"}, + + "BSNL 3G", RADIO_TYPE_WCDMA, TTYUSB4, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +//Test by ZLJ in india 已经OK +{ {0x230D, 0x0103, "HSPADataCardA"}, + + "MTNL LW272", RADIO_TYPE_WCDMA, TTYUSB4, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x05C6, 0x0023, "29"}, + "BSNL 3G SKYNET DATA CADE NO.SK3001", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x12D1, 0x1001, "M6280"}, + "Qualocomm HSPA USB MODEM", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x1A8D, 0x2006, "B150"}, + "B150", RADIO_TYPE_WCDMA, TTYACM1, TTYACM0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +//SPW9S,实创兴3G WCDMA模块 + { {0x21F5, 0x2012, "SPW9P"}, + "Strong Rising MU270,SPW9S", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, 10, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_SCV_SPW9P, 1}, + +{ {0x1C9E, 0x9915, "HSDPA mobile station"}, + "WM66E", RADIO_TYPE_WCDMA, TTYUSB4, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x1C9E, 0x9800, "HSPA USB MODEM"}, + "Speedup HSDPA USB MODEM", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x12D1, 0x140C, "E180"}, + "du Huawei E180 WCDMA", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x19D2, 0x0017,"MF668A"}, + "ZTE MF668A",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x05c6, 0x0016,"3.5GH-72"}, + "iball 3G modem",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, +//ZTE 1,2待验证 +{ {0x19d2, 0x0151,"Etisaltat Modem"}, + "PROLINK MODEL etisalat state Trading",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19d2, 0x0153,"zte0153"}, + "zte 0153",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19d2, 0x0155,"zte"}, + +"zte",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19d2, 0x0156,"zte"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19d2, 0x0157,"zte"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19d2, 0x1246,"zte"}, +"ZTE 1246",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19d2, 0x1247,"zte"}, +"zte ",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19d2, 0x1251,"zte"}, +"zte",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19d2, 0x1252,"zte"}, + + +"zte",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19d2, 0x1255,"zte"}, +"zte",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19d2, 0x1256,"zte1246"}, +"zte",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x12D1, 0x1001, "E303S"}, +"E303C", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + +{ {0x12D1, 0x14AE, "K3806"}, + "K3806", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, +//modiy 2013-4-27 + +{ {0x19D2, 0x0104, "K4505-Z"}, + "Vodafone Mobile Broadband K4505-z", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0106, "K4505-Z"}, +"Vodafone Mobile Broadband", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x12D1, 0x1D50, "ET302/306"}, + "HUAWEI ET-306", RADIO_TYPE_WCDMA, TTYUSB4, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x19D2, 0x0094, "AC580"}, + "ZTE CDMA AC580", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + +//{ {0x0e8d, 0x00a0, "MT6276"}, +// "USI MT6276", RADIO_TYPE_WCDMA, TTYS1, TTYACM0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,1}, + + +{ {0x12D1, 0x1003, "E173"}, + "HUAWEI E173", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x19D2, 0x0031, "MF112"}, + "ZTE-MF112", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x1C9E, 0x9918, "Micromax MMX144F HSPA USB Modem"}, +"MMX144F", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + +{ {0x2020, 0x4000, "Micromax MMX377GG 3G USB Modem"}, + "Micromax MMX377G", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x2020, 0x2000, "TS-991"}, + "TS-991", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S,CONNECT_INIT_SCRIPT,DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x1DBC, 0x0669, "Micromax MMX353G 3G HSPA Modem"}, + "Micromax MMX353G", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x12D1, 0x1001, "E173"}, + "E173u-2", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +{ {0x12D1, 0x1001, "E3131C"}, + "HUAWEI Turkcell Vinn E3131Cs-2", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + +{ {0x12D1, 0x1001, "E3256"}, + "HiLink Tunisiana E3256 ", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x1506, "E372"}, + "HUAWEI Mobile Broadband E372 orange TM", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x12D1, 0x1001, "E122"}, + "HUAWEI E122", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x140C, "E2010"}, + "HUAWEI E2010", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +{ {0x19D2, 0x0117, "3G-100"}, + "ZTE MF180S HSDPA USB Stick", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_AD3812, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x19D2, 0x0117, "K3800"}, + "ZTE MF197 HSPA USB Stick", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, +//dibai MF190 NOT OK + { {0x19d2, 0x1404, "MF190"}, + "zte", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S,CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + + { {0x12D1, 0x14AC, "E368"}, + "HUAWEI E368", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S,CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +{ {0x0af0, 0xd157, "GI1515"}, + "Option Wireless Technology orange GI1515", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S,CONNECT_INIT_SCRIPT,DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x2001, 0x7D00, "DMW-156"}, + "D-Link DWM-156", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S,CONNECT_INIT_SCRIPT,DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x2001, 0x7D01, "DMW-156"}, + "D-Link DWM-156", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB2, 115200, INIT_WAIT_TIME_10S,CONNECT_INIT_SCRIPT,DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + +{ {0x2001, 0x7D02, "DMW-157"}, + "D-Link DWM-157", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB2, 115200, INIT_WAIT_TIME_10S,CONNECT_INIT_SCRIPT,DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x0421, 0x0612, "Nokia Internet Stick CS-15"}, + "NOKIA", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S,CONNECT_INIT_SCRIPT,DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x05c6, 0x9000, "33"}, + "AIRIS USB 3G dongle", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S,CONNECT_INIT_SCRIPT,DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + +{ {0x05c6, 0x9000, "simcom5215"}, + "simcom5215", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S,CONNECT_INIT_SCRIPT,DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x19D2, 0x2003, "MF667"}, + "ZTE MF667", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0117, "MF667"}, + "ZTE MF667", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +//ZTE单ECM口 + //2013-7-16 中兴最新VID PID数据卡 + +{ {0x19D2, 0x1405, "MF667"}, + "ZTE MF667", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1266, "MF190U"}, + "ZTE MF190U",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1253, "MF193A"}, + "ZTE MF193A",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1533, "MF1533"}, + "ZTE MF1533",RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1533, "MF1535"}, + "ZTE MF1535",RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1433, "MF1433"}, + "ZTE MF1433",RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1594, "MF1594"}, +"ZTE MF1594",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1596, "MF1596"}, +"ZTE MF1596",RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0001, "MF0001"}, + "ZTE MF0001",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0002, "MF0002"}, + "ZTE MF0002",RADIO_TYPE_WCDMA, TTYUSB4, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0012, "MF0012"}, + "ZTE MF0012",RADIO_TYPE_WCDMA, TTYUSB4, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0015, "MF0015"}, + "ZTE MF0015",RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0030, "MF0030"}, + "ZTE MF0030",RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0042, "MF0042"}, + "ZTE MF0042",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0043, "MF0043"}, + "ZTE MF0043",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0048, "MF0048"}, + "ZTE MF0048",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0049, "MF0049"}, + "ZTE MF0049",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0030, "MF0061"}, + "ZTE MF0061",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0030, "MF0064"}, + "ZTE MF0064",RADIO_TYPE_WCDMA, TTYUSB0, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x1589, "MF193M"}, + "ZTE MF193M",RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0017, "MF193"}, + "ZTE MF193",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0021, "ZTE"}, + "ZTE MF21",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1591, "MF710"}, + "ZTE MF710",RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0189, "LTE"}, + "ZTE CDMA LTE",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1592, "MF730M"}, + "ZTE MF730M",RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +//{ {0x19D2, 0x0167, "MF880T"}, +// "ZTE MF880T",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, +//AT+NCM 接口 +{ {0x19D2, 0x1244, "K4201-Z"}, + "ZTE K4201-Z",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x1435, "MF823"}, + "ZTE MF823 LTE USB MODEM",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1218, "MF652"}, + "ZTE MF652",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, +//国外3G dognle MF195必须使用国外SIM卡 +{ {0x19D2, 0x1515, "MF195"}, +"ZTE MF195",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0082, "MF190"}, +"ZTE MF190 K4305",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1260, "MF1260"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, +//AT+NCM +{ {0x19d2, 0x1402,"ZTE1402"}, +"ZTE AT+NCM",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1261, "MF1261"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1259, "MF1259"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1510, "MF1510"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0xFFEC, "MFFFEC"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, +//ZTE RNDIS 按照PPP目前方式拨号 +{ {0x19D2, 0x1404, "MF1404"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1432, "MF1432"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0018, "MF0018"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0019, "ZTE"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0037, "ZTE"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19d2, 0x0039,"ZTE"}, +"zte",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0052, "ZTE"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0057, "ZTE"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0066, "ZTE"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0086, "ZTE"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0058, "ZTE"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, +{ {0x19D2, 0x0063, "ZTE"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0078, "ZTE"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0091, "MF"}, +"ZTE",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +//end 2013-7-16 + + +//ZTE 数据卡,未验证 2103/12/19 + +{ {0x19D2, 0x1083, "K4305-Z"}, +"Vodafone Broadband", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1264, "HSDPA"}, +"ZTE", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1263, "HSDPA"}, + "ZTE", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x2002, "HSDPA"}, +"ZTE", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1249, "HSDPA"}, +"Vodafone Mobile Broadband", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1010, "K4505-Z"}, +"Mobile Broadband", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0122, "HSDPA"}, +"ZTE", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0148, "HSDPA"}, +"ZTE", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0159, "HSDPA"}, +"ZTE", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0165, "HSDPA"}, +"ZTE", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0164, "HSDPA+"}, +"ZTE", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1084, "HSDPA+"}, + "ZTE", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1272, "HSDPA+"}, +"ZTE", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x1563, "HSDPA+"}, +"ZTE", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1268, "HSDPA+"}, +"ZTE", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1269, "HSDPA+"}, +"ZTE", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1589, "HSDPA+"}, +"ZTE", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x1591, "HSDPA+"}, +"ZTE", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x1592, "HSDPA+"}, +"ZTE", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +//end 2013/12/19 + + +//ZTE DC-LTE 2013/12/20 +{ {0x19D2, 0x0167, "LTE"}, + "LTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0191, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0189, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0199, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB0, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0201, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB0, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0257, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0317, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0330, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0350, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB4, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x1018, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x1333, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB0, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0284, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0396, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0414, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0448, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0447, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB4, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0387, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB4, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0445, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0443, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +{ {0x19D2, 0x0265, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0394, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0411, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB4, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + + +{ {0x19D2, 0x0412, "LTE"}, + "ZTE DC-LTE", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +//END DC-LTE 2013/12/20 + +//国外3G dognle必须使用国外SIM卡 +{ {0x1C9E, 0x9914, "HSDPA mobile station"}, +"Smart BRO WM66E",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, +{ {0x1C9E, 0x9905, "HSDPA mobile station"}, +"Smart BRO WM726",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, + s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x0E8D, 0x00A2, "MTK2"}, +"MTK",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,1}, + + +{ {0x0E8D, 0x00A5, "UNA+"}, +"UNAPLAS UNA+",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,1}, + +{ {0x0E8D, 0x00A7, "UNA+"}, + "UNAPLAS UNA+",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,1}, + +{ {0x12D1, 0x1001, "E1780"}, +"E1780", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, +//未调通 +{ {0x0403, 0x6010, "CE901"}, + "Telit Data Module EVK2-0", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, +//india MTS evdo 3G dongle need sim card +{ {0x1bbb, 0x0012, "MDM"}, + "MDM",RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, +{ {0x1BBB, 0x011e, "HSPA Data Card"}, + "HSPA Data Card", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT,DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x12d1, 0x14CF, "K3772"}, + "K3772",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_GENERIC,0}, + +{ {0x1c9e, 0x9801, "HSPA USB MODEM"}, + "Telewell INDIA",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_GENERIC,0}, + +{ {0x1c9e, 0x9801, "WU520-G19A-LAV"}, +"INTEX WU520-G19A-LAV",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_GENERIC,0}, + +{ {0x1c9e, 0x9803, "HSPA USB MODEM"}, + "iball 3G donlge",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_GENERIC,0}, + +{ {0x1782, 0x0002, "V1.0.1-B7"}, +"U7501",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB1, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_GENERIC,0}, + +{ {0x12D1, 0x141B, "E1752"}, +"E1752",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_GENERIC,0}, + + +{ {0x12D1, 0x1001, "E3231"}, + "HUAWEI E3231", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +{ {0x12D1, 0x1506, "K3773"}, +"HUAWEI K3773", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x12D1, 0x1001, "K3773"}, +"HUAWEI K3773", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +{ {0x12D1, 0x1515, "K3773"}, +"HUAWEI K3773", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x12D1, 0x140c, "EC177"}, + "HUAWEI EC177", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + +{ {0x12D1, 0x1001, "EC177"}, + "HUAWEI EC177", RADIO_TYPE_EVDO, TTYUSB2,TTYUSB0,115200,INIT_WAIT_TIME_10S,CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, +//LTE MESSI +{ {0x216F,0x0047, "ALT3100"}, +"USI MESSI", RADIO_TYPE_WCDMA, TTYACM0, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_GENERIC,0}, + + +{ {0x05c6,0x9025, "KMD-L200"}, + "USB_L200_NDIS", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x12D1, 0x1001, "E357"}, + "E357", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +{ {0x12D1, 0x1506, "E3276"}, + "huawei LTE usb Rotator E3276", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +{ {0x12D1, 0x1001, "E353"}, + "E353", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +{ {0x12D1, 0x1001, "E153"}, + "E353u-1", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +{ {0x12D1, 0x1001, "E3236"}, + "E3236", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +{ {0x12D1, 0x1C08, "E173"}, + "E173", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +{ {0x1C9E, 0x9803, "WM66E"}, +"WM66E", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB3, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +{ {0x12D1, 0x1436, "Huawei Mobile Broadband Network Device"}, +"Mobile Broadband Network Device", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, +{ {0x11F6, 0x1030, "WM66E"}, + "WM66E", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB2, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT,DISCONNECT_SCRIPT,s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +//test at +{ {0x04E2, 0x1410, "ME909S"}, + "HUAWEI lte ME909S", RADIO_TYPE_WCDMA, TTYACM0, TTYUSB2, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT,DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +//{ {0x106C, 0x3718, "UML290VW"}, + // "Pantech UML290", RADIO_TYPE_WCDMA, TTYACM0, TTYACM0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +//由于内核option.c变化导致串口有变化的dongle列于此 +#if (RIL_VERSION >= 6) + { {0x12D1, 0x1465, "Huawei K3765"}, + "K3765", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +//最近发现有K3770使用/dev/ttyUSB2作为AT口 + + { {0x12d1, 0x14c9, "K3770"}, + "K3770",RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_GENERIC,0}, + + { {0x12d1, 0x14c9, "K3770"}, + "K3770",RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_GENERIC,0}, + +#else + { {0x12D1, 0x1465, "Huawei K3765"}, + "K3765", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + { {0x12d1, 0x14c9, "K3770"}, + "K3770",RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_GENERIC,0}, +#endif + +// 未确认、未开放的模块皆列于此 +// 对于要发布的ril库,请定义RIL_RELEASE后再编译 +#ifndef RIL_RELEASE + // 在系统睡眠时该模块经常进不了睡眠,从而造成功耗太高,ZZC在与华为FAE调试 + { {0x12D1, 0x1506, "MU733"}, + "HuaWei MU733", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,1}, + + // 在国内无法注网,怀疑该dongle与运营商绑定 + { {0x12D1, 0x14A8, "E173"}, + "Huawei E173Eu-1", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +// 4G + { {0x19D2, 0x0167, "MF820"}, + "4G Lte", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_ZTE,0}, + +// 4G + { {0x12D1, 0x1506, "E392"}, + "E392u-92", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, +//4G + { {0x12D1, 0x1506, "E303"}, + "E303", RADIO_TYPE_WCDMA, TTYUSB3, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +// 4G + { {0x1004, 0x61AA, "VL600 136"}, + "LG VL600", RADIO_TYPE_EVDO, TTYACM0, TTYACM0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_GENERIC,0}, + +// 4G + { {0x106C, 0x3718, "UML290VW"}, + "Pantech UML290", RADIO_TYPE_WCDMA, TTYACM0, TTYACM0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +// 国外Dongle未调通 + { {0x05C6, 0x0018, "29"}, + "HSUPA INCORPORATED", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +// 以下内置模块未经验证 + { {0x1D6B, 0x0002, "F5521gw"}, + "F5521gw", RADIO_TYPE_WCDMA, TTYACM0, TTYACM2, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+ EXT_AT_GENERIC,1}, + +// 未调通 + { {0x12D1, 0x140C, "E1556"}, + "E1556", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +// 待确认 + { {0x12D1, 0x1003, "E156G"}, + "E156G", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + +// 未调通 + { {0x12D1, 0x1001, "E1762V"}, + "E1762", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_CNMOBILE,0}, + +// USI的模组需要开启CDC-ACM驱动,可能影响到其它dongle的AT/PPP口的分配 + { {0x0E8D, 0x00A2, "MTK2"}, + "MTK",RADIO_TYPE_WCDMA, TTYUSB0, TTYACM0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,1}, + +// 该3g的AT口与其它的3G Dongle(相同VID/PID) 不同, + { {0x05C6, 0x6000, "SEV859"}, + "SCV SEV859", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT_MF210, DISCONNECT_SCRIPT_UE800, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + + { {0x12D1, 0x140C, "E1732"}, + "HuaWei E1732", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + // 在系统睡眠时该模块经常进不了睡眠,从而造成功耗太高,ZZC在与华为FAE调试 + { {0x12D1, 0x1506, "MU733"}, + "HuaWei MU733", RADIO_TYPE_WCDMA, TTYUSB1, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,0}, + + { {0x12D1, 0x140B, "EC1561"}, + "HuaWei EC1561", RADIO_TYPE_EVDO, TTYUSB2, TTYUSB0, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_CDMA, s_extend_func+EXT_AT_CNTELECOM,0}, + +// 还处理验证阶段,需要确认睡眠、唤醒及功耗等 + { {0x19F5, 0x9013, "WM800"}, + "Thinkwill WM800", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC,1}, + +// 内置模块,在demo板上调试AT指令OK,需在整机上调试睡眠、唤醒及功耗等 + { {0x05C6, 0x9000, "SIMCOM_SIM5213"}, + "SIM5320E", RADIO_TYPE_WCDMA, TTYUSB2, TTYUSB3, 115200, INIT_WAIT_TIME_10S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_GSM, s_extend_func+EXT_AT_GENERIC, 0}, + +// 内置模块,调试AT指令OK,需调试睡眠、唤醒及功耗等 + { {0x19D2, 0xFFEB, "0"}, + "ZTE MW3736",RADIO_TYPE_WCDMA, TTYUSB0, TTYUSB3, 115200, INIT_WAIT_TIME_15S, CONNECT_INIT_SCRIPT, DISCONNECT_SCRIPT, s_modem_define_func+MODEM_FUNC_AD3812, s_extend_func+EXT_AT_ZTE_AD3812,1}, + +#endif + + { {0, 0, NULL}, NULL, RADIO_TYPE_GSM, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL,0}, +}; + +#endif + + diff --git a/hardware/ril/reference-ril/operator_table.c b/hardware/ril/reference-ril/operator_table.c new file mode 100644 index 0000000000..b82798a922 --- /dev/null +++ b/hardware/ril/reference-ril/operator_table.c @@ -0,0 +1,189 @@ +#include +#include "operator_table.h" + +#define LOG_TAG "RIL" +#include + +OperatorInfo** gOperatorTable = NULL;//[200]; +SpnInfo** spnTable=NULL; +int gOperatorCounts = 0; +int gSpnCounts = 0; + +/* 有效行: 去除了行前空格,去除了行末的回车换行,不以'#'开关,不为空行 + 成功则返回 用户需要的数据。 + 失败返回 null + */ +char* getValidLine(char* buf, int len, FILE* fp) +{ + char* ret = NULL; + + char line[1000]={0}; + char* pt = line; + while(1) + { + if( (ret=fgets(line, 1000, fp)) == NULL ) break; + + pt = line; + + // 去除行前空格 + while(pt[0] == ' ') ++pt; + + // 去除尾部的 \r\n + int line_len = strlen(pt); + while(pt[0] != 0) + { + if( (pt[line_len-1] != '\n') && (pt[line_len-1] != '\r') ) + break; + pt[line_len-1] = '\0'; + --line_len; + } + +// LOGD("line: %s", pt); + if( pt[0] == '#' ) continue; // 注释行 + if( pt[0] == '\0' ) continue; // 空行 + + // 取得一个有效行 + int copylen = len>strlen(pt)?strlen(pt):len; + memcpy( buf, pt, copylen ); + buf[copylen] = '\0'; + + ret = buf; + + break; + } + + return ret; +} + +int calcValidLines(FILE* fp) +{ + char line[64]; + int count = 0; + fseek(fp, 0, SEEK_SET); + while(1){ + if( getValidLine(line, 63, fp) == NULL ) break; + ++count; +// LOGD("count=%d", count); + } + fseek(fp, 0, SEEK_SET); + return count; +} + +void clearOperatorTable() +{ + while(gOperatorCounts--) + { + free(gOperatorTable[gOperatorCounts]); + gOperatorTable[gOperatorCounts] = NULL; + } + free(gOperatorTable); + gOperatorTable = NULL; + gOperatorCounts = 0; +} + +OperatorInfo* getOperator(char* numeric) +{ +// LOGD("== enter getOperator"); + int i=0; +// LOGD("gOperatorTable=%p", gOperatorTable); + if( gOperatorTable == NULL ) return NULL; + for(i=0; inumeric, gOperatorTable[i]->salphanumeric, gOperatorTable[i]->lalphanumeric); + if( !strcmp(gOperatorTable[i]->numeric,numeric) ) + return gOperatorTable[i]; + } + return NULL; +} + +/* 成功: operator table 大小 + 失败: 0 + */ +int loadOperatorTable(const char* path) +{ + FILE* fp = NULL; + int i=0; + + clearOperatorTable(); + + if( (fp = fopen(path, "r")) == NULL ) + return 0; + + gOperatorCounts = calcValidLines(fp)/3; + + gOperatorTable = (OperatorInfo**)malloc(gOperatorCounts * sizeof(OperatorInfo*)); + + for(i=0; inumeric, 5, fp) == NULL ) break; + if( getValidLine(operator->salphanumeric, 31, fp) == NULL ) break; + if( getValidLine(operator->lalphanumeric, 63, fp) == NULL ) break; + + //LOGD("%d: %s %s %s", i, operator->numeric, operator->salphanumeric, operator->lalphanumeric); + gOperatorTable[i] = operator; + } + + return gOperatorCounts; +} +SpnInfo* getSpn(char * numeric){ + ALOGD("== enter getOperator"); + int i=0; + // LOGD("gOperatorTable=%p", gOperatorTable); + if( spnTable == NULL ) return NULL; + for(i=0; inumeric, spnTable[i]->name); + if( !strcmp(spnTable[i]->numeric,numeric) ) + return spnTable[i]; + } + return NULL; + + +} + +int loadSpnTable(const char* path) +{ + FILE* fp = NULL; + int i=0; + + clearSpnTable(); + + if( (fp = fopen(path, "r")) == NULL ) + return 0; + + gSpnCounts = calcValidLines(fp)/2; + + spnTable = (SpnInfo**)malloc(gSpnCounts * sizeof(SpnInfo*)); + + for(i=0; inumeric, 5, fp) == NULL ) break; + if( getValidLine(spn->name, 31, fp) == NULL ) break; + + // LOGD("%d: %s %s %s", i, spn->numeric, spn->name); + spnTable[i] = spn; + } + + return gSpnCounts; +} +void clearSpnTable() +{ + while(gSpnCounts--) + { + free(spnTable[gSpnCounts]); + spnTable[gSpnCounts] = NULL; + } + free(spnTable); + spnTable = NULL; + gSpnCounts = 0; +} + + diff --git a/hardware/ril/reference-ril/operator_table.h b/hardware/ril/reference-ril/operator_table.h new file mode 100644 index 0000000000..f639223ae6 --- /dev/null +++ b/hardware/ril/reference-ril/operator_table.h @@ -0,0 +1,17 @@ +typedef struct TOperatorItem{ + char numeric[6]; // NMSI(MCC+MNC) + char salphanumeric[32]; // max 31 bytes + char lalphanumeric[64]; // max 63 bytes +}OperatorInfo; + +typedef struct TSpnInfo{ + char numeric[6]; + char name[64]; + +}SpnInfo; + +OperatorInfo* getOperator(char* numeric); +int loadOperatorTable(const char* path); + +SpnInfo* getSpn(char * numeric); +int loadSpn(const char* path); diff --git a/hardware/ril/reference-ril/ril-rk29-dataonly.c b/hardware/ril/reference-ril/ril-rk29-dataonly.c new file mode 100644 index 0000000000..3c14d5aeed --- /dev/null +++ b/hardware/ril/reference-ril/ril-rk29-dataonly.c @@ -0,0 +1,6275 @@ +/* //device/system/reference-ril/reference-ril.c +** +** Copyright 2006, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/********************************************************************************** + * Version + * + * ril-rk29-mid v0.10 从android2.1上移植过来 + * ril-rk29-mid v0.11 新加几个modem的支持 + * ril-rk29-mid v0.12 拨号时间过长导致程序认为拨号失败,但pppd还在运行且最终拨号成功, + * 目前出现这种情况时,杀掉PPPD进程 + * 查询运营商的返回存在问题,已修正 + * ril-rk29-mid v0.13 modem列表放到modem_list.h文件中 + * + * ril-rk29-dataonly v0.14 代码调整、添加部分模块,完善网络类型的获取 + * ril-rk29-dataonly v0.15 发现对于ttyACM设备(主要是TD-SCDMA设备),在获取它的vid/pid时存在问题,目前已修正 + * ril-rk29-dataonly v0.16 支持USSD(Unstructured Supplementary Service Data) + * ril-rk29-dataonly v0.17 ttyACM驱动存在问题,TD-SCDMA设备全都使用ttyUSB驱动 + * 注意内核那边要把ACM驱动去掉 + * ril-rk29-dataonly v0.18 添加几款dongle的支持 + * ril-rk29-dataonly v0.20 部分Dongle,在系统从睡眠中唤醒后,发现原有的数据连接不可用,此 + * 时需要重新连接 + * ril-rk29-dataonly v0.23 修改MC8630模块的支持问题,添加新的模块:F210(19d2/2003)、ALCATEL + * ril-rk29-dataonly v0.33 发现出现"睡眠中唤醒后,原有数据连接不可用"的模块主要是CDMA,当发现CDMA/EVDO模块 + * 建立数据连接时,申请唤醒锁,阻止系统进入睡眠 + * ril-rk29-dataonly v1.0.00 在上网过程中,概率出现pppd自动退出,而此时上层并未发觉,导致无法继续上网。 + * 现在在拨号完成后新建线程来监视pppd状态 + * ril-rk29-dataonly v1.0.02 使用ENABLE_STAY_AWAKE控制是否保持清醒状态(不进入休眠) + * 修正BUG: 当modem匹配结束后,在调用onSIMReady时会再次发命令进行匹配 + * ril-rk29-dataonly v1.0.03 部分模块在初始化过程中,可能部分AT命令导致AT指令的返回带有回显,如今在初始化结束时再将发送"ATE0"取消回显 + * ril-rk29-dataonly v1.0.04 添加两个dongle的支持,代码由客户提供,添加5个modem的支持。增加APN列表,基本包含了所以国家的APN + * ril-rk29-dataonly v1.0.05 CDMA模式第一次拨号上网时,等待一段时间 + * ril-rk29-dataonly v1.0.06 添加modem支持的方式,只支持EVDO模式,或者TD模式,或者WCDMA模式 + * ril-rk29-dataonly v1.0.07 添加几款Dongle支持,国外一款,国内两款,其中TU930使用了新的拨号脚本 + * ril-rk29-dataonly v1.0.08 针对CDMA/EVDO模块,修复当唤醒屏幕后会出现数据超时无法上网的问题 + * ril-rk29-dataonly v1.0.09 针对爱可视dongle的2G/3G网络切换做的修正 + * ril-rk29-dataonly v1.0.10 移植到android4.0 + * ril-rk29-dataonly v1.0.11 添加3款DONGLE支持 + * ril-rk29-dataonly v1.0.12 支持E392、MF820 + * ril-rk29-dataonly v1.1.01 不去查询语音注册状态,华为E1750一直返回"CGREG: 2,0", 根据在香港测试MF820的结果做出调整 + * ril-rk29-dataonly v1.1.02 仅支持 LG VL600 4G Dongle + * ril-rk29-dataonly v1.1.03 支持LG VL600 4G Dongle 及以前的modem,添加vl600 attach + * ril-rk29-dataonly v1.2.00 添加虚拟modem的支持,用于应付单个AT口的情况 + * ril-rk29-dataonly v1.2.01 完善虚拟modem的功能 + * ril-rk29-dataonly v1.2.02 MU509 2G/3G 切换实现 + * ril-rk29-dataonly v1.2.03 MTK2 MT6276MA 3G support + * ril-rk29-dataonly v1.2.04 E153的CGREG命令返回有问题,使用CREG + * ril-rk29-dataonly v1.2.05 添加内置模块mc509和几款dongle,其中国外两款dongel(其中一款等待客户测试结果) + * ril-rk29-dataonly v1.2.06 合并XXH代码 + * ril-rk29-dataonly v1.2.07 添加宏 RIL_RELEASE,用于控制未确认的模块 + * ril-rk29-dataonly v1.2.08 修正SIM卡上锁、解锁、修改密码的BUG + * ril-rk29-dataonly v1.2.09 修正SIM PUK解锁问题 + * ril-rk29-dataonly v1.2.10 增加对获取到无效DNS:10.11.12.13的检查 + * ril-rk29-dataonly v1.2.11 增加对 爱立信F3307 WCDMA modem的支持 + * ril-rk29-dataonly v1.2.12 爱立信F3307拨号脚本问题导致再次连接时候容易拨号失败 + * DNS检查代码放到更合适的位置 + * ril-rk29-dataonly v1.2.13 华为MU739支持 + * ril-rk29-dataonly v1.2.14 新增两款3G Dongle + * ril-rk29-dataonly v1.2.15 修正vodafone K3770 在国内使用的情况[可选], 添加MF631 + 使用宏控制由于ICS内核option.c变化导致在2.3上可以使用而ICS无法使用的情况 + 使用request请求号来区分修改PIN码和解锁PUK码 + * ril-rk29-dataonly v1.2.16 添加3G Dongle支持(UE660,EC122,T1731)和一款内置模块 MW100G + 修改内置3G模块UW100 2G/3G切换,在国外测试发现只能连接2G + * ril-rk29-dataonly v1.2.17 添加/修复 共3款3g dongle: Vtion E1916/Vtion U1920/正东兴LKT868 + * ril-rk29-dataonly v1.2.18 支持地图通过Modem定位,通过CREG等指定得到LAC、CID的值 + * ril-rk29-dataonly v1.2.19 测试发现LAC值需是4位数,CID值需是7位数,否则地图应用无法定位位置 + 部分modem的CID只返回4位数,需补齐为7位数 + * ril-rk29-dataonly v1.8.00 推出补丁 v1.8 + * ril-rk29-dataonly v1.8.01 修正E172使用问题 + * ril-rk29-dataonly v1.8.02 支持USI modem + * ril-rk29-dataonly v1.8.03 支持Rate EC183与SCV SEV859,但注册SEV859与其它的AT口不同 + * ril-rk29-dataonly v1.8.04 支持BSNL 3G、HW E1756 + * ril-rk29-dataonly v1.8.05 支持MMX353G、HW E1731、HW E177、HW E171、山寨的E1750、ZTE MC2718 + 山寨的E1750需要修改devices_filter.h + * ril-rk29-dataonly v1.8.06 支持Vodafone K3772-Z,需要修改VOLD ,多执行一次usb_modeswitch + * ril-rk29-dataonly v1.8.07 支持多款实创兴的3g dongle,目前发现VID/PID=0x05C6/0x6000的3g dongle + 有部分使用ttyUSB2作为AT口,而另外一部分使用ttyUSB1,拨号号都用ttyUSB0 + * ril-rk29-dataonly v1.8.08 添加dongle支持,修正部分dongle AT指令 + INTEX(0x230D, 0x000D)初始化时使用AT*ELED=1,1,0 点亮LED等 + 实创兴TD STD808/ cgmm返回NULL,上层会设置属性会报错,添加一个返回值 + * ril-rk29-dataonly v1.8.09 添加3G dongle支持 + 支持IE701 3G 内置模块使用ie701.c驱动,修改内置模块MC2718信号查询以及绕过SIM卡检测 + 印度EC156,EC122绕过SIM卡检测,添加信号手动查询,主动上报 + 印度EVDO dongle 0x12D1, 0x140B 都不需要SIM卡 + 添加一款手机Modem(0x20A6, 0x1105, "Test number"), 构造一个CIMI返回值才能正常连接3G + * ril-rk29-dataonly v1.8.10 添加3G dongle支持: + ZTE-MF193, Nokia CS-11, Onda-MSA14.4 + * ril-rk29-dataonly v1.8.11 添加短信功能支持的开关 + * ril-rk29-dataonly v1.8.12 支持Android4.1下编译 + * ril-rk29-dataonly v1.8.13 支持VID/PID相同 而AT channel不同的模块 + * ril-rk29-dataonly v1.8.14 当没有3g时,radio状态设置为RADIO_STATE_OFF,从而加快关机的速度 + * ril-rk29-dataonly v1.9.00 推出补丁1.9 + * ril-rk29-dataonly v1.9.01 修正上层信号图标显示的问题 + * ril-rk29-dataonly v2.0.01 修正中国联通3G网络名称全F的问题 + * ril-rk29-dataonly v2.0.02 模块modemEarlyInit的时候发送AT+CFUN=1指令,开启射频功能 + * ril-rk29-dataonly v2.0.03 没有3g模块或者3G模块不支持时,上报RADIO_STATE_UNAVAILABLE + 当找到3G模块并打开AT口时,上报RADIO_STATE_OFF + * ril-rk29-dataonly v2.0.04 内置模组没有SIM卡的时候,关闭模块,降低功耗 + * ril-rk29-dataonly v2.0.05 添加K3570-Z,Micromax MMX352G,Qualocomm HSPA USB MODEM MF180 3G dognle支持 + * ril-rk29-dataonly v2.1.00 推出补丁V2.1.00 + * ril-rk29-dataonly v2.1.01 推出补丁V2.1.01 印度3G dongle综合处理 + * ril-rk29-dataonly v2.1.02 添加部分新3g模块的支持 + * ril-rk29-dataonly v2.1.03 对于内置3G模组,支持AT+CFUN=0的指令,用于实现飞行模式;外置模块依然不支持该指令 + * ril-rk29-dataonly v2.1.04 部分模块主动上报的+CGREG带有"n"参数,需区别对待 + * ril-rk29-dataonly v2.1.05 增加巴西E303,Olivetti,印度 BSNL 3G dongle支持 + * ril-rk29-dataonly v2.2.00 发布V2.2.00补丁 + * ril-rk29-dataonly v2.2.01 添加实创兴MU270 + * ril-rk29-dataonly v2.2.02 添加3G dongle支持,MF669 E3131 E398 E1553 海尔 CBP7.1 3G dongle ,B150(国外) + * ril-rk29-dataonly v2.2.03 USI模块查询运营商为数字的情况(未发布) + * ril-rk29-dataonly v2.2.05 添加迪拜3G dongle支持(测试中) + (0x1C9E,0x9915, "HSDPA mobile station)发送AT+CGACT出现随机性失败,导致拨号不成功,过滤掉该AT指令 + * ril-rk29-dataonly v2.2.06 增加多款国外Speedup 3G dongle,印度LW272,EVDO AC2787(NO SIM Card),E303D + * ril-rk29-dataonly v2.2.07 印度测试龙尚模块只连接2G,HUAWEI E303C(modemid=E303S) + speedup 3G dongle只能连接一次3G,修改Option.c + operator_table添加MTS运营商MCC/NCC + * ril-rk29-dataonly v2.2.08 山寨dognle CGREG=2,0 olivetti 3G dognle 切换脚本修改,解决内核崩溃问题 + 修改call-pppd脚本,使得手机那边也可以用dataonly.so库 + * ril-rk29-dataonly v2.2.09 add ioctrl to get usi imei + 添加3G Dongle MULTI_RIL LIB 支持 + 可以正常切换,但以前我们支持的dongle发现会有不支持情况, + * ril-rk29-dataonly v2.2.10 修改ZTE EVDO 库使用后其他/dev/ttyUSB1无法使用的BUG + + * ril-rk29-dataonly v2.2.11 修改部分dongle一直获取无效DNS的情况,使用"8.8.8.8"带设置net.dns1,net dns2 + 进过验证方法可行 + + * ril-rk29-dataonly v2.3.00 add MMX144F/MF652/MF193/MF190U/MF667/Airis/DMW-156/GI1515/E220/MMX377GG 3G dongle support + MF195,WM66E,E303需要在国外测试后再更新 + * ril-rk29-dataonly v2.3.01 USI MT6229 CGERG主动上报修改,驱动修改对AP_READY引脚的控制 + E3231/E1780 3g DONGLE + + * ril-rk29-dataonly v2.3.02 支持展讯U7501 WCDMA 3G modem + 支持华为E1230 WCDMA 3G Modem + 支持C218D EVDO 3G modem(厂商测试中) + + * ril-rk29-dataonly v2.3.03 不插SIM卡,在查询到IMEI后才关闭内置模块电源 + MC509-A 使用AT^PPPCFG配置user password + + * ril-rk29-dataonly v2.3.04 修正在设置里面查询运营商,2G/3G无法区分的问题,和搜索报错的BUG + * ril-rk29-dataonly v2.3.05 添加ZTE免驱数据卡支持, + 添加DHCP方式拨号 + 添加LTE MESSI DHCP拨号 + * ril-rk29-dataonly v2.3.06 添加REQUEST_SIM_IO操作 + 添加两款UNA+ DONGLE(0X00A7/0X00A5),SCV HSPS+ + * ril-rk29-dataonly v2.3.07 修改CALL-PPPD脚本,修正采用PAP鉴权无效的情况 + + * ril-rk29-dataonly v2.3.08 解决部分内置模块,RILD概率挂掉的情况,解决方法:添加kill_rild方法 + + * ril-rk29-dataoly v2.3.09 部分donngle在拨号阶段AT+CGDCONT返回ERROR,导致拨号失败, + 有两种解决办法: + 1.过滤该指令 + 2.不去检测返回值是否OK(beta 1) + 3.整合了大部分ZTE WCDMA 3G dongle + + * ril-rk29-dataoly v2.3.10 1.支持中兴NCM驱动LTE dongle ,使用chcpcd usb0方式 + 2.驱动AT+CGACT返回值检查,避免拨号失败 + + * ril-rk29-dataoly v3.1.00 1.zte DC-LTE数据卡,使用modem拨号 + * ril-rk29-dataoly v3.2.00 1.and network type 13 + **********************************************************************************/ +// +#include +#define MULTI_RIL_LIB 0 +#if (RIL_VERSION >= 6) +#define RIL_CardStatus RIL_CardStatus_v6 +#define RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED +#define RIL_REQUEST_REGISTRATION_STATE RIL_REQUEST_VOICE_REGISTRATION_STATE +#define RIL_REQUEST_GPRS_REGISTRATION_STATE RIL_REQUEST_DATA_REGISTRATION_STATE +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "atchannel.h" +#include "at_tok.h" +#include "misc.h" +#include +#include +#include +#include + +#include +#include + +#include +#include "extend_at_func.h" +#include "modem_define_func.h" +#include "operator_table.h" +#include "modem_list.h" +#include "gsm.h" +#include +#include "config.h" +#include "telephony/config.h" +static const char* REFERENCE_RIL_VERSION = "RIL_RK_DATA_V3.5" +#ifndef RIL_RELEASE + " [debug version]" +#endif +#if !ENABLE_DNS_CHECK + " [!DNS]" +#endif +#if SUPPORT_SMS + " [SMS]" +#endif +; + +#define DBG_1 + +#define LOG_NDEBUG 0 +#define LOG_TAG "RIL_RK_DATA_V3.5" +#include + +#define MAX_AT_RESPONSE 0x1000 + +#define RIL_REQUEST_SEND_SMS_EXTENDED 512 + +#define PPP_TTY_PATH "ppp0" + +#define OPERATOR_TABLE_PATH "/etc/operator_table" + +#ifdef ENABLE_STAY_AWAKE +#include +static const char *WAKE_LOCK_ID = "ril-rk29-dataonly"; +#endif + +#ifdef USE_TI_COMMANDS + +// Enable a workaround +// 1) Make incoming call, do not answer +// 2) Hangup remote end +// Expected: call should disappear from CLCC line +// Actual: Call shows as "ACTIVE" before disappearing +#define WORKAROUND_ERRONEOUS_ANSWER 1 + +// Some varients of the TI stack do not support the +CGEV unsolicited +// response. However, they seem to send an unsolicited +CME ERROR: 150 +#define WORKAROUND_FAKE_CGEV 1 +#endif + +#define SUPPORT_MODEM_TYPE_NONE 0 +#define SUPPORT_MODEM_TYPE_EVDO 1 +#define SUPPORT_MODEM_TYPE_WCMDA 2 +#define SUPPORT_MODEM_TYPE_TDSCDMA 4 + + +#define MODEM_CONTRL_PATH "/dev/voice_modem" +#define BP_IOCTL_BASE 0x1a +#define BP_IOCTL_RESET _IOW(BP_IOCTL_BASE, 0x01, int) +#define BP_IOCTL_POWOFF _IOW(BP_IOCTL_BASE, 0x02, int) +#define BP_IOCTL_POWON _IOW(BP_IOCTL_BASE, 0x03, int) +#define BP_IOCTL_WRITE_STATUS _IOW(BP_IOCTL_BASE, 0x04, int) +#define BP_IOCTL_GET_STATUS _IOR(BP_IOCTL_BASE, 0x05, int) +#define BP_IOCTL_SET_PVID _IOW(BP_IOCTL_BASE, 0x06, int) +#define BP_IOCTL_GET_BPID _IOR(BP_IOCTL_BASE, 0x07, int) +#define BP_IOCTL_GET_IMEI _IOR(BP_IOCTL_BASE, 0x08, int) +char IMEI_value[17]; +static int sSupportModemType = SUPPORT_MODEM_TYPE_EVDO|SUPPORT_MODEM_TYPE_WCMDA|SUPPORT_MODEM_TYPE_TDSCDMA; + + +typedef enum { + SIM_ABSENT = 0, + SIM_NOT_READY = 1, + SIM_READY = 2, /* SIM_READY means the radio state is RADIO_STATE_SIM_READY */ + SIM_PIN = 3, + SIM_PUK = 4, + SIM_NETWORK_PERSONALIZATION = 5, + RUIM_ABSENT = 6, + RUIM_NOT_READY = 7, + RUIM_READY = 8, + RUIM_PIN = 9, + RUIM_PUK = 10, + RUIM_NETWORK_PERSONALIZATION = 11 +} SIM_Status; + +static void onRequest (int request, void *data, size_t datalen, RIL_Token t); +static RIL_RadioState currentState(); +static int onSupports (int requestCode); +static void onCancel (RIL_Token t); +static const char *getVersion(); +static int isRadioOn(); +static SIM_Status getSIMStatus(); +static int getCardStatus(RIL_CardStatus **pp_card_status); +static void freeCardStatus(RIL_CardStatus *p_card_status); +static void onDataCallListChanged(void *param); +static void closeATReader(); +static void onATReaderClosed(); +static int findModem(int vid, int pid, const char* modemID, RIL_ModemInterface** modem); +static char* getModelID(); +static void kill_rild(); +static int kill_pppd(); +extern const char * requestToString(int request); +static int GetIMSI(char* imsi); + + +/*** Static Variables ***/ +static const RIL_RadioFunctions s_callbacks = { + RIL_VERSION, + onRequest, + currentState, + onSupports, + onCancel, + getVersion +}; + +#ifdef RIL_SHLIB +static const struct RIL_Env *s_rilenv; + +#define RIL_onRequestComplete(t, e, response, responselen) s_rilenv->OnRequestComplete(t,e, response, responselen) +#define RIL_onUnsolicitedResponse(a,b,c) s_rilenv->OnUnsolicitedResponse(a,b,c) +#define RIL_requestTimedCallback(a,b,c) s_rilenv->RequestTimedCallback(a,b,c) +#endif + +/* + 当RIL_ATMONITOR的属性 设为 'y' 时,将不对model发送命令 + */ +#define RIL_ATMONITOR "rild.debug.atmonitor" + +/* + 若指定了设备,则系统将使用指定的设备作为atchannel。 + */ +#define RIL_ATCHANNEL "ril.atchannel" + +/* 当连接到网络后,该属性存放本地IP + */ +#define RIL_LOCAL_IP "net.ppp0.local-ip" +#define RIL_LOCAL_GW "net.ppp0.gw" + +static RIL_ModemInterface* s_current_modem = NULL; + +static RIL_RadioState sState = RADIO_STATE_UNAVAILABLE; + +static pthread_mutex_t s_state_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t s_state_cond = PTHREAD_COND_INITIALIZER; + +static int s_port = -1; +static const char * s_device_path = NULL; +static int s_device_socket = 0; + +/* trigger change to this with s_state_cond */ +static int s_closed = 0; + +static int sFD; /* file desc of AT channel */ +static char sATBuffer[MAX_AT_RESPONSE+1]; +static char *sATBufferCur = NULL; +static char *sNITZtime = NULL; + +static const struct timeval TIMEVAL_SIMPOLL = {1,0}; +static const struct timeval TIMEVAL_CALLSTATEPOLL = {0,500000}; +static const struct timeval TIMEVAL_0 = {0,0}; + +/* + 在匹配modem型号时,如果modem的VID/PID有多个匹配,则先取第一个匹配作初始化。 + 在初始化后期,再通过查询到的modem id进行精确匹配。 +*/ +static int sMmodemRematch = 0; + +#ifdef WORKAROUND_ERRONEOUS_ANSWER +// Max number of times we'll try to repoll when we think +// we have a AT+CLCC race condition +#define REPOLL_CALLS_COUNT_MAX 4 + +// Line index that was incoming or waiting at last poll, or -1 for none +static int s_incomingOrWaitingLine = -1; +// Number of times we've asked for a repoll of AT+CLCC +static int s_repollCallsCount = 0; +// Should we expect a call to be answered in the next CLCC? +static int s_expectAnswer = 0; +#endif /* WORKAROUND_ERRONEOUS_ANSWER */ + +static void pollSIMState (void *param); +static void setRadioState(RIL_RadioState newState); + +static int rematchModem(const char* modemID, const char* atchannel); + +static int isgsm=0; +static int isEth=0; +static char *callwaiting_num; + +/* + 关于信号 CDMA/GSM/UMTS 都使用 AT+CSQ,EVDO使用AT^HDRCSQ查询 + 主动上报的信号值,"^RSSI:"、"^RSSILVL:"这两种值存放在signalStrength, "^HRSSILVL:"存放在signalStrength_hdr + */ +static int signalStrength_hdr[2]; +static int signalStrength[2]; + +// 记住当前模块的IMSI,以便CDMA查询Operator时用 +static char IMSI[20]; + +static int s_cur_vid; +static int s_cur_pid; +static char s_cur_atchannel[64] = ""; +static char s_cur_pppchannel[64] = ""; + +//static pthread_mutex_t s_waitmutex = PTHREAD_MUTEX_INITIALIZER; +//static pthread_cond_t s_waitcond = PTHREAD_COND_INITIALIZER; + + +/* + restricted state: + RIL_RESTRICTED_STATE_NONE + RIL_RESTRICTED_STATE_CS_EMERGENCY + RIL_RESTRICTED_STATE_CS_NORMAL + RIL_RESTRICTED_STATE_CS_ALL + RIL_RESTRICTED_STATE_PS_ALL + */ +static int s_restricted_state=RIL_RESTRICTED_STATE_NONE; + +static int s_reg_stat=-1; +static int s_reg_rat=-1; +static int s_greg_stat=-1; +static int s_sys_mode=-1; + +static int tryCount = 0; + +int g_fileid = -1; +char g_smspath[64] = {0}; + +static pthread_t s_tid_pppdState; +static pthread_mutex_t s_waitmutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t s_waitcond = PTHREAD_COND_INITIALIZER; +static int s_pppd_exception = 0; +static int nosimcard =0; +static int s_first_dialup = 1; +static int sim_pin =0; +#define ETH_OPERSTATE_PATH "/sys/class/net/lte0/operstate" +#define SERVICE_LTE "lteup" +#define PPP_ETH_PATH "lte0" +#define POLL_PPP_SYSFS_RETRY 3 +#define POLL_PPP_SYSFS_SECONDS 3 + +extern int dhcp_do_request(const char *ifname, + in_addr_t *ipaddr, + in_addr_t *gateway, + in_addr_t *mask, + in_addr_t *dns1, + in_addr_t *dns2, + in_addr_t *server, + uint32_t *lease); + +extern int dhcp_stop(const char *interface); + +static void *pppdStateLoop(void *param) +{ + // char value[64] = ""; + char value[PROPERTY_VALUE_MAX]; + char dns1[PROPERTY_VALUE_MAX]; + char dns2[PROPERTY_VALUE_MAX]; + // char dns1[64]=""; + // char dns2[64]=""; + s_pppd_exception = 0; + LOGD("[%s]: begin pppd state monitor", __FUNCTION__); + while( ETIMEDOUT==pthread_cond_timeout_np(&s_waitcond, &s_waitmutex, 3000) ) + { + property_get("net.gprs.ppp-exit", value, ""); + if(value[0]) + { + LOGD("[%s] pppd: exception exited", __FUNCTION__); + s_pppd_exception = 1; + // if(0 == modem_cmp(0x106C, 0x3718, NULL)) + // at_emulate_exit(); + RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL); + break; + } + value[0] = 0; + +#if ENABLE_DNS_CHECK + ///xxh:处理DNS获取不正确的情况 + property_get("net.dns1", dns1, ""); + property_get("net.dns2", dns2, ""); + if(!strncmp(dns1,"10.11.12.13",strlen("10.11.12.13")) && + !strncmp(dns2,"10.11.12.14",strlen("10.11.12.14"))) + { + // LOGD("[%s] DNS not correct ! pppd: exception exited", __FUNCTION__); + //s_pppd_exception = 1; + // RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL); + LOGD("[%s] the Server give worng DNS ,set to Generic", __FUNCTION__); + property_set("net.dns1", "8.8.8.8"); + property_set("net.dns2", "8.8.8.8"); + property_set("net.ppp0.dns1", "8.8.8.8"); + property_set("net.ppp0.dns2", "8.8.8.8"); + } +#endif + } + + LOGD("[%s] exit pppdStateLoop, s_pppd_exception=%d", __FUNCTION__, s_pppd_exception); + + return 0; +} + +/* + 1 support + 0 unsupport + */ +int is_support_modem_type(int type) +{ + int ret = SUPPORT_MODEM_TYPE_NONE; + + if(type == RADIO_TYPE_EVDO) + ret = sSupportModemType&SUPPORT_MODEM_TYPE_EVDO; + else if(type == RADIO_TYPE_WCDMA) + ret = sSupportModemType&SUPPORT_MODEM_TYPE_WCMDA; + else if(type == RADIO_TYPE_TDSCDMA) + ret = sSupportModemType&SUPPORT_MODEM_TYPE_TDSCDMA; + + return ret?1:0; +} + + +/* + 参数: + vid: 一个正数,若不想比较该值可给负数 + pid: 一个正数,若不想比较该值可给负数 + name: 一个字符串,若不想比较该值可给NULL + 相同返回 0 + 不同返回 非0 + */ +int modem_cmp(int vid, int pid, const char* name) +{ + if( vid>=0 && s_current_modem->modem_info.vid != vid ) + return !0; + if( pid>=0 && s_current_modem->modem_info.pid != pid ) + return !0; + if( name!=NULL && strcmp(s_current_modem->modem_info.model_id,name) ) + return !0; + + return 0; +} + +#define EATCHAR(x, c) for (; *(x) == (c); (x)++) ; // 去除字符串x中左边为c的字符 +/* -1:error. */ +static int atox( const char * line, int f_base ) +{ + int base = 10; + char max = '9'; + int v = 0; + + EATCHAR(line, ' '); + if(*line == 0) return 0; + + if( line[1] == 'x' || line[1] == 'X' ){ + base = 16; + max = 'f'; /* F*/ + line += 2; + } + else if(f_base==16) + { + base = 16; + max = 'f'; /* F*/ + } + + if( base == 10 ) { + while( *line >= '0' && *line <= max ) { + v *= base ; + v += *line-'0'; + line++; + } + } else { + while( *line >= '0' && *line <= max ) { + v *= base ; + if( *line >= 'a' ) + v += *line-'a'+10; + else if ( *line >= 'A' ) + v += *line-'A'+10; + else + v += *line-'0'; + line++; + } + } + return v; +} + +RIL_RadioType getCurModelRadio() +{ + return s_current_modem->radioType; +} + +static const char* networkStatusToRilString(int state) +{ + switch(state){ + case 0: return("unknown"); break; + case 1: return("available"); break; + case 2: return("current"); break; + case 3: return("forbidden"); break; + default: return NULL; + } +} + +static void sleepMsec(long long msec) +{ + struct timespec ts; + int err; + + ts.tv_sec = (msec / 1000); + ts.tv_nsec = (msec % 1000) * 1000 * 1000; + + do { + err = nanosleep (&ts, &ts); + } while (err < 0 && errno == EINTR); +} + +/* + 用于确认modem是否能收发AT指令,正常则返回0 + 要求: 发送下去的at指令,必须返回"OK",否则说明失败 + */ +static int check_at_ready(const char* at, int count) +{ + int err; + ATResponse *p_response = NULL; + int i; + + for (i = 0 ; i < count ; i++) { + err = at_send_command(at, &p_response); + if (err < 0 || p_response->success == 0) { + err = 1; + sleepMsec(250); + } + else + { + err = 0; + break; + } + } + + at_response_free(p_response); + + return err; +} + + +/** do post-AT+CFUN=1 initialization */ +/* + 此时AT+CFUN=1,接着应判断SIM状态,直到SIM卡状态为READY + */ +static void onRadioPowerOn() +{ +// 进行AT握手 + if(check_at_ready("AT", 32)) + { + LOGE("AT handshake failed!!!"); + return; + } + +// 查询SIM卡状态 + pollSIMState(NULL); +} + +/** do post- SIM ready initialization */ +/* + 当SIM ready后,此时可进行更多的初始化 + */ +static void onSIMReady() +{ +// 确认模块型号 + if( sMmodemRematch ) + { + // 查询modem id + char* modemID = getModelID(); + RLOGD("Current modem id is: %s", modemID); + // 根据modem id 以及AT channel,确认 modem 型号 + int match_count = rematchModem(modemID, s_current_modem->atchannel_index); + + RLOGD("[%s]: match model count=%d", __FUNCTION__, match_count); + if( match_count != 1 || !is_support_modem_type(s_current_modem->radioType)) + { + // 没有找到匹配的modem,设radio状态为RADIO_STATE_UNAVAILABLE,上层不再下发指令 + RLOGE("Can not match modem!!!"); + setRadioState (RADIO_STATE_UNAVAILABLE); + return; + } + // cmy@20110818: 已经匹配完成,将sMmodemRematch清0 + sMmodemRematch = 0; + } + + switch(s_current_modem->radioType) + { + case RADIO_TYPE_CDMA: + case RADIO_TYPE_EVDO: + isgsm = 0; + break; + case RADIO_TYPE_GSM: + case RADIO_TYPE_WCDMA: + case RADIO_TYPE_TDSCDMA: + default: + isgsm = 1; + break; + } + + LOGD("[%s] isgsm:%d", __FUNCTION__, isgsm); +//s property_set("ril.radio.type", isgsm?"gsm":"cdma"); + +// modem 进行初始化 + s_current_modem->modemDefFunc->initModem(); +} +int hexCharToInt(char c) +{ + if (c >= '0' && c <= '9') + return (c - '0'); + if (c >= 'A' && c <= 'F') + return (c - 'A' + 10); + if (c >= 'a' && c <= 'f') + return (c - 'a' + 10); + return 0; +} + + +/************************************************ + Function: hexStringToBytes + Description: + 16进制字符数组转换为字节数组, "ABCD" ---> {0xAB,0xCD} + Calls: + Called By: + request_send_ussd, request_sim_io, cdma_pdu_decode + Input: + 16进制字符数组,16进制字符数组长度 + Output: + 字节数组 + Return: + 字节数组长度 + Others: +**************************************************/ +int hexStringToBytes(char * s,char *hs ,int len) +{ + int i; + if (s == 0) return -1; + + int sz = strlen(s); + + for (i=0 ; i = len) + return -1; + hs[i/2] = (char) ((hexCharToInt(s[i]) << 4) + | hexCharToInt(s[i+1])); + } + return (sz+1) / 2; +} +static char *StrToUpper(char * str) +{ + if( NULL == str) + { + return NULL; + } + char *s=str; + + while(*s != '\0') + { + if(*s <= 'z' && *s >= 'a' ) + { + *s=*s-('a'-'A'); + } + s++; + } + return str; +} + + +static void requestSIM_IO(void *data, size_t datalen, RIL_Token t) +{ + int err; + char *cmd = NULL; + char *line; + char hs[20]; + unsigned short file_size; + RIL_SIM_IO_Response sr; + ATResponse *p_response = NULL; + + memset(&sr, 0, sizeof(sr)); + + if( NULL == data ) + goto error; + + RIL_SIM_IO_v6 *p_args; + p_args = (RIL_SIM_IO_v6 *)data; + if(p_args->path != NULL){ + if((strlen(p_args->path)%4) != 0) + goto error; + } + + if(p_args->data != NULL) + { + p_args->data = StrToUpper(p_args->data); + } + + /* FIXME handle pin2 */ + // goto sim_io_error; + //modified by wkf32792 begin for DTS2011062001722 + + /* Begin to modify by hexiaokong kf39947 for DTS2011122605765 2012-01-13*/ + if (p_args->data == NULL) { + asprintf(&cmd, "AT+CRSM=%d,%d,%d,%d,%d,,\"%s\"", + p_args->command, p_args->fileid, + p_args->p1, p_args->p2, p_args->p3, p_args->path); + + if(p_args->fileid == 28476) + { + sprintf(g_smspath,"%s",p_args->path); + g_fileid = p_args->fileid; + } + + } else { + asprintf(&cmd, "AT+CRSM=%d,%d,%d,%d,%d,\"%s\",\"%s\"", + p_args->command, p_args->fileid, + p_args->p1, p_args->p2, p_args->p3, p_args->data, p_args->path); // p_args->p1获取的响应时间,是不是对ril有影响 + + if(p_args->fileid == 28476) + { + sprintf(g_smspath,"%s",p_args->path); + g_fileid = p_args->fileid; + } + + } //modified by wkf32792 end for DTS2011062001722 + /* End to modify by hexiaokong kf39947 for DTS2011122605765 2012-01-13*/ + + err = at_send_command_singleline(cmd, "+CRSM:", &p_response); + + if (err < 0 || p_response->success == 0) { + goto error; + } + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &(sr.sw1)); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &(sr.sw2)); + if (err < 0) goto error; + + if (at_tok_hasmore(&line)) { + err = at_tok_nextstr(&line, &(sr.simResponse)); + if (err < 0) goto error; + + + if(('6' == sr.simResponse[0]) + && ('2' == sr.simResponse[1]) + && 192 ==p_args->command + && ('0' == sr.simResponse[6]) + && ('5' == sr.simResponse[7])) + { //usim card + + LOGD("USIM : sr.simResponse = %s,len=%d",sr.simResponse,strlen(sr.simResponse)); + + hexStringToBytes(sr.simResponse,hs,15); + + sr.simResponse[0] = '0'; + sr.simResponse[1] = '0'; + sr.simResponse[2] = '0'; + sr.simResponse[3] = '0'; + //file_size = Record length * Number of records + file_size = ((hs[6]<<8)+hs[7]) * hs[8]; + //copy file size + sprintf(&(sr.simResponse[4]),"%04x",file_size); + //copy file id + sr.simResponse[8] = sr.simResponse[22]; + sr.simResponse[9] = sr.simResponse[23]; + sr.simResponse[10] = sr.simResponse[24]; + sr.simResponse[11] = sr.simResponse[25]; + //TYPE_EF RESPONSE_DATA_FILE_TYPE + sr.simResponse[13] = '4'; + //EF_TYPE_LINEAR_FIXED RESPONSE_DATA_STRUCTURE + sr.simResponse[26] = '0'; + sr.simResponse[27] = '1'; + //Record length + sr.simResponse[28] = sr.simResponse[14]; + sr.simResponse[29] = sr.simResponse[15]; + sr.simResponse[30] = 0x0;//the end + LOGD("response simResponse = %s,len=%d",sr.simResponse,strlen(sr.simResponse)); + + } + + } + + RIL_onRequestComplete(t, RIL_E_SUCCESS, &sr, sizeof(sr)); + at_response_free(p_response); + free(cmd); + return; + +error: + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + if(p_response != NULL) + { + at_response_free(p_response); + } + free(cmd); + cmd = NULL; + return; +} + +/* + radio 的 on/off 应该只是在开启/关闭 飞行模式时被调用到 + */ +static void requestRadioPower(void *data, size_t datalen, RIL_Token t) +{ +// onOff: 0 - OFF, 1 - ON + int onOff; + + int err; + ATResponse *p_response = NULL; + + assert (datalen >= sizeof(int *)); + onOff = ((int *)data)[0]; + +#ifdef DBG_1 + LOGD("[%s]: sState=%d onOff=%d\n", __FUNCTION__, sState, onOff); +#endif + + if (onOff == 0 && sState != RADIO_STATE_OFF) { + if (s_current_modem->inner == 0) + { + LOGD("[%s]: not support 'AT+CFUN=0'\n", __FUNCTION__); + // setRadioState(RADIO_STATE_SIM_NOT_READY); + setRadioState(RADIO_STATE_OFF); + } + else + { + err = at_send_command("AT+CFUN=0", &p_response); + if (err < 0 || p_response->success == 0) goto error; + setRadioState(RADIO_STATE_OFF); + } + } else if (onOff > 0 && sState == RADIO_STATE_OFF) { + //if( 0 == modem_cmp(0x19D2, 0xFFFE, "MC8630") ) + // err = at_send_command("AT+CFUN=3", &p_response); + // else + err = at_send_command("AT+CFUN=1", &p_response); + if (err < 0|| p_response->success == 0) { + // Some stacks return an error when there is no SIM, + // but they really turn the RF portion on + // So, if we get an error, let's check to see if it + // turned on anyway + + if (isRadioOn() != 1) { + goto error; + } + } + LOGD("[%s]: sleep %ds befor open %s", __FUNCTION__, s_current_modem->initWaitTime, s_current_modem->atchannel_index); + sleep(s_current_modem->initWaitTime); + setRadioState(RADIO_STATE_SIM_NOT_READY); + } + + at_response_free(p_response); + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + return; +error: + at_response_free(p_response); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); +} + +static void requestOrSendDataCallList(RIL_Token *t); + +static void onDataCallListChanged(void *param) +{ + requestOrSendDataCallList(NULL); +} + +static void requestDataCallList(void *data, size_t datalen, RIL_Token t) +{ + requestOrSendDataCallList(&t); +} + +#if (RIL_VERSION >= 6) +static void requestOrSendDataCallList(RIL_Token *t) +{ + LOGD("%s ===Enter===",__FUNCTION__); + if(!modem_cmp(0x05c6,0x9025,NULL)){ + ATResponse *p_response; + RIL_Data_Call_Response_v6 *responses; + ATLine *p_cur; + int err; + int n = 1; + responses = alloca(sizeof(RIL_Data_Call_Response_v6)); + responses[0].status = 0; + responses[0].suggestedRetryTime = -1; + responses[0].cid = 1; + responses[0].active = 1; + responses[0].type = "IP"; + responses[0].ifname = "lte0"; + responses[0].addresses = "0.0.0.0";//ip_address; + responses[0].dnses = ""; + responses[0].gateways = ""; + if (t != NULL) + RIL_onRequestComplete(*t, RIL_E_SUCCESS, responses, + n * sizeof(RIL_Data_Call_Response_v6)); + else + RIL_onUnsolicitedResponse(RIL_UNSOL_DATA_CALL_LIST_CHANGED, + responses, + n * sizeof(RIL_Data_Call_Response_v6)); + + + }else + {ATResponse *p_response; + RIL_Data_Call_Response_v6 *responses; + ATLine *p_cur; + int err; + int n = 0; + char *out =NULL; + + LOGD("%s ===enter else===",__FUNCTION__); +//XXH:CID 与上次连接的不一致,导致上层会断开上次连接,再拨号 +//XXH:MF190 AT+CGACT?上报 +CGACT: 1,0,导致连接断开 + if (isgsm &&modem_cmp(0x19D2, 0x0167, "MF820") + && modem_cmp(0x12d1, 0x1506, "E303") + && modem_cmp(0x12d1, 0x1506, "E303C") + && modem_cmp(0x12d1, 0x1506, "E3131") + && modem_cmp(0x12D1, 0x1506, "E173") + && modem_cmp(0x12d1, 0x1001, "E122") + && modem_cmp(0x12D1, 0x1506, "E357") + && modem_cmp(0x12d1, 0x0117, "MF190") + && modem_cmp(0x12d1, 0x1001, "K3772") + && modem_cmp(0x12d1, 0x1001, "E1750") + && modem_cmp(0x1782, 0x0002, "V1.0.1-B7") + && modem_cmp(0x12d1, 0x140c, "E261") + && modem_cmp(0x21F5, 0x2012, "SPW9P") + && !modem_cmp(0x19D2, 0x2003, "MF667") + && !modem_cmp(0x19D2, 0x0117, "MF667") + && !modem_cmp(0x19D2, 0x1405, "MF667")) { + err = at_send_command_multiline ("AT+CGACT?", "+CGACT:", &p_response); + if (err != 0 || p_response->success == 0) { + if (t != NULL) + RIL_onRequestComplete(*t, RIL_E_GENERIC_FAILURE, NULL, 0); + else + RIL_onUnsolicitedResponse(RIL_UNSOL_DATA_CALL_LIST_CHANGED, + NULL, 0); + return; + } + + for (p_cur = p_response->p_intermediates; p_cur != NULL; + p_cur = p_cur->p_next) + n++; + + responses = alloca(n * sizeof(RIL_Data_Call_Response_v6)); + + int i; + for (i = 0; i < n; i++) { + + responses[i].status = -1; + responses[i].suggestedRetryTime = -1; + responses[i].cid = -1; + responses[i].active = -1; + responses[i].type = ""; + responses[i].ifname = ""; + responses[i].addresses = ""; + responses[i].dnses = ""; + responses[i].gateways = ""; + } + + RIL_Data_Call_Response_v6 *response = responses; + for (p_cur = p_response->p_intermediates; p_cur != NULL; + p_cur = p_cur->p_next) { + char *line = p_cur->line; + + err = at_tok_start(&line); + if (err < 0) + goto error; + + err = at_tok_nextint(&line, &response->cid); + if (err < 0) + goto error; + err = at_tok_nextint(&line, &response->active); + if (err < 0) + goto error; + if(response->active == 1 ||response->active==0){ + ALOGD("Foce active to 2............."); + response->active = 2; + } + response++; + + } + + at_response_free(p_response); + + err = at_send_command_multiline ("AT+CGDCONT?", "+CGDCONT:", &p_response); + if (err != 0 || p_response->success == 0) { + if (t != NULL) + RIL_onRequestComplete(*t, RIL_E_GENERIC_FAILURE, NULL, 0); + else + RIL_onUnsolicitedResponse(RIL_UNSOL_DATA_CALL_LIST_CHANGED, + NULL, 0); + return; + } + + for (p_cur = p_response->p_intermediates; p_cur != NULL; + p_cur = p_cur->p_next) { + char *line = p_cur->line; + int cid; + + err = at_tok_start(&line); + if (err < 0) + goto error; + + err = at_tok_nextint(&line, &cid); + if (err < 0) + goto error; + + for (i = 0; i < n; i++) { + if (responses[i].cid == cid) + break; + } + + if (i >= n) { + /* details for a context we didn't hear about in the last request */ + continue; + } + + // Assume no error + responses[i].status = 0; + + // type + err = at_tok_nextstr(&line, &out); + if (err < 0) + goto error; + responses[i].type = alloca(strlen(out) + 1); + strcpy(responses[i].type, out); + + // APN ignored for v5 + err = at_tok_nextstr(&line, &out); + if (err < 0) + goto error; + + responses[i].ifname = alloca(strlen(PPP_TTY_PATH) + 1); + strcpy(responses[i].ifname, PPP_TTY_PATH); + + //xxh: 对于部分3G dongel AT+CGDCONT?命令返回的pdp addres为空null,导致上层报增加处理 + + err = at_tok_nextstr(&line, &out); + if (err < 0) + goto error; + if ('\0' == out[0]) + { + responses[i].addresses = (char *)alloca(strlen("0.0.0.0")+1); + strcpy(responses[i].addresses, "0.0.0.0"); + } + else + { + responses[i].addresses = alloca(strlen(out) + 1); + strcpy(responses[i].addresses, out); + } + } + + at_response_free(p_response); + + } else { + //CDMA + n = 1; + responses = alloca(sizeof(RIL_Data_Call_Response_v6)); + responses[0].status = 0; + responses[0].suggestedRetryTime = -1; + responses[0].cid = 1; + responses[0].active = 1; + responses[0].type = "IP"; + responses[0].ifname = "ppp0"; + responses[0].addresses = "0.0.0.0";//ip_address; + responses[0].dnses = ""; + responses[0].gateways = ""; + + } + + if(s_pppd_exception) + { + /* 设置active=0,以使上层知道pppd已经被自动退出,从而更新状态栏并下发命令重新连接。 + */ + LOGD("data state force set to 0"); + int i; + for(i=0; isuccess == 0) { + if (t != NULL) + RIL_onRequestComplete(*t, RIL_E_GENERIC_FAILURE, NULL, 0); + else + RIL_onUnsolicitedResponse(RIL_UNSOL_DATA_CALL_LIST_CHANGED, + NULL, 0); + return; + } + + for (p_cur = p_response->p_intermediates; p_cur != NULL; + p_cur = p_cur->p_next) + n++; + + responses = alloca(n * sizeof(RIL_Data_Call_Response)); + + int i; + for (i = 0; i < n; i++) { + responses[i].cid = -1; + responses[i].active = -1; + responses[i].type = ""; + responses[i].apn = ""; + responses[i].address = ""; + } + + RIL_Data_Call_Response *response = responses; + for (p_cur = p_response->p_intermediates; p_cur != NULL; + p_cur = p_cur->p_next) { + char *line = p_cur->line; + + err = at_tok_start(&line); + if (err < 0) + goto error; + + err = at_tok_nextint(&line, &response->cid); + if (err < 0) + goto error; + + err = at_tok_nextint(&line, &response->active); + if (err < 0) + goto error; + + response++; + } + + at_response_free(p_response); + + err = at_send_command_multiline ("AT+CGDCONT?", "+CGDCONT:", &p_response); + if (err != 0 || p_response->success == 0) { + if (t != NULL) + RIL_onRequestComplete(*t, RIL_E_GENERIC_FAILURE, NULL, 0); + else + RIL_onUnsolicitedResponse(RIL_UNSOL_DATA_CALL_LIST_CHANGED, + NULL, 0); + return; + } + + for (p_cur = p_response->p_intermediates; p_cur != NULL; + p_cur = p_cur->p_next) { + char *line = p_cur->line; + int cid; + char *type; + char *apn; + char *address; + + + err = at_tok_start(&line); + if (err < 0) + goto error; + + err = at_tok_nextint(&line, &cid); + if (err < 0) + goto error; + + for (i = 0; i < n; i++) { + if (responses[i].cid == cid) + break; + } + + if (i >= n) { + /* details for a context we didn't hear about in the last request */ + continue; + } + + err = at_tok_nextstr(&line, &out); + if (err < 0) + goto error; + + responses[i].type = alloca(strlen(out) + 1); + strcpy(responses[i].type, out); + + err = at_tok_nextstr(&line, &out); + if (err < 0) + goto error; + + responses[i].apn = alloca(strlen(out) + 1); + strcpy(responses[i].apn, out); + + err = at_tok_nextstr(&line, &out); + if (err < 0) + goto error; + + responses[i].address = alloca(strlen(out) + 1); + strcpy(responses[i].address, out); + } + + at_response_free(p_response); + } else { + //CDMA + n = 1; + responses = alloca(sizeof(RIL_Data_Call_Response)); + responses[0].cid = 1; + responses[0].active = 1; + responses[0].address = ""; + responses[0].type = "internet"; + responses[0].apn = ""; + + } + if(s_pppd_exception) + { + /* 设置active=0,以使上层知道pppd已经被自动退出,从而更新状态栏并下发命令重新连接。 + */ + LOGD("data state force set to 0"); + int i; + for(i=0; isuccess == 0) + goto error; + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + if( err < 0) + line = p_response->p_intermediates->line; +// else if(strncmp(p_response->p_intermediates->line, prex, strlen(prex))) + else if( !strstr(p_response->p_intermediates->line, prex) ) + continue; + + err = at_tok_nextstr(&line, &response); + if (err < 0) + continue; + //实创兴0x21f5, 0x1101 dongle返回的CGMM为空,导致上层处理出错,这里手动赋值基带信息 + if(0 == modem_cmp(0x21f5, 0x1101, NULL)) + { + response="StrongRsing"; + } + asprintf(&result, "%s", response); + LOGD("[%s]: result=%s", __FUNCTION__, result); + break; + } + + if( try_count<0 ) + goto error; + + at_response_free(p_response); + return result; + +error: + LOGD("[%s]: error=%d", __FUNCTION__, err); + at_response_free(p_response); + return NULL; +} + +#if 1 +/* + cmy: 该函数调用是在 SIM Ready 之后 + */ +static char* getModelID() +{ +/* + * cmy: Vtion_E1916模块,该模块的"AT+CGMM"命令的返回并不带前缀. + +CGMM: E1916 + E1916 + + @20101206: 在查询modem id时,概率收到其它的主动上报,目前用多次获取modem id的方法来获取到正确的值 + */ +// cmy@20120105: 部分modem不支持AT+CGMM命令,但是支持AT+GMM + if(!modem_cmp(0x05c6,0x9025,NULL)){ + + int err; + char * responseStr = NULL; + ATResponse *p_response = NULL; + const char *cmd; + const char *prefix; + char *line, *p; + int commas; + int skip; + int count = 4; + err = at_send_command_singleline("AT+CGMM", "", &p_response); + if (err < 0 || !p_response->success) + goto error; + responseStr = p_response->p_intermediates->line; + + +error: + free(responseStr); + + return responseStr; + + + }else{ + char * response = NULL; + response = getCommandResponse("AT+CGMM", "GMM:", 6); + if(response == NULL) + response = getCommandResponse("AT+GMM", "GMM:", 5); + return response; + } + + +} +#else +/* + cmy: 获取模块型号可能无反应。 + 成功返回 model id + 失败返回 NULL + */ +static char* getModelID() +{ +/* + * cmy: Vtion_E1916模块,该模块的"AT+CGMM"命令的返回并不带前缀. + +CGMM: E1916 + E1916 + + 注意: 有些模块在没有插SIM卡时,无法获取模块型号 + TODO: 在无法获取模块型号时,可发送命令CPIN,查询SIM卡状态 + + @20101206: 在查询modem id时,概率收到其它的主动上报,目前用多次获取modem id的方法来获取到正确的值 + */ + char * response = NULL; + response = getCommandResponse("AT+CGMM", "GMM:", 5); + + if( !response ) + { + if (getSIMStatus() == SIM_ABSENT) { + // 缺少SIM卡 + LOGD("[%s]: Sim card not inserted!", __FUNCTION__); + setRadioState(RADIO_STATE_SIM_LOCKED_OR_ABSENT); + } + } + + return response; +} +#endif +static void requestBaseBandVersionT(int request, void *data, + size_t datalen, RIL_Token t){ + +int err; +char * responseStr; +ATResponse *p_response = NULL; +const char *cmd; +const char *prefix; +char *line, *p; +int commas; +int skip; +int count = 4; +err = at_send_command_singleline("AT+GMR", "", &p_response); +if (err < 0 || !p_response->success) goto error; +responseStr = p_response->p_intermediates->line; +RIL_onRequestComplete(t, RIL_E_SUCCESS, responseStr, sizeof(responseStr)); + +error: + free(responseStr);} + +static void requestBasebandVersion(void *data, size_t datalen, RIL_Token t) +{ + char* model_id = getModelID(); + if( model_id != NULL ) + { + RIL_onRequestComplete(t, RIL_E_SUCCESS, model_id, sizeof(char *)); + free(model_id); + } + else + { + LOGE("ERROR: requestBasebandVersion failed\n"); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + } +} + +// 成功返回 >= 0 +// 失败返回 < 0 +static int queryNetworkSelectionMode() +{ + int err; + ATResponse *p_response = NULL; + int response = 0; + char *line; + + LOGD("Enter queryNetworkSelectionMode"); + + // AT+COPS? Ask for current Mode Preference + err = at_send_command_singleline("AT+COPS?", "+COPS:", &p_response); + + if (err < 0 || p_response->success == 0) { + goto error; + } + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + + if (err < 0) { + goto error; + } + + err = at_tok_nextint(&line, &response); + + if (err < 0) { + goto error; + } + + LOGD("response=%d", response); + + return response; + +error: + at_response_free(p_response); + return -1; +} + +/* cmy: 查询当前选择的网络 + AT+COPS? + + +COPS: 0 自动搜网模式,未选择网络 + or + +COPS: 1,2,"46000",2 手动搜网模式,选择了网络 + +COPS: 0,2,"46000",2 自动搜网模式,选择了网络 + */ +static void requestQueryNetworkSelectionMode( + void *data, size_t datalen, RIL_Token t) +{ + int response = 0; + + LOGD("Enter requestQueryNetworkSelectionMode"); + + if(isgsm) { //this command conflicts with the network status command + response = queryNetworkSelectionMode(); + if( response < 0 ) goto error; + } + + RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(int)); + return; +error: + LOGE("requestQueryNetworkSelectionMode must never return error when radio is on"); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); +} +//adb by xxh 2103-5-10 +char *getFirstElementValue(const char* document, + const char* elementBeginTag, + const char* elementEndTag, + char** remainingDocument) +{ + char* value = NULL; + char* start = NULL; + char* end = NULL; + + if (document != NULL && elementBeginTag != NULL && elementEndTag != NULL) + { + start = strstr(document, elementBeginTag); + if (start != NULL) + { + end = strstr(start, elementEndTag); + if (end != NULL) + { + int n = strlen(elementBeginTag); + int m = end - (start + n); + value = (char*) malloc((m + 1) * sizeof(char)); + strncpy(value, (start + n), m); + value[m] = (char) 0; + + /* Optional, return a pointer to the remaining document, + to be used when document contains many tags with same name. */ + if (remainingDocument != NULL) + { + *remainingDocument = end + strlen(elementEndTag); + } + } + } + } + return value; +} + +void requestQueryAvailableNetworksxxh(void *data, size_t datalen, RIL_Token t) +{ + + int err = 0; + ATResponse *atresponse = NULL; + const char *statusTable[] = + { "unknown", "available", "current", "forbidden" }; + char **responseArray = NULL; + char *p; + int n = 0; + int i = 0; + + err = at_send_command_multiline("AT+COPS=?", "+COPS:", &atresponse); + if (err < 0 || + atresponse->success == 0 || + atresponse->p_intermediates == NULL) + goto error; + + p = atresponse->p_intermediates->line; + while (*p != '\0') { + if (*p == '(') + n++; + if(*p == ',' && *(p+1) == ',') + break; + p++; + } + + responseArray = alloca(n * 4 * sizeof(char *)); + + p = atresponse->p_intermediates->line; + + for (i = 0; i < n; i++) { + int status = 0; + char *line = NULL; + char *s = NULL; + char *longAlphaNumeric = NULL; + char *shortAlphaNumeric = NULL; + char *numeric = NULL; + char *remaining = NULL; + char *GSMType="-2G"; + char *UTRANType="-3G"; + char *networkType = NULL; + + + s = line = getFirstElementValue(p, "(", ")", &remaining); + p = remaining; + + if (line == NULL) { + LOGE("Null pointer while parsing COPS response. This should not happen."); + break; + } + err = at_tok_nextint(&line, &status); + if (err < 0) + goto error; + + err = at_tok_nextstr(&line, &longAlphaNumeric); + if (err < 0) + goto error; + + err = at_tok_nextstr(&line, &shortAlphaNumeric); + if (err < 0) + goto error; + + err = at_tok_nextstr(&line, &numeric); + if (err < 0) + goto error; + + err = at_tok_nextstr(&line,&networkType); + if(err<0) + goto error; + + if(strcmp(networkType,"2")==0) { + strcat(longAlphaNumeric,UTRANType); + LOGD("the operator is %s",longAlphaNumeric); + } + else if((strcmp(networkType,"1")==0) || (strcmp(networkType,"0")==0)) + { + strcat(longAlphaNumeric,GSMType); + LOGD("the operator is %s",longAlphaNumeric); + } + responseArray[i * 4 + 0] = alloca(strlen(longAlphaNumeric) + 1); + strcpy(responseArray[i * 4 + 0], longAlphaNumeric); + + responseArray[i * 4 + 1] = alloca(strlen(shortAlphaNumeric) + 1); + strcpy(responseArray[i * 4 + 1], shortAlphaNumeric); + + responseArray[i * 4 + 2] = alloca(strlen(numeric) + 1); + strcpy(responseArray[i * 4 + 2], numeric); + + free(s); + + if (responseArray[i * 4 + 0] && strlen(responseArray[i * 4 + 0]) == 0) { + responseArray[i * 4 + 0] = alloca(strlen(responseArray[i * 4 + 2]) + + 1); + strcpy(responseArray[i * 4 + 0], responseArray[i * 4 + 2]); + } + + if (responseArray[i * 4 + 1] && strlen(responseArray[i * 4 + 1]) == 0) { + responseArray[i * 4 + 1] = alloca(strlen(responseArray[i * 4 + 2]) + 1); + strcpy(responseArray[i * 4 + 1], responseArray[i * 4 + 2]); + } + + responseArray[i * 4 + 3] = alloca(strlen(statusTable[status]) + 1); + sprintf(responseArray[i * 4 + 3], "%s", statusTable[status]); + } + + RIL_onRequestComplete(t, RIL_E_SUCCESS, responseArray, + i * 4 * sizeof(char *)); + +finally: + at_response_free(atresponse); + return; + +error: + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + goto finally; +} + +/* cmy: 查询可用网络 + AT+COPS=? + +COPS: (2,"中国移动","CMCC","46000",2),(1,"中国移动","CMCC","46000",0),(3,"中国联通","CUCC","46001"),,(0-4),(0-2) + */ +#define OPS_RET 4 +static void requestQueryAvailableNetworks(void *data, size_t datalen, RIL_Token t) +{ + /* We expect an answer on the following form: + +COPS: (2,"AT&T","AT&T","310410",0),(1,"T-Mobile ","TMO","310260",0) + +COPS: (2,"CHN-CUGSM","CU-GSM","46001",2),(1,"3 HK","3 HK","45403",2),(3,"CSL","CSL","45400",2),(3,"PCCW","PCCW","45419",2),(1,"SmarToneVodafone","SMC-Voda","45406",2), + */ + + int err, operators, i=0, skip, status, rat; + ATResponse *p_response = NULL; + char * c_skip, *line, *p = NULL; + char ** response = NULL; + +// cmy: CDMA not support 'COPS' commands + if(!isgsm) + { + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + return; + } + +// 查询运营商的命令所花时间相当长,如果信号不好的话,所花时间会更多 + err = at_send_command_singleline_t("AT+COPS=?", "+COPS:", 80000, &p_response); + + if (err < 0 || p_response->success == 0) goto error; + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + if (err < 0) goto error; + + /* Count number of '(' in the +COPS response to get number of operators*/ + operators = 0; + for (p = line ; *p != '\0' ;p++) { + if (*p == '(') operators++; + } + +#ifdef DBG_1 + LOGD("[%s] operators=%d", __FUNCTION__, operators); +#endif + response = (char **)alloca(operators * 5 * sizeof(char *)); + + for (i = 0 ; i < operators ; i++ ) + { + err = at_tok_nextstr(&line, &c_skip); + if (err < 0) goto error; + if (strcmp(c_skip,"") == 0) + { + operators = i; +#ifdef DBG_1 + LOGD("[%s] break in %d", __FUNCTION__, i); +#endif + continue; + } + // stat + status = atoi(&c_skip[1]); + response[i*OPS_RET+3] = (char*)networkStatusToRilString(status); + + // long format alphanumeric + err = at_tok_nextstr(&line, &(response[i*OPS_RET+0])); + if (err < 0) goto error; + + // short format alphanumeric + err = at_tok_nextstr(&line, &(response[i*OPS_RET+1])); + if (err < 0) goto error; + + // numeric + err = at_tok_nextstr(&line, &(response[i*OPS_RET+2])); + if (err < 0) goto error; + + err = at_tok_nextstr(&line, &c_skip); + if (err < 0) goto error; + LOGD("[%s] act is %s", __FUNCTION__, c_skip); +// cmy: 不支持中文 + if(response[i*OPS_RET+0]!=NULL ) + { + if( !strcmp(response[i*OPS_RET+0], "中国移动") ) + response[i*OPS_RET+0] = "China Mobile"; + else if( !strcmp(response[i*OPS_RET+0], "中国电信") ) + response[i*OPS_RET+0] = "China Telecom"; + else if( !strcmp(response[i*OPS_RET+0], "中国联通") ) + response[i*OPS_RET+0] = "China Unicom"; + } + } + + RIL_onRequestComplete(t, RIL_E_SUCCESS, response, (operators * OPS_RET * sizeof(char *))); + at_response_free(p_response); + return; + +error: + if(i>0) + {// cmy: 如果有获得了一部分运营商,则将它们传回 + LOGD("[%s] get oper count=%d", __FUNCTION__, i); + RIL_onRequestComplete(t, RIL_E_SUCCESS, response, (i * 5 * sizeof(char *))); + } + else + { + LOGE("ERROR - requestQueryAvailableNetworks() failed"); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + } + + at_response_free(p_response); +} + +static void requestGetPreferredNetworkType(void *data, size_t datalen, RIL_Token t) +{ + int response = 0; + response = s_current_modem->extATFunc->getPrefNetworkType(); + if(response < 0) + { + LOGE("ERROR: requestGetPreferredNetworkType() failed\n"); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + } + else + { + LOGD("[%s]: return network mode=%d", __FUNCTION__, response); + RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(int)); + } + + return; +} + +/** + * RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE + * + * Requests to set the preferred network type for searching and registering + * (CS/PS domain, RAT, and operation mode) + * + * "data" is int * + * + * ((int *)data)[0] is == 0 for GSM/WCDMA (WCDMA preferred) + * ((int *)data)[0] is == 1 for GSM only + * ((int *)data)[0] is == 2 for WCDMA only + * ((int *)data)[0] is == 3 for GSM/WCDMA (auto mode, according to PRL) + * ((int *)data)[0] is == 4 for CDMA and EvDo (auto mode, according to PRL) + * ((int *)data)[0] is == 5 for CDMA only + * ((int *)data)[0] is == 6 for EvDo only + * ((int *)data)[0] is == 7 for GSM/WCDMA, CDMA, and EvDo (auto mode, according to PRL) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + * MODE_NOT_SUPPORTED + */ +static void requestSetPreferredNetworkType(void *data, size_t datalen, RIL_Token t) +{ + int err, rat; + assert (datalen >= sizeof(int *)); + rat = ((int *)data)[0]; + + LOGD("[%s]: new Network Type: %d", __FUNCTION__, rat); + + kill_pppd(25); + /* Set new preferred network type */ + err = s_current_modem->extATFunc->setPrefNetworkType(rat); + if(err < 0) + { + if(err == -1) goto error_not_support; + else goto error; + } + + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, sizeof(int)); + return; +error: + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + return; +error_not_support: + RIL_onRequestComplete(t, RIL_E_MODE_NOT_SUPPORTED, NULL, 0); + return; +} + +static void requestQueryFacilityLock(void *data, size_t datalen, RIL_Token t) +{ + int err, rat, response; + ATResponse *p_response = NULL; + char * cmd = NULL; + char * line = NULL; + char * facility_string = NULL; + char * facility_password = NULL; + char * facility_class = NULL; + + assert (datalen >= (3 * sizeof(char **))); + + facility_string = ((char **)data)[0]; + facility_password = ((char **)data)[1]; + facility_class = ((char **)data)[2]; + + LOGD("FACILITY: %s", facility_string); + LOGD(" facility_string=%s facility_password=%s facility_class=%s ",facility_string, facility_password, facility_class); +// asprintf(&cmd, "AT+CLCK=\"%s\",2,\"%s\",%s", facility_string, facility_password, facility_class); + asprintf(&cmd, "AT+CLCK=\"%s\",2", facility_string); + + err = at_send_command_singleline(cmd,"+CLCK:", &p_response); + free(cmd); + if (err < 0 || p_response->success == 0){ + goto error; + } + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + + if (err < 0) { + goto error; + } + + err = at_tok_nextint(&line, &response); + + if (err < 0) { + goto error; + } + + RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(int)); + at_response_free(p_response); + return; + +error: + at_response_free(p_response); + LOGE("ERROR: requestQueryFacilityLock() failed\n"); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); +} + +static void requestGetCurrentCalls(void *data, size_t datalen, RIL_Token t) +{ + int countValidCalls; + RIL_Call **pp_calls; + + if(currentState() != RADIO_STATE_SIM_READY){ + /* Might be waiting for SIM PIN */ + RIL_onRequestComplete(t, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0); + } + +/* CMY: 测试发现,在拨号连接时,概率性地会出现来电界面,系因此命令的返回结果。 + 目前MID并未支持语音通话功能,可直接返回空的结果给上层,以解决该BUG + */ + countValidCalls = 0; + pp_calls = NULL; + RIL_onRequestComplete(t, RIL_E_SUCCESS, pp_calls, + countValidCalls * sizeof (RIL_Call *)); + return; +} + +// 返回值: 0 - 受限状态不改变 +// 1 - 受限状态被改变 +static int queryRestrictedState() +{ + int restricted_state; + + LOGD("[%s] === ENTER ===\n", __FUNCTION__); + + if(!isgsm || !modem_cmp(0x0E8D, 0x00A2, "MTK2"))// C网无法查询受限服务状态 + restricted_state = RIL_RESTRICTED_STATE_NONE; + else + restricted_state = s_current_modem->extATFunc->getRestrictedState(); + + if(restricted_state >= 0 && restricted_state != s_restricted_state) + { + LOGD("[%s]: restricted state: old=%d, new=%d", __FUNCTION__, s_restricted_state, restricted_state); + s_restricted_state = restricted_state; +// cmy: 对 AST 不启用服务受限的功能 + RIL_onUnsolicitedResponse(RIL_UNSOL_RESTRICTED_STATE_CHANGED, + &s_restricted_state, + sizeof(int) ); + return 1; + } + + return 0; +} + +/* + 查询注册状态 + 参数: + regInfo: 状态信息通过该参数返回,通常由调用方传递一个 int[4]的数组 + count: 状态信息个数 + 返回值: + 0: 成功 + 非0: 失败 + */ +static int getRegistrationInfo(int *regInfo, int* count) +{ + int err; + int* response = regInfo; + ATResponse *p_response = NULL; + const char *cmd; + const char *prefix; + char *line, *p; + int commas; + int skip; + *count = 3; + +/* + RIL_REQUEST_GPRS_REGISTRATION_STATE: 返回值中,responseStr[3]存放网络类型 + + 对于网络类型: + 1、在初始化初始可能是2G + 2、上层分CDMA、GSM两个网络, + */ +// cmy@20111228: 不查询语音注册状态 +// cmy@20120419: 地图查询位置需用到语音注册状态的返回值 +// 且E1750查询数据状态没问题 + if (!isgsm || !modem_cmp(0x1234, 0x0033, "LCR 3.0.0")) { + // cmy: for CDMA + regInfo[0] = 1; + regInfo[1] = -1; + regInfo[2] = -1; + + return 0; + } + + // data registration state + cmd = "AT+CGREG?"; + prefix = "+CGREG:"; + if( !modem_cmp(0x12D1, 0x14AC, "E153") || + !modem_cmp(0x12D1, 0x1003, "E156G") || + !modem_cmp(0x12D1, 0x1C05, "E173") || + !modem_cmp(0x12d1, 0x1506,"E303") || + !modem_cmp(0x12d1, 0x1506,"E303C") || + !modem_cmp(0x12d1,0x0117,"MF190") || + !modem_cmp(0x12d1, 0x1506,"E3131") || + !modem_cmp(0x20A6, 0x1105,"HSUPA") || + !modem_cmp(0x21f5, 0x1101, NULL)) + { + cmd = "AT+CREG?"; + prefix = "+CREG:"; + } + + err = at_send_command_singleline(cmd, prefix, &p_response); + + if (err != 0 || p_response->success==0) goto error; + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + if (err < 0) goto error; + + /* Ok you have to be careful here + * The solicited version of the CREG response is + * +CREG: n, stat, [lac, cid] + * and the unsolicited version is + * +CREG: stat, [lac, cid] + * The parameter is basically "is unsolicited creg on?" + * which it should always be + * + * Now we should normally get the solicited version here, + * but the unsolicited version could have snuck in + * so we have to handle both + * + * Also since the LAC and CID are only reported when registered, + * we can have 1, 2, 3, or 4 arguments here + * + * finally, a +CGREG: answer may have a fifth value that corresponds + * to the network type, as in; + * + * +CGREG: n, stat [,lac, cid [,networkType]] + */ + + /* count number of commas */ + commas = 0; + for (p = line ; *p != '\0' ;p++) { + if (*p == ',') commas++; + } + + switch (commas) { + case 0: /* +CREG: */ + err = at_tok_nextint(&line, &response[0]); + if (err < 0) goto error; + response[1] = -1; + response[2] = -1; + break; + + case 1: /* +CREG: , +CGREG: , */ + err = at_tok_nextint(&line, &skip); + if (err < 0) goto error; + err = at_tok_nextint(&line, &response[0]); + if (err < 0) goto error; + + if(!modem_cmp(0x05C6, 0x6000, "HSDPA Modem") + || !modem_cmp(0x12D1, 0x1001, "E1750") + || !modem_cmp(0x12D1, 0x1001, "3G HSDPA MODEM")) + { + response[0] = 1; + } + + response[1] = -1; + response[2] = -1; + break; + + case 2: /* +CREG: , , */ + err = at_tok_nextint(&line, &response[0]); + if (err < 0) goto error; + err = at_tok_nexthexint(&line, &response[1]); + if (err < 0) goto error; + err = at_tok_nexthexint(&line, &response[2]); + if (err < 0) goto error; + break; + + case 3: /* +CREG: , , , */ + err = at_tok_nextint(&line, &skip); + if (err < 0) goto error; + err = at_tok_nextint(&line, &response[0]); + if (err < 0) goto error; + err = at_tok_nexthexint(&line, &response[1]); + if (err < 0) goto error; + err = at_tok_nexthexint(&line, &response[2]); + if (err < 0) goto error; + break; + + /* special case for CGREG, there is a fourth parameter + * that is the network type (unknown/gprs/edge/umts) + */ + case 4: /* +CGREG: , , , , */ + case 5: + err = at_tok_nextint(&line, &skip); + if (err < 0) goto error; + err = at_tok_nextint(&line, &response[0]); + if (err < 0) goto error; + err = at_tok_nexthexint(&line, &response[1]); + if (err < 0) goto error; + err = at_tok_nexthexint(&line, &response[2]); + if (err < 0) goto error; + err = at_tok_nexthexint(&line, &response[3]); + if (err < 0) goto error; + *count = 4; + break; + default: + goto error; + } + + at_response_free(p_response); + return 0; + +error: + at_response_free(p_response); + return -1; +} + +static int queryRegistrationRat() +{ + int count = 0; + int response[4]={0}; + int network_type = RADIO_TECHNOLOGY_UNKNOWN; + + if( !getRegistrationInfo(&response[0], &count) + && count>3 ) + { + network_type = response[3]; + } + + return network_type; +} + +static void doSomeQuery() +{ +#if 0 +/* cmy: 查询当前的PS/CS服务,当有改变时,上报 RIL_UNSOL_RESTRICTED_STATE_CHANGED + CS PS 状态: 仅PS/仅CS/PS+CS/无服务 + */ + int restricted_state_chg = 0; + + restricted_state_chg = queryRestrictedState(); + + if(restricted_state_chg) + { + // 受限状态发生变化时,要求上层去查询下网络状态 + RIL_onUnsolicitedResponse ( + RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, + NULL, 0); + } +#endif + + // 对于爱可视dongle,在此查询网络类型,以便及时更新网络类型的改变 + if(!modem_cmp(0x1BBB, 0x00B7, "HSPA Data Card") + || !modem_cmp(0x12D1, 0x1001, "MU509") + || !modem_cmp(0x19F5, 0x9013, "UW100") + || !modem_cmp(0x1C9E, 0x9603, "HSPA USB MODEM") + ) + { + int rat = queryRegistrationRat(); + if( rat != s_reg_rat ) { + LOGD("reg RAT: %d -> %d\n", s_reg_rat, rat); + s_reg_rat = rat; + RIL_onUnsolicitedResponse ( + RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, + NULL, 0); + } + } + +} + +/* + GSM/WCDMA: + 0: 0,99 + 1: <9 + 2: <15 + 3: <21 + 4: >=21 + + TD-SCDMA + 0: 0,199 + 1: <125 + 2: <143 + 3: <161 + 4: >=161 + + CDMA/EVDO: + 0: 0 + 1: 20 + 2: 40 + 3: 60 + 4: 80 + */ +static void requestSignalStrength(void *data, size_t datalen, RIL_Token t) +{ + ATResponse *p_response = NULL; + int err; + #if (RIL_VERSION >= 6) + int response[13]; + #else + int response[2]; + #endif + char *line; + int cur_network_type = 0; + RIL_SignalStrength_v6 responseV6; + +/* cmy: 处理一些定时查询的命令 + */ + doSomeQuery(); + +// xxh 部分modem不支持信号查询 + if( !modem_cmp(0x19D2, 0x0094, "AC580") + || !modem_cmp(0x1D09, 0xAEF4, "E800") + || !modem_cmp(0x12D1,0x140B,NULL) + ||!modem_cmp(0x12D1, 0x140C, NULL)) + + { + response[0] = 15; + response[1] = 99; + }else if(!modem_cmp(0x19D2, 0xFFE8, "MC2718"))//xxh:美国SPINRT网络查询信号用AT+CSQ? + + { + err = at_send_command_singleline("AT+CSQ?", "+CSQ:", &p_response); + + if (err < 0 || p_response->success == 0) { + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + goto error; + } + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &(response[0])); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &(response[1])); + if (err < 0) goto error; + response[1] = 99; + + at_response_free(p_response); + + } + else + { + if(!isgsm) + { + // 获取当前网络类型 + if(s_sys_mode==-1) + cur_network_type = s_current_modem->extATFunc->getNetworkType(); + else + {// s_sys_mode: 0, 2, 4, 8 + switch(s_sys_mode) + { + case 4: case 8: cur_network_type = RADIO_TECHNOLOGY_EVDO_A; break; + default: cur_network_type = RADIO_TECHNOLOGY_1xRTT; break; + } + } + } + + if( cur_network_type==RADIO_TECHNOLOGY_EVDO_A ) + { + if(signalStrength_hdr[0] < 0 && signalStrength_hdr[0] < 0) + { + err = at_send_command_singleline("AT^HDRCSQ", "^HDRCSQ:", &p_response); + if (err < 0 || p_response->success == 0) { + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + goto error; + } + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &(response[0])); + if (err < 0) goto error; + + switch(response[0]) + { + case 0: break; + case 20: response[0] = 4; break; + case 40: response[0] = 12; break; + case 60: response[0] = 18; break; + case 80: response[0] = 26; break; + case 99: response[0] = 34;break; + default: response[0] = 99; break; + } + + response[1] = 99; + at_response_free(p_response); + } else { + LOGD("Sending stored CSQ values to RIL"); + + response[0] = signalStrength_hdr[0]; + response[1] = signalStrength_hdr[1]; + } + } + else + { + if( signalStrength[0] < 0 && signalStrength[0] < 0 ) + { + if(0 == modem_cmp(0x106C, 0x3718, NULL)){ + response[0] = 15; + response[1] = 99; + }else{ + err = at_send_command_singleline("AT+CSQ", "+CSQ:", &p_response); + + if (err < 0 || p_response->success == 0) { + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + goto error; + } + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &(response[0])); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &(response[1])); + if (err < 0) goto error; + response[1] = 99; + + at_response_free(p_response); + } + } else { + LOGD("Sending stored CSQ values to RIL"); + + response[0] = signalStrength[0]; + response[1] = signalStrength[1]; + } + } + } + + #if (RIL_VERSION >= 6) + //response[2]=-1; + //response[3]=-1; + //response[4]=-1; + //response[5]=-1; + //response[6]=-1; + //response[7]=-1; + //response[8]=-1; + //response[9]=-1; + //response[10]=-1; + //response[11]=-1; + //response[12]=-1; + responseV6.GW_SignalStrength.signalStrength = response[0]; + responseV6.GW_SignalStrength.bitErrorRate = response[1]; + //responseV6.CDMA_SignalStrength.dbm = -1; + //responseV6.CDMA_SignalStrength.ecio = -1; +// responseV6.EVDO_SignalStrength.dbm = -1; + //responseV6.EVDO_SignalStrength.ecio = -1; + //responseV6.EVDO_SignalStrength.signalNoiseRatio = -1; + responseV6.LTE_SignalStrength.signalStrength=99; + responseV6.LTE_SignalStrength.rsrp = 0x7FFFFFFF; + responseV6.LTE_SignalStrength.rsrq = 0x7FFFFFFF; + responseV6.LTE_SignalStrength.rssnr = 0x7FFFFFFF; + responseV6.LTE_SignalStrength.cqi = 0x7FFFFFFF; + #endif + RIL_onRequestComplete(t, RIL_E_SUCCESS, &responseV6, sizeof(RIL_SignalStrength_v6)); + //RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); + return; + +error: + LOGE("requestSignalStrength must never return an error when radio is on"); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + at_response_free(p_response); +} +static void onUnsolicitedSignalStrength() +{ + + ATResponse *p_response = NULL; + int err; + int response[2]; + char *line; + + RIL_SignalStrength_v6 responseV6; + + err = at_send_command_singleline("AT+CSQ", "+CSQ:", &p_response); + + if (err < 0 || p_response->success == 0) { + goto error; + } + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &(response[0])); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &(response[1])); + if (err < 0) goto error; + + LOGD("The requestSignalStrength =%d profile=%d",response[0],response[1]); + + + responseV6.GW_SignalStrength.signalStrength = response[0]; + responseV6.GW_SignalStrength.bitErrorRate = response[1]; + + //responseV6.CDMA_SignalStrength.dbm = -1; + //responseV6.CDMA_SignalStrength.ecio = -1; + //responseV6.EVDO_SignalStrength.dbm = -1; + //responseV6.EVDO_SignalStrength.ecio = -1; + //responseV6.EVDO_SignalStrength.signalNoiseRatio = -1; + responseV6.LTE_SignalStrength.signalStrength=99; + responseV6.LTE_SignalStrength.rsrp = 0x7FFFFFFF; + responseV6.LTE_SignalStrength.rsrq = 0x7FFFFFFF; + responseV6.LTE_SignalStrength.rssnr = 0x7FFFFFFF; + responseV6.LTE_SignalStrength.cqi = 0x7FFFFFFF; + + RIL_onUnsolicitedResponse (RIL_UNSOL_SIGNAL_STRENGTH,&responseV6, sizeof(RIL_SignalStrength_v6)); + at_response_free(p_response); + return; + +error: + LOGD("requestSignalStrength must never return an error when radio is on"); + at_response_free(p_response); + return; +} + +#define MODEM_POWER_INTERFACE "/sys/class/rk291x_modem/modem_status" +static int setModemPower(int onoff) +{ + FILE*fp = fopen(MODEM_POWER_INTERFACE, "wr"); + + LOGD("set modem power [%s]", onoff?"on":"off"); + + if (fp != NULL) + { + if( fwrite(onoff?"1":"0", 1, 1, fp) <= 0 ) + LOGE("modem_status file write error!\n"); + + fclose(fp); + } + else + { + LOGE("file %s open failed!", MODEM_POWER_INTERFACE); + } + + return 0; +} + +static void requestScreenState(void *data, size_t datalen, RIL_Token t) +{ + int err, screenState; + + assert (datalen >= sizeof(int *)); + screenState = ((int*)data)[0]; + +#ifdef DBG_1 + LOGD("[%s]: screenState=%d\n", __FUNCTION__, screenState); +#endif + if(screenState == 1) + { + if (isgsm) { + /* Screen is on - be sure to enable all unsolicited notifications again */ + err = at_send_command("AT+CREG=2", NULL); + if (err < 0) goto error; + err = at_send_command("AT+CGREG=2", NULL); + if (err < 0) goto error; + } else { + // char value[64] = ""; + // property_get("net.gprs.ppp-exit", value, ""); + // if(!value[0]) + // { + // LOGD("[%s] pppd: no response", __FUNCTION__); + // value[0]=1; + // property_set("net.gprs.ppp-exit", value); + // RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL); + // } + // LOGD("[%s] pppd reconncet", __FUNCTION__); + } + } else if (screenState == 0) { + if (isgsm) { + /* Screen is off - disable all unsolicited notifications */ + err = at_send_command("AT+CREG=0", NULL); + if (err < 0) goto error; + err = at_send_command("AT+CGREG=0", NULL); + if (err < 0) goto error; + } else { + + } + } else { + /* Not a defined value - error */ + goto error; + } + + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + return; + +error: + LOGE("ERROR: requestScreenState failed"); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); +} + +/* cmy: 获取当前注册的网络类型 + RIL_REQUEST_GPRS_REGISTRATION_STATE: 返回值中, + responseStr[0] GSM/GPRS的注册状态 + responseStr[3] 存放网络类型 + + Available radio technologies for GSM, UMTS and CDMA. + RADIO_TECHNOLOGY_UNKNOWN = 0; + RADIO_TECHNOLOGY_GPRS = 1; + RADIO_TECHNOLOGY_EDGE = 2; + RADIO_TECHNOLOGY_UMTS = 3; + RADIO_TECHNOLOGY_IS95A = 4; + RADIO_TECHNOLOGY_IS95B = 5; + RADIO_TECHNOLOGY_1xRTT = 6; + RADIO_TECHNOLOGY_EVDO_0 = 7; + RADIO_TECHNOLOGY_EVDO_A = 8; + RADIO_TECHNOLOGY_HSDPA = 9; + RADIO_TECHNOLOGY_HSUPA = 10; + RADIO_TECHNOLOGY_HSPA = 11; + + 对于网络类型: + 1、在初始化初始可能是2G + 2、上层分CDMA、GSM两个网络, + + 可以根据主动上报的^MODE的值设置网络类型 + 或者使用命令AT^SYSINFO查询。 + */ +static void requestRegistrationState(int request, void *data, + size_t datalen, RIL_Token t) +{ + int response[4]={0}; + char* responseStr[4]={NULL}; + int count = 0; + int network_type = RADIO_TECHNOLOGY_UNKNOWN; + + getRegistrationInfo(&response[0], &count); + + //zte dongle + if(s_current_modem->modem_info.vid==0x19d2){ + asprintf(&responseStr[0], "%d", response[0]); + asprintf(&responseStr[1], "%04x", response[1]); + asprintf(&responseStr[2], "%08x", response[2]); + }else + //huawei dongle + asprintf(&responseStr[0], "%d", response[0]); + asprintf(&responseStr[1], "%x", response[1]); + asprintf(&responseStr[2], "%x", response[2]); + +/* + RIL_REQUEST_GPRS_REGISTRATION_STATE: 返回值中,responseStr[3]存放网络类型 + + 对于网络类型: + 1、在初始化初始可能是2G + 2、上层分CDMA、GSM两个网络, + */ +// cmy@20111228: 不查询语音注册状态 +// cmy@20120419: 地图查询位置需用到语音注册状态的返回值 +// 且E1750查询数据状态没问题 + if (!isgsm || !modem_cmp(0x1234, 0x0033, "LCR 3.0.0")) { + // cmy: for CDMA + if(!isgsm && request == RIL_REQUEST_GPRS_REGISTRATION_STATE) + { + if(sim_pin){ + network_type=-1; + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + + }else{ + network_type = s_current_modem->extATFunc->getNetworkType(); + if( network_type < 0) + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + + asprintf(&responseStr[3], "%d", network_type); + count = 4; + + // cmy: 查询当前服务受限状态 + queryRestrictedState(); + } + } + RIL_onRequestComplete(t, RIL_E_SUCCESS, responseStr, count*sizeof(char*)); + return; + } + + if (count > 3) + { + s_reg_rat = response[3]; + network_type = networkType2RAT(response[3]); + asprintf(&responseStr[3], "%d", network_type); + } + + /* cmy: 只有在已经注网,且CREG/CGREG没有返回网络接入技术的情况下, + 才需要去获取接入技术 + */ + if( (response[0]==1 || response[0]==5) && network_type==RADIO_TECHNOLOGY_UNKNOWN ) + { + network_type = s_current_modem->extATFunc->getNetworkType(); + if(network_type < 0) + asprintf(&responseStr[3], "%d", RADIO_TECHNOLOGY_UNKNOWN); + else + asprintf(&responseStr[3], "%d", network_type); + count = 4; + + // cmy: 查询当前服务受限状态 + queryRestrictedState(); + } + +/* + cmy@20101206,修正BUG: 当上一次连接后s_reg_stat/s_greg_stat已经被改成了1 + 当本次连接,初始状态CREG/CGREG的状态为2,之后通过主动上报方式告知CREG/CGREG的状态为1. + 但由于s_reg_stat/s_greg_stat已经是1,不会触发上层的主动查询,导致上层误认为CREG/CGREG为2. + */ + if(request == RIL_REQUEST_REGISTRATION_STATE) + s_reg_stat = response[0]; + else + s_greg_stat = response[0]; + + RIL_onRequestComplete(t, RIL_E_SUCCESS, responseStr, count*sizeof(char*)); + onUnsolicitedSignalStrength(); + return; +error: + LOGE("requestRegistrationState must never return an error when radio is on"); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); +} + +/* cmy: 获取当前注册网络的信息 + + AT+COPS? + +COPS: ,,, + + : 网络选择模式 + 0: 自动搜网,设置命令中,mode 取值为0 时,后面参数 format,oper都无效。 + 1: 手动搜网 + 2: 去注册网络 + 3: 仅为+COPS?读命令设置返回的格式 + + : 运营商信息的格式 + 0: 长字符串格式的运营商信息 + 1: 短字符串格式的运营商信息 + 2: 数字格式的运营商信息 + + :无线接入技术,取值如下: + 0: GSM/GPRS 制式 + 2: UTRAN制式 + + +COPS: 0,0,"中国移动",2 + +COPS: 0,1,"CMCC",2 + +COPS: 0,2,"46000",2 + */ +static void requestOperator(void *data, size_t datalen, RIL_Token t) +{ + int err; + int i; + int skip; + ATLine *p_cur; + char *response[3]; + + memset(response, 0, sizeof(response)); + + ATResponse *p_response = NULL; + + OperatorInfo* info = NULL; + + /* + cmy@20101023: 当mcc/mnc值出现在operator_table中时,使用该表中的operator. + */ + if( IMSI[0] == 0 ) + GetIMSI(IMSI); + + if( IMSI[0] != 0 ) + { + LOGD("IMSI is %s", IMSI); + char nmsi[10]={0}; + strncpy(nmsi, IMSI, 5); + info = getOperator( nmsi ); + LOGD("info: %p", info); + } + + if( info != NULL ) + { + response[0]=info->lalphanumeric; + response[1]=info->salphanumeric; + response[2]=info->numeric; + onUnsolicitedSignalStrength(); + LOGD("get operator form table: %s, %s, %s", response[0], response[1], response[2]); + } + else + { + if(isgsm) { +/* + 目前发现部分modem 对 AT+COPS=3,x 指令直接返回失败 + */ + char cmd[64] = ""; + char *result = NULL; + for(i=0; i<3; i++) + { + at_response_free(p_response); + p_response = NULL; + sprintf(cmd, "AT+COPS=3,%d", i); + err = at_send_command(cmd, &p_response); + if (err < 0|| p_response->success == 0) { + continue; + } + at_response_free(p_response); + p_response = NULL; + err = at_send_command_singleline("AT+COPS?", "+COPS:", &p_response); + if (err < 0|| p_response->success == 0) { + continue; + } + + char *line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &skip); + if (err < 0) goto error; + + // If we're unregistered, we may just get + // a "+COPS: 0" response + if (!at_tok_hasmore(&line)) { + response[i] = NULL; + continue; + } + + err = at_tok_nextint(&line, &skip); + if (err < 0) goto error; + + // a "+COPS: 0, n" response is also possible + if (!at_tok_hasmore(&line)) { + response[i] = NULL; + continue; + } + + err = at_tok_nextstr(&line, &result); + if (err < 0) goto error; + + asprintf(&response[i], "%s", result); + } + + if( response[0] == NULL ) response[0] = response[1]; + if( response[1] == NULL ) response[1] = response[0]; + + + // cmy: 不支持中文 + if(response[0]!=NULL ) + { + if( !strcmp(response[0], "中国移动") ) + response[0] = "China Mobile"; + else if( !strcmp(response[0], "中国电信") ) + response[0] = "China Telecom"; + else if( !strcmp(response[0], "中国联通") + || !strcmp(response[0], "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") + || !strcmp(response[0],"FFFFFFFFFFFFFFFF")) + response[0] = "China Unicom"; + } + } + } + + RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); + at_response_free(p_response); + + return; +error: + LOGE("requestOperator must not return error when radio is on"); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + at_response_free(p_response); +} + +static int kill_pppd(int second) +{ + int i=0; + int fd; + + if(!modem_cmp(0x1E89, 0x1E16, "E1916")) + { + // 目前发现 E1916 需要在 AT 口发送 'ATH'指令才能正常断开连接 + // 如果不发ATH,那么在下次拨号时就会失败 + at_send_command("ATH", NULL); + sleep(2); + } + + LOGD("kill pppd process!"); + while((fd = open("/sys/class/net/ppp0/iflink",O_RDONLY)) > 0) { + if(i%5 == 0) { + system("busybox1.11 killall pppd"); + } + close(fd); + if(i>second) + return -1; + i++; + sleep(1); + } +//end + // if(0 == modem_cmp(0x106C, 0x3718, NULL)) + // at_emulate_exit(); + //end by xxh + return 0; +} + + static int get_pid(char *Name) + { + char name[14] = {0}; + strncpy(name,Name,14); + char szBuf[256] = {0}; + char cmd[20] = {0}; + char *p_pid = NULL; + FILE *pFile = NULL; + int pid = 0; + sprintf(cmd, "ps %s", name); + pFile = popen(cmd, "r"); +if (pFile != NULL) { + while (fgets(szBuf, sizeof(szBuf), pFile)) { + if(strstr(szBuf, name)) { + p_pid = strstr(szBuf, " "); + pid = strtoul(p_pid, NULL, 10); + RLOGD("--- %s pid = %d ---",name,pid); + break; + } + } + } + pclose(pFile); + return pid; + } + + +static void kill_rild() +{ + int rild_pid = get_pid("rild"); + int count = 5; + while((rild_pid = get_pid("rild")) && count--){ + kill(rild_pid, SIGKILL); + RLOGD("--- kill rild pid = %d ---",rild_pid); + sleep(1); + } +} + +/* + cmy: PPP连接上的条件 + 1 ip-up脚本被执行 "net.ppp0.local-ip" 不为空 + 2 "/sys/class/net/ppp0/operstate"文件的内容为"unknown" 或者 "up" + + 返回值: -1 超时退出 + 0 连接成功 + */ +static int getpppstatus(char **ip_address) +{ + int timeout = 30;// 30S + char line[64]; + //ip_address[0] = 0; + // char ppp_exit_status[64]; + char ppp_exit_status[PROPERTY_VALUE_MAX]; + static char ip_local_address[PROPERTY_VALUE_MAX]; + while(timeout--){ + sleep(1); + + /* 确定pppd进程没有退出 + 当执行pppd时,net.gprs.ppp-exit 设为空 + 当退出pppd后,net.gprs.ppp-exit 不为空 + */ + property_get("net.gprs.ppp-exit", ppp_exit_status, ""); + if(ppp_exit_status[0] != '\0') break; + +#if 0 // cmy: 目前发现该功能基本上没有用上,反而部分模块因此命令而超时 + // 确定模块正常工作 + int err = at_send_command("AT", NULL); + if(err) break; +#endif + FILE*fp = fopen("/sys/class/net/ppp0/operstate", "r"); + if(fp == NULL){ + RLOGD("[%s]: fp == NULL", __FUNCTION__); + } + + // 文件不存在,说明还没到PPP协商部分,可能此时在拨号 + if(fp == NULL) continue; + + line[0] = 0; + fgets(line, 63, fp); + fclose(fp); + + RLOGD("[%s]: read=%s", __FUNCTION__, line); + + /* operstate 有如下值: + down: 未连接上,还在进行协商 + up: 已连接 + unknown: 已连接 + */ + if( !strncmp(line, "up", strlen("up")) || !strncmp(line, "unknown", strlen("unknown")) ) + { + property_get(RIL_LOCAL_IP, ip_local_address, ""); + + RLOGD("[%s]: local-ip=%s", __FUNCTION__, ip_local_address); + *ip_address=ip_local_address; + + // ip_address不为空 + if( ip_local_address[0] ) return 0; + } + } + + // 拨号失败或者超时,杀掉pppd进程 + kill_pppd(25); + + return -1; +} +/** +* called by requestSetupDataCall add by xxh +* +* return 0 for success +* return 1 for error; +* return 2 for ppp_error; +*/ +static int setupDataCallEth(char**response_local_ip,const char* apn) +{ +#define SUCCESS 0 +#define ERROR 1 +#define PPP_ERROR 2 + int fd; + char buffer[20]; + char exit_code[PROPERTY_VALUE_MAX]; + char result_code[PROPERTY_VALUE_MAX]; + static char local_ip[PROPERTY_VALUE_MAX]; + static char local_pdns[PROPERTY_VALUE_MAX]={0}; + static char local_sdns[PROPERTY_VALUE_MAX]={0}; + static char local_gateway[PROPERTY_VALUE_MAX]={0}; + isEth=1; + int retry = POLL_PPP_SYSFS_RETRY; + int check_result_time = 0; + int ready_for_connect = 0; + int try_connect_numbers = 0; + int err = 0; + char* cmd; + in_addr_t ipaddr,gateway,mask,dns1,dns2,server; + uint32_t lease; + + LOGD("******** Enter setupDataCallEth ********"); + + + err = at_send_command("ATH", NULL); + + + LOGD("requesting data connection to APN '%s'", apn); + asprintf(&cmd, "AT+CGDCONT=1,\"IP\",\"%s\",,0,0", apn); + err = at_send_command(cmd, NULL); + free(cmd); + if(!modem_cmp(0x05c6,0x9025,NULL)){ + + err =at_send_command("AT^NETACT=1,0",NULL); + + if(err<0) LOGD("can not act ======="); + } + + //int lte_err=0; + + //lte_err=property_set("ctl.start", SERVICE_LTE); + + //if(lte_err<0){ + + // LOGD("Can not start lteup"); + + //} + //pppd = 1; + if(!modem_cmp(0x19D2, 0x1244, NULL)||!modem_cmp(0x05c6,0x9025,NULL)){ + property_set("dhcp.lte0.result", ""); + property_set("dhcp.lte0.ipaddress", ""); + + }else{ + property_set("dhcp.eth0.result", ""); + property_set("dhcp.eth0.ipaddress", ""); + } + // Waitting for dhcpcd sucessfully + do + { + // Waitting for dhcpcd sucessfully +// sleep(3); + LOGW("******** Start dhcpcd********"); + if(!modem_cmp(0x19D2, 0x1244, NULL)||!modem_cmp(0x05c6,0x9025,NULL)) + + dhcp_do_request("lte0", &ipaddr, &gateway, &mask, &dns1, &dns2, &server, &lease); + else + dhcp_do_request("eth0", &ipaddr, &gateway, &mask, &dns1, &dns2, &server, &lease); + + // clear this counter + check_result_time = 0; + + //readinterfaceprop("/sys/class/net/eth0"); + + // this index start from 1 + LOGW("Check the lte0 stats for the %dth time", (POLL_PPP_SYSFS_RETRY - retry + 1)); + + fd = open(ETH_OPERSTATE_PATH, O_RDONLY); + if (fd >= 0) + { + LOGD("open eth_operstate_path ok"); + buffer[0] = 0; + read(fd, buffer, sizeof(buffer)); + close(fd); + + if(!strncmp(buffer, "up", strlen("up")) || !strncmp(buffer, "unknown", strlen("unknown"))) + { + + //waiting for dhcpcd completely + do + { + // Delay for max 20 seconds, the break to retry + if(check_result_time > 10) + break; + + sleep(1); + check_result_time++; + if(!modem_cmp(0x19D2, 0x1244, NULL)||!modem_cmp(0x05c6,0x9025,NULL)) + err = property_get("dhcp.lte0.result", result_code, ""); + + else + + err = property_get("dhcp.eth0.result", result_code, ""); + } + while (strcmp(result_code, "ok")); + + LOGW("Dhcpcd waste %d senconds in the %dth time", check_result_time, (POLL_PPP_SYSFS_RETRY - retry + 1)); + if(check_result_time > 21) + continue; + + // Should already get local IP address from PPP link after IPCP negotation + // system property net.ppp0.local-ip is created by PPPD in "ip-up" script + local_ip[0] = 0; + if(!modem_cmp(0x19D2, 0x1244, NULL)||!modem_cmp(0x05c6,0x9025,NULL)){ + property_get("dhcp.lte0.ipaddress", local_ip, ""); + property_get("dhcp.lte0.dns1", local_pdns, ""); + property_get("dhcp.lte0.dns2", local_sdns, ""); + property_get("dhcp.lte0.gateway", local_gateway, ""); + + LOGD("local_ip:%s",local_ip); + LOGD("local_pdns:%s",local_pdns); + LOGD("local_sdns:%s",local_sdns); + property_set("net.dns1", local_pdns); + property_set("net.dns2", local_sdns); + property_set("net.lte0.dns1", local_pdns); + property_set("net.lte0.dns2", local_sdns); + property_set("net.lte0.gw", local_gateway); + + + } + else{ + property_get("dhcp.eth0.ipaddress", local_ip, ""); + property_get("dhcp.eth0.dns1", local_pdns, ""); + property_get("dhcp.eth0.dns2", local_sdns, ""); + property_get("dhcp.eth0.gateway", local_gateway, ""); + + LOGD("local_ip:%s",local_ip); + LOGD("local_pdns:%s",local_pdns); + LOGD("local_sdns:%s",local_sdns); + property_set("net.dns1", local_pdns); + property_set("net.dns2", local_sdns); + property_set("net.eth0.dns1", local_pdns); + property_set("net.eth0.dns2", local_sdns); + property_set("net.eth0.gw", local_gateway); + } + if((!strcmp(local_ip, "")) || (!strcmp(local_ip, "0.0.0.0")) || (!strcmp(local_pdns, "")) || (!strcmp(local_sdns, ""))) + { + LOGW("eth0 link is up but no local IP is assigned. Will retry %d times after %d seconds", \ + retry, POLL_PPP_SYSFS_SECONDS); + } + else + { + LOGD("eth0 link is up with local IP address %s", local_ip); + // other info like dns will be passed to framework via property (set in ip-up script) + //response[2] = local_ip; + *response_local_ip = local_ip; + // now we think et1 is ready + break; + } + } + else + { + LOGW("eth0 link status in %s is %s. Will retry %d times after %d seconds", \ + ETH_OPERSTATE_PATH, buffer, retry, POLL_PPP_SYSFS_SECONDS); + } + } + else + { + LOGW("Can not detect eth state in %s. Will retry %d times after %d seconds", \ + ETH_OPERSTATE_PATH, retry-1, POLL_PPP_SYSFS_SECONDS); + } + sleep(POLL_PPP_SYSFS_SECONDS); + + at_send_command("ATH", NULL); + + if(!modem_cmp(0x19D2, 0x1244, NULL)||!modem_cmp(0x05c6,0x9025,NULL)) + dhcp_stop("lte0"); + else + dhcp_stop("eth0"); + } + while (--retry); + + if(retry == 0) + { + goto ppp_error; + } + + return SUCCESS; +error: + return ERROR; +ppp_error: + return PPP_ERROR; +} + +/* +static void requestSetupDataCall(void *data, size_t datalen, RIL_Token t) +{ + at_send_command("ATD18259010520;", NULL); +} +*/ + +/* + cmy: 在拨号上网时,需根据上层下传的网络类型发送 AT^SYSCONFIG 命令进行相应配置,比如: + 只连接2G/只连接3G/2G优先/3G优先 + */ +static void requestSetupDataCall(void *data, size_t datalen, RIL_Token t) +{ + char *cmd = NULL; + int err = 0; + //char ip_address[32]; + char ip_address[PROPERTY_VALUE_MAX]; + //char ip_gw[32]; + char ip_gw[PROPERTY_VALUE_MAX]; + char *response[3] = { "1", PPP_TTY_PATH, ip_address }; +// char *response[2] = { "1", PPP_TTY_PATH }; + int mypppstatus; + char strTemp[32]; + ATResponse *p_response = NULL; + // char dialup[64] = {0}; + char* dialup = NULL; + + const char* radioTechnology = ((const char**)data)[0];// GSM or CDMA + const char* profile = ((const char**)data)[1]; + const char* apn = ((const char**)data)[2]; + const char* user = ((const char**)data)[3]; + const char* password = ((const char**)data)[4]; + const char* authType = ((const char**)data)[5]; + char* option ; + int setup_data_call_result = 0; + char*response_local_ip[32]; + //canel by xxh + #if 0 + if(!modem_cmp(0x1004, 0x61AA, NULL)) + { + vl600_attach(); + /* + set ip_address + set net.[ip_address].gw + set net.[ip_address].dns1 + set net.[ip_address].dns2 + */ + RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); + at_response_free(p_response); + return; + } + //end by xxh +#endif + if(0 == modem_cmp(0x04CC, 0x225A, "TD369")) + { + dialup= "ATDT*99***1#"; + } + else if (!modem_cmp(0x106C, 0x3718, "UML290VW")) + { + dialup = "ATD*99***3#"; + } + else + { + switch(s_current_modem->radioType) + { + case RADIO_TYPE_CDMA: case RADIO_TYPE_EVDO: + dialup = "ATDT#777"; + break; + case RADIO_TYPE_TDSCDMA: + dialup = "ATDT*98*1#"; + break; + default: + dialup = "ATDT*99#"; + break; + } + } + + if(isgsm) { + // cmy: CGDCONT/CGACT两个命令都不应该失败 + if (modem_cmp(0x106C, 0x3718, "UML290VW") == 1) + { + if (!modem_cmp(0x19D2, 0x0167, "MF820")){ + asprintf(&cmd, "AT+CGDCONT=1,\"IP\",\"%s\",\"0.0.0.0\",0,0", apn); + property_set("net.ppp0.local-ip", ""); + } + else + asprintf(&cmd, "AT+CGDCONT=1,\"IP\",\"%s\",,0,0", apn); + property_set("net.ppp0.local-ip", ""); + err = at_send_command(cmd, &p_response); + free(cmd); + //FIXME check for error here + // if(err || p_response->success == 0) goto error; + } + if(0 == modem_cmp(0x05C6, 0x6000, "HSDPA Modem")) + { + err = at_send_command("AT+CGATT=1", NULL); + } + //for LC6341 + if(0 == modem_cmp(0x1AB7, 0x6341, "LC6341")) + { + // Set required QoS params to default + err = at_send_command("AT+CGEQREQ=1,2,128,2048,0,0,0,0,\"0E0\",\"0E0\",,0,0", NULL); + } + if(err) goto error; + if(!modem_cmp(0x1782, 0x0002, "V1.0.1-B7")){ + //err=at_send_command("AT+SIPMODE=0",NULL); + //err=at_send_command("AT+SPACTCFUN=1,0",NULL); + // err=at_send_command("AT+SAUTOATT=1",NULL); + // err=at_send_command("AT+SATT=1,0",NULL); + } + else{ + // Set required QoS params to default + //err = at_send_command("AT+CGQREQ=1", NULL); + // Set minimum QoS params to default + // err = at_send_command("AT+CGQMIN=1", NULL); + } + // packet-domain event reporting +// err = at_send_command("AT+CGEREP=1,0", NULL); + // Hangup anything that's happening there now + //WM66E激活PDP上下失败后,不去拨号,过滤掉此命令 + if (modem_cmp(0x19D2, 0x0167, "MF820") + && modem_cmp(0x106C, 0x3718, "UML290VW") + && modem_cmp(0x1C9E, 0x9915, "HSDPA mobile station") //smart bro WM66E + && modem_cmp(0x1C9E, 0x9914, "HSDPA mobile station")) //smart bro WM66E + { + err = at_send_command("AT+CGACT=0,1", &p_response); + // if(err || p_response->success == 0) goto error; + } + // Start data on PDP context 1 + } else if(s_first_dialup){ + s_first_dialup =0; + if(!modem_cmp(0x15EB, 0x0001, "CBP7.1T")){ + LOGD("send ATH command to modem"); + err = at_send_command("ATH", NULL); + sleep(2); + } + LOGD("for cdma setup data, should sleep 8s."); + property_set("net.ppp0.local-ip", ""); + sleep(8); + } + + if (!modem_cmp(0x05C6, 0x6000, "SEV859")) + { + asprintf(&cmd, "AT^PPPCFG=\"%s\",\"%s\"", user, password); + err = at_send_command(cmd, &p_response); + free(cmd); + } + if(!modem_cmp(0x12D1, 0x1404, "MC509-a")){ + + asprintf(&cmd, "AT^PPPCFG=\"%s\",\"%s\"", user, password); + err = at_send_command(cmd, &p_response); + free(cmd); + + } + if(!modem_cmp(0x15EB, 0x0001, "CBP7.1T")){ + err = at_send_command("ATH", NULL); + LOGD("send ATH command to modem second time"); + } + + // The modem replies immediately even if it's not connected! + // so wait a short time. + sleep(1); +// LOGD("[%s]: dial ok.", __FUNCTION__); + + char* conn_script; + char* disconn_script; + +/* + cmy: 部分Dongle,在拨号时会收到'NO CARRIER',导致ppp退出 + */ +// asprintf(&conn_script, "/system/bin/chat -v -s -S TIMEOUT 25 ABORT 'BUSY' ABORT 'NO CARRIER' ABORT 'ERROR' ABORT '+CME ERROR:' %s %s CONNECT", s_current_modem->connect_init_script, dialup); + + if(0 == modem_cmp(0x04CC, 0x225A, "TD369")) + { + option="novj"; + asprintf(&conn_script, "/system/bin/chat -v -s -S TIMEOUT 25 ABORT 'BUSY' ABORT 'NO ANSWER' %s %s CONNECT", s_current_modem->connect_init_script, dialup); + asprintf(&disconn_script, "/system/bin/chat -v -s -S ABORT 'BUSY' ABORT 'ERROR' ABORT '+CME ERROR:' %s", s_current_modem->disconnect_script); + user="cmnet"; + password="cmnet"; + //asprintf(&cmd, "/etc/ppp/call-pppd \"%s %d\" \"%s\" \"%s\" \"%s\" \"%s\" &",s_current_modem->pppchannel_index, s_current_modem->baudrate, user, password, conn_script, disconn_script); + asprintf(&cmd, "/etc/ppp/call-pppd \"%s %d\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" &",s_current_modem->pppchannel_index, s_current_modem->baudrate, option,user, password, conn_script, disconn_script); + }else if(0 == modem_cmp(0x19D2, 0xFFF1, "MC271X")) + { + option="novj"; + asprintf(&conn_script, "/system/bin/chat -v -s -S TIMEOUT 25 ABORT 'BUSY' ABORT 'NO ANSWER' %s %s CONNECT", s_current_modem->connect_init_script, dialup); + asprintf(&disconn_script, "/system/bin/chat -v -s -S ABORT 'BUSY' ABORT 'ERROR' ABORT '+CME ERROR:' %s", s_current_modem->disconnect_script); + //asprintf(&cmd, "/etc/ppp/call-pppd \"%s %d\" \"%s\" \"%s\" \"%s\" \"%s\" &",s_current_modem->pppchannel_index, s_current_modem->baudrate, user, password, conn_script, disconn_script); + asprintf(&cmd, "/etc/ppp/call-pppd \"%s %d\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" &",s_current_modem->pppchannel_index, s_current_modem->baudrate, option,user, password, conn_script, disconn_script); + } + else if(0 == modem_cmp(0x12D1, 0x1506, "E303C") ||0== modem_cmp(0x12D1, 0x1506, "E303") || 0==modem_cmp(0x12D1, 0x1506, "E369")||!modem_cmp(0x12d1, 0x1506,"E3131")||!modem_cmp(0x12D1, 0x1506, "E173")||!modem_cmp(0x12D1, 0x140C, "E173")||!modem_cmp(0x12d1,0x1506,"E3256")) + { + option="novjccomp"; + asprintf(&conn_script, "/system/bin/chat -v -s -S TIMEOUT 25 ABORT 'BUSY' ABORT 'ERROR' ABORT '+CME ERROR:' %s %s CONNECT", s_current_modem->connect_init_script, dialup); + asprintf(&disconn_script, "/system/bin/chat -v -s -S ABORT 'BUSY' ABORT 'ERROR' ABORT '+CME ERROR:' %s", s_current_modem->disconnect_script); + asprintf(&cmd, "/etc/ppp/call-pppd \"%s %d\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" &",s_current_modem->pppchannel_index, s_current_modem->baudrate,option,user, password, conn_script, disconn_script); + } + else + { + option="novj"; + asprintf(&conn_script, "/system/bin/chat -v -s -S TIMEOUT 25 ABORT 'BUSY' ABORT 'ERROR' ABORT '+CME ERROR:' %s %s CONNECT", s_current_modem->connect_init_script, dialup); + asprintf(&disconn_script, "/system/bin/chat -v -s -S ABORT 'BUSY' ABORT 'ERROR' ABORT '+CME ERROR:' %s", s_current_modem->disconnect_script); + asprintf(&cmd, "/etc/ppp/call-pppd \"%s %d\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" &",s_current_modem->pppchannel_index, s_current_modem->baudrate, option,user, password, conn_script, disconn_script); + } + +#ifdef ENABLE_STAY_AWAKE + if(s_current_modem->radioType==RADIO_TYPE_CDMA || s_current_modem->radioType==RADIO_TYPE_EVDO||!modem_cmp(0x12D1, 0x1D09, "ET127/158/128-2")||!modem_cmp(0x12D1, 0x1D50, "ET302/306")) + { + LOGD("[%s]: acquire_wake_lock: %s\n", __FUNCTION__, WAKE_LOCK_ID); + acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID); + } +#endif +#if 0 + if(0 == modem_cmp(0x106C, 0x3718, NULL)) + at_emulate_enter(); +#endif + if(!modem_cmp(0x216F, 0x0047, "ALT3100") ||!modem_cmp(0x19D2, 0x1244, "K4201-Z")||!modem_cmp(0x05c6,0x9025, NULL)){ + + + setup_data_call_result = setupDataCallEth(response_local_ip,apn); + if(setup_data_call_result == 1) + { + goto error; + } + response[1]=PPP_ETH_PATH; + response[2] = *response_local_ip; + //ip_address + char ip_gw[PROPERTY_VALUE_MAX]={0}; + property_get("dhcp.lte0.gateway", ip_gw, ""); + LOGD("[%s]: local-gw=%s", __FUNCTION__, ip_gw); + LOGD("******** lte0 local ip %s",response[2]); + + } + else + { + LOGD("[%s]: execute cmd:\n%s", __FUNCTION__, cmd); + mypppstatus = system(cmd); + free(cmd); + free(conn_script); + free(disconn_script); + LOGD("[%s] mypppstatus=%d", __FUNCTION__, mypppstatus); + char*response_local_ip[32]; + if ( (mypppstatus < 0) || getpppstatus(response_local_ip) ) //ip_address + { +#ifdef ENABLE_STAY_AWAKE + if(s_current_modem->radioType==RADIO_TYPE_CDMA || s_current_modem->radioType==RADIO_TYPE_EVDO||!modem_cmp(0x12D1, 0x1D09, "ET127/158/128-2")||!modem_cmp(0x12D1, 0x1D50, "ET302/306")) + { + LOGD("[%s]: release_wake_lock: %s\n", __FUNCTION__, WAKE_LOCK_ID); + release_wake_lock(WAKE_LOCK_ID); + } +#endif + goto error; + } + //response[2]=ip_address; + response[2] = *response_local_ip; + property_get("net.ppp0.gw", ip_gw, ""); + LOGD("[%s]: local-gw=%s", __FUNCTION__, ip_gw); + + // 新建进程,用于监视pppd的运行状况 + LOGD("create thread for pppd state!"); + if( pthread_create(&s_tid_pppdState, NULL, pppdStateLoop, NULL) ) + { + LOGD("thread create failed!"); + } +} +#if (RIL_VERSION >= 6) + { + RIL_Data_Call_Response_v6 response_v6; + response_v6.status = 0; + response_v6.suggestedRetryTime = -1; + response_v6.cid = 1;//response[0]; + response_v6.active = 2; + response_v6.type = "IP"; + response_v6.addresses = response[2]; + response_v6.dnses = NULL; + response_v6.gateways = ip_gw; + response_v6.ifname = response[1]; + RLOGD("[%s]: sizeof(RIL_Data_Call_Response_v6)=%d", __FUNCTION__,sizeof(RIL_Data_Call_Response_v6)); + RIL_onRequestComplete(t, RIL_E_SUCCESS, &response_v6, sizeof(RIL_Data_Call_Response_v6)); + } +#else + RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); +#endif + + at_response_free(p_response); + return; + +error: + LOGD("[%s]: failed", __FUNCTION__); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + at_response_free(p_response); + #if 0 + if(0 == modem_cmp(0x106C, 0x3718, NULL)) + at_emulate_exit(); + #endif +} + +static void requestDeactivateDefaultPDP(void *data, size_t datalen, RIL_Token t) +{ + int err; + char * cmd; + char *netcfg; + char * cid; + int fd,i,fd2; + ATResponse *p_response = NULL; + + pthread_cond_signal(&s_waitcond); + +#if 1 +// 此时是否有必要发送AT命令? + cid = ((char **)data)[0]; +if(!modem_cmp(0x19d2,0x1244,NULL)){ + +err=dhcp_stop("lte0"); +if(err<0) +{ +LOGW("Can not down the lte0 link"); + goto error; +} +system("netcfg lte0 down"); +RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); +return; +}else{ + if (isgsm) { + // AT+CGACT=0,1 + asprintf(&cmd, "AT+CGACT=0,%s", cid); + + err = at_send_command(cmd, &p_response); + free(cmd); + at_response_free(p_response); + } + else + { +// err = at_send_command("ATH", NULL); +// sleep(2); + } +#else + if(!isgsm) + { + // cmy: 部分modem使用ATH指令即可close ppp + err = at_send_command("ATH", NULL); + sleep(2); + } +#endif + +#ifdef ENABLE_STAY_AWAKE + if(s_current_modem->radioType==RADIO_TYPE_CDMA || s_current_modem->radioType==RADIO_TYPE_EVDO||!modem_cmp(0x12D1, 0x1D09, "ET127/158/128-2")||!modem_cmp(0x12D1, 0x1D50, "ET302/306")) + { + LOGD("[%s]: release_wake_lock: %s\n", __FUNCTION__, WAKE_LOCK_ID); + release_wake_lock(WAKE_LOCK_ID); + } +#endif + + if( kill_pppd(25)<0 ) goto error; + + sleep(2); + + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + return; + } +error: + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); +} + +static void requestEnterSimPin(int request,void* data, size_t datalen, RIL_Token t) +{ + ATResponse *p_response = NULL; + int err; + char* cmd = NULL; + const char** strings = (const char**)data; + + int count = datalen/sizeof(char*); + if(strings[count-1] == NULL) + --count; + + if(1/*isgsm*/) { + if ( count == 1 ){ + asprintf(&cmd, "AT+CPIN=\"%s\"", strings[0]); + } + else if ( count == 2 ) { +// 实际测试发现要用CPIN命令来解开PUK码 + if(!modem_cmp(0x0e8d,0x00a2,"MTK2")){ //usi modem + LOGE("USI request enter sim pin ===================="); + asprintf(&cmd, "AT+CPIN=\"%s\"", strings[0]); + } + else{ + asprintf(&cmd, "AT+CPIN=\"%s\",\"%s\"", strings[0], strings[1]); + // asprintf(&cmd, "AT+CPWD=\"SC\",\"%s\",\"%s\"", strings[0], strings[1]); + if(request == RIL_REQUEST_ENTER_SIM_PUK || request == RIL_REQUEST_ENTER_SIM_PUK2) { + asprintf(&cmd, "AT+CPIN=\"%s\",\"%s\"", strings[0], strings[1]); + }else if(request == RIL_REQUEST_CHANGE_SIM_PIN || request == RIL_REQUEST_CHANGE_SIM_PIN2){ + asprintf(&cmd, "AT+CPWD=\"SC\",\"%s\",\"%s\"", strings[0], strings[1]); + } + } + } + else + + goto error; + +// cmy: "AT+CPIN=..." 命令不返回 "+CPIN: ..." +// err = at_send_command_singleline(cmd, "+CPIN:", &p_response); + err = at_send_command(cmd, &p_response); + free(cmd); + + if (err < 0 || p_response->success == 0) { +error: + RIL_onRequestComplete(t, RIL_E_PASSWORD_INCORRECT, NULL, 0); + } else { + if ( count == 1 )//PIN码验证成功后需等待一段时间 + { + // 确认可收发AT指令 + LOGE("cpin correct===================="); + sleep(3); + sim_pin = 0; + if(check_at_ready("AT+CIMI", 80)) + { + LOGE("AT handshake failed!!!"); + RIL_onRequestComplete(t, RIL_E_PASSWORD_INCORRECT, NULL, 0); + return; + } + +// sleep(3); + } + if(!modem_cmp(0x0e8d,0x00a2,"MTK2")){ + + // RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + // RIL_requestTimedCallback(atinit, NULL, &TIMEVAL_0); + LOGE("USI cpin correct===================="); + sleep(5); //输入pin码后,需要给modem一点时间初始化sim卡信息 + + } + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + /* Notify that SIM is ready */ + setRadioState(RADIO_STATE_SIM_READY); + } + at_response_free(p_response); + } else { + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + setRadioState(RADIO_STATE_SIM_READY); + } +} + +static void unsolicitedNitzTime(const char * s) +{ + int err; + char * response = NULL; + char * line = NULL; + char * p = NULL; + char * tz = NULL; /* Timezone */ + line = strdup(s); + + /* Higher layers expect a NITZ string in this format: + * 08/10/28,19:08:37-20,1 (yy/mm/dd,hh:mm:ss(+/-)tz,dst) + */ + + if(strStartsWith(s,"+CTZV:")){ + + /* Get Time and Timezone data and store in static variable. + * Wait until DST is received to send response to upper layers + */ + at_tok_start(&line); + + err = at_tok_nextstr(&line, &tz); + if (err < 0) goto error; + + err = at_tok_nextstr(&line, &response); + if (err < 0) goto error; + + strcat(response,tz); + + sNITZtime = response; + return; + + } + else if(strStartsWith(s,"+CTZDST:")){ + + /* We got DST, now assemble the response and send to upper layers */ + at_tok_start(&line); + + err = at_tok_nextstr(&line, &tz); + if (err < 0) goto error; + + asprintf(&response, "%s,%s", sNITZtime, tz); + + RIL_onUnsolicitedResponse(RIL_UNSOL_NITZ_TIME_RECEIVED, response, strlen(response)); + free(response); + return; + + } + else if(strStartsWith(s, "+HTCCTZV:")){ + at_tok_start(&line); + + err = at_tok_nextstr(&line, &response); + if (err < 0) goto error; + RIL_onUnsolicitedResponse(RIL_UNSOL_NITZ_TIME_RECEIVED, response, strlen(response)); + return; + + } + +error: + LOGE("Invalid NITZ line %s\n", s); +} + +static void unsolicitedRSSI(const char * s) +{ + int err; + int response[2]; + char * line = NULL; + + line = strdup(s); + + err = at_tok_start(&line); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &(response[0])); + if (err < 0) goto error; + +// err = at_tok_nextint(&line, &(response[1])); +// if (err < 0) goto error; +// cmy: 为什么要乘以2 +// response[0]*=2; + response[1]=99; + + signalStrength[0]=response[0]; + signalStrength[1]=response[1]; +// free(line); + +// cmy: 主动RIL_UNSOL_SIGNAL_STRENGTH会导致上层不再定时查询信号强度 +// RIL_onUnsolicitedResponse(RIL_UNSOL_SIGNAL_STRENGTH, response, sizeof(response)); + return; + +error: + /* The notification was for a battery event - do not send a msg to upper layers */ + return; +} + +static void unsolicitedRSSILVL(const char * s) +{ + int err; + int response; + char * line = NULL; + int value = 0; + + line = strdup(s); + + err = at_tok_start(&line); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &response); + if (err < 0) goto error; + +/* + 转换在GSM所用的数值,以便上层统一处理 + */ + switch(response) + { + case 0: + value = 0; + break; + case 20: + value = 4; + break; + case 40: + value = 12; + break; + case 60: + value = 18; + break; + case 80: + value = 26; + break; + case 99: + value=34; + break; + default: + value = 0; + break; + } + + signalStrength[0]=value; + signalStrength[1]=99; + +// cmy: 主动RIL_UNSOL_SIGNAL_STRENGTH会导致上层不再定时查询信号强度 +// RIL_onUnsolicitedResponse(RIL_UNSOL_SIGNAL_STRENGTH, response, sizeof(response)); + return; + +error: + /* The notification was for a battery event - do not send a msg to upper layers */ + return; +} +static void unsolicitedHDRRSSI(const char * s){//add by xxh + + int err; + int response[2]; + char * line = NULL; + + line = strdup(s); + + err = at_tok_start(&line); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &(response[0])); + if (err < 0) goto error; + response[1]=99; + LOGD("[%s]: HDR Uosolicited signalStrenth=%d\n", __FUNCTION__, response[0]); + + signalStrength_hdr[0]=response[0]; + signalStrength_hdr[1]=response[1]; +// free(line); +// cmy: 主动RIL_UNSOL_SIGNAL_STRENGTH会导致上层不再定时查询信号强度 +// RIL_onUnsolicitedResponse(RIL_UNSOL_SIGNAL_STRENGTH, response, sizeof(response)); + return; +error: + /* The notification was for a battery event - do not send a msg to upper layers */ + return; + + +} +static void unsolicitedHRSSILVL(const char * s) +{ + int err; + int response; + char * line = NULL; + int value = 0; + + line = strdup(s); + + err = at_tok_start(&line); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &response); + if (err < 0) goto error; + +/* + 转换成GSM所用的数值,以便上层统一处理 + */ + switch(response) + { + case 0: + value = 0; + break; + case 20: + value = 4; + break; + case 40: + value = 12; + break; + case 60: + value = 18; + break; + case 80: + value = 26; + break; + case 99: + value = 34; + break; + default: + value = 99; + break; + } + + signalStrength_hdr[0]=value; + signalStrength_hdr[1]=99; + + return; +error: + /* The notification was for a battery event - do not send a msg to upper layers */ + return; +} +static void requestNotSupported(RIL_Token t) +{ + RIL_onRequestComplete(t, RIL_E_REQUEST_NOT_SUPPORTED, NULL, 0); + return; +} + +static void requestSetFacilityLock(void *data, size_t datalen, RIL_Token t) +{ + /* It must be tested if the Lock for a particular class can be set without + * modifing the values of the other class. If not, first must call + * requestQueryFacilityLock to obtain the previus value + */ + int err = 0; + char *cmd = NULL; + char *code = NULL; + char *lock = NULL; + char *password = NULL; + //char *class = NULL; + ATResponse *p_response = NULL; + + assert (datalen >= (4 * sizeof(char **))); + + code = ((char **)data)[0]; + lock = ((char **)data)[1]; + password = ((char **)data)[2]; +// class = ((char **)data)[3]; + +// asprintf(&cmd, "AT+CLCK=\"%s\",%s,\"%s\",%s", code, lock, password, class); + LOGD(" code=%s lock=%s password=%s ",code, lock, password); + asprintf(&cmd, "AT+CLCK=\"%s\",%s,\"%s\"", code, lock, password); + err = at_send_command(cmd, &p_response); + free(cmd); + if (err < 0 || p_response->success == 0){ + goto error; + } + + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + at_response_free(p_response); + return; + +error: + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + at_response_free(p_response); +} + +static void requestChangeBarringPassword(void *data, size_t datalen, RIL_Token t) +{ + int err = 0; + char *cmd = NULL; + char *string = NULL; + char *old_password = NULL; + char *new_password = NULL; + + assert (datalen >= (3 * sizeof(char **))); + + string = ((char **)data)[0]; + old_password = ((char **)data)[1]; + new_password = ((char **)data)[2]; + + asprintf(&cmd, "AT+CPWD=\"%s\",\"%s\",\"%s\"", string, old_password, new_password); + err = at_send_command(cmd, NULL); + + free(cmd); + + if (err < 0) goto error; + + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + return; + +error: + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); +} + +/* cmy: 目前手动选择网络的方案 + 1 成功,记录当前选择的网络 + 2 失败,重新设置为 AT+COPS=0,且记录为"自动选择网络" + 当前网络选择登记在如下文件: + /data/data/com.android.phone/shared_prefs/com.android.phone_preferences.xml + */ +/* cmy: 手动选择网络(中国移动、中国联通...) + AT+COPS=1,2,"46000" + */ +static void requestSetNetworkSelectionManual(void *data, size_t datalen, RIL_Token t) +{ + char *operator = NULL; + char *cmd = NULL; + int err = 0; + ATResponse *p_response = NULL; + + if( !isgsm ) + { + RIL_onRequestComplete(t, RIL_E_REQUEST_NOT_SUPPORTED, NULL, 0); + return; + } + + operator = (char *)data; + asprintf(&cmd, "AT+COPS=1,2,\"%s\"", operator); +// cmy: 设置了30秒的超时时间 +// 超时返回时, p_response = null + err = at_send_command(cmd, &p_response); +// LOGD("err=%d p_response=%p", err, p_response); + if (err < 0 || p_response == NULL || p_response->success==0 ){ + LOGD("network manual select failed, reset to auto select"); + at_send_command("AT+COPS=0", &p_response); + goto error; + } + + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + at_response_free(p_response); + free(cmd); + return; + +error: + at_response_free(p_response); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); +} + +static void requestResetRadio(RIL_Token t) +{ + int err = 0; + +// err = at_send_command("AT+CFUN=16", NULL); + if(err < 0) + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + else + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + + return; +} + +static void requestSetSuppSVCNotification(void *data, size_t datalen, RIL_Token t) +{ + int err = 0; + int enabled = 0; + char *cmd = NULL; + enabled = ((int *)data)[0]; + + asprintf(&cmd, "AT+CSSN=%d,%d", enabled, enabled); + err = at_send_command(cmd,NULL); + free(cmd); + if(err < 0) + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + else + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); +} + +static void requestSetLocationUpdates(void *data, size_t datalen, RIL_Token t) +{ + int err = 0; + int updates = 0; + char *cmd = NULL; + ATResponse *p_response = NULL; + updates = ((int *)data)[0] == 1? 2 : 1; + + asprintf(&cmd, "AT+CREG=%d", updates); + +// cmy@20101223: +// err = at_send_command_singleline(cmd,"+CREG:",&p_response); + err = at_send_command(cmd, &p_response); + if(err < 0 || p_response->success == 0) goto error; + + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + at_response_free(p_response); + return; + +error: + at_response_free(p_response); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); +} + +static void requestLastFailCause(RIL_Token t) +{ + ATResponse *p_response = NULL; + int err = 0; + int response = 0; + char *tmp = NULL; + char *line = NULL; + + err = at_send_command_singleline("AT+CEER", "+CEER:", &p_response); + if(err < 0 || p_response->success == 0) goto error; + + line = p_response->p_intermediates->line; + err = at_tok_start(&line); + if(err < 0) goto error; + + err = at_tok_nextstr(&line, &tmp); + if(err < 0) goto error; + + err = at_tok_nextint(&line, &response); + if(err < 0) goto error; + + RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(int)); + at_response_free(p_response); + return; + +error: + at_response_free(p_response); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); +} + +static int GetIMSI(char* imsi) +{ + ATResponse *p_response = NULL; + char *line; + char *response; + char *part; + int err; + + int loop = 0; + int success = 0; + /* We are looping here because the command fails on the first try. + What needs to be done, is to trap the "+CME ERROR: 14" which means + SIM BUSY and retry that. As a workaround for now, simply try, wait + 1 second, and try again, until a valid result is obtained. Usually only + takes 2 tries. + */ +/* + +CIMI: 460020059343258 + 460019602709144 + */ + for(loop=2; loop>0; loop--) + { + err = at_send_command_numeric("AT+CIMI", &p_response); + if (err < 0 || p_response->success == 0) + { + at_response_free(p_response); + p_response = NULL; + + if (!modem_cmp(0x19D2, 0xFFF1, "AC27XX")) + // response = getCommandResponse("AT+CIMI", "CIMI:", 1); + //国外AC2787 + response = getCommandResponse("AT+CIMI", "^CIMI:", 1); + else if(!modem_cmp(0x20A6, 0x1105, "Test number")){ + response="460039602709144";//手机modem + } + else{ + err = at_send_command_singleline("AT+CIMI", "+CIMI:", &p_response); + if (err < 0 || p_response->success == 0) goto loop_error; + line = p_response->p_intermediates->line; + err = at_tok_start(&line); + if(err < 0) goto loop_error; + err = at_tok_nextstr(&line, &response); + if(err < 0) goto loop_error; + } + } + else + { + response = p_response->p_intermediates->line; + } + strcpy(imsi, response); + + success=1; + break; + +loop_error: + at_response_free(p_response); + p_response = NULL; + } + + if (success == 0) goto error; + + at_response_free(p_response); + return 0; + +error: + at_response_free(p_response); + return -1; +} + +static void requestGetIMSI(RIL_Token t) +{ + if( GetIMSI(IMSI) != 0 ) + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + else + RIL_onRequestComplete(t, RIL_E_SUCCESS,IMSI, sizeof(char *)); +} + +/* + other - ok + NULL - failed + */ +static char* check_did(const char* did) +{ + if( strlen(did) < 8 ) + return NULL; + + if(did[0]=='0' && (did[1]=='x' || did[1]=='X') ) + did += 2; + + int count = 0; + char v = 0; + while( (v = did[count++]) !=0 ) + { + if( !((v>='0' && v<='9') || (v>='a' && v<='f') || (v>='A' && v<='F')) ) + break; + } +// LOGD("count=%d, did=%s", count, did); + + return (v==0)?(char *)did:NULL; +} + +static void requestGetIMEI(RIL_Token t, int request) +{ + int err = 0; + char *response = NULL; + +/* + +CGSN: 860061000450164 + 860061000450164 + case RADIO_TYPE_GSM: + case RADIO_TYPE_WCDMA: + case RADIO_TYPE_TDSCDMA: + + +GSN:a3e2503b + 0xA3E2503B + */ + if( s_current_modem->radioType==RADIO_TYPE_GSM || + s_current_modem->radioType==RADIO_TYPE_WCDMA|| + s_current_modem->radioType==RADIO_TYPE_TDSCDMA) + { + + response = getCommandResponse("AT+CGSN", "GSN:", 3); + } + else + { + /* + AT> AT^MEID + AT< ^MEID:00000000000000 + */ + response = getCommandResponse("AT^MEID", "^MEID:", 3); + + if ( response==NULL ) + goto meid_err; + + if( check_did(response)==NULL || atox(response,16)==0 ) + goto meid_err; + + RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(char *)); + free(response); + return; + +meid_err: + free(response); + LOGD("get meid failed or invalid meid!"); + response = getCommandResponse("AT+GSN", "GSN:", 3); + } + + if (response==NULL) + goto error; + + if( check_did(response) == NULL ) + goto error; + + char *tResponse = check_did(response); + + RIL_onRequestComplete(t, RIL_E_SUCCESS, tResponse, sizeof(char *)); + free(response); + + if(nosimcard==1){ + + setModemPower(0); //查询到IMEI码后才关闭模块 + } + return; + +// cmy: 部分Modem(E169)查询IMEI失败,在此情况下返回一个虚假的值 +#if 0 +error: + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + at_response_free(p_response); +#else +error: + free(response); + if( isgsm ) + { + response = "123456789012345"; // IMEI + LOGD("CURRENT IMEI IS 123456789012345!"); + } + else + response = "12345678"; // ESN + + RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(char *)); +// at_response_free(p_response); +#endif +} + +static void requestGetIMEISV(RIL_Token t, int request) +{ + char imeisv[4]; + + if(!modem_cmp(0x12d1, 0x1506, "E1220")){ + + char *response = NULL; + + response = getCommandResponse("AT^ICCID?", "^ICCID:", 3); + + RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(char *)); + + + }else{ + char imeisv[4] = "00"; + RIL_onRequestComplete(t, RIL_E_SUCCESS, imeisv, sizeof(char *)); + + } + return; +} + +/* cmy: 自动选择网络 + */ +static void requestSetNetworkSelectionAutomatic(RIL_Token t) +{ + int err = 0; + + LOGD("Enter requestSetNetworkSelectionAutomatic"); +//cmy: cdma not support 'cops' commands + if(!isgsm) + { + LOGD("[%s]: CDMA not supported!", __FUNCTION__); + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + return; + } + +// cmy: for AST +#if 1 +// cmy: 如果目前已经是自动选择模式,不用再次设置,否则会导致重新注册网络 + if( queryNetworkSelectionMode() != 0 ) + { + err = at_send_command("AT+COPS=0", NULL); + } +#endif + + if(err < 0) + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + else + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + + return; +} + +static void requestSendUSSD(void *data, size_t datalen, RIL_Token t) +{ + ATResponse *p_response = NULL; + int err = 0; + int len; + cbytes_t ussdRequest; + char *cmd; + bytes_t temp; + char *newUSSDRequest; + if(isgsm) { + ussdRequest = (cbytes_t)(data); + temp = malloc(strlen((char *)ussdRequest)*sizeof(char)+1); + len = utf8_to_gsm8(ussdRequest,strlen((char *)ussdRequest),temp); + newUSSDRequest = malloc(2*len*sizeof(char)+1); + gsm_hex_from_bytes(newUSSDRequest,temp, len); + newUSSDRequest[2*len]='\0'; + asprintf(&cmd, "AT+CUSD=1,\"%s\",15", newUSSDRequest); + free(newUSSDRequest); + free(temp); + err = at_send_command(cmd, &p_response); + free(cmd); + if (err < 0 || p_response->success == 0) { + goto error; + } else { + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + } + at_response_free(p_response); + } else { + RIL_onRequestComplete(t, RIL_E_REQUEST_NOT_SUPPORTED, NULL, 0); + } + return; + +error: + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); +} + +static void requestCancelUSSD(RIL_Token t) +{ + int err = 0; + ATResponse *p_response = NULL; + + err = at_send_command_numeric("AT+CUSD=2", &p_response); + + if (err < 0 || p_response->success == 0){ + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + } + else{ + RIL_onRequestComplete(t, RIL_E_SUCCESS, + p_response->p_intermediates->line, sizeof(char *)); + } + + at_response_free(p_response); + return; +} + +#ifdef SUPPORT_SMS +static void requestSendSMS(void *data, size_t datalen, RIL_Token t) +{ + int err; + const char *smsc; + const char *pdu; + int tpLayerLength; + char *cmd1, *cmd2; + RIL_SMS_Response response; + ATResponse *p_response = NULL; + + smsc = ((const char **)data)[0]; + pdu = ((const char **)data)[1]; + + tpLayerLength = strlen(pdu)/2; + + // "NULL for default SMSC" + if (smsc == NULL) { + smsc= "00"; + } + + LOGD("SMSC==%s PDU=%s",smsc,pdu); + asprintf(&cmd1, "AT^HCMGS=%d", tpLayerLength); + asprintf(&cmd2, "%s%s", smsc, pdu); + + err = at_send_command_sms(cmd1, cmd2, "^HCMGS:", &p_response); + free(cmd1);free(cmd2); + if (err != 0 || p_response->success == 0) goto error; + + memset(&response, 0, sizeof(response)); + + /* FIXME fill in messageRef and ackPDU */ + + RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(response)); + at_response_free(p_response); + + return; +error: + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + at_response_free(p_response); +} +static void requestWriteSmsToSim(void *data, size_t datalen, RIL_Token t) +{ + RIL_SMS_WriteArgs *p_args; + char *cmd; + int length; + int err; + ATResponse *p_response = NULL; + + p_args = (RIL_SMS_WriteArgs *)data; + + length = strlen(p_args->pdu)/2; + asprintf(&cmd, "AT+CMGW=%d,%d", length, p_args->status); + + err = at_send_command_sms(cmd, p_args->pdu, "+CMGW:", &p_response); + free(cmd); + + if (err != 0 || p_response->success == 0) goto error; + + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + at_response_free(p_response); + + return; +error: + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + at_response_free(p_response); +} +#endif +#if 0 +static void unsolicitedUSSD(const char *s) +{ + char *line, *linestart; + int typeCode, count, err, len; + unsigned char *message; + unsigned char *outputmessage; + char *responseStr[2]; + + LOGD("unsolicitedUSSD %s\n",s); + + linestart=line=strdup(s); + err = at_tok_start(&line); + if(err < 0) goto error; + + err = at_tok_nextint(&line, &typeCode); + if(err < 0) goto error; + + if(at_tok_hasmore(&line)) { + err = at_tok_nextstr(&line, &message); + if(err < 0) goto error; + outputmessage = malloc(strlen(message)*2+1); + gsm_hex_to_bytes(message,strlen(message),outputmessage); + responseStr[1] = malloc(strlen(outputmessage)*2+1); + len = utf8_from_gsm8(outputmessage,strlen(outputmessage),responseStr[1]); + responseStr[1][strlen(message)/2]='\0'; + free(outputmessage); + count = 2; + } else { + responseStr[1]=NULL; + count = 1; + } + free(linestart); + asprintf(&responseStr[0], "%d", typeCode); + + RIL_onUnsolicitedResponse (RIL_UNSOL_ON_USSD, responseStr, count*sizeof(char*)); + return; + +error: + LOGE("unexpectedUSSD error\n"); +} +#endif +static void requestNeighboringCellIds(void * data, size_t datalen, RIL_Token t) +{ + int i=0; + int response[4]={0}; + int count = 0; + RIL_NeighboringCell *p_cellIds; + + p_cellIds = (RIL_NeighboringCell *)alloca(sizeof(RIL_NeighboringCell)); + + for (i=0; i<4; i++) { + if( !getRegistrationInfo(&response[0], &count) ) + break; + } + if (i<4) + { + p_cellIds[0].rssi = 2; + if(s_current_modem->modem_info.vid==0x19d2){ + asprintf(&(p_cellIds[0].cid), "%08x", response[2]); + }else + asprintf(&(p_cellIds[0].cid), "%x", response[2]); + RIL_onRequestComplete(t, RIL_E_SUCCESS, &p_cellIds, sizeof(p_cellIds)); + } + else + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + + +} + + + +/*** Callback methods from the RIL library to us ***/ + +/** + * Call from RIL to us to make a RIL_REQUEST + * + * Must be completed with a call to RIL_onRequestComplete() + * + * RIL_onRequestComplete() may be called from any thread, before or after + * this function returns. + * + * Will always be called from the same thread, so returning here implies + * that the radio is ready to process another command (whether or not + * the previous command has completed). + */ +static void +onRequest (int request, void *data, size_t datalen, RIL_Token t) +{ + ATResponse *p_response; + int err; + + RLOGD("onRequest: %s", requestToString(request)); + + + /* Ignore all requests except RIL_REQUEST_GET_SIM_STATUS + * when RADIO_STATE_UNAVAILABLE. + */ + if (sState == RADIO_STATE_UNAVAILABLE + && request != RIL_REQUEST_GET_SIM_STATUS + ) { + RIL_onRequestComplete(t, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0); + return; + } + + /* Ignore all non-power requests when RADIO_STATE_OFF + * (except RIL_REQUEST_GET_SIM_STATUS) + */ + if (sState == RADIO_STATE_OFF + && !(request == RIL_REQUEST_RADIO_POWER + || request == RIL_REQUEST_GET_SIM_STATUS) + ) { + RIL_onRequestComplete(t, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0); + return; + } + + switch (request) { + case RIL_REQUEST_GET_SIM_STATUS: +#if 0 + { + int simStatus; + simStatus = getSIMStatus(); + RIL_onRequestComplete(t, RIL_E_SUCCESS, &simStatus, sizeof(simStatus)); + break; + } +#else + { + RIL_CardStatus *p_card_status; + char *p_buffer; + int buffer_size; + + int result = getCardStatus(&p_card_status); + if (result == RIL_E_SUCCESS) { + p_buffer = (char *)p_card_status; + buffer_size = sizeof(*p_card_status); + } else { + p_buffer = NULL; + buffer_size = 0; + } + RIL_onRequestComplete(t, result, p_buffer, buffer_size); + freeCardStatus(p_card_status); + break; + } +#endif + case RIL_REQUEST_GET_CURRENT_CALLS: + requestGetCurrentCalls(data, datalen, t); + break; + case RIL_REQUEST_SIGNAL_STRENGTH: + requestSignalStrength(data, datalen, t); + break; + + case RIL_REQUEST_REGISTRATION_STATE: + case RIL_REQUEST_GPRS_REGISTRATION_STATE: + requestRegistrationState(request, data, datalen, t); + break; + + case RIL_REQUEST_SCREEN_STATE: + requestScreenState(data, datalen, t); + break; + + case RIL_REQUEST_OPERATOR: + requestOperator(data, datalen, t); + break; + case RIL_REQUEST_RADIO_POWER: + requestRadioPower(data, datalen, t); + break; + case RIL_REQUEST_QUERY_FACILITY_LOCK: + requestQueryFacilityLock(data, datalen, t); + break; + + case RIL_REQUEST_SETUP_DATA_CALL: + requestSetupDataCall(data, datalen, t); + break; + + case RIL_REQUEST_DEACTIVATE_DATA_CALL: + requestDeactivateDefaultPDP(data, datalen, t); + break; + + case RIL_REQUEST_GET_IMSI: + requestGetIMSI(t); + break; + + case RIL_REQUEST_BASEBAND_VERSION: + requestBasebandVersion(data, datalen, t); + // requestBaseBandVersionT(request, data, datalen, t); + break; + + case RIL_REQUEST_GET_IMEI: + requestGetIMEI(t, request); + break; + case RIL_REQUEST_GET_IMEISV: + requestGetIMEISV(t, request); + break; + case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: + requestSetNetworkSelectionAutomatic(t); + break; + + case RIL_REQUEST_DATA_CALL_LIST: + requestDataCallList(data, datalen, t); + break; + + case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: + requestQueryNetworkSelectionMode(data, datalen, t); + break; + + case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: + requestQueryAvailableNetworksxxh(data, datalen, t); + break; + + case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: + requestGetPreferredNetworkType(data, datalen, t); + break; + + case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: + requestSetPreferredNetworkType(data, datalen, t); + break; + + case RIL_REQUEST_ENTER_SIM_PIN: + case RIL_REQUEST_ENTER_SIM_PUK: + case RIL_REQUEST_ENTER_SIM_PIN2: + case RIL_REQUEST_ENTER_SIM_PUK2: + case RIL_REQUEST_CHANGE_SIM_PIN: + case RIL_REQUEST_CHANGE_SIM_PIN2: + requestEnterSimPin(request,data, datalen, t); + break; + + case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: + // NOTE: There isn't an AT command with this capability + requestNotSupported(t); + break; + + case RIL_REQUEST_SET_FACILITY_LOCK: + requestSetFacilityLock(data, datalen, t); + break; + + case RIL_REQUEST_CHANGE_BARRING_PASSWORD: + requestChangeBarringPassword(data, datalen, t); + break; + + case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: + requestSetNetworkSelectionManual(data, datalen, t); + break; + + case RIL_REQUEST_RESET_RADIO: + requestResetRadio(t); + break; + + case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: + requestSetSuppSVCNotification(data, datalen, t); + break; + + case RIL_REQUEST_SET_LOCATION_UPDATES: + requestSetLocationUpdates(data, datalen, t); + break; + + case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: + case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: + requestLastFailCause(t); + break; + case RIL_REQUEST_SIM_IO: + //测试发现对CDMA不支持 + //if(isgsm){ + // LOGD("=======huawei wcdma sim io======"); + requestSIM_IO(data,datalen,t); + //} + + break; + case RIL_REQUEST_SEND_USSD: + // requestSendUSSD(data, datalen, t); + break; + + case RIL_REQUEST_CANCEL_USSD: + //requestCancelUSSD(t); + break; + + case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: + requestNeighboringCellIds(data, datalen, t); + break; + +#ifdef SUPPORT_SMS + case RIL_REQUEST_SEND_SMS: + requestSendSMS(data, datalen, t); + break; + case RIL_REQUEST_CDMA_SEND_SMS: + //requestSendCdmaSms(data, datalen, t); + break; + case RIL_REQUEST_WRITE_SMS_TO_SIM: + requestWriteSmsToSim(data, datalen, t); + break; + case RIL_REQUEST_DELETE_SMS_ON_SIM: { + char * cmd; + p_response = NULL; + asprintf(&cmd, "AT+CMGD=%d", ((int *)data)[0]); + err = at_send_command(cmd, &p_response); + free(cmd); + if (err < 0 || p_response->success == 0) { + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + } else { + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + } + at_response_free(p_response); + break; + } +#endif + default: + requestNotSupported(t); + break; + } +} + +/** + * Synchronous call from the RIL to us to return current radio state. + * RADIO_STATE_UNAVAILABLE should be the initial state. + */ +static RIL_RadioState +currentState() +{ + return sState; +} +/** + * Call from RIL to us to find out whether a specific request code + * is supported by this implementation. + * + * Return 1 for "supported" and 0 for "unsupported" + */ + +static int +onSupports (int requestCode) +{ + //@@@ todo + + return 1; +} + +static void onCancel (RIL_Token t) +{ + //@@@todo + +} + +static const char * getVersion(void) +{ + return REFERENCE_RIL_VERSION; +} + +static void +setRadioState(RIL_RadioState newState) +{ +#ifdef DBG_1 + LOGD("[%s]: oldstate=%d newstate=%d s_closed=%d\n", __FUNCTION__, sState, newState, s_closed); +#endif + + RIL_RadioState oldState; + + pthread_mutex_lock(&s_state_mutex); + + oldState = sState; + + if (s_closed > 0) { + // If we're closed, the only reasonable state is + // RADIO_STATE_UNAVAILABLE + // This is here because things on the main thread + // may attempt to change the radio state after the closed + // event happened in another thread + newState = RADIO_STATE_UNAVAILABLE; + } + + if (sState != newState || s_closed > 0) { + sState = newState; + + pthread_cond_broadcast (&s_state_cond); + } + + pthread_mutex_unlock(&s_state_mutex); + + + /* do these outside of the mutex */ + if (sState != oldState) { + RIL_onUnsolicitedResponse (RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, + NULL, 0); + + /* FIXME onSimReady() and onRadioPowerOn() cannot be called + * from the AT reader thread + * Currently, this doesn't happen, but if that changes then these + * will need to be dispatched on the request thread + */ + if (sState == RADIO_STATE_SIM_READY) { + onSIMReady(); + } else if (sState == RADIO_STATE_SIM_NOT_READY) { + onRadioPowerOn(); + } + } +} + +/** Returns SIM_NOT_READY on error */ +static SIM_Status +getSIMStatus() +{ + ATResponse *p_response = NULL; + int err; + int ret; + char *cpinLine; + char *cpinResult; + static int sim_absent = 0; +#ifdef DBG_1 + LOGD("[%s]: sState=%d\n", __FUNCTION__, sState); +#endif + + if (sState == RADIO_STATE_OFF || sState == RADIO_STATE_UNAVAILABLE) { + ret = SIM_NOT_READY; + goto done; + } + + if(!modem_cmp(0x1E89, 0x1E16, NULL) && !strcmp(getModelID(), "172")) + err = at_send_command_singleline("AT^CPIN?", "^CPIN:", &p_response); + else + err = at_send_command_singleline("AT+CPIN?", "+CPIN:", &p_response); + +#if 1 + if (err < 0) { + ret = SIM_NOT_READY; + goto done; + } +#else + if (err < 0 || p_response->success == 0) { + ret = SIM_NOT_READY; + goto done; + } +#endif + + switch (at_get_cme_error(p_response)) { + case CME_SUCCESS: + break; + + case CME_SIM_NOT_INSERTED: +// cmy: 发现W制式的Modem,未插SIM卡时返回 +CME ERROR: 13 + case CME_SIM_FAILED: + ret = SIM_ABSENT; + goto done; + + default: + if(tryCount > 5) + ret = SIM_ABSENT; + else + ret = SIM_NOT_READY; + goto done; + } + + /* CPIN? has succeeded, now look at the result */ + + cpinLine = p_response->p_intermediates->line; + err = at_tok_start (&cpinLine); + + if (err < 0) { + ret = SIM_NOT_READY; + goto done; + } + + err = at_tok_nextstr(&cpinLine, &cpinResult); + + if (err < 0) { + ret = SIM_NOT_READY; + goto done; + } + + if (0 == strncmp (cpinResult, "SIM PIN", strlen("SIM PIN"))) { + ret = SIM_PIN; + sim_pin =1; + goto done; + } else if (0 == strncmp (cpinResult, "SIM PUK", strlen("SIM PUK"))) { + ret = SIM_PUK; + goto done; + } else if (0 == strncmp (cpinResult, "PH-NET PIN", strlen("PH-NET PIN"))) { + return SIM_NETWORK_PERSONALIZATION; + } else if (0 != strncmp (cpinResult, "READY", strlen("READY"))) { + /* we're treating unsupported lock types as "sim absent" */ + ret = SIM_ABSENT; + goto done; + } + + at_response_free(p_response); + p_response = NULL; + cpinResult = NULL; + sim_absent = 0; + ret = SIM_READY; + +done: + LOGD("########check sim ready or not ready"); + if(SIM_ABSENT == ret && s_current_modem->inner==1)//如果卡不存在则关闭内置模块,降低功耗 + { + //setModemPower(0); + LOGD("########Inner 3G modem has no sim card,will shut down power later.."); + nosimcard=1; + } + at_response_free(p_response); + + RLOGD("getSIMStatus return: %d", ret); + if(ret == SIM_ABSENT ){ + RLOGD("find no sim card,check sim card slot or insert sim card"); + } + return ret; +} + + +/** + * Get the current card status. + * + * This must be freed using freeCardStatus. + * @return: On success returns RIL_E_SUCCESS + */ +static int getCardStatus(RIL_CardStatus **pp_card_status) { + + static RIL_AppStatus app_status_array[] = { + // SIM_ABSENT = 0 + { RIL_APPTYPE_UNKNOWN, RIL_APPSTATE_UNKNOWN, RIL_PERSOSUBSTATE_UNKNOWN, + NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, RIL_PINSTATE_UNKNOWN }, + // SIM_NOT_READY = 1 + { RIL_APPTYPE_SIM, RIL_APPSTATE_DETECTED, RIL_PERSOSUBSTATE_UNKNOWN, + NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, RIL_PINSTATE_UNKNOWN }, + // SIM_READY = 2 + { RIL_APPTYPE_SIM, RIL_APPSTATE_READY, RIL_PERSOSUBSTATE_READY, + NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, RIL_PINSTATE_UNKNOWN }, + // SIM_PIN = 3 + { RIL_APPTYPE_SIM, RIL_APPSTATE_PIN, RIL_PERSOSUBSTATE_UNKNOWN, + NULL, NULL, 0, RIL_PINSTATE_ENABLED_NOT_VERIFIED, RIL_PINSTATE_UNKNOWN }, + // SIM_PUK = 4 + { RIL_APPTYPE_SIM, RIL_APPSTATE_PUK, RIL_PERSOSUBSTATE_UNKNOWN, + NULL, NULL, 0, RIL_PINSTATE_ENABLED_BLOCKED, RIL_PINSTATE_UNKNOWN }, + // SIM_NETWORK_PERSONALIZATION = 5 + { RIL_APPTYPE_SIM, RIL_APPSTATE_SUBSCRIPTION_PERSO, RIL_PERSOSUBSTATE_SIM_NETWORK, + NULL, NULL, 0, RIL_PINSTATE_ENABLED_NOT_VERIFIED, RIL_PINSTATE_UNKNOWN }, + // RUIM_ABSENT = 6 + { RIL_APPTYPE_UNKNOWN, RIL_APPSTATE_UNKNOWN, RIL_PERSOSUBSTATE_UNKNOWN, + NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, RIL_PINSTATE_UNKNOWN }, + // RUIM_NOT_READY = 7 + { RIL_APPTYPE_RUIM, RIL_APPSTATE_DETECTED, RIL_PERSOSUBSTATE_UNKNOWN, + NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, RIL_PINSTATE_UNKNOWN }, + // RUIM_READY = 8 + { RIL_APPTYPE_RUIM, RIL_APPSTATE_READY, RIL_PERSOSUBSTATE_READY, + NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, RIL_PINSTATE_UNKNOWN }, + // RUIM_PIN = 9 + { RIL_APPTYPE_RUIM, RIL_APPSTATE_PIN, RIL_PERSOSUBSTATE_UNKNOWN, + NULL, NULL, 0, RIL_PINSTATE_ENABLED_NOT_VERIFIED, RIL_PINSTATE_UNKNOWN }, + // RUIM_PUK = 10 + { RIL_APPTYPE_RUIM, RIL_APPSTATE_PUK, RIL_PERSOSUBSTATE_UNKNOWN, + NULL, NULL, 0, RIL_PINSTATE_ENABLED_BLOCKED, RIL_PINSTATE_UNKNOWN }, + // RUIM_NETWORK_PERSONALIZATION = 11 + { RIL_APPTYPE_RUIM, RIL_APPSTATE_SUBSCRIPTION_PERSO, RIL_PERSOSUBSTATE_SIM_NETWORK, + NULL, NULL, 0, RIL_PINSTATE_ENABLED_NOT_VERIFIED, RIL_PINSTATE_UNKNOWN } + }; + RIL_CardState card_state; + int num_apps; + + int sim_status = getSIMStatus(); + if (sim_status == SIM_ABSENT) { + card_state = RIL_CARDSTATE_ABSENT; + num_apps = 0; + } else { + card_state = RIL_CARDSTATE_PRESENT; + num_apps = 2; + } + + // Allocate and initialize base card status. + RIL_CardStatus_v6 *p_card_status = malloc(sizeof(RIL_CardStatus_v6)); + p_card_status->card_state = card_state; + p_card_status->universal_pin_state = RIL_PINSTATE_UNKNOWN; + p_card_status->gsm_umts_subscription_app_index = RIL_CARD_MAX_APPS; + p_card_status->cdma_subscription_app_index = RIL_CARD_MAX_APPS; + p_card_status->ims_subscription_app_index = RIL_CARD_MAX_APPS; + p_card_status->num_applications = num_apps; + + // Initialize application status + int i; + for (i = 0; i < RIL_CARD_MAX_APPS; i++) { + p_card_status->applications[i] = app_status_array[SIM_ABSENT]; + } + + // Pickup the appropriate application status + // that reflects sim_status for gsm. + if (num_apps != 0) { + // Only support one app, gsm + p_card_status->num_applications = 2; + p_card_status->gsm_umts_subscription_app_index = 0; + p_card_status->cdma_subscription_app_index = 1; + + // Get the correct app status + p_card_status->applications[0] = app_status_array[sim_status]; + p_card_status->applications[1] = app_status_array[sim_status + RUIM_ABSENT]; + } + + *pp_card_status = p_card_status; + return RIL_E_SUCCESS; +} + +/** + * Free the card status returned by getCardStatus + */ +static void freeCardStatus(RIL_CardStatus *p_card_status) { + free(p_card_status); +} + +/* + cmy@20101029: 判断该SIM卡是否支持 + 0 - 支持 + 1 - 此卡不支持 + */ +static int isCardNotSupported() +{ +#if 1 + int isNotSupported = 0; + LOGD("isCardNotSupported: %d", isNotSupported); + return isNotSupported; +#else + int isNotSupported = 1; + + ATResponse *p_response = NULL; + char * line; + int err; + + err = at_send_command_singleline("AT+ZGETMCCLOCK", "+ZCCRTB:", &p_response); + + if (err < 0 || p_response->success == 0) { + goto error; + } + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + if (err < 0) goto error; + + err = at_tok_nextint(&line, &isNotSupported); + if (err < 0) goto error; + +error: + at_response_free(p_response); + LOGD("isCardNotSupported: %d", isNotSupported); + return isNotSupported; +#endif +} + +/** + * SIM ready means any commands that access the SIM will work, including: + * AT+CPIN, AT+CSMS, AT+CNMI, AT+CRSM + * (all SMS-related commands) + */ +static void pollSIMState (void *param) +{ + ATResponse *p_response; + int ret; + + if (sState != RADIO_STATE_SIM_NOT_READY) { + // no longer valid to poll + return; + } + //India EVDO no need sim card by return SIM Ready + if(!modem_cmp(0x12D1, 0x140B,NULL) + ||!modem_cmp(0x19D2, 0xFFE8,NULL) + ||!modem_cmp(0x19D2, 0xFFF1, "AC27XX") + ||!modem_cmp(0x1bbb, 0x0012,"MDM")){ + setRadioState(RADIO_STATE_SIM_READY); + return; + }else{ + + switch(getSIMStatus()) { + case SIM_ABSENT: + case SIM_PIN: + case SIM_PUK: + case SIM_NETWORK_PERSONALIZATION: + default: + setRadioState(RADIO_STATE_SIM_LOCKED_OR_ABSENT); + return; + + case SIM_NOT_READY: + ++tryCount; + RIL_requestTimedCallback (pollSIMState, NULL, &TIMEVAL_SIMPOLL); + return; + + case SIM_READY: + /* 对于不能够支持的SIM卡,在上层发出通知 + */ + if( isCardNotSupported() ) + { + setRadioState(RADIO_STATE_UNAVAILABLE); + +// int isSimNotSupport = 1; +// RIL_onUnsolicitedResponse(RIL_UNSOL_SIM_NOT_SUPPORT, +// &isSimNotSupport, +// sizeof(int) ); + } + else + { + setRadioState(RADIO_STATE_SIM_READY); + +// int isSimNotSupport = 0; +// RIL_onUnsolicitedResponse(RIL_UNSOL_SIM_NOT_SUPPORT, +// &isSimNotSupport, +// sizeof(int) ); + } + return; + } + } +} + +/** returns 1 if on, 0 if off, and -1 on error */ +static int isRadioOn() +{ + ATResponse *p_response = NULL; + int err; + char *line; + char ret; + + err = at_send_command_singleline("AT+CFUN?", "+CFUN:", &p_response); + + if (err < 0 || p_response->success == 0) { + // assume radio is off + goto error; + } + + line = p_response->p_intermediates->line; + + err = at_tok_start(&line); + if (err < 0) goto error; + + /* if( 0 == modem_cmp(0x12d1, 0x1003, NULL) ) + { + if( (err=at_tok_nextint(&line, &ret)) >= 0 ) + { + if(ret == 0) + ret = 1; + LOGE("=======change CFUN value ======"); + } + } + else*/ + err = at_tok_nextbool(&line, &ret); + + if (err < 0) goto error; + + at_response_free(p_response); + + return (int)ret; + +error: + + at_response_free(p_response); + return -1; +} + +extern void closeSocket(); + +static void closeATReader() +{ + + LOGD("Close AT Reader!"); + if(isEth){ + system("netcfg lte0 down"); + LOGD("Close eth inferface!"); + }else + kill_pppd(25); + kill_rild(); + at_close(); + s_closed = 1; + +// LOGD("free wait cond"); +// pthread_cond_signal(&s_waitcond); + + s_current_modem = NULL; + setRadioState (RADIO_STATE_UNAVAILABLE); +} + +/* Called on command or reader thread */ +static void onATReaderClosed() +{ + LOGD("on AT channel closed\n"); + closeATReader(); +// closeSocket(); + LOGD("END onATReaderClosed"); +} + +static void modemEarlyInit() +{ + LOGD("modem early init"); + /* echo off */ + at_send_command("ATE0", NULL); + + /* No auto-answer */ + at_send_command("ATS0=0", NULL); + + /* set DTR according to service */ + at_send_command("AT&D1", NULL); + + /* Extended errors */ + at_send_command("AT+CMEE=1", NULL); + if(!modem_cmp(0x201e, 0x1022,NULL)) + { + + at_send_command("AT^SWVER", NULL); + + at_send_command("AT^SDEN=27", NULL); + + } + //xxh:发送AT点亮指示灯 + if(!modem_cmp(0x230D, 0x000D, NULL)) + + { + + at_send_command("AT*ELED=1,1,0",NULL); + + } + if(!modem_cmp(0x12D1, 0x1001, "3G HSDPA MODEM")){ + + at_send_command("AT+ZSNT=0,0,2",NULL); + + } + + //if(!modem_cmp(0x0e8d,0x00A2,NULL)){ + + //LOGD("[%s]: acquire_USI_wake_lock: %s\n", __FUNCTION__, WAKE_LOCK_ID); + //acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID); +// } + if(!modem_cmp(0x1C9E, 0x9603, NULL)){ + + + at_send_command("AT+LCTNVUART=0",NULL);//xxh:模块休眠时能 + at_send_command("AT+SLEEPEN=1",NULL); + + } + if(!modem_cmp(0x1782, 0x0002, "V1.0.1-B7")){ + at_send_command("AT+SIPMODE=0",NULL); + // err=at_send_command("AT+SAUTOATT=1",NULL); + // err=at_send_command("AT+SATT=1,0",NULL); + } + +} + +/** + * Initialize everything that can be configured while we're still in + * AT+CFUN=0 + */ +static void initializeCallback(void *param) +{ +// 设置radio状态为RADIO_STATE_OFF,上层收到状态改变的消息后显示出radio图标 + setRadioState(RADIO_STATE_OFF); + +// 进行AT握手 + if(at_handshake()) + { + LOGE("AT handshake failed!!!"); + return; + } +#if GET_USI_IMEI + int fd; + int i; + if(!modem_cmp(0x0e8d,0x00a2,NULL)){ + + //fd = open(MODEM_CONTRL_PATH, O_RDWR|O_EXCL); + + // if(fd < 0) { + + + // LOGD("Can't open usi1 fd=0x%x", fd); + + // } + if(ioctl(fd,BP_IOCTL_GET_IMEI, (unsigned long)IMEI_value) < 0) + + { + LOGD("mt6229 ioctl failed\n"); + } + for(i=0;i<16;i++){ + LOGD("bd_addr%x = %x",i,IMEI_value[i]); + close(fd); + } +} +#endif +// modem 早期初始化,此时应发送不依赖于 modem's RF/SIM 状态的指令 + modemEarlyInit(); + + /* assume radio is off on error */ + /* + cmy: 当RF打开时(+CFUN=1),查询SIM卡的状态(有效的SIM卡,或者其它) + */ + //if(!modem_cmp(0x12d1,0x1003,NULL)){ + // LOGE("=======E220 AT+CFUN enale========"); + // at_send_command("AT+CFUN=1",NULL); + + //} + if (isRadioOn() > 0) { + setRadioState (RADIO_STATE_SIM_NOT_READY); + } + +// cmy: 初始设定服务受限状态为: 不受限 + s_restricted_state=RIL_RESTRICTED_STATE_NONE; + RIL_onUnsolicitedResponse(RIL_UNSOL_RESTRICTED_STATE_CHANGED, + &s_restricted_state, + sizeof(int) ); + + LOGD("[%s]: === END ===", __FUNCTION__); +} + +static void waitForClose() +{ + pthread_mutex_lock(&s_state_mutex); + + while (s_closed == 0) { + pthread_cond_wait(&s_state_cond, &s_state_mutex); + } + + pthread_mutex_unlock(&s_state_mutex); +} + +static int getRegistrationState(char* line, int with_n, int* state, int* rat) +{ + int err; + int skip; + int lac; + int cid; + *state = -1; + *rat = -1; + char *p; + int commas=0; + /* +CGREG: , , , */ + // 1,D9000, 583114F,12 + /* or */ + /* +CGREG: , , , , */ + + /* +CGREG: ,,,*/ + // +CGREG: 2, 1 , D9000, 583114F + // +CGREG: 1, "A5F4", "01EFD83F", 6 + for (p = line ; *p != '\0' ;p++) { + if (*p == ',') commas++; + } + + err = at_tok_start(&line); + if (err < 0) goto end; + if (with_n) + { + err = at_tok_nextint(&line, &skip); + if (err < 0) goto end; + } + LOGD("comms is: %d\n", commas); + + switch(commas){ + + case 0: /* +CGREG: */ + err = at_tok_nexthexint(&line, state); + if (err < 0) goto end; + case 1: /* +CGREG: , */ + err = at_tok_nextint(&line, &skip); + if (err < 0) goto end; + err = at_tok_nexthexint(&line, state); + if (err < 0) goto end; + break; + case 2: + //+CGREG: , , , + err = at_tok_nexthexint(&line, state); + if (err < 0) goto end; + err = at_tok_nexthexint(&line, &lac); + if (err < 0) goto end; + err = at_tok_nexthexint(&line, &cid); + if (err < 0) goto end; + break; + case 3: + // +CGREG: ,,,*/ + // +CGREG: 1,"A53F","0000C618",6 + // CGREG: 1, "A5F4", "01EFD83F", 6 + + if(!modem_cmp(0x1782, 0x0002, "V1.0.1-B7") + ||!modem_cmp(0x0E8D, 0x00A2, "MTK2") + ||!modem_cmp(0x2001, 0x7D01, "DMW-156")){ + err = at_tok_nexthexint(&line, state); + if(err <0 ) goto end; + err = at_tok_nexthexint(&line, &lac); + if (err < 0) goto end; + err = at_tok_nexthexint(&line, &cid); + if (err < 0) goto end; + err = at_tok_nexthexint(&line, rat); + if (err < 0) goto end; + } + else{ + //+CGREG: 2, 1 , D9000, 583114F + err = at_tok_nextint(&line, &skip); + if (err < 0) goto end; + err = at_tok_nexthexint(&line, state); + if (err < 0) goto end; + err = at_tok_nexthexint(&line, &lac); + if (err < 0) goto end; + err = at_tok_nexthexint(&line, &cid); + if (err < 0) goto end; + } + break; + case 4: + //CGREG: , , , , */ + err = at_tok_nextint(&line, &skip); + if (err < 0) goto end; + err = at_tok_nexthexint(&line, state); + if (err < 0) goto end; + err = at_tok_nexthexint(&line, &lac); + if (err < 0) goto end; + err = at_tok_nexthexint(&line, &cid); + if (err < 0) goto end; + err = at_tok_nexthexint(&line, rat); + if (err < 0) goto end; + break; + default: + goto end; + } +end: + return 0; +} + +/** + * Called by atchannel when an unsolicited line appears + * This is called on atchannel's reader thread. AT commands may + * not be issued here + */ +/* + cmy: 按原本意思,当网络状态发生变化时才会上报 +CREG、+CGREG、^MODE 等信息,但目前发现 + 部分厂家并没有这么做(EM770/TDM330等),在拨号上网后,经常主动上报CREG、CGREG,所以在这边加了些判断 + 只有当网络状态跟上次不同时才上报状态 + */ +/* + cmy: 对于网络类型变化时,可主动上报 RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED + 上层在收到该事件时,会依次发送如下请求: + OPERATOR + GPRS_REGISTRATION_STATE + REGISTRATION_STATE + QUERY_NETWORK_SELECTION_MODE + */ +static void onUnsolicited (const char *s, const char *sms_pdu) +{ + char *line = NULL; + int err; + + LOGD("onUnsolicited <<<<<<<<<<<<<<<<< %s", s); + + /* Ignore unsolicited responses until we're initialized. + * This is OK because the RIL library will poll for initial state + */ + if (sState == RADIO_STATE_UNAVAILABLE) { + return; + } + + if (strStartsWith(s, "%CTZV:") + || strStartsWith(s,"+CTZV:") + || strStartsWith(s,"+CTZDST:") + || strStartsWith(s,"+HTCCTZV:")) { + unsolicitedNitzTime(s); + } else if (strStartsWith(s,"NO CARRIER")) { + RIL_onUnsolicitedResponse ( + RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, + NULL, 0); + RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL); //TODO use new function + }else if (strStartsWith(s,"^RSSI:")) { + unsolicitedRSSI(s); + } else if(!isgsm && strStartsWith(s,"^HDRRSSI:")) { + unsolicitedHDRRSSI(s); + } else if( !isgsm && strStartsWith(s, "^RSSILVL:") ) { + unsolicitedRSSILVL(s); + } else if( !isgsm && strStartsWith(s, "^HRSSILVL:") ) { + unsolicitedHRSSILVL(s); + } else if (0 && strStartsWith(s,"+CREG:")){ + int newStat = atoi(s+strlen("+CREG:")); + int new_reg_rat = -1; + if(newStat != s_reg_stat) + { + LOGD("reg state: %d -> %d\n", s_reg_stat, newStat); + if( (s_reg_stat==1||s_reg_stat==5) && !(newStat==1||newStat==5) ) + {// 当注网状态从已注册变化为未注册时,此时的数据连接已经无效,应在注网后重新拨号 + s_pppd_exception = 1; + } + s_reg_stat = newStat; + RIL_onUnsolicitedResponse ( + RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, + NULL, 0); + RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL); + } + // 部分模块在网络类型发生改变时,会上报CREG;当接收到该上报时,应通知上层以便及时改变网络类型 + else if( new_reg_rat != s_reg_rat ) + { + LOGD("reg RAT: %d -> %d\n", s_reg_rat, new_reg_rat); + s_reg_rat = new_reg_rat; + RIL_onUnsolicitedResponse ( + RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, + NULL, 0); + } + } else if (strStartsWith(s,"+CGREG:")){ + int newStat = -1; + int new_reg_rat = -1; + int with_n = 0; + if (!modem_cmp(0x19D2, 0xFFEB, "0")) + with_n = 1; + + getRegistrationState(s, with_n, &newStat, &new_reg_rat); + //处理特殊上报,以下两种情况上报均是正常状态,不应该断开PPP连接 + /* +CGREG: , , , */ + // 1,D9000, 583114F,12 + /* +CGREG: ,,,*/ + // +CGREG: 2, 1 , D9000, 583114F + if(newStat != s_greg_stat) + { + LOGD("greg: %d -> %d\n", s_greg_stat, newStat); + if( (s_greg_stat==1||s_greg_stat==5) && !(newStat==1||newStat==5) ) + {// 当注网状态从已注册变化为未注册时,此时的数据连接已经无效,应在注网后重新拨号 + s_pppd_exception = 1; + } + s_greg_stat = newStat; + RIL_onUnsolicitedResponse ( + RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, + NULL, 0); + RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL); + } + // 部分模块在网络类型发生改变时,会上报CREG;当接收到该上报时,应通知上层以便及时改变网络类型 + else if( new_reg_rat != s_reg_rat ) + { + LOGD("reg RAT: %d -> %d\n", s_reg_rat, new_reg_rat); + s_reg_rat = new_reg_rat; + RIL_onUnsolicitedResponse ( + RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, + NULL, 0); + } + } else if (strStartsWith(s,"^MODE:")){ + int newStat = atoi(s+strlen("^MODE:")); + if(newStat != s_sys_mode) + { + LOGD("mode: %d -> %d\n", s_sys_mode, newStat); + s_sys_mode = newStat; + RIL_onUnsolicitedResponse ( + RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, + NULL, 0); + RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL); + } + } else if (strStartsWith(s, "+CGEV:")) { + /* Really, we can ignore NW CLASS and ME CLASS events here, + * but right now we don't since extranous + * RIL_UNSOL_DATA_CALL_LIST_CHANGED calls are tolerated + */ + /* can't issue AT commands here -- call on main thread */ + RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL); +#ifdef WORKAROUND_FAKE_CGEV + } else if (strStartsWith(s, "+CME ERROR: 150")) { + RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL); +#endif /* WORKAROUND_FAKE_CGEV */ +// } else if (!isgsm && strStartsWith(s, "^SIMST:")) {// CDMA主动上报SIM卡状态 + } else if ( strStartsWith(s, "^SIMST:") ) { + // 主动上报SIM卡状态改变的消息 + int newStat = atoi(s+strlen("^SIMST:")); + if(newStat==255) + setRadioState(RADIO_STATE_SIM_LOCKED_OR_ABSENT); + } else if (strStartsWith(s, "+CUSD:")) { + //unsolicitedUSSD(s); +#ifdef SUPPORT_SMS + }else if (strStartsWith(s, "+CDS:")) {//收到短信 + RIL_onUnsolicitedResponse (RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT,sms_pdu, strlen(sms_pdu)); + }else if (strStartsWith(s, "+CMT:")) { + RIL_onUnsolicitedResponse ( + RIL_UNSOL_RESPONSE_NEW_SMS, + sms_pdu, strlen(sms_pdu)); +#endif + } +} + +// cmy: 等待AT命令的返回超时,调用onATTimeout来处理 +#if 0 +static void onATTimeout() +{ + LOGI("AT command timeout\n"); +} +#else +/* Called on command thread */ +static void onATTimeout() +{ + LOGI("AT channel timeout; closing\n"); + + onATReaderClosed(); + + /* FIXME cause a radio reset here */ + + // reset modem +// 关闭modem,然后将超时消息主动上报给上层,由上层决定是否再次打开设备 + LOGD("reset modem"); +// reset_modem(cur_dev_path); +// turn_on_modem(s_cur_devpath, 0); + LOGD("END onATTimeout"); +} +#endif + +static void usage(char *s) +{ +#ifdef RIL_SHLIB + fprintf(stderr, "reference-ril requires: -p or -d /dev/tty_device\n"); +#else + fprintf(stderr, "usage: %s [-p ] [-d /dev/tty_device]\n", s); + exit(-1); +#endif +} + +#if 0 +/* + cmy: 获取模块型号 + */ +static void getModelIDCallback(void* param) +{ + char* model_id = *(char**)param; + int err; + +// LOGD("[%s] delay %ds before first AT cmd", __FUNCTION__, DELAY_BEFORE_FIRST_ATCMD); +// sleep(DELAY_BEFORE_FIRST_ATCMD); + + err = at_handshake(); + LOGD("[%s]: at_handshake result=%d\n", __FUNCTION__, err); + if(err != 0) return; + +// 第一次向模块发送指令后,很可能会收到多个返回,这些返回都是modem主动上报 +// 在这边加点延时,防止获取modem id时,取到了主动上报的字符串 +// sleep(3); + *(char**)param = getModelID(); + + LOGD("[%s]: model_id: %s\n", __FUNCTION__, *(char**)param); + + closeATReader(); +} +#endif + +#if 0 +// 成功返回 model id +// 失败返回 NULL +char* getCurModelID(RIL_ModemInterface* modem) +{ + int fd = -1; + char* cur_model_id = NULL; + int ret = 0; + const char* at_channel = modem->atchannel_index;// s_cur_atchannel; + + if(!delayed_before_open_at){ + LOGD("[%s]: sleep %ds befor open %s", __FUNCTION__, modem->initWaitTime, at_channel); + sleep(modem->initWaitTime); + delayed_before_open_at = 1; + } + + fd = open (at_channel, O_RDWR); + LOGD("[%s]: opened fd=%d", __FUNCTION__, fd); + if ( fd >= 0 ) { + /* disable echo on serial ports */ + struct termios ios; + tcgetattr( fd, &ios ); + ios.c_lflag = 0; /* disable ECHO, ICANON, etc... */ + tcsetattr( fd, TCSANOW, &ios ); + } + else + return NULL; + + s_closed = 0; + ret = at_open(fd, NULL); + + if (ret < 0) { + LOGE ("AT error %d on at_open\n", ret); + return NULL; + } + + LOGD("[%s]: Get model ID", __FUNCTION__); + RIL_requestTimedCallback(getModelIDCallback, &cur_model_id, &TIMEVAL_0); + + sleep(1); + + waitForClose(); + + LOGD("[%s]: cur_model_id: %s\n", __FUNCTION__, cur_model_id); + + return cur_model_id; +} +#endif + +static RIL_ModemInterface* s_match_modem_list[MAX_MATCH_MODEM_ATCHANNEL][MAX_SUPPORT_MODEM]; + +static void dump_modem(RIL_ModemInterface* modem_if) +{ + if (modem_if) + LOGD("VID/PID=0x%04X/0x%04X, ID: %s, AT=%s, PPP=%s", modem_if->modem_info.vid, + modem_if->modem_info.pid, + modem_if->modem_info.model_id, + modem_if->atchannel_index, modem_if->pppchannel_index); + else + LOGD("NULL MODEM"); +} + +static int rematchModem(const char* modemID, const char* atchannel) +{ + int i=0; + int j=0; + int count = 0; + + for (i=0;iatchannel_index)) + { + for (j=0; jmodem_info.model_id)) + { + count++; + s_current_modem = s_match_modem_list[i][j]; + dump_modem(s_current_modem); + break; + } + } + } + } + + return count; +} + int open_at_port() + { + LOGD("open %s ...", s_current_modem->atchannel_index); + int fd = open (s_current_modem->atchannel_index, O_RDWR); + + if ( fd >= 0 ) { + /* disable echo on serial ports */ + struct termios ios; + tcgetattr( fd, &ios ); + if(!modem_cmp(0x1004, 0x61AA, NULL)) + { + LOGE ("setup VL600 serial port"); + ios.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); + ios.c_oflag &= ~(OPOST); + ios.c_cflag &= ~(CSIZE | PARENB); + ios.c_cflag |= CS8; + ios.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); + ios.c_cc[VMIN] = 1; + ios.c_cc[VTIME] = 0; + cfsetospeed(&ios, B115200); + cfsetispeed(&ios, B115200); + tcsetattr( fd, TCSAFLUSH, &ios ); + } + else + { + ios.c_lflag = 0; + /* disable ECHO, ICANON, etc... */ + //xxh:3G Mutil lib bug + ios.c_cc[VMIN]=1; + tcsetattr( fd, TCSANOW, &ios ); + RLOGE("E:/dev/ttyUSB* open sucess........."); + } + } + + return fd; + } +static int checkAtChannel() +{ + int fd = -1; + int ret = 0; + int i = 0; + int err = 0; + + fd = open_at_port(); + if (fd < 0) { + LOGE ("open failed"); + return -1; + } + + s_closed = 0; + ret = at_open(fd, NULL); + if (ret < 0) + { + LOGE ("AT error %d on at_open\n", ret); + close(fd); + return -2; + } + +// 进行AT握手 + err = at_handshake(); + + close(fd); + at_close(); + s_closed = 1; + + return (err==0)?0:-3; +} + +static void add_to_match_modem_list(RIL_ModemInterface* modem_if) +{ + int i=0; + int j=0; + + RIL_ModemInterface** match_modem_at = NULL; + + for (i=0;iatchannel_index, + match_modem_at[0]->atchannel_index)) { + // Add to list + while (match_modem_at[++j]!=NULL) + ; + match_modem_at[j] = modem_if; + break; + } + } else { + match_modem_at[0] = modem_if; + break; + } + } +} + +static int findModem(int vid, int pid, const char* modemID, RIL_ModemInterface** modem) +{ + int match_count=0; + int index = 0; + int i=0; + int j=0; + + for (i=0;i 1) + { + sMmodemRematch = 1; + LOGD("Need rematch modem later!"); + } + else if(!is_support_modem_type(match_modem->radioType)) + match_modem = NULL; + + return match_modem; +} + +/*-------------------------------------------------------*/ + +/** 用于 check cpu 类型的文件节点路径字串. */ +#define FILE_FOR_CPU_CHECKING "/proc/addr_kmsg" + +/** 用于 check cpu 的 ioctl 标识宏. */ +#define IOCTL_CHECK_CPU_TYPE 0xffffffff + +/** + * rk CPU 类型的常数标识. + * 保密起见, 没有 定义在 public 的 头文件中, 但必须同 rk28_dsp.c 中一致. + */ +#define TYPE_RK2816 2816 +#define TYPE_RK2818 2818 + +/* + 成功返回 0 + */ +int cpu_checking() +{ + int fd = -1; + + unsigned int cpu_type = -1; + int result = 0; + + if ( 0 > (fd = open(FILE_FOR_CPU_CHECKING, O_RDONLY) ) ) + { +// LOGD("Failed to open '%s', error is '%s'.", FILE_FOR_CPU_CHECKING, strerror(errno) ); + goto EXIT; + } + + if ( 0 > (result = ioctl(fd, IOCTL_CHECK_CPU_TYPE, &cpu_type) ) ) // ...... ... unsigned int* + { +// LOGD("Failed to perform ioctl, error is '%s'.", strerror(errno) ); + goto EXIT; + } + +// LOGD("Current cpu type is : %d", cpu_type); + + if( cpu_type == TYPE_RK2818 ) + return 0; + + return -2; + +EXIT: + close(fd); + + return -1; +} + +int get_tty_id(const char* tty_path, int *vid, int* pid, int isACM) +{ + char linkto[260]=""; + int len=0; + int prev_dir_deep = 0; + + len = readlink(tty_path, linkto, 260); + if(len < 0) return -1; + + char* plink = linkto; + while( plink[0] == '.' && plink[1] == '.' && plink[2] == '/' ) + { + plink += 3; + prev_dir_deep++; + } + plink-=5; + memcpy(plink, "/sys/", 5); + + ALOGD("device path: %s", plink); + + int i; + char* pend = plink; + for(i=isACM?3:4; i>0; i--) + { + pend = strrchr(plink, '/'); + *pend = '\0'; + } + + RLOGD("USB device path: %s", plink); + + FILE* fp = NULL; + char buf[5] = ""; + strcat(plink, "/idVendor"); + RLOGD("TTY Device Vendor path: %s", plink); + fp = fopen(plink, "r"); + if(fp == NULL) + return -2; + if(fread(buf, 1, 4, fp) != 4) + { + fclose(fp); + return -2; + } + fclose(fp); + *vid = atox(buf, 16); + + plink[strlen(plink)-9] = '\0'; + strcat(plink, "/idProduct"); + RLOGD("TTY Device Product path: %s", plink); + fp = fopen(plink, "r"); + if(fp == NULL) + return -3; + if(fread(buf, 1, 4, fp) != 4) + { + fclose(fp); + return -3; + } + fclose(fp); + *pid = atox(buf, 16); + + return 0; +} +#if 0 +int open_at_port() +{ + LOGD("open %s ...", s_current_modem->atchannel_index); + int fd = open (s_current_modem->atchannel_index, O_RDWR); + + if ( fd >= 0 ) { + /* disable echo on serial ports */ + struct termios ios; + tcgetattr( fd, &ios ); + if(!modem_cmp(0x1004, 0x61AA, NULL)) + { + LOGE ("setup VL600 serial port"); + ios.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); + ios.c_oflag &= ~(OPOST); + ios.c_cflag &= ~(CSIZE | PARENB); + ios.c_cflag |= CS8; + ios.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); + ios.c_cc[VMIN] = 1; + ios.c_cc[VTIME] = 0; + cfsetospeed(&ios, B115200); + cfsetispeed(&ios, B115200); + tcsetattr( fd, TCSAFLUSH, &ios ); + } + else + { + ios.c_lflag = 0; + /* disable ECHO, ICANON, etc... */ + //xxh:3G Mutil lib bug + ios.c_cc[VMIN]=1; + tcsetattr( fd, TCSANOW, &ios ); + RLOGE("E:/dev/ttyUSB* open sucess........."); + } + } + + return fd; +} +#endif +static void *mainLoop(void *param) +{ + int fd; + int ret; + + AT_DUMP("== ", "entering mainLoop()", -1 ); + at_set_on_reader_closed(onATReaderClosed); + at_set_on_timeout(onATTimeout); + + // Load operator table (for CDMA) + loadOperatorTable(OPERATOR_TABLE_PATH); + + for (;;) + { + LOGI("Initial var!"); + fd = -1; + s_current_modem = NULL; + IMSI[0] = 0; + tryCount = 0; + // 将signalStrength清空,防止modem打开时使用signalStrength中遗留的值 + signalStrength[0] = -1; + signalStrength[1] = -1; + signalStrength_hdr[0] = -1; + signalStrength_hdr[1] = -1; + s_reg_stat=0; + s_reg_rat=-1; + s_greg_stat=0; + s_sys_mode=-1; + sMmodemRematch = 0; + s_pppd_exception = 0; + s_first_dialup = 1; + nosimcard =0; + sim_pin=0; + pthread_cond_signal(&s_waitcond); + +#ifdef ENABLE_STAY_AWAKE + LOGD("[%s]: release_wake_lock: %s\n", __FUNCTION__, WAKE_LOCK_ID); + release_wake_lock(WAKE_LOCK_ID); +#endif + + while (fd < 0) + { + int vid=-1; + int pid=-1; + const char* dev_path = NULL; + // LOGD("Wait device..."); + sleep(3); + /* + 等待设备出现 + */ + if( access("/sys/class/tty/ttyUSB0", 0) == 0 ) + { + + RLOGD("Found a device, get id"); + if( 0 != get_tty_id("/sys/class/tty/ttyUSB0", &vid, &pid, 0) ) + { + LOGD("Get device id failed!"); + continue; + } + } + #if SUPPORT_MU509&&SUPPORT_MT6229 + if( access("/sys/class/tty/ttyUSB244", 0) == 0 ) + { + + RLOGD("Found a inner 3G modem device, get id"); + if( 0 != get_tty_id("/sys/class/tty/ttyUSB244", &vid, &pid, 0) ) + { + LOGD("Get inner device id failed!"); + continue; + } + } + #endif + else if( access("/sys/class/tty/ttyACM0", 0) == 0 ) + { + + RLOGD("Found a device, get id"); + if( 0 != get_tty_id("/sys/class/tty/ttyACM0", &vid, &pid, 1) ) + { + LOGD("Get device id failed!"); + continue; + } + } + + if(vid==-1 || pid==-1) + { + // 没有找到设备 +#if (!MULTI_RIL_LIB) + continue; +#else + exit(0); + + +#endif + } + RLOGD("tty Device id is: %04X/%04X", vid, pid); + + // 根据VID/PID来匹配模块型号 + RLOGD("Searching modem table..."); + s_current_modem = matchModem(vid, pid); + + if( s_current_modem == NULL ) + { + ALOGE("E: Not support modem!!!!"); + continue; + } + + RLOGD("AT[%s] PPP[%s]", s_current_modem->atchannel_index, + s_current_modem->pppchannel_index); + + RLOGD("[%s]: sleep %ds befor open %s", __FUNCTION__, s_current_modem->initWaitTime, s_current_modem->atchannel_index); + // sleep(s_current_modem->initWaitTime); + int wait_count = 10*s_current_modem->initWaitTime; + while(wait_count>0) + { + if( access(s_current_modem->atchannel_index, 0) != 0 ) + { + // LOGE("E: modem disconnected!!!!"); +#if (!MULTI_RIL_LIB) + continue; +#else + exit(0); +#endif + } + sleepMsec(100); + --wait_count; + } + if (s_match_modem_list[1][0] != NULL) + {// 如果相同vid/pid的3g使用不同的AT口,则在此判断当前模块使用哪个AT口 + int at_index = 0; + RLOGD("Check AT Channel..."); + while (s_match_modem_list[at_index][0]) + { + s_current_modem = s_match_modem_list[at_index][0]; + if(0==checkAtChannel()) + break; + ++at_index; + } + } + + fd = open_at_port(); + if (fd < 0) { + #if (!MULTI_RIL_LIB) + RLOGE ("opening AT interface. retrying..."); + /* never returns */ + sleep(2); +#else + LOGE ("open at port failed."); + exit(1); +#endif + } + } + + + RLOGI("Device %s has been opened, fd=%d", s_current_modem->atchannel_index, fd); + s_closed = 0; + ret = at_open(fd, onUnsolicited); + if (ret < 0) + { + RLOGE ("AT error %d on at_open\n", ret); + return 0; + } + RIL_requestTimedCallback(initializeCallback, NULL, &TIMEVAL_0); + // Give initializeCallback a chance to dispatched, since + // we don't presently have a cancellation mechanism + sleep(1); + waitForClose(); +#if (!MULTI_RIL_LIB) + RLOGI("Re-opening after close"); +#else + exit(1); +#endif + } +} + +#if 1//#ifdef RIL_SHLIB + +pthread_t s_tid_mainloop; + +const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc, char **argv) +{ + int ret; + pthread_attr_t attr; + + s_rilenv = env; + + LOGD("Enter RIL_Init"); + + pthread_attr_init (&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + ret = pthread_create(&s_tid_mainloop, &attr, mainLoop, NULL); + + return &s_callbacks; +} +#else /* RIL_SHLIB */ +int main (int argc, char **argv) +{ + int ret; + int fd = -1; + int opt; + + while ( -1 != (opt = getopt(argc, argv, "p:d:"))) { + switch (opt) { + case 'p': + s_port = atoi(optarg); + if (s_port == 0) { + usage(argv[0]); + } + LOGI("Opening loopback port %d\n", s_port); + break; + + case 'd': + s_device_path = optarg; + LOGI("Opening tty device %s\n", s_device_path); + break; + + case 's': + s_device_path = optarg; + s_device_socket = 1; + LOGI("Opening socket %s\n", s_device_path); + break; + + default: + usage(argv[0]); + } + } + + if (s_port < 0 && s_device_path == NULL) { + usage(argv[0]); + } + + RIL_register(&s_callbacks); + + mainLoop(NULL); + + return 0; +} + +#endif /* RIL_SHLIB */