]> jspc29.x-matter.uni-frankfurt.de Git - avr.git/commitdiff
LANTelnetToSerial_Board: add comments, code gets a new structure
authorOle Artz <ole.artz@t-online.de>
Tue, 19 Jul 2022 09:23:50 +0000 (11:23 +0200)
committerOle Artz <ole.artz@t-online.de>
Tue, 19 Jul 2022 09:23:50 +0000 (11:23 +0200)
esp32/EthernetUART/LANTelnetToSerial_Board/LANTelnetToSerial_Board.ino

index 7bd70590f7112a2c50253a186c74e5420ca23865..ec7611520ab1e76ad725e6a7385714d30dfcebbf 100644 (file)
@@ -8,13 +8,13 @@
 # ### author: O.Artz                            ### #
 # ###                                           ### #
 # ###                                           ### #
-# ### UPDATE 2020-07-22                         ### #
+# ### UPDATE 2022-19-07                         ### #
 # ###                                           ### #
 #####################################################
 
 ETH MAC: 24:6F:28:1E:C5:57 
-IPv4: 192.168.8.64
-Telnet: 192.168.8.64 2323
+IPv4: 192.168.8.NN    NN = Labelnumber w/o 2 f.e. 268 -> 68
+Telnet: 192.168.8.68 2323
 
 Visual Status via Board LEDs:
 ETH Start                 -> Green LED blink for 1 sec
@@ -24,9 +24,8 @@ ETH Disconnected/stopped  -> Orange LED on
 
 //load needed Libaries
 #include <ETH.h>
-//#include <WiFi.h>
 
-//how many clients should be able to telnet to this ESP32
+//number of clients for this telnet server
 #define MAX_SRV_CLIENTS 10
 
 WiFiServer server(2323);
@@ -35,8 +34,7 @@ WiFiClient serverClients[MAX_SRV_CLIENTS];
 //used to check the number every time, cause could changed
 volatile static bool eth_connected = false;
 
-void WiFiEvent(WiFiEvent_t event)
-{
+void WiFiEvent(WiFiEvent_t event) {
   switch (event){
     case SYSTEM_EVENT_ETH_START:
       Serial.println("ETH Started");
@@ -87,15 +85,14 @@ void WiFiEvent(WiFiEvent_t event)
   }
 }
 
-void setup()
-{
+void setup() {
   pinMode(2, OUTPUT); // yellow LED
   pinMode(15, OUTPUT); // green LED 
   Serial.begin(57600);
   Serial.println("\nConnecting");
   WiFi.onEvent(WiFiEvent);
   delay(1000);
-  //start UART and the server
+  //start UART and the telnet server
   ETH.begin(1,17,23,18,ETH_PHY_LAN8720,ETH_CLOCK_GPIO0_IN);
   server.begin();
   server.setNoDelay(true);
@@ -110,8 +107,7 @@ void setup()
   digitalWrite(15,HIGH);
 }
 
-void loop()
-{
+void loop() {
   uint8_t i;
   if (eth_connected == true) {
     //check if there are any new clients
@@ -161,12 +157,4 @@ void loop()
       }
     }
   }
-  /*
-  else {
-    Serial.println("WiFi not connected!");
-    for(i = 0; i < MAX_SRV_CLIENTS; i++) {
-      if (serverClients[i]) serverClients[i].stop();
-    }
-    setup();
-  }*/
 }