add GPIO output for bluetooth communication error (#701)
This commit is contained in:
@@ -180,6 +180,7 @@ void Gpio::setPins()
|
|||||||
case PinRole::GeneralOutput:
|
case PinRole::GeneralOutput:
|
||||||
case PinRole::OutputHighMqttConnected:
|
case PinRole::OutputHighMqttConnected:
|
||||||
case PinRole::OutputHighNetworkConnected:
|
case PinRole::OutputHighNetworkConnected:
|
||||||
|
case PinRole::OutputHighBluetoothCommError:
|
||||||
pinMode(entry.pin, OUTPUT);
|
pinMode(entry.pin, OUTPUT);
|
||||||
break;
|
break;
|
||||||
case PinRole::Ethernet:
|
case PinRole::Ethernet:
|
||||||
@@ -503,12 +504,13 @@ String Gpio::getRoleDescription(const PinRole& role) const
|
|||||||
return "Output: High when MQTT connected";
|
return "Output: High when MQTT connected";
|
||||||
case PinRole::OutputHighNetworkConnected:
|
case PinRole::OutputHighNetworkConnected:
|
||||||
return "Output: High when network connected";
|
return "Output: High when network connected";
|
||||||
|
case PinRole::OutputHighBluetoothCommError:
|
||||||
|
return "Output: High on bluetooth communication error";
|
||||||
default:
|
default:
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GpioAction Gpio::getGpioAction(const PinRole &role) const
|
GpioAction Gpio::getGpioAction(const PinRole &role) const
|
||||||
{
|
{
|
||||||
switch(role)
|
switch(role)
|
||||||
@@ -552,6 +554,7 @@ GpioAction Gpio::getGpioAction(const PinRole &role) const
|
|||||||
case PinRole::OutputHighRtoOrCmActive:
|
case PinRole::OutputHighRtoOrCmActive:
|
||||||
case PinRole::OutputHighMqttConnected:
|
case PinRole::OutputHighMqttConnected:
|
||||||
case PinRole::OutputHighNetworkConnected:
|
case PinRole::OutputHighNetworkConnected:
|
||||||
|
case PinRole::OutputHighBluetoothCommError:
|
||||||
default:
|
default:
|
||||||
return GpioAction::None;
|
return GpioAction::None;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ enum class PinRole
|
|||||||
Ethernet,
|
Ethernet,
|
||||||
OutputHighMqttConnected,
|
OutputHighMqttConnected,
|
||||||
OutputHighNetworkConnected,
|
OutputHighNetworkConnected,
|
||||||
|
OutputHighBluetoothCommError
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class GpioAction
|
enum class GpioAction
|
||||||
@@ -127,6 +128,7 @@ private:
|
|||||||
PinRole::InputDeactivateCM,
|
PinRole::InputDeactivateCM,
|
||||||
PinRole::OutputHighMqttConnected,
|
PinRole::OutputHighMqttConnected,
|
||||||
PinRole::OutputHighNetworkConnected,
|
PinRole::OutputHighNetworkConnected,
|
||||||
|
PinRole::OutputHighBluetoothCommError,
|
||||||
PinRole::OutputHighLocked,
|
PinRole::OutputHighLocked,
|
||||||
PinRole::OutputHighUnlocked,
|
PinRole::OutputHighUnlocked,
|
||||||
PinRole::OutputHighRtoActive,
|
PinRole::OutputHighRtoActive,
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ NukiOpenerWrapper::NukiOpenerWrapper(const std::string& deviceName, NukiDeviceId
|
|||||||
network->setAuthCommandReceivedCallback(nukiOpenerInst->onAuthCommandReceivedCallback);
|
network->setAuthCommandReceivedCallback(nukiOpenerInst->onAuthCommandReceivedCallback);
|
||||||
|
|
||||||
_gpio->addCallback(NukiOpenerWrapper::gpioActionCallback);
|
_gpio->addCallback(NukiOpenerWrapper::gpioActionCallback);
|
||||||
|
#ifndef NUKI_HUB_UPDATER
|
||||||
|
_pinsCommError = _gpio->getPinsWithRole(PinRole::OutputHighBluetoothCommError);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -299,6 +302,7 @@ void NukiOpenerWrapper::update()
|
|||||||
|
|
||||||
if(cmdResult != Nuki::CmdResult::Success)
|
if(cmdResult != Nuki::CmdResult::Success)
|
||||||
{
|
{
|
||||||
|
setCommErrorPins(HIGH);
|
||||||
Log->print("Opener: Last command failed, retrying after ");
|
Log->print("Opener: Last command failed, retrying after ");
|
||||||
Log->print(_retryDelay);
|
Log->print(_retryDelay);
|
||||||
Log->print(" milliseconds. Retry ");
|
Log->print(" milliseconds. Retry ");
|
||||||
@@ -318,6 +322,7 @@ void NukiOpenerWrapper::update()
|
|||||||
}
|
}
|
||||||
postponeBleWatchdog();
|
postponeBleWatchdog();
|
||||||
}
|
}
|
||||||
|
setCommErrorPins(LOW);
|
||||||
|
|
||||||
if(cmdResult == Nuki::CmdResult::Success)
|
if(cmdResult == Nuki::CmdResult::Success)
|
||||||
{
|
{
|
||||||
@@ -3746,6 +3751,14 @@ const std::string NukiOpenerWrapper::hardwareVersion() const
|
|||||||
return _hardwareVersion;
|
return _hardwareVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NukiOpenerWrapper::setCommErrorPins(const uint8_t& value)
|
||||||
|
{
|
||||||
|
for (uint8_t pin : _pinsCommError)
|
||||||
|
{
|
||||||
|
_gpio->setPinOutput(pin, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NukiOpenerWrapper::disableWatchdog()
|
void NukiOpenerWrapper::disableWatchdog()
|
||||||
{
|
{
|
||||||
_restartBeaconTimeout = -1;
|
_restartBeaconTimeout = -1;
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ public:
|
|||||||
const std::string firmwareVersion() const;
|
const std::string firmwareVersion() const;
|
||||||
const std::string hardwareVersion() const;
|
const std::string hardwareVersion() const;
|
||||||
|
|
||||||
|
void setCommErrorPins(const uint8_t& value);
|
||||||
|
|
||||||
const BleScanner::Scanner* bleScanner();
|
const BleScanner::Scanner* bleScanner();
|
||||||
|
|
||||||
void notify(NukiOpener::EventType eventType) override;
|
void notify(NukiOpener::EventType eventType) override;
|
||||||
@@ -81,8 +83,11 @@ private:
|
|||||||
NukiOpener::NukiOpener _nukiOpener;
|
NukiOpener::NukiOpener _nukiOpener;
|
||||||
BleScanner::Scanner* _bleScanner = nullptr;
|
BleScanner::Scanner* _bleScanner = nullptr;
|
||||||
NukiNetworkOpener* _network = nullptr;
|
NukiNetworkOpener* _network = nullptr;
|
||||||
Gpio* _gpio = nullptr;
|
|
||||||
Preferences* _preferences = nullptr;
|
Preferences* _preferences = nullptr;
|
||||||
|
Gpio* _gpio = nullptr;
|
||||||
|
|
||||||
|
std::vector<uint8_t> _pinsCommError;
|
||||||
|
|
||||||
int _intervalLockstate = 0; // seconds
|
int _intervalLockstate = 0; // seconds
|
||||||
int _intervalBattery = 0; // seconds
|
int _intervalBattery = 0; // seconds
|
||||||
int _intervalConfig = 60 * 60; // seconds
|
int _intervalConfig = 60 * 60; // seconds
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ NukiWrapper::NukiWrapper(const std::string& deviceName, NukiDeviceId* deviceId,
|
|||||||
network->setAuthCommandReceivedCallback(nukiInst->onAuthCommandReceivedCallback);
|
network->setAuthCommandReceivedCallback(nukiInst->onAuthCommandReceivedCallback);
|
||||||
|
|
||||||
_gpio->addCallback(NukiWrapper::gpioActionCallback);
|
_gpio->addCallback(NukiWrapper::gpioActionCallback);
|
||||||
|
#ifndef NUKI_HUB_UPDATER
|
||||||
|
_pinsCommError = _gpio->getPinsWithRole(PinRole::OutputHighBluetoothCommError);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -318,6 +321,7 @@ void NukiWrapper::update(bool reboot)
|
|||||||
|
|
||||||
if(cmdResult != Nuki::CmdResult::Success)
|
if(cmdResult != Nuki::CmdResult::Success)
|
||||||
{
|
{
|
||||||
|
setCommErrorPins(HIGH);
|
||||||
Log->print("Lock: Last command failed, retrying after ");
|
Log->print("Lock: Last command failed, retrying after ");
|
||||||
Log->print(_retryDelay);
|
Log->print(_retryDelay);
|
||||||
Log->print(" milliseconds. Retry ");
|
Log->print(" milliseconds. Retry ");
|
||||||
@@ -337,6 +341,7 @@ void NukiWrapper::update(bool reboot)
|
|||||||
}
|
}
|
||||||
postponeBleWatchdog();
|
postponeBleWatchdog();
|
||||||
}
|
}
|
||||||
|
setCommErrorPins(LOW);
|
||||||
|
|
||||||
if(cmdResult == Nuki::CmdResult::Success)
|
if(cmdResult == Nuki::CmdResult::Success)
|
||||||
{
|
{
|
||||||
@@ -4153,6 +4158,14 @@ const std::string NukiWrapper::hardwareVersion() const
|
|||||||
return _hardwareVersion;
|
return _hardwareVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NukiWrapper::setCommErrorPins(const uint8_t& value)
|
||||||
|
{
|
||||||
|
for (uint8_t pin : _pinsCommError)
|
||||||
|
{
|
||||||
|
_gpio->setPinOutput(pin, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NukiWrapper::disableWatchdog()
|
void NukiWrapper::disableWatchdog()
|
||||||
{
|
{
|
||||||
_restartBeaconTimeout = -1;
|
_restartBeaconTimeout = -1;
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ public:
|
|||||||
const std::string firmwareVersion() const;
|
const std::string firmwareVersion() const;
|
||||||
const std::string hardwareVersion() const;
|
const std::string hardwareVersion() const;
|
||||||
|
|
||||||
|
void setCommErrorPins(const uint8_t& value);
|
||||||
|
|
||||||
void notify(Nuki::EventType eventType) override;
|
void notify(Nuki::EventType eventType) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -91,6 +93,9 @@ private:
|
|||||||
NukiNetworkLock* _network = nullptr;
|
NukiNetworkLock* _network = nullptr;
|
||||||
NukiOfficial* _nukiOfficial = nullptr;
|
NukiOfficial* _nukiOfficial = nullptr;
|
||||||
Gpio* _gpio = nullptr;
|
Gpio* _gpio = nullptr;
|
||||||
|
|
||||||
|
std::vector<uint8_t> _pinsCommError;
|
||||||
|
|
||||||
Preferences* _preferences;
|
Preferences* _preferences;
|
||||||
int _intervalLockstate = 0; // seconds
|
int _intervalLockstate = 0; // seconds
|
||||||
int _intervalHybridLockstate = 0; // seconds
|
int _intervalHybridLockstate = 0; // seconds
|
||||||
|
|||||||
Reference in New Issue
Block a user