Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Teensy 4.1 and the QNEthernet library #128

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
ARDUINOCORE_MBED_STAGING_PATH: extras/ArduinoCore-mbed
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/ConnectionHandlerDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@
#define NETWORK_CONNECTED WL_CONNECTED
#endif

#if defined(ARDUINO_TEENSY41)
#define BOARD_HAS_ETHERNET
#endif

#endif // BOARD_HAS_NOTECARD

/******************************************************************************
Expand Down
12 changes: 12 additions & 0 deletions src/EthernetConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down
4 changes: 4 additions & 0 deletions src/EthernetConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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