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

Added Example and Bug fixes on Ethernet #70

Open
wants to merge 2 commits into
base: ethernet
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
10 changes: 10 additions & 0 deletions examples/ConnectionHandlerDemo/ConnectionHandlerDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* NBConnectionHandler conMan(SECRET_PIN);
*/


//#define ARDUINO_ETHERNET_SHIELD /* Uncomment this line if you want to use a ethernet shield */

#include "arduino_secrets.h"

#include <Arduino_ConnectionHandler.h>
Expand All @@ -28,11 +31,18 @@ GSMConnectionHandler conMan(SECRET_APN, SECRET_PIN, SECRET_GSM_USER, SECRET_GSM_
NBConnectionHandler conMan(SECRET_PIN);
#elif defined(BOARD_HAS_LORA)
LoRaConnectionHandler conMan(SECRET_APP_EUI, SECRET_APP_KEY);
#elif defined(BOARD_HAS_ETHERNET)
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Teensy 4.0 and 4.1 have a built-in MAC address that should be used instead. Perhaps a board check here is appropriate.

EthernetConnectionHandler conMan(mac);
#endif

void setup() {
Serial.begin(9600);
/* Give a few seconds for the Serial connection to be available */
#if defined(BOARD_HAS_ETHERNET)
SPI.begin();
Ethernet.init(10); // CS pin on most Arduino shields
#endif
delay(4000);

setDebugMessageLevel(DBG_INFO);
Expand Down
2 changes: 1 addition & 1 deletion src/Arduino_ConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class ConnectionHandler {

NetworkConnectionState check();

#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB)
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET)
virtual unsigned long getTime() = 0;
virtual Client &getClient() = 0;
virtual UDP &getUDP() = 0;
Expand Down