@@ -74,12 +74,19 @@ NetworkConnectionState EthernetConnectionHandler::update_handleInit()
74
74
75
75
// An ip address is provided -> static ip configuration
76
76
if (ip != INADDR_NONE) {
77
+ #if defined(ARDUINO_TEENSY41)
78
+ if (Ethernet.begin (nullptr , ip,
79
+ IPAddress (_settings.eth .dns .type , _settings.eth .dns .bytes ),
80
+ IPAddress (_settings.eth .gateway .type , _settings.eth .gateway .bytes ),
81
+ IPAddress (_settings.eth .netmask .type , _settings.eth .netmask .bytes )) == 0 ) {
82
+ #else
77
83
if (Ethernet.begin (nullptr , ip,
78
84
IPAddress (_settings.eth .dns .type , _settings.eth .dns .bytes ),
79
85
IPAddress (_settings.eth .gateway .type , _settings.eth .gateway .bytes ),
80
86
IPAddress (_settings.eth .netmask .type , _settings.eth .netmask .bytes ),
81
87
_settings.eth .timeout ,
82
88
_settings.eth .response_timeout ) == 0 ) {
89
+ #endif // ARDUINO_TEENSY41
83
90
84
91
DEBUG_ERROR (F (" Failed to configure Ethernet, check cable connection" ));
85
92
DEBUG_VERBOSE (" timeout: %d, response timeout: %d" ,
@@ -88,7 +95,11 @@ NetworkConnectionState EthernetConnectionHandler::update_handleInit()
88
95
}
89
96
// An ip address is not provided -> dhcp configuration
90
97
} else {
98
+ #if defined(ARDUINO_TEENSY41)
99
+ if (Ethernet.begin (nullptr , _settings.eth .timeout ) == 0 ) {
100
+ #else
91
101
if (Ethernet.begin (nullptr , _settings.eth .timeout , _settings.eth .response_timeout ) == 0 ) {
102
+ #endif // ARDUINO_TEENSY41
92
103
DEBUG_ERROR (F (" Waiting Ethernet configuration from DHCP server, check cable connection" ));
93
104
DEBUG_VERBOSE (" timeout: %d, response timeout: %d" ,
94
105
_settings.eth .timeout , _settings.eth .response_timeout );
@@ -110,6 +121,10 @@ NetworkConnectionState EthernetConnectionHandler::update_handleConnecting()
110
121
return NetworkConnectionState::CONNECTED;
111
122
}
112
123
124
+ #if defined(ARDUINO_TEENSY41)
125
+ DEBUG_INFO (F (" Connected to network" ));
126
+ return NetworkConnectionState::CONNECTED;
127
+ #else
113
128
int ping_result = Ethernet.ping (" time.arduino.cc" );
114
129
DEBUG_INFO (F (" Ethernet.ping(): %d" ), ping_result);
115
130
if (ping_result < 0 )
@@ -123,6 +138,7 @@ NetworkConnectionState EthernetConnectionHandler::update_handleConnecting()
123
138
DEBUG_INFO (F (" Connected to Internet" ));
124
139
return NetworkConnectionState::CONNECTED;
125
140
}
141
+ #endif // ARDUINO_TEENSY41
126
142
127
143
}
128
144
@@ -141,7 +157,11 @@ NetworkConnectionState EthernetConnectionHandler::update_handleConnected()
141
157
142
158
NetworkConnectionState EthernetConnectionHandler::update_handleDisconnecting ()
143
159
{
160
+ #if defined(ARDUINO_TEENSY41)
161
+ Ethernet.end ();
162
+ #else
144
163
Ethernet.disconnect ();
164
+ #endif
145
165
return NetworkConnectionState::DISCONNECTED;
146
166
}
147
167
0 commit comments