@@ -13,16 +13,6 @@ constexpr char broker[] { SECRET_BROKER };
1313constexpr unsigned port { SECRET_PORT };
1414const char * certificate { SECRET_CERTIFICATE };
1515
16- // Remove comment for using the Ethernet connection
17- // #define USE_ETHERNET_CONNECTION
18-
19- #if defined(USE_ETHERNET_CONNECTION)
20- #include < Ethernet.h>
21- #include < EthernetUdp.h>
22- EthernetConnectionHandler conMan;
23- EthernetClient tcpClient;
24- EthernetUDP NTPUdp;
25- #else
2616#include < WiFi.h>
2717#include < WiFiUdp.h>
2818// Enter your sensitive data in arduino_secrets.h
@@ -31,7 +21,6 @@ constexpr char pass[] { SECRET_PASS };
3121WiFiConnectionHandler conMan (SECRET_SSID, SECRET_PASS);
3222WiFiClient tcpClient;
3323WiFiUDP NTPUdp;
34- #endif
3524
3625NTPClient timeClient (NTPUdp);
3726BearSSLClient sslClient (tcpClient);
@@ -141,10 +130,7 @@ void publishMessage()
141130 String msg = " Hello, World! " ;
142131 msg += millis ();
143132 payload[" message" ] = msg;
144-
145- #if !defined(USE_ETHERNET_CONNECTION)
146133 payload[" rssi" ] = WiFi.RSSI ();
147- #endif
148134
149135 JSONVar message;
150136 message[" ts" ] = static_cast <unsigned long >(time (nullptr ));
@@ -197,11 +183,8 @@ void onMessageReceived(int messageSize)
197183void onNetworkConnect ()
198184{
199185 Serial.println (" >>>> CONNECTED to network" );
200- #if defined(USE_ETHERNET_CONNECTION)
201- printEthernetStatus ();
202- #else
186+
203187 printWifiStatus ();
204- #endif
205188 setNtpTime ();
206189 connectMQTT ();
207190}
@@ -235,13 +218,3 @@ void printWifiStatus()
235218 Serial.println (WiFi.gatewayIP ());
236219 Serial.println ();
237220}
238-
239- void printEthernetStatus ()
240- {
241- // print your board's IP address:
242- Serial.print (" Local IP: " );
243- Serial.println (Ethernet.localIP ());
244- Serial.print (" Local GW: " );
245- Serial.println (Ethernet.gatewayIP ());
246- Serial.println ();
247- }
0 commit comments