hardware/ril
Revision | b499fabc3459930a42f0ecc62257caef6aa216dc (tree) |
---|---|
Zeit | 2010-03-04 19:00:32 |
Autor | Luke Yang <luke_yang@asus...> |
Commiter | Chih-Wei Huang |
modify reference-ril to support 3G modem card on x86
@@ -208,6 +208,8 @@ static const char * s_smsUnsoliciteds[] = { | ||
208 | 208 | "+CMT:", |
209 | 209 | "+CDS:", |
210 | 210 | "+CBM:" |
211 | + //,"+CMGR" | |
212 | + //,"+CMTI" | |
211 | 213 | }; |
212 | 214 | static int isSMSUnsolicited(const char *line) |
213 | 215 | { |
@@ -36,11 +36,12 @@ | ||
36 | 36 | |
37 | 37 | #define LOG_TAG "RIL" |
38 | 38 | #include <utils/Log.h> |
39 | +#include <cutils/properties.h> | |
39 | 40 | |
40 | 41 | #define MAX_AT_RESPONSE 0x1000 |
41 | 42 | |
42 | 43 | /* pathname returned from RIL_REQUEST_SETUP_DATA_CALL / RIL_REQUEST_SETUP_DEFAULT_PDP */ |
43 | -#define PPP_TTY_PATH "/dev/omap_csmi_tty1" | |
44 | +#define PPP_TTY_PATH "/dev/ppp0" | |
44 | 45 | |
45 | 46 | #ifdef USE_TI_COMMANDS |
46 | 47 |
@@ -239,7 +240,8 @@ static void onSIMReady() | ||
239 | 240 | * ds = 1 // Status reports routed to TE |
240 | 241 | * bfr = 1 // flush buffer |
241 | 242 | */ |
242 | - at_send_command("AT+CNMI=1,2,2,1,1", NULL); | |
243 | + LOGI ("######### SIM READY !!\n"); | |
244 | + at_send_command("AT+CNMI=1,2,2,1,0", NULL); | |
243 | 245 | } |
244 | 246 | |
245 | 247 | static void requestRadioPower(void *data, size_t datalen, RIL_Token t) |
@@ -987,18 +989,18 @@ static void requestSetupDataCall(void *data, size_t datalen, RIL_Token t) | ||
987 | 989 | len = strlen(cmd); |
988 | 990 | |
989 | 991 | while (cur < len) { |
990 | - do { | |
992 | + do { | |
991 | 993 | written = write (fd, cmd + cur, len - cur); |
992 | 994 | } while (written < 0 && errno == EINTR); |
993 | 995 | |
994 | 996 | if (written < 0) { |
995 | - LOGE("### ERROR writing to /dev/qmi"); | |
996 | - close(fd); | |
997 | - goto error; | |
998 | - } | |
997 | + LOGE("### ERROR writing to /dev/qmi"); | |
998 | + close(fd); | |
999 | + goto error; | |
1000 | + } | |
999 | 1001 | |
1000 | - cur += written; | |
1001 | - } | |
1002 | + cur += written; | |
1003 | + } | |
1002 | 1004 | |
1003 | 1005 | // wait for interface to come online |
1004 | 1006 |
@@ -1022,8 +1024,8 @@ static void requestSetupDataCall(void *data, size_t datalen, RIL_Token t) | ||
1022 | 1024 | |
1023 | 1025 | if (retry == 0) { |
1024 | 1026 | LOGE("### Failed to get data connection up\n"); |
1025 | - goto error; | |
1026 | - } | |
1027 | + goto error; | |
1028 | + } | |
1027 | 1029 | |
1028 | 1030 | qmistatus = system("netcfg rmnet0 dhcp"); |
1029 | 1031 |
@@ -1031,31 +1033,41 @@ static void requestSetupDataCall(void *data, size_t datalen, RIL_Token t) | ||
1031 | 1033 | |
1032 | 1034 | if (qmistatus < 0) goto error; |
1033 | 1035 | |
1034 | - } else { | |
1036 | + } else { | |
1035 | 1037 | |
1036 | - asprintf(&cmd, "AT+CGDCONT=1,\"IP\",\"%s\",,0,0", apn); | |
1038 | + //asprintf(&cmd, "AT+CGDCONT=1,\"IP\",\"%s\",,0,0", apn); | |
1037 | 1039 | //FIXME check for error here |
1038 | - err = at_send_command(cmd, NULL); | |
1039 | - free(cmd); | |
1040 | + //err = at_send_command(cmd, NULL); | |
1041 | + //free(cmd); | |
1040 | 1042 | |
1041 | 1043 | // Set required QoS params to default |
1042 | - err = at_send_command("AT+CGQREQ=1", NULL); | |
1044 | + //err = at_send_command("AT+CGQREQ=1", NULL); | |
1043 | 1045 | |
1044 | 1046 | // Set minimum QoS params to default |
1045 | - err = at_send_command("AT+CGQMIN=1", NULL); | |
1047 | + //err = at_send_command("AT+CGQMIN=1", NULL); | |
1046 | 1048 | |
1047 | 1049 | // packet-domain event reporting |
1048 | - err = at_send_command("AT+CGEREP=1,0", NULL); | |
1050 | + //err = at_send_command("AT+CGEREP=1,0", NULL); | |
1049 | 1051 | |
1050 | 1052 | // Hangup anything that's happening there now |
1051 | - err = at_send_command("AT+CGACT=1,0", NULL); | |
1053 | + //err = at_send_command("AT+CGACT=1,0", NULL); | |
1054 | + //err = at_send_command("AT+CGACT=1,1", NULL); | |
1052 | 1055 | |
1053 | 1056 | // Start data on PDP context 1 |
1054 | - err = at_send_command("ATD*99***1#", &p_response); | |
1055 | - | |
1056 | - if (err < 0 || p_response->success == 0) { | |
1057 | + //err = at_send_command("ATD*99***1#", &p_response); | |
1058 | + //err = at_send_command("ATD*99#", &p_response); | |
1059 | + //system("echo test"); | |
1060 | + //system("pppd call gprs"); | |
1061 | + //property_set("ctl.start", "pppd_gprs"); | |
1062 | + //LOGD("ctrl.start err = %d\n", err); | |
1063 | + //err = system("pppd call gprs"); | |
1064 | + //LOGD("pppd err = %d\n", err); | |
1065 | + /*if (err < 0 || p_response->success == 0) { | |
1057 | 1066 | goto error; |
1058 | - } | |
1067 | + }*/ | |
1068 | + // add pppd init code under this line | |
1069 | + | |
1070 | + | |
1059 | 1071 | } |
1060 | 1072 | |
1061 | 1073 | RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); |
@@ -1836,9 +1848,6 @@ static void initializeCallback(void *param) | ||
1836 | 1848 | /* Alternating voice/data off */ |
1837 | 1849 | at_send_command("AT+CMOD=0", NULL); |
1838 | 1850 | |
1839 | - /* Not muted */ | |
1840 | - at_send_command("AT+CMUT=0", NULL); | |
1841 | - | |
1842 | 1851 | /* +CSSU unsolicited supp service notifications */ |
1843 | 1852 | at_send_command("AT+CSSN=0,1", NULL); |
1844 | 1853 |
@@ -1893,7 +1902,7 @@ static void onUnsolicited (const char *s, const char *sms_pdu) | ||
1893 | 1902 | { |
1894 | 1903 | char *line = NULL; |
1895 | 1904 | int err; |
1896 | - | |
1905 | +LOGI("!!!!!!!!!!!!!!!!!!!!!! reference-ril.c onUnsolicited !!!!!!!!!!!!!!!!!!!!!!1\n"); | |
1897 | 1906 | /* Ignore unsolicited responses until we're initialized. |
1898 | 1907 | * This is OK because the RIL library will poll for initial state |
1899 | 1908 | */ |
@@ -2031,7 +2040,7 @@ mainLoop(void *param) | ||
2031 | 2040 | SOCK_STREAM ); |
2032 | 2041 | } else if (s_device_path != NULL) { |
2033 | 2042 | fd = open (s_device_path, O_RDWR); |
2034 | - if ( fd >= 0 && !memcmp( s_device_path, "/dev/ttyS", 9 ) ) { | |
2043 | + if ( fd >= 0) { | |
2035 | 2044 | /* disable echo on serial ports */ |
2036 | 2045 | struct termios ios; |
2037 | 2046 | tcgetattr( fd, &ios ); |
@@ -2047,6 +2056,50 @@ mainLoop(void *param) | ||
2047 | 2056 | } |
2048 | 2057 | } |
2049 | 2058 | |
2059 | +#if 0 | |
2060 | + fd=-1; | |
2061 | + while (fd < 0) { | |
2062 | + LOGI ("xp-debug mainLoop\n"); | |
2063 | + // signal(SIGIO, SIG_IGN); // the important one. | |
2064 | + | |
2065 | + fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY); | |
2066 | + LOGD ("##############open /dev/ttyUSB0##############\n"); | |
2067 | + if (fd < 0) { | |
2068 | + LOGI ("fd < 0 fd:%d\n",fd); | |
2069 | + //return 0; | |
2070 | + } else { | |
2071 | + fcntl(fd,F_SETFL,0); | |
2072 | + struct termios my_termios; | |
2073 | + tcgetattr(fd, &my_termios); | |
2074 | + | |
2075 | + cfsetispeed(&my_termios,B9600); // Baud rate 9600 | |
2076 | + cfsetospeed(&my_termios,B9600); | |
2077 | + | |
2078 | + my_termios.c_cflag &= ~CSIZE; // 8 data bits | |
2079 | + my_termios.c_cflag &= ~PARENB; // no parity | |
2080 | + my_termios.c_cflag &= ~CSTOPB; // No hw flow control | |
2081 | + my_termios.c_cflag &= ~CRTSCTS; | |
2082 | + my_termios.c_cflag |= CS8; | |
2083 | + my_termios.c_lflag &= ~(ICANON|ECHO|ECHOE|ISIG); // No terminal processing | |
2084 | + my_termios.c_oflag &= ~OPOST; | |
2085 | + | |
2086 | + my_termios.c_cc[VMIN] = 0; // Timeout before packet (unused) | |
2087 | + my_termios.c_cc[VTIME] = 10; // Timeout between characters | |
2088 | + my_termios.c_iflag &= ~(IXON|IXOFF|IXANY); // Disable sw flow control | |
2089 | + | |
2090 | + my_termios.c_cflag |= (CLOCAL|CREAD); | |
2091 | + | |
2092 | + tcsetattr(fd,TCSANOW, &my_termios); | |
2093 | + fcntl(fd,F_SETFL,0); | |
2094 | + } | |
2095 | + if (fd < 0) { | |
2096 | + perror ("opening AT interface. retrying..."); | |
2097 | + sleep(10); | |
2098 | + /* never returns */ | |
2099 | + } | |
2100 | + } | |
2101 | +#endif | |
2102 | + | |
2050 | 2103 | s_closed = 0; |
2051 | 2104 | ret = at_open(fd, onUnsolicited); |
2052 | 2105 |
@@ -131,8 +131,8 @@ int main(int argc, char **argv) | ||
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | +#if 0 | |
134 | 135 | /* special override when in the emulator */ |
135 | -#if 1 | |
136 | 136 | { |
137 | 137 | static char* arg_overrides[3]; |
138 | 138 | static char arg_device[32]; |