373 lines
14 KiB
C
373 lines
14 KiB
C
//
|
|
// Created by xemon on 18.11.22.
|
|
//
|
|
|
|
|
|
#include "DeviceTesting_TestingMethods.h"
|
|
#include "SystemDelayInterface.h"
|
|
#include "string.h"
|
|
#include "ext_telematica.h"
|
|
#include "AtGsmSimComA7600_SSL_LOAD_CA.h"
|
|
|
|
eDeviceTestingCode DeviceTesting_AntTest(tAntTest *antTest) {
|
|
if (*antTest->mode == false) {
|
|
static uint8_t tries = 10;
|
|
|
|
uint64_t antVoltage = 0;
|
|
for (uint8_t try = 0; try < tries; try++) {
|
|
uint16_t single = AdcGet(antTest->externalAdc, 1000);
|
|
antVoltage += single;
|
|
}
|
|
antVoltage /= tries;
|
|
|
|
if (antVoltage < 50) {
|
|
return DEVICE_TESTING_CODE_NOT_CONNECTED;
|
|
}
|
|
|
|
if ((antVoltage > 4080) && (antVoltage < 4090)) {
|
|
return DEVICE_TESTING_CODE_CONNECTED;
|
|
}
|
|
|
|
if ((antVoltage > 4000) && (antVoltage < 4075)) {
|
|
return DEVICE_TESTING_CODE_SHORT_CIRCUIT;
|
|
}
|
|
|
|
return DEVICE_TESTING_CODE_CONNECTED;
|
|
} else {
|
|
return DEVICE_TESTING_CODE_INPUT_ANTENA_OK;
|
|
}
|
|
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_ModemCertValidation(tModemVersionRevisionTest *env) {
|
|
if((*env->telematicaIsActive == true) || ( (*env->testTelematicaIsActive == true)||(*env->fl_telematicaServerIsActive == true)) ) {
|
|
if (env->modemDataCollector->fl_IsLoad == true) {
|
|
if (env->modemDataCollector->modemVersionRevision.sertRevision.validSert == MOD_READY) {
|
|
return DEVICE_TESTING_CODE_PASSED;
|
|
}
|
|
if (env->modemDataCollector->modemVersionRevision.sertRevision.validSert == MOD_UNDEFANDED) {
|
|
return DEVICE_TESTING_CODE_IN_PROCESS;
|
|
}
|
|
if (env->modemDataCollector->modemVersionRevision.sertRevision.validSert == MOD_ERROR) {
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
}
|
|
}
|
|
return DEVICE_TESTING_CODE_IN_PROCESS;
|
|
} else {
|
|
return DEVICE_TESTING_CODE_NOT_ACTIVE;
|
|
}
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_ModemAudioFileValidation(tModemVersionRevisionTest *env) {
|
|
if (env->modemDataCollector->fl_IsLoad == true) {
|
|
if (env->modemDataCollector->modemVersionRevision.validAudio == MOD_READY) {
|
|
return DEVICE_TESTING_CODE_PASSED;
|
|
}
|
|
if (env->modemDataCollector->modemVersionRevision.validAudio == MOD_UNDEFANDED) {
|
|
return DEVICE_TESTING_CODE_IN_PROCESS;
|
|
}
|
|
if (env->modemDataCollector->modemVersionRevision.validAudio == MOD_ERROR) {
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
}
|
|
}
|
|
return DEVICE_TESTING_CODE_IN_PROCESS;
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_ModemSoftwareValidation(tModemVersionRevisionTest *env) {
|
|
// if((*env->telematicaIsActive == true) || ( (*env->testTelematicaIsActive == true)||(*env->fl_telematicaServerIsActive == true)) ) {
|
|
if (env->modemDataCollector->fl_IsLoad == true) {
|
|
tVariableDescriptor *var = VariablesTable_GetByNameStatic(&env->deviceStorage->publicVariablesTable,
|
|
"GSM_CGMR");
|
|
if (var->len) {
|
|
tStringLink cgmrOldValue = {
|
|
.length = var->len,
|
|
.data = var->addr
|
|
};
|
|
tStringLink cgmr = {
|
|
.length = &env->modemDataCollector->modemVersionRevision.softValue.length,
|
|
.data = env->modemDataCollector->modemVersionRevision.softValue.data
|
|
};
|
|
if (
|
|
(memcmp(cgmr.data, cgmrOldValue.data, *cgmrOldValue.length) == 0) &&
|
|
(*cgmr.length == *cgmrOldValue.length)
|
|
) {
|
|
return DEVICE_TESTING_CODE_PASSED;
|
|
} else {
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
}
|
|
}
|
|
} else {
|
|
return DEVICE_TESTING_CODE_IN_PROCESS;
|
|
}
|
|
return DEVICE_TESTING_CODE_NOT_ACTIVE;
|
|
// } else {
|
|
// return DEVICE_TESTING_CODE_NOT_ACTIVE;
|
|
// }
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_Aamplifier(tAmplifier *amplifier) {
|
|
if (amplifier->isTest == 2) {
|
|
return DEVICE_TESTING_CODE_PASSED;
|
|
} else if (amplifier->isTest == 1) {
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
}
|
|
|
|
return DEVICE_TESTING_CODE_IN_PROCESS;
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_BipConnectTest(tBipPins *env) {
|
|
bool res = GpioPinGet(&env->Diagnost);
|
|
if (res) {
|
|
return DEVICE_TESTING_CODE_CONNECTED;
|
|
} else {
|
|
return DEVICE_TESTING_CODE_NOT_CONNECTED;
|
|
}
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_AdcSpeakerTest(tSpekTestPower *env) {
|
|
eDeviceTestingCode result = DEVICE_TESTING_CODE_CONNECTED;
|
|
if (env->lastTestTime < SystemGetMs()) {
|
|
if (env->speakTestAcsess == true) {
|
|
GpioPinSet(&env->PowerCheckSpkOn, true);
|
|
SystemDelayMs(40);
|
|
bool res = GpioPinGet(&env->PowerTestSpkIn);
|
|
GpioPinSet(&env->PowerCheckSpkOn, false);
|
|
SystemDelayMs(40);
|
|
if (res) {
|
|
return DEVICE_TESTING_CODE_CONNECTED;
|
|
} else {
|
|
return DEVICE_TESTING_CODE_NOT_CONNECTED;
|
|
}
|
|
}
|
|
env->lastTestTime = SystemGetMs() + 5000;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_AdcBatteryConnectionTest(tBatteryPower *batteryPower) {
|
|
if (batteryPower->currentBatVoltage < 1500) {
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
} else {
|
|
return DEVICE_TESTING_CODE_CONNECTED;
|
|
}
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_AdcBatteryChargeTest(tBatteryPower *batteryPower) {
|
|
if (batteryPower->currentBatVoltage < 2500) {
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
} else if ((batteryPower->currentBatVoltage >= 2500) && (batteryPower->currentBatVoltage < 3000)) {
|
|
return DEVICE_TESTING_CODE_BATTERY_PRE_CHARGE;
|
|
} else if ((batteryPower->currentBatVoltage >= 3000) && (batteryPower->currentBatVoltage < 4000)) {
|
|
return DEVICE_TESTING_CODE_BATTERY_FAST_CHARGE;
|
|
} else if ((batteryPower->currentBatVoltage >= 4000) && (batteryPower->currentBatVoltage < 4450)) {
|
|
return DEVICE_TESTING_CODE_BATTERY_CHARGE_DONE;
|
|
} else {
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
}
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_AdcBatteryVoltageTest(tBatteryPower *batteryPower) {
|
|
if(batteryPower->currentBatVoltage > 2500) {
|
|
return DEVICE_TESTING_CODE_PASSED;
|
|
} else {
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
}
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_CanTest(const tCanTest *env) {
|
|
if (env->deviceStorage->nvm->device.factoryMode) {
|
|
return *env->deviceTestingCodeCan;
|
|
} else {
|
|
return DEVICE_TESTING_CODE_NOT_ACTIVE;
|
|
}
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_IgnitionTest(tGpioPin *gpioPin) {
|
|
return GpioPinGet(gpioPin) ? DEVICE_TESTING_CODE_CONNECTED : DEVICE_TESTING_CODE_NOT_CONNECTED_OK;
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_TestAt(tModemVersionRevisionTest *env) {
|
|
if (env->modemDataCollector->fl_IsLoad == true) {
|
|
if (env->modemDataCollector->modemVersionRevision.modemStateIsValid == false) {
|
|
|
|
// if (env->modemDataCollector->modemVersionRevision.deviceTestFix_ModemValidation != NULL) {
|
|
// if ((*env->modemDataCollector->modemVersionRevision.deviceTestFix_ModemValidation !=
|
|
// DEVICE_TESTING_CODE_NOT_TESTED) &&
|
|
// (*env->modemDataCollector->modemVersionRevision.deviceTestFix_ModemValidation !=
|
|
// DEVICE_TESTING_CODE_IN_PROCESS))
|
|
// return DEVICE_TESTING_CODE_ERROR;
|
|
// }
|
|
|
|
AtCommandResult resGetCgmr = AT_ERROR;
|
|
if (osMutexAcquire(env->modemDataCollector->gsmAt->access, 500) == osOK) {
|
|
resGetCgmr = AtCmdWaitOk(&env->gsmWithGnss->gsmAt, 500, 5000);
|
|
osMutexRelease(env->modemDataCollector->gsmAt->access);
|
|
if (resGetCgmr == AT_OK) {
|
|
env->modemDataCollector->modemVersionRevision.modemStateIsValid = true;
|
|
return DEVICE_TESTING_CODE_PASSED;
|
|
} else {
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
}
|
|
} else {
|
|
return DEVICE_TESTING_CODE_IN_PROCESS;
|
|
}
|
|
} else {
|
|
return DEVICE_TESTING_CODE_PASSED;
|
|
}
|
|
}
|
|
|
|
if(env->modemDataCollector->timeIsTestModemLimit < SystemGetMs()){
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
} else {
|
|
return DEVICE_TESTING_CODE_IN_PROCESS;
|
|
}
|
|
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_TestAudioCodec(tAudioCodec *audioCodec) {
|
|
// return AudioCodecTestStatus(audioCodec) ? DEVICE_TESTING_CODE_PASSED : DEVICE_TESTING_CODE_ERROR;
|
|
if(audioCodec->state == true){
|
|
return DEVICE_TESTING_CODE_PASSED;
|
|
}
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_TestAccel(tAccel *accel) {
|
|
if ((accel->accel.xyz.x == 0) &&
|
|
(accel->accel.xyz.y == 0) &&
|
|
(accel->accel.xyz.z == 0)) {
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
}
|
|
|
|
if ((accel->accel.xyz.x == -1950) &&
|
|
(accel->accel.xyz.y == -1950) &&
|
|
(accel->accel.xyz.z == -1950)) {
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
}
|
|
|
|
// float len = vector3Len(accel->current);
|
|
// if ((len < 0.89) || (len > 1.1)) {
|
|
// return DEVICE_TESTING_CODE_ERROR;
|
|
// }
|
|
|
|
return DEVICE_TESTING_CODE_PASSED;
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_JustOk(void *nil) {
|
|
return DEVICE_TESTING_CODE_PASSED;
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_SimEra(tModemVersionRevisionTest *env) {
|
|
if (env->modemDataCollector->fl_IsLoad == true) {
|
|
if (
|
|
(env->modemDataCollector->modemVersionRevision.ssidValue.length > 18) &&
|
|
(env->modemDataCollector->modemVersionRevision.ssidValue.length <= 20)
|
|
) {
|
|
if (env->modemDataCollector->modemVersionRevision.valid_CCID == MOD_READY) {
|
|
return DEVICE_TESTING_CODE_PASSED;
|
|
} else {
|
|
if (env->modemDataCollector->modemVersionRevision.valid_CCID == MOD_ERROR) {
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
}
|
|
}
|
|
if (env->modemDataCollector->modemVersionRevision.valid_CCID == MOD_UNDEFANDED) {
|
|
return DEVICE_TESTING_CODE_IN_PROCESS;
|
|
}
|
|
}
|
|
return DEVICE_TESTING_CODE_IN_PROCESS;
|
|
}
|
|
return DEVICE_TESTING_CODE_IN_PROCESS;
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_SimComers(tModemVersionRevisionTest *env){
|
|
if((*env->telematicaIsActive == true) || ( (*env->testTelematicaIsActive == true)||(*env->fl_telematicaServerIsActive == true)) ) {
|
|
if (env->modemDataCollector->fl_IsLoad == true) {
|
|
if (
|
|
(env->modemDataCollector->modemVersionRevision.ssidComersValue.length > 18) &&
|
|
(env->modemDataCollector->modemVersionRevision.ssidComersValue.length <= 20)
|
|
) {
|
|
if (env->modemDataCollector->modemVersionRevision.valid_CCIDComer == MOD_READY) {
|
|
return DEVICE_TESTING_CODE_PASSED;
|
|
} else {
|
|
if (env->modemDataCollector->modemVersionRevision.valid_CCIDComer == MOD_ERROR) {
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
}
|
|
}
|
|
if (env->modemDataCollector->modemVersionRevision.valid_CCIDComer == MOD_UNDEFANDED) {
|
|
return DEVICE_TESTING_CODE_IN_PROCESS;
|
|
}
|
|
}
|
|
return DEVICE_TESTING_CODE_IN_PROCESS;
|
|
}
|
|
return DEVICE_TESTING_CODE_IN_PROCESS;
|
|
} else {
|
|
return DEVICE_TESTING_CODE_NOT_ACTIVE;
|
|
}
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_VIN(tDeviceStorage *deviceStorage) {
|
|
|
|
if (osMutexAcquire(deviceStorage->dumpObserver.access, 100) == osOK) {
|
|
if ((deviceStorage->nvm->gost.VIN.length <= 1) ||
|
|
(memcmp(&deviceStorage->nvm->gost.VIN.data, "00000000000000000", sizeof("00000000000000000") - 1) == 0)) {
|
|
osMutexRelease(deviceStorage->dumpObserver.access);
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
}
|
|
osMutexRelease(deviceStorage->dumpObserver.access);
|
|
} else {
|
|
return DEVICE_TESTING_CODE_IN_PROCESS;
|
|
}
|
|
return DEVICE_TESTING_CODE_PASSED;
|
|
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_CALIB_ACCEL(tDeviceStorage *deviceStorage) {
|
|
// return DEVICE_TESTING_CODE_PASSED;
|
|
|
|
if (osMutexAcquire(deviceStorage->dumpObserver.access, 100) == osOK) {
|
|
|
|
if ((deviceStorage->nvm->device.AccelCalibrationX == -32768) ||
|
|
(deviceStorage->nvm->device.AccelCalibrationY == -32768) ||
|
|
(deviceStorage->nvm->device.AccelCalibrationZ == -32768) ||
|
|
(deviceStorage->nvm->device.RolloverAngle == 255) ||
|
|
(deviceStorage->nvm->device.RolloverTime == 255) ||
|
|
(deviceStorage->nvm->device.DirectionAngle == 255)) {
|
|
|
|
osMutexRelease(deviceStorage->dumpObserver.access);
|
|
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
}
|
|
|
|
osMutexRelease(deviceStorage->dumpObserver.access);
|
|
} else {
|
|
return DEVICE_TESTING_CODE_IN_PROCESS;
|
|
}
|
|
|
|
return DEVICE_TESTING_CODE_PASSED;
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_EOL(tDeviceTestsTable *env) {
|
|
for (uint16_t i = 0; i < env->count; ++i) {
|
|
if ((env->items[i].result == DEVICE_TESTING_CODE_ERROR) ||
|
|
(env->items[i].result == DEVICE_TESTING_CODE_NOT_CONNECTED) ||
|
|
(env->items[i].result == DEVICE_TESTING_CODE_SHORT_CIRCUIT)) {
|
|
if ((memcmp(env->items[i].name.str, "ACCEL_CALIB", env->items[i].name.length) == 0) ||
|
|
(memcmp(env->items[i].name.str, "VIN", env->items[i].name.length) == 0)) {
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
}
|
|
}
|
|
}
|
|
return DEVICE_TESTING_CODE_PASSED;
|
|
}
|
|
|
|
eDeviceTestingCode DeviceTesting_Telematica(tModemVersionRevisionTest *env){
|
|
if((*env->telematicaIsActive == true) || ( (*env->testTelematicaIsActive == true)||(*env->fl_telematicaServerIsActive == true)) ) {
|
|
if (EXT_ENV_ADR_TELE.META_EXT_ENV_TELE) {
|
|
return DEVICE_TESTING_CODE_PASSED;
|
|
}
|
|
return DEVICE_TESTING_CODE_ERROR;
|
|
} else {
|
|
return DEVICE_TESTING_CODE_NOT_ACTIVE;
|
|
}
|
|
}
|