![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
voltando a versao de n aberturas e fechamentos de sockets data 19/09
Dependencies: EthernetInterface NTPClient mbed-rtos mbed EALib
Fork of header_main_publish by
Diff: main.cpp
- Revision:
- 7:019b08223b87
- Parent:
- 6:a10de9926fbe
- Child:
- 8:e3bfe62a477e
diff -r a10de9926fbe -r 019b08223b87 main.cpp --- a/main.cpp Fri Sep 12 16:46:37 2014 +0000 +++ b/main.cpp Sat Sep 13 19:21:48 2014 +0000 @@ -7,6 +7,8 @@ #include "debug.h" #include "utils.h" +//#define debug_telos + /* #define set_status(a,b) _set_status(a,b) #define _set_status(a,b) { \ @@ -104,18 +106,31 @@ data = __parse_cb_buffer__( &ext, &port, &type, buffer ); if( data != NULL ){ - if( type == __CB_BYE__ ){ - debug_msg("--> %s <--", buffer); + //if( type == __CB_BYE__ ){ + // debug_msg("--> %s <--", buffer); + //} + //debug_msg("Procurando pelo CBx :: %d -- Type :: %d", ext, type ); + if( type != __AUDIO__ ){ +#ifdef debug_telos + debug_msg(""); + debug_32( data ); + debug_msg(""); + __send_to_cb__( buffer ); + debug_msg(""); + type = __DO_NOTHING__; + debug_msg(""); + continue; + debug_msg(""); } - debug_msg("Procurando pelo CBx :: %d -- Type :: %d", ext, type ); - if( type != __AUDIO__ ){ +#endif +#ifndef debug_telos Call_Box * cb = __find_CB__( v_cb, ext ); if( cb != NULL ){ cb->reset_elapsed_time(); if( ( data[ 0 ] ^ cb->get_msg_id() ) == BIT7 ){ // some pkg reply if( ( data[ 0 ] | BIT7 ) == cb->get_msg_id() ){ - if( type == __BOOT__ ) type = __REGISTRY__; + if( type == __BOOT__ ) type = __REGISTRY__; __send_to_cb__( __build_cb_package__( ext, port, type, ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); type = __DO_NOTHING__; @@ -124,10 +139,13 @@ // ack from CBx debug_msg("-- ACK do meu pkg --"); type = __DO_NOTHING__; + cb->reset_elapsed_time(); + if( type == __REGISTRY__ ) cb->set_msg_id( cb->get_msg_id() + 10 ); } } } } +#endif }else type = __DO_NOTHING__; } //---------------------- @@ -168,7 +186,8 @@ } } } - }break; + }break; + case __INVITE__ : { debug_msg("ok -- recebido o invite pelo menos"); Call_Box * cb = __find_CB__( v_cb, ext ); @@ -264,7 +283,6 @@ case __BOOT__ : { __send_to_cb__( __build_cb_package__( ext, port, __REGISTRY__, ( char * )data, data[ 0 ], __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); - debug_msg( "--%s-- reply do boot", write_buffer ); }break; case __TELEMETRY__ : { debug_msg("Leitura da bateria :: ( Id : %x, MSB : %x, LSB : %x )", data[ 0 ], data[ 1 ], data[ 2 ] ); @@ -288,6 +306,7 @@ } }break; }// fim switch +#ifndef debug_telos for( register int i = 0; i < v_call->size(); i++ ){ VZ_call * call = ( VZ_call * )v_call->get_element( i ); int length = 0; @@ -307,6 +326,7 @@ __send_to_cb__( pkg2cb ); } } +#endif //nessa funcao eu deveria me registar a cada 2 min por exemplo registry_aging( v_cb, data, write_buffer );