static void processLine(const char *line)
{
    pthread_mutex_lock(&s_commandmutex);

    if (sp_response == NULL) {
        /* no command pending */
        handleUnsolicited(line);
    } else if (isFinalResponseSuccess(line)) {
        sp_response->success = 1;
        handleFinalResponse(line);
    } else if (isFinalResponseError(line)) {
        sp_response->success = 0;
        handleFinalResponse(line);
    } else if (s_smsPDU != NULL && 0 == strcmp(line, "> ")) {
        // See eg. TS 27.005 4.3
        // Commands like AT+CMGS have a "> " prompt
        writeCtrlZ(s_smsPDU);
        s_smsPDU = NULL;
    } else switch (s_type) {
        case NO_RESULT:
            handleUnsolicited(line);
            break;
        case NUMERIC:
            if (sp_response->p_intermediates == NULL
                && isdigit(line[0])
            ) {
                addIntermediate(line);
            } else {
                /* either we already have an intermediate response or
                   the line doesn't begin with a digit */
                handleUnsolicited(line);
            }
            break;
        case SINGLELINE:
            if (sp_response->p_intermediates == NULL
                && strStartsWith (line, s_responsePrefix)
            ) {
                addIntermediate(line);
            } else {
                /* we already have an intermediate response */
                handleUnsolicited(line);
            }
            break;
        case MULTILINE:
            if (strStartsWith (line, s_responsePrefix)) {
                addIntermediate(line);
            } else {
                handleUnsolicited(line);
            }
        break;

        default: /* this should never be reached */
            RLOGE("Unsupported AT command type %d\n", s_type);
            handleUnsolicited(line);
        break;
    }

    pthread_mutex_unlock(&s_commandmutex);
}
Beispiel #2
0
static void processLine(const char *line)
{
    struct atcontext *ac = getAtContext();
    pthread_mutex_lock(&ac->commandmutex);

    if (ac->response == NULL) {
        /* No command pending. */
        handleUnsolicited(line);
    } else if (isFinalResponseSuccess(line)) {
        ac->response->success = 1;
        handleFinalResponse(line);
    } else if (isFinalResponseError(line)) {
        ac->response->success = 0;
        handleFinalResponse(line);
    } else if (ac->smsPDU != NULL && 0 == strcmp(line, "> ")) {
        /* See eg. TS 27.005 4.3.
           Commands like AT+CMGS have a "> " prompt. */
        writeCtrlZ(ac->smsPDU);
        ac->smsPDU = NULL;
    } else switch (ac->type) {
        case NO_RESULT:
            handleUnsolicited(line);
            break;
        case NUMERIC:
            if (ac->response->p_intermediates == NULL
                && isdigit(line[0])) {
                addIntermediate(line);
            } else {
                /* Either we already have an intermediate response or
                   the line doesn't begin with a digit. */
                handleUnsolicited(line);
            }
            break;
        case SINGLELINE:
            if (ac->response->p_intermediates == NULL
                && strStartsWith (line, ac->responsePrefix)) {
                addIntermediate(line);
            } else {
                /* We already have an intermediate response. */
                handleUnsolicited(line);
            }
            break;
        case MULTILINE:
            if (strStartsWith (line, ac->responsePrefix)) {
                addIntermediate(line);
            } else {
                handleUnsolicited(line);
            }
        break;

        default: /* This should never be reached */
            ALOGE("%s() Unsupported AT command type %d", __func__, ac->type);
            handleUnsolicited(line);
        break;
    }

    pthread_mutex_unlock(&ac->commandmutex);
}
Beispiel #3
0
static void processLine(const char *line, RILChannelCtx *p_channel)
{
	ATResponse *p_response = p_channel->p_response;
	const char *smsPDU = p_channel->smsPDU;
	//Move out to the function
	//pthread_mutex_lock(&p_channel->commandmutex);
	int isIntermediateResult = 0;

	if (p_response == NULL) {
		/* no command pending */
		handleUnsolicited(line, p_channel);
		return;
	} else {
		switch (p_channel->type) {
		case NO_RESULT:
			//handleUnsolicited(line,p_channel);
			break;
		case NUMERIC:
			if (p_response->p_intermediates == NULL
			    && isdigit(line[0])
			    ) {
				addIntermediate(line, p_channel);
				isIntermediateResult = 1;
			} else {
				/* either we already have an intermediate response or
				 *     the line doesn't begin with a digit */
				//handleUnsolicited(line,p_channel);
			}
			break;
		case SINGLELINE:
			if (p_response->p_intermediates == NULL
			    && strStartsWith(line, p_channel->responsePrefix)
			    ) {
				addIntermediate(line, p_channel);
				isIntermediateResult = 1;
			} else {
				/* we already have an intermediate response */
				//handleUnsolicited(line,p_channel);
			}
			break;
		case MULTILINE:
			if (strStartsWith(line, p_channel->responsePrefix)) {
				addIntermediate(line, p_channel);
				isIntermediateResult = 1;
			} else {
				//handleUnsolicited(line,p_channel);
			}
			break;
		/* atci start */
		case RAW:
			if (!isFinalResponseSuccess(line) && !isFinalResponseErrorEx(line, p_channel) && !isIntermediatePattern(line) ) {
				addIntermediate(line, p_channel);
				isIntermediateResult = 1;
			}
			break;
		/* atci end */
		default: /* this should never be reached */
			RLOGE("Unsupported AT command type %d\n", p_channel->type);
			//handleUnsolicited(line,p_channel);
			break;
		}
	}

	if (isIntermediateResult) {
		/* No need to run the following code*/
	} else if (isFinalResponseSuccess(line)) {
		p_response->success = 1;
		handleFinalResponse(line, p_channel);
	} else if (isFinalResponseErrorEx(line, p_channel)) {
		p_response->success = 0;
		handleFinalResponse(line, p_channel);
	} else if (smsPDU != NULL && 0 == strcmp(line, "> ")) {
		// See eg. TS 27.005 4.3
		// Commands like AT+CMGS have a "> " prompt
		writeCtrlZ(smsPDU, p_channel);
		smsPDU = NULL;
	} else if (isIntermediatePattern(line)) {
		p_response->success = 1;
		handleFinalResponse(line, p_channel);
	} else {
		handleUnsolicited(line, p_channel);
	}
	// Move out to the function
	//pthread_mutex_unlock(&p_channel->commandmutex);
}