|
24 | 24 | CTOR/DTOR
|
25 | 25 | ******************************************************************************/
|
26 | 26 |
|
27 |
| -EthernetConnectionHandler::EthernetConnectionHandler(bool const keep_alive) |
| 27 | +EthernetConnectionHandler::EthernetConnectionHandler(unsigned long const timeout, unsigned long const responseTimeout, bool const keep_alive) |
28 | 28 | : ConnectionHandler{keep_alive, NetworkAdapter::ETHERNET}
|
29 | 29 | ,_ip{INADDR_NONE}
|
30 | 30 | ,_dns{INADDR_NONE}
|
31 | 31 | ,_gateway{INADDR_NONE}
|
32 | 32 | ,_netmask{INADDR_NONE}
|
| 33 | +,_timeout{timeout} |
| 34 | +,_response_timeout{responseTimeout} |
33 | 35 | {
|
34 | 36 |
|
35 | 37 | }
|
36 | 38 |
|
37 |
| -EthernetConnectionHandler::EthernetConnectionHandler(const IPAddress ip, const IPAddress dns, const IPAddress gateway, const IPAddress netmask, bool const keep_alive) |
| 39 | +EthernetConnectionHandler::EthernetConnectionHandler(const IPAddress ip, const IPAddress dns, const IPAddress gateway, const IPAddress netmask, unsigned long const timeout, unsigned long const responseTimeout, bool const keep_alive) |
38 | 40 | : ConnectionHandler{keep_alive, NetworkAdapter::ETHERNET}
|
39 | 41 | ,_ip{ip}
|
40 | 42 | ,_dns{dns}
|
41 | 43 | ,_gateway{gateway}
|
42 | 44 | ,_netmask{netmask}
|
| 45 | +,_timeout{timeout} |
| 46 | +,_response_timeout{responseTimeout} |
43 | 47 | {
|
44 | 48 |
|
45 | 49 | }
|
46 | 50 |
|
47 |
| -EthernetConnectionHandler::EthernetConnectionHandler(const char * ip, const char * dns, const char * gateway, const char * netmask, bool const keep_alive) |
| 51 | +EthernetConnectionHandler::EthernetConnectionHandler(const char * ip, const char * dns, const char * gateway, const char * netmask, unsigned long const timeout, unsigned long const responseTimeout, bool const keep_alive) |
48 | 52 | : ConnectionHandler{keep_alive, NetworkAdapter::ETHERNET}
|
49 | 53 | ,_ip{INADDR_NONE}
|
50 | 54 | ,_dns{INADDR_NONE}
|
51 | 55 | ,_gateway{INADDR_NONE}
|
52 | 56 | ,_netmask{INADDR_NONE}
|
| 57 | +,_timeout{timeout} |
| 58 | +,_response_timeout{responseTimeout} |
53 | 59 | {
|
54 | 60 | if(!_ip.fromString(ip)) {
|
55 | 61 | _ip = INADDR_NONE;
|
@@ -81,13 +87,15 @@ NetworkConnectionState EthernetConnectionHandler::update_handleInit()
|
81 | 87 | NetworkConnectionState EthernetConnectionHandler::update_handleConnecting()
|
82 | 88 | {
|
83 | 89 | if (_ip != INADDR_NONE) {
|
84 |
| - if (Ethernet.begin(nullptr, _ip, _dns, _gateway, _netmask, 15000, 4000) == 0) { |
| 90 | + if (Ethernet.begin(nullptr, _ip, _dns, _gateway, _netmask, _timeout, _response_timeout) == 0) { |
85 | 91 | Debug.print(DBG_ERROR, F("Failed to configure Ethernet, check cable connection"));
|
| 92 | + Debug.print(DBG_VERBOSE, "timeout: %d, response timeout: %d", _timeout, _response_timeout); |
86 | 93 | return NetworkConnectionState::CONNECTING;
|
87 | 94 | }
|
88 | 95 | } else {
|
89 |
| - if (Ethernet.begin(nullptr, 15000, 4000) == 0) { |
| 96 | + if (Ethernet.begin(nullptr, _timeout, _response_timeout) == 0) { |
90 | 97 | Debug.print(DBG_ERROR, F("Waiting Ethernet configuration from DHCP server, check cable connection"));
|
| 98 | + Debug.print(DBG_VERBOSE, "timeout: %d, response timeout: %d", _timeout, _response_timeout); |
91 | 99 | return NetworkConnectionState::CONNECTING;
|
92 | 100 | }
|
93 | 101 | }
|
|
0 commit comments