LAN8720: Add code to wait for IP address
This commit is contained in:
@@ -798,10 +798,6 @@ bool NukiNetwork::pathEquals(const char* prefix, const char* path, const char* r
|
|||||||
{
|
{
|
||||||
char prefixedPath[500];
|
char prefixedPath[500];
|
||||||
buildMqttPath(prefixedPath, { prefix, path });
|
buildMqttPath(prefixedPath, { prefix, path });
|
||||||
|
|
||||||
Log->println(prefixedPath);
|
|
||||||
Log->println(referencePath);
|
|
||||||
|
|
||||||
return strcmp(prefixedPath, referencePath) == 0;
|
return strcmp(prefixedPath, referencePath) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ void NukiNetworkLock::onMqttDataReceived(const char* topic, byte* payload, const
|
|||||||
if(_network->mqttRecentlyConnected() && _network->pathEquals(_mqttPath, mqtt_topic_lock_action, topic))
|
if(_network->mqttRecentlyConnected() && _network->pathEquals(_mqttPath, mqtt_topic_lock_action, topic))
|
||||||
{
|
{
|
||||||
Log->println("MQTT recently connected, ignoring lock action.");
|
Log->println("MQTT recently connected, ignoring lock action.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(comparePrefixedPath(topic, mqtt_topic_reset) && strcmp(value, "1") == 0)
|
if(comparePrefixedPath(topic, mqtt_topic_reset) && strcmp(value, "1") == 0)
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ void NukiNetworkOpener::onMqttDataReceived(const char* topic, byte* payload, con
|
|||||||
if(_network->mqttRecentlyConnected() && _network->pathEquals(_mqttPath, mqtt_topic_lock_action, topic))
|
if(_network->mqttRecentlyConnected() && _network->pathEquals(_mqttPath, mqtt_topic_lock_action, topic))
|
||||||
{
|
{
|
||||||
Log->println("MQTT recently connected, ignoring opener action.");
|
Log->println("MQTT recently connected, ignoring opener action.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(comparePrefixedPath(topic, mqtt_topic_lock_log_rolling_last))
|
if(comparePrefixedPath(topic, mqtt_topic_lock_log_rolling_last))
|
||||||
|
|||||||
@@ -97,6 +97,34 @@ void EthLan8720Device::initialize()
|
|||||||
onDisconnected();
|
onDisconnected();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(_ipConfiguration->dhcpEnabled())
|
||||||
|
{
|
||||||
|
waitForIpAddressWithTimeout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EthLan8720Device::waitForIpAddressWithTimeout()
|
||||||
|
{
|
||||||
|
int count = 50;
|
||||||
|
|
||||||
|
Log->print(F("LAN8720: Obtaining IP address via DHCP"));
|
||||||
|
|
||||||
|
while(count > 0 && localIP().equals("0.0.0.0"))
|
||||||
|
{
|
||||||
|
Log->print(F("."));
|
||||||
|
count--;
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(localIP().equals("0.0.0.0"))
|
||||||
|
{
|
||||||
|
Log->println(F(" Failed"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log->println(localIP());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EthLan8720Device::reconfigure()
|
void EthLan8720Device::reconfigure()
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void onDisconnected();
|
void onDisconnected();
|
||||||
|
void waitForIpAddressWithTimeout();
|
||||||
|
|
||||||
bool _restartOnDisconnect = false;
|
bool _restartOnDisconnect = false;
|
||||||
bool _startAp = false;
|
bool _startAp = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user