ATRESPONSE_t pas_wirx_handler(char* cmdline, ATOP_t opType, char* response) { int err = 0, cmd = -1; bool b = false; bool enable = false; char* srcAddr = "", dstAddr = ""; switch(opType){ case AT_SET_OP: err = at_tok_nextint(&cmdline, &cmd); if (err < 0) return -1; switch(cmd) { case 0: #ifdef MTK_WLAN_SUPPORT b = WIFI_TEST_SetRX(false, srcAddr, dstAddr); #endif break; case 1: err = at_tok_nextint(&cmdline, &srcAddr); if (err < 0) return -1; err = at_tok_nextint(&cmdline, &dstAddr); if (err < 0) return -1; #ifdef MTK_WLAN_SUPPORT b = WIFI_TEST_SetRX(true, srcAddr, dstAddr); #endif break; } default: break; } if(b) return AT_OK; else return AT_ERROR; }
/** * RIL_REQUEST_QUERY_CALL_WAITING * * Query current call waiting state. ok */ void requestQueryCallWaiting(void *data, size_t datalen, RIL_Token t) { ATResponse *p_response; p_response = NULL; int response[2] = {0, 0}; int c = ((int *)data)[0]; char *cmd; asprintf(&cmd, "AT+CCWA=1,2,1,%d", c); int err = at_send_command_singleline(cmd, "+CCWA: ", &p_response); free(cmd); if (err >= 0 && p_response->success) { char *line = p_response->p_intermediates->line; err = at_tok_start(&line); if (err >= 0) { err = at_tok_nextint(&line, &response[0]); if (err >= 0) err = at_tok_nextint(&line, &response[1]); } } RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); at_response_free(p_response); }
int sendSimIOCmdICC(const RIL_SIM_IO_v6 *ioargs, ATResponse **atresponse, RIL_SIM_IO_Response *sr) { int err; char *fmt; char *arg6; char *arg7; char *line; /* FIXME Handle pin2. */ memset(sr, 0, sizeof(*sr)); arg6 = ioargs->data; arg7 = ioargs->path; if (arg7 && arg6) { fmt = "AT+CRSM=%d,%d,%d,%d,%d,\"%s\",\"%s\""; } else if (arg7) { fmt = "AT+CRSM=%d,%d,%d,%d,%d,,\"%s\""; arg6 = arg7; } else if (arg6) { fmt = "AT+CRSM=%d,%d,%d,%d,%d,\"%s\""; } else { fmt = "AT+CRSM=%d,%d,%d,%d,%d"; } err = at_send_command_singleline(fmt, "+CRSM:", atresponse,ioargs->command, ioargs->fileid, ioargs->p1, ioargs->p2, ioargs->p3, arg6, arg7); if (err != AT_NOERROR) return err; line = (*atresponse)->p_intermediates->line; err = at_tok_start(&line); if (err < 0) goto finally; err = at_tok_nextint(&line, &(sr->sw1)); if (err < 0) goto finally; err = at_tok_nextint(&line, &(sr->sw2)); if (err < 0) goto finally; if (at_tok_hasmore(&line)) { err = at_tok_nextstr(&line, &(sr->simResponse)); if (err < 0) goto finally; } finally: return err; }
void reportSignalStrength(void *param) { ATResponse *p_response = NULL; int err, tmp; char *line; RIL_SignalStrength_v6 resp; memset(&resp,0,sizeof(resp)); resp.GW_SignalStrength.signalStrength = -1; resp.GW_SignalStrength.bitErrorRate = -1; resp.LTE_SignalStrength.signalStrength = -1; resp.LTE_SignalStrength.rsrp = -1; resp.LTE_SignalStrength.rsrq = -1; resp.LTE_SignalStrength.rssnr = -1; resp.LTE_SignalStrength.cqi = -1; 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, &(resp.GW_SignalStrength.signalStrength)); if (err < 0) goto error; err = at_tok_nextint(&line, &(resp.GW_SignalStrength.bitErrorRate)); if (err < 0) goto error; at_response_free(p_response); p_response = NULL; if (param != NULL) resp.GW_SignalStrength.signalStrength = *(int*)param; resp.LTE_SignalStrength.signalStrength = -1; resp.LTE_SignalStrength.rsrp = -1; resp.LTE_SignalStrength.rsrq = -1; resp.LTE_SignalStrength.rssnr = -1; resp.LTE_SignalStrength.cqi = -1; RIL_onUnsolicitedResponse ( RIL_UNSOL_SIGNAL_STRENGTH, & resp, sizeof(resp)); return; error: at_response_free(p_response); }
/** * Note: directly modified line and has *p_call point directly into * modified line */ static int callFromCLCCLine(char *line, RIL_Call *p_call) { //+CLCC: 1,0,2,0,0,\"+18005551212\",145 // index,isMT,state,mode,isMpty(,number,TOA)? int err; int state; int mode; err = at_tok_start(&line); if (err < 0) goto error; err = at_tok_nextint(&line, &(p_call->index)); if (err < 0) goto error; err = at_tok_nextbool(&line, &(p_call->isMT)); if (err < 0) goto error; err = at_tok_nextint(&line, &state); if (err < 0) goto error; err = clccStateToRILState(state, &(p_call->state)); if (err < 0) goto error; err = at_tok_nextint(&line, &mode); if (err < 0) goto error; p_call->isVoice = (mode == 0); err = at_tok_nextbool(&line, &(p_call->isMpty)); if (err < 0) goto error; if (at_tok_hasmore(&line)) { err = at_tok_nextstr(&line, &(p_call->number)); /* tolerate null here */ if (err < 0) return 0; // Some lame implementations return strings // like "NOT AVAILABLE" in the CLCC line if (p_call->number != NULL && 0 == strspn(p_call->number, "+0123456789")) p_call->number = NULL; err = at_tok_nextint(&line, &p_call->toa); if (err < 0) goto error; } p_call->uusInfo = NULL; return 0; error: LOGE("invalid CLCC line\n"); return -1; }
/** * RIL_UNSOL_NITZ_TIME_RECEIVED * * Called when radio has received a NITZ time message. * * "data" is const char * pointing to NITZ time string * */ void onNetworkTimeReceived(const char *s) { /* Special handling of DST for Android framework Module does not include DST correction in NITZ, but Android expects it */ char *line, *tok, *response, *time, *timestamp; int tz, dst; tok = line = strdup(s); if (NULL == tok) { LOGE("%s() Failed to allocate memory", __func__); return; } at_tok_start(&tok); LOGD("%s() Got nitz: %s", __func__, s); if (at_tok_nextint(&tok, &tz) != 0) LOGE("%s() Failed to parse NITZ tz %s", __func__, s); else if (at_tok_nextstr(&tok, &time) != 0) LOGE("%s() Failed to parse NITZ time %s", __func__, s); else if (at_tok_nextstr(&tok, ×tamp) != 0) LOGE("%s() Failed to parse NITZ timestamp %s", __func__, s); else { if (at_tok_nextint(&tok, &dst) != 0) { dst = 0; LOGE("%s() Failed to parse NITZ dst, fallbacking to dst=0 %s", __func__, s); } if (!(asprintf(&response, "%s%+03d,%02d", time + 2, tz + (dst * 4), dst))) { free(line); LOGE("%s() Failed to allocate string", __func__); return; } if (strncmp(response, last_nitz_time, strlen(response)) != 0) { RIL_onUnsolicitedResponse(RIL_UNSOL_NITZ_TIME_RECEIVED, response, sizeof(char *)); strncpy(last_nitz_time, response, strlen(response)); } else LOGD("%s() Discarding NITZ since it hasn't changed since last update", __func__); free(response); enqueueRILEvent(RIL_EVENT_QUEUE_NORMAL, sendTime, NULL, NULL); } free(line); }
static int get_phone_book(int index, phone_book_t* pb) { int ret = -1, err; char* cmd = NULL; char* line = NULL; char* buffer = NULL; ATResponse *p_response = NULL; asprintf(&cmd,"AT+CPBR=%d", index); at_send_command("AT+CSCS=\"UCS2\"", NULL); err = at_send_command_singleline(cmd,"+CPBR:",&p_response); if (err < 0 || !p_response || p_response->success == 0) goto error; if (p_response && p_response->p_intermediates) { line=p_response->p_intermediates->line; err=at_tok_start(&line); if (err < 0) goto error; err=at_tok_nextint(&line,&(pb->index)); if (err < 0) goto error; err=at_tok_nextstr(&line,&buffer); if (err < 0) goto error; strcpy(pb->number, buffer); err=at_tok_nextint(&line,&(pb->code)); if (err < 0) goto error; err=at_tok_nextstr(&line,&buffer); if (err < 0) goto error; strcpy(pb->alpha, buffer); } ret = 0; error: at_response_free(p_response); free(cmd); return ret; }
void* onUnknownCertificate (void *data) { int err; char *line; int ignore; int msg_id; int app_id; GpsCtrlContext *context = get_context(); line = (char *) data; LOGD("%s: %s", __FUNCTION__, line); err = at_tok_start(&line); if (err < 0) { LOGE("%s error parsing data", __FUNCTION__); return NULL; } err = at_tok_nextint(&line, &ignore); if (err < 0) { LOGE("%s error parsing data", __FUNCTION__); return NULL; } err = at_tok_nextint(&line, &msg_id); if (err < 0) { LOGE("%s error parsing data", __FUNCTION__); return NULL; } err = at_tok_nextint(&line, &app_id); if (err < 0) { LOGE("%s error parsing data", __FUNCTION__); return NULL; } LOGD("%s, msg_id=%d, app_id=%d", __FUNCTION__, msg_id, app_id); err = at_send_command("AT*E2CERTUNREPLY=%d,%d", msg_id, context->supl_config.allow_uncert); if (err < 0) { LOGE("%s error sending at command", __FUNCTION__); return NULL; } return NULL; }
/** returns 1 if on, 0 if off, and -1 on error */ int getRadioPower() { ATResponse *p_response = NULL; int err; char *line; int 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; err = at_tok_nextint(&line, &ret); if (err < 0) goto error; at_response_free(p_response); return ret; error: at_response_free(p_response); return -1; }
int getZmdsValue() { int err = 0; int type = 4; char *line; ATResponse *atresponse=NULL; err = at_send_command_singleline("AT+ZMDS?", "+ZMDS:", &atresponse); if (err < 0) goto error; if (!atresponse->p_intermediates || !atresponse->p_intermediates->line) goto error; line = atresponse->p_intermediates->line; err = at_tok_start(&line); if (err < 0) goto error; err = at_tok_nextint(&line, &type); if (err < 0) goto error; error: at_response_free(atresponse); return type; }
static int onCmeError(char* s, char* sms_pdu) { char* line = NULL; int err; if (ussdStatus) { int code; line = strdup(s); at_tok_start(&line); err = at_tok_nextint(&line, &code); free(line); if (err < 0) goto out; if(code == 258 || code == 257 || code == 100){ char *responseStr[2]; responseStr[1] = NULL; asprintf(&responseStr[0], "%d", -1); RIL_onUnsolicitedResponse (RIL_UNSOL_ON_USSD, responseStr, 1*sizeof(char*)); } } out: return UNSOLICITED_SUCCESSED; }
/** * Returns error code from response * Assumes AT+CMEE=1 (numeric) mode */ AT_CME_Error at_get_cme_error(const ATResponse *p_response) { int ret; int err; char *p_cur; if (p_response->success > 0) { return CME_SUCCESS; } if (p_response->finalResponse == NULL || !strStartsWith(p_response->finalResponse, "+CME ERROR:") ) { return CME_ERROR_NON_CME; } p_cur = p_response->finalResponse; err = at_tok_start(&p_cur); if (err < 0) { return CME_ERROR_NON_CME; } err = at_tok_nextint(&p_cur, &ret); if (err < 0) { return CME_ERROR_NON_CME; } return (AT_CME_Error) ret; }
ATRESPONSE_t pas_wipow_handler(char* cmdline, ATOP_t opType, char* response) { int err = 0; bool b = false; uint32_t gain = 0; switch(opType){ case AT_SET_OP: err = at_tok_nextint(&cmdline, &gain); if (err < 0) return -1; #ifdef MTK_WLAN_SUPPORT b = WIFI_TEST_SetTXPower(gain); #endif if(b) { wifiGain = gain; return AT_OK; } else { wifiGain = -1; return AT_ERROR; } case AT_READ_OP: sprintf(response, "%d", wifiGain); return AT_OK; default: break; } return AT_ERROR; }
/* * Returns: 0 if FDN is not enabled * 1 if FDN is enabled */ static int isFdnEnabled(void) { int err = -1; int status = 0; char *line = NULL; ATResponse *atresponse = NULL; err = at_send_command_multiline("AT+CLCK=\"FD\",2", "+CLCK:", &atresponse); if (err < 0 || atresponse->success == 0) goto finally; line = atresponse->p_intermediates->line; err = at_tok_start(&line); if (err < 0) goto finally; err = at_tok_nextint(&line, &status); if (err < 0 ) goto finally; /* status = 1 means that FDN facility is active */ if (status != 1) status = 0; finally: at_response_free(atresponse); return status; }
/** * Poll +COPS? and return a success, or if the loop counter reaches * REPOLL_OPERATOR_SELECTED, return generic failure. */ static void pollOperatorSelected(void *params) { int err = 0; int response = 0; char *line = NULL; ATResponse *atresponse = NULL; struct operatorPollParams *poll_params; RIL_Token t; assert(params != NULL); poll_params = (struct operatorPollParams *) params; t = poll_params->t; if (poll_params->loopcount >= REPOLL_OPERATOR_SELECTED) goto error; err = at_send_command_singleline("AT+COPS?", "+COPS:", &atresponse); if (err != AT_NOERROR) goto error; line = atresponse->p_intermediates->line; err = at_tok_start(&line); if (err < 0) goto error; err = at_tok_nextint(&line, &response); if (err < 0) goto error; /* If we don't get more than the COPS: {0-4} we are not registered. Loop and try again. */ if (!at_tok_hasmore(&line)) { switch (s_registrationDeniedReason) { case IMSI_UNKNOWN_IN_HLR: /* fall through */ case ILLEGAL_ME: RIL_onRequestComplete(t, RIL_E_ILLEGAL_SIM_OR_ME, NULL, 0); free(poll_params); break; default: poll_params->loopcount++; enqueueRILEvent(RIL_EVENT_QUEUE_PRIO, pollOperatorSelected, poll_params, &TIMEVAL_OPERATOR_SELECT_POLL); } } else { /* We got operator, throw a success! */ RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); free(poll_params); } at_response_free(atresponse); return; error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); free(poll_params); at_response_free(atresponse); return; }
int getClvlValue() { int err = 0; int clvl; char *line; ATResponse *atresponse=NULL; err = at_send_command_singleline("AT+CLVL?", "+CLVL:", &atresponse); if (err < 0 || !atresponse || !atresponse->p_intermediates) goto error; line = atresponse->p_intermediates->line; err = at_tok_start(&line); if (err < 0) goto error; err = at_tok_nextint(&line, &clvl); if (err < 0) goto error; error: at_response_free(atresponse); return clvl; }
ATRESPONSE_t pas_wifreq_handler(char* cmdline, ATOP_t opType, char* response) { int err = 0; bool b = false; uint32_t freq = 0, offset = 0; switch(opType){ case AT_SET_OP: err = at_tok_nextint(&cmdline, &freq); if (err < 0) return -1; #ifdef MTK_WLAN_SUPPORT b = WIFI_TEST_SetFrequency(freq, offset); #endif if(b) { wifiFreq = freq; return AT_OK; } else { wifiFreq = -1; return AT_ERROR; } case AT_READ_OP: sprintf(response, "%d", wifiFreq); return AT_OK; default: break; } return AT_ERROR; }
static int onNewMesssageByIndex(char* s, char* sms_pdu) { char *line = NULL; int err; /* can't issue AT commands here -- call on main thread */ int index; char *response = NULL; line = strdup(s); at_tok_start(&line); err = at_tok_nextstr(&line, &response); if (err < 0) { LOGD("sms request fail"); goto out; } if (strcmp(response, "SM")) { LOGD("sms request arrive but it is not a new sms"); goto out; } /* Read the memory location of the sms */ err = at_tok_nextint(&line, &index); if (err < 0) { LOGD("error parse location"); goto out; } out: free(line); RIL_requestTimedCallback (readMessageByIndex, (void *)index, NULL); return UNSOLICITED_SUCCESSED; }
static int simIOGetLogicalChannel(void) { ATResponse *atresponse = NULL; static int g_lc = 0; int err; if (g_lc == 0) { struct tlv tlvApp, tlvAppId; char *line; char *resp; err = at_send_command_singleline("AT+CUAD", "+CUAD:", &atresponse); if (err != AT_NOERROR) return g_lc; line = atresponse->p_intermediates->line; err = at_tok_start(&line); if (err < 0) goto finally; err = at_tok_nextstr(&line, &resp); if (err < 0) goto finally; err = parseTlv(resp, &resp[strlen(resp)], &tlvApp); if (err < 0) goto finally; if (tlvApp.tag != 0x61) { /* Application */ err = -EINVAL; goto finally; } err = parseTlv(tlvApp.data, tlvApp.end, &tlvAppId); if (err < 0) goto finally; if (tlvAppId.tag != 0x4F) { /* Application ID */ err = -EINVAL; goto finally; } at_response_free(atresponse); err = at_send_command_singleline("AT+CCHO=\"%.*s\"", "+CCHO:", &atresponse, tlvAppId.end - tlvAppId.data, tlvAppId.data); if (err != AT_NOERROR) return g_lc; line = atresponse->p_intermediates->line; err = at_tok_start(&line); if (err < 0) goto finally; err = at_tok_nextint(&line, &g_lc); if (err < 0) goto finally; } finally: at_response_free(atresponse); return g_lc; }
void* onPgpsUrlReceived(void *data) { GpsCtrlContext *context = get_gpsctrl_context(); int err; int ignore; int id; char *url; char *cmd; char *line = (char *) data; err = at_tok_start(&line); if (err < 0) { MBMLOGE("%s error parsing data", __FUNCTION__); return NULL; } /* Ignore 1 integer from line */ err = at_tok_nextint(&line, &ignore); if (err < 0) { MBMLOGE("%s error parsing data", __FUNCTION__); return NULL; } err = at_tok_nextint(&line, &id); if (err < 0) { MBMLOGE("%s error parsing data", __FUNCTION__); return NULL; } err = at_tok_nextstr(&line, &url); if (err < 0) { MBMLOGW("%s error parsing pgps url", __FUNCTION__); return NULL; } err = asprintf(&cmd, "%d\n%s", id, url); if (err < 0) { MBMLOGE("%s error allocating cmd string", __FUNCTION__); return NULL; } service_handler_send_message(CMD_DOWNLOAD_PGPS_DATA, cmd); return NULL; }
ATRESPONSE_t pas_wienable_handler(char* cmdline, ATOP_t opType, char* response){ int err = 0, cmdID = 0; bool b = false; int r = -1; switch(opType){ case AT_SET_OP: err = at_tok_nextint(&cmdline, &cmdID); if (err < 0) return -1; switch(cmdID) { case 0: if(wifiEnableState == 1) { r = sendATCommandToServiceWithResult("AT+WITOF=1"); if(r != -1) wifiEnableState = 0; else return AT_ERROR; } else { #ifdef MTK_WLAN_SUPPORT b = WIFI_TEST_CloseDUT(); #endif if(b) wifiEnableState = 0; else return AT_ERROR; } return AT_OK; case 1: r = sendATCommandToServiceWithResult("AT+WITOF=2"); if(r != -1) wifiEnableState = 1; else return AT_ERROR; return AT_OK; case 2: #ifdef MTK_WLAN_SUPPORT b = WIFI_TEST_OpenDUT(); #endif if(b) wifiEnableState = 2; else return AT_ERROR; return AT_OK; } break; case AT_READ_OP: sprintf(response, "%d", wifiEnableState); return AT_OK; default: break; } return AT_ERROR; }
void onNetworkStatusChanged(const char *s) { int err; int skip; int cs_status, ps_status; int resp; char *line = NULL, *tok = NULL; cs_status = ps_status = 0; tok = line = strdup(s); if (tok == NULL) goto error; at_tok_start(&tok); err = at_tok_nextint(&tok, &skip); if (err < 0) goto error; err = at_tok_nextint(&tok, &cs_status); if (err < 0) goto error; err = at_tok_nextint(&tok, &ps_status); if (err < 0) goto error; resp = RIL_RESTRICTED_STATE_NONE; if (cs_status == E2REG_ACCESS_CLASS_BARRED) resp |= RIL_RESTRICTED_STATE_CS_ALL; if (ps_status == E2REG_ACCESS_CLASS_BARRED) resp |= RIL_RESTRICTED_STATE_PS_ALL; RIL_onUnsolicitedResponse(RIL_UNSOL_RESTRICTED_STATE_CHANGED, &resp, sizeof(int *)); /* If registered, poll signal strength for faster update of signal bar */ if ((cs_status == E2REG_REGISTERED) || (ps_status == E2REG_REGISTERED)) enqueueRILEvent(RIL_EVENT_QUEUE_PRIO, pollSignalStrength, (void *)-1, NULL); error: free(line); }
void _requestSignalStrengthWCDMA(void *data, size_t datalen, RIL_Token t) { ATResponse *p_response = NULL; int err; RIL_SignalStrength_v6 resp; char *line; memset(&resp,0,sizeof(resp)); 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, &(resp.GW_SignalStrength.signalStrength)); if (err < 0) goto error; err = at_tok_nextint(&line, &(resp.GW_SignalStrength.bitErrorRate)); if (err < 0) goto error; resp.LTE_SignalStrength.signalStrength = -1; resp.LTE_SignalStrength.rsrp = -1; resp.LTE_SignalStrength.rsrq = -1; resp.LTE_SignalStrength.rssnr = -1; resp.LTE_SignalStrength.cqi = -1; RIL_onRequestComplete(t, RIL_E_SUCCESS, &resp, sizeof(resp)); at_response_free(p_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 int onMessageListing(char* s, char* sms_pdu) { int* index = malloc(sizeof(int)); int stat = -1; char* line = NULL; line = strdup(s); at_tok_start(&line); at_tok_nextint(&line, index); at_tok_nextint(&line, &stat); RIL_requestTimedCallback (deleteMessageByIndex, index, NULL); if(stat == 0){ RIL_onUnsolicitedResponse ( RIL_UNSOL_RESPONSE_NEW_SMS, sms_pdu, strlen(sms_pdu)); } free(line); return UNSOLICITED_SUCCESSED; }
ATRESPONSE_t pas_wimode_handler(char* cmdline, ATOP_t opType, char* response) { int err = 0, cmdID = 0; bool b = false; uint32_t mode = 0; switch(opType){ case AT_SET_OP: err = at_tok_nextint(&cmdline, &cmdID); if (err < 0) return -1; switch(cmdID) { case 0: #ifdef MTK_WLAN_SUPPORT b = WIFI_TEST_SetMode(WIFI_TEST_MODE_BY_API_CONTROL); #endif break; case 1: #ifdef MTK_WLAN_SUPPORT b = WIFI_TEST_SetMode(WIFI_TEST_MODE_CW_ONLY); #endif break; case 2: #ifdef MTK_WLAN_SUPPORT b = WIFI_TEST_SetMode(WIFI_TEST_MODE_80211A_ONLY); #endif break; case 3: #ifdef MTK_WLAN_SUPPORT b = WIFI_TEST_SetMode(WIFI_TEST_MODE_80211B_ONLY); #endif break; case 4: #ifdef MTK_WLAN_SUPPORT b = WIFI_TEST_SetMode(WIFI_TEST_MODE_80211G_ONLY); #endif break; } if(b) return AT_OK; else return AT_ERROR; case AT_TEST_OP: #ifdef MTK_WLAN_SUPPORT b = WIFI_TEST_GetSupportedMode(mode); #endif sprintf(response, "%d", mode); break; default: break; } if(b) return AT_OK; else return AT_ERROR; }
static int getNetworkType() { int err; ATResponse *p_response = NULL; int type = 0; char *line; err = at_send_command_singleline("AT+COPS?", "+COPS:", &p_response); if (err < 0 || p_response->success == 0) { return type; } line = p_response->p_intermediates->line; err = at_tok_start(&line); if (err < 0) { goto out; } err = at_tok_nextint(&line, &type); err = at_tok_nextint(&line, &type); err = at_tok_nextint(&line, &type); err = at_tok_nextint(&line, &type); switch(type){ case 0: case 1: type = 2; break; case 2: type = 3; break; default: type = 3; break; } out: at_response_free(p_response); return type; }
/** * RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE * * Query the preferred network type (CS/PS domain, RAT, and operation mode) * for searching and registering. */ void requestGetPreferredNetworkType(void *data, size_t datalen, RIL_Token t) { (void) data; (void) datalen; int err = 0; int response = 0; int cfun; char *line; ATResponse *atresponse; err = at_send_command_singleline("AT+CFUN?", "+CFUN:", &atresponse); if (err != AT_NOERROR) goto error; line = atresponse->p_intermediates->line; err = at_tok_start(&line); if (err < 0) goto error; err = at_tok_nextint(&line, &cfun); if (err < 0) goto error; if (cfun < 0 || cfun >= 7) goto error; switch (cfun) { case PREF_NET_TYPE_2G_ONLY: response = PREF_NET_TYPE_GSM_ONLY; break; case PREF_NET_TYPE_3G_ONLY: response = PREF_NET_TYPE_WCDMA; break; case PREF_NET_TYPE_3G: response = PREF_NET_TYPE_GSM_WCDMA_AUTO; break; default: response = PREF_NET_TYPE_GSM_WCDMA_AUTO; break; } RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(int)); finally: at_response_free(atresponse); return; error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; }
/** * *EACE: Ringback tone received */ void onAudioCallEventNotify(const char *s) { char *line; char *tok; int err; int res; tok = line = strdup(s); err = at_tok_start(&tok); if (err < 0) goto error; err = at_tok_nextint(&tok, &res); if (err < 0) goto error; /* * *EACE:0/1 indicates stop/start of comfort tone. * *EACE:2 indicates voice call stopped. * *EACE:3 indicates voice call start, RIL uses this to inform Android * call state changed. This indicates call state has changed to ALERTING. */ if (res == 3) { #ifdef ENABLE_REPORTING_ALERTING_UPON_MISSING_CALL_STATE_FROM_NETWORK g_voice_call_start = true; #endif RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0); goto exit; } else if (res == 2) { #ifdef ENABLE_REPORTING_ALERTING_UPON_MISSING_CALL_STATE_FROM_NETWORK g_voice_call_start = false; #endif goto exit; } goto finally; error: LOGE("EACE: Failed to parse %s.", s); /* Stop a potential ringback tone from going forever due to failed parsing*/ res = 0; finally: RIL_onUnsolicitedResponse(RIL_UNSOL_RINGBACK_TONE, &res, sizeof(int *)); exit: free(line); return; }
ATRESPONSE_t pas_wiband_handler(char* cmdline, ATOP_t opType, char* response){ int err = 0, cmdID = 0; bool b = false; uint32_t mode = 0; switch(opType){ case AT_SET_OP: err = at_tok_nextint(&cmdline, &cmdID); if (err < 0) return -1; switch(cmdID) { case 0: #ifdef MTK_WLAN_SUPPORT b = WIFI_TEST_SetBandwidth(WIFI_TEST_BW_20MHZ); #endif if(b) { sprintf(response, "20MHZ"); wifiBand = 0; } break; case 1: #ifdef MTK_WLAN_SUPPORT b = WIFI_TEST_SetBandwidth(WIFI_TEST_BW_40MHZ); #endif if(b) { sprintf(response, "40MHZ"); wifiBand = 1; } break; } if(b) return AT_OK; else return AT_ERROR; case AT_READ_OP: if(wifiBand == 0) { sprintf(response, "20MHZ"); return AT_OK; } else if(wifiBand == 1) { sprintf(response, "40MHZ"); return AT_OK; } else { return AT_ERROR; } break; default: break; } return AT_ERROR; }
/** * RIL_REQUEST_QUERY_FACILITY_LOCK * * Query the status of a facility lock state. */ void requestQueryFacilityLock(void *data, size_t datalen, RIL_Token t) { int err, rat, response; ATResponse *atresponse = 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]; /* do not support FD string, force copy string SC */ if(strcmp(facility_string, "FD") == 0){ strcpy(facility_string, "SC"); } asprintf(&cmd, "AT+CLCK=\"%s\",2,\"%s\",%s", facility_string, facility_password, facility_class); err = at_send_command_singleline(cmd, "+CLCK:", &atresponse); free(cmd); if (err < 0 || atresponse->success == 0) { goto error; } line = atresponse->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)); finally: at_response_free(atresponse); return; error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; }