EraGlonassUveos/Inc/EraGlonassUveos.h

169 lines
4.8 KiB
C

//
// Created by xemon on 21.10.22.
//
#ifndef UVEOS_ON_NATION_ERAGLONASSUVEOS_H
#define UVEOS_ON_NATION_ERAGLONASSUVEOS_H
#include "UveosGostSettings.h"
#include "EraGlonassMsdTable.h"
#include "LoggerInterface.h"
#include "UveosEmergencyEventInterface.h"
#include "UserButtonsInterface.h"
#include "EraGlonassUveos_NavDataProvider.h"
#include "EraGlonassUveos_EcallProvider.h"
#include "EraGlonassUveos_SmsProvider.h"
#include "EraGlonassUveos_Dumper.h"
#include "EraGlonassUveos_Indicatior.h"
#include "AudioPlayerInterface.h"
#include "DeviceStorage.h"
#include "RtcIO.h"
typedef enum {
UVEOS_DO_NOTHING_DISABLED,
UVEOS_DO_NOTHING_GARAGE,
UVEOS_DO_NOTHING_TESTING,
UVEOS_DO_NOTHING_MOVE_TO,
} eUveosDoNothing;
typedef enum {
ERA_GLONASS_UVEOS_CALL_SUCCESS,
ERA_GLONASS_UVEOS_CALL_FAIL,
ERA_GLONASS_UVEOS_CALL_USER_BREAK,
ERA_GLONASS_UVEOS_SMS_SENT,
ERA_GLONASS_UVEOS_SEND_FAIL,
ERA_GLONASS_UVEOS_TEST_CALL_NOT_ALLOWED,
} eEraGlonassUveos_EcallProcessingResult;
typedef struct {
uint8_t len;
uint8_t data[ERA_GLONASS_MSD_ENCODED_BUFFER_LENGTH];
} tMsdEncoded;
typedef struct {
uint8_t len;
uint8_t data[128];
} tEgtsEncoded;
typedef struct {
tLoggerInterface *logger;
tUveosGostSettings *settings;
tNavDataProvider *navDataProvider;
tEraGlonassMsdTable *msdTable;
tEraGlonassMsdTableItem *currentMsd;
tEraGlonassUveosDumperInterface *dumper;
tEraGlonassEcallProvider *ecallProvider;
tUserButtonsInterface *buttons;
tEraGlonassSmsProvider *smsProvider;
tEraGlonassUveosIndicator *indicator;
struct {
uint16_t emergensy;
uint16_t additional;
} buttonsIds;
struct {
uint64_t allowInCall;
uint64_t requireNetwork;
uint64_t lastTestCall;
uint64_t lastInMemTransmit;
uint64_t lastNetworkRequest;
uint64_t powerOfDelay;
tRtcIO *rtcIo
} timings;
struct {
uint32_t movDist;
uint64_t stopLimitTime;
eUveosDoNothing mode;
EraGlonassUveosNavData beginPosition;
EraGlonassUveosNavData movePosition;
} doNothing;
tAudioPlayerInterface *audioPlayer;
uint32_t offsetToDistance;
} tEraGlonassUveos;
void EraGlonassUveos_Init(
tEraGlonassUveos *env,
tLoggerInterface *logger,
tEraGlonassMsdTable *msdTable,
tUveosGostSettings *settings,
tEraGlonassUveosDumperInterface *dumper,
tNavDataProvider *navDataProvider,
tEraGlonassEcallProvider *ecallProvider,
tEraGlonassSmsProvider *smsProvider,
tEraGlonassUveosIndicator *indicator,
tUserButtonsInterface *buttons,
uint16_t addButtonId,
tAudioPlayerInterface *audioPlayer,
tRtcIO *Rtc,
uint32_t stopLimitTime
);
void EraGlonassUveos_CompileMsd(tEraGlonassUveos *env, tEraGlonassMsd *msd, tMsdEncoded *msdEncoded);
void EraGlonassUveos_InvalidateSettings(tEraGlonassUveos *env);
bool EraGlonassUveos_IsAllowInCall(tEraGlonassUveos *env);
bool EraGlonassUveos_IsStandby(tEraGlonassUveos *env);
bool EraGlonassUveos_IsPowerOffDelay(tEraGlonassUveos *env);
bool EraGlonassUveos_IsRequireNetwork(tEraGlonassUveos *env);
bool EraGlonassUveos_IsEraAllowed(tEraGlonassUveos *env);
void EraGlonassUveos_ProcessingEra(tEraGlonassUveos *env);
void EraGlonassUveos_ProcessingCheckNoSendMSD(tEraGlonassUveos *env);
void EraGlonassUveos_ManualEmergencyCall(tEraGlonassUveos *env, bool fl_blocRegNet);
void EraGlonassUveos_SetTimings(tEraGlonassUveos *env);
void EraGlonassUveos_setNewNumber(tEraGlonassUveos *env, uint16_t target, char *number, uint8_t lenghtNum);
bool EraGlonassUveos_ProcessEgtsPacket(tEraGlonassUveos *env, uint8_t *data, uint16_t dataSize);
eEraGlonassUveos_EcallProcessingResult EraGlonassUveos_TestEmergencyCall(
tEraGlonassUveos *env, tMSD_DiagnosticResult *diagnosticResult,
bool blocReg
);
eEraGlonassUveos_EcallProcessingResult EraGlonassUveos_ProcessingEmergencyEvent(tEraGlonassUveos *env, tUveosEmergencyEvent *event);
void EraGlonassUveos_TestingStarted(tEraGlonassUveos *env);
void EraGlonassUveos_GarageStarted(tEraGlonassUveos *env);
void EraGlonassUveos_DoNothingModeDistance(tEraGlonassUveos *env, bool sourseNaData) ;
void EraGlonassUveos_DoNotingReset(tEraGlonassUveos *env);
void EraGlonassUveos_DoNotingSetStartPos(tEraGlonassUveos *env);
uint16_t EraGlonassUveos_GetNoSendMSDCount(tEraGlonassUveos *env);
static void EraGlonassUveos_EgtsMsdReq(tEraGlonassUveos *env);
static void EraGlonassUveos_UpdateMsd(tEraGlonassUveos *env, eEcallTimeSourse timeSourse);
void setMsdToPull(tEraGlonassUveos *env, const bool *mndSendFlag, bool *wasNewSetMsd, bool *wasResent, tMsdEncoded *msdEncoded);
void reSetMsdToPull(tEraGlonassUveos *env, const bool *wasNewSetMsd, const bool *wasResent, tMsdEncoded *msdEncoded);
#endif //UVEOS_ON_NATION_ERAGLONASSUVEOS_H