From 09ac732dcc98723926bd412f8d422d03992f5f73 Mon Sep 17 00:00:00 2001 From: Shawn Silverman Date: Tue, 17 Sep 2024 21:03:54 -0700 Subject: [PATCH 1/2] Add support for Teensy 4.1 and the QNEthernet library --- src/ConnectionHandlerDefinitions.h | 4 ++++ src/EthernetConnectionHandler.cpp | 12 ++++++++++++ src/EthernetConnectionHandler.h | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/src/ConnectionHandlerDefinitions.h b/src/ConnectionHandlerDefinitions.h index 4f29559..d090ec9 100644 --- a/src/ConnectionHandlerDefinitions.h +++ b/src/ConnectionHandlerDefinitions.h @@ -151,6 +151,10 @@ #define NETWORK_CONNECTED WL_CONNECTED #endif +#if defined(ARDUINO_TEENSY41) + #define BOARD_HAS_ETHERNET +#endif + #endif // BOARD_HAS_NOTECARD /****************************************************************************** diff --git a/src/EthernetConnectionHandler.cpp b/src/EthernetConnectionHandler.cpp index 14f7aee..ac1e1e1 100644 --- a/src/EthernetConnectionHandler.cpp +++ b/src/EthernetConnectionHandler.cpp @@ -88,13 +88,21 @@ NetworkConnectionState EthernetConnectionHandler::update_handleInit() NetworkConnectionState EthernetConnectionHandler::update_handleConnecting() { if (_ip != INADDR_NONE) { +#if defined(ARDUINO_TEENSY41) + if (Ethernet.begin(nullptr, _ip, _dns, _gateway, _netmask) == 0) { +#else if (Ethernet.begin(nullptr, _ip, _dns, _gateway, _netmask, _timeout, _response_timeout) == 0) { +#endif Debug.print(DBG_ERROR, F("Failed to configure Ethernet, check cable connection")); Debug.print(DBG_VERBOSE, "timeout: %d, response timeout: %d", _timeout, _response_timeout); return NetworkConnectionState::CONNECTING; } } else { +#if defined(ARDUINO_TEENSY41) + if (Ethernet.begin(nullptr, _timeout) == 0) { +#else if (Ethernet.begin(nullptr, _timeout, _response_timeout) == 0) { +#endif Debug.print(DBG_ERROR, F("Waiting Ethernet configuration from DHCP server, check cable connection")); Debug.print(DBG_VERBOSE, "timeout: %d, response timeout: %d", _timeout, _response_timeout); return NetworkConnectionState::CONNECTING; @@ -119,7 +127,11 @@ NetworkConnectionState EthernetConnectionHandler::update_handleConnected() NetworkConnectionState EthernetConnectionHandler::update_handleDisconnecting() { +#if defined(ARDUINO_TEENSY41) + Ethernet.end(); +#else Ethernet.disconnect(); +#endif return NetworkConnectionState::DISCONNECTED; } diff --git a/src/EthernetConnectionHandler.h b/src/EthernetConnectionHandler.h index 35a02cd..1521491 100644 --- a/src/EthernetConnectionHandler.h +++ b/src/EthernetConnectionHandler.h @@ -30,6 +30,10 @@ #elif defined(ARDUINO_OPTA) #include #include +#elif defined(ARDUINO_TEENSY41) + #include + + using namespace qindesign::network; #endif #ifndef BOARD_HAS_ETHERNET From ddaf6942bf9284401835319bfa78c598b9579f55 Mon Sep 17 00:00:00 2001 From: Shawn Silverman Date: Tue, 17 Sep 2024 21:20:23 -0700 Subject: [PATCH 2/2] Add Teensy 4.1 entries to compile-examples.yml --- .github/workflows/compile-examples.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 808258e..6713a7d 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -36,6 +36,7 @@ jobs: - name: MKRWAN - name: Arduino_Cellular - name: Blues Wireless Notecard + - name: QNEthernet SKETCH_PATHS: | - examples/ConnectionHandlerDemo ARDUINOCORE_MBED_STAGING_PATH: extras/ArduinoCore-mbed @@ -104,6 +105,9 @@ jobs: - fqbn: "rp2040:rp2040:rpipicow" platform-name: rp2040:rp2040 artifact-name-suffix: rp2040-rp2040-rpipicow + - fqbn: "teensy:avr:teensy41" + platform-name: teensy:avr + artifact-name-suffix: teensy-avr-teensy41 # Make board type-specific customizations to the matrix jobs include: @@ -192,6 +196,14 @@ jobs: source-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json sketch-paths: | - examples/ConnectionHandlerDemo-Notecard + - board: + platform-name: teensy:avr + platforms: | + # Install Teensy platform via Boards Manager + - name: teensy:avr + source-url: https://www.pjrc.com/teensy/package_teensy_index.json + sketch-paths: | + - examples/ConnectionHandlerDemo steps: - uses: actions/checkout@v4