![](/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: main.cpp
- Revision:
- 71:757fa1ef37c6
- Parent:
- 70:714c33487aae
- Child:
- 72:895ca792c647
--- a/main.cpp Thu Nov 13 19:16:48 2014 +0000 +++ b/main.cpp Mon Nov 17 13:44:53 2014 +0000 @@ -283,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() ); @@ -323,10 +323,10 @@ if( main_test ){ data = buffer; - //ext = test_ext++ + ( ( test_ext % 2 ) ? 100 : 50 ); - //port = test_port++; + ext = test_ext++; + port = test_port++; //type = __REGISTRY__; - type = __TELEMETRY__; + /*type = __TELEMETRY__; ext = 5108; port = 5008; uint8_t var = 0xAA; @@ -337,7 +337,14 @@ for( register uint16_t i = __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__; i < __CB_BUFFER_SIZE__; i++ ){ data[ i ] = 0x00; } - main_test = false; + main_test = false;*/ + Call_Box * cb = new Call_Box( ext, port ); + if( cb != NULL ){ + v_cb->add( cb ); + cb->set_timeslice( ts->get_timeslice() ); + VZ_call * call = new VZ_call( ext, port, 913, 10112 ); + v_call->add( call ); + } } /* @@ -385,6 +392,7 @@ case __INVITE__ : { invite_counter++; if( debug_main ) debug_msg("Request Invite received from Cbx %i", ext); + /*procura pelo cbx usando como chave o ramal( ext ) - caso nao encontre, cria o objeto e coloca na logica*/ Call_Box * cb = __find_CB__( v_cb, ext ); if( cb == NULL ){ if( debug_main ) debug_msg("Adding CBx :: %i", ext ); @@ -394,7 +402,9 @@ cb->registry(); } cb->reset_elapsed_time(); - if( v_call->size() != 0 ){ + /* restricao de que so podemos fazer 1 call por vez */ + /* + if( v_call->size() != 0 ){ data[ 0 ] |= BIT7; cb->set_msg_id( data[ 0 ] ); set_status(cb->status,cb_idle); @@ -405,9 +415,9 @@ if( debug_main ) debug_msg( "denying call - another call box on call" ); break; } + */ set_status( cb->status, cb_trying ); if( debug_main ) debug_msg("Request invite cbx status :: %d", cb->status ); - //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 @@ -435,7 +445,7 @@ data[ __TIMESLICE_PLACE__ ] = 0x00; __send_to_cb__( __build_cb_package__( ext, port, __INVITE__, ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); - set_status( cb->sip->status, sip_idle); + set_status( cb->sip->status, sip_idle ); if( debug_main ) debug_msg( "-- Trying -- without TS -- %s ", write_buffer ); }else{ set_status(cb->status,cb_busy); @@ -446,6 +456,7 @@ if( debug_main ) debug_msg(" -- %d on %d -- ", cb->get_ext(), data[ __TIMESLICE_PLACE__ ] ); cb->set_msg_id( ( ( cb->get_msg_id() ) + 1 ) & ( BIT7 ^ 0xff ) ); + VZ_call * call = cb->invite(); if( call != NULL ){ @@ -606,6 +617,7 @@ call_manager( v_call, v_cb, buffer, write_buffer, ts ); + /* static uint8_t flag = 0; if( v_call->size() == 0 ){ if (flag == 0) { flag = 1; } @@ -613,6 +625,7 @@ }else{ if (flag == 1) { flag = 0; } } + */ bl_handler();