update
This commit is contained in:
@@ -16,7 +16,9 @@ CFingerLogic::CFingerLogic(CMain *pMain)
|
||||
memset(&m_FingerParams, 0, sizeof(m_FingerParams));
|
||||
memset(m_aFingerSlots, 0, sizeof(m_aFingerSlots));
|
||||
m_FingerSlotsAdded = 0;
|
||||
m_ErrorCounter = 0;
|
||||
|
||||
m_InitTimer.initializeMs(100, TimerDelegate(&CFingerLogic::InitFinger, this));
|
||||
m_PowerOffTimer.initializeMs(1000, TimerDelegate(&CFingerLogic::PowerOff, this));
|
||||
}
|
||||
|
||||
@@ -31,8 +33,13 @@ void CFingerLogic::SetState(FingerLogicState state)
|
||||
{
|
||||
m_State = state;
|
||||
|
||||
if(m_State == STATE_ERROR)
|
||||
m_ErrorCounter++;
|
||||
|
||||
if(m_State == STATE_READY || m_State == STATE_ERROR)
|
||||
m_PowerOffTimer.start(false);
|
||||
{
|
||||
m_PowerOffTimer.startOnce();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_PowerOffTimer.stop();
|
||||
@@ -47,9 +54,8 @@ void CFingerLogic::PowerOff()
|
||||
|
||||
debugf("PowerOff()");
|
||||
m_Power = false;
|
||||
Main().FingerEnable(false);
|
||||
wifi_set_sleep_type(LIGHT_SLEEP_T);
|
||||
system_soft_wdt_feed();
|
||||
m_ErrorCounter = 0;
|
||||
Main().FingerPower(false);
|
||||
}
|
||||
|
||||
void CFingerLogic::PowerOn()
|
||||
@@ -59,14 +65,15 @@ void CFingerLogic::PowerOn()
|
||||
|
||||
debugf("PowerOn()");
|
||||
m_Power = true;
|
||||
Main().FingerEnable(true);
|
||||
wifi_set_sleep_type(MODEM_SLEEP_T);
|
||||
Main().FingerPower(true);
|
||||
system_soft_wdt_feed();
|
||||
delayMilliseconds(100);
|
||||
system_soft_wdt_feed();
|
||||
}
|
||||
|
||||
void CFingerLogic::OnFingerInterrupt(bool finger)
|
||||
void CFingerLogic::OnFinger(bool finger)
|
||||
{
|
||||
debugf("OnFingerInterrupt: %s", finger ? "DOWN" : "UP");
|
||||
debugf("OnFinger: %s", finger ? "DOWN" : "UP");
|
||||
m_Finger = finger;
|
||||
|
||||
if(finger)
|
||||
@@ -122,15 +129,20 @@ void CFingerLogic::InitFinger()
|
||||
if(m_State > STATE_INIT_VERIFYPASSWORD)
|
||||
return;
|
||||
|
||||
if(m_ErrorCounter > 100)
|
||||
return;
|
||||
|
||||
SetState(STATE_INIT_VERIFYPASSWORD);
|
||||
FingerPrint().AsyncVerifyPassword((VerifyPasswordCallback)InitFinger_OnVerifyPassword, this);
|
||||
|
||||
m_Timer.initializeMs(100, TimerDelegate(&CFingerLogic::InitFinger, this)).start();
|
||||
m_InitTimer.start();
|
||||
m_ErrorCounter++;
|
||||
}
|
||||
|
||||
void CFingerLogic::InitFinger_OnVerifyPassword(CFingerLogic *pThis, FingerPrintError error, const char *errorStr)
|
||||
{
|
||||
pThis->m_Timer.stop();
|
||||
pThis->m_ErrorCounter--;
|
||||
pThis->m_InitTimer.stop();
|
||||
debugf("InitFinger_OnVerifyPassword: (%d) %s", error, errorStr);
|
||||
|
||||
if(error == ERROR_OK)
|
||||
@@ -157,11 +169,38 @@ void CFingerLogic::InitFinger_OnReadSystemParameters(CFingerLogic *pThis, Finger
|
||||
debugf("packetLength: %d", param->packetLength);
|
||||
debugf("baudRate: %d", param->baudRate);
|
||||
|
||||
if(param->securityLevel != pThis->Main().Settings().m_SecurityLevel)
|
||||
{
|
||||
pThis->SetState(STATE_INIT_SETSYSTEM_SECURITYLEVEL);
|
||||
pThis->FingerPrint().AsyncSetSystemParameter((SetSystemParameterCallback)InitFinger_OnSetSystemSecurityLevel, pThis, FINGERPRINT_SECURITY_REG_ADDR, pThis->Main().Settings().m_SecurityLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
pThis->SetState(STATE_INIT_READTEMPLATEMAP);
|
||||
pThis->FingerPrint().AsyncReadTemplateMap((ReadTemplateMapCallback)InitFinger_OnReadTemplateMap, pThis, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pThis->SetState(STATE_ERROR);
|
||||
pThis->m_InitTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
void CFingerLogic::InitFinger_OnSetSystemSecurityLevel(CFingerLogic *pThis, FingerPrintError error, const char *errorStr)
|
||||
{
|
||||
debugf("InitFinger_OnSetSystemSecurityLevel: (%d) %s", error, errorStr);
|
||||
|
||||
if(error == ERROR_OK)
|
||||
{
|
||||
pThis->SetState(STATE_INIT_READTEMPLATEMAP);
|
||||
pThis->FingerPrint().AsyncReadTemplateMap((ReadTemplateMapCallback)InitFinger_OnReadTemplateMap, pThis, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
pThis->SetState(STATE_ERROR);
|
||||
pThis->m_InitTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
void CFingerLogic::InitFinger_OnReadTemplateMap(CFingerLogic *pThis, FingerPrintError error, const char *errorStr, uint8_t *pData, uint16_t dataLen)
|
||||
@@ -241,7 +280,10 @@ void CFingerLogic::InitFinger_OnLoadTemplate(CFingerLogic *pThis, FingerPrintErr
|
||||
pThis->FingerPrint().AsyncDownloadCharacteristics((DownloadCharacteristicsCallback)InitFinger_OnDownloadCharacteristics, pThis, 0x01);
|
||||
}
|
||||
else
|
||||
{
|
||||
pThis->SetState(STATE_ERROR);
|
||||
pThis->m_InitTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
void CFingerLogic::InitFinger_OnDownloadCharacteristics(CFingerLogic *pThis, FingerPrintError error, const char *errorStr, int8_t *pChar, uint16_t charLen)
|
||||
@@ -282,7 +324,10 @@ void CFingerLogic::InitFinger_OnDownloadCharacteristics(CFingerLogic *pThis, Fin
|
||||
pThis->FingerPrint().AsyncLoadTemplate((LoadTemplateCallback)InitFinger_OnLoadTemplate, pThis, position, 0x01);
|
||||
}
|
||||
else
|
||||
{
|
||||
pThis->SetState(STATE_ERROR);
|
||||
pThis->m_InitTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -537,9 +582,7 @@ void CFingerLogic::EnrollFinger_OnCreateTemplate(CFingerLogic *pThis, FingerPrin
|
||||
pThis->FingerPrint().AsyncStoreTemplate((StoreTemplateCallback)EnrollFinger_OnStoreTemplate, pThis, pThis->m_iBuffer, 0x01);
|
||||
}
|
||||
else
|
||||
{
|
||||
pThis->SetState(STATE_READY);
|
||||
}
|
||||
}
|
||||
|
||||
void CFingerLogic::EnrollFinger_OnStoreTemplate(CFingerLogic *pThis, FingerPrintError error, const char *errorStr, uint16_t positionNumber)
|
||||
@@ -554,9 +597,7 @@ void CFingerLogic::EnrollFinger_OnStoreTemplate(CFingerLogic *pThis, FingerPrint
|
||||
pThis->FingerPrint().AsyncLoadTemplate((LoadTemplateCallback)EnrollFinger_OnLoadTemplate, pThis, positionNumber, 0x01);
|
||||
}
|
||||
else
|
||||
{
|
||||
pThis->SetState(STATE_READY);
|
||||
}
|
||||
}
|
||||
|
||||
void CFingerLogic::EnrollFinger_OnLoadTemplate(CFingerLogic *pThis, FingerPrintError error, const char *errorStr)
|
||||
@@ -570,9 +611,7 @@ void CFingerLogic::EnrollFinger_OnLoadTemplate(CFingerLogic *pThis, FingerPrintE
|
||||
pThis->FingerPrint().AsyncDownloadCharacteristics((DownloadCharacteristicsCallback)EnrollFinger_OnDownloadCharacteristics, pThis, 0x01);
|
||||
}
|
||||
else
|
||||
{
|
||||
pThis->SetState(STATE_READY);
|
||||
}
|
||||
}
|
||||
|
||||
void CFingerLogic::EnrollFinger_OnDownloadCharacteristics(CFingerLogic *pThis, FingerPrintError error, const char *errorStr, int8_t *pChar, uint16_t charLen)
|
||||
@@ -586,13 +625,20 @@ void CFingerLogic::EnrollFinger_OnDownloadCharacteristics(CFingerLogic *pThis, F
|
||||
ctx.update(pChar, charLen);
|
||||
uint8_t *digest = ctx.getHash().data();
|
||||
|
||||
Serial1.printf("NEW Finger %d hexdigest: ", pThis->m_iBuffer);
|
||||
for(uint8_t i = 0; i < sizeof(digest); i++)
|
||||
Serial1.printf("%x", digest[i]);
|
||||
Serial1.printf("\n");
|
||||
|
||||
pThis->Main().OnFingerEnrolled(pThis->m_iBuffer, digest);
|
||||
}
|
||||
|
||||
pThis->SetState(STATE_READY);
|
||||
}
|
||||
|
||||
void CFingerLogic::SetSecurityLevel(int securityLevel)
|
||||
{
|
||||
SetState(STATE_SETSYSTEM_SECURITYLEVEL);
|
||||
FingerPrint().AsyncSetSystemParameter((SetSystemParameterCallback)SetSecurityLevel_OnSetSystemSecurityLevel, this, FINGERPRINT_SECURITY_REG_ADDR, securityLevel);
|
||||
}
|
||||
|
||||
void CFingerLogic::SetSecurityLevel_OnSetSystemSecurityLevel(CFingerLogic *pThis, FingerPrintError error, const char *errorStr)
|
||||
{
|
||||
debugf("SetSecurityLevel_OnSetSystemSecurityLevel: (%d) %s", error, errorStr);
|
||||
pThis->SetState(STATE_READY);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user