114 lines
2.9 KiB
C
114 lines
2.9 KiB
C
//
|
|
// Created by cfif on 19.12.2024.
|
|
//
|
|
#include <SystemDelayInterface.h>
|
|
#include "AtCmdCommonProtected.h"
|
|
#include "AsciiStringParsingUtils.h"
|
|
#include "AtGsmQuerySignalQuality.h"
|
|
#include "stdlib.h"
|
|
|
|
AtCommandResult AtGsm_ReceiverGnssStartStop(
|
|
tAtCmd *env,
|
|
bool isStartStop
|
|
) {
|
|
|
|
AtCmdTxClear(env);
|
|
AtCmdTxAddStatic(env, "AT$GPSP=");
|
|
AtCmdTxAddChar(env, isStartStop ? '1' : '0');
|
|
AtCmdTxSendLn(env);
|
|
|
|
uint32_t timeout = 1000;
|
|
uint32_t endMs = SystemGetMs() + timeout;
|
|
uint32_t leftMs = timeout;
|
|
|
|
while ((AtCmdReceiveNextLine(env, leftMs) == AT_OK) && (SystemGetMs() < endMs)) {
|
|
leftMs = endMs - SystemGetMs();
|
|
|
|
if (AtCmdRxBeginWithStatic(env, "OK")) {
|
|
AtCmdRxClear(env);
|
|
return AT_OK;
|
|
} else if (AtCmdRxBeginWithStatic(env, "ERROR")) {
|
|
AtCmdRxClear(env);
|
|
return AT_ERROR;
|
|
} else if (AtCmdRxBeginWithStatic(env, "+CME ERROR: ")) {
|
|
AtCmdRxClear(env);
|
|
return AT_ERROR;
|
|
} else {
|
|
AtCmdProcessUnresolvedLine(env);
|
|
AtCmdRxClear(env);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
return AT_TIMEOUT;
|
|
}
|
|
|
|
AtCommandResult AtGsm_ReceiverGnssResetColdstart(
|
|
tAtCmd *env
|
|
) {
|
|
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdTxClear(env);
|
|
AtCmdSendStatic(env, "AT$GPSR=1\r\n");
|
|
|
|
uint32_t timeout = 1000;
|
|
uint32_t endMs = SystemGetMs() + timeout;
|
|
uint32_t leftMs = timeout;
|
|
|
|
while ((AtCmdReceiveNextLine(env, leftMs) == AT_OK) && (SystemGetMs() < endMs)) {
|
|
leftMs = endMs - SystemGetMs();
|
|
|
|
if (AtCmdRxBeginWithStatic(env, "OK")) {
|
|
AtCmdRxClear(env);
|
|
return AT_OK;
|
|
} else if (AtCmdRxBeginWithStatic(env, "ERROR")) {
|
|
AtCmdRxClear(env);
|
|
return AT_ERROR;
|
|
} else if (AtCmdRxBeginWithStatic(env, "+CME ERROR: ")) {
|
|
AtCmdRxClear(env);
|
|
return AT_ERROR;
|
|
} else {
|
|
AtCmdProcessUnresolvedLine(env);
|
|
AtCmdRxClear(env);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
return AT_TIMEOUT;
|
|
}
|
|
|
|
AtCommandResult AtGsm_ReceiverGnssClearBuffer(
|
|
tAtCmd *env
|
|
) {
|
|
|
|
AtCmdPrepare(env);
|
|
|
|
AtCmdTxClear(env);
|
|
AtCmdSendStatic(env, "AT$GPSNVRAM=15,0\r\n");
|
|
|
|
uint32_t timeout = 1000;
|
|
uint32_t endMs = SystemGetMs() + timeout;
|
|
uint32_t leftMs = timeout;
|
|
|
|
while ((AtCmdReceiveNextLine(env, leftMs) == AT_OK) && (SystemGetMs() < endMs)) {
|
|
leftMs = endMs - SystemGetMs();
|
|
|
|
if (AtCmdRxBeginWithStatic(env, "OK")) {
|
|
AtCmdRxClear(env);
|
|
return AT_OK;
|
|
} else if (AtCmdRxBeginWithStatic(env, "ERROR")) {
|
|
AtCmdRxClear(env);
|
|
return AT_ERROR;
|
|
} else if (AtCmdRxBeginWithStatic(env, "+CME ERROR: ")) {
|
|
AtCmdRxClear(env);
|
|
return AT_ERROR;
|
|
} else {
|
|
AtCmdProcessUnresolvedLine(env);
|
|
AtCmdRxClear(env);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
return AT_TIMEOUT;
|
|
} |