Skip to content

Commit 09ac732

Browse files
committed
Add support for Teensy 4.1 and the QNEthernet library
1 parent bbaabd2 commit 09ac732

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/ConnectionHandlerDefinitions.h

+4
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@
151151
#define NETWORK_CONNECTED WL_CONNECTED
152152
#endif
153153

154+
#if defined(ARDUINO_TEENSY41)
155+
#define BOARD_HAS_ETHERNET
156+
#endif
157+
154158
#endif // BOARD_HAS_NOTECARD
155159

156160
/******************************************************************************

src/EthernetConnectionHandler.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,21 @@ NetworkConnectionState EthernetConnectionHandler::update_handleInit()
8888
NetworkConnectionState EthernetConnectionHandler::update_handleConnecting()
8989
{
9090
if (_ip != INADDR_NONE) {
91+
#if defined(ARDUINO_TEENSY41)
92+
if (Ethernet.begin(nullptr, _ip, _dns, _gateway, _netmask) == 0) {
93+
#else
9194
if (Ethernet.begin(nullptr, _ip, _dns, _gateway, _netmask, _timeout, _response_timeout) == 0) {
95+
#endif
9296
Debug.print(DBG_ERROR, F("Failed to configure Ethernet, check cable connection"));
9397
Debug.print(DBG_VERBOSE, "timeout: %d, response timeout: %d", _timeout, _response_timeout);
9498
return NetworkConnectionState::CONNECTING;
9599
}
96100
} else {
101+
#if defined(ARDUINO_TEENSY41)
102+
if (Ethernet.begin(nullptr, _timeout) == 0) {
103+
#else
97104
if (Ethernet.begin(nullptr, _timeout, _response_timeout) == 0) {
105+
#endif
98106
Debug.print(DBG_ERROR, F("Waiting Ethernet configuration from DHCP server, check cable connection"));
99107
Debug.print(DBG_VERBOSE, "timeout: %d, response timeout: %d", _timeout, _response_timeout);
100108
return NetworkConnectionState::CONNECTING;
@@ -119,7 +127,11 @@ NetworkConnectionState EthernetConnectionHandler::update_handleConnected()
119127

120128
NetworkConnectionState EthernetConnectionHandler::update_handleDisconnecting()
121129
{
130+
#if defined(ARDUINO_TEENSY41)
131+
Ethernet.end();
132+
#else
122133
Ethernet.disconnect();
134+
#endif
123135
return NetworkConnectionState::DISCONNECTED;
124136
}
125137

src/EthernetConnectionHandler.h

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
#elif defined(ARDUINO_OPTA)
3131
#include <Ethernet.h>
3232
#include <PortentaEthernet.h>
33+
#elif defined(ARDUINO_TEENSY41)
34+
#include <QNEthernet.h>
35+
36+
using namespace qindesign::network;
3337
#endif
3438

3539
#ifndef BOARD_HAS_ETHERNET

0 commit comments

Comments
 (0)