[hardware/ril] add dongle
This commit is contained in:
29
hardware/ril/include/telephony/config.h
Normal file
29
hardware/ril/include/telephony/config.h
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
/*
|
||||
<20><><EFBFBD><EFBFBD>RIL_RELEASE<53><45><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>е<EFBFBD>modem<65><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<20>ڱ<EFBFBD><DAB1><EFBFBD>RIL<49>Ⲣ<EFBFBD><E2B2A2><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>塡RIL_RELEASE
|
||||
*/
|
||||
#define RIL_RELEASE
|
||||
|
||||
/*
|
||||
<20><><EFBFBD><EFBFBD>ENABLE_DNS_CHECK<43><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>䵽<EFBFBD><E4B5BD>DNS
|
||||
<20><><EFBFBD><EFBFBD>DNS<4E><53><EFBFBD>쳣(<28><><EFBFBD><EFBFBD>10.11.12.13)ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><C2BD>в<EFBFBD><D0B2><EFBFBD>
|
||||
|
||||
ʹ<><CAB9>ר<EFBFBD><D7A8><EFBFBD><EFBFBD>SIM<49><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܲ<EFBFBD><DCB2>ṩ<EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD>
|
||||
<20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DNS,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>:
|
||||
#define ENABLE_DNS_CHECK 0
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SIM<49><4D><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>:
|
||||
#define ENABLE_DNS_CHECK 1
|
||||
*/
|
||||
#define ENABLE_DNS_CHECK 1
|
||||
|
||||
#define SUPPORT_SMS 0
|
||||
|
||||
/*
|
||||
<20><> ENABLE_STAY_AWAKE <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CDMA/EVDO<44><4F><EFBFBD>磬<EFBFBD><E7A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3BDABB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><CBAF>
|
||||
*/
|
||||
//#define ENABLE_STAY_AWAKE
|
||||
|
||||
#define MULTI_RIL_LIB 0
|
||||
|
||||
#define GET_USI_IMEI 0
|
||||
@ -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
|
||||
|
||||
@ -46,6 +46,8 @@
|
||||
#define HANDSHAKE_RETRY_COUNT 8
|
||||
#define HANDSHAKE_TIMEOUT_MSEC 250
|
||||
|
||||
// cmy: <20>ڷ<EFBFBD><DAB7><EFBFBD>AT<41><54><EFBFBD><EFBFBD>֮ǰ<D6AE>ӵ<EFBFBD><D3B5><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>ʱ<EFBFBD>ײ㴦<D7B2><E3B4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#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<line; i++)
|
||||
{
|
||||
for(j=0; j<16; j++)
|
||||
{
|
||||
if((i*16+j)>=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: <20><><EFBFBD>漸<EFBFBD><E6BCB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HuaWei EM660Cģ<43><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
"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) {
|
||||
|
||||
@ -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);
|
||||
|
||||
38
hardware/ril/reference-ril/config.h
Normal file
38
hardware/ril/reference-ril/config.h
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
/*
|
||||
<20><><EFBFBD><EFBFBD>RIL_RELEASE<53><45><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>е<EFBFBD>modem<65><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<20>ڱ<EFBFBD><DAB1><EFBFBD>RIL<49>Ⲣ<EFBFBD><E2B2A2><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>塡RIL_RELEASE
|
||||
*/
|
||||
#define RIL_RELEASE
|
||||
|
||||
/*
|
||||
<20><><EFBFBD><EFBFBD>ENABLE_DNS_CHECK<43><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>䵽<EFBFBD><E4B5BD>DNS
|
||||
<20><><EFBFBD><EFBFBD>DNS<4E><53><EFBFBD>쳣(<28><><EFBFBD><EFBFBD>10.11.12.13)ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><C2BD>в<EFBFBD><D0B2><EFBFBD>
|
||||
|
||||
ʹ<><CAB9>ר<EFBFBD><D7A8><EFBFBD><EFBFBD>SIM<49><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܲ<EFBFBD><DCB2>ṩ<EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD>
|
||||
<20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DNS,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>:
|
||||
#define ENABLE_DNS_CHECK 0
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SIM<49><4D><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>:
|
||||
#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
|
||||
|
||||
/*
|
||||
<20><> ENABLE_STAY_AWAKE <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CDMA/EVDO<44><4F><EFBFBD>磬<EFBFBD><E7A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3BDABB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><CBAF>
|
||||
*/
|
||||
#define ENABLE_STAY_AWAKE
|
||||
|
||||
|
||||
|
||||
1244
hardware/ril/reference-ril/extend_at_func.c
Normal file
1244
hardware/ril/reference-ril/extend_at_func.c
Normal file
File diff suppressed because it is too large
Load Diff
96
hardware/ril/reference-ril/extend_at_func.h
Normal file
96
hardware/ril/reference-ril/extend_at_func.h
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
һ<><D2BB>ģ<EFBFBD>飬<EFBFBD><E9A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ATָ<54><EFBFBD><EEBCAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>AT<41><54><EFBFBD><EFBFBD> + <20><>չAT<41><54><EFBFBD><EFBFBD>
|
||||
<20><>AT<41><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չAT<41><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܲ<EFBFBD>ͬ<EFBFBD><CDAC>Ŀǰ<C4BF><C7B0>֪<EFBFBD><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
||||
<20><><EFBFBD>˲<EFBFBD><CBB2><EFBFBD>ģ<EFBFBD><C4A3>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չAT<41><54><EFBFBD><EFBFBD>
|
||||
<20>й<EFBFBD><D0B9>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>ͨ<EFBFBD><CDA8>GSMģ<4D>鷽<EFBFBD><E9B7BD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>չAT<41><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ
|
||||
<20>й<EFBFBD><D0B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CDMAģ<41>鷽<EFBFBD><E9B7BD>Ҳ<EFBFBD><D2B2><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>չAT<41><54><EFBFBD><EFBFBD>
|
||||
|
||||
ע: Ŀǰû<C7B0>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>飬<EFBFBD><E9A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>AT<41><54>չָ<D5B9><EFBFBD><EEBCAF><EFBFBD><EFBFBD><EFBFBD>εľͲ<C4BE><CDB2>ö<EFBFBD>֪<EFBFBD><D6AA>
|
||||
|
||||
cmy: <20><>Ҫʹ<D2AA><CAB9><EFBFBD><EFBFBD>չAT<41><54><EFBFBD><EFBFBD>ʵ<EFBFBD>ֵĹ<D6B5><C4B9>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD>伯<EFBFBD><E4BCAF><EFBFBD>ڸ<EFBFBD><DAB8>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
*/
|
||||
|
||||
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: <20>ø<EFBFBD>ֵ<EFBFBD><D6B5>ʾ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: <20>ø<EFBFBD>ֵ<EFBFBD><D6B5>ʾ<EFBFBD>Զ<EFBFBD>ѡ<EFBFBD><D1A1> 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);
|
||||
1165
hardware/ril/reference-ril/gsm.c
Normal file
1165
hardware/ril/reference-ril/gsm.c
Normal file
File diff suppressed because it is too large
Load Diff
177
hardware/ril/reference-ril/gsm.h
Normal file
177
hardware/ril/reference-ril/gsm.h
Normal file
@ -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 */
|
||||
233
hardware/ril/reference-ril/modem_define_func.c
Normal file
233
hardware/ril/reference-ril/modem_define_func.c
Normal file
@ -0,0 +1,233 @@
|
||||
#include <telephony/ril.h>
|
||||
#include "atchannel.h"
|
||||
#include "at_tok.h"
|
||||
#include "modem_define_func.h"
|
||||
|
||||
#define LOG_TAG "RIL"
|
||||
#include <utils/Log.h>
|
||||
|
||||
/* cmy: ijЩģ<D0A9><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ų<EFBFBD>ͬ<EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʽ
|
||||
*/
|
||||
void initModem_gsm()
|
||||
{
|
||||
LOGD("[%s]: === Enter", __FUNCTION__);
|
||||
|
||||
ATResponse *p_response = NULL;
|
||||
int err;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/* <20><>ʾ<EFBFBD><CABE><EFBFBD>к<EFBFBD><D0BA><EFBFBD> */
|
||||
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);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/* SMS PDU mode */
|
||||
at_send_command("AT+CMGF=0", NULL);
|
||||
|
||||
/* +CSSU unsolicited supp service notifications */
|
||||
at_send_command("AT+CSSN=0,1", NULL);
|
||||
|
||||
// cmy: <20><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD><C2B6><EFBFBD>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+CMT<4D><54>+CMTI<54><49>+CDSI3 <20>֣<EFBFBD><D6A3>ϱ<EFBFBD><CFB1><EFBFBD> TE <20>ķ<EFBFBD>ʽ
|
||||
at_send_command("AT+CNMI=1,2,0,0,0", NULL);
|
||||
|
||||
// ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD>
|
||||
at_send_command("AT+CSMS=1", NULL);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/* HEX character set */
|
||||
at_send_command("AT+CSCS=\"IRA\"", NULL);
|
||||
|
||||
/* Extra stuff */
|
||||
// at_send_command("AT+FCLASS=0", NULL);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// cmy: <20><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ϱ<EFBFBD>+CREG:<stat>
|
||||
/* 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: <20><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ϱ<EFBFBD>+CGREG:<stat>
|
||||
/* 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);
|
||||
|
||||
// <20><><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>ģ<EFBFBD>飬<EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٷ<EFBFBD><D9B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD>
|
||||
// <20>ڴ<EFBFBD><DAB4>ٴ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
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;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/* <20><>ʾ<EFBFBD><CABE><EFBFBD>к<EFBFBD><D0BA><EFBFBD> */
|
||||
at_send_command("AT+CLIP=1", NULL);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/* SMS text mode */
|
||||
/* lintao: just only support text mode*/
|
||||
at_send_command("AT+CMGF=0", NULL);
|
||||
|
||||
/* lintaos: set notify for new SMS(including +CMT<4D><54>+CMTI<54><49>+CDSI)*/
|
||||
at_send_command("AT+CNMI=1,2,0,0,0", NULL);
|
||||
|
||||
// ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD>
|
||||
at_send_command("AT+CSMS=1", NULL);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// cmy: <20><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ϱ<EFBFBD>+CREG:<stat>
|
||||
/* 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: <20><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ϱ<EFBFBD>+CGREG:<stat>
|
||||
/* GPRS registration events */
|
||||
at_send_command("AT+CGREG=2", NULL);
|
||||
|
||||
// <20><><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>ģ<EFBFBD>飬<EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٷ<EFBFBD><D9B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD>
|
||||
// <20>ڴ<EFBFBD><DAB4>ٴ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
at_send_command("ATE0", NULL);
|
||||
|
||||
LOGD("[%s]: === Level", __FUNCTION__);
|
||||
}
|
||||
|
||||
void initModem_cdma()
|
||||
{
|
||||
LOGD("[%s]: === Enter", __FUNCTION__);
|
||||
|
||||
ATResponse *p_response = NULL;
|
||||
int err;
|
||||
|
||||
/* <20><>ʾ<EFBFBD><CABE><EFBFBD>к<EFBFBD><D0BA><EFBFBD> */
|
||||
//at_send_command("AT+CLIP=1", NULL);
|
||||
|
||||
/* SMS text mode */
|
||||
// cmy: just only support text mode
|
||||
//at_send_command("AT+CMGF=1", NULL);
|
||||
|
||||
// cmy: <20><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD><C2B6><EFBFBD>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+CMT<4D><54>+CMTI<54><49>+CDSI3 <20>֣<EFBFBD><D6A3>ϱ<EFBFBD><CFB1><EFBFBD> TE <20>ķ<EFBFBD>ʽ
|
||||
//at_send_command("AT+CNMI=1,2,0,0,0", NULL);
|
||||
|
||||
// <20><><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>ģ<EFBFBD>飬<EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٷ<EFBFBD><D9B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD>
|
||||
// <20>ڴ<EFBFBD><DAB4>ٴ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
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;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/* <09><>ʾ<EFBFBD><CABE><EFBFBD>к<EFBFBD><D0BA><EFBFBD> */
|
||||
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);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/* SMS PDU mode */
|
||||
at_send_command("AT+CMGF=0", NULL);
|
||||
|
||||
/* +CSSU unsolicited supp service notifications */
|
||||
at_send_command("AT+CSSN=0,1", NULL);
|
||||
|
||||
// cmy: <20><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD><C2B6><EFBFBD>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+CMT<4D><54>+CMTI<54><49>+CDSI3 <20>֣<EFBFBD><D6A3>ϱ<EFBFBD><CFB1><EFBFBD> TE <20>ķ<EFBFBD>ʽ
|
||||
at_send_command("AT+CNMI=1,2,0,0,0", NULL);
|
||||
|
||||
// ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD>
|
||||
at_send_command("AT+CSMS=1", NULL);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/* HEX character set */
|
||||
at_send_command("AT+CSCS=\"IRA\"", NULL);
|
||||
|
||||
/* Extra stuff */
|
||||
// at_send_command("AT+FCLASS=0", NULL);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
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__);
|
||||
|
||||
|
||||
}
|
||||
|
||||
7
hardware/ril/reference-ril/modem_define_func.h
Normal file
7
hardware/ril/reference-ril/modem_define_func.h
Normal file
@ -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);
|
||||
1990
hardware/ril/reference-ril/modem_list.h
Normal file
1990
hardware/ril/reference-ril/modem_list.h
Normal file
File diff suppressed because it is too large
Load Diff
189
hardware/ril/reference-ril/operator_table.c
Normal file
189
hardware/ril/reference-ril/operator_table.c
Normal file
@ -0,0 +1,189 @@
|
||||
#include <stdio.h>
|
||||
#include "operator_table.h"
|
||||
|
||||
#define LOG_TAG "RIL"
|
||||
#include <utils/Log.h>
|
||||
|
||||
OperatorInfo** gOperatorTable = NULL;//[200];
|
||||
SpnInfo** spnTable=NULL;
|
||||
int gOperatorCounts = 0;
|
||||
int gSpnCounts = 0;
|
||||
|
||||
/* <20><>Ч<EFBFBD><D0A7>: ȥ<><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ո<EFBFBD><D5B8><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĩ<EFBFBD>Ļس<C4BB><D8B3><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD>'#'<27><><EFBFBD>أ<EFBFBD><D8A3><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
||||
<20>ɹ<EFBFBD><C9B9><EFBFBD> <20>û<EFBFBD><C3BB><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>
|
||||
ʧ<>ܷ<EFBFBD><DCB7><EFBFBD> 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;
|
||||
|
||||
// ȥ<><C8A5><EFBFBD><EFBFBD>ǰ<EFBFBD>ո<EFBFBD>
|
||||
while(pt[0] == ' ') ++pt;
|
||||
|
||||
// ȥ<><C8A5>β<EFBFBD><CEB2><EFBFBD><EFBFBD> \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; // ע<><D7A2><EFBFBD><EFBFBD>
|
||||
if( pt[0] == '\0' ) continue; // <20><><EFBFBD><EFBFBD>
|
||||
|
||||
// ȡ<><C8A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>
|
||||
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; i<gOperatorCounts; i++)
|
||||
{
|
||||
// LOGD("gOperatorTable[i]=%p", gOperatorTable[i]);
|
||||
if( gOperatorTable[i]==NULL ) continue;
|
||||
|
||||
// LOGD("%d: [%s] [%s] [%s]\n", i, gOperatorTable[i]->numeric, gOperatorTable[i]->salphanumeric, gOperatorTable[i]->lalphanumeric);
|
||||
if( !strcmp(gOperatorTable[i]->numeric,numeric) )
|
||||
return gOperatorTable[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* <20>ɹ<EFBFBD>: operator table <20><>С
|
||||
ʧ<><CAA7>: 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; i<gOperatorCounts; i++)
|
||||
{
|
||||
OperatorInfo* operator = (OperatorInfo*)malloc(sizeof(OperatorInfo));
|
||||
if( getValidLine(operator->numeric, 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; i<gSpnCounts; i++)
|
||||
{
|
||||
// LOGD("gOperatorTable[i]=%p", gOperatorTable[i]);
|
||||
if( spnTable[i]==NULL ) continue;
|
||||
|
||||
// LOGD("%d: [%s] [%s]\n", i, spnTable[i]->numeric, 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; i<gSpnCounts; i++)
|
||||
{
|
||||
SpnInfo* spn = (SpnInfo*)malloc(sizeof(OperatorInfo));
|
||||
if( getValidLine(spn->numeric, 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;
|
||||
}
|
||||
|
||||
|
||||
17
hardware/ril/reference-ril/operator_table.h
Normal file
17
hardware/ril/reference-ril/operator_table.h
Normal file
@ -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);
|
||||
6275
hardware/ril/reference-ril/ril-rk29-dataonly.c
Normal file
6275
hardware/ril/reference-ril/ril-rk29-dataonly.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user