![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Diff: utils.cpp
- Revision:
- 53:bb492a8f115a
- Parent:
- 50:d9b6577a70f5
- Child:
- 54:448d57291be6
diff -r 12930cef17c4 -r bb492a8f115a utils.cpp --- a/utils.cpp Mon Oct 20 19:44:16 2014 +0000 +++ b/utils.cpp Tue Oct 21 19:35:07 2014 +0000 @@ -221,10 +221,49 @@ } void build_telemetry_report( int ext, int port, char * data ){ - pc.printf("Telemetry pkg from ( %i, %i ) ::\n\r", ext, port ); - for( register int i = 0; i < __TELEMETRY_SIZE__; i++ ) + /* + pc.printf("\n\r 1. "); + uint8_t count = 2; + for( register int i = 0; i < __TELEMETRY_SIZE__; i++ ){ + if( i > 0 && !( i % 15 ) ) pc.printf("\n\r%2u. ", count++ ); pc.printf("%3i ", data[ i ] ); + } pc.printf("\n\r"); + */ + char aux[ __CB_BUFFER_SIZE__ ]; + char tmp[ 6 ]; + strcpy( aux, itoa( ext, tmp, 10 ) ); + strcat( aux, " " ); + strncat( aux, (char * )data, __TELEMETRY_SIZE__ ); + + pc.printf("\n\r 1. "); + uint8_t count = 2; + for( register int i = 0; i < __CB_BUFFER_SIZE__; i++ ){ + if( i > 0 && !( i % 15 ) ) pc.printf("\n\r%2u. ", count++ ); + pc.printf("%3i ", aux[ i ] ); + } + pc.printf("\n\r"); + + if( tcp_session ) tcp_client.send_all( ( char *)aux, strlen( (char * )aux ) ); + + UDPSocket t_sock; + Endpoint t_server; + + int adr = t_server.set_address( __TELEMETRY_SERVER_IP__ , __TELEMETRY_SERVER_PORT__ ); + if( debug_telemetry ) send_msg("Valor de retorno adr -- %d", adr ); + t_sock.set_blocking( false, 1 ); + + int bind = t_sock.bind( __TELEMETRY_HEADER_PORT__ ); + if( debug_telemetry ) send_msg("Valor de retorno bind -- %d", bind ); + + //int init = t_sock.init(); + //if( debug_telemetry ) send_msg("Valor de retorno init -- %d", init ); + + int ret = t_sock.sendTo( t_server, aux, strlen( aux ) ); + if( debug_telemetry ) send_msg("Valor de retorno sent-- %d", ret ); + + int close = t_sock.close(); + if( debug_telemetry ) send_msg("Valor de retorno close-- %d", close ); } void __send_to_cb__( uint8_t * buffer ){