Beispiel #1
0
/**
 * 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;
}
Beispiel #2
0
void requestGSMGetBroadcastSMSConfig(void *data, size_t datalen, RIL_Token t)
{
	ATResponse *atresponse = NULL;
	int err;
	char *cmd;
	char* line;
	RIL_GSM_BroadcastSmsConfigInfo* configInfo;

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

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

	configInfo = malloc(sizeof(RIL_GSM_BroadcastSmsConfigInfo));
	memset(&configInfo, 0, sizeof(RIL_GSM_BroadcastSmsConfigInfo));

	line = atresponse->p_intermediates->line;

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

	/* Get the string that yields the service ids.
	   We expect the form: "fromServiceId-toServiceId". */    
	err = at_tok_nextstr(&line, &line);
	if (err < 0)
		goto error;

	line = strsep(&line, "\"");
	if (line == NULL)
		goto error;

	err = at_tok_nextint(&line, &configInfo->fromServiceId);
	if (err < 0)
		goto error;

	line = strsep(&line, "-");
	if (line == NULL)
		goto error;

	err = at_tok_nextint(&line, &configInfo->toServiceId);
	if (err < 0)
		goto error;

	/* Get the string that yields the coding schemes.   
	   We expect the form: "fromCodeScheme-toCodeScheme". */    
	err = at_tok_nextstr(&line, &line);
	if (err < 0)
		goto error;

	line = strsep(&line, "\"");

	if (line == NULL)
		goto error;

	err = at_tok_nextint(&line, &configInfo->fromCodeScheme);
	if (err < 0)
		goto error;

	line = strsep(&line, "-");
	if (line == NULL)
		goto error;

	err = at_tok_nextint(&line, &configInfo->toCodeScheme);
	if (err < 0)
		goto error;

	err = at_tok_nextbool(&line, (char*)&configInfo->selected);
	if (err < 0)
		goto error;

	RIL_onRequestComplete(t, RIL_E_SUCCESS, &configInfo, sizeof(RIL_GSM_BroadcastSmsConfigInfo));

finally:
	free(configInfo);
	at_response_free(atresponse);
	return;

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