diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index ff8b383..0b99645 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 - examples/CheckInternetAvailabilityDemo @@ -105,6 +106,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: @@ -193,6 +197,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@v5 diff --git a/src/ConnectionHandlerDefinitions.h b/src/ConnectionHandlerDefinitions.h index 1534e47..3152299 100644 --- a/src/ConnectionHandlerDefinitions.h +++ b/src/ConnectionHandlerDefinitions.h @@ -144,6 +144,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 9ef06cf..12ce41c 100644 --- a/src/EthernetConnectionHandler.cpp +++ b/src/EthernetConnectionHandler.cpp @@ -74,12 +74,19 @@ NetworkConnectionState EthernetConnectionHandler::update_handleInit() // An ip address is provided -> static ip configuration if (ip != INADDR_NONE) { +#if defined(ARDUINO_TEENSY41) + if (Ethernet.begin(nullptr, ip, + IPAddress(_settings.eth.dns.type, _settings.eth.dns.bytes), + IPAddress(_settings.eth.gateway.type, _settings.eth.gateway.bytes), + IPAddress(_settings.eth.netmask.type, _settings.eth.netmask.bytes)) == 0) { +#else if (Ethernet.begin(nullptr, ip, IPAddress(_settings.eth.dns.type, _settings.eth.dns.bytes), IPAddress(_settings.eth.gateway.type, _settings.eth.gateway.bytes), IPAddress(_settings.eth.netmask.type, _settings.eth.netmask.bytes), _settings.eth.timeout, _settings.eth.response_timeout) == 0) { +#endif // ARDUINO_TEENSY41 DEBUG_ERROR(F("Failed to configure Ethernet, check cable connection")); DEBUG_VERBOSE("timeout: %d, response timeout: %d", @@ -88,7 +95,11 @@ NetworkConnectionState EthernetConnectionHandler::update_handleInit() } // An ip address is not provided -> dhcp configuration } else { +#if defined(ARDUINO_TEENSY41) + if (Ethernet.begin(nullptr, _settings.eth.timeout) == 0) { +#else if (Ethernet.begin(nullptr, _settings.eth.timeout, _settings.eth.response_timeout) == 0) { +#endif // ARDUINO_TEENSY41 DEBUG_ERROR(F("Waiting Ethernet configuration from DHCP server, check cable connection")); DEBUG_VERBOSE("timeout: %d, response timeout: %d", _settings.eth.timeout, _settings.eth.response_timeout); @@ -110,6 +121,10 @@ NetworkConnectionState EthernetConnectionHandler::update_handleConnecting() return NetworkConnectionState::CONNECTED; } +#if defined(ARDUINO_TEENSY41) + DEBUG_INFO(F("Connected to network")); + return NetworkConnectionState::CONNECTED; +#else int ping_result = Ethernet.ping("time.arduino.cc"); DEBUG_INFO(F("Ethernet.ping(): %d"), ping_result); if (ping_result < 0) @@ -123,6 +138,7 @@ NetworkConnectionState EthernetConnectionHandler::update_handleConnecting() DEBUG_INFO(F("Connected to Internet")); return NetworkConnectionState::CONNECTED; } +#endif // ARDUINO_TEENSY41 } @@ -141,7 +157,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 82dc893..5a6ea1f 100644 --- a/src/EthernetConnectionHandler.h +++ b/src/EthernetConnectionHandler.h @@ -26,6 +26,10 @@ #elif defined(ARDUINO_OPTA) #include #include +#elif defined(ARDUINO_TEENSY41) + #include + + using namespace qindesign::network; #endif #ifndef BOARD_HAS_ETHERNET