Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Revision:
68:b54993674190
Parent:
67:cdedc64d9921
Child:
69:65665afbad5d
--- a/main.cpp	Thu Oct 30 19:26:41 2014 +0000
+++ b/main.cpp	Fri Nov 07 17:57:55 2014 +0000
@@ -18,7 +18,7 @@
     
     init_fsystem();
     
-    // pensar melhor em como saber se estou conectado na eth
+    //FIXMEj pensar melhor em como saber se estou conectado na eth
     //int eth_status = __init_eth__( &eth );
     int eth_status = __init_eth__();
         
@@ -94,15 +94,20 @@
     
     reset_leds();
     udp_timer.start();
-    send_msg("Ready");
-    uint8_t before = t.read();
+    
+    init_telemetry_handler();
+    
     static uint8_t count = 0;
     int bl_ret = init_bl_handler();
     if( dbl ) send_msg("Valor de retorno do bl_habdler = %d", bl_ret );
     
+    uint8_t before = t.read();
+    
+    send_msg("Ready");
+    
     /*------------------------------------------------ main loop -------------------------------------------------------------------------*/
     while( true ){
-        //FIXME colocar uma condicao aqui caso necessario pra nao comprometer ligacoes ...
+        //FIXMEj colocar uma condicao aqui caso necessario pra nao comprometer ligacoes ...
         prompt_process( NULL );
         wdt.kick();
         
@@ -278,8 +283,8 @@
             }
 
             if( t.read() > 5 ){
-                static int test_ext = 5010;
-                static int test_port = 5010;
+                //static int test_ext = 5010;
+                //static int test_port = 5010;
                 //send_msg("from_eth = %s - tcp_session = %s", ( from_eth ) ? "true" : "false", ( tcp_session ) ? "true" : "false" );
                 if( debug_alive ){
                     send_msg("Registred %d CBx", v_cb->size() );
@@ -318,9 +323,21 @@
                 
                 if( main_test ){
                     data = buffer;
-                    ext = test_ext++ + ( ( test_ext % 2  ) ? 100 : 50 );
-                    port = test_port++;
-                    type = __REGISTRY__;
+                    //ext = test_ext++ + ( ( test_ext % 2  ) ? 100 : 50 );
+                    //port = test_port++;
+                    //type = __REGISTRY__;
+                    type = __TELEMETRY__;
+                    ext = 5108;
+                    port = 5008;
+                    uint8_t var = 0xAA;
+                    for( register uint16_t i = 0; i < __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__; i++ ){
+                        data[ i ] = var++;
+                        if( var == 0xFF ) var = 0xAA;
+                    }
+                    for( register uint16_t i = __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__; i < __CB_BUFFER_SIZE__; i++ ){
+                        data[ i ] = 0x00;
+                    }
+                    main_test = false;
                 }
                 
                 /*
@@ -391,7 +408,7 @@
                 set_status( cb->status, cb_trying );
                 if( debug_main ) debug_msg("Request invite cbx status :: %d", cb->status );
                 
-                //FIXME essa logica deve estar la embaixo, fora do switch maior, a ideia eh
+                //FIXMEj essa logica deve estar la embaixo, fora do switch maior, a ideia eh
                 // quando receber um pedido de invite, apenas manda o invite pro server
                 // dai rodar, ver se alguem mandou alguma coisa e voltar a tratar com o 
                 // * ver se ja esta tudo ok, a ideia é fazer esse pedido de invite funcionar
@@ -579,7 +596,7 @@
                     }
                     __send_to_cb__( __build_cb_package__( ext, port, __CB_BYE__, 
                         ( char * )buffer, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) );
-                    //FIXME talvez eu nao precise dessa linha mudar o set_status( cb->sip->status, sip_idle ); pra ver o que acontece
+                    //FIXMEj talvez eu nao precise dessa linha mudar o set_status( cb->sip->status, sip_idle ); pra ver o que acontece
                     //cb->reset_sip();
                     set_status( cb->sip->status, sip_idle );
                     cb->re_start_timer();