Skip to content

Commit

Permalink
show hw and fw version in sysinfo page
Browse files Browse the repository at this point in the history
  • Loading branch information
technyon committed Feb 20, 2023
1 parent 4676f24 commit 6597814
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 3 deletions.
13 changes: 13 additions & 0 deletions NukiOpenerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ void NukiOpenerWrapper::update()
if(_restartBeaconTimeout > 0 &&
ts > 60000 &&
lastReceivedBeaconTs > 0 &&
_disableBleWatchdogTs < ts &&
(ts - lastReceivedBeaconTs > _restartBeaconTimeout * 1000))
{
Log->print("No BLE beacon received from the opener for ");
Expand Down Expand Up @@ -335,6 +336,8 @@ void NukiOpenerWrapper::updateConfig()
_hasKeypad = _nukiConfig.hasKeypad > 0;
if(_nukiConfigValid)
{
_firmwareVersion = std::to_string(_nukiConfig.firmwareVersion[0]) + "." + std::to_string(_nukiConfig.firmwareVersion[1]) + "." + std::to_string(_nukiConfig.firmwareVersion[2]);
_hardwareVersion = std::to_string(_nukiConfig.hardwareRevision[0]) + "." + std::to_string(_nukiConfig.hardwareRevision[1]);
_network->publishConfig(_nukiConfig);
}
if(_nukiAdvancedConfigValid)
Expand Down Expand Up @@ -667,3 +670,13 @@ void NukiOpenerWrapper::printCommandResult(Nuki::CmdResult result)
NukiOpener::cmdResultToString(result, resultStr);
Log->println(resultStr);
}

std::string NukiOpenerWrapper::firmwareVersion() const
{
return _firmwareVersion;
}

std::string NukiOpenerWrapper::hardwareVersion() const
{
return _hardwareVersion;
}
5 changes: 5 additions & 0 deletions NukiOpenerWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class NukiOpenerWrapper : public NukiOpener::SmartlockEventHandler
const bool hasKeypad();
const BLEAddress getBleAddress() const;

std::string firmwareVersion() const;
std::string hardwareVersion() const;

BleScanner::Scanner* bleScanner();

void notify(NukiOpener::EventType eventType) override;
Expand Down Expand Up @@ -101,5 +104,7 @@ class NukiOpenerWrapper : public NukiOpener::SmartlockEventHandler
long _nextRssiTs = 0;
unsigned long _lastRssi = 0;
unsigned long _disableBleWatchdogTs = 0;
std::string _firmwareVersion = "";
std::string _hardwareVersion = "";
NukiOpener::LockAction _nextLockAction = (NukiOpener::LockAction)0xff;
};
12 changes: 12 additions & 0 deletions NukiWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ void NukiWrapper::updateConfig()
_hasKeypad = _nukiConfig.hasKeypad > 0;
if(_nukiConfigValid)
{
_firmwareVersion = std::to_string(_nukiConfig.firmwareVersion[0]) + "." + std::to_string(_nukiConfig.firmwareVersion[1]) + "." + std::to_string(_nukiConfig.firmwareVersion[2]);
_hardwareVersion = std::to_string(_nukiConfig.hardwareRevision[0]) + "." + std::to_string(_nukiConfig.hardwareRevision[1]);
_network->publishConfig(_nukiConfig);
}
if(_nukiAdvancedConfigValid)
Expand Down Expand Up @@ -696,3 +698,13 @@ void NukiWrapper::printCommandResult(Nuki::CmdResult result)
NukiLock::cmdResultToString(result, resultStr);
Log->println(resultStr);
}

std::string NukiWrapper::firmwareVersion() const
{
return _firmwareVersion;
}

std::string NukiWrapper::hardwareVersion() const
{
return _hardwareVersion;
}
5 changes: 5 additions & 0 deletions NukiWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class NukiWrapper : public Nuki::SmartlockEventHandler
const bool hasKeypad();
const BLEAddress getBleAddress() const;

std::string firmwareVersion() const;
std::string hardwareVersion() const;

void notify(Nuki::EventType eventType) override;

private:
Expand Down Expand Up @@ -102,5 +105,7 @@ class NukiWrapper : public Nuki::SmartlockEventHandler
unsigned long _nextRssiTs = 0;
unsigned long _lastRssi = 0;
unsigned long _disableBleWatchdogTs = 0;
std::string _firmwareVersion = "";
std::string _hardwareVersion = "";
volatile NukiLock::LockAction _nextLockAction = (NukiLock::LockAction)0xff;
};
13 changes: 10 additions & 3 deletions WebCfgServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ void WebCfgServer::buildInfoHtml(String &response)
buildHtmlHeader(response);
response.concat("<h3>System Information</h3> <pre>");

response.concat("Firmware version: ");
response.concat("NUKI Hub version: ");
response.concat(NUKI_HUB_VERSION);
response.concat("\n");

Expand All @@ -753,14 +753,21 @@ void WebCfgServer::buildInfoHtml(String &response)

if(_nuki != nullptr)
{
response.concat("Lock paired: ");
response.concat("Lock firmware version: ");
response.concat(_nuki->firmwareVersion().c_str());
response.concat("\nLock hardware version: ");
response.concat(_nuki->hardwareVersion().c_str());
response.concat("\nLock paired: ");
response.concat(_nuki->isPaired() ? "Yes\n" : "No\n");
response.concat("Lock PIN set: ");
response.concat(_nuki->isPaired() ? _nuki->isPinSet() ? "Yes\n" : "No\n" : "-\n");
}
if(_nukiOpener != nullptr)
{
response.concat("Opener paired: ");
response.concat("Opener firmware version: ");
response.concat(_nukiOpener->firmwareVersion().c_str());
response.concat("\nOpener hardware version: ");
response.concat(_nukiOpener->hardwareVersion().c_str()); response.concat("\nOpener paired: ");
response.concat(_nukiOpener->isPaired() ? "Yes\n" : "No\n");
response.concat("Opener PIN set: ");
response.concat(_nukiOpener->isPaired() ? _nukiOpener->isPinSet() ? "Yes\n" : "No\n" : "-\n");
Expand Down
Binary file modified webflash/nuki_hub.bin
Binary file not shown.

0 comments on commit 6597814

Please sign in to comment.