![](/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:
- 3:cd9148672e25
- Parent:
- 2:93bec7313ccc
- Child:
- 4:de46f0d9b14d
diff -r 93bec7313ccc -r cd9148672e25 main.cpp --- a/main.cpp Wed Sep 10 14:32:19 2014 +0000 +++ b/main.cpp Wed Sep 10 18:21:48 2014 +0000 @@ -103,14 +103,14 @@ data = __parse_cb_buffer__( &ext, &port, &type, buffer ); - if( data != NULL ){ - + if( data != NULL ){ if( type == __CB_BYE__ ){ debug_msg("--> %s <--", buffer); } if( type != __AUDIO__ ){ 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() ){ @@ -121,19 +121,16 @@ debug_msg("-- Renviado ultimo pkg --"); }else if( data[ 0 ] == ( cb->get_msg_id() | BIT7 ) ){ // ack from CBx + debug_msg("-- ACK do meu pkg --"); type = __DO_NOTHING__; - debug_msg("-- ACK do meu pkg --"); + debug_msg("morri aqui"); } } } } }else type = __DO_NOTHING__; - /* - if( data == NULL ) type = __DO_NOTHING__; - */ } //---------------------- -/* if( t.read() > 5 ){ for( register uint8_t i = 0; i < v_cb->size(); i++ ){ Call_Box * cb = ( Call_Box * )v_cb->get_element( i ); @@ -142,7 +139,6 @@ t.reset(); led3 = !led3; } -*/ //---------------------- switch( type ){ case __DO_NOTHING__ :{} @@ -167,6 +163,7 @@ __send_to_cb__( __build_cb_package__( ext, port, __CB_BYE__, ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); set_status( cb->sip->status, sip_idle ); + delete( call ); } } } @@ -216,7 +213,7 @@ debug_msg(" -- %d on %d -- ", cb->get_ext(), data[ __TIMESLICE_PLACE__ ] ); - cb->set_msg_id( ( ( cb->get_msg_id() ) + 1 ) & ( BIT7 ^ 0xff ) ); + cb->set_msg_id( ( ( cb->get_msg_id() ) + 1 ) & ( BIT7 ^ 0xff ) ); VZ_call * call = cb->invite(); if( call != NULL ){ @@ -249,21 +246,23 @@ }break; case __REGISTRY__ : { - Call_Box * cb_master; - Call_Box * cb_slave; + Call_Box * cb_master = NULL; + Call_Box * cb_slave = NULL; data[ 0 ] |= BIT7; cb_master = __find_CB__( v_cb, ext ); - cb_slave = __find_CB__( v_cb, ext+1 ); + cb_slave = __find_CB__( v_cb, ext + 1 ); if( cb_master != NULL ){ cb_master->reset_elapsed_time(); - }else if( cb_slave != NULL ){ + }else if( cb_slave != NULL ){ cb_slave->reset_elapsed_time(); }else{ cb_master = new Call_Box( ext, port ); cb_slave = new Call_Box( ext + 1, port + 1 ); + v_cb->add( cb_master ); v_cb->add( cb_slave ); + debug_msg("Registrados"); } cb_master->registry(); cb_slave->registry();