nova proba

Revision:
21:2232f5a34eb4
Parent:
20:d8277082f4e3
Child:
22:11279d24a105
diff -r d8277082f4e3 -r 2232f5a34eb4 main.cpp
--- a/main.cpp	Sat May 23 23:37:10 2020 +0200
+++ b/main.cpp	Mon May 25 22:19:36 2020 +0200
@@ -1,13 +1,13 @@
 #include "mbed.h"
 #include "clubbing.h"
 #include "EthernetSetup.h"
-#include "UdpToScom.h"
+#include "UdpClients.h"
 #include "TcpClients.h"
+#include "SerialCom.h"
 #include "TcpServerToFlash.h"
-#include "dxml.h"
+//#include "dxml.h"
 #include "doHTML.h"
 #include "dataFlash.h"
-#include "string.h"
 
 
 
@@ -17,6 +17,8 @@
 
 
 DigitalOut GLed(LED2,1);
+DigitalOut BLed(LED3,1);
+DigitalOut *p_led;
 
 void pfv_fun( void ) 
 {
@@ -134,24 +136,49 @@
    // showFlashData(  );
 
 
-//    init_EthToScom(  );
+   //extern EthernetInterface *gp_eth;
 
-   extern EthernetInterface *gp_eth;
+
+   
 
-   init_EthToScom(  );
-  //tcpRxThreadsRiseUp(  );
+  if( ethernet_setup(  ) )
+  {
+    start_TcpClients( );
+    start_UdpClients( );
+     inic_TcpServerToFlash(  );
+     p_led = &GLed;
+  }
+  else p_led = &BLed;
 
-//    gp_eth = ethernet_setup(  );
-     inic_TcpServerToFlash(  );
+  start_SerialCom( );
 
 extern void test_HTML(void);
 //    test_HTML( );
 
     
 int i=0;
+
+int s = getEthernetStatus();
+if( s == 1 ) p_led = &GLed;
+else         p_led = &BLed;
+int k = s;
+
     while(true)
     {
-       if(i++ >10 ) { i=0;  GLed = !GLed;}
+       if(i++ >10 ) 
+       { 
+           i=0;  
+           s = getEthernetStatus();
+           if( s != k)
+           {
+               *p_led = 1;
+                if( s == 1 )        p_led = &GLed;
+                else if( s == 3)    p_led = &BLed; 
+                k = s;
+           }
+           else *p_led = !*p_led;
+
+        }
         wait(0.01);  
     }