@@ -74,12 +74,19 @@ NetworkConnectionState EthernetConnectionHandler::update_handleInit()
7474
7575 // An ip address is provided -> static ip configuration
7676 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
7783 if (Ethernet.begin (nullptr , ip,
7884 IPAddress (_settings.eth .dns .type , _settings.eth .dns .bytes ),
7985 IPAddress (_settings.eth .gateway .type , _settings.eth .gateway .bytes ),
8086 IPAddress (_settings.eth .netmask .type , _settings.eth .netmask .bytes ),
8187 _settings.eth .timeout ,
8288 _settings.eth .response_timeout ) == 0 ) {
89+ #endif // ARDUINO_TEENSY41
8390
8491 DEBUG_ERROR (F (" Failed to configure Ethernet, check cable connection" ));
8592 DEBUG_VERBOSE (" timeout: %d, response timeout: %d" ,
@@ -88,7 +95,11 @@ NetworkConnectionState EthernetConnectionHandler::update_handleInit()
8895 }
8996 // An ip address is not provided -> dhcp configuration
9097 } else {
98+ #if defined(ARDUINO_TEENSY41)
99+ if (Ethernet.begin (nullptr , _settings.eth .timeout ) == 0 ) {
100+ #else
91101 if (Ethernet.begin (nullptr , _settings.eth .timeout , _settings.eth .response_timeout ) == 0 ) {
102+ #endif // ARDUINO_TEENSY41
92103 DEBUG_ERROR (F (" Waiting Ethernet configuration from DHCP server, check cable connection" ));
93104 DEBUG_VERBOSE (" timeout: %d, response timeout: %d" ,
94105 _settings.eth .timeout , _settings.eth .response_timeout );
@@ -110,6 +121,10 @@ NetworkConnectionState EthernetConnectionHandler::update_handleConnecting()
110121 return NetworkConnectionState::CONNECTED;
111122 }
112123
124+ #if defined(ARDUINO_TEENSY41)
125+ DEBUG_INFO (F (" Connected to Internet" ));
126+ return NetworkConnectionState::CONNECTED;
127+ #else
113128 int ping_result = Ethernet.ping (" time.arduino.cc" );
114129 DEBUG_INFO (F (" Ethernet.ping(): %d" ), ping_result);
115130 if (ping_result < 0 )
@@ -123,6 +138,7 @@ NetworkConnectionState EthernetConnectionHandler::update_handleConnecting()
123138 DEBUG_INFO (F (" Connected to Internet" ));
124139 return NetworkConnectionState::CONNECTED;
125140 }
141+ #endif // ARDUINO_TEENSY41
126142
127143}
128144
@@ -141,7 +157,11 @@ NetworkConnectionState EthernetConnectionHandler::update_handleConnected()
141157
142158NetworkConnectionState EthernetConnectionHandler::update_handleDisconnecting ()
143159{
160+ #if defined(ARDUINO_TEENSY41)
161+ Ethernet.end ();
162+ #else
144163 Ethernet.disconnect ();
164+ #endif
145165 return NetworkConnectionState::DISCONNECTED;
146166}
147167
0 commit comments