77 lines
2.3 KiB
C
Executable File
77 lines
2.3 KiB
C
Executable File
//
|
|
// Created by xemon on 09.09.22.
|
|
//
|
|
#include <SystemDelayInterface.h>
|
|
#include "AtGsmListCurrentCalls.h"
|
|
#include "AtCmdCommonProtected.h"
|
|
#include "AsciiStringParsingUtils.h"
|
|
|
|
AtCommandResult AtGsmListOfCurrentCalls(tAtCmd *env, tGsmCurrentCallsTable *currentCallsTable) {
|
|
|
|
currentCallsTable->count = 0;
|
|
|
|
AtCmdPrepare(env);
|
|
AtCmdSendStatic(env, "AT+CLCC\r\n");
|
|
|
|
|
|
uint32_t timeout = 5000;
|
|
uint32_t endMs = SystemGetMs() + timeout;
|
|
uint32_t leftMs = timeout;
|
|
|
|
while (AtCmdReceiveNextLine(env, leftMs) == AT_OK) {
|
|
leftMs = endMs - SystemGetMs();
|
|
|
|
if (AtCmdRxBeginWithStatic(env, "AT+CLCC")) {
|
|
AtCmdRxClear(env);
|
|
continue;
|
|
|
|
} else if (AtCmdRxBeginWithStatic(env, "OK")) {
|
|
|
|
return AT_OK;
|
|
|
|
} else if (AtCmdRxBeginWithStatic(env, "ERROR")) {
|
|
|
|
return AT_ERROR;
|
|
|
|
} else if (AtCmdRxBeginWithStatic(env, "+CLCC:")) {
|
|
|
|
tGsmCurrentCall *next_call = ¤tCallsTable->calls[currentCallsTable->count];
|
|
|
|
char *front;
|
|
char *div = env->rxBuffer.data + sizeof("+CLCC:");
|
|
char *end = div + env->rxBuffer.len;
|
|
|
|
if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) {
|
|
next_call->idx = iAsciiStringParseUnsignedLongDecimalNumber(front, div);
|
|
}
|
|
|
|
if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) {
|
|
next_call->direction = iAsciiStringParseUnsignedLongDecimalNumber(front, div);
|
|
}
|
|
|
|
if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) {
|
|
next_call->state = iAsciiStringParseUnsignedLongDecimalNumber(front, div);
|
|
}
|
|
|
|
if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) {
|
|
next_call->mode = iAsciiStringParseUnsignedLongDecimalNumber(front, div);
|
|
}
|
|
|
|
if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) {
|
|
next_call->multiparty = iAsciiStringParseUnsignedLongDecimalNumber(front, div);
|
|
}
|
|
|
|
|
|
++currentCallsTable->count;
|
|
|
|
AtCmdRxClear(env);
|
|
} else {
|
|
AtCmdProcessUnresolvedLine(env);
|
|
AtCmdRxClear(env);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
return AT_ERROR;
|
|
}
|