Skip to content

Commit 4e68980

Browse files
committed
Extend example adding ethernet connection handler
1 parent 2462ec0 commit 4e68980

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

examples/ConnectionHandlerDemo/ConnectionHandlerDemo.ino

+14-1
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,26 @@
1414
* If using a MKR NB1500 you'll need a NBConnectionHandler object as follows
1515
*
1616
* NBConnectionHandler conMan(SECRET_PIN);
17+
*
18+
* If using a Portenta + Ethernet shield you'll need a EthernetConnectionHandler object as follows:
19+
*
20+
* DHCP mode
21+
* EthernetConnectionHandler conMan();
22+
*
23+
* Manual configuration
24+
* EthernetConnectionHandler conMan(SECRET_IP, SECRET_DNS, SECRET_GATEWAY, SECRET_NETMASK);
25+
*
26+
* Manual configuration will fallback on DHCP mode if SECRET_IP is invalid or equal to INADDR_NONE.
27+
*
1728
*/
1829

1930
#include "arduino_secrets.h"
2031

2132
#include <Arduino_ConnectionHandler.h>
2233

23-
#if defined(BOARD_HAS_WIFI)
34+
#if defined(BOARD_HAS_ETHERNET)
35+
EthernetConnectionHandler conMan(SECRET_IP, SECRET_DNS, SECRET_GATEWAY, SECRET_NETMASK);
36+
#elif defined(BOARD_HAS_WIFI)
2437
WiFiConnectionHandler conMan(SECRET_SSID, SECRET_PASS);
2538
#elif defined(BOARD_HAS_GSM)
2639
GSMConnectionHandler conMan(SECRET_APN, SECRET_PIN, SECRET_GSM_USER, SECRET_GSM_PASS);

examples/ConnectionHandlerDemo/arduino_secrets.h

+5
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ const char SECRET_GSM_PASS[] = "GSM PASSWORD";
88

99
const char SECRET_APP_EUI[] = "APP_EUI";
1010
const char SECRET_APP_KEY[] = "APP_KEY";
11+
12+
const char SECRET_IP[] = "IP ADDRESS";
13+
const char SECRET_DNS[] = "DNS ADDRESS";
14+
const char SECRET_GATEWAY[] = "GATEWAY ADDRESS";
15+
const char SECRET_NETMASK[] = "NETWORK MASK";

0 commit comments

Comments
 (0)