Add GPIO for network connected status (#700)
* Add gpio output if mqtt connected * Add gpio output for network connected status
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
#define NUKI_HUB_VERSION "9.13"
|
||||
#define NUKI_HUB_VERSION_INT (uint32_t)913
|
||||
#define NUKI_HUB_BUILD "unknownbuildnr"
|
||||
#define NUKI_HUB_DATE "2025-10-01"
|
||||
#define NUKI_HUB_DATE "2025-10-01"
|
||||
#define NUKI_HUB_DATE "2025-10-02"
|
||||
#define NUKI_HUB_DATE "2025-10-02"
|
||||
|
||||
#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"
|
||||
|
||||
@@ -179,6 +179,7 @@ void Gpio::setPins()
|
||||
case PinRole::OutputHighRtoOrCmActive:
|
||||
case PinRole::GeneralOutput:
|
||||
case PinRole::OutputHighMqttConnected:
|
||||
case PinRole::OutputHighNetworkConnected:
|
||||
pinMode(entry.pin, OUTPUT);
|
||||
break;
|
||||
case PinRole::Ethernet:
|
||||
@@ -500,6 +501,8 @@ String Gpio::getRoleDescription(const PinRole& role) const
|
||||
return "Ethernet";
|
||||
case PinRole::OutputHighMqttConnected:
|
||||
return "Output: High when MQTT connected";
|
||||
case PinRole::OutputHighNetworkConnected:
|
||||
return "Output: High when network connected";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
@@ -548,6 +551,7 @@ GpioAction Gpio::getGpioAction(const PinRole &role) const
|
||||
case PinRole::OutputHighCmActive:
|
||||
case PinRole::OutputHighRtoOrCmActive:
|
||||
case PinRole::OutputHighMqttConnected:
|
||||
case PinRole::OutputHighNetworkConnected:
|
||||
default:
|
||||
return GpioAction::None;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@ enum class PinRole
|
||||
GeneralInputPullDown,
|
||||
GeneralInputPullUp,
|
||||
Ethernet,
|
||||
OutputHighMqttConnected
|
||||
OutputHighMqttConnected,
|
||||
OutputHighNetworkConnected,
|
||||
};
|
||||
|
||||
enum class GpioAction
|
||||
@@ -125,6 +126,7 @@ private:
|
||||
PinRole::InputDeactivateRTO,
|
||||
PinRole::InputDeactivateCM,
|
||||
PinRole::OutputHighMqttConnected,
|
||||
PinRole::OutputHighNetworkConnected,
|
||||
PinRole::OutputHighLocked,
|
||||
PinRole::OutputHighUnlocked,
|
||||
PinRole::OutputHighRtoActive,
|
||||
|
||||
@@ -38,6 +38,7 @@ NukiNetwork::NukiNetwork(Preferences *preferences)
|
||||
_inst = this;
|
||||
#ifndef NUKI_HUB_UPDATER
|
||||
_pinsMqttConnected = _gpio->getPinsWithRole(PinRole::OutputHighMqttConnected);
|
||||
_pinsNetworkConnected = _gpio->getPinsWithRole(PinRole::OutputHighNetworkConnected);
|
||||
#endif
|
||||
setupDevice();
|
||||
}
|
||||
@@ -682,11 +683,16 @@ bool NukiNetwork::update()
|
||||
void NukiNetwork::updateNetworkStatusLeds()
|
||||
{
|
||||
bool mqttConnected = _device->mqttConnected();
|
||||
bool networkConnected = _device->isConnected();
|
||||
|
||||
for (uint8_t pin : _pinsMqttConnected)
|
||||
{
|
||||
_gpio->setPinOutput(pin, mqttConnected ? HIGH : LOW);
|
||||
}
|
||||
for (uint8_t pin : _pinsNetworkConnected)
|
||||
{
|
||||
_gpio->setPinOutput(pin, networkConnected ? HIGH : LOW);
|
||||
}
|
||||
}
|
||||
|
||||
void NukiNetwork::checkInternetConnectivity()
|
||||
|
||||
@@ -176,6 +176,7 @@ private:
|
||||
|
||||
std::map<uint8_t, int64_t> _gpioTs;
|
||||
std::vector<uint8_t> _pinsMqttConnected;
|
||||
std::vector<uint8_t> _pinsNetworkConnected;
|
||||
|
||||
char* _buffer;
|
||||
const size_t _bufferSize;
|
||||
|
||||
Reference in New Issue
Block a user