move code to handle network events from anonymous to class method
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#define NUKI_HUB_VERSION "9.01"
|
#define NUKI_HUB_VERSION "9.01"
|
||||||
#define NUKI_HUB_BUILD "unknownbuildnr"
|
#define NUKI_HUB_BUILD "unknownbuildnr"
|
||||||
#define NUKI_HUB_DATE "2024-08-17"
|
#define NUKI_HUB_DATE "2024-08-18"
|
||||||
|
|
||||||
#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"
|
||||||
|
|||||||
@@ -161,7 +161,10 @@ void NukiNetwork::setupDevice()
|
|||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
Log->println(F("Custom LAN Module"));
|
Log->println(F("Custom LAN Module"));
|
||||||
if(_preferences->getInt(preference_network_custom_phy, 0) > 0) _networkDeviceType = NetworkDeviceType::CUSTOM;
|
if(_preferences->getInt(preference_network_custom_phy, 0) > 0)
|
||||||
|
{
|
||||||
|
_networkDeviceType = NetworkDeviceType::CUSTOM;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log->println(F("Custom LAN Module not setup correctly, falling back to Wi-Fi"));
|
Log->println(F("Custom LAN Module not setup correctly, falling back to Wi-Fi"));
|
||||||
|
|||||||
@@ -2593,9 +2593,18 @@ void WebCfgServer::buildHtml(AsyncWebServerRequest *request)
|
|||||||
buildNavigationMenuEntry(response, "GPIO Configuration", "/gpiocfg");
|
buildNavigationMenuEntry(response, "GPIO Configuration", "/gpiocfg");
|
||||||
buildNavigationMenuEntry(response, "Firmware update", "/ota");
|
buildNavigationMenuEntry(response, "Firmware update", "/ota");
|
||||||
buildNavigationMenuEntry(response, "Import/Export Configuration", "/impexpcfg");
|
buildNavigationMenuEntry(response, "Import/Export Configuration", "/impexpcfg");
|
||||||
if(_preferences->getInt(preference_network_hardware, 0) == 11) buildNavigationMenuEntry(response, "Custom Ethernet Configuration", "/custntw");
|
if(_preferences->getInt(preference_network_hardware, 0) == 11)
|
||||||
if(_preferences->getBool(preference_publish_debug_info, false)) buildNavigationMenuEntry(response, "Advanced Configuration", "/advanced");
|
{
|
||||||
if(_preferences->getBool(preference_webserial_enabled, false)) buildNavigationMenuEntry(response, "Open Webserial", "/webserial");
|
buildNavigationMenuEntry(response, "Custom Ethernet Configuration", "/custntw");
|
||||||
|
}
|
||||||
|
if (_preferences->getBool(preference_publish_debug_info, false))
|
||||||
|
{
|
||||||
|
buildNavigationMenuEntry(response, "Advanced Configuration", "/advanced");
|
||||||
|
}
|
||||||
|
if(_preferences->getBool(preference_webserial_enabled, false))
|
||||||
|
{
|
||||||
|
buildNavigationMenuEntry(response, "Open Webserial", "/webserial");
|
||||||
|
}
|
||||||
#ifndef CONFIG_IDF_TARGET_ESP32H2
|
#ifndef CONFIG_IDF_TARGET_ESP32H2
|
||||||
if(_allowRestartToPortal) buildNavigationMenuEntry(response, "Configure Wi-Fi", "/wifi");
|
if(_allowRestartToPortal) buildNavigationMenuEntry(response, "Configure Wi-Fi", "/wifi");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -142,6 +142,37 @@ void EthernetDevice::initialize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Network.onEvent([&](arduino_event_id_t event, arduino_event_info_t info)
|
Network.onEvent([&](arduino_event_id_t event, arduino_event_info_t info)
|
||||||
|
{
|
||||||
|
onNetworkEvent(event, info);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log->println(F("Failed to initialize ethernet hardware"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EthernetDevice::update()
|
||||||
|
{
|
||||||
|
NetworkDevice::update();
|
||||||
|
|
||||||
|
if(_checkIpTs != -1)
|
||||||
|
{
|
||||||
|
if(_ipConfiguration->ipAddress() != ETH.localIP())
|
||||||
|
{
|
||||||
|
Log->println(F("ETH Set static IP"));
|
||||||
|
ETH.config(_ipConfiguration->ipAddress(), _ipConfiguration->defaultGateway(), _ipConfiguration->subnet(), _ipConfiguration->dnsServer());
|
||||||
|
_checkIpTs = (esp_timer_get_time() / 1000) + 2000;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_checkIpTs = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EthernetDevice::onNetworkEvent(arduino_event_id_t event, arduino_event_info_t info)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case ARDUINO_EVENT_ETH_START:
|
case ARDUINO_EVENT_ETH_START:
|
||||||
@@ -193,32 +224,8 @@ void EthernetDevice::initialize()
|
|||||||
Log->println(event);
|
Log->println(event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Log->println(F("Failed to initialize ethernet hardware"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EthernetDevice::update()
|
|
||||||
{
|
|
||||||
NetworkDevice::update();
|
|
||||||
|
|
||||||
if(_checkIpTs != -1)
|
|
||||||
{
|
|
||||||
if(_ipConfiguration->ipAddress() != ETH.localIP())
|
|
||||||
{
|
|
||||||
Log->println(F("ETH Set static IP"));
|
|
||||||
ETH.config(_ipConfiguration->ipAddress(), _ipConfiguration->defaultGateway(), _ipConfiguration->subnet(), _ipConfiguration->dnsServer());
|
|
||||||
_checkIpTs = (esp_timer_get_time() / 1000) + 2000;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_checkIpTs = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void EthernetDevice::reconfigure()
|
void EthernetDevice::reconfigure()
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ private:
|
|||||||
void init();
|
void init();
|
||||||
void onDisconnected();
|
void onDisconnected();
|
||||||
void waitForIpAddressWithTimeout();
|
void waitForIpAddressWithTimeout();
|
||||||
|
void onNetworkEvent(arduino_event_id_t event, arduino_event_info_t info);
|
||||||
|
|
||||||
bool _connected = false;
|
bool _connected = false;
|
||||||
bool _restartOnDisconnect = false;
|
bool _restartOnDisconnect = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user