26
26
27
27
EthernetConnectionHandler::EthernetConnectionHandler (bool const keep_alive)
28
28
: ConnectionHandler{keep_alive, NetworkAdapter::ETHERNET}
29
+ ,_ip{INADDR_NONE}
30
+ ,_dns{INADDR_NONE}
31
+ ,_gateway{INADDR_NONE}
32
+ ,_subnet{INADDR_NONE}
33
+ {
34
+
35
+ }
36
+
37
+ EthernetConnectionHandler::EthernetConnectionHandler (IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet, bool const keep_alive)
38
+ : ConnectionHandler{keep_alive, NetworkAdapter::ETHERNET}
39
+ ,_ip{ip}
40
+ ,_dns{dns}
41
+ ,_gateway{gateway}
42
+ ,_subnet{subnet}
29
43
{
30
44
31
45
}
@@ -47,11 +61,20 @@ NetworkConnectionState EthernetConnectionHandler::update_handleInit()
47
61
48
62
NetworkConnectionState EthernetConnectionHandler::update_handleConnecting ()
49
63
{
50
- if (Ethernet.begin (nullptr , 15000 , 4000 ) == 0 ) {
64
+ if (_ip != INADDR_NONE) {
65
+ if (Ethernet.begin (nullptr , _ip, _dns, _gateway, _subnet, 15000 , 4000 ) == 0 ) {
51
66
#if !defined(__AVR__)
52
- Debug.print (DBG_ERROR, F (" Waiting Ethernet configuration from DHCP server , check cable connection" ));
67
+ Debug.print (DBG_ERROR, F (" Failed to configure Ethernet , check cable connection" ));
53
68
#endif
54
- return NetworkConnectionState::CONNECTING;
69
+ return NetworkConnectionState::CONNECTING;
70
+ }
71
+ } else {
72
+ if (Ethernet.begin (nullptr , 15000 , 4000 ) == 0 ) {
73
+ #if !defined(__AVR__)
74
+ Debug.print (DBG_ERROR, F (" Waiting Ethernet configuration from DHCP server, check cable connection" ));
75
+ #endif
76
+ return NetworkConnectionState::CONNECTING;
77
+ }
55
78
}
56
79
return NetworkConnectionState::CONNECTED;
57
80
}
0 commit comments