![](/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: vz_protocol.cpp
- Revision:
- 14:22a35f575502
- Parent:
- 4:de46f0d9b14d
- Child:
- 17:67a6b557eda5
--- a/vz_protocol.cpp Tue Sep 16 15:09:11 2014 +0000 +++ b/vz_protocol.cpp Tue Sep 16 21:02:37 2014 +0000 @@ -55,6 +55,7 @@ } } uint8_t * __build_cb_package__( int ext, int port, uint8_t type, char * cb_buffer, uint8_t seq_num, int length, uint8_t * pkg ){ + debug_msg(""); pkg[ 0 ] = ( uint8_t )( ( ext & 0xFF00 ) >> 8 ); pkg[ 1 ] = ( uint8_t )( ext & 0x00FF ); pkg[ 2 ] = ( uint8_t )( ( port & 0xFF00 ) >> 8 ); @@ -75,7 +76,7 @@ fill = __TIMESLICE_PLACE__ + 1; }else if( type == __REGISTRY__ || type == __BOOT__ ){ pkg[ 7 ] = seq_num; - __print_clock__( pkg + 8 ); + //__print_clock__( pkg + 8 ); fill = __VZ_HEADER_OFFSET__ + __CLOCK_SYNC_SIZE__ + __SEQ_NUM_SIZE__; }if( type == __CB_BYE__ ){ pkg[ 7 ] = seq_num; @@ -84,7 +85,7 @@ fill = __TIMESLICE_PLACE__ + 1; }else if( type == __TELEMETRY__ ){ pkg[ 7 ] = seq_num; - __print_clock__( pkg + 8 ); + //__print_clock__( pkg + 8 ); pkg[ __TIMESLICE_PLACE__ ] = cb_buffer[ __TIMESLICE_PLACE__ ]; fill = __TIMESLICE_PLACE__ + 1; } @@ -96,6 +97,7 @@ pkg[ 4 ] =( uint8_t )( ( cc & 0xFF00 ) >> 8) ; pkg[ 5 ] =( uint8_t )( cc & 0x00FF ); + debug_msg(""); return pkg; } @@ -141,14 +143,23 @@ } void __print_clock__( uint8_t * buffer ){ + debug_msg(""); NTPClient ntp; - ntp.setTime( "200.192.232.8", 123, 3 ); - time_t seconds; - // seconds = time(NULL); + debug_msg(""); + //int ntp_result = ntp.setTime( "200.192.232.8", 123, 3 ); struct tm ts; - time( &seconds ); - ts = *localtime( &seconds ); + int ntp_result = ntp.setTime( "200.192.232.8" ); + if( ntp_result == 0 ){ + debug_msg(""); + time_t seconds; + debug_msg(""); + // seconds = time(NULL); + time( &seconds ); + debug_msg(""); + ts = *localtime( &seconds ); + } + debug_msg(""); int ano = ts.tm_year + 1900; int mes = ts.tm_mon + 1; int dia = ts.tm_mday; @@ -176,4 +187,5 @@ /* convertendo pro ascii do nro */ for( register int i = 0; i < 14; i++ ) buffer[ i ] += 0x30; + debug_msg(""); } \ No newline at end of file