fix lock action crash
This commit is contained in:
35
Nuki.cpp
35
Nuki.cpp
@@ -36,32 +36,26 @@ void Nuki::update()
|
|||||||
vTaskDelay( 200 / portTICK_PERIOD_MS);
|
vTaskDelay( 200 / portTICK_PERIOD_MS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vTaskDelay( 100 / portTICK_PERIOD_MS);
|
|
||||||
|
|
||||||
|
|
||||||
// Config config;
|
|
||||||
// uint8_t res = _nukiBle.requestConfig(&config, false);
|
|
||||||
// Serial.print("Result: ");
|
|
||||||
// Serial.println(res);
|
|
||||||
// Serial.print("Time: ");
|
|
||||||
// Serial.print(config.currentTimeHour);
|
|
||||||
// Serial.print(":");
|
|
||||||
// Serial.println(config.currentTimeMinute);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vTaskDelay( 100 / portTICK_PERIOD_MS);
|
vTaskDelay( 200 / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
unsigned long ts = millis();
|
unsigned long ts = millis();
|
||||||
|
|
||||||
updateKeyTurnerState();
|
if(_lastLockStateUpdateTs == 0 || _lastLockStateUpdateTs + 60000 < ts)
|
||||||
|
{
|
||||||
|
_lastLockStateUpdateTs = ts;
|
||||||
|
updateKeyTurnerState();
|
||||||
|
}
|
||||||
if(_lastBatteryReportTs == 0 || _lastBatteryReportTs + 600000 < ts)
|
if(_lastBatteryReportTs == 0 || _lastBatteryReportTs + 600000 < ts)
|
||||||
{
|
{
|
||||||
_lastBatteryReportTs = ts;
|
_lastBatteryReportTs = ts;
|
||||||
updateBatteryState();
|
updateBatteryState();
|
||||||
}
|
}
|
||||||
|
if(_nextLockAction != (LockAction)0xff)
|
||||||
vTaskDelay( 60000 / portTICK_PERIOD_MS);
|
{
|
||||||
|
_nukiBle.lockAction(_nextLockAction, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -155,12 +149,7 @@ LockAction Nuki::lockActionToEnum(const char *str)
|
|||||||
|
|
||||||
void Nuki::onLockActionReceived(const char *value)
|
void Nuki::onLockActionReceived(const char *value)
|
||||||
{
|
{
|
||||||
LockAction action = nukiInst->lockActionToEnum(value);
|
nukiInst->_nextLockAction = nukiInst->lockActionToEnum(value);
|
||||||
Serial.print("Action: ");
|
Serial.print("Action: ");
|
||||||
Serial.println((int)action);
|
Serial.println((int)nukiInst->_nextLockAction);
|
||||||
if(action != (LockAction)0xff)
|
|
||||||
{
|
|
||||||
nukiInst->_nukiBle.lockAction(action, 0, 0);
|
|
||||||
vTaskDelay( 5000 / portTICK_PERIOD_MS);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
2
Nuki.h
2
Nuki.h
@@ -31,5 +31,7 @@ private:
|
|||||||
BatteryReport _lastBatteryReport;
|
BatteryReport _lastBatteryReport;
|
||||||
|
|
||||||
bool _paired = false;
|
bool _paired = false;
|
||||||
|
unsigned long _lastLockStateUpdateTs = 0;
|
||||||
unsigned long _lastBatteryReportTs = 0;
|
unsigned long _lastBatteryReportTs = 0;
|
||||||
|
LockAction _nextLockAction = (LockAction)0xff;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user