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