Esempio n. 1
0
void requestDeleteSmsOnSim(void *data, size_t datalen, RIL_Token t)
{
	char * cmd;
	int err;
	ATResponse * p_response = NULL;
	asprintf(&cmd, "AT+CMGD=%d", ((int *)data)[0]);
	err = at_send_command(cmd, &p_response);
	free(cmd);
	if (err < 0 || p_response->success == 0) {
		RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	} else {
		RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
	}
	at_response_free(p_response);
}
Esempio n. 2
0
static char *getCharEncoding(void)
{
    int err;
    char *line, *chSet;
    char *result = NULL;
    ATResponse *p_response = NULL;
    err = at_send_command_singleline("AT+CSCS?", "+CSCS:", &p_response);

    if (err != AT_NOERROR) {
        ALOGE("%s() Failed to read AT+CSCS?", __func__);
        return NULL;
    }

    line = p_response->p_intermediates->line;
    err = at_tok_start(&line);
    if (err < 0) {
        at_response_free(p_response);
        return NULL;
    }

    err = at_tok_nextstr(&line, &chSet);
    if (err < 0) {
        at_response_free(p_response);
        return NULL;
    }

    /* If not any of the listed below, assume UCS-2 */
    if (!strcmp(chSet, "GSM") || !strcmp(chSet, "IRA")
            || !strncmp(chSet, "8859", 4) || !strcmp(chSet, "UTF-8")) {
        result = strdup(chSet);
    } else
        result = strdup("UCS-2");

    at_response_free(p_response);
    return result;
}
Esempio n. 3
0
static void clearPendingCommand(void)
{
    struct atcontext *context = get_at_context();

    ENTER;

    if (context->response != NULL) {
        at_response_free(context->response);
    }

    context->response = NULL;
    context->responsePrefix = NULL;
    context->smsPDU = NULL;

    EXIT;
}
Esempio n. 4
0
/**
 * RIL_REQUEST_WRITE_SMS_TO_SIM
 *
 * Stores a SMS message to SIM memory.
 */
void requestWriteSmsToSim(void *data, size_t datalen, RIL_Token t)
{
    RIL_SMS_WriteArgs *args;
    char *cmd;
    char *pdu;
    char *line;
    int length;
    int index;
    int err;
    ATResponse *atresponse = NULL;

    args = (RIL_SMS_WriteArgs *) data;

    length = strlen(args->pdu) / 2;
    asprintf(&cmd, "AT+CMGW=%d,%d", length, args->status);
    asprintf(&pdu, "%s%s", (args->smsc ? args->smsc : "00"), args->pdu);

    err = at_send_command_sms(cmd, pdu, "+CMGW:", &atresponse);
    free(cmd);
    free(pdu);

    if (err < 0 || atresponse->success == 0)
        goto error;

    if (atresponse->p_intermediates->line == NULL)
        goto error;

    line = atresponse->p_intermediates->line;

    err = at_tok_start(&line);
    if (err < 0)
        goto error;

    err = at_tok_nextint(&line, &index);
    if (err < 0)
        goto error;

    RIL_onRequestComplete(t, RIL_E_SUCCESS, &index, sizeof(int *));

finally:
    at_response_free(atresponse);
    return;

error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
    goto finally;
}
Esempio n. 5
0
void requestCancelUSSD(void *data, size_t datalen, RIL_Token t)
{
	ATResponse *p_response;
	int err;
	p_response = NULL;
	err = at_send_command_numeric("AT+CUSD=2", &p_response);
	if (err < 0 || p_response->success == 0) {
		RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	} else {
		RIL_onRequestComplete(t, RIL_E_SUCCESS,
				p_response->p_intermediates->line, sizeof(char *));
	}
	ussdStatus = 0;

	at_send_command("AT+CSCS=\"CUS2\"", NULL);
	at_response_free(p_response);
}
Esempio n. 6
0
void requestStkSendTerminalResponse (void *data, size_t datalen, RIL_Token t)
{
    char* cmd;
    ATResponse *p_response = NULL;
    int err;

    RIL_STK_UNUSED_PARM(datalen);

    asprintf(&cmd, "AT+STKTR=\"%s\"", (char *)data);

    err = at_send_command(cmd, &p_response, STK_CHANNEL_CTX);
    free(cmd);

    StkSendRequestComplete(err, p_response, t);

    at_response_free(p_response);
}
Esempio n. 7
0
void waitForTargetPPPStopped(RILChannelCtx *p_channel) {
    const char* line = NULL;
    int count = 0;
    p_channel->p_response = at_response_new();
    while (count < 60) {
        line = readline(p_channel);
        if (line != NULL && strcmp(line, "NO CARRIER") == 0) {
            RLOGI("readline: %s [%d]", line, count);
            break;
        } else {
            RLOGI("Still wait for NO CARRIER [%d]", count);
            ++count;
            sleep(1);
        }
    }
    at_response_free(p_channel->p_response);
}
Esempio n. 8
0
/**
 * RIL_REQUEST_SMS_ACKNOWLEDGE
 *
 * Acknowledge successful or failed receipt of SMS previously indicated
 * via RIL_UNSOL_RESPONSE_NEW_SMS .
 */
void requestSMSAcknowledge(void *data, size_t datalen, RIL_Token t)
{
    ATResponse *atresponse = NULL;
    int ack;
    int err;

    assert(datalen >= sizeof(int));
    ack = ((int *)data)[0];

    switch (ack) {
    case 0: /* Failed receipt */

        assert(datalen >= 2 * sizeof(int));
        switch (((int *)data)[1]) {
        case 0xD3: /* Memory capacity exceeded */
            err = at_send_command_with_pdu("AT+CNMA=2,3", "00D300", &atresponse);
            break;
        case 0xFF: /* Unspecified error */
            err = at_send_command_with_pdu("AT+CNMA=2,3", "00FF00", &atresponse);
            break;
        default:
            LOGE("%s(): Invalid failure cause from Android.\r\n", __func__);
            goto error;
        }

        break;
    case 1: /* Successful receipt */
        err = at_send_command("AT+CNMA=1", &atresponse);
        break;
    default:
        LOGE("%s(): Invalid parameter.\r\n", __func__);
        goto error;
    }

    if (err < 0 || atresponse->success == 0)
        goto error;

    RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
finally:
    at_response_free(atresponse);
    return;

error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
    goto finally;
}
Esempio n. 9
0
/**
 * RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG
 */
void requestGSMSetBroadcastSMSConfig(void *data, size_t datalen,
                                     RIL_Token t)
{
    ATResponse *atresponse = NULL;
    int err, count, i;
    char *cmd, *tmp, *mids = NULL;
    RIL_GSM_BroadcastSmsConfigInfo **configInfoArray =
        (RIL_GSM_BroadcastSmsConfigInfo **) data;
    RIL_GSM_BroadcastSmsConfigInfo *configInfo = NULL;

    count = NUM_ELEMS(configInfoArray);
    LOGI("Number of MID ranges in BROADCAST_SMS_CONFIG: %d", count);

    for (i = 0; i < count; i++) {
        configInfo = configInfoArray[i];
        /* No support for "Not accepted mids" in AT */
        if (configInfo->selected) {
            tmp = mids;
            asprintf(&mids, "%s%d-%d%s", (tmp ? tmp : ""),
                configInfo->fromServiceId, configInfo->toServiceId,
                (i == (count - 1) ? "" : ",")); /* Last one? Skip comma */
            free(tmp);
        }
    }

    if (mids == NULL)
        goto error;

    asprintf(&cmd, "AT+CSCB=0,\"%s\"", mids);
    free(mids);

    err = at_send_command(cmd, &atresponse);
    free(cmd);

    if (err < 0 || atresponse->success == 0)
        goto error;

    RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
    goto exit;

error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);

exit:
    at_response_free(atresponse);
}
Esempio n. 10
0
	/**
	 * RIL_REQUEST_SET_CALL_WAITING
	 *
	 * Configure current call waiting state.
	 ok
	 */
void requestSetCallWaiting(void *data, size_t datalen, RIL_Token t)
{
	ATResponse *p_response;
	int enable = ((int *)data)[0];
	int c = ((int *)data)[1];
	char *cmd;
	asprintf(&cmd, "AT+CCWA=1,%d,1,%d", enable, c);
	int err = at_send_command( cmd,
			&p_response);
	free(cmd);
	if (err < 0 || p_response->success == 0) {
		RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	} else {
		RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
	}
	at_response_free(p_response);    
}
/**
 * RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE
 *
 * Query current network selectin mode.
 */
void requestQueryNetworkSelectionMode(void *data, size_t datalen,
                                      RIL_Token t)
{
    (void) data; (void) datalen;
    int err;
    ATResponse *atresponse = NULL;
    int response = 0;
    char *line;

    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;

    /*
     * Android accepts 0(automatic) and 1(manual).
     * Modem may return mode 4(Manual/automatic).
     * Convert it to 1(Manual) as android expects.
     */
    if (response == 4)
        response = 1;

    RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(int));

finally:
    at_response_free(atresponse);
    return;

error:
    LOGE("%s() Must never return error when radio is on", __func__);
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
    goto finally;
}
Esempio n. 12
0
static int set_phone_book(int index, phone_book_t* pb)
{
	int ret = -1, err;
	char* cmd = NULL;
	char* line = NULL;
    ATResponse *p_response = NULL;
	asprintf(&cmd,"AT+CPBW=%d, \"%s\", %d, \"%s\"", index, pb->number, pb->code, pb->alpha);

	at_send_command("AT+CSCS=\"UCS2\"", NULL);
	err = at_send_command(cmd, &p_response);
	if (err < 0 || !p_response || p_response->success == 0)
		goto error;
	ret = 0;
error:
	at_response_free(p_response);
	free(cmd);
	return ret;	
}
Esempio n. 13
0
int at_send_command_numeric(const char *	command,
			    ATResponse **	pp_outResponse,
			    RILChannelCtx *	p_channel)
{
	int err;
	err = at_send_command_full(command, NUMERIC, NULL, NULL, 0, pp_outResponse, p_channel);

	if (err == 0 && pp_outResponse != NULL && 
        (*pp_outResponse)->success > 0 && 
        (*pp_outResponse)->p_intermediates == NULL) 
    {
		/* successful command must have an intermediate response */
		at_response_free(*pp_outResponse);
		*pp_outResponse = NULL;
		return AT_ERROR_INVALID_RESPONSE;
	}

	return err;
}
Esempio n. 14
0
void requestStkSetEvdlCallByAP (void *data, size_t datalen, RIL_Token t)
{
    char* cmd;
    ATResponse *p_response = NULL;
    int err;
    int enabled = ((int *)data)[0];
    LOGD("requestStkSetEvdlCallByAP:%d.", enabled);

    RIL_STK_UNUSED_PARM(datalen);

    asprintf(&cmd, "AT+EVDLCALL=%d", enabled);

    err = at_send_command(cmd, &p_response, STK_CHANNEL_CTX);
    free(cmd);

    StkSendRequestComplete(err, p_response, t);

    at_response_free(p_response);
}
Esempio n. 15
0
static void requestGetIMEI(void *data, size_t datalen, RIL_Token t)
{
	ATResponse *atresponse = NULL;
	int err;

	err = at_send_command_singleline("AT+CGSN", "+CGSN:",&atresponse);

	if (err < 0 || atresponse->success == 0) {
		RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	} else {
		property_set("ril.imei",atresponse->p_intermediates->line+6);

		RIL_onRequestComplete(t, RIL_E_SUCCESS,
				atresponse->p_intermediates->line+6,
				sizeof(char *));
	}
	at_response_free(atresponse);
	return;
}
Esempio n. 16
0
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;	
}
Esempio n. 17
0
int at_send_command_sms(const char *	command,
                        const char *	pdu,
                        const char *	responsePrefix,
                        ATResponse **	pp_outResponse,
                        RILChannelCtx * p_channel)
{
	int err;
	err = at_send_command_full(command, SINGLELINE, responsePrefix, pdu, 0, pp_outResponse, p_channel);

	if (err == 0 && pp_outResponse != NULL && 
        (*pp_outResponse)->success > 0 && 
        (*pp_outResponse)->p_intermediates == NULL) {
		/* successful command must have an intermediate response */
		at_response_free(*pp_outResponse);
		*pp_outResponse = NULL;
		return AT_ERROR_INVALID_RESPONSE;
	}

	return err;
}
/**
 * RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND
 *
 * Requests to send a SAT/USAT envelope command to SIM.
 * The SAT/USAT envelope command refers to 3GPP TS 11.14 and 3GPP TS 31.111.
 */
void requestStkSendEnvelopeCommand(void *data, size_t datalen, RIL_Token t)
{
    char *cmd;
    char *line;
    char *stkResponse;
    int err;
    ATResponse *atresponse = NULL;
    const char *ec = (const char *) data;

    asprintf(&cmd, "AT*STKE=\"%s\"", ec);
    err = at_send_command_singleline(cmd, "*STKE:", &atresponse);
    free(cmd);

    if (err < 0 || atresponse->success == 0)
        goto error;

    if (atresponse->p_intermediates) {
        line = atresponse->p_intermediates->line;

        err = at_tok_start(&line);
        if (err < 0)
            goto error;

        err = at_tok_nextstr(&line, &stkResponse);
        if (err < 0)
            goto error;

        RIL_onRequestComplete(t, RIL_E_SUCCESS, stkResponse,
                              sizeof(char *));
    } else
        RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);

  finally:
    at_response_free(atresponse);

    return;

  error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
    goto finally;
}
Esempio n. 19
0
static int simIOSelectFile(unsigned short fileid)
{
    int err = 0;
    unsigned short lc = simIOGetLogicalChannel();
    ATResponse *atresponse = NULL;
    char *line;
    char *resp;
    int resplen;

    if (lc == 0)
        return -EIO;

    err = at_send_command_singleline("AT+CGLA=%d,14,\"00A4000C02%.4X\"", "+CGLA:", &atresponse, lc, fileid);
    if (at_get_error_type(err) == AT_ERROR)
        return err;
    if (err != AT_NOERROR)
        return -EINVAL;

    line = atresponse->p_intermediates->line;
    err = at_tok_start(&line);
    if (err < 0)
        goto finally;

    err = at_tok_nextint(&line, &resplen);
    if (err < 0)
        goto finally;

    err = at_tok_nextstr(&line, &resp);
    if (err < 0)
        goto finally;

    /* Std resp code: "9000" */
    if (resplen != 4 || strcmp(resp, "9000") != 0) {
        err = -EIO;
        goto finally;
    }

finally:
    at_response_free(atresponse);
    return err;
}
Esempio n. 20
0
void requestGSMSMSBroadcastActivation(void *data, size_t datalen, RIL_Token t)
{
	ATResponse *atresponse = NULL;
	int err;
	char *cmd;

	err = at_send_command("AT+CNMI=1,2,2,0,0", &atresponse); 

	if (err < 0 || atresponse->success == 0)
		goto error;

	RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);

finally:
	at_response_free(atresponse);
	return;

error:
	RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	goto finally;
}
Esempio n. 21
0
int at_send_command_singleline (const char *command,
                                const char *responsePrefix,
                                 ATResponse **pp_outResponse)
{
    int err;

    err = at_send_command_full (command, SINGLELINE, responsePrefix,
                                    NULL, 5000, pp_outResponse);

    if (err == 0 && pp_outResponse != NULL
        && (*pp_outResponse)->success > 0
        && (*pp_outResponse)->p_intermediates == NULL
    ) {
        /* successful command must have an intermediate response */
        at_response_free(*pp_outResponse);
        *pp_outResponse = NULL;
        return AT_ERROR_INVALID_RESPONSE;
    }

    return err;
}
Esempio n. 22
0
/**
 * RIL_REQUEST_REPORT_SMS_MEMORY_STATUS
 */
void requestSmsStorageFull(void *data, size_t datalen, RIL_Token t)
{
    ATResponse *atresponse = NULL;
    int ack;
    int err;

    assert(datalen >= sizeof(int));
    ack = ((int *) data)[0];

    /* Android will call RIL_REQUEST_REPORT_SMS_MEMORY_STATUS in case of:
    0. memory is full
    1. memory was full and been cleaned up, inform modem memory is available now. */
    switch (ack) {
    case 0:
        /* Android will handle this, no need to inform modem. always return success. */
        LOGI("SMS storage full.\r\n");
        break;
    case 1:
        err = at_send_command("AT*ESMSMEMAVAIL", &atresponse);

        if (err < 0 || atresponse->success == 0) {
            LOGE("%s(): Failed to reset memory status to network, incoming SMS might be blocked.\n ", __func__);
            goto error;
        }
        break;
    default:
        LOGE("%s(): Invalid parameter.\r\n", __func__);
        goto error;
    }

    RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
finally:

    at_response_free(atresponse);

    return;
error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
    goto finally;
}
Esempio n. 23
0
void _requestSetNetworkSelectionManualWCDMA(void *data, size_t datalen,
		RIL_Token t)
{
/* 
 * AT+COPS=[<mode>[,<format>[,<oper>[,<AcT>]]]]
 *    <mode>   = 4 = Manual (<oper> field shall be present and AcT optionally) with fallback to automatic if manual fails.
 *    <format> = 2 = Numeric <oper>, the number has structure:
 *                   (country code digit 3)(country code digit 2)(country code digit 1)
 *                   (network code digit 2)(network code digit 1) 
 */

	int err = 0;
	char *cmd = NULL;
	ATResponse *atresponse = NULL;
	const char *mccMnc = (const char *) data;

	/* Check inparameter. */
	if (mccMnc == NULL) {
		goto error;
	}
	/* Build and send command. */
	asprintf(&cmd, "AT+COPS=4,2,\"%s\"", mccMnc);
	err = at_send_command(cmd, &atresponse);
	if (err < 0 || atresponse->success == 0)
		goto error;

	RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
finally:

	at_response_free(atresponse);

	if (cmd != NULL)
		free(cmd);

	return;

error:
	RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	goto finally;
}
Esempio n. 24
0
/**
 * Fetch information about UICC card type (SIM/USIM)
 *
 * \return UICC_Type: type of UICC card.
 */
static UICC_Type getUICCType(void)
{
    ATResponse *atresponse = NULL;
    static UICC_Type UiccType = UICC_TYPE_UNKNOWN;
    int err;

    if (getRadioState() == RADIO_STATE_OFF ||
        getRadioState() == RADIO_STATE_UNAVAILABLE) {
        return UICC_TYPE_UNKNOWN;
    }

    if (UiccType == UICC_TYPE_UNKNOWN) {
        err = at_send_command_singleline("AT+CUAD", "+CUAD:", &atresponse);
        if (err == AT_NOERROR) {
            /* USIM */
            if(strstr(atresponse->p_intermediates->line, USIM_APPLICATION_ID)){
                UiccType = UICC_TYPE_USIM;
                ALOGI("Detected card type USIM - stored");
            } else {
                /* should maybe be unknown */
                UiccType = UICC_TYPE_SIM;
            }
        } else if (at_get_error_type(err) != AT_ERROR) {
            /* Command failed - unknown card */
            UiccType = UICC_TYPE_UNKNOWN;
            ALOGE("%s() Failed to detect card type - Retry at next request", __func__);
        } else {
            /* Legacy SIM */
            /* TODO: CUAD only responds OK if SIM is inserted.
             *       This is an inccorect AT response...
             */
            UiccType = UICC_TYPE_SIM;
            ALOGI("Detected card type Legacy SIM - stored");
        }
        at_response_free(atresponse);
    }

    return UiccType;
}
/**
 * Send TERMINAL RESPONSE after processing REFRESH proactive command
 */
static void sendRefreshTerminalResponse(void *param)
{
    ATResponse *atresponse = NULL;
    char *cmd = NULL;
    int err;

    asprintf(&cmd, "AT*STKR=\"8103%02x01%02x820282818301%02x\"",
             s_refeshStatus.cmdNumber, s_refeshStatus.cmdQualifier,
             s_refeshStatus.Result);

    err = at_send_command(cmd, &atresponse);
    if (err < 0 || atresponse->success == 0)
        goto error;

finally:
    at_response_free(atresponse);
    return;

error:
    ALOGE("%s failed!", __func__);
    goto finally;
}
Esempio n. 26
0
/**
 * Get the number of retries left for pin functions
 */
static int getNumRetries (int request) {
    ATResponse *atresponse = NULL;
    int err;
    int num_retries = -1;

    err = at_send_command_singleline("AT*EPIN?", "*EPIN:", &atresponse);
    if (err != AT_NOERROR) {
        ALOGE("%s() AT*EPIN error", __func__);
        return -1;
    }

    switch (request) {
    case RIL_REQUEST_ENTER_SIM_PIN:
    case RIL_REQUEST_CHANGE_SIM_PIN:
        sscanf(atresponse->p_intermediates->line, "*EPIN: %d",
               &num_retries);
        break;
    case RIL_REQUEST_ENTER_SIM_PUK:
        sscanf(atresponse->p_intermediates->line, "*EPIN: %*d,%d",
               &num_retries);
        break;
    case RIL_REQUEST_ENTER_SIM_PIN2:
    case RIL_REQUEST_CHANGE_SIM_PIN2:
        sscanf(atresponse->p_intermediates->line, "*EPIN: %*d,%*d,%d",
               &num_retries);
        break;
    case RIL_REQUEST_ENTER_SIM_PUK2:
        sscanf(atresponse->p_intermediates->line, "*EPIN: %*d,%*d,%*d,%d",
               &num_retries);
        break;
    default:
        num_retries = -1;
    break;
    }

    at_response_free(atresponse);
    return num_retries;
}
Esempio n. 27
0
void requestSetSMSCAddress(void *data, size_t datalen, RIL_Token t)
{
	ATResponse *atresponse = NULL;
	int err;
	char *cmd;
	const char *smsc = ((const char *)data);

	asprintf(&cmd, "AT+CSCA=\"%s\"", smsc);
	err = at_send_command(cmd, &atresponse);
	free(cmd);
	if (err < 0 || atresponse->success == 0)
		goto error;

	RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);

finally:
	at_response_free(atresponse);
	return;

error:
	RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	goto finally;
}
/**
 * RIL_REQUEST_STK_GET_PROFILE
 *
 * Requests the profile of SIM tool kit.
 * The profile indicates the SAT/USAT features supported by ME.
 * The SAT/USAT features refer to 3GPP TS 11.14 and 3GPP TS 31.111.
 */
void requestStkGetProfile(void *data, size_t datalen, RIL_Token t)
{
    ATResponse *atresponse = NULL;
    char *line;
    char *response;
    int err = 0;
    int activated = 0;

    err = at_send_command_singleline("AT*STKC?", "*STKC:", &atresponse);
    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, &activated);
    if (err < 0)
        goto error;

    err = at_tok_nextstr(&line, &response);
    if (err < 0)
        goto error;

    RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(char *));

  finally:
    at_response_free(atresponse);

    return;

  error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
    goto finally;
}
Esempio n. 29
0
void requestStkHandleCallSetupRequestedFromSim (void *data, size_t datalen, RIL_Token t)
{
    char* cmd;
    ATResponse *p_response = NULL;
    int err = 0, user_confirm = 0, addtional_info = 0;

    RIL_STK_UNUSED_PARM(datalen);

    if(((int *)data)[0] == 1) {
        user_confirm = 0;
    } else if(((int *)data)[0] == 32) { //ME currently unable to process
        user_confirm = 32;
        addtional_info = 2;
    } else if(((int *)data)[0] == 33) { //NW currently unable to process
        user_confirm = 33;
        addtional_info = 0x9d;
    } else if(((int *)data)[0] == 0) {
        user_confirm = 34;
    } else {
        assert(0);
    }

    if( addtional_info == 0) {
        asprintf(&cmd, "AT+STKCALL=%d", user_confirm);
    } else {
        asprintf(&cmd, "AT+STKCALL=%d, %d", user_confirm, addtional_info);
    }

    err = at_send_command(cmd, &p_response, STK_CHANNEL_CTX);
    free(cmd);

    StkSendRequestComplete(err, p_response, t);

    at_response_free(p_response);

}
Esempio n. 30
0
int at_send_command_multiline (const char *command,
                                const char *responsePrefix,
                                 ATResponse **pp_outResponse, ...)
{
    int err;

    struct atcontext *context = get_at_context();

    ENTER;

    va_list ap;
    va_start(ap, pp_outResponse);

    err = at_send_command_full (command, MULTILINE, responsePrefix,
                                    NULL, context->timeoutMsec, pp_outResponse, 1, ap);
    va_end(ap);

    if (err == AT_NOERROR && pp_outResponse != NULL
            && (*pp_outResponse) != NULL
            && (*pp_outResponse)->p_intermediates == NULL)
        /* Command with pp_outResponse must have an intermediate response */
        err = AT_ERROR_INVALID_RESPONSE;

    /* Free response in case of error */
    if (err != AT_NOERROR && pp_outResponse != NULL
            && (*pp_outResponse) != NULL) {
         at_response_free(*pp_outResponse);
         *pp_outResponse = NULL;
    }

    if (err != AT_NOERROR)
        MBMLOGE("%s --- %s", command, at_str_err(-err));

    EXIT;
    return -err;
}