Skip to content

Commit

Permalink
Fix intermediate state
Browse files Browse the repository at this point in the history
  • Loading branch information
iranl committed Nov 11, 2024
1 parent f97593e commit 6acfade
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#define NUKI_HUB_VERSION "9.02"
#define NUKI_HUB_BUILD "unknownbuildnr"
#define NUKI_HUB_DATE "2024-11-08"
#define NUKI_HUB_DATE "2024-11-11"

#define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest"
#define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json"
Expand Down
9 changes: 5 additions & 4 deletions src/NukiOpenerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,8 @@ void NukiOpenerWrapper::update()
}
if(_statusUpdated || _nextLockStateUpdateTs == 0 || ts >= _nextLockStateUpdateTs || (queryCommands & QUERY_COMMAND_LOCKSTATE) > 0)
{
updateKeyTurnerState();
_statusUpdated = updateKeyTurnerState();
_nextLockStateUpdateTs = ts + _intervalLockstate * 1000;
_statusUpdated = false;
_network->publishStatusUpdated(_statusUpdated);
}
if(_network->mqttConnectionState() == 2)
Expand Down Expand Up @@ -418,8 +417,9 @@ void NukiOpenerWrapper::unpair()
_paired = false;
}

void NukiOpenerWrapper::updateKeyTurnerState()
bool NukiOpenerWrapper::updateKeyTurnerState()
{
bool updateStatus = false;
Nuki::CmdResult result = (Nuki::CmdResult)-1;
int retryCount = 0;

Expand All @@ -445,7 +445,7 @@ void NukiOpenerWrapper::updateKeyTurnerState()
{
_nextLockStateUpdateTs = espMillis() + _retryDelay;
}
return;
return false;
}
_retryLockstateCount = 0;

Expand Down Expand Up @@ -491,6 +491,7 @@ void NukiOpenerWrapper::updateKeyTurnerState()

postponeBleWatchdog();
Log->println(F("Done querying opener state"));
return updateStatus;
}

void NukiOpenerWrapper::updateBatteryState()
Expand Down
2 changes: 1 addition & 1 deletion src/NukiOpenerWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class NukiOpenerWrapper : public NukiOpener::SmartlockEventHandler
void onTimeControlCommandReceived(const char* value);
void onAuthCommandReceived(const char* value);

void updateKeyTurnerState();
bool updateKeyTurnerState();
void updateBatteryState();
void updateConfig();
void updateAuthData(bool retrieved);
Expand Down
11 changes: 6 additions & 5 deletions src/NukiWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,7 @@ void NukiWrapper::update()
if(_nukiOfficial->getStatusUpdated() || _statusUpdated || _nextLockStateUpdateTs == 0 || ts >= _nextLockStateUpdateTs || (queryCommands & QUERY_COMMAND_LOCKSTATE) > 0)
{
Log->println("Updating Lock state based on status, timer or query");
updateKeyTurnerState();
_statusUpdated = false;
_statusUpdated = updateKeyTurnerState();
_nextLockStateUpdateTs = ts + _intervalLockstate * 1000;
_network->publishStatusUpdated(_statusUpdated);
}
Expand Down Expand Up @@ -427,8 +426,9 @@ void NukiWrapper::unpair()
_paired = false;
}

void NukiWrapper::updateKeyTurnerState()
bool NukiWrapper::updateKeyTurnerState()
{
bool updateStatus = false;
Nuki::CmdResult result = (Nuki::CmdResult)-1;
int retryCount = 0;

Expand Down Expand Up @@ -460,7 +460,7 @@ void NukiWrapper::updateKeyTurnerState()
Log->println("ms");
_nextLockStateUpdateTs = espMillis() + _retryDelay;
}
return;
return false;
}

_retryLockstateCount = 0;
Expand Down Expand Up @@ -489,7 +489,7 @@ void NukiWrapper::updateKeyTurnerState()
}
else if(!_nukiOfficial->getOffConnected() && espMillis() < _statusUpdatedTs + 10000)
{
_statusUpdated = true;
updateStatus = true;
Log->println(F("Lock: Keep updating status on intermediate lock state"));
}

Expand All @@ -501,6 +501,7 @@ void NukiWrapper::updateKeyTurnerState()

postponeBleWatchdog();
Log->println(F("Done querying lock state"));
return updateStatus;
}

void NukiWrapper::updateBatteryState()
Expand Down
2 changes: 1 addition & 1 deletion src/NukiWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class NukiWrapper : public Nuki::SmartlockEventHandler
void onAuthCommandReceived(const char* value);
void onGpioActionReceived(const GpioAction& action, const int& pin);

void updateKeyTurnerState();
bool updateKeyTurnerState();
void updateBatteryState();
void updateConfig();
void updateAuthData(bool retrieved);
Expand Down
4 changes: 2 additions & 2 deletions src/WebCfgServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4063,10 +4063,10 @@ esp_err_t WebCfgServer::buildInfoHtml(PsychicRequest *request)
if(esp_psram_get_size() > 0)
{
response.print("\nPSRAM Available: Yes");
response.print("\nTotal PSRAM: ");
response.print(esp_psram_get_size());
response.print("\nFree PSRAM: ");
response.print((esp_get_free_heap_size() - ESP.getFreeHeap()));
response.print("\nTotal PSRAM: ");
response.print(esp_psram_get_size());
response.print("\nTotal free heap: ");
response.print(esp_get_free_heap_size());
}
Expand Down

0 comments on commit 6acfade

Please sign in to comment.