nova proba

Revision:
9:893843262a1f
Parent:
5:c9a908749d4c
Child:
12:cbfc10c15437
--- a/Ethernet/EthernetSetup.cpp	Sun Apr 19 22:13:45 2020 +0000
+++ b/Ethernet/EthernetSetup.cpp	Wed Apr 22 13:21:50 2020 +0000
@@ -1,9 +1,9 @@
 #include "EthernetSetup.h"
 #include "clubbing.h"
-
+#include "doHTML.h"
 
-EthernetInterface eth;
-
+EthernetInterface eth, *gp_eth= ð
+extern C_HTMLparse * gpc_html;
 
 struct S_EthernetAddress
 /*{
@@ -26,21 +26,48 @@
 
 int test_EthAdd( struct S_EthernetAddress* ps_ea)
 {
-  if( !(test_ip(ps_ea->ip)) ) { printf("pogresan ip: %s\n\r", ps_ea->ip); return 0; } 
-  if( !(test_ip(ps_ea->mask)) )     { printf("pogresna maska: %s\r\n", ps_ea->mask); return 0; } 
-  if( !(test_ip(ps_ea->gate)) )   { printf("pogresan gate: %s\n\r", ps_ea->gate); return 0; }
+
   return 1;  
 }
 
+void ethCancel( void )
+{
+     gp_eth->disconnect();           /* gasenje ethernta */
+}
+
+void ethRiseUp( void )
+{     
+     gp_eth = ethernet_setup(  );    /*paljenje etherneta*/
+     if(gp_eth == NULL) printf("ethernet greska\n\r"); 
+     else printf("eth OK\n\r");
+}
+
+void ethRestart( void )
+{
+    ethCancel(  );
+    ethRiseUp(  );
+}
+
+
+
+void do_ethAddr( void )
+{
+   strcpy( s_net.ps_ea->ip, gpc_html->get_myIP( ));
+   strcpy( s_net.ps_ea->mask, gpc_html->get_myMASK( ));
+   strcpy( s_net.ps_ea->gate, gpc_html->get_myGATE( ));
+    
+}
+
 EthernetInterface * ethernet_setup( void )
 {
   //  if( (err = eth.disconnect()) != NSAPI_ERROR_OK )  { printf(" greska diskonekcije %d \n\r", err); return 1; } 
   //  ((NetworkInterface *)&eth)->set_network("192.168.1.11","255.255.255.0","192.168.1.1");
      
-     if( test_EthAdd( &s_EthAddFlash )) { printf("upisana ip adresa sa DataFlash-a\n\r"); }
-     else if( test_EthAdd( &s_EthAdd )) { printf("upisana ip adresa sa ProgFlash-a\n\r"); }
-     else                            { printf("neispravne ip adrese!!!\n\r"); return NULL;}
+//     if( test_EthAdd( &s_EthAddFlash )) { printf("upisana ip adresa sa DataFlash-a\n\r"); }
+//     else if( test_EthAdd( &s_EthAdd )) { printf("upisana ip adresa sa ProgFlash-a\n\r"); }
+//     else                            { printf("neispravne ip adrese!!!\n\r"); return NULL;}
      
+     do_ethAddr( );
      if( (err = s_net.p_eth->set_network(s_net.ps_ea->ip, s_net.ps_ea->mask, s_net.ps_ea->gate))!= NSAPI_ERROR_OK )  { printf(" greska setovanja mreze %d \n\r", err);  } 
      
      else  if( (err = s_net.p_eth->connect())  != NSAPI_ERROR_OK )  { printf(" greska konekcije %d \n\r", err); }