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