Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
- name: MKRWAN
- name: Arduino_Cellular
- name: Blues Wireless Notecard
- name: QNEthernet
SKETCH_PATHS: |
- examples/ConnectionHandlerDemo
- examples/CheckInternetAvailabilityDemo
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/ConnectionHandlerDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@
#define NETWORK_CONNECTED WL_CONNECTED
#endif

#if defined(ARDUINO_TEENSY41)
#define BOARD_HAS_ETHERNET
#endif

#endif // BOARD_HAS_NOTECARD

/******************************************************************************
Expand Down
20 changes: 20 additions & 0 deletions src/EthernetConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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);
Expand All @@ -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)
Expand All @@ -123,6 +138,7 @@ NetworkConnectionState EthernetConnectionHandler::update_handleConnecting()
DEBUG_INFO(F("Connected to Internet"));
return NetworkConnectionState::CONNECTED;
}
#endif // ARDUINO_TEENSY41

}

Expand All @@ -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;
}

Expand Down
4 changes: 4 additions & 0 deletions src/EthernetConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#elif defined(ARDUINO_OPTA)
#include <Ethernet.h>
#include <PortentaEthernet.h>
#elif defined(ARDUINO_TEENSY41)
#include <QNEthernet.h>

using namespace qindesign::network;
#endif

#ifndef BOARD_HAS_ETHERNET
Expand Down
Loading