#define LOG_TAG "RIL"
#include <utils/Log.h>
+#include <cutils/properties.h>
#define MAX_AT_RESPONSE 0x1000
/* pathname returned from RIL_REQUEST_SETUP_DATA_CALL / RIL_REQUEST_SETUP_DEFAULT_PDP */
-#define PPP_TTY_PATH "/dev/omap_csmi_tty1"
+#define PPP_TTY_PATH "/dev/ppp0"
#ifdef USE_TI_COMMANDS
#define WORKAROUND_FAKE_CGEV 1
#endif
+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
+} 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 int getSIMStatus();
+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);
* Note: directly modified line and has *p_call point directly into
* modified line
*/
-static int callFromCLCCLine(char *line, RIL_CallOld *p_call)
+static int callFromCLCCLine(char *line, RIL_Call *p_call)
{
//+CLCC: 1,0,2,0,0,\"+18005551212\",145
// index,isMT,state,mode,isMpty(,number,TOA)?
* ds = 1 // Status reports routed to TE
* bfr = 1 // flush buffer
*/
- at_send_command("AT+CNMI=1,2,2,1,1", NULL);
+ LOGI ("######### SIM READY !!\n");
+ at_send_command("AT+CNMI=1,2,2,1,0", NULL);
}
static void requestRadioPower(void *data, size_t datalen, RIL_Token t)
ATLine *p_cur;
int countCalls;
int countValidCalls;
- RIL_CallOld *p_calls;
- RIL_CallOld **pp_calls;
+ RIL_Call *p_calls;
+ RIL_Call **pp_calls;
int i;
int needRepoll = 0;
/* yes, there's an array of pointers and then an array of structures */
- pp_calls = (RIL_CallOld **)alloca(countCalls * sizeof(RIL_CallOld *));
- p_calls = (RIL_CallOld *)alloca(countCalls * sizeof(RIL_CallOld));
- memset (p_calls, 0, countCalls * sizeof(RIL_CallOld));
+ pp_calls = (RIL_Call **)alloca(countCalls * sizeof(RIL_Call *));
+ p_calls = (RIL_Call *)alloca(countCalls * sizeof(RIL_Call));
+ memset (p_calls, 0, countCalls * sizeof(RIL_Call));
/* init the pointer array */
for(i = 0; i < countCalls ; i++) {
#endif /*WORKAROUND_ERRONEOUS_ANSWER*/
RIL_onRequestComplete(t, RIL_E_SUCCESS, pp_calls,
- countValidCalls * sizeof (RIL_CallOld *));
+ countValidCalls * sizeof (RIL_Call *));
at_response_free(p_response);
}
asprintf(&responseStr[0], "%d", response[0]);
- asprintf(&responseStr[1], "%d", response[1]);
- asprintf(&responseStr[2], "%d", response[2]);
+ asprintf(&responseStr[1], "%x", response[1]);
+ asprintf(&responseStr[2], "%x", response[2]);
if (count > 3)
asprintf(&responseStr[3], "%d", response[3]);
len = strlen(cmd);
while (cur < len) {
- do {
+ do {
written = write (fd, cmd + cur, len - cur);
} while (written < 0 && errno == EINTR);
if (written < 0) {
- LOGE("### ERROR writing to /dev/qmi");
- close(fd);
- goto error;
- }
+ LOGE("### ERROR writing to /dev/qmi");
+ close(fd);
+ goto error;
+ }
- cur += written;
- }
+ cur += written;
+ }
// wait for interface to come online
if (retry == 0) {
LOGE("### Failed to get data connection up\n");
- goto error;
- }
+ goto error;
+ }
qmistatus = system("netcfg rmnet0 dhcp");
if (qmistatus < 0) goto error;
- } else {
+ } else {
- asprintf(&cmd, "AT+CGDCONT=1,\"IP\",\"%s\",,0,0", apn);
+ //asprintf(&cmd, "AT+CGDCONT=1,\"IP\",\"%s\",,0,0", apn);
//FIXME check for error here
- err = at_send_command(cmd, NULL);
- free(cmd);
+ //err = at_send_command(cmd, NULL);
+ //free(cmd);
// Set required QoS params to default
- err = at_send_command("AT+CGQREQ=1", NULL);
+ //err = at_send_command("AT+CGQREQ=1", NULL);
// Set minimum QoS params to default
- err = at_send_command("AT+CGQMIN=1", NULL);
+ //err = at_send_command("AT+CGQMIN=1", NULL);
// packet-domain event reporting
- err = at_send_command("AT+CGEREP=1,0", NULL);
+ //err = at_send_command("AT+CGEREP=1,0", NULL);
// Hangup anything that's happening there now
- err = at_send_command("AT+CGACT=1,0", NULL);
+ //err = at_send_command("AT+CGACT=1,0", NULL);
+ //err = at_send_command("AT+CGACT=1,1", NULL);
// Start data on PDP context 1
- err = at_send_command("ATD*99***1#", &p_response);
-
- if (err < 0 || p_response->success == 0) {
+ //err = at_send_command("ATD*99***1#", &p_response);
+ //err = at_send_command("ATD*99#", &p_response);
+ //system("echo test");
+ //system("pppd call gprs");
+ //property_set("ctl.start", "pppd_gprs");
+ //LOGD("ctrl.start err = %d\n", err);
+ //err = system("pppd call gprs");
+ //LOGD("pppd err = %d\n", err);
+ /*if (err < 0 || p_response->success == 0) {
goto error;
- }
+ }*/
+ // add pppd init code under this line
+
+
}
RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response));
}
}
-/** returns one of RIM_SIM_*. Returns RIL_SIM_NOT_READY on error */
-static int
+/** Returns SIM_NOT_READY on error */
+static SIM_Status
getSIMStatus()
{
ATResponse *p_response = NULL;
char *cpinResult;
if (sState == RADIO_STATE_OFF || sState == RADIO_STATE_UNAVAILABLE) {
- ret = RIL_SIM_NOT_READY;
+ ret = SIM_NOT_READY;
goto done;
}
err = at_send_command_singleline("AT+CPIN?", "+CPIN:", &p_response);
if (err != 0) {
- ret = RIL_SIM_NOT_READY;
+ ret = SIM_NOT_READY;
goto done;
}
break;
case CME_SIM_NOT_INSERTED:
- ret = RIL_SIM_ABSENT;
+ ret = SIM_ABSENT;
goto done;
default:
- ret = RIL_SIM_NOT_READY;
+ ret = SIM_NOT_READY;
goto done;
}
err = at_tok_start (&cpinLine);
if (err < 0) {
- ret = RIL_SIM_NOT_READY;
+ ret = SIM_NOT_READY;
goto done;
}
err = at_tok_nextstr(&cpinLine, &cpinResult);
if (err < 0) {
- ret = RIL_SIM_NOT_READY;
+ ret = SIM_NOT_READY;
goto done;
}
if (0 == strcmp (cpinResult, "SIM PIN")) {
- ret = RIL_SIM_PIN;
+ ret = SIM_PIN;
goto done;
} else if (0 == strcmp (cpinResult, "SIM PUK")) {
- ret = RIL_SIM_PUK;
+ ret = SIM_PUK;
goto done;
} else if (0 == strcmp (cpinResult, "PH-NET PIN")) {
- return RIL_SIM_NETWORK_PERSONALIZATION;
+ return SIM_NETWORK_PERSONALIZATION;
} else if (0 != strcmp (cpinResult, "READY")) {
/* we're treating unsupported lock types as "sim absent" */
- ret = RIL_SIM_ABSENT;
+ ret = SIM_ABSENT;
goto done;
}
p_response = NULL;
cpinResult = NULL;
- ret = RIL_SIM_READY;
+ ret = SIM_READY;
done:
at_response_free(p_response);
*/
static int getCardStatus(RIL_CardStatus **pp_card_status) {
static RIL_AppStatus app_status_array[] = {
- // RIL_SIM_ABSENT = 0
+ // SIM_ABSENT = 0
{ RIL_APPTYPE_UNKNOWN, RIL_APPSTATE_UNKNOWN, RIL_PERSOSUBSTATE_UNKNOWN,
NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, RIL_PINSTATE_UNKNOWN },
- // RIL_SIM_NOT_READY = 1
+ // SIM_NOT_READY = 1
{ RIL_APPTYPE_SIM, RIL_APPSTATE_DETECTED, RIL_PERSOSUBSTATE_UNKNOWN,
NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, RIL_PINSTATE_UNKNOWN },
- // RIL_SIM_READY = 2
+ // SIM_READY = 2
{ RIL_APPTYPE_SIM, RIL_APPSTATE_READY, RIL_PERSOSUBSTATE_READY,
NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, RIL_PINSTATE_UNKNOWN },
- // RIL_SIM_PIN = 3
+ // SIM_PIN = 3
{ RIL_APPTYPE_SIM, RIL_APPSTATE_PIN, RIL_PERSOSUBSTATE_UNKNOWN,
NULL, NULL, 0, RIL_PINSTATE_ENABLED_NOT_VERIFIED, RIL_PINSTATE_UNKNOWN },
- // RIL_SIM_PUK = 4
+ // SIM_PUK = 4
{ RIL_APPTYPE_SIM, RIL_APPSTATE_PUK, RIL_PERSOSUBSTATE_UNKNOWN,
NULL, NULL, 0, RIL_PINSTATE_ENABLED_BLOCKED, RIL_PINSTATE_UNKNOWN },
- // RIL_SIM_NETWORK_PERSONALIZATION = 5
+ // 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 }
};
int num_apps;
int sim_status = getSIMStatus();
- if (sim_status == RIL_SIM_ABSENT) {
+ if (sim_status == SIM_ABSENT) {
card_state = RIL_CARDSTATE_ABSENT;
num_apps = 0;
} else {
// Initialize application status
int i;
for (i = 0; i < RIL_CARD_MAX_APPS; i++) {
- p_card_status->applications[i] = app_status_array[RIL_SIM_ABSENT];
+ p_card_status->applications[i] = app_status_array[SIM_ABSENT];
}
// Pickup the appropriate application status
}
switch(getSIMStatus()) {
- case RIL_SIM_ABSENT:
- case RIL_SIM_PIN:
- case RIL_SIM_PUK:
- case RIL_SIM_NETWORK_PERSONALIZATION:
+ case SIM_ABSENT:
+ case SIM_PIN:
+ case SIM_PUK:
+ case SIM_NETWORK_PERSONALIZATION:
default:
setRadioState(RADIO_STATE_SIM_LOCKED_OR_ABSENT);
return;
- case RIL_SIM_NOT_READY:
+ case SIM_NOT_READY:
RIL_requestTimedCallback (pollSIMState, NULL, &TIMEVAL_SIMPOLL);
return;
- case RIL_SIM_READY:
+ case SIM_READY:
setRadioState(RADIO_STATE_SIM_READY);
return;
}
/* Alternating voice/data off */
at_send_command("AT+CMOD=0", NULL);
- /* Not muted */
- at_send_command("AT+CMUT=0", NULL);
-
/* +CSSU unsolicited supp service notifications */
at_send_command("AT+CSSN=0,1", NULL);
{
char *line = NULL;
int err;
-
+LOGI("!!!!!!!!!!!!!!!!!!!!!! reference-ril.c onUnsolicited !!!!!!!!!!!!!!!!!!!!!!1\n");
/* Ignore unsolicited responses until we're initialized.
* This is OK because the RIL library will poll for initial state
*/
RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED,
NULL, 0);
#ifdef WORKAROUND_FAKE_CGEV
- RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL);
+ RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL);
#endif /* WORKAROUND_FAKE_CGEV */
} else if (strStartsWith(s, "+CMT:")) {
RIL_onUnsolicitedResponse (
SOCK_STREAM );
} else if (s_device_path != NULL) {
fd = open (s_device_path, O_RDWR);
- if ( fd >= 0 && !memcmp( s_device_path, "/dev/ttyS", 9 ) ) {
+ if ( fd >= 0) {
/* disable echo on serial ports */
struct termios ios;
tcgetattr( fd, &ios );
}
}
+#if 0
+ fd=-1;
+ while (fd < 0) {
+ LOGI ("xp-debug mainLoop\n");
+ // signal(SIGIO, SIG_IGN); // the important one.
+
+ fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY);
+ LOGD ("##############open /dev/ttyUSB0##############\n");
+ if (fd < 0) {
+ LOGI ("fd < 0 fd:%d\n",fd);
+ //return 0;
+ } else {
+ fcntl(fd,F_SETFL,0);
+ struct termios my_termios;
+ tcgetattr(fd, &my_termios);
+
+ cfsetispeed(&my_termios,B9600); // Baud rate 9600
+ cfsetospeed(&my_termios,B9600);
+
+ my_termios.c_cflag &= ~CSIZE; // 8 data bits
+ my_termios.c_cflag &= ~PARENB; // no parity
+ my_termios.c_cflag &= ~CSTOPB; // No hw flow control
+ my_termios.c_cflag &= ~CRTSCTS;
+ my_termios.c_cflag |= CS8;
+ my_termios.c_lflag &= ~(ICANON|ECHO|ECHOE|ISIG); // No terminal processing
+ my_termios.c_oflag &= ~OPOST;
+
+ my_termios.c_cc[VMIN] = 0; // Timeout before packet (unused)
+ my_termios.c_cc[VTIME] = 10; // Timeout between characters
+ my_termios.c_iflag &= ~(IXON|IXOFF|IXANY); // Disable sw flow control
+
+ my_termios.c_cflag |= (CLOCAL|CREAD);
+
+ tcsetattr(fd,TCSANOW, &my_termios);
+ fcntl(fd,F_SETFL,0);
+ }
+ if (fd < 0) {
+ perror ("opening AT interface. retrying...");
+ sleep(10);
+ /* never returns */
+ }
+ }
+#endif
+
s_closed = 0;
ret = at_open(fd, onUnsolicited);