EraGlonassUveos/Inc/EraGlonassUveos.h

184 lines
5.4 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"
#include "AudioRecorderInterface.h"
//#define AURUS_CAR_UI 1
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 {
uint8_t len;
uint8_t data[1280];
} tEgtsEncodedR;
typedef void (*tSimSelecror_func)(void *env, uint8_t thisSimChip);
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;
tAudioRecorderInterface *audioRecorderIO;
tAudioPlayerInterface *audioPlayerIO;
uint32_t offsetToDistance;
bool fl_ecallState;
tSimSelecror_func simSelecror_func;
void *selecrorEnv;
bool fl_telematicaCipReady;
bool fl_audioHids;
} 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_setTelematicaChipState(tEraGlonassUveos *env, bool eValidCCID);
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_IsStandbyTestTimer(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);
eEraGlonassUveos_EcallProcessingResult EraGlonassUveos_ManualEmergencyCall(tEraGlonassUveos *env);
void EraGlonassUveos_setNewNumber(tEraGlonassUveos *env, uint16_t target, char *number, uint8_t lenghtNum);
bool EraGlonassUveos_updateInternalSoftware(tEraGlonassUveos *env, tDeviceStorage *storage) ;
bool EraGlonassUveos_ProcessEgtsPacket(tEraGlonassUveos *env, tDeviceStorage *storage, uint8_t *binaryData, uint16_t dataSize) ;
eEraGlonassUveos_EcallProcessingResult EraGlonassUveos_TestEmergencyCall(
tEraGlonassUveos *env, tMSD_DiagnosticResult *diagnosticResult
);
eEraGlonassUveos_EcallProcessingResult EraGlonassUveos_ProcessingEmergencyEvent(tEraGlonassUveos *env, tUveosEmergencyEvent *event);
void EraGlonassUveos_DoNotingTestingStarted(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);
void EraGlonassUveos_EgtsMsdReq(tEraGlonassUveos *env);
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);
void EraGlonassUveos_SetTimings(tEraGlonassUveos *env);
#endif //UVEOS_ON_NATION_ERAGLONASSUVEOS_H