SMART_COMPONENTS_MainModesA.../MainModesArbiter_EgtsSms.c

77 lines
2.5 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// Created by xemon on 09.01.23.
//
#include "MainModesArbiter_Private.h"
#include <AtGsmSms_Utils.h>
#define LOG_SIGN "Главн. sms"
#define LOGGER &env->slog.logger
void Mma_DeletSms(tMma *env) {
if (osMutexAcquire(env->gsmWithGnss.gsmAt.access, 1000) == osOK) {
AtGsmSms_DeleteAll(&env->gsmWithGnss.gsmAt);
osMutexRelease(env->gsmWithGnss.gsmAt.access);
}
}
AtCommandResult Mma_CheckIncomingSms(tMma *env) {
if (env->lastSmsCheckTime > SystemGetMs()) {
return AT_NONE;
}
env->lastSmsCheckTime = SystemGetMs() + 8000;
uint8_t binaryData[255];
memset(binaryData, 0, sizeof(binaryData));
uint16_t binaryDataSize = 0;
AtCommandResult resultReadPdu = AtGsmSms_UtilsReadPduData(&env->gsmWithGnss.gsmAt, binaryData, &binaryDataSize, sizeof(binaryData));
if (resultReadPdu == AT_OK) {
LoggerInfoStatic(LOGGER, LOG_SIGN, "Получена команда посредствам СМС");
if (binaryDataSize) {
eSubSystems subSystemsTmp = ModemDataCollector_GetThisSubSystem(&env->systemSelector);
SystemSelector(&env->systemSwitcher, UVEOS);
LoggerInfoStatic(LOGGER, LOG_SIGN, "Команда содержит EGTS пакет");
Mma_AudioSubSystemRequire(env);
Mma_NetworkRequire(env);
bool res = EraGlonassUveos_ProcessEgtsPacket(&env->uveos, &env->storage, binaryData, binaryDataSize);
if(
(env->indication.mode == DEVICE_MODE_UVEOS_ERA_WAIT_GNSS) ||
(env->indication.mode == DEVICE_MODE_UVEOS_ERA_GNSS_READY)
){
Mma_AudioSubSystemRelease(env);
}
if(res == true) {
StopResiver(&env->gsmWithGnss);
HotStartGNSS(&env->gsmWithGnss);
}
SystemSelector(&env->systemSwitcher, subSystemsTmp);
} else {
LoggerInfoStatic(LOGGER, LOG_SIGN, "Команда не содержит EGTS пакета");
}
uint32_t t = SystemGetMs() + 2000;
while (t > SystemGetMs()){
if (osMutexAcquire(env->gsmWithGnss.gsmAt.access, 100) == osOK) {
if(AtGsmSms_DeleteAll(&env->gsmWithGnss.gsmAt) == AT_OK){
osMutexRelease(env->gsmWithGnss.gsmAt.access);
return AT_OK;
}
osMutexRelease(env->gsmWithGnss.gsmAt.access);
}
SystemDelayMs(40);
}
return AT_TIMEOUT;
} else {
return resultReadPdu;
}
return resultReadPdu;
}