Fix
This commit is contained in:
parent
e36b7928cd
commit
263b152442
|
|
@ -0,0 +1,15 @@
|
|||
//
|
||||
// Created by cfif on 07.06.2024.
|
||||
//
|
||||
|
||||
#ifndef SMART_COMPONENTS_ATGSMQUERYSIGNALQUALITY_H
|
||||
#define SMART_COMPONENTS_ATGSMQUERYSIGNALQUALITY_H
|
||||
|
||||
#include "AtCmdBase.h"
|
||||
|
||||
AtCommandResult AtGsm_QuerySignalQuality(
|
||||
tAtCmd *env,
|
||||
uint8_t *rssi
|
||||
);
|
||||
|
||||
#endif //SMART_COMPONENTS_ATGSMQUERYSIGNALQUALITY_H
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
//
|
||||
// Created by cfif on 07.06.2024.
|
||||
//
|
||||
#include <SystemDelayInterface.h>
|
||||
#include "AtCmdCommonProtected.h"
|
||||
#include "AsciiStringParsingUtils.h"
|
||||
#include "AtGsmQuerySignalQuality.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
AtCommandResult AtGsm_QuerySignalQuality(
|
||||
tAtCmd *env,
|
||||
uint8_t *rssi
|
||||
) {
|
||||
|
||||
AtCmdPrepare(env);
|
||||
AtCmdRxClear(env);
|
||||
AtCmdSendStatic(env, "AT+CSQ\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, "AT+CSQ")) {
|
||||
AtCmdRxClear(env);
|
||||
continue;
|
||||
|
||||
} else if (AtCmdRxBeginWithStatic(env, "ERROR")) {
|
||||
AtCmdRxClear(env);
|
||||
return AT_ERROR;
|
||||
|
||||
} else if (AtCmdRxBeginWithStatic(env, "+CSQ: ")) {
|
||||
|
||||
char *front;
|
||||
char *div = env->rxBuffer.data + sizeof("+CSQ:") - 1;
|
||||
char *end = div + env->rxBuffer.len;
|
||||
|
||||
uint8_t Ber = 0;
|
||||
uint8_t Rssi = 0;
|
||||
if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) {
|
||||
Rssi = atoi(front);
|
||||
*(uint8_t *) rssi = Rssi;
|
||||
}
|
||||
|
||||
if (iAsciiStringMoveToNextParsingBlock(&front, &div, end, ',')) {
|
||||
Ber = atoi(front);
|
||||
}
|
||||
|
||||
AtCmdRxClear(env);
|
||||
return AT_OK;
|
||||
} else {
|
||||
AtCmdProcessUnresolvedLine(env);
|
||||
AtCmdRxClear(env);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return AT_ERROR;
|
||||
}
|
||||
Loading…
Reference in New Issue