예제 #1
0
void requestWriteSmsToSim(void *data, size_t datalen, RIL_Token t)
{
	RIL_SMS_WriteArgs *p_args;
	char *cmd;
	int length;
	int err;
	ATResponse *p_response = NULL;

	p_args = (RIL_SMS_WriteArgs *)data;

	length = strlen(p_args->pdu)/2;
	asprintf(&cmd, "AT+CMGW=%d,%d", length, p_args->status);

	err = at_send_command_sms(cmd, p_args->pdu, "+CMGW:", &p_response);

	if (err != 0 || p_response->success == 0) goto error;

	RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
	at_response_free(p_response);

	return;
error:
	RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	at_response_free(p_response);
}
예제 #2
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;
}
예제 #3
0
static void requestSendSMS(void *data, size_t datalen, RIL_Token t)
{
	int err;
	const char *smsc;
	const char *pdu;
	int tpLayerLength;
	char *cmd1, *cmd2;
	RIL_SMS_Response response;
	ATResponse *p_response = NULL;

	smsc = ((const char **)data)[0];
	pdu = ((const char **)data)[1];

	tpLayerLength = strlen(pdu)/2;

	// "NULL for default SMSC"
	if (smsc == NULL) {
		smsc= "00";
	}

	asprintf(&cmd1, "AT+CMGS=%d", tpLayerLength);
	asprintf(&cmd2, "%s%s", smsc, pdu);

	err = at_send_command_sms(cmd1, cmd2, "+CMGS:", &p_response);

	if (err != 0 || p_response->success == 0) goto error;

	memset(&response, 0, sizeof(response));

	/* FIXME fill in messageRef and ackPDU */

	RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(response));
	at_response_free(p_response);

	return;
error:
	RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	at_response_free(p_response);
}
예제 #4
0
/**
 * RIL_REQUEST_SEND_SMS
 *
 * Sends an SMS message.
 */
void requestSendSMS(void *data, size_t datalen, RIL_Token t)
{
    int err;
    const char *smsc;
    const char *pdu;
    char *line;
    int tpLayerLength;
    char *cmd1, *cmd2;
    RIL_SMS_Response response;
    RIL_Errno ret = RIL_E_GENERIC_FAILURE;
    ATResponse *atresponse = NULL;
    ATCmsError cms_error_code;

    smsc = ((const char **) data)[0];
    pdu = ((const char **) data)[1];

    tpLayerLength = strlen(pdu) / 2;

    /* NULL for default SMSC. */
    if (smsc == NULL)
        smsc = "00";

    asprintf(&cmd1, "AT+CMGS=%d", tpLayerLength);
    asprintf(&cmd2, "%s%s", smsc, pdu);

    err = at_send_command_sms(cmd1, cmd2, "+CMGS:", &atresponse);
    free(cmd1);
    free(cmd2);

    if (err != 0) {
        goto error;
    }
    if (atresponse->success == 0) {
        if (at_get_cms_error(atresponse, &cms_error_code)) {
            switch (cms_error_code) {
            case CMS_NETWORK_TIMEOUT:
                ret = RIL_E_SMS_SEND_FAIL_RETRY;
                break;
            case CMS_PRE_DIAL_CHECK_ERROR:
                /* failing pre-dial check may indicate FDN check failure */
                if (isFdnEnabled())
                   ret = RIL_E_FDN_CHECK_FAILURE;
                break;
            default:
                break;
            }
        }
        goto error;
    }

    memset(&response, 0, sizeof(response));
    response.errorCode = -1;

    line = atresponse->p_intermediates->line;

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

    err = at_tok_nextint(&line, &response.messageRef);
    if (err < 0)
        goto error;

    /* ackPDU is not supported */

    RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(response));
finally:
    at_response_free(atresponse);
    return;

error:
    RIL_onRequestComplete(t, ret, NULL, 0);
    goto finally;
}