Изменения на новый
This commit is contained in:
parent
ef32a09622
commit
5b475930d9
|
|
@ -5,6 +5,7 @@
|
|||
#ifndef MODEMMAIN_H
|
||||
#define MODEMMAIN_H
|
||||
|
||||
#include <CmsisRtosThreadUtils.h>
|
||||
#include <SerialPortIO.h>
|
||||
#include <DeviceStorageIni.h>
|
||||
#include <Gnss.h>
|
||||
|
|
@ -287,8 +288,8 @@ typedef struct {
|
|||
md5a_context md5ctx_r;
|
||||
|
||||
int32_t msgId;
|
||||
char gsmIMEI[16];
|
||||
char gsmSimId[16];
|
||||
char gsmIMEI[32];
|
||||
char gsmSimId[32];
|
||||
|
||||
tGonetsAlmanac alms[50];
|
||||
int countAlmanac;
|
||||
|
|
@ -296,7 +297,11 @@ typedef struct {
|
|||
bool isModemCheck;
|
||||
uint32_t isEnableTracerTimeStamp;
|
||||
|
||||
struct {
|
||||
bool pbDone;
|
||||
} urc;
|
||||
|
||||
tStaticThreadBlock(512) urcT;
|
||||
} tModemMain;
|
||||
|
||||
typedef struct __attribute__ ((packed)) {
|
||||
|
|
|
|||
|
|
@ -77,6 +77,33 @@ void ModemMain_Urc(tModemMain *env, tAtBuffer *buff) {
|
|||
// LoggerInfoRaw(LOGGER, LOG_SIGN, buff->data, buff->len);
|
||||
}
|
||||
|
||||
void ModemMainGsm_Urc(tModemMain *env, tAtBuffer *buff) {
|
||||
|
||||
if (AtBufferBeginWithStatic(buff, "PB DONE")) {
|
||||
env->urc.pbDone = true;
|
||||
// LoggerInfoStatic(LOGGER, LOG_SIGN, "Получена URC, MSD доставлен.")
|
||||
}
|
||||
}
|
||||
|
||||
_Noreturn void GsmWithGnss_urcThread_body(tModemMain *env) {
|
||||
for (;;) {
|
||||
if (osMutexAcquire(env->modemAtGsm.access, 5000) == osOK) {
|
||||
// LoggerInfoStatic(LOGGER, LOG_SIGN, "--URC processor мьютэкс RMC захвачен")
|
||||
//AtCmdProcessUnresolvedLines(&env->gsmAt);
|
||||
while (AtCmdReceiveNextLine(&env->modemAtGsm, 150) == AT_OK) {
|
||||
AtCmdProcessUnresolvedLine(&env->modemAtGsm);
|
||||
}
|
||||
|
||||
osMutexRelease(env->modemAtGsm.access);
|
||||
// LoggerInfoStatic(LOGGER, LOG_SIGN, "--URC processor мьютэкс RMC освобождён")
|
||||
} else {
|
||||
asm("nop");
|
||||
// LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка доступа (GsmWithGnss_urcThread_body)")
|
||||
}
|
||||
SystemDelayMs(40);
|
||||
}
|
||||
}
|
||||
|
||||
void ModemMain_Init(
|
||||
tModemMain *env,
|
||||
tGpios *gpios,
|
||||
|
|
@ -232,6 +259,11 @@ void ModemMain_Init(
|
|||
6000, 6000
|
||||
);
|
||||
|
||||
AtCmdSetUrcProcessor(&env->modemAtGsm, env, ModemMainGsm_Urc);
|
||||
|
||||
InitThreadBlock(env->urcT, "gsm_urc", osPriorityNormal);
|
||||
ThreadBlock_Start(env->urcT, env, GsmWithGnss_urcThread_body);
|
||||
|
||||
env->location.region = env->store->nvm.Settings_Frequency_Speed.RegionRegistr_v;
|
||||
|
||||
env->stateRequest.stateReqReg = StateReqRegNoSendStatus;
|
||||
|
|
@ -852,6 +884,20 @@ bool sendI2c() {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
AtCommandResult AtCmdWaitPbDone(tModemMain *env, uint32_t retryInterval, uint32_t timeout) {
|
||||
uint32_t endMs = SystemGetMs() + timeout;
|
||||
while (endMs > SystemGetMs()) {
|
||||
if (env->urc.pbDone) {
|
||||
return AT_OK;
|
||||
} else {
|
||||
SystemDelayMs(retryInterval);
|
||||
}
|
||||
}
|
||||
return AT_TIMEOUT;
|
||||
}
|
||||
|
||||
|
||||
static _Noreturn void ModemMain_Thread(tModemMain *env) {
|
||||
bool result;
|
||||
|
||||
|
|
@ -993,9 +1039,13 @@ static _Noreturn void ModemMain_Thread(tModemMain *env) {
|
|||
|
||||
|
||||
bool isGsmStart = false;
|
||||
if (AtCmdWaitOk(&env->modemAtGsm, 100, 10000) == AT_OK) {
|
||||
|
||||
if (AtCmdWaitPbDone(env, 100, 20000) == AT_OK) {
|
||||
isGsmStart = true;
|
||||
}
|
||||
// if (AtCmdWaitOk(&env->modemAtGsm, 100, 10000) == AT_OK) {
|
||||
// isGsmStart = true;
|
||||
// }
|
||||
|
||||
memset(env->gsmIMEI, 0, sizeof(env->gsmIMEI));
|
||||
memset(env->gsmSimId, 0, sizeof(env->gsmSimId));
|
||||
|
|
|
|||
Loading…
Reference in New Issue