![](/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
main.cpp@118:b93b17c50910, 2015-04-24 (annotated)
- Committer:
- klauss
- Date:
- Fri Apr 24 13:54:24 2015 +0000
- Revision:
- 118:b93b17c50910
- Parent:
- 117:e9facba9db27
- Child:
- 119:ee6a53069455
inclus?o do tratamento dos pacotes sevidor->cbx no procedimento de grava??o via bootloader
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 117:e9facba9db27 | 1 | #include "telemetry.h" |
klauss | 114:472502b31a12 | 2 | #include "eth.h" |
klauss | 114:472502b31a12 | 3 | #include "bits.h" |
klauss | 117:e9facba9db27 | 4 | #include "UART3Interrupt.h" // for RXBuffer[ __CB_BUFFER_SIZE__ ]; |
klauss | 114:472502b31a12 | 5 | #include "utils.h" |
klauss | 114:472502b31a12 | 6 | #include "parallelcpld.h" |
klauss | 114:472502b31a12 | 7 | #include "debug.h" |
klauss | 114:472502b31a12 | 8 | #include "flood.h" |
klauss | 117:e9facba9db27 | 9 | #include "bootloader_cbx.h" |
klauss | 114:472502b31a12 | 10 | #include "call_manager.h" |
klauss | 114:472502b31a12 | 11 | #include "call_box_manager.h" |
klauss | 114:472502b31a12 | 12 | #include "sip_manager.h" |
klauss | 114:472502b31a12 | 13 | #include "shared_variables.h" |
klauss | 114:472502b31a12 | 14 | #include "prompt.h" |
klauss | 114:472502b31a12 | 15 | #include "configs.h" |
klauss | 114:472502b31a12 | 16 | #include "sdram.h" |
klauss | 114:472502b31a12 | 17 | #include "fw.h" |
klauss | 117:e9facba9db27 | 18 | #include "bootloader.h" |
klauss | 87:679ee0d594a9 | 19 | volatile u16_t lpc_low_level_input_counter = 0; |
klauss | 85:b6f2dc1d0f4f | 20 | |
klauss | 91:c2a86b1f8aaa | 21 | int main() |
klauss | 114:472502b31a12 | 22 | { |
klauss | 81:3656f00ab3db | 23 | init_wdt(); |
klauss | 91:c2a86b1f8aaa | 24 | |
klauss | 81:3656f00ab3db | 25 | config_lpc(); |
klauss | 91:c2a86b1f8aaa | 26 | |
klauss | 0:4d17cd9c8f9d | 27 | start_cpld(); |
klauss | 91:c2a86b1f8aaa | 28 | |
klauss | 100:09a23fcd3bdf | 29 | debug_uart3 = true; |
klauss | 91:c2a86b1f8aaa | 30 | if( sdram_init() == 1 ) { |
klauss | 114:472502b31a12 | 31 | send_msg("******* Failed to initialize SDRAM *******"); |
klauss | 87:679ee0d594a9 | 32 | return 1; |
klauss | 89:0fe315117b00 | 33 | } else { |
klauss | 114:472502b31a12 | 34 | send_msg("******* Success to initialize SDRAM *******"); |
klauss | 87:679ee0d594a9 | 35 | } |
klauss | 91:c2a86b1f8aaa | 36 | |
klauss | 43:455522f98de5 | 37 | init_fsystem(); |
klauss | 91:c2a86b1f8aaa | 38 | |
klauss | 89:0fe315117b00 | 39 | { |
klauss | 89:0fe315117b00 | 40 | char s[ 32 ]; |
klauss | 89:0fe315117b00 | 41 | mbed_mac_address( s ); |
klauss | 114:472502b31a12 | 42 | send_msg( "::Mac::%02x:%02x:%02x:%02x:%02x:%02x:: ", s[0],s[1],s[2],s[3],s[4],s[5] ); |
klauss | 89:0fe315117b00 | 43 | } |
klauss | 91:c2a86b1f8aaa | 44 | |
klauss | 78:1353744f01e1 | 45 | short int eth_status = __init_eth__(); |
klauss | 91:c2a86b1f8aaa | 46 | if( eth_status ) { |
klauss | 114:472502b31a12 | 47 | send_msg("******* Cannot connect to eth *******"); |
klauss | 91:c2a86b1f8aaa | 48 | } else { |
klauss | 114:472502b31a12 | 49 | send_msg("******* Connection eth - ok *******"); |
klauss | 78:1353744f01e1 | 50 | init_prompt_eth(); |
klauss | 111:c0833f2455ed | 51 | init_external_wdt(); |
klauss | 117:e9facba9db27 | 52 | init_bl(); |
klauss | 8:e3bfe62a477e | 53 | } |
klauss | 91:c2a86b1f8aaa | 54 | |
klauss | 78:1353744f01e1 | 55 | Timer sync_timer, led_sync_timer; |
klauss | 114:472502b31a12 | 56 | sync_timer.start(), led_sync_timer.start(); |
klauss | 91:c2a86b1f8aaa | 57 | |
klauss | 114:472502b31a12 | 58 | /* representa ramal do call box */ |
klauss | 0:4d17cd9c8f9d | 59 | int ext = 0; |
klauss | 91:c2a86b1f8aaa | 60 | |
klauss | 114:472502b31a12 | 61 | /* representa porta do call box */ |
klauss | 78:1353744f01e1 | 62 | int port = 0; |
klauss | 91:c2a86b1f8aaa | 63 | |
klauss | 114:472502b31a12 | 64 | /* buffer para onde se copia os dados vindos do cb para tratameno interno */ |
klauss | 117:e9facba9db27 | 65 | uint8_t buffer[ __CB_BUFFER_SIZE__ ]; |
klauss | 91:c2a86b1f8aaa | 66 | |
klauss | 114:472502b31a12 | 67 | /* buffer de escrita do pacote de saida que sera enviado pro cb / servidor */ |
klauss | 117:e9facba9db27 | 68 | uint8_t write_buffer[ __CB_BUFFER_SIZE__ ]; |
klauss | 91:c2a86b1f8aaa | 69 | |
klauss | 114:472502b31a12 | 70 | /* ponteiro que aponta para os dados vindo do CPLD */ |
klauss | 0:4d17cd9c8f9d | 71 | uint8_t * buffer_from_cb_ptr = ( uint8_t * )RXBuffer; |
klauss | 91:c2a86b1f8aaa | 72 | |
klauss | 114:472502b31a12 | 73 | /* Armazena o ultimo pacote recebido dos CBx */ |
klauss | 117:e9facba9db27 | 74 | uint8_t cb_rx_buffer[ __CB_BUFFER_SIZE__ ]; |
klauss | 91:c2a86b1f8aaa | 75 | |
klauss | 114:472502b31a12 | 76 | /* referencia para os dados contidos no pacote, sem o header */ |
klauss | 0:4d17cd9c8f9d | 77 | uint8_t * data = NULL; |
klauss | 91:c2a86b1f8aaa | 78 | |
klauss | 114:472502b31a12 | 79 | /* gerencia o tipo do pacote para providenciar tratamento adequado */ |
klauss | 0:4d17cd9c8f9d | 80 | volatile uint8_t type = __DO_NOTHING__; |
klauss | 91:c2a86b1f8aaa | 81 | |
klauss | 114:472502b31a12 | 82 | /* representa a lista dos Call Boxes atualmente recfonhecidos pela cabeceira */ |
klauss | 0:4d17cd9c8f9d | 83 | Vector * v_cb = new Vector(); |
klauss | 91:c2a86b1f8aaa | 84 | |
klauss | 114:472502b31a12 | 85 | /* representa a lista de ligacoes ativas na cabeceira */ |
klauss | 0:4d17cd9c8f9d | 86 | Vector * v_call = new Vector(); |
klauss | 91:c2a86b1f8aaa | 87 | |
klauss | 114:472502b31a12 | 88 | /* gerencia a distribuicao de timeslice para os call boxes */ |
klauss | 0:4d17cd9c8f9d | 89 | Timeslice * ts = new Timeslice(); |
klauss | 91:c2a86b1f8aaa | 90 | if( ts == NULL ) { |
klauss | 89:0fe315117b00 | 91 | memory_is_over = true; |
klauss | 89:0fe315117b00 | 92 | if( debug_memory ) debug_msg("TS allocation fail"); |
klauss | 89:0fe315117b00 | 93 | } |
klauss | 91:c2a86b1f8aaa | 94 | |
klauss | 114:472502b31a12 | 95 | /* instancia o vetor de call boxes // calls */ |
klauss | 91:c2a86b1f8aaa | 96 | if( v_cb == NULL ) { |
klauss | 91:c2a86b1f8aaa | 97 | while( v_cb == NULL ) { |
klauss | 0:4d17cd9c8f9d | 98 | Vector * v_cb = new Vector(); |
klauss | 91:c2a86b1f8aaa | 99 | if( sync_timer.read() > 5 ) { |
klauss | 48:195c97f12e8e | 100 | send_msg("Erro ao alocar o vetor de CBx"); |
klauss | 78:1353744f01e1 | 101 | sync_timer.reset(); |
klauss | 0:4d17cd9c8f9d | 102 | } |
klauss | 0:4d17cd9c8f9d | 103 | } |
klauss | 117:e9facba9db27 | 104 | } else if( v_call == NULL ) { |
klauss | 91:c2a86b1f8aaa | 105 | while( v_call == NULL ) { |
klauss | 0:4d17cd9c8f9d | 106 | Vector * v_call = new Vector(); |
klauss | 91:c2a86b1f8aaa | 107 | if( sync_timer.read() > 5 ) { |
klauss | 48:195c97f12e8e | 108 | send_msg("Erro ao alocar o vetor de Calls"); |
klauss | 78:1353744f01e1 | 109 | sync_timer.reset(); |
klauss | 0:4d17cd9c8f9d | 110 | } |
klauss | 0:4d17cd9c8f9d | 111 | } |
klauss | 0:4d17cd9c8f9d | 112 | } |
klauss | 91:c2a86b1f8aaa | 113 | |
klauss | 91:c2a86b1f8aaa | 114 | if( v_cb == NULL ) { |
klauss | 89:0fe315117b00 | 115 | memory_is_over = true; |
klauss | 89:0fe315117b00 | 116 | if( debug_memory ) debug_msg("Call_Box vector allocation fail"); |
klauss | 89:0fe315117b00 | 117 | } |
klauss | 91:c2a86b1f8aaa | 118 | |
klauss | 91:c2a86b1f8aaa | 119 | if( v_call == NULL ) { |
klauss | 89:0fe315117b00 | 120 | memory_is_over = true; |
klauss | 89:0fe315117b00 | 121 | if( debug_memory ) debug_msg("Call vector allocation fail"); |
klauss | 89:0fe315117b00 | 122 | } |
klauss | 91:c2a86b1f8aaa | 123 | |
klauss | 117:e9facba9db27 | 124 | for( register uint16_t i = 0; i < __CB_BUFFER_SIZE__; i++ ) { |
klauss | 63:0d95da692bb4 | 125 | cb_rx_buffer[ i ] = 0; |
klauss | 63:0d95da692bb4 | 126 | cb_tx_buffer[ i ] = 0; |
klauss | 63:0d95da692bb4 | 127 | } |
klauss | 91:c2a86b1f8aaa | 128 | |
klauss | 0:4d17cd9c8f9d | 129 | reset_leds(); |
klauss | 91:c2a86b1f8aaa | 130 | |
klauss | 33:735fd60e96d8 | 131 | udp_timer.start(); |
klauss | 114:472502b31a12 | 132 | |
klauss | 117:e9facba9db27 | 133 | init_telemetry_handler(); |
klauss | 117:e9facba9db27 | 134 | |
klauss | 117:e9facba9db27 | 135 | //debug_msg(""); |
klauss | 99:e80850c51106 | 136 | init_fw_handler(); |
klauss | 117:e9facba9db27 | 137 | //debug_msg(""); |
klauss | 99:e80850c51106 | 138 | |
klauss | 99:e80850c51106 | 139 | led2 = 0; |
klauss | 81:3656f00ab3db | 140 | init_ranges(); |
klauss | 114:472502b31a12 | 141 | |
klauss | 80:61d61c9eb75c | 142 | init_refresh(); |
klauss | 91:c2a86b1f8aaa | 143 | |
klauss | 117:e9facba9db27 | 144 | init_aging(); |
klauss | 117:e9facba9db27 | 145 | |
klauss | 89:0fe315117b00 | 146 | init_sync_refresh(); |
klauss | 91:c2a86b1f8aaa | 147 | |
klauss | 114:472502b31a12 | 148 | //init_invite_pgk_retry_manager(); |
klauss | 114:472502b31a12 | 149 | |
klauss | 114:472502b31a12 | 150 | //void init_bye_pgk_retry_manager(); |
klauss | 114:472502b31a12 | 151 | |
klauss | 62:07e5bdc9f8f7 | 152 | static uint8_t count = 0; |
klauss | 91:c2a86b1f8aaa | 153 | |
klauss | 114:472502b31a12 | 154 | //short int bl_ret = init_bl_handler(); |
klauss | 114:472502b31a12 | 155 | //if( dbl ) send_msg("Valor de retorno do bl_habdler = %d", bl_ret ); |
klauss | 114:472502b31a12 | 156 | |
klauss | 78:1353744f01e1 | 157 | uint8_t max_registered_cbx = 0; |
klauss | 91:c2a86b1f8aaa | 158 | |
klauss | 81:3656f00ab3db | 159 | bool wake_all = false; |
klauss | 91:c2a86b1f8aaa | 160 | |
klauss | 81:3656f00ab3db | 161 | uint16_t pkg_wdt = RX_CB_IDLE; |
klauss | 81:3656f00ab3db | 162 | uint16_t eth_wdt = ETH_CONNECT_TIMEOUT; |
klauss | 117:e9facba9db27 | 163 | uint32_t uptime = 0; |
klauss | 109:a5b8264ffbbc | 164 | led1 = 0; |
klauss | 114:472502b31a12 | 165 | send_msg("Ready"); |
klauss | 114:472502b31a12 | 166 | |
klauss | 114:472502b31a12 | 167 | //bool registry_test = false; |
klauss | 114:472502b31a12 | 168 | //static int next_value = 5002; |
klauss | 114:472502b31a12 | 169 | //static int nex_test_registry = next_value; |
klauss | 105:a930035b6556 | 170 | |
klauss | 114:472502b31a12 | 171 | //bool invite_retry_time = false; |
klauss | 99:e80850c51106 | 172 | Timer invite_retry_timer; |
klauss | 99:e80850c51106 | 173 | invite_retry_timer.start(); |
klauss | 114:472502b31a12 | 174 | debug_uart3 = false; |
klauss | 105:a930035b6556 | 175 | |
klauss | 114:472502b31a12 | 176 | Timer test_timer; |
klauss | 115:a1e1e2e60a2c | 177 | |
klauss | 117:e9facba9db27 | 178 | hex_init(); |
klauss | 91:c2a86b1f8aaa | 179 | |
klauss | 78:1353744f01e1 | 180 | /*------------------------------------------ main loop ---------------------------------------------------------------*/ |
klauss | 117:e9facba9db27 | 181 | while( true ) { |
klauss | 117:e9facba9db27 | 182 | reset_leds(); |
klauss | 117:e9facba9db27 | 183 | // need be removed; |
klauss | 117:e9facba9db27 | 184 | |
klauss | 78:1353744f01e1 | 185 | if( v_cb->size() > max_registered_cbx ) max_registered_cbx = v_cb->size(); |
klauss | 91:c2a86b1f8aaa | 186 | |
klauss | 117:e9facba9db27 | 187 | if( sync_timer.read() > 5 ) { |
klauss | 78:1353744f01e1 | 188 | sync_timer.reset(); |
klauss | 91:c2a86b1f8aaa | 189 | |
klauss | 117:e9facba9db27 | 190 | if( debug_cks == true ) { |
klauss | 117:e9facba9db27 | 191 | pcks_s = true; |
klauss | 117:e9facba9db27 | 192 | } |
klauss | 91:c2a86b1f8aaa | 193 | |
klauss | 117:e9facba9db27 | 194 | if( debug_alive == true ) { |
klauss | 117:e9facba9db27 | 195 | pshowcb = true; |
klauss | 117:e9facba9db27 | 196 | } |
klauss | 117:e9facba9db27 | 197 | |
klauss | 117:e9facba9db27 | 198 | |
klauss | 117:e9facba9db27 | 199 | { |
klauss | 117:e9facba9db27 | 200 | // debug_msg("Enviei"); |
klauss | 117:e9facba9db27 | 201 | // send2callboxes( __build_cb_package__( 5000, 5000, __INVITE__, |
klauss | 117:e9facba9db27 | 202 | // ( char * )buffer, 0x12, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 117:e9facba9db27 | 203 | // v_cb -> add ( new Call_Box ( 5010, 5010 ) ); |
klauss | 117:e9facba9db27 | 204 | } |
klauss | 105:a930035b6556 | 205 | |
klauss | 114:472502b31a12 | 206 | if( !( ++count % 15 ) ) { |
klauss | 91:c2a86b1f8aaa | 207 | if( eth_status ) { |
klauss | 78:1353744f01e1 | 208 | eth_status = __init_eth__(); |
klauss | 91:c2a86b1f8aaa | 209 | if( eth_status ) { |
klauss | 114:472502b31a12 | 210 | if( debug_main ) debug_msg("Cannot connect to eth"); |
klauss | 91:c2a86b1f8aaa | 211 | } else { |
klauss | 114:472502b31a12 | 212 | if( debug_main ) debug_msg("Connection eth - ok"); |
klauss | 78:1353744f01e1 | 213 | init_prompt_eth(); |
klauss | 114:472502b31a12 | 214 | init_external_wdt(); |
klauss | 117:e9facba9db27 | 215 | init_bl(); |
klauss | 78:1353744f01e1 | 216 | } |
klauss | 78:1353744f01e1 | 217 | } |
klauss | 78:1353744f01e1 | 218 | } |
klauss | 100:09a23fcd3bdf | 219 | |
klauss | 114:472502b31a12 | 220 | //35 sec. |
klauss | 91:c2a86b1f8aaa | 221 | if( ( count > 7 ) && ( wake_all == false ) ) { |
klauss | 81:3656f00ab3db | 222 | wake_all = true; |
klauss | 78:1353744f01e1 | 223 | if( debug_wake == true ) send_msg( "Time to wake" ); |
klauss | 78:1353744f01e1 | 224 | } |
klauss | 114:472502b31a12 | 225 | } |
klauss | 91:c2a86b1f8aaa | 226 | |
klauss | 114:472502b31a12 | 227 | //FIXMEj colocar uma condicao aqui caso necessario pra nao comprometer ligacoes ... |
klauss | 117:e9facba9db27 | 228 | prompt_process( NULL ); |
klauss | 114:472502b31a12 | 229 | |
klauss | 91:c2a86b1f8aaa | 230 | if( r_stats ) { |
klauss | 91:c2a86b1f8aaa | 231 | boot_counter = 0; |
klauss | 91:c2a86b1f8aaa | 232 | registry_counter = 0; |
klauss | 91:c2a86b1f8aaa | 233 | invite_counter = 0; |
klauss | 91:c2a86b1f8aaa | 234 | audio_counter = 0; |
klauss | 91:c2a86b1f8aaa | 235 | telemetry_counter = 0; |
klauss | 91:c2a86b1f8aaa | 236 | cb_bye_counter = 0; |
klauss | 91:c2a86b1f8aaa | 237 | prompt_counter = 0; |
klauss | 91:c2a86b1f8aaa | 238 | flood_counter = 0; |
klauss | 67:cdedc64d9921 | 239 | bootloader_cbx_counter = 0; |
klauss | 99:e80850c51106 | 240 | cb_stats_counter = 0; |
klauss | 63:0d95da692bb4 | 241 | r_stats = false; |
klauss | 63:0d95da692bb4 | 242 | stats = true; |
klauss | 63:0d95da692bb4 | 243 | } |
klauss | 91:c2a86b1f8aaa | 244 | |
klauss | 117:e9facba9db27 | 245 | if( stats ) { |
klauss | 63:0d95da692bb4 | 246 | char str[ 200 ]; |
klauss | 117:e9facba9db27 | 247 | snprintf( str, 200, "\n\rReceived Pkgs::\n\r Boot :: %u\n\r Registry :: %u\n\r Invite :: %u\n\r Audio :: %u\n\r Telemetry :: %u\n\r CB_stats :: %u\n\r CB_bye :: %u\n\r Prompt :: %u\n\r Flood :: %u\n\r Bootloader_cbx :: %u\n\r", |
klauss | 117:e9facba9db27 | 248 | boot_counter, registry_counter, invite_counter, audio_counter, telemetry_counter, cb_stats_counter, cb_bye_counter, prompt_counter, flood_counter, bootloader_cbx_counter ); |
klauss | 63:0d95da692bb4 | 249 | send_msg( str ); |
klauss | 63:0d95da692bb4 | 250 | stats =false; |
klauss | 63:0d95da692bb4 | 251 | } |
klauss | 114:472502b31a12 | 252 | |
klauss | 117:e9facba9db27 | 253 | if( list ) { |
klauss | 78:1353744f01e1 | 254 | uint8_t missed_cb = ( ( max_ext - min_ext ) + 1 ) - v_cb->size(); |
klauss | 91:c2a86b1f8aaa | 255 | |
klauss | 78:1353744f01e1 | 256 | if( ( max_ext % 2 ) == 0 ) missed_cb++; |
klauss | 91:c2a86b1f8aaa | 257 | |
klauss | 78:1353744f01e1 | 258 | if( min_ext % 2 ) missed_cb++; |
klauss | 91:c2a86b1f8aaa | 259 | |
klauss | 78:1353744f01e1 | 260 | if( min_ext == 0 && max_ext == 0 ) missed_cb = 0; |
klauss | 91:c2a86b1f8aaa | 261 | |
klauss | 78:1353744f01e1 | 262 | send_msg("Registered %d[ %d ] CBx ( %d - %d ) - Missed %d -- Remain_timeslices :: %d :: v_call->size() :: %d", v_cb->size(), max_registered_cbx, min_ext, max_ext, missed_cb, ts->remain_timeslices(), v_call->size() ); |
klauss | 91:c2a86b1f8aaa | 263 | if( v_cb->size() == 1 ) { |
klauss | 78:1353744f01e1 | 264 | send_msg(" %d ", ( ( Call_Box * )v_cb->get_element( 0 ) )->get_ext() ); |
klauss | 91:c2a86b1f8aaa | 265 | } else if( v_cb->size() > 1 ) { |
klauss | 62:07e5bdc9f8f7 | 266 | char str[ 1024 ]; |
klauss | 78:1353744f01e1 | 267 | int ext_list[ __MAX_CB_IN_A_BRANCH__ ]; |
klauss | 62:07e5bdc9f8f7 | 268 | register int i = 0; |
klauss | 91:c2a86b1f8aaa | 269 | for( ; i < v_cb->size(); i++ ) { |
klauss | 78:1353744f01e1 | 270 | ext_list[ i ] = ( ( Call_Box * )v_cb->get_element( i ) )->get_ext(); |
klauss | 62:07e5bdc9f8f7 | 271 | } |
klauss | 91:c2a86b1f8aaa | 272 | |
klauss | 62:07e5bdc9f8f7 | 273 | qsort( ext_list, v_cb->size(), sizeof( int ), ls_comp ); |
klauss | 91:c2a86b1f8aaa | 274 | |
klauss | 62:07e5bdc9f8f7 | 275 | char aux[ 16 ]; |
klauss | 78:1353744f01e1 | 276 | strcpy( str, "\r\n> " ); |
klauss | 91:c2a86b1f8aaa | 277 | for( i = 0; i < v_cb->size() - 1; i++ ) { |
klauss | 62:07e5bdc9f8f7 | 278 | sprintf( aux, "%i, ", ext_list[ i ] ); |
klauss | 62:07e5bdc9f8f7 | 279 | strcat( str, aux ); |
klauss | 78:1353744f01e1 | 280 | if( ( i != 0 ) && !( ( i + 1 ) % 16 ) ) strcat( str, "\r\n> " ); |
klauss | 62:07e5bdc9f8f7 | 281 | } |
klauss | 62:07e5bdc9f8f7 | 282 | sprintf( aux, "%i ", ext_list[ i ] ); |
klauss | 62:07e5bdc9f8f7 | 283 | strcat( str, aux ); |
klauss | 62:07e5bdc9f8f7 | 284 | send_msg( "%s", str ); |
klauss | 62:07e5bdc9f8f7 | 285 | } |
klauss | 91:c2a86b1f8aaa | 286 | list = false; |
klauss | 114:472502b31a12 | 287 | } |
klauss | 114:472502b31a12 | 288 | |
klauss | 106:a34fcf9f0e02 | 289 | if( long_list ) |
klauss | 106:a34fcf9f0e02 | 290 | { |
klauss | 106:a34fcf9f0e02 | 291 | uint8_t missed_cb = ( ( max_ext - min_ext ) + 1 ) - v_cb->size(); |
klauss | 91:c2a86b1f8aaa | 292 | |
klauss | 106:a34fcf9f0e02 | 293 | if( ( max_ext % 2 ) == 0 ) missed_cb++; |
klauss | 106:a34fcf9f0e02 | 294 | |
klauss | 106:a34fcf9f0e02 | 295 | if( min_ext % 2 ) missed_cb++; |
klauss | 106:a34fcf9f0e02 | 296 | |
klauss | 106:a34fcf9f0e02 | 297 | if( min_ext == 0 && max_ext == 0 ) missed_cb = 0; |
klauss | 106:a34fcf9f0e02 | 298 | |
klauss | 106:a34fcf9f0e02 | 299 | { |
klauss | 106:a34fcf9f0e02 | 300 | int ext_list[ __MAX_CB_IN_A_BRANCH__ ]; |
klauss | 106:a34fcf9f0e02 | 301 | |
klauss | 106:a34fcf9f0e02 | 302 | if( v_cb->size() >= 1 ) { |
klauss | 106:a34fcf9f0e02 | 303 | for( register int i = 0; i < v_cb->size(); i++ ) |
klauss | 106:a34fcf9f0e02 | 304 | { |
klauss | 106:a34fcf9f0e02 | 305 | ext_list[ i ] = ( ( Call_Box * )v_cb->get_element( i ) )->get_ext(); |
klauss | 106:a34fcf9f0e02 | 306 | } |
klauss | 106:a34fcf9f0e02 | 307 | qsort( ext_list, v_cb->size(), sizeof( int ), ls_comp ); |
klauss | 106:a34fcf9f0e02 | 308 | } |
klauss | 106:a34fcf9f0e02 | 309 | |
klauss | 106:a34fcf9f0e02 | 310 | send_msg("Registered %d[ %d ] CBx ( %d - %d ) - Missed %d -- Remain_timeslices :: %d :: v_call->size() :: %d", v_cb->size(), max_registered_cbx, min_ext, max_ext, missed_cb, ts->remain_timeslices(), v_call->size() ); |
klauss | 106:a34fcf9f0e02 | 311 | |
klauss | 106:a34fcf9f0e02 | 312 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 106:a34fcf9f0e02 | 313 | |
klauss | 106:a34fcf9f0e02 | 314 | Call_Box * cb = __find_CB__( v_cb, ext_list[ i ] ); |
klauss | 106:a34fcf9f0e02 | 315 | |
klauss | 106:a34fcf9f0e02 | 316 | if( cb != NULL ) |
klauss | 106:a34fcf9f0e02 | 317 | { |
klauss | 106:a34fcf9f0e02 | 318 | char cb_status[ 32 ]; |
klauss | 106:a34fcf9f0e02 | 319 | char cb_sip_status[ 32 ]; |
klauss | 106:a34fcf9f0e02 | 320 | switch( cb->status ) { |
klauss | 106:a34fcf9f0e02 | 321 | case cb_idle : { |
klauss | 106:a34fcf9f0e02 | 322 | strcpy( cb_status, "cb_idle" ); |
klauss | 106:a34fcf9f0e02 | 323 | break; |
klauss | 106:a34fcf9f0e02 | 324 | } |
klauss | 106:a34fcf9f0e02 | 325 | case cb_ringing : { |
klauss | 106:a34fcf9f0e02 | 326 | strcpy( cb_status, "cb_ringing" ); |
klauss | 106:a34fcf9f0e02 | 327 | break; |
klauss | 106:a34fcf9f0e02 | 328 | } |
klauss | 106:a34fcf9f0e02 | 329 | case cb_trying : { |
klauss | 106:a34fcf9f0e02 | 330 | strcpy( cb_status,"cb_trying" ); |
klauss | 106:a34fcf9f0e02 | 331 | break; |
klauss | 106:a34fcf9f0e02 | 332 | } |
klauss | 106:a34fcf9f0e02 | 333 | case cb_on_call : { |
klauss | 106:a34fcf9f0e02 | 334 | strcpy( cb_status, "cb_on_call" ); |
klauss | 106:a34fcf9f0e02 | 335 | break; |
klauss | 106:a34fcf9f0e02 | 336 | } |
klauss | 106:a34fcf9f0e02 | 337 | case cb_busy : { |
klauss | 106:a34fcf9f0e02 | 338 | strcpy( cb_status, "cb_busy" ); |
klauss | 106:a34fcf9f0e02 | 339 | break; |
klauss | 106:a34fcf9f0e02 | 340 | } |
klauss | 106:a34fcf9f0e02 | 341 | case cb_denied : { |
klauss | 106:a34fcf9f0e02 | 342 | strcpy( cb_status, "cb_denied" ); |
klauss | 106:a34fcf9f0e02 | 343 | break; |
klauss | 106:a34fcf9f0e02 | 344 | } |
klauss | 117:e9facba9db27 | 345 | case cb_bootloader : { |
klauss | 117:e9facba9db27 | 346 | strcpy( cb_status, "cb_bootloader" ); |
klauss | 117:e9facba9db27 | 347 | break; |
klauss | 117:e9facba9db27 | 348 | } |
klauss | 106:a34fcf9f0e02 | 349 | } |
klauss | 106:a34fcf9f0e02 | 350 | switch( cb->sip->status ) { |
klauss | 106:a34fcf9f0e02 | 351 | case sip_idle : { |
klauss | 106:a34fcf9f0e02 | 352 | strcpy( cb_sip_status, "sip_idle" ); |
klauss | 106:a34fcf9f0e02 | 353 | break; |
klauss | 106:a34fcf9f0e02 | 354 | } |
klauss | 106:a34fcf9f0e02 | 355 | case sip_waiting_trying : { |
klauss | 106:a34fcf9f0e02 | 356 | strcpy( cb_sip_status, "sip_waiting_trying" ); |
klauss | 106:a34fcf9f0e02 | 357 | break; |
klauss | 106:a34fcf9f0e02 | 358 | } |
klauss | 106:a34fcf9f0e02 | 359 | case sip_trying : { |
klauss | 106:a34fcf9f0e02 | 360 | strcpy( cb_sip_status, "sip_trying" ); |
klauss | 106:a34fcf9f0e02 | 361 | break; |
klauss | 106:a34fcf9f0e02 | 362 | } |
klauss | 106:a34fcf9f0e02 | 363 | case sip_ringing : { |
klauss | 106:a34fcf9f0e02 | 364 | strcpy( cb_sip_status, "sip_ringing" ); |
klauss | 106:a34fcf9f0e02 | 365 | break; |
klauss | 106:a34fcf9f0e02 | 366 | } |
klauss | 106:a34fcf9f0e02 | 367 | case sip_busy : { |
klauss | 106:a34fcf9f0e02 | 368 | strcpy( cb_sip_status, "sip_busy" ); |
klauss | 106:a34fcf9f0e02 | 369 | break; |
klauss | 106:a34fcf9f0e02 | 370 | } |
klauss | 106:a34fcf9f0e02 | 371 | case sip_ok : { |
klauss | 106:a34fcf9f0e02 | 372 | strcpy( cb_sip_status, "sip_ok" ); |
klauss | 106:a34fcf9f0e02 | 373 | break; |
klauss | 106:a34fcf9f0e02 | 374 | } |
klauss | 106:a34fcf9f0e02 | 375 | case sip_on_call : { |
klauss | 106:a34fcf9f0e02 | 376 | strcpy( cb_sip_status, "sip_on_call" ); |
klauss | 106:a34fcf9f0e02 | 377 | break; |
klauss | 106:a34fcf9f0e02 | 378 | } |
klauss | 106:a34fcf9f0e02 | 379 | case sip_denied : { |
klauss | 106:a34fcf9f0e02 | 380 | strcpy( cb_sip_status, "sip_denied" ); |
klauss | 106:a34fcf9f0e02 | 381 | break; |
klauss | 106:a34fcf9f0e02 | 382 | } |
klauss | 106:a34fcf9f0e02 | 383 | } |
klauss | 106:a34fcf9f0e02 | 384 | char cbx_to_string[ 254 ]; |
klauss | 106:a34fcf9f0e02 | 385 | char aux[ 16 ]; |
klauss | 106:a34fcf9f0e02 | 386 | strcpy( cbx_to_string, "Ext :: " ); |
klauss | 106:a34fcf9f0e02 | 387 | itoa( cb->get_ext(), aux , 10 ); |
klauss | 106:a34fcf9f0e02 | 388 | strcat( cbx_to_string, aux ); |
klauss | 106:a34fcf9f0e02 | 389 | strcat( cbx_to_string, " :: Port :: " ); |
klauss | 106:a34fcf9f0e02 | 390 | itoa( cb->get_port(), aux , 10 ); |
klauss | 106:a34fcf9f0e02 | 391 | strcat( cbx_to_string, aux ); |
klauss | 106:a34fcf9f0e02 | 392 | strcat( cbx_to_string, " :: Status -- " ); |
klauss | 106:a34fcf9f0e02 | 393 | strcat( cbx_to_string, cb_status ); |
klauss | 106:a34fcf9f0e02 | 394 | strcat( cbx_to_string, " - " ); |
klauss | 106:a34fcf9f0e02 | 395 | strcat( cbx_to_string, cb_sip_status ); |
klauss | 106:a34fcf9f0e02 | 396 | if( cb->get_timeslice() != 0 ) { |
klauss | 106:a34fcf9f0e02 | 397 | strcat( cbx_to_string, " -- on TimeSlice :: " ); |
klauss | 106:a34fcf9f0e02 | 398 | itoa( cb->get_timeslice(), aux , 10 ); |
klauss | 106:a34fcf9f0e02 | 399 | strcat( cbx_to_string, aux ); |
klauss | 106:a34fcf9f0e02 | 400 | } |
klauss | 106:a34fcf9f0e02 | 401 | send_msg( cbx_to_string ); |
klauss | 106:a34fcf9f0e02 | 402 | } |
klauss | 106:a34fcf9f0e02 | 403 | } |
klauss | 106:a34fcf9f0e02 | 404 | |
klauss | 106:a34fcf9f0e02 | 405 | } |
klauss | 91:c2a86b1f8aaa | 406 | long_list = false; |
klauss | 52:12930cef17c4 | 407 | } |
klauss | 114:472502b31a12 | 408 | |
klauss | 117:e9facba9db27 | 409 | if( pshowcb == true ) { |
klauss | 78:1353744f01e1 | 410 | send_msg("Registered %d ( of %d ) CBx ( %d - %d ) -- Remain_timeslices :: %d :: v_call->size() :: %d", v_cb->size(), max_registered_cbx, min_ext, max_ext, ts->remain_timeslices(), v_call->size() ); |
klauss | 91:c2a86b1f8aaa | 411 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 30:8dfb6d8de53d | 412 | Call_Box * cb = ( Call_Box * )v_cb->get_element( i ); |
klauss | 78:1353744f01e1 | 413 | char cb_status[ 32 ]; |
klauss | 78:1353744f01e1 | 414 | char cb_sip_status[ 32 ]; |
klauss | 91:c2a86b1f8aaa | 415 | switch( cb->status ) { |
klauss | 91:c2a86b1f8aaa | 416 | case cb_idle : { |
klauss | 91:c2a86b1f8aaa | 417 | strcpy( cb_status, "cb_idle" ); |
klauss | 91:c2a86b1f8aaa | 418 | break; |
klauss | 91:c2a86b1f8aaa | 419 | } |
klauss | 91:c2a86b1f8aaa | 420 | case cb_ringing : { |
klauss | 91:c2a86b1f8aaa | 421 | strcpy( cb_status, "cb_ringing" ); |
klauss | 91:c2a86b1f8aaa | 422 | break; |
klauss | 91:c2a86b1f8aaa | 423 | } |
klauss | 91:c2a86b1f8aaa | 424 | case cb_trying : { |
klauss | 91:c2a86b1f8aaa | 425 | strcpy( cb_status,"cb_trying" ); |
klauss | 91:c2a86b1f8aaa | 426 | break; |
klauss | 91:c2a86b1f8aaa | 427 | } |
klauss | 91:c2a86b1f8aaa | 428 | case cb_on_call : { |
klauss | 91:c2a86b1f8aaa | 429 | strcpy( cb_status, "cb_on_call" ); |
klauss | 91:c2a86b1f8aaa | 430 | break; |
klauss | 91:c2a86b1f8aaa | 431 | } |
klauss | 91:c2a86b1f8aaa | 432 | case cb_busy : { |
klauss | 91:c2a86b1f8aaa | 433 | strcpy( cb_status, "cb_busy" ); |
klauss | 91:c2a86b1f8aaa | 434 | break; |
klauss | 91:c2a86b1f8aaa | 435 | } |
klauss | 91:c2a86b1f8aaa | 436 | case cb_denied : { |
klauss | 91:c2a86b1f8aaa | 437 | strcpy( cb_status, "cb_denied" ); |
klauss | 91:c2a86b1f8aaa | 438 | break; |
klauss | 91:c2a86b1f8aaa | 439 | } |
klauss | 78:1353744f01e1 | 440 | } |
klauss | 91:c2a86b1f8aaa | 441 | switch( cb->sip->status ) { |
klauss | 91:c2a86b1f8aaa | 442 | case sip_idle : { |
klauss | 91:c2a86b1f8aaa | 443 | strcpy( cb_sip_status, "sip_idle" ); |
klauss | 91:c2a86b1f8aaa | 444 | break; |
klauss | 91:c2a86b1f8aaa | 445 | } |
klauss | 91:c2a86b1f8aaa | 446 | case sip_waiting_trying : { |
klauss | 91:c2a86b1f8aaa | 447 | strcpy( cb_sip_status, "sip_waiting_trying" ); |
klauss | 91:c2a86b1f8aaa | 448 | break; |
klauss | 91:c2a86b1f8aaa | 449 | } |
klauss | 91:c2a86b1f8aaa | 450 | case sip_trying : { |
klauss | 91:c2a86b1f8aaa | 451 | strcpy( cb_sip_status, "sip_trying" ); |
klauss | 91:c2a86b1f8aaa | 452 | break; |
klauss | 91:c2a86b1f8aaa | 453 | } |
klauss | 91:c2a86b1f8aaa | 454 | case sip_ringing : { |
klauss | 91:c2a86b1f8aaa | 455 | strcpy( cb_sip_status, "sip_ringing" ); |
klauss | 91:c2a86b1f8aaa | 456 | break; |
klauss | 91:c2a86b1f8aaa | 457 | } |
klauss | 91:c2a86b1f8aaa | 458 | case sip_busy : { |
klauss | 91:c2a86b1f8aaa | 459 | strcpy( cb_sip_status, "sip_busy" ); |
klauss | 91:c2a86b1f8aaa | 460 | break; |
klauss | 91:c2a86b1f8aaa | 461 | } |
klauss | 91:c2a86b1f8aaa | 462 | case sip_ok : { |
klauss | 91:c2a86b1f8aaa | 463 | strcpy( cb_sip_status, "sip_ok" ); |
klauss | 91:c2a86b1f8aaa | 464 | break; |
klauss | 91:c2a86b1f8aaa | 465 | } |
klauss | 91:c2a86b1f8aaa | 466 | case sip_on_call : { |
klauss | 91:c2a86b1f8aaa | 467 | strcpy( cb_sip_status, "sip_on_call" ); |
klauss | 91:c2a86b1f8aaa | 468 | break; |
klauss | 91:c2a86b1f8aaa | 469 | } |
klauss | 91:c2a86b1f8aaa | 470 | case sip_denied : { |
klauss | 91:c2a86b1f8aaa | 471 | strcpy( cb_sip_status, "sip_denied" ); |
klauss | 91:c2a86b1f8aaa | 472 | break; |
klauss | 91:c2a86b1f8aaa | 473 | } |
klauss | 78:1353744f01e1 | 474 | } |
klauss | 78:1353744f01e1 | 475 | char cbx_to_string[ 254 ]; |
klauss | 78:1353744f01e1 | 476 | char aux[ 16 ]; |
klauss | 78:1353744f01e1 | 477 | strcpy( cbx_to_string, "Ext :: " ); |
klauss | 78:1353744f01e1 | 478 | itoa( cb->get_ext(), aux , 10 ); |
klauss | 98:43b45f26b430 | 479 | strcat( cbx_to_string, aux ); |
klauss | 97:8985817e8847 | 480 | strcat( cbx_to_string, " :: Port :: " ); |
klauss | 97:8985817e8847 | 481 | itoa( cb->get_port(), aux , 10 ); |
klauss | 78:1353744f01e1 | 482 | strcat( cbx_to_string, aux ); |
klauss | 78:1353744f01e1 | 483 | strcat( cbx_to_string, " :: Status -- " ); |
klauss | 78:1353744f01e1 | 484 | strcat( cbx_to_string, cb_status ); |
klauss | 78:1353744f01e1 | 485 | strcat( cbx_to_string, " - " ); |
klauss | 78:1353744f01e1 | 486 | strcat( cbx_to_string, cb_sip_status ); |
klauss | 91:c2a86b1f8aaa | 487 | if( cb->get_timeslice() != 0 ) { |
klauss | 78:1353744f01e1 | 488 | strcat( cbx_to_string, " -- on TimeSlice :: " ); |
klauss | 78:1353744f01e1 | 489 | itoa( cb->get_timeslice(), aux , 10 ); |
klauss | 78:1353744f01e1 | 490 | strcat( cbx_to_string, aux ); |
klauss | 78:1353744f01e1 | 491 | } |
klauss | 78:1353744f01e1 | 492 | send_msg( cbx_to_string ); |
klauss | 48:195c97f12e8e | 493 | } |
klauss | 78:1353744f01e1 | 494 | pshowcb = false; |
klauss | 48:195c97f12e8e | 495 | } |
klauss | 97:8985817e8847 | 496 | |
klauss | 97:8985817e8847 | 497 | if( show_sip == true ){ |
klauss | 97:8985817e8847 | 498 | show_sip = false; |
klauss | 99:e80850c51106 | 499 | send_msg(":: Sip :: %u", v_cb->size() ); |
klauss | 97:8985817e8847 | 500 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 97:8985817e8847 | 501 | Call_Box * cb = ( Call_Box * )v_cb->get_element( i ); |
klauss | 114:472502b31a12 | 502 | send_msg("ext :: %d -- port :: %d -- timer %d", cb->get_sip_ext(), cb->get_sip_port(), cb->get_timer() ); |
klauss | 97:8985817e8847 | 503 | } |
klauss | 97:8985817e8847 | 504 | } |
klauss | 91:c2a86b1f8aaa | 505 | |
klauss | 81:3656f00ab3db | 506 | if( pflood == true ) flood(); |
klauss | 91:c2a86b1f8aaa | 507 | |
klauss | 91:c2a86b1f8aaa | 508 | if( debug_eth ) { |
klauss | 81:3656f00ab3db | 509 | debug_eth = false; |
klauss | 81:3656f00ab3db | 510 | send_msg("Eth status %s", ( eth_status == 0 ) ? "Connected" : "Disconnected" ); |
klauss | 81:3656f00ab3db | 511 | } |
klauss | 91:c2a86b1f8aaa | 512 | |
klauss | 91:c2a86b1f8aaa | 513 | if( status != __WAITING__ ) { |
klauss | 81:3656f00ab3db | 514 | pkg_wdt = RX_CB_IDLE; |
klauss | 117:e9facba9db27 | 515 | xmemcpy( cb_rx_buffer, buffer_from_cb_ptr, __CB_BUFFER_SIZE__ ); |
klauss | 0:4d17cd9c8f9d | 516 | status = __WAITING__; |
klauss | 81:3656f00ab3db | 517 | missed_pkg--; |
klauss | 117:e9facba9db27 | 518 | xmemcpy( buffer, cb_rx_buffer, __CB_BUFFER_SIZE__ ); |
klauss | 117:e9facba9db27 | 519 | |
klauss | 117:e9facba9db27 | 520 | /* |
klauss | 117:e9facba9db27 | 521 | { |
klauss | 117:e9facba9db27 | 522 | uint16_t e, p; |
klauss | 117:e9facba9db27 | 523 | e = buffer[0]; |
klauss | 117:e9facba9db27 | 524 | e <<= 8; |
klauss | 117:e9facba9db27 | 525 | e |= buffer[1]; |
klauss | 117:e9facba9db27 | 526 | p = buffer[2]; |
klauss | 117:e9facba9db27 | 527 | p <<= 8; |
klauss | 117:e9facba9db27 | 528 | p |= buffer[3]; |
klauss | 117:e9facba9db27 | 529 | //if (e != (p+100)) { |
klauss | 117:e9facba9db27 | 530 | if( ( buffer[0] == 0x14 ) && ( buffer[1] == 0x0a ) ) { |
klauss | 117:e9facba9db27 | 531 | int i; |
klauss | 117:e9facba9db27 | 532 | char s[400], ss[4];; |
klauss | 117:e9facba9db27 | 533 | strcpy(s,"OPS-PKG:"); |
klauss | 117:e9facba9db27 | 534 | for (i=0; i<40; i++) { |
klauss | 117:e9facba9db27 | 535 | sprintf(ss," %02x",buffer[i]); |
klauss | 117:e9facba9db27 | 536 | strcat(s,ss); |
klauss | 117:e9facba9db27 | 537 | } |
klauss | 117:e9facba9db27 | 538 | debug_msg( s ); |
klauss | 117:e9facba9db27 | 539 | } |
klauss | 117:e9facba9db27 | 540 | } |
klauss | 117:e9facba9db27 | 541 | */ |
klauss | 117:e9facba9db27 | 542 | |
klauss | 117:e9facba9db27 | 543 | if( debug_cpld ) { |
klauss | 117:e9facba9db27 | 544 | rx = true; |
klauss | 117:e9facba9db27 | 545 | tx = true; |
klauss | 117:e9facba9db27 | 546 | } |
klauss | 91:c2a86b1f8aaa | 547 | |
klauss | 91:c2a86b1f8aaa | 548 | if( rx ) { |
klauss | 81:3656f00ab3db | 549 | char str[ 1024 ]; |
klauss | 81:3656f00ab3db | 550 | strcpy( str, "RX :: \n\r " ); |
klauss | 117:e9facba9db27 | 551 | for( register uint16_t i = 0; i < __CB_BUFFER_SIZE__; i++ ) { |
klauss | 81:3656f00ab3db | 552 | char tmp[ 16 ]; |
klauss | 81:3656f00ab3db | 553 | strcat( str, itoa( cb_rx_buffer[ i ], tmp, 16 ) ); |
klauss | 81:3656f00ab3db | 554 | if( ( i != 0 ) && !( ( i + 1 ) % 50 ) ) strcat( str, "\n\r " ); |
klauss | 91:c2a86b1f8aaa | 555 | |
klauss | 81:3656f00ab3db | 556 | else strcat( str, " " ); |
klauss | 81:3656f00ab3db | 557 | } |
klauss | 81:3656f00ab3db | 558 | send_msg( "%s", str ); |
klauss | 91:c2a86b1f8aaa | 559 | rx = false; |
klauss | 81:3656f00ab3db | 560 | } |
klauss | 91:c2a86b1f8aaa | 561 | |
klauss | 117:e9facba9db27 | 562 | data = __parse_vz_pkg__( &ext, &port, &type, buffer ); |
klauss | 114:472502b31a12 | 563 | |
klauss | 117:e9facba9db27 | 564 | if( data != NULL ) { |
klauss | 78:1353744f01e1 | 565 | if( min_ext == 0 ) min_ext = ext; |
klauss | 91:c2a86b1f8aaa | 566 | |
klauss | 78:1353744f01e1 | 567 | if( ext > max_ext ) max_ext = ext; |
klauss | 91:c2a86b1f8aaa | 568 | |
klauss | 78:1353744f01e1 | 569 | if( ext < min_ext ) min_ext = ext; |
klauss | 99:e80850c51106 | 570 | |
klauss | 117:e9facba9db27 | 571 | if( debug_fw ){ |
klauss | 117:e9facba9db27 | 572 | fw_cbx_pkg( ext, port, ( char *)buffer ); |
klauss | 117:e9facba9db27 | 573 | } |
klauss | 99:e80850c51106 | 574 | |
klauss | 114:472502b31a12 | 575 | if( type == __TELEMETRY__ ) telemetry_counter++; |
klauss | 114:472502b31a12 | 576 | |
klauss | 114:472502b31a12 | 577 | if( type != __AUDIO__ ) { |
klauss | 99:e80850c51106 | 578 | if( |
klauss | 99:e80850c51106 | 579 | type == __TELEMETRY__ || |
klauss | 99:e80850c51106 | 580 | type == __CB_STATS__ || |
klauss | 99:e80850c51106 | 581 | type == __FW1__ || |
klauss | 99:e80850c51106 | 582 | type == __FW2__ || |
klauss | 99:e80850c51106 | 583 | type == __FW3__ || |
klauss | 99:e80850c51106 | 584 | type == __FW4__ || |
klauss | 99:e80850c51106 | 585 | type == __FW5__ || |
klauss | 99:e80850c51106 | 586 | type == __FW6__ |
klauss | 99:e80850c51106 | 587 | ) type = __FW__; |
klauss | 99:e80850c51106 | 588 | |
klauss | 99:e80850c51106 | 589 | if( debug_cb_rx == true ){ |
klauss | 99:e80850c51106 | 590 | send_msg("Pkg from CBx :: ( %d, %d ) -- Type :: %d", ext, port, type ); |
klauss | 99:e80850c51106 | 591 | } |
klauss | 99:e80850c51106 | 592 | |
klauss | 0:4d17cd9c8f9d | 593 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 91:c2a86b1f8aaa | 594 | if( cb != NULL ) { |
klauss | 92:92df17f538a8 | 595 | if( data[ 0 ] & BIT7 ) { |
klauss | 91:c2a86b1f8aaa | 596 | if( type == __BOOT__ ) { |
klauss | 117:e9facba9db27 | 597 | send2callboxes( __build_cb_package__( ext, port, __REGISTRY__, |
klauss | 117:e9facba9db27 | 598 | ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 92:92df17f538a8 | 599 | } else { |
klauss | 81:3656f00ab3db | 600 | if( debug_main ) debug_msg("Received ack pkg with seq_num %d", data[ 0 ] ); |
klauss | 91:c2a86b1f8aaa | 601 | |
klauss | 91:c2a86b1f8aaa | 602 | switch( type ) { |
klauss | 81:3656f00ab3db | 603 | case __INVITE__ : { |
klauss | 117:e9facba9db27 | 604 | if( debug_main || debug_invite ) debug_msg("Invite Ack from %d on msg_id %d", ext, cb->get_msg_id() ); |
klauss | 117:e9facba9db27 | 605 | //cb->first_invite_response_ok(); |
klauss | 91:c2a86b1f8aaa | 606 | break; |
klauss | 81:3656f00ab3db | 607 | } |
klauss | 81:3656f00ab3db | 608 | case __CB_BYE__ : { |
klauss | 81:3656f00ab3db | 609 | if( debug_main || debug_invite ) debug_msg("BYE Ack from %d on msg_id %d", ext, cb->get_msg_id() ); |
klauss | 81:3656f00ab3db | 610 | cb->set_bye_response_ok(); |
klauss | 91:c2a86b1f8aaa | 611 | break; |
klauss | 81:3656f00ab3db | 612 | } |
klauss | 81:3656f00ab3db | 613 | case __REGISTRY__ : { |
klauss | 81:3656f00ab3db | 614 | if( debug_main || debug_aging ) debug_msg("Registry ACK from %d in pkg :: %d", ext, cb->get_msg_id() ); |
klauss | 81:3656f00ab3db | 615 | break; |
klauss | 81:3656f00ab3db | 616 | } |
klauss | 81:3656f00ab3db | 617 | default : { |
klauss | 91:c2a86b1f8aaa | 618 | if( debug_main || debug_aging ) debug_msg("ACK from %d in pkg :: %d :: type %d", ext, cb->get_msg_id(), type ); |
klauss | 91:c2a86b1f8aaa | 619 | } |
klauss | 81:3656f00ab3db | 620 | } |
klauss | 117:e9facba9db27 | 621 | if( type != __REGISTRY__ && type != __CB_BYE__ ) type = __DO_NOTHING__; |
klauss | 92:92df17f538a8 | 622 | if( type == __CB_BYE__ ){ |
klauss | 92:92df17f538a8 | 623 | VZ_call * call = __find_Call__( v_call, ext ); |
klauss | 92:92df17f538a8 | 624 | if( call != NULL ){ |
klauss | 92:92df17f538a8 | 625 | if( call->get_elapsed_time() < 120000 ){ |
klauss | 92:92df17f538a8 | 626 | if( debug_invite ) debug_msg("%d ack bye ignored", ext ); |
klauss | 92:92df17f538a8 | 627 | type = __DO_NOTHING__; |
klauss | 92:92df17f538a8 | 628 | } |
klauss | 92:92df17f538a8 | 629 | } |
klauss | 92:92df17f538a8 | 630 | } |
klauss | 0:4d17cd9c8f9d | 631 | } |
klauss | 0:4d17cd9c8f9d | 632 | } |
klauss | 0:4d17cd9c8f9d | 633 | } |
klauss | 0:4d17cd9c8f9d | 634 | } |
klauss | 91:c2a86b1f8aaa | 635 | } else type = __DO_NOTHING__; |
klauss | 0:4d17cd9c8f9d | 636 | } |
klauss | 91:c2a86b1f8aaa | 637 | |
klauss | 117:e9facba9db27 | 638 | if( main_test == true ) { |
klauss | 117:e9facba9db27 | 639 | main_test = false; |
klauss | 85:b6f2dc1d0f4f | 640 | send_msg("CB_New (%u) -- CB_Delete (%u)", cb_new_counter, cb_delete_counter ); |
klauss | 85:b6f2dc1d0f4f | 641 | send_msg("SIP_New (%u) -- SIP_Delete (%u)", sip_new_counter, sip_delete_counter ); |
klauss | 87:679ee0d594a9 | 642 | send_msg("RTP_header_New (%u) -- RTP_header_Delete (%u)", rtp_header_new_counter, rtp_header_delete_counter ); |
klauss | 87:679ee0d594a9 | 643 | send_msg("RTP_body_New (%u) -- RTP_body_Delete (%u)", rtp_body_new_counter, rtp_body_delete_counter ); |
klauss | 109:a5b8264ffbbc | 644 | send_msg("Call_New (%u) -- Call_Delete (%u)", call_new_counter, call_delete_counter ); |
klauss | 87:679ee0d594a9 | 645 | send_msg("lpc_low_level_input_counter :: %d", lpc_low_level_input_counter ); |
klauss | 87:679ee0d594a9 | 646 | send_msg("Memory is %s", ( memory_is_over ) ? "Over" : "Ok" ); |
klauss | 81:3656f00ab3db | 647 | send_msg("Missed_Pkg :: %d ::", missed_pkg ); |
klauss | 87:679ee0d594a9 | 648 | send_msg("Sizeof Sip :: %u", sizeof( Sip ) ); |
klauss | 87:679ee0d594a9 | 649 | send_msg("Sizeof VZ_call :: %u", sizeof( VZ_call ) ); |
klauss | 87:679ee0d594a9 | 650 | send_msg("Sizeof RTP :: %u", sizeof( RTP ) ); |
klauss | 87:679ee0d594a9 | 651 | send_msg("Sizeof RTP_Header :: %u", sizeof( RTP_Header ) ); |
klauss | 87:679ee0d594a9 | 652 | send_msg("Sizeof RTP_Body :: %u", sizeof( RTP_Body ) ); |
klauss | 87:679ee0d594a9 | 653 | send_msg("Sizeof Vector :: %u", sizeof( Vector ) ); |
klauss | 87:679ee0d594a9 | 654 | send_msg("Sizeof Timeslice :: %u", sizeof( Timeslice ) ); |
klauss | 87:679ee0d594a9 | 655 | send_msg("Sizeof Watchdog :: %u", sizeof( Watchdog ) ); |
klauss | 117:e9facba9db27 | 656 | //VZ_call * call = new VZ_call( 1234, 9876, 413, 12093 ); |
klauss | 117:e9facba9db27 | 657 | //v_call -> add ( call ); |
klauss | 109:a5b8264ffbbc | 658 | } |
klauss | 117:e9facba9db27 | 659 | |
klauss | 117:e9facba9db27 | 660 | //static int wdt_count = 0; |
klauss | 117:e9facba9db27 | 661 | /* |
klauss | 117:e9facba9db27 | 662 | if( registry_test == true ) { |
klauss | 117:e9facba9db27 | 663 | registry_test = false; |
klauss | 117:e9facba9db27 | 664 | |
klauss | 117:e9facba9db27 | 665 | if( wdt_count++ > 5 || v_cb->size() < 66 ) { |
klauss | 117:e9facba9db27 | 666 | wdt_count = 0; |
klauss | 117:e9facba9db27 | 667 | |
klauss | 117:e9facba9db27 | 668 | if( type == __DO_NOTHING__ ) { |
klauss | 117:e9facba9db27 | 669 | if( next_value < ( 5002 + __MAX_CB_IN_A_BRANCH__ - 2 ) ) { |
klauss | 117:e9facba9db27 | 670 | //type = __REGISTRY__; |
klauss | 117:e9facba9db27 | 671 | data = buffer; |
klauss | 117:e9facba9db27 | 672 | ext = next_value; |
klauss | 117:e9facba9db27 | 673 | port = next_value++; |
klauss | 117:e9facba9db27 | 674 | } else { |
klauss | 117:e9facba9db27 | 675 | if( nex_test_registry > ( 5002 + __MAX_CB_IN_A_BRANCH__ - 1 - 2 ) ) nex_test_registry = 5002; |
klauss | 117:e9facba9db27 | 676 | //type = __REGISTRY__; |
klauss | 117:e9facba9db27 | 677 | data = buffer; |
klauss | 117:e9facba9db27 | 678 | ext = nex_test_registry; |
klauss | 117:e9facba9db27 | 679 | port = nex_test_registry++; |
klauss | 117:e9facba9db27 | 680 | } |
klauss | 117:e9facba9db27 | 681 | } |
klauss | 117:e9facba9db27 | 682 | } |
klauss | 117:e9facba9db27 | 683 | } |
klauss | 117:e9facba9db27 | 684 | */ |
klauss | 109:a5b8264ffbbc | 685 | |
klauss | 114:472502b31a12 | 686 | if ( registra ) |
klauss | 112:6ae726539ab9 | 687 | { |
klauss | 112:6ae726539ab9 | 688 | int internal_ext = 8000; |
klauss | 112:6ae726539ab9 | 689 | registra = false; |
klauss | 112:6ae726539ab9 | 690 | for( register uint8_t i = 0; i < 4; i++ ) { |
klauss | 112:6ae726539ab9 | 691 | v_cb -> add ( new Call_Box ( internal_ext, internal_ext++ ) ); |
klauss | 112:6ae726539ab9 | 692 | } |
klauss | 112:6ae726539ab9 | 693 | } |
klauss | 112:6ae726539ab9 | 694 | |
klauss | 109:a5b8264ffbbc | 695 | { |
klauss | 109:a5b8264ffbbc | 696 | fd_set fdSet; |
klauss | 109:a5b8264ffbbc | 697 | FD_ZERO(&fdSet); |
klauss | 109:a5b8264ffbbc | 698 | |
klauss | 109:a5b8264ffbbc | 699 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 109:a5b8264ffbbc | 700 | Call_Box * cb = (Call_Box *)v_cb->get_element( i ); |
klauss | 109:a5b8264ffbbc | 701 | FD_SET( cb->get_sip_socket_fd(), &fdSet); |
klauss | 109:a5b8264ffbbc | 702 | } |
klauss | 109:a5b8264ffbbc | 703 | |
klauss | 117:e9facba9db27 | 704 | /* Recepcao de pacotes UDP para atualizacao de callboxes */ |
klauss | 117:e9facba9db27 | 705 | FD_SET( udp_bl_client.get_fd(), &fdSet); |
klauss | 117:e9facba9db27 | 706 | |
klauss | 117:e9facba9db27 | 707 | /* Recepcao de pacotes UDP para "tickagem" do watchdog */ |
klauss | 109:a5b8264ffbbc | 708 | FD_SET( udp_wdt_client.get_fd(), &fdSet); |
klauss | 109:a5b8264ffbbc | 709 | |
klauss | 109:a5b8264ffbbc | 710 | struct timeval t; |
klauss | 109:a5b8264ffbbc | 711 | t.tv_sec = 0; |
klauss | 109:a5b8264ffbbc | 712 | t.tv_usec = 0; |
klauss | 109:a5b8264ffbbc | 713 | int ret = lwip_select( FD_SETSIZE, &fdSet, NULL, NULL, &t ); |
klauss | 117:e9facba9db27 | 714 | |
klauss | 117:e9facba9db27 | 715 | if ((udp_bl_timer.read() > 30) and (bl_start_flag)) { |
klauss | 117:e9facba9db27 | 716 | udp_bl_timer.stop(); |
klauss | 117:e9facba9db27 | 717 | udp_bl_timer.reset(); |
klauss | 117:e9facba9db27 | 718 | bl_start_flag = 0; |
klauss | 117:e9facba9db27 | 719 | if (bl_ts != 0) { |
klauss | 117:e9facba9db27 | 720 | ts->return_timeslice( bl_ts ); |
klauss | 117:e9facba9db27 | 721 | bl_ts = 0; |
klauss | 117:e9facba9db27 | 722 | } |
klauss | 117:e9facba9db27 | 723 | if (bl_cb != NULL) { |
klauss | 117:e9facba9db27 | 724 | bl_cb->set_timeslice( 0 ); |
klauss | 117:e9facba9db27 | 725 | set_status( bl_cb->status, cb_idle ); |
klauss | 117:e9facba9db27 | 726 | bl_cb = NULL; |
klauss | 117:e9facba9db27 | 727 | } |
klauss | 117:e9facba9db27 | 728 | } |
klauss | 109:a5b8264ffbbc | 729 | |
klauss | 109:a5b8264ffbbc | 730 | if(ret > 0 ) { |
klauss | 109:a5b8264ffbbc | 731 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 109:a5b8264ffbbc | 732 | Call_Box * cb = (Call_Box *)v_cb->get_element( i ); |
klauss | 109:a5b8264ffbbc | 733 | int fd = cb->get_sip_socket_fd(); |
klauss | 109:a5b8264ffbbc | 734 | if( FD_ISSET( fd, &fdSet ) ) { |
klauss | 109:a5b8264ffbbc | 735 | int rcv = cb->sip_udp_incomming_pkg(); |
klauss | 109:a5b8264ffbbc | 736 | } |
klauss | 109:a5b8264ffbbc | 737 | } |
klauss | 118:b93b17c50910 | 738 | |
klauss | 118:b93b17c50910 | 739 | /* Tratamento dos pacotes de bootloader vindo do servidor */ |
klauss | 118:b93b17c50910 | 740 | if( FD_ISSET( udp_bl_client.get_fd(), &fdSet ) ) { |
klauss | 118:b93b17c50910 | 741 | if( udp_bl_client.receiveFrom( udp_bl_server, bl_recv_buffer, sizeof( bl_recv_buffer ) ) > 0 ) { |
klauss | 118:b93b17c50910 | 742 | uint16_t cnt = 0; |
klauss | 118:b93b17c50910 | 743 | if (debug_bootloader) { |
klauss | 118:b93b17c50910 | 744 | pc.printf("\r\nPACOTE SRV->HDR {"); |
klauss | 118:b93b17c50910 | 745 | for (cnt = 0;cnt < UDP_BL_SIZE;cnt++) { |
klauss | 118:b93b17c50910 | 746 | if ((cnt % 30) == 0) { |
klauss | 118:b93b17c50910 | 747 | pc.printf("\r\n "); |
klauss | 118:b93b17c50910 | 748 | pc.printf(hex16(cnt)); |
klauss | 118:b93b17c50910 | 749 | pc.printf(" : "); |
klauss | 118:b93b17c50910 | 750 | } |
klauss | 118:b93b17c50910 | 751 | pc.printf(hex8(bl_recv_buffer[cnt])); |
klauss | 118:b93b17c50910 | 752 | pc.printf(", "); |
klauss | 118:b93b17c50910 | 753 | } |
klauss | 118:b93b17c50910 | 754 | pc.printf("\r\n}"); |
klauss | 118:b93b17c50910 | 755 | } |
klauss | 118:b93b17c50910 | 756 | bl_peer = ((uint8_t)bl_recv_buffer[0])*256 + (uint8_t)bl_recv_buffer[1]; |
klauss | 118:b93b17c50910 | 757 | bl_send_buffer[0] = bl_recv_buffer[0]; |
klauss | 118:b93b17c50910 | 758 | bl_send_buffer[1] = bl_recv_buffer[1]; |
klauss | 118:b93b17c50910 | 759 | for (cnt = 2;cnt < UDP_BL_SIZE;cnt++) { |
klauss | 118:b93b17c50910 | 760 | bl_send_buffer[cnt] = 0; |
klauss | 118:b93b17c50910 | 761 | } |
klauss | 118:b93b17c50910 | 762 | |
klauss | 118:b93b17c50910 | 763 | if ((bl_ts == 0) and !(bl_start_flag)) { |
klauss | 118:b93b17c50910 | 764 | bl_ts = ts->get_timeslice(); |
klauss | 118:b93b17c50910 | 765 | } |
klauss | 118:b93b17c50910 | 766 | |
klauss | 118:b93b17c50910 | 767 | /* caso nao haja timeslice disponivel informar servidor */ |
klauss | 118:b93b17c50910 | 768 | if ((bl_ts == 0) and !(bl_start_flag)) { |
klauss | 118:b93b17c50910 | 769 | strncpy(bl_send_buffer + 2,"cbxdead\x00",8); |
klauss | 118:b93b17c50910 | 770 | udp_bl_client.sendTo( udp_bl_server, bl_send_buffer, strlen( bl_send_buffer ) ); |
klauss | 118:b93b17c50910 | 771 | } else { |
klauss | 118:b93b17c50910 | 772 | |
klauss | 118:b93b17c50910 | 773 | /* pacote para verificar se o callbox esta disponivel */ |
klauss | 118:b93b17c50910 | 774 | if (!(strncmp(bl_recv_buffer + 2,"avaiable?",9))) { |
klauss | 118:b93b17c50910 | 775 | bl_start_flag = 1; |
klauss | 118:b93b17c50910 | 776 | udp_bl_timer.start(); |
klauss | 118:b93b17c50910 | 777 | udp_bl_timer.reset(); |
klauss | 118:b93b17c50910 | 778 | strncpy(bl_send_buffer + 2,"cbxalive\x00",9); |
klauss | 118:b93b17c50910 | 779 | if (debug_bootloader) { |
klauss | 118:b93b17c50910 | 780 | pc.printf("\r\nPACOTE HDR->SRV {"); |
klauss | 118:b93b17c50910 | 781 | for (cnt = 0;cnt < UDP_BL_SIZE;cnt++) { |
klauss | 118:b93b17c50910 | 782 | if ((cnt % 30) == 0) { |
klauss | 118:b93b17c50910 | 783 | pc.printf("\r\n "); |
klauss | 118:b93b17c50910 | 784 | pc.printf(hex16(cnt)); |
klauss | 118:b93b17c50910 | 785 | pc.printf(" : "); |
klauss | 118:b93b17c50910 | 786 | } |
klauss | 118:b93b17c50910 | 787 | pc.printf(hex8(bl_send_buffer[cnt])); |
klauss | 118:b93b17c50910 | 788 | pc.printf(", "); |
klauss | 118:b93b17c50910 | 789 | } |
klauss | 118:b93b17c50910 | 790 | pc.printf("\r\n}"); |
klauss | 118:b93b17c50910 | 791 | } |
klauss | 118:b93b17c50910 | 792 | udp_bl_client.sendTo( udp_bl_server, bl_send_buffer, strlen( bl_send_buffer ) ); |
klauss | 118:b93b17c50910 | 793 | } |
klauss | 118:b93b17c50910 | 794 | |
klauss | 118:b93b17c50910 | 795 | /* pacote para indicar o termino do processo de atualizacao */ |
klauss | 118:b93b17c50910 | 796 | else if (!(strncmp(bl_recv_buffer + 2,"finished",8))) { |
klauss | 118:b93b17c50910 | 797 | bl_start_flag = 0; |
klauss | 118:b93b17c50910 | 798 | if (bl_ts != 0) { |
klauss | 118:b93b17c50910 | 799 | ts->return_timeslice( bl_ts ); |
klauss | 118:b93b17c50910 | 800 | bl_ts = 0; |
klauss | 118:b93b17c50910 | 801 | } |
klauss | 118:b93b17c50910 | 802 | if (bl_cb != NULL) { |
klauss | 118:b93b17c50910 | 803 | bl_cb->set_timeslice( 0 ); |
klauss | 118:b93b17c50910 | 804 | set_status( bl_cb->status, cb_idle ); |
klauss | 118:b93b17c50910 | 805 | bl_cb = NULL; |
klauss | 118:b93b17c50910 | 806 | } |
klauss | 118:b93b17c50910 | 807 | } |
klauss | 118:b93b17c50910 | 808 | |
klauss | 118:b93b17c50910 | 809 | /* pacotes a serem repassados para o callbox */ |
klauss | 118:b93b17c50910 | 810 | else if (bl_start_flag) { |
klauss | 118:b93b17c50910 | 811 | uint16_t bl_cnt = 0; |
klauss | 118:b93b17c50910 | 812 | udp_bl_timer.reset(); |
klauss | 118:b93b17c50910 | 813 | /* pacote de ERASE enviado para o cbx */ |
klauss | 118:b93b17c50910 | 814 | /* neste momento a cabeceira sabe que o servidor se comunicou com o callbox */ |
klauss | 118:b93b17c50910 | 815 | if (!(strncmp(bl_recv_buffer + 2,"\x45",1))) { |
klauss | 118:b93b17c50910 | 816 | bl_cb = __find_CB__( v_cb, bl_peer ); |
klauss | 118:b93b17c50910 | 817 | if (bl_cb != NULL) { |
klauss | 118:b93b17c50910 | 818 | bl_cb->set_timeslice( bl_ts ); |
klauss | 118:b93b17c50910 | 819 | set_status( bl_cb->status, cb_bootloader ); |
klauss | 118:b93b17c50910 | 820 | } |
klauss | 118:b93b17c50910 | 821 | } |
klauss | 118:b93b17c50910 | 822 | /* pacote de OK enviado para o cbx */ |
klauss | 118:b93b17c50910 | 823 | /* neste momento a cabeceira desaloca o timeslice do callbox */ |
klauss | 118:b93b17c50910 | 824 | if (!(strncmp(bl_recv_buffer + 2,"\x4f\x00\x00\x00",4))) { |
klauss | 118:b93b17c50910 | 825 | ts->return_timeslice( bl_ts ); |
klauss | 118:b93b17c50910 | 826 | bl_ts = 0; |
klauss | 118:b93b17c50910 | 827 | if (bl_cb != NULL) { |
klauss | 118:b93b17c50910 | 828 | bl_cb->set_timeslice( 0 ); |
klauss | 118:b93b17c50910 | 829 | } |
klauss | 118:b93b17c50910 | 830 | } |
klauss | 118:b93b17c50910 | 831 | bl_cbx_buffer[0] = bl_ts; |
klauss | 118:b93b17c50910 | 832 | for (bl_cnt = 0; bl_cnt < BL_SIZE; bl_cnt++) { |
klauss | 118:b93b17c50910 | 833 | bl_cbx_buffer[bl_cnt + 1] = bl_recv_buffer[bl_cnt + 2]; |
klauss | 118:b93b17c50910 | 834 | } |
klauss | 118:b93b17c50910 | 835 | if (debug_bootloader) { |
klauss | 118:b93b17c50910 | 836 | pc.printf("\r\nPACOTE HDR->CBX {"); |
klauss | 118:b93b17c50910 | 837 | for (cnt = 0;cnt < BL_SIZE + 1;cnt++) { |
klauss | 118:b93b17c50910 | 838 | if ((cnt % 30) == 0) { |
klauss | 118:b93b17c50910 | 839 | pc.printf("\r\n "); |
klauss | 118:b93b17c50910 | 840 | pc.printf(hex16(cnt)); |
klauss | 118:b93b17c50910 | 841 | pc.printf(" : "); |
klauss | 118:b93b17c50910 | 842 | } |
klauss | 118:b93b17c50910 | 843 | pc.printf(hex8(bl_cbx_buffer[cnt])); |
klauss | 118:b93b17c50910 | 844 | pc.printf(", "); |
klauss | 118:b93b17c50910 | 845 | } |
klauss | 118:b93b17c50910 | 846 | pc.printf("\r\n}"); |
klauss | 118:b93b17c50910 | 847 | } |
klauss | 118:b93b17c50910 | 848 | if (bl_cb != NULL) { |
klauss | 118:b93b17c50910 | 849 | bl_port = bl_cb->get_port(); |
klauss | 118:b93b17c50910 | 850 | } else { |
klauss | 118:b93b17c50910 | 851 | bl_port = bl_peer; |
klauss | 118:b93b17c50910 | 852 | } |
klauss | 118:b93b17c50910 | 853 | send2callboxes( __build_cb_package__( bl_peer, bl_port, __BOOTLOADER_CBX__,bl_cbx_buffer, 0, BL_SIZE + 1, write_buffer) ); |
klauss | 118:b93b17c50910 | 854 | } |
klauss | 118:b93b17c50910 | 855 | } |
klauss | 118:b93b17c50910 | 856 | } |
klauss | 118:b93b17c50910 | 857 | } |
klauss | 118:b93b17c50910 | 858 | |
klauss | 109:a5b8264ffbbc | 859 | if( FD_ISSET( udp_wdt_client.get_fd(), &fdSet ) ) { |
klauss | 109:a5b8264ffbbc | 860 | char wake_msg[ 768 ]; |
klauss | 109:a5b8264ffbbc | 861 | Endpoint udp_wdt_server; |
klauss | 109:a5b8264ffbbc | 862 | |
klauss | 109:a5b8264ffbbc | 863 | if( udp_wdt_client.receiveFrom( udp_wdt_server, wake_msg, sizeof( wake_msg ) ) > 0 ){ |
klauss | 109:a5b8264ffbbc | 864 | if( !( strncmp( wake_msg, "alive", 5 ) ) ) { |
klauss | 109:a5b8264ffbbc | 865 | // Just ckeck but not set 'alive?' |
klauss | 109:a5b8264ffbbc | 866 | // 'alive*' - force wdt tick right now |
klauss | 109:a5b8264ffbbc | 867 | // Ckecking and set 'alive' |
klauss | 109:a5b8264ffbbc | 868 | bool question_alive = ( wake_msg[ 5 ] == '?' ); |
klauss | 109:a5b8264ffbbc | 869 | if( wake_msg[ 5 ] == '*' ) wdt.kick(); |
klauss | 109:a5b8264ffbbc | 870 | |
klauss | 109:a5b8264ffbbc | 871 | /* |
klauss | 109:a5b8264ffbbc | 872 | uint8_t registered_cbx = v_cb->size(); |
klauss | 109:a5b8264ffbbc | 873 | for( register int i = 0; i < v_cb->size(); i++ ){ |
klauss | 109:a5b8264ffbbc | 874 | Call_Box * cb = (Call_Box * )v_cb->get_element( i ); |
klauss | 109:a5b8264ffbbc | 875 | if( cb->is_timeout() ){ if( registered_cbx ) registered_cbx--; } |
klauss | 109:a5b8264ffbbc | 876 | } |
klauss | 109:a5b8264ffbbc | 877 | */ |
klauss | 109:a5b8264ffbbc | 878 | |
klauss | 109:a5b8264ffbbc | 879 | snprintf( wake_msg, 48,"wdt:%u,%u,%u,%c,%u,%u,%u,%u,%u:", |
klauss | 109:a5b8264ffbbc | 880 | uptime, |
klauss | 109:a5b8264ffbbc | 881 | invite_counter, |
klauss | 109:a5b8264ffbbc | 882 | external_wdt, |
klauss | 109:a5b8264ffbbc | 883 | ( wdt.WatchdogCausedReset() ) ? '1' : '0', |
klauss | 109:a5b8264ffbbc | 884 | cb_new_counter, |
klauss | 109:a5b8264ffbbc | 885 | v_cb->size(), |
klauss | 109:a5b8264ffbbc | 886 | ts->remain_timeslices(), |
klauss | 109:a5b8264ffbbc | 887 | sip_socket_send_failure, |
klauss | 109:a5b8264ffbbc | 888 | v_call->size() |
klauss | 109:a5b8264ffbbc | 889 | // registered_cbx |
klauss | 109:a5b8264ffbbc | 890 | ); |
klauss | 109:a5b8264ffbbc | 891 | wake_msg[ 768 - 1 ] = 0; |
klauss | 109:a5b8264ffbbc | 892 | udp_wdt_client.sendTo( udp_wdt_server, wake_msg, strlen( wake_msg ) ); |
klauss | 109:a5b8264ffbbc | 893 | |
klauss | 109:a5b8264ffbbc | 894 | if( ( (!question_alive) && ( cb_new_counter <= __MAX_CB_IN_A_BRANCH__ ) && ( cb_new_counter >= 2 ) ) ) { |
klauss | 109:a5b8264ffbbc | 895 | external_wdt = EXTERN_WDT_IDLE; |
klauss | 109:a5b8264ffbbc | 896 | } |
klauss | 109:a5b8264ffbbc | 897 | } else if( !( strncmp( wake_msg, "reset", 5 ) ) ) { |
klauss | 109:a5b8264ffbbc | 898 | external_wdt = 0; |
klauss | 109:a5b8264ffbbc | 899 | |
klauss | 109:a5b8264ffbbc | 900 | sprintf( wake_msg, "rst:%u:", uptime ); |
klauss | 109:a5b8264ffbbc | 901 | udp_wdt_client.sendTo( udp_wdt_server, wake_msg, strlen( wake_msg ) ); |
klauss | 109:a5b8264ffbbc | 902 | } |
klauss | 109:a5b8264ffbbc | 903 | } |
klauss | 109:a5b8264ffbbc | 904 | } |
klauss | 109:a5b8264ffbbc | 905 | } |
klauss | 109:a5b8264ffbbc | 906 | } |
klauss | 109:a5b8264ffbbc | 907 | |
klauss | 112:6ae726539ab9 | 908 | if ( cogumelo ) |
klauss | 112:6ae726539ab9 | 909 | { |
klauss | 112:6ae726539ab9 | 910 | cogumelo = false; |
klauss | 112:6ae726539ab9 | 911 | for( register int i = 0; i < v_cb->size(); i++ ) |
klauss | 112:6ae726539ab9 | 912 | { |
klauss | 112:6ae726539ab9 | 913 | Call_Box * cb = ( Call_Box * )v_cb->get_element( i ); |
klauss | 112:6ae726539ab9 | 914 | if ( cb ) |
klauss | 112:6ae726539ab9 | 915 | { |
klauss | 112:6ae726539ab9 | 916 | set_status( cb->status, cb_on_call ); |
klauss | 112:6ae726539ab9 | 917 | set_status( cb->sip->status, sip_on_call ); |
klauss | 112:6ae726539ab9 | 918 | } |
klauss | 112:6ae726539ab9 | 919 | else |
klauss | 112:6ae726539ab9 | 920 | { |
klauss | 112:6ae726539ab9 | 921 | debug_msg("%d congumelo missed", i ); |
klauss | 112:6ae726539ab9 | 922 | } |
klauss | 112:6ae726539ab9 | 923 | } |
klauss | 112:6ae726539ab9 | 924 | |
klauss | 112:6ae726539ab9 | 925 | } |
klauss | 112:6ae726539ab9 | 926 | |
klauss | 112:6ae726539ab9 | 927 | if ( gnomo ) |
klauss | 112:6ae726539ab9 | 928 | { |
klauss | 112:6ae726539ab9 | 929 | gnomo = false; |
klauss | 112:6ae726539ab9 | 930 | for( register int i = 0; i < v_cb->size(); i++ ) |
klauss | 112:6ae726539ab9 | 931 | { |
klauss | 112:6ae726539ab9 | 932 | Call_Box * cb = ( Call_Box * )v_cb->get_element( i ); |
klauss | 112:6ae726539ab9 | 933 | if ( cb ) |
klauss | 112:6ae726539ab9 | 934 | { |
klauss | 112:6ae726539ab9 | 935 | set_status( cb->status, cb_idle ); |
klauss | 112:6ae726539ab9 | 936 | set_status( cb->sip->status, sip_idle ); |
klauss | 112:6ae726539ab9 | 937 | } |
klauss | 112:6ae726539ab9 | 938 | else |
klauss | 112:6ae726539ab9 | 939 | { |
klauss | 112:6ae726539ab9 | 940 | debug_msg("%d gnomo missed", i ); |
klauss | 112:6ae726539ab9 | 941 | } |
klauss | 112:6ae726539ab9 | 942 | } |
klauss | 112:6ae726539ab9 | 943 | |
klauss | 112:6ae726539ab9 | 944 | } |
klauss | 112:6ae726539ab9 | 945 | |
klauss | 112:6ae726539ab9 | 946 | |
klauss | 109:a5b8264ffbbc | 947 | if( dshow_rtp == true ){ |
klauss | 109:a5b8264ffbbc | 948 | dshow_rtp = false; |
klauss | 109:a5b8264ffbbc | 949 | send_msg(":: RTP :: %u", v_cb->size() ); |
klauss | 109:a5b8264ffbbc | 950 | |
klauss | 109:a5b8264ffbbc | 951 | int ext_list[ __MAX_CB_IN_A_BRANCH__ ]; |
klauss | 109:a5b8264ffbbc | 952 | |
klauss | 109:a5b8264ffbbc | 953 | if( v_cb->size() >= 1 ) { |
klauss | 109:a5b8264ffbbc | 954 | for( register int i = 0; i < v_cb->size(); i++ ) |
klauss | 109:a5b8264ffbbc | 955 | { |
klauss | 109:a5b8264ffbbc | 956 | ext_list[ i ] = ( ( Call_Box * )v_cb->get_element( i ) )->get_ext(); |
klauss | 109:a5b8264ffbbc | 957 | } |
klauss | 109:a5b8264ffbbc | 958 | qsort( ext_list, v_cb->size(), sizeof( int ), ls_comp ); |
klauss | 109:a5b8264ffbbc | 959 | } |
klauss | 109:a5b8264ffbbc | 960 | |
klauss | 109:a5b8264ffbbc | 961 | for ( register uint8_t i = 0; i < v_cb->size(); i++ ) |
klauss | 109:a5b8264ffbbc | 962 | { |
klauss | 109:a5b8264ffbbc | 963 | Call_Box * cb = __find_CB__( v_cb, ext_list[ i ] ); |
klauss | 109:a5b8264ffbbc | 964 | if( cb != NULL ) |
klauss | 109:a5b8264ffbbc | 965 | { |
klauss | 109:a5b8264ffbbc | 966 | send_msg("CBX ( %d, %d ) - SIP ( %d, %d ) - RTP ( %d )", |
klauss | 109:a5b8264ffbbc | 967 | cb -> get_ext (), |
klauss | 109:a5b8264ffbbc | 968 | cb -> get_port (), |
klauss | 109:a5b8264ffbbc | 969 | cb -> get_sip_ext (), |
klauss | 109:a5b8264ffbbc | 970 | cb -> get_sip_port (), |
klauss | 109:a5b8264ffbbc | 971 | cb -> get_rtp_port () |
klauss | 109:a5b8264ffbbc | 972 | ); |
klauss | 109:a5b8264ffbbc | 973 | } |
klauss | 109:a5b8264ffbbc | 974 | } |
klauss | 109:a5b8264ffbbc | 975 | } |
klauss | 109:a5b8264ffbbc | 976 | |
klauss | 109:a5b8264ffbbc | 977 | if( malasia ) |
klauss | 109:a5b8264ffbbc | 978 | { |
klauss | 109:a5b8264ffbbc | 979 | malasia = false; |
klauss | 109:a5b8264ffbbc | 980 | // conclusao, mudar o nro nao impala, talvez mudar o nro no pacote ... |
klauss | 109:a5b8264ffbbc | 981 | Call_Box * cb = __find_CB__( v_cb, 5016 ); |
klauss | 109:a5b8264ffbbc | 982 | if( cb != NULL ) |
klauss | 109:a5b8264ffbbc | 983 | { |
klauss | 109:a5b8264ffbbc | 984 | cb -> set_rtp_port ( cb -> get_rtp_port () * 10 + 1 ); |
klauss | 109:a5b8264ffbbc | 985 | send_msg("CBX ( %d, %d ) - SIP ( %d, %d ) - RTP ( %d )", |
klauss | 109:a5b8264ffbbc | 986 | cb -> get_ext (), |
klauss | 109:a5b8264ffbbc | 987 | cb -> get_port (), |
klauss | 109:a5b8264ffbbc | 988 | cb -> get_sip_ext (), |
klauss | 109:a5b8264ffbbc | 989 | cb -> get_sip_port (), |
klauss | 109:a5b8264ffbbc | 990 | cb -> get_rtp_port () |
klauss | 109:a5b8264ffbbc | 991 | ); |
klauss | 109:a5b8264ffbbc | 992 | } |
klauss | 109:a5b8264ffbbc | 993 | } |
klauss | 109:a5b8264ffbbc | 994 | |
klauss | 109:a5b8264ffbbc | 995 | if( york ) |
klauss | 109:a5b8264ffbbc | 996 | { |
klauss | 109:a5b8264ffbbc | 997 | york = false; |
klauss | 109:a5b8264ffbbc | 998 | Call_Box * cb = __find_CB__( v_cb, 5016 ); |
klauss | 109:a5b8264ffbbc | 999 | if( cb != NULL ) |
klauss | 109:a5b8264ffbbc | 1000 | { |
klauss | 109:a5b8264ffbbc | 1001 | cb -> set_rtp_port ( 80 ); |
klauss | 109:a5b8264ffbbc | 1002 | send_msg("CBX ( %d, %d ) - SIP ( %d, %d ) - RTP ( %d )", |
klauss | 109:a5b8264ffbbc | 1003 | cb -> get_ext (), |
klauss | 109:a5b8264ffbbc | 1004 | cb -> get_port (), |
klauss | 109:a5b8264ffbbc | 1005 | cb -> get_sip_ext (), |
klauss | 109:a5b8264ffbbc | 1006 | cb -> get_sip_port (), |
klauss | 109:a5b8264ffbbc | 1007 | cb -> get_rtp_port () |
klauss | 109:a5b8264ffbbc | 1008 | ); |
klauss | 109:a5b8264ffbbc | 1009 | } |
klauss | 109:a5b8264ffbbc | 1010 | } |
klauss | 109:a5b8264ffbbc | 1011 | |
klauss | 109:a5b8264ffbbc | 1012 | if ( frtp ) |
klauss | 109:a5b8264ffbbc | 1013 | { |
klauss | 109:a5b8264ffbbc | 1014 | frtp = false; |
klauss | 109:a5b8264ffbbc | 1015 | Call_Box * cb = __find_CB__( v_cb, frtp_target ); |
klauss | 109:a5b8264ffbbc | 1016 | if ( cb != NULL ) |
klauss | 109:a5b8264ffbbc | 1017 | { |
klauss | 109:a5b8264ffbbc | 1018 | cb -> set_rtp_port ( -1008789032 ); |
klauss | 109:a5b8264ffbbc | 1019 | } |
klauss | 109:a5b8264ffbbc | 1020 | else |
klauss | 109:a5b8264ffbbc | 1021 | { |
klauss | 109:a5b8264ffbbc | 1022 | debug_msg("frtp fail"); |
klauss | 109:a5b8264ffbbc | 1023 | } |
klauss | 109:a5b8264ffbbc | 1024 | |
klauss | 109:a5b8264ffbbc | 1025 | } |
klauss | 109:a5b8264ffbbc | 1026 | |
klauss | 109:a5b8264ffbbc | 1027 | if ( rescue_rtp ) |
klauss | 109:a5b8264ffbbc | 1028 | { |
klauss | 109:a5b8264ffbbc | 1029 | rescue_rtp = false; |
klauss | 109:a5b8264ffbbc | 1030 | Call_Box * cb = __find_CB__( v_cb, rescue_rtp_target ); |
klauss | 109:a5b8264ffbbc | 1031 | if ( cb != NULL ) |
klauss | 109:a5b8264ffbbc | 1032 | { |
klauss | 109:a5b8264ffbbc | 1033 | cb -> set_rtp_port ( rescue_rtp_value ); |
klauss | 109:a5b8264ffbbc | 1034 | } |
klauss | 109:a5b8264ffbbc | 1035 | else |
klauss | 109:a5b8264ffbbc | 1036 | { |
klauss | 109:a5b8264ffbbc | 1037 | debug_msg("rescue rtp fail"); |
klauss | 109:a5b8264ffbbc | 1038 | } |
klauss | 109:a5b8264ffbbc | 1039 | |
klauss | 109:a5b8264ffbbc | 1040 | } |
klauss | 109:a5b8264ffbbc | 1041 | |
klauss | 109:a5b8264ffbbc | 1042 | if( america ) |
klauss | 109:a5b8264ffbbc | 1043 | { |
klauss | 109:a5b8264ffbbc | 1044 | america = false; |
klauss | 109:a5b8264ffbbc | 1045 | Call_Box * cb = __find_CB__( v_cb, 5016 ); |
klauss | 109:a5b8264ffbbc | 1046 | if( cb != NULL ) |
klauss | 109:a5b8264ffbbc | 1047 | { |
klauss | 109:a5b8264ffbbc | 1048 | cb -> set_rtp_port ( 8929415 ); |
klauss | 109:a5b8264ffbbc | 1049 | send_msg("CBX ( %d, %d ) - SIP ( %d, %d ) - RTP ( %d )", |
klauss | 109:a5b8264ffbbc | 1050 | cb -> get_ext (), |
klauss | 109:a5b8264ffbbc | 1051 | cb -> get_port (), |
klauss | 109:a5b8264ffbbc | 1052 | cb -> get_sip_ext (), |
klauss | 109:a5b8264ffbbc | 1053 | cb -> get_sip_port (), |
klauss | 109:a5b8264ffbbc | 1054 | cb -> get_rtp_port () |
klauss | 109:a5b8264ffbbc | 1055 | ); |
klauss | 109:a5b8264ffbbc | 1056 | } |
klauss | 109:a5b8264ffbbc | 1057 | } |
klauss | 109:a5b8264ffbbc | 1058 | |
klauss | 114:472502b31a12 | 1059 | //begin debug_print |
klauss | 109:a5b8264ffbbc | 1060 | if ( print_v_cb ) |
klauss | 109:a5b8264ffbbc | 1061 | { |
klauss | 109:a5b8264ffbbc | 1062 | print_v_cb = false; |
klauss | 114:472502b31a12 | 1063 | v_cb->print_yourself (); |
klauss | 109:a5b8264ffbbc | 1064 | } |
klauss | 109:a5b8264ffbbc | 1065 | |
klauss | 109:a5b8264ffbbc | 1066 | if ( print_v_call ) |
klauss | 109:a5b8264ffbbc | 1067 | { |
klauss | 109:a5b8264ffbbc | 1068 | print_v_call = false; |
klauss | 109:a5b8264ffbbc | 1069 | v_call->print_yourself (); |
klauss | 109:a5b8264ffbbc | 1070 | } |
klauss | 109:a5b8264ffbbc | 1071 | |
klauss | 109:a5b8264ffbbc | 1072 | if ( print_cb_var ) |
klauss | 109:a5b8264ffbbc | 1073 | { |
klauss | 109:a5b8264ffbbc | 1074 | print_cb_var = false; |
klauss | 109:a5b8264ffbbc | 1075 | Call_Box * cb = __find_CB__ ( v_cb, print_this_cb ); |
klauss | 109:a5b8264ffbbc | 1076 | if ( cb != NULL ) |
klauss | 109:a5b8264ffbbc | 1077 | { |
klauss | 109:a5b8264ffbbc | 1078 | cb -> print_yourself (); |
klauss | 109:a5b8264ffbbc | 1079 | } |
klauss | 109:a5b8264ffbbc | 1080 | else |
klauss | 109:a5b8264ffbbc | 1081 | { |
klauss | 109:a5b8264ffbbc | 1082 | if( print_values ) |
klauss | 109:a5b8264ffbbc | 1083 | { |
klauss | 109:a5b8264ffbbc | 1084 | debug_msg ("Objeto CBx ( %d ) nao encontrado", print_this_cb ); |
klauss | 109:a5b8264ffbbc | 1085 | } |
klauss | 109:a5b8264ffbbc | 1086 | else |
klauss | 109:a5b8264ffbbc | 1087 | { |
klauss | 109:a5b8264ffbbc | 1088 | send_msg ("Objeto CBx ( %d ) nao encontrado", print_this_cb ); |
klauss | 109:a5b8264ffbbc | 1089 | } |
klauss | 109:a5b8264ffbbc | 1090 | } |
klauss | 109:a5b8264ffbbc | 1091 | } |
klauss | 109:a5b8264ffbbc | 1092 | |
klauss | 109:a5b8264ffbbc | 1093 | if ( print_cb_all ) |
klauss | 109:a5b8264ffbbc | 1094 | { |
klauss | 109:a5b8264ffbbc | 1095 | print_cb_all = false; |
klauss | 109:a5b8264ffbbc | 1096 | |
klauss | 109:a5b8264ffbbc | 1097 | if ( v_cb -> size () == 0 ) |
klauss | 109:a5b8264ffbbc | 1098 | { |
klauss | 109:a5b8264ffbbc | 1099 | send_msg("known CBx :: 0"); |
klauss | 109:a5b8264ffbbc | 1100 | } |
klauss | 109:a5b8264ffbbc | 1101 | |
klauss | 109:a5b8264ffbbc | 1102 | for ( register uint8_t i = 0; i < v_cb->size(); i++ ) |
klauss | 109:a5b8264ffbbc | 1103 | { |
klauss | 109:a5b8264ffbbc | 1104 | Call_Box * cb = (Call_Box *)v_cb->get_element( i ); |
klauss | 109:a5b8264ffbbc | 1105 | |
klauss | 109:a5b8264ffbbc | 1106 | if ( cb != NULL ) |
klauss | 109:a5b8264ffbbc | 1107 | { |
klauss | 109:a5b8264ffbbc | 1108 | cb -> print_yourself (); |
klauss | 109:a5b8264ffbbc | 1109 | } |
klauss | 109:a5b8264ffbbc | 1110 | else |
klauss | 109:a5b8264ffbbc | 1111 | { |
klauss | 109:a5b8264ffbbc | 1112 | if ( print_values ) debug_msg ("Objeto CBx ( %d ) nao encontrado", i ); |
klauss | 109:a5b8264ffbbc | 1113 | } |
klauss | 109:a5b8264ffbbc | 1114 | } |
klauss | 109:a5b8264ffbbc | 1115 | } |
klauss | 109:a5b8264ffbbc | 1116 | |
klauss | 109:a5b8264ffbbc | 1117 | if ( print_hex_cb_var ) |
klauss | 109:a5b8264ffbbc | 1118 | { |
klauss | 109:a5b8264ffbbc | 1119 | print_hex_cb_var = false; |
klauss | 109:a5b8264ffbbc | 1120 | uint8_t * ptr = ( uint8_t * ) __find_CB__ ( v_cb, print_hex_this_cb ); |
klauss | 109:a5b8264ffbbc | 1121 | |
klauss | 109:a5b8264ffbbc | 1122 | if ( ptr != NULL ) |
klauss | 109:a5b8264ffbbc | 1123 | { |
klauss | 109:a5b8264ffbbc | 1124 | send_msg ("Values :: %p\r\n", ( void *) ptr ); |
klauss | 109:a5b8264ffbbc | 1125 | for ( register int i = 0; i < sizeof( Call_Box ); i++ ) |
klauss | 109:a5b8264ffbbc | 1126 | { |
klauss | 109:a5b8264ffbbc | 1127 | if( debug_uart3 ) pc.printf("%x", *ptr++ ); |
klauss | 109:a5b8264ffbbc | 1128 | |
klauss | 109:a5b8264ffbbc | 1129 | if ( ( i % 32 ) == 0 ) |
klauss | 109:a5b8264ffbbc | 1130 | { |
klauss | 109:a5b8264ffbbc | 1131 | if( i != 0 ) |
klauss | 109:a5b8264ffbbc | 1132 | { |
klauss | 109:a5b8264ffbbc | 1133 | if( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 109:a5b8264ffbbc | 1134 | } |
klauss | 109:a5b8264ffbbc | 1135 | else |
klauss | 109:a5b8264ffbbc | 1136 | { |
klauss | 109:a5b8264ffbbc | 1137 | if( debug_uart3 ) pc.printf(" "); |
klauss | 109:a5b8264ffbbc | 1138 | } |
klauss | 109:a5b8264ffbbc | 1139 | } |
klauss | 109:a5b8264ffbbc | 1140 | else |
klauss | 109:a5b8264ffbbc | 1141 | { |
klauss | 109:a5b8264ffbbc | 1142 | if( debug_uart3 ) pc.printf(" "); |
klauss | 109:a5b8264ffbbc | 1143 | } |
klauss | 109:a5b8264ffbbc | 1144 | } |
klauss | 109:a5b8264ffbbc | 1145 | if ( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 109:a5b8264ffbbc | 1146 | |
klauss | 109:a5b8264ffbbc | 1147 | if ( tcp_session ) { |
klauss | 109:a5b8264ffbbc | 1148 | char aux[ ( sizeof( Call_Box ) * 3 ) + 3 ]; |
klauss | 109:a5b8264ffbbc | 1149 | |
klauss | 109:a5b8264ffbbc | 1150 | for ( register int i = 0; i < ( sizeof( Call_Box ) * 3 ) + 3 ; i++ ) aux [ i ] = 0; |
klauss | 109:a5b8264ffbbc | 1151 | |
klauss | 109:a5b8264ffbbc | 1152 | uint8_t * ptr = ( uint8_t * ) __find_CB__ ( v_cb, print_hex_this_cb ); |
klauss | 109:a5b8264ffbbc | 1153 | |
klauss | 109:a5b8264ffbbc | 1154 | for ( register int i = 0; i < sizeof( Call_Box ); i++ ) |
klauss | 109:a5b8264ffbbc | 1155 | { |
klauss | 109:a5b8264ffbbc | 1156 | char tmp[ 16 ]; |
klauss | 109:a5b8264ffbbc | 1157 | sprintf( tmp, "%x ", *ptr++ ); |
klauss | 109:a5b8264ffbbc | 1158 | strcat( aux, tmp ); |
klauss | 109:a5b8264ffbbc | 1159 | } |
klauss | 109:a5b8264ffbbc | 1160 | |
klauss | 109:a5b8264ffbbc | 1161 | strcat( aux, "\n\r\0" ); |
klauss | 109:a5b8264ffbbc | 1162 | tcp_client.send_all( ( char *)aux, strlen( (char * )aux ) ); |
klauss | 109:a5b8264ffbbc | 1163 | tcp_client.send_all( "\r\n> ", strlen( "\r\n> " ) ); |
klauss | 109:a5b8264ffbbc | 1164 | } |
klauss | 109:a5b8264ffbbc | 1165 | } |
klauss | 109:a5b8264ffbbc | 1166 | else |
klauss | 109:a5b8264ffbbc | 1167 | { |
klauss | 109:a5b8264ffbbc | 1168 | if ( print_values ) debug_msg ("Objeto CBx ( %d ) nao encontrado", print_this_cb ); |
klauss | 109:a5b8264ffbbc | 1169 | } |
klauss | 81:3656f00ab3db | 1170 | } |
klauss | 106:a34fcf9f0e02 | 1171 | |
klauss | 109:a5b8264ffbbc | 1172 | if ( print_hex_cb_all ) |
klauss | 109:a5b8264ffbbc | 1173 | { |
klauss | 109:a5b8264ffbbc | 1174 | print_hex_cb_all = false; |
klauss | 109:a5b8264ffbbc | 1175 | |
klauss | 109:a5b8264ffbbc | 1176 | if ( v_cb -> size () == 0 ) |
klauss | 109:a5b8264ffbbc | 1177 | { |
klauss | 109:a5b8264ffbbc | 1178 | send_msg("known CBx :: 0"); |
klauss | 109:a5b8264ffbbc | 1179 | } |
klauss | 109:a5b8264ffbbc | 1180 | |
klauss | 109:a5b8264ffbbc | 1181 | for ( register uint8_t j = 0; j < v_cb->size(); j++ ) |
klauss | 109:a5b8264ffbbc | 1182 | { |
klauss | 109:a5b8264ffbbc | 1183 | uint8_t * ptr = ( uint8_t * ) v_cb->get_element( j ); |
klauss | 109:a5b8264ffbbc | 1184 | |
klauss | 109:a5b8264ffbbc | 1185 | if ( ptr != NULL ) |
klauss | 109:a5b8264ffbbc | 1186 | { |
klauss | 109:a5b8264ffbbc | 1187 | send_msg ("Values :: %p\r\n", ( void *) ptr ); |
klauss | 109:a5b8264ffbbc | 1188 | for ( register int i = 0; i < sizeof( Call_Box ); i++ ) |
klauss | 109:a5b8264ffbbc | 1189 | { |
klauss | 109:a5b8264ffbbc | 1190 | if( debug_uart3 ) pc.printf("%x", *ptr++ ); |
klauss | 109:a5b8264ffbbc | 1191 | |
klauss | 109:a5b8264ffbbc | 1192 | if ( ( i % 32 ) == 0 ) |
klauss | 109:a5b8264ffbbc | 1193 | { |
klauss | 109:a5b8264ffbbc | 1194 | if( i != 0 ) |
klauss | 109:a5b8264ffbbc | 1195 | { |
klauss | 109:a5b8264ffbbc | 1196 | if( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 109:a5b8264ffbbc | 1197 | } |
klauss | 109:a5b8264ffbbc | 1198 | else |
klauss | 109:a5b8264ffbbc | 1199 | { |
klauss | 109:a5b8264ffbbc | 1200 | if( debug_uart3 ) pc.printf(" "); |
klauss | 109:a5b8264ffbbc | 1201 | } |
klauss | 109:a5b8264ffbbc | 1202 | } |
klauss | 109:a5b8264ffbbc | 1203 | else |
klauss | 109:a5b8264ffbbc | 1204 | { |
klauss | 109:a5b8264ffbbc | 1205 | if( debug_uart3 ) pc.printf(" "); |
klauss | 109:a5b8264ffbbc | 1206 | } |
klauss | 109:a5b8264ffbbc | 1207 | } |
klauss | 109:a5b8264ffbbc | 1208 | if ( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 109:a5b8264ffbbc | 1209 | |
klauss | 109:a5b8264ffbbc | 1210 | if ( tcp_session ) { |
klauss | 109:a5b8264ffbbc | 1211 | char aux[ ( sizeof( Call_Box ) * 3 ) + 3 ]; |
klauss | 109:a5b8264ffbbc | 1212 | |
klauss | 109:a5b8264ffbbc | 1213 | for ( register int i = 0; i < ( sizeof( Call_Box ) * 3 ) + 3 ; i++ ) aux [ i ] = 0; |
klauss | 109:a5b8264ffbbc | 1214 | |
klauss | 109:a5b8264ffbbc | 1215 | uint8_t * ptr = ( uint8_t * ) v_cb->get_element( j ); |
klauss | 109:a5b8264ffbbc | 1216 | |
klauss | 109:a5b8264ffbbc | 1217 | for ( register int i = 0; i < sizeof( Call_Box ); i++ ) |
klauss | 109:a5b8264ffbbc | 1218 | { |
klauss | 109:a5b8264ffbbc | 1219 | char tmp[ 16 ]; |
klauss | 109:a5b8264ffbbc | 1220 | sprintf( tmp, "%x ", *ptr++ ); |
klauss | 109:a5b8264ffbbc | 1221 | strcat( aux, tmp ); |
klauss | 109:a5b8264ffbbc | 1222 | } |
klauss | 109:a5b8264ffbbc | 1223 | |
klauss | 109:a5b8264ffbbc | 1224 | strcat( aux, "\n\r\0" ); |
klauss | 109:a5b8264ffbbc | 1225 | tcp_client.send_all( ( char *)aux, strlen( (char * )aux ) ); |
klauss | 109:a5b8264ffbbc | 1226 | tcp_client.send_all( "\r\n> ", strlen( "\r\n> " ) ); |
klauss | 109:a5b8264ffbbc | 1227 | } |
klauss | 109:a5b8264ffbbc | 1228 | } |
klauss | 109:a5b8264ffbbc | 1229 | else |
klauss | 109:a5b8264ffbbc | 1230 | { |
klauss | 109:a5b8264ffbbc | 1231 | if ( print_values ) |
klauss | 109:a5b8264ffbbc | 1232 | { |
klauss | 109:a5b8264ffbbc | 1233 | debug_msg ("Objeto CBx ( %d ) nao encontrado", j ); |
klauss | 109:a5b8264ffbbc | 1234 | } |
klauss | 109:a5b8264ffbbc | 1235 | else |
klauss | 109:a5b8264ffbbc | 1236 | { |
klauss | 109:a5b8264ffbbc | 1237 | send_msg ("Objeto CBx ( %d ) nao encontrado", j ); |
klauss | 109:a5b8264ffbbc | 1238 | } |
klauss | 109:a5b8264ffbbc | 1239 | } |
klauss | 109:a5b8264ffbbc | 1240 | } |
klauss | 109:a5b8264ffbbc | 1241 | } |
klauss | 106:a34fcf9f0e02 | 1242 | |
klauss | 109:a5b8264ffbbc | 1243 | //begin Sip debug print |
klauss | 109:a5b8264ffbbc | 1244 | { |
klauss | 109:a5b8264ffbbc | 1245 | if ( print_sip_var ) |
klauss | 109:a5b8264ffbbc | 1246 | { |
klauss | 109:a5b8264ffbbc | 1247 | print_sip_var = false; |
klauss | 109:a5b8264ffbbc | 1248 | Call_Box * cb = __find_CB__ ( v_cb, print_this_sip ); |
klauss | 109:a5b8264ffbbc | 1249 | if ( cb != NULL ) |
klauss | 109:a5b8264ffbbc | 1250 | { |
klauss | 109:a5b8264ffbbc | 1251 | if( ( cb -> sip ) != NULL ) |
klauss | 109:a5b8264ffbbc | 1252 | { |
klauss | 109:a5b8264ffbbc | 1253 | cb -> sip -> print_yourself (); |
klauss | 109:a5b8264ffbbc | 1254 | } |
klauss | 109:a5b8264ffbbc | 1255 | else |
klauss | 109:a5b8264ffbbc | 1256 | { |
klauss | 109:a5b8264ffbbc | 1257 | if( print_values ) |
klauss | 109:a5b8264ffbbc | 1258 | { |
klauss | 109:a5b8264ffbbc | 1259 | debug_msg("Sip param of %d equals NULL", print_this_sip ); |
klauss | 109:a5b8264ffbbc | 1260 | } |
klauss | 109:a5b8264ffbbc | 1261 | else |
klauss | 109:a5b8264ffbbc | 1262 | { |
klauss | 109:a5b8264ffbbc | 1263 | send_msg("Sip param of %d equals NULL", print_this_sip ); |
klauss | 109:a5b8264ffbbc | 1264 | } |
klauss | 109:a5b8264ffbbc | 1265 | } |
klauss | 109:a5b8264ffbbc | 1266 | } |
klauss | 109:a5b8264ffbbc | 1267 | else |
klauss | 109:a5b8264ffbbc | 1268 | { |
klauss | 109:a5b8264ffbbc | 1269 | if ( print_values ) |
klauss | 109:a5b8264ffbbc | 1270 | { |
klauss | 109:a5b8264ffbbc | 1271 | debug_msg ("Objeto CBx ( %d ) nao encontrado", print_this_cb ); |
klauss | 109:a5b8264ffbbc | 1272 | } |
klauss | 109:a5b8264ffbbc | 1273 | else |
klauss | 109:a5b8264ffbbc | 1274 | { |
klauss | 109:a5b8264ffbbc | 1275 | send_msg ("Objeto CBx ( %d ) nao encontrado", print_this_cb ); |
klauss | 109:a5b8264ffbbc | 1276 | } } |
klauss | 109:a5b8264ffbbc | 1277 | } |
klauss | 109:a5b8264ffbbc | 1278 | |
klauss | 109:a5b8264ffbbc | 1279 | if ( print_sip_all ) |
klauss | 109:a5b8264ffbbc | 1280 | { |
klauss | 109:a5b8264ffbbc | 1281 | print_sip_all = false; |
klauss | 109:a5b8264ffbbc | 1282 | |
klauss | 109:a5b8264ffbbc | 1283 | if ( v_cb -> size () == 0 ) |
klauss | 109:a5b8264ffbbc | 1284 | { |
klauss | 109:a5b8264ffbbc | 1285 | send_msg("known CBx :: 0"); |
klauss | 109:a5b8264ffbbc | 1286 | } |
klauss | 109:a5b8264ffbbc | 1287 | |
klauss | 109:a5b8264ffbbc | 1288 | for ( register uint8_t i = 0; i < v_cb->size(); i++ ) |
klauss | 109:a5b8264ffbbc | 1289 | { |
klauss | 109:a5b8264ffbbc | 1290 | Call_Box * cb = (Call_Box *)v_cb->get_element( i ); |
klauss | 109:a5b8264ffbbc | 1291 | |
klauss | 109:a5b8264ffbbc | 1292 | if ( cb != NULL ) |
klauss | 109:a5b8264ffbbc | 1293 | { |
klauss | 109:a5b8264ffbbc | 1294 | if( ( cb -> sip ) != NULL ) |
klauss | 109:a5b8264ffbbc | 1295 | { |
klauss | 109:a5b8264ffbbc | 1296 | cb -> sip -> print_yourself (); |
klauss | 109:a5b8264ffbbc | 1297 | } |
klauss | 109:a5b8264ffbbc | 1298 | else |
klauss | 109:a5b8264ffbbc | 1299 | { |
klauss | 109:a5b8264ffbbc | 1300 | if( print_values ) |
klauss | 109:a5b8264ffbbc | 1301 | { |
klauss | 109:a5b8264ffbbc | 1302 | debug_msg("Sip param of %d equals NULL", print_this_sip ); |
klauss | 109:a5b8264ffbbc | 1303 | } |
klauss | 109:a5b8264ffbbc | 1304 | else |
klauss | 109:a5b8264ffbbc | 1305 | { |
klauss | 109:a5b8264ffbbc | 1306 | send_msg("Sip param of %d equals NULL", print_this_sip ); |
klauss | 109:a5b8264ffbbc | 1307 | } |
klauss | 109:a5b8264ffbbc | 1308 | } |
klauss | 109:a5b8264ffbbc | 1309 | } |
klauss | 109:a5b8264ffbbc | 1310 | else |
klauss | 109:a5b8264ffbbc | 1311 | { |
klauss | 109:a5b8264ffbbc | 1312 | if( print_values ) |
klauss | 109:a5b8264ffbbc | 1313 | { |
klauss | 109:a5b8264ffbbc | 1314 | debug_msg("CBx %d not found", print_this_sip ); |
klauss | 109:a5b8264ffbbc | 1315 | } |
klauss | 109:a5b8264ffbbc | 1316 | else |
klauss | 109:a5b8264ffbbc | 1317 | { |
klauss | 109:a5b8264ffbbc | 1318 | send_msg("CBx %d not found", print_this_sip ); |
klauss | 109:a5b8264ffbbc | 1319 | } |
klauss | 109:a5b8264ffbbc | 1320 | } |
klauss | 109:a5b8264ffbbc | 1321 | } |
klauss | 109:a5b8264ffbbc | 1322 | } |
klauss | 109:a5b8264ffbbc | 1323 | |
klauss | 109:a5b8264ffbbc | 1324 | if ( print_hex_sip_var ) |
klauss | 109:a5b8264ffbbc | 1325 | { |
klauss | 109:a5b8264ffbbc | 1326 | uint8_t * ptr = NULL; |
klauss | 109:a5b8264ffbbc | 1327 | |
klauss | 109:a5b8264ffbbc | 1328 | print_hex_sip_var = false; |
klauss | 109:a5b8264ffbbc | 1329 | Call_Box * cb = __find_CB__ ( v_cb, print_hex_this_sip ); |
klauss | 109:a5b8264ffbbc | 1330 | if( cb != NULL ) |
klauss | 109:a5b8264ffbbc | 1331 | { |
klauss | 109:a5b8264ffbbc | 1332 | if( ( cb -> sip ) != NULL ) |
klauss | 109:a5b8264ffbbc | 1333 | ptr = ( uint8_t * ) cb -> sip; |
klauss | 109:a5b8264ffbbc | 1334 | } |
klauss | 109:a5b8264ffbbc | 1335 | |
klauss | 109:a5b8264ffbbc | 1336 | if ( ptr != NULL ) |
klauss | 109:a5b8264ffbbc | 1337 | { |
klauss | 109:a5b8264ffbbc | 1338 | send_msg ("Values :: %p\r\n", ( void *) ptr ); |
klauss | 109:a5b8264ffbbc | 1339 | for ( register int i = 0; i < sizeof( Sip ); i++ ) |
klauss | 109:a5b8264ffbbc | 1340 | { |
klauss | 109:a5b8264ffbbc | 1341 | if( debug_uart3 ) pc.printf("%x", *ptr++ ); |
klauss | 109:a5b8264ffbbc | 1342 | |
klauss | 109:a5b8264ffbbc | 1343 | if ( ( i % 32 ) == 0 ) |
klauss | 109:a5b8264ffbbc | 1344 | { |
klauss | 109:a5b8264ffbbc | 1345 | if( i != 0 ) |
klauss | 109:a5b8264ffbbc | 1346 | { |
klauss | 109:a5b8264ffbbc | 1347 | if( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 109:a5b8264ffbbc | 1348 | } |
klauss | 109:a5b8264ffbbc | 1349 | else |
klauss | 109:a5b8264ffbbc | 1350 | { |
klauss | 109:a5b8264ffbbc | 1351 | if( debug_uart3 ) pc.printf(" "); |
klauss | 109:a5b8264ffbbc | 1352 | } |
klauss | 109:a5b8264ffbbc | 1353 | } |
klauss | 109:a5b8264ffbbc | 1354 | else |
klauss | 109:a5b8264ffbbc | 1355 | { |
klauss | 109:a5b8264ffbbc | 1356 | if( debug_uart3 ) pc.printf(" "); |
klauss | 109:a5b8264ffbbc | 1357 | } |
klauss | 109:a5b8264ffbbc | 1358 | } |
klauss | 109:a5b8264ffbbc | 1359 | if ( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 109:a5b8264ffbbc | 1360 | |
klauss | 109:a5b8264ffbbc | 1361 | if ( tcp_session ) { |
klauss | 109:a5b8264ffbbc | 1362 | char aux[ ( 32 * 3 ) + 5 ]; |
klauss | 109:a5b8264ffbbc | 1363 | |
klauss | 109:a5b8264ffbbc | 1364 | for ( register int i = 0; i < ( 32 * 3 ) + 5 ; i++ ) aux [ i ] = 0; |
klauss | 109:a5b8264ffbbc | 1365 | |
klauss | 109:a5b8264ffbbc | 1366 | ptr = NULL; |
klauss | 109:a5b8264ffbbc | 1367 | |
klauss | 109:a5b8264ffbbc | 1368 | print_hex_sip_var = false; |
klauss | 109:a5b8264ffbbc | 1369 | Call_Box * cb = __find_CB__ ( v_cb, print_hex_this_sip ); |
klauss | 109:a5b8264ffbbc | 1370 | if( cb != NULL ) |
klauss | 109:a5b8264ffbbc | 1371 | { |
klauss | 109:a5b8264ffbbc | 1372 | if( ( cb -> sip ) != NULL ) |
klauss | 109:a5b8264ffbbc | 1373 | ptr = ( uint8_t * ) cb -> sip; |
klauss | 109:a5b8264ffbbc | 1374 | } |
klauss | 109:a5b8264ffbbc | 1375 | |
klauss | 109:a5b8264ffbbc | 1376 | if ( ptr != NULL ) |
klauss | 109:a5b8264ffbbc | 1377 | { |
klauss | 109:a5b8264ffbbc | 1378 | bool finished = false; |
klauss | 109:a5b8264ffbbc | 1379 | volatile int i = 0; |
klauss | 109:a5b8264ffbbc | 1380 | int count = 0; |
klauss | 109:a5b8264ffbbc | 1381 | Timer dont_overwrite_tcp_buffer; |
klauss | 109:a5b8264ffbbc | 1382 | dont_overwrite_tcp_buffer.reset (); |
klauss | 109:a5b8264ffbbc | 1383 | dont_overwrite_tcp_buffer.start (); |
klauss | 109:a5b8264ffbbc | 1384 | |
klauss | 109:a5b8264ffbbc | 1385 | while ( !finished ) |
klauss | 109:a5b8264ffbbc | 1386 | { |
klauss | 109:a5b8264ffbbc | 1387 | if( dont_overwrite_tcp_buffer.read_ms () >= 500 ) |
klauss | 109:a5b8264ffbbc | 1388 | { |
klauss | 109:a5b8264ffbbc | 1389 | dont_overwrite_tcp_buffer.reset(); |
klauss | 109:a5b8264ffbbc | 1390 | for ( ; i < sizeof( Sip ); i++ ) |
klauss | 109:a5b8264ffbbc | 1391 | { |
klauss | 109:a5b8264ffbbc | 1392 | char tmp[ 16 ]; |
klauss | 109:a5b8264ffbbc | 1393 | sprintf( tmp, "%x ", *ptr++ ); |
klauss | 109:a5b8264ffbbc | 1394 | strcat( aux, tmp ); |
klauss | 109:a5b8264ffbbc | 1395 | count++; |
klauss | 109:a5b8264ffbbc | 1396 | |
klauss | 109:a5b8264ffbbc | 1397 | if ( count >= 32 ) |
klauss | 109:a5b8264ffbbc | 1398 | { |
klauss | 109:a5b8264ffbbc | 1399 | count = 0; |
klauss | 109:a5b8264ffbbc | 1400 | i++; |
klauss | 109:a5b8264ffbbc | 1401 | break; |
klauss | 109:a5b8264ffbbc | 1402 | } |
klauss | 109:a5b8264ffbbc | 1403 | } |
klauss | 109:a5b8264ffbbc | 1404 | strcat ( aux, "\n\r\0" ); |
klauss | 109:a5b8264ffbbc | 1405 | tcp_client.send_all ( ( char *)aux, strlen( (char * )aux ) ); |
klauss | 109:a5b8264ffbbc | 1406 | if ( i >= sizeof ( Sip ) ) finished = true; |
klauss | 109:a5b8264ffbbc | 1407 | strcpy ( aux, "\0" ); |
klauss | 109:a5b8264ffbbc | 1408 | } |
klauss | 109:a5b8264ffbbc | 1409 | } |
klauss | 109:a5b8264ffbbc | 1410 | dont_overwrite_tcp_buffer.reset(); |
klauss | 109:a5b8264ffbbc | 1411 | dont_overwrite_tcp_buffer.stop(); |
klauss | 109:a5b8264ffbbc | 1412 | tcp_client.send_all ( "\r\n> ", strlen( "\r\n> " ) ); |
klauss | 109:a5b8264ffbbc | 1413 | } |
klauss | 109:a5b8264ffbbc | 1414 | } |
klauss | 109:a5b8264ffbbc | 1415 | } |
klauss | 109:a5b8264ffbbc | 1416 | else |
klauss | 109:a5b8264ffbbc | 1417 | { |
klauss | 109:a5b8264ffbbc | 1418 | if ( print_values ) debug_msg ("Objeto CBx ( %d ) nao encontrado", print_this_cb ); |
klauss | 109:a5b8264ffbbc | 1419 | } |
klauss | 109:a5b8264ffbbc | 1420 | } |
klauss | 109:a5b8264ffbbc | 1421 | /* |
klauss | 109:a5b8264ffbbc | 1422 | if ( print_hex_cb_all ) |
klauss | 109:a5b8264ffbbc | 1423 | { |
klauss | 109:a5b8264ffbbc | 1424 | print_hex_cb_all = false; |
klauss | 109:a5b8264ffbbc | 1425 | |
klauss | 109:a5b8264ffbbc | 1426 | if ( v_cb -> size () == 0 ) |
klauss | 109:a5b8264ffbbc | 1427 | { |
klauss | 109:a5b8264ffbbc | 1428 | send_msg("known CBx :: 0"); |
klauss | 109:a5b8264ffbbc | 1429 | } |
klauss | 109:a5b8264ffbbc | 1430 | |
klauss | 109:a5b8264ffbbc | 1431 | for ( register uint8_t j = 0; j < v_cb->size(); j++ ) |
klauss | 109:a5b8264ffbbc | 1432 | { |
klauss | 109:a5b8264ffbbc | 1433 | uint8_t * ptr = ( uint8_t * ) v_cb->get_element( j ); |
klauss | 109:a5b8264ffbbc | 1434 | |
klauss | 109:a5b8264ffbbc | 1435 | if ( ptr != NULL ) |
klauss | 109:a5b8264ffbbc | 1436 | { |
klauss | 109:a5b8264ffbbc | 1437 | send_msg ("Values :: %p\r\n", ( void *) ptr ); |
klauss | 109:a5b8264ffbbc | 1438 | for ( register int i = 0; i < sizeof( Call_Box ); i++ ) |
klauss | 109:a5b8264ffbbc | 1439 | { |
klauss | 109:a5b8264ffbbc | 1440 | if( debug_uart3 ) pc.printf("%x", *ptr++ ); |
klauss | 109:a5b8264ffbbc | 1441 | |
klauss | 109:a5b8264ffbbc | 1442 | if ( ( i % 32 ) == 0 ) |
klauss | 109:a5b8264ffbbc | 1443 | { |
klauss | 109:a5b8264ffbbc | 1444 | if( i != 0 ) |
klauss | 109:a5b8264ffbbc | 1445 | { |
klauss | 109:a5b8264ffbbc | 1446 | if( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 109:a5b8264ffbbc | 1447 | } |
klauss | 109:a5b8264ffbbc | 1448 | else |
klauss | 109:a5b8264ffbbc | 1449 | { |
klauss | 109:a5b8264ffbbc | 1450 | if( debug_uart3 ) pc.printf(" "); |
klauss | 109:a5b8264ffbbc | 1451 | } |
klauss | 109:a5b8264ffbbc | 1452 | } |
klauss | 109:a5b8264ffbbc | 1453 | else |
klauss | 109:a5b8264ffbbc | 1454 | { |
klauss | 109:a5b8264ffbbc | 1455 | if( debug_uart3 ) pc.printf(" "); |
klauss | 109:a5b8264ffbbc | 1456 | } |
klauss | 109:a5b8264ffbbc | 1457 | } |
klauss | 109:a5b8264ffbbc | 1458 | if ( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 109:a5b8264ffbbc | 1459 | |
klauss | 109:a5b8264ffbbc | 1460 | if ( tcp_session ) { |
klauss | 109:a5b8264ffbbc | 1461 | char aux[ ( sizeof( Call_Box ) * 3 ) + 3 ]; |
klauss | 109:a5b8264ffbbc | 1462 | |
klauss | 109:a5b8264ffbbc | 1463 | for ( register int i = 0; i < ( sizeof( Call_Box ) * 3 ) + 3 ; i++ ) aux [ i ] = 0; |
klauss | 109:a5b8264ffbbc | 1464 | |
klauss | 109:a5b8264ffbbc | 1465 | uint8_t * ptr = ( uint8_t * ) v_cb->get_element( j ); |
klauss | 109:a5b8264ffbbc | 1466 | |
klauss | 109:a5b8264ffbbc | 1467 | for ( register int i = 0; i < sizeof( Call_Box ); i++ ) |
klauss | 109:a5b8264ffbbc | 1468 | { |
klauss | 109:a5b8264ffbbc | 1469 | char tmp[ 16 ]; |
klauss | 109:a5b8264ffbbc | 1470 | sprintf( tmp, "%x ", *ptr++ ); |
klauss | 109:a5b8264ffbbc | 1471 | strcat( aux, tmp ); |
klauss | 109:a5b8264ffbbc | 1472 | } |
klauss | 109:a5b8264ffbbc | 1473 | |
klauss | 109:a5b8264ffbbc | 1474 | strcat( aux, "\n\r\0" ); |
klauss | 109:a5b8264ffbbc | 1475 | tcp_client.send_all( ( char *)aux, strlen( (char * )aux ) ); |
klauss | 109:a5b8264ffbbc | 1476 | tcp_client.send_all( "\r\n> ", strlen( "\r\n> " ) ); |
klauss | 109:a5b8264ffbbc | 1477 | } |
klauss | 109:a5b8264ffbbc | 1478 | } |
klauss | 109:a5b8264ffbbc | 1479 | else |
klauss | 109:a5b8264ffbbc | 1480 | { |
klauss | 109:a5b8264ffbbc | 1481 | if ( print_values ) debug_msg ("Objeto CBx ( %d ) nao encontrado", j ); |
klauss | 109:a5b8264ffbbc | 1482 | } |
klauss | 109:a5b8264ffbbc | 1483 | } |
klauss | 109:a5b8264ffbbc | 1484 | } |
klauss | 109:a5b8264ffbbc | 1485 | */ |
klauss | 109:a5b8264ffbbc | 1486 | }//end Sip debug print |
klauss | 109:a5b8264ffbbc | 1487 | |
klauss | 109:a5b8264ffbbc | 1488 | if( dcallshow_rtp == true ){ |
klauss | 109:a5b8264ffbbc | 1489 | dcallshow_rtp = false; |
klauss | 109:a5b8264ffbbc | 1490 | send_msg(":: CAll RTP :: %u", v_call->size() ); |
klauss | 109:a5b8264ffbbc | 1491 | for( register uint8_t i = 0; i < v_call->size(); i++ ) { |
klauss | 109:a5b8264ffbbc | 1492 | VZ_call * call = ( VZ_call * )v_call->get_element( i ); |
klauss | 109:a5b8264ffbbc | 1493 | if( call != NULL ) |
klauss | 109:a5b8264ffbbc | 1494 | { |
klauss | 109:a5b8264ffbbc | 1495 | send_msg("CBX ( %d, %d ) - Server ( %d, %d )", |
klauss | 109:a5b8264ffbbc | 1496 | call->get_cb_ext(), |
klauss | 109:a5b8264ffbbc | 1497 | call->get_cb_port(), |
klauss | 109:a5b8264ffbbc | 1498 | call->get_rtp_server_ext(), |
klauss | 109:a5b8264ffbbc | 1499 | call->get_rtp_server_port() |
klauss | 109:a5b8264ffbbc | 1500 | ); |
klauss | 109:a5b8264ffbbc | 1501 | } |
klauss | 109:a5b8264ffbbc | 1502 | } |
klauss | 109:a5b8264ffbbc | 1503 | } |
klauss | 109:a5b8264ffbbc | 1504 | |
klauss | 109:a5b8264ffbbc | 1505 | if ( print_call_var ) |
klauss | 109:a5b8264ffbbc | 1506 | { |
klauss | 109:a5b8264ffbbc | 1507 | print_call_var = false; |
klauss | 109:a5b8264ffbbc | 1508 | VZ_call * call = __find_Call__( v_call, print_this_call ); |
klauss | 109:a5b8264ffbbc | 1509 | if ( call != NULL ) |
klauss | 109:a5b8264ffbbc | 1510 | { |
klauss | 109:a5b8264ffbbc | 1511 | send_msg ("Values :: %p\r\n", ( void *) call ); |
klauss | 109:a5b8264ffbbc | 1512 | call -> print_yourself (); |
klauss | 109:a5b8264ffbbc | 1513 | } |
klauss | 109:a5b8264ffbbc | 1514 | else |
klauss | 109:a5b8264ffbbc | 1515 | { |
klauss | 109:a5b8264ffbbc | 1516 | if( print_values ) |
klauss | 109:a5b8264ffbbc | 1517 | { |
klauss | 109:a5b8264ffbbc | 1518 | debug_msg("Call %d not found", print_this_call ); |
klauss | 109:a5b8264ffbbc | 1519 | } |
klauss | 109:a5b8264ffbbc | 1520 | else |
klauss | 109:a5b8264ffbbc | 1521 | { |
klauss | 109:a5b8264ffbbc | 1522 | send_msg("Call %d not found", print_this_call ); |
klauss | 109:a5b8264ffbbc | 1523 | } |
klauss | 109:a5b8264ffbbc | 1524 | } |
klauss | 109:a5b8264ffbbc | 1525 | } |
klauss | 109:a5b8264ffbbc | 1526 | |
klauss | 109:a5b8264ffbbc | 1527 | if ( print_hex_call_var ) |
klauss | 109:a5b8264ffbbc | 1528 | { |
klauss | 109:a5b8264ffbbc | 1529 | print_hex_call_var = false; |
klauss | 109:a5b8264ffbbc | 1530 | VZ_call * call = __find_Call__( v_call, print_hex_this_call ); |
klauss | 109:a5b8264ffbbc | 1531 | |
klauss | 109:a5b8264ffbbc | 1532 | uint8_t * ptr = NULL; |
klauss | 109:a5b8264ffbbc | 1533 | if( call != NULL ) |
klauss | 109:a5b8264ffbbc | 1534 | { |
klauss | 109:a5b8264ffbbc | 1535 | ptr = ( uint8_t * ) call; |
klauss | 109:a5b8264ffbbc | 1536 | } |
klauss | 109:a5b8264ffbbc | 1537 | |
klauss | 109:a5b8264ffbbc | 1538 | if ( ptr != NULL ) |
klauss | 109:a5b8264ffbbc | 1539 | { |
klauss | 109:a5b8264ffbbc | 1540 | send_msg ("Values :: %p\r\n", ( void *) ptr ); |
klauss | 109:a5b8264ffbbc | 1541 | for ( register int i = 0; i < sizeof( VZ_call ); i++ ) |
klauss | 109:a5b8264ffbbc | 1542 | { |
klauss | 109:a5b8264ffbbc | 1543 | if( debug_uart3 ) pc.printf("%x", *ptr++ ); |
klauss | 109:a5b8264ffbbc | 1544 | |
klauss | 109:a5b8264ffbbc | 1545 | if ( ( i % 32 ) == 0 ) |
klauss | 109:a5b8264ffbbc | 1546 | { |
klauss | 109:a5b8264ffbbc | 1547 | if( i != 0 ) |
klauss | 109:a5b8264ffbbc | 1548 | { |
klauss | 109:a5b8264ffbbc | 1549 | if( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 109:a5b8264ffbbc | 1550 | } |
klauss | 109:a5b8264ffbbc | 1551 | else |
klauss | 109:a5b8264ffbbc | 1552 | { |
klauss | 109:a5b8264ffbbc | 1553 | if( debug_uart3 ) pc.printf(" "); |
klauss | 109:a5b8264ffbbc | 1554 | } |
klauss | 109:a5b8264ffbbc | 1555 | } |
klauss | 109:a5b8264ffbbc | 1556 | else |
klauss | 109:a5b8264ffbbc | 1557 | { |
klauss | 109:a5b8264ffbbc | 1558 | if( debug_uart3 ) pc.printf(" "); |
klauss | 109:a5b8264ffbbc | 1559 | } |
klauss | 109:a5b8264ffbbc | 1560 | } |
klauss | 109:a5b8264ffbbc | 1561 | if ( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 109:a5b8264ffbbc | 1562 | |
klauss | 109:a5b8264ffbbc | 1563 | if ( tcp_session ) { |
klauss | 109:a5b8264ffbbc | 1564 | char aux[ ( 32 * 3 ) + 5 ]; |
klauss | 109:a5b8264ffbbc | 1565 | |
klauss | 109:a5b8264ffbbc | 1566 | for ( register int i = 0; i < ( 32 * 3 ) + 5 ; i++ ) aux [ i ] = 0; |
klauss | 109:a5b8264ffbbc | 1567 | |
klauss | 109:a5b8264ffbbc | 1568 | ptr = NULL; |
klauss | 109:a5b8264ffbbc | 1569 | |
klauss | 109:a5b8264ffbbc | 1570 | VZ_call * call = __find_Call__( v_call, print_hex_this_call ); |
klauss | 109:a5b8264ffbbc | 1571 | |
klauss | 109:a5b8264ffbbc | 1572 | uint8_t * ptr = NULL; |
klauss | 109:a5b8264ffbbc | 1573 | if( call != NULL ) |
klauss | 109:a5b8264ffbbc | 1574 | { |
klauss | 109:a5b8264ffbbc | 1575 | ptr = ( uint8_t * ) call; |
klauss | 109:a5b8264ffbbc | 1576 | } |
klauss | 109:a5b8264ffbbc | 1577 | |
klauss | 109:a5b8264ffbbc | 1578 | if ( ptr != NULL ) |
klauss | 109:a5b8264ffbbc | 1579 | { |
klauss | 109:a5b8264ffbbc | 1580 | bool finished = false; |
klauss | 109:a5b8264ffbbc | 1581 | volatile int i = 0; |
klauss | 109:a5b8264ffbbc | 1582 | int count = 0; |
klauss | 109:a5b8264ffbbc | 1583 | Timer dont_overwrite_tcp_buffer; |
klauss | 109:a5b8264ffbbc | 1584 | dont_overwrite_tcp_buffer.reset (); |
klauss | 109:a5b8264ffbbc | 1585 | dont_overwrite_tcp_buffer.start (); |
klauss | 109:a5b8264ffbbc | 1586 | |
klauss | 109:a5b8264ffbbc | 1587 | while ( !finished ) |
klauss | 109:a5b8264ffbbc | 1588 | { |
klauss | 109:a5b8264ffbbc | 1589 | if( dont_overwrite_tcp_buffer.read_ms () >= 20 ) |
klauss | 109:a5b8264ffbbc | 1590 | { |
klauss | 109:a5b8264ffbbc | 1591 | dont_overwrite_tcp_buffer.reset(); |
klauss | 109:a5b8264ffbbc | 1592 | for ( ; i < sizeof( VZ_call ); i++ ) |
klauss | 109:a5b8264ffbbc | 1593 | { |
klauss | 109:a5b8264ffbbc | 1594 | char tmp[ 16 ]; |
klauss | 109:a5b8264ffbbc | 1595 | sprintf( tmp, "%x ", *ptr++ ); |
klauss | 109:a5b8264ffbbc | 1596 | strcat( aux, tmp ); |
klauss | 109:a5b8264ffbbc | 1597 | count++; |
klauss | 109:a5b8264ffbbc | 1598 | |
klauss | 109:a5b8264ffbbc | 1599 | if ( count >= 32 ) |
klauss | 109:a5b8264ffbbc | 1600 | { |
klauss | 109:a5b8264ffbbc | 1601 | count = 0; |
klauss | 109:a5b8264ffbbc | 1602 | i++; |
klauss | 109:a5b8264ffbbc | 1603 | break; |
klauss | 109:a5b8264ffbbc | 1604 | } |
klauss | 109:a5b8264ffbbc | 1605 | } |
klauss | 109:a5b8264ffbbc | 1606 | strcat ( aux, "\n\r\0" ); |
klauss | 109:a5b8264ffbbc | 1607 | tcp_client.send_all ( ( char *)aux, strlen( (char * )aux ) ); |
klauss | 109:a5b8264ffbbc | 1608 | if ( i >= sizeof ( VZ_call ) ) finished = true; |
klauss | 109:a5b8264ffbbc | 1609 | strcpy ( aux, "\0" ); |
klauss | 109:a5b8264ffbbc | 1610 | } |
klauss | 109:a5b8264ffbbc | 1611 | } |
klauss | 109:a5b8264ffbbc | 1612 | dont_overwrite_tcp_buffer.reset(); |
klauss | 109:a5b8264ffbbc | 1613 | dont_overwrite_tcp_buffer.stop(); |
klauss | 109:a5b8264ffbbc | 1614 | tcp_client.send_all ( "\r\n> ", strlen( "\r\n> " ) ); |
klauss | 109:a5b8264ffbbc | 1615 | } |
klauss | 109:a5b8264ffbbc | 1616 | } |
klauss | 109:a5b8264ffbbc | 1617 | } |
klauss | 109:a5b8264ffbbc | 1618 | else |
klauss | 109:a5b8264ffbbc | 1619 | { |
klauss | 109:a5b8264ffbbc | 1620 | if( print_values ) |
klauss | 109:a5b8264ffbbc | 1621 | { |
klauss | 109:a5b8264ffbbc | 1622 | debug_msg("Call %d not found", print_this_call ); |
klauss | 109:a5b8264ffbbc | 1623 | } |
klauss | 109:a5b8264ffbbc | 1624 | else |
klauss | 109:a5b8264ffbbc | 1625 | { |
klauss | 109:a5b8264ffbbc | 1626 | send_msg("Call %d not found", print_this_call ); |
klauss | 109:a5b8264ffbbc | 1627 | } |
klauss | 109:a5b8264ffbbc | 1628 | } |
klauss | 109:a5b8264ffbbc | 1629 | } |
klauss | 109:a5b8264ffbbc | 1630 | |
klauss | 109:a5b8264ffbbc | 1631 | |
klauss | 109:a5b8264ffbbc | 1632 | if ( print_hex_rtp_var ) |
klauss | 109:a5b8264ffbbc | 1633 | { |
klauss | 109:a5b8264ffbbc | 1634 | print_hex_rtp_var = false; |
klauss | 109:a5b8264ffbbc | 1635 | VZ_call * call = __find_Call__( v_call, print_hex_this_rtp ); |
klauss | 109:a5b8264ffbbc | 1636 | |
klauss | 109:a5b8264ffbbc | 1637 | uint8_t * ptr = NULL; |
klauss | 109:a5b8264ffbbc | 1638 | if( call != NULL ) |
klauss | 109:a5b8264ffbbc | 1639 | { |
klauss | 109:a5b8264ffbbc | 1640 | ptr = ( uint8_t * ) call -> check_rtp (); |
klauss | 109:a5b8264ffbbc | 1641 | } |
klauss | 109:a5b8264ffbbc | 1642 | |
klauss | 109:a5b8264ffbbc | 1643 | if ( ptr != NULL ) |
klauss | 109:a5b8264ffbbc | 1644 | { |
klauss | 109:a5b8264ffbbc | 1645 | send_msg ("Values :: %p\r\n", ( void *) ptr ); |
klauss | 109:a5b8264ffbbc | 1646 | for ( register int i = 0; i < sizeof( RTP ); i++ ) |
klauss | 109:a5b8264ffbbc | 1647 | { |
klauss | 109:a5b8264ffbbc | 1648 | if( debug_uart3 ) pc.printf("%x", *ptr++ ); |
klauss | 109:a5b8264ffbbc | 1649 | |
klauss | 109:a5b8264ffbbc | 1650 | if ( ( i % 32 ) == 0 ) |
klauss | 109:a5b8264ffbbc | 1651 | { |
klauss | 109:a5b8264ffbbc | 1652 | if( i != 0 ) |
klauss | 109:a5b8264ffbbc | 1653 | { |
klauss | 109:a5b8264ffbbc | 1654 | if( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 109:a5b8264ffbbc | 1655 | } |
klauss | 109:a5b8264ffbbc | 1656 | else |
klauss | 109:a5b8264ffbbc | 1657 | { |
klauss | 109:a5b8264ffbbc | 1658 | if( debug_uart3 ) pc.printf(" "); |
klauss | 109:a5b8264ffbbc | 1659 | } |
klauss | 109:a5b8264ffbbc | 1660 | } |
klauss | 109:a5b8264ffbbc | 1661 | else |
klauss | 109:a5b8264ffbbc | 1662 | { |
klauss | 109:a5b8264ffbbc | 1663 | if( debug_uart3 ) pc.printf(" "); |
klauss | 109:a5b8264ffbbc | 1664 | } |
klauss | 109:a5b8264ffbbc | 1665 | } |
klauss | 109:a5b8264ffbbc | 1666 | if ( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 109:a5b8264ffbbc | 1667 | |
klauss | 109:a5b8264ffbbc | 1668 | if ( tcp_session ) { |
klauss | 109:a5b8264ffbbc | 1669 | char aux[ ( 32 * 3 ) + 5 ]; |
klauss | 109:a5b8264ffbbc | 1670 | |
klauss | 109:a5b8264ffbbc | 1671 | for ( register int i = 0; i < ( 32 * 3 ) + 5 ; i++ ) aux [ i ] = 0; |
klauss | 109:a5b8264ffbbc | 1672 | |
klauss | 109:a5b8264ffbbc | 1673 | ptr = NULL; |
klauss | 109:a5b8264ffbbc | 1674 | |
klauss | 109:a5b8264ffbbc | 1675 | VZ_call * call = __find_Call__( v_call, print_hex_this_rtp ); |
klauss | 109:a5b8264ffbbc | 1676 | |
klauss | 109:a5b8264ffbbc | 1677 | uint8_t * ptr = NULL; |
klauss | 109:a5b8264ffbbc | 1678 | if( call != NULL ) |
klauss | 109:a5b8264ffbbc | 1679 | { |
klauss | 109:a5b8264ffbbc | 1680 | ptr = ( uint8_t * ) call -> check_rtp (); |
klauss | 109:a5b8264ffbbc | 1681 | } |
klauss | 109:a5b8264ffbbc | 1682 | |
klauss | 109:a5b8264ffbbc | 1683 | if ( ptr != NULL ) |
klauss | 109:a5b8264ffbbc | 1684 | { |
klauss | 109:a5b8264ffbbc | 1685 | bool finished = false; |
klauss | 109:a5b8264ffbbc | 1686 | volatile int i = 0; |
klauss | 109:a5b8264ffbbc | 1687 | int count = 0; |
klauss | 109:a5b8264ffbbc | 1688 | Timer dont_overwrite_tcp_buffer; |
klauss | 109:a5b8264ffbbc | 1689 | dont_overwrite_tcp_buffer.reset (); |
klauss | 109:a5b8264ffbbc | 1690 | dont_overwrite_tcp_buffer.start (); |
klauss | 109:a5b8264ffbbc | 1691 | |
klauss | 109:a5b8264ffbbc | 1692 | while ( !finished ) |
klauss | 109:a5b8264ffbbc | 1693 | { |
klauss | 109:a5b8264ffbbc | 1694 | if( dont_overwrite_tcp_buffer.read_ms () >= 20 ) |
klauss | 109:a5b8264ffbbc | 1695 | { |
klauss | 109:a5b8264ffbbc | 1696 | dont_overwrite_tcp_buffer.reset(); |
klauss | 109:a5b8264ffbbc | 1697 | for ( ; i < sizeof( RTP ); i++ ) |
klauss | 109:a5b8264ffbbc | 1698 | { |
klauss | 109:a5b8264ffbbc | 1699 | char tmp[ 16 ]; |
klauss | 109:a5b8264ffbbc | 1700 | sprintf( tmp, "%x ", *ptr++ ); |
klauss | 109:a5b8264ffbbc | 1701 | strcat( aux, tmp ); |
klauss | 109:a5b8264ffbbc | 1702 | count++; |
klauss | 109:a5b8264ffbbc | 1703 | |
klauss | 109:a5b8264ffbbc | 1704 | if ( count >= 32 ) |
klauss | 109:a5b8264ffbbc | 1705 | { |
klauss | 109:a5b8264ffbbc | 1706 | count = 0; |
klauss | 109:a5b8264ffbbc | 1707 | i++; |
klauss | 109:a5b8264ffbbc | 1708 | break; |
klauss | 109:a5b8264ffbbc | 1709 | } |
klauss | 109:a5b8264ffbbc | 1710 | } |
klauss | 109:a5b8264ffbbc | 1711 | strcat ( aux, "\n\r\0" ); |
klauss | 109:a5b8264ffbbc | 1712 | tcp_client.send_all ( ( char *)aux, strlen( (char * )aux ) ); |
klauss | 109:a5b8264ffbbc | 1713 | if ( i >= sizeof ( RTP ) ) finished = true; |
klauss | 109:a5b8264ffbbc | 1714 | strcpy ( aux, "\0" ); |
klauss | 109:a5b8264ffbbc | 1715 | } |
klauss | 109:a5b8264ffbbc | 1716 | } |
klauss | 109:a5b8264ffbbc | 1717 | dont_overwrite_tcp_buffer.reset(); |
klauss | 109:a5b8264ffbbc | 1718 | dont_overwrite_tcp_buffer.stop(); |
klauss | 109:a5b8264ffbbc | 1719 | tcp_client.send_all ( "\r\n> ", strlen( "\r\n> " ) ); |
klauss | 109:a5b8264ffbbc | 1720 | } |
klauss | 109:a5b8264ffbbc | 1721 | } |
klauss | 109:a5b8264ffbbc | 1722 | } |
klauss | 109:a5b8264ffbbc | 1723 | else |
klauss | 109:a5b8264ffbbc | 1724 | { |
klauss | 109:a5b8264ffbbc | 1725 | if( print_values ) |
klauss | 109:a5b8264ffbbc | 1726 | { |
klauss | 109:a5b8264ffbbc | 1727 | debug_msg("Call %d not found", print_this_rtp ); |
klauss | 109:a5b8264ffbbc | 1728 | } |
klauss | 109:a5b8264ffbbc | 1729 | else |
klauss | 109:a5b8264ffbbc | 1730 | { |
klauss | 109:a5b8264ffbbc | 1731 | send_msg("Call %d not found", print_this_rtp ); |
klauss | 109:a5b8264ffbbc | 1732 | } |
klauss | 109:a5b8264ffbbc | 1733 | } |
klauss | 109:a5b8264ffbbc | 1734 | } |
klauss | 109:a5b8264ffbbc | 1735 | |
klauss | 109:a5b8264ffbbc | 1736 | if ( print_rtp_var ) |
klauss | 109:a5b8264ffbbc | 1737 | { |
klauss | 109:a5b8264ffbbc | 1738 | print_rtp_var = false; |
klauss | 109:a5b8264ffbbc | 1739 | VZ_call * call = __find_Call__( v_call, print_this_rtp ); |
klauss | 109:a5b8264ffbbc | 1740 | if ( call != NULL ) |
klauss | 109:a5b8264ffbbc | 1741 | { |
klauss | 109:a5b8264ffbbc | 1742 | if ( call -> check_rtp () != NULL ) |
klauss | 109:a5b8264ffbbc | 1743 | { |
klauss | 109:a5b8264ffbbc | 1744 | send_msg ("Values :: %p\r\n", ( void *) call -> check_rtp () ); |
klauss | 109:a5b8264ffbbc | 1745 | call -> rtp_print_yourself (); |
klauss | 109:a5b8264ffbbc | 1746 | } |
klauss | 109:a5b8264ffbbc | 1747 | else |
klauss | 109:a5b8264ffbbc | 1748 | { |
klauss | 109:a5b8264ffbbc | 1749 | if( print_values ) |
klauss | 109:a5b8264ffbbc | 1750 | { |
klauss | 109:a5b8264ffbbc | 1751 | debug_msg("Call->RTP %d not found", print_this_rtp ); |
klauss | 109:a5b8264ffbbc | 1752 | } |
klauss | 109:a5b8264ffbbc | 1753 | else |
klauss | 109:a5b8264ffbbc | 1754 | { |
klauss | 109:a5b8264ffbbc | 1755 | send_msg("Call->RTP %d not found", print_this_rtp ); |
klauss | 109:a5b8264ffbbc | 1756 | } |
klauss | 109:a5b8264ffbbc | 1757 | } |
klauss | 109:a5b8264ffbbc | 1758 | } |
klauss | 109:a5b8264ffbbc | 1759 | else |
klauss | 109:a5b8264ffbbc | 1760 | { |
klauss | 109:a5b8264ffbbc | 1761 | if( print_values ) |
klauss | 109:a5b8264ffbbc | 1762 | { |
klauss | 109:a5b8264ffbbc | 1763 | debug_msg("Call->RTP %d not found", print_this_rtp ); |
klauss | 109:a5b8264ffbbc | 1764 | } |
klauss | 109:a5b8264ffbbc | 1765 | else |
klauss | 109:a5b8264ffbbc | 1766 | { |
klauss | 109:a5b8264ffbbc | 1767 | send_msg("Call->RTP %d not found", print_this_rtp ); |
klauss | 109:a5b8264ffbbc | 1768 | } |
klauss | 109:a5b8264ffbbc | 1769 | } |
klauss | 109:a5b8264ffbbc | 1770 | } |
klauss | 109:a5b8264ffbbc | 1771 | |
klauss | 114:472502b31a12 | 1772 | //end debug_print |
klauss | 91:c2a86b1f8aaa | 1773 | |
klauss | 91:c2a86b1f8aaa | 1774 | if( reset_cks == true ) { |
klauss | 81:3656f00ab3db | 1775 | pkg_cksok = 0; |
klauss | 81:3656f00ab3db | 1776 | pkg_ckserr = 0; |
klauss | 99:e80850c51106 | 1777 | pkg_zero = 0; |
klauss | 81:3656f00ab3db | 1778 | reset_cks = false; |
klauss | 99:e80850c51106 | 1779 | out_of_range = 0; |
klauss | 99:e80850c51106 | 1780 | missed_pkg = 0; |
klauss | 100:09a23fcd3bdf | 1781 | delayed_pkg_to_cb = 0; |
klauss | 99:e80850c51106 | 1782 | cpld_pkg_tx_counter = 0; |
klauss | 99:e80850c51106 | 1783 | cpld_pkg_rx_counter = 0; |
klauss | 81:3656f00ab3db | 1784 | pcks_s = true; |
klauss | 81:3656f00ab3db | 1785 | } |
klauss | 91:c2a86b1f8aaa | 1786 | |
klauss | 91:c2a86b1f8aaa | 1787 | if( pcks_s == true ) { |
klauss | 117:e9facba9db27 | 1788 | send_msg("PKG_CKS OK: %d :: PKG_CKS ERR: %d :: PKG_0: %d :: Out_of_range: %d :: Miss_Pkg :: %d" |
klauss | 117:e9facba9db27 | 1789 | "\n\r> TX_delayed :: %d :: TX_Counter :: %d :: RX_Counter :: %d", pkg_cksok, pkg_ckserr, pkg_zero, out_of_range, missed_pkg, delayed_pkg_to_cb, cpld_pkg_tx_counter, cpld_pkg_rx_counter ); |
klauss | 81:3656f00ab3db | 1790 | pcks_s = false; |
klauss | 81:3656f00ab3db | 1791 | } |
klauss | 114:472502b31a12 | 1792 | |
klauss | 100:09a23fcd3bdf | 1793 | if( flood_bug_pkg ){ |
klauss | 100:09a23fcd3bdf | 1794 | static int id = 0x10; |
klauss | 100:09a23fcd3bdf | 1795 | if( id < 10 ) id = 0x0b; |
klauss | 117:e9facba9db27 | 1796 | send2callboxes( __build_cb_package__( 5828, 5123, __REGISTRY__, |
klauss | 117:e9facba9db27 | 1797 | ( char * )buffer, id++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 100:09a23fcd3bdf | 1798 | } |
klauss | 100:09a23fcd3bdf | 1799 | |
klauss | 114:472502b31a12 | 1800 | if( led_sync_timer.read() > 1 ) { |
klauss | 78:1353744f01e1 | 1801 | led_sync_timer.reset(); |
klauss | 78:1353744f01e1 | 1802 | led3 = !led3; |
klauss | 78:1353744f01e1 | 1803 | CAB_LED = !CAB_LED; |
klauss | 78:1353744f01e1 | 1804 | } |
klauss | 117:e9facba9db27 | 1805 | |
klauss | 117:e9facba9db27 | 1806 | static int test_ext = 5102; |
klauss | 117:e9facba9db27 | 1807 | static int test_port = 5102; |
klauss | 117:e9facba9db27 | 1808 | |
klauss | 117:e9facba9db27 | 1809 | if ( tango ) |
klauss | 117:e9facba9db27 | 1810 | { |
klauss | 117:e9facba9db27 | 1811 | if ( v_cb -> size () >= 27 ) |
klauss | 117:e9facba9db27 | 1812 | { |
klauss | 117:e9facba9db27 | 1813 | tango = false; |
klauss | 117:e9facba9db27 | 1814 | test_timer.start (); |
klauss | 117:e9facba9db27 | 1815 | } |
klauss | 117:e9facba9db27 | 1816 | |
klauss | 117:e9facba9db27 | 1817 | ext = test_ext++; |
klauss | 117:e9facba9db27 | 1818 | port = test_port++; |
klauss | 117:e9facba9db27 | 1819 | type = __REGISTRY__; |
klauss | 117:e9facba9db27 | 1820 | data = buffer; |
klauss | 117:e9facba9db27 | 1821 | } |
klauss | 117:e9facba9db27 | 1822 | |
klauss | 117:e9facba9db27 | 1823 | if( v_cb -> size () >= 27 ) |
klauss | 117:e9facba9db27 | 1824 | { |
klauss | 117:e9facba9db27 | 1825 | if( ( test_timer.read_ms () > 500 ) && ( type == __DO_NOTHING__ ) ) |
klauss | 117:e9facba9db27 | 1826 | { |
klauss | 117:e9facba9db27 | 1827 | if( test_ext >= ( 5102 + 26 ) ) test_ext = 5102; |
klauss | 117:e9facba9db27 | 1828 | if( test_port >= ( 5102 + 26 ) ) test_port = 5102; |
klauss | 117:e9facba9db27 | 1829 | |
klauss | 117:e9facba9db27 | 1830 | ext = test_ext++; |
klauss | 117:e9facba9db27 | 1831 | port = test_port++; |
klauss | 117:e9facba9db27 | 1832 | type = __REGISTRY__; |
klauss | 117:e9facba9db27 | 1833 | data = buffer; |
klauss | 117:e9facba9db27 | 1834 | test_timer.reset (); |
klauss | 117:e9facba9db27 | 1835 | } |
klauss | 117:e9facba9db27 | 1836 | } |
klauss | 114:472502b31a12 | 1837 | |
klauss | 91:c2a86b1f8aaa | 1838 | switch( type ) { |
klauss | 91:c2a86b1f8aaa | 1839 | case __DO_NOTHING__ : |
klauss | 91:c2a86b1f8aaa | 1840 | {} |
klauss | 91:c2a86b1f8aaa | 1841 | break; |
klauss | 91:c2a86b1f8aaa | 1842 | |
klauss | 0:4d17cd9c8f9d | 1843 | case __CB_BYE__ : { |
klauss | 63:0d95da692bb4 | 1844 | cb_bye_counter++; |
klauss | 0:4d17cd9c8f9d | 1845 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 91:c2a86b1f8aaa | 1846 | if( cb != NULL ) { |
klauss | 81:3656f00ab3db | 1847 | if( debug_invite || debug_main ) debug_msg("Received bye pkg with msg_id %d e pkg_id %d", cb->get_msg_id(), data[ 0 ] ); |
klauss | 0:4d17cd9c8f9d | 1848 | data[ 0 ] |= BIT7; |
klauss | 0:4d17cd9c8f9d | 1849 | cb->set_msg_id( data[ 0 ] ); |
klauss | 81:3656f00ab3db | 1850 | if( debug_main || debug_invite ) debug_msg( "Request bye from CBx " ); |
klauss | 92:92df17f538a8 | 1851 | |
klauss | 81:3656f00ab3db | 1852 | bool already_removed = true; |
klauss | 91:c2a86b1f8aaa | 1853 | for( register uint8_t i = 0; i < v_call->size(); i++ ) { |
klauss | 0:4d17cd9c8f9d | 1854 | VZ_call * call = (VZ_call *)v_call->get_element( i ); |
klauss | 91:c2a86b1f8aaa | 1855 | if( call->get_cb_ext() == ext ) { |
klauss | 81:3656f00ab3db | 1856 | already_removed = false; |
klauss | 4:de46f0d9b14d | 1857 | cb->send_bye(); |
klauss | 91:c2a86b1f8aaa | 1858 | |
klauss | 0:4d17cd9c8f9d | 1859 | ts->return_timeslice( cb->get_timeslice() ); |
klauss | 0:4d17cd9c8f9d | 1860 | cb->set_timeslice( 0x00 ); |
klauss | 78:1353744f01e1 | 1861 | data[ __TIMESLICE_PLACE__ ] = 0x00; |
klauss | 91:c2a86b1f8aaa | 1862 | |
klauss | 0:4d17cd9c8f9d | 1863 | set_status( cb->status, cb_idle ); |
klauss | 78:1353744f01e1 | 1864 | set_status( cb->sip->status, sip_idle ); |
klauss | 91:c2a86b1f8aaa | 1865 | |
klauss | 81:3656f00ab3db | 1866 | v_call->remove_element( i ); |
klauss | 117:e9facba9db27 | 1867 | |
klauss | 117:e9facba9db27 | 1868 | //cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); |
klauss | 117:e9facba9db27 | 1869 | //cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); |
klauss | 91:c2a86b1f8aaa | 1870 | |
klauss | 117:e9facba9db27 | 1871 | send2callboxes( __build_cb_package__( ext, port, __CB_BYE__, |
klauss | 117:e9facba9db27 | 1872 | ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 92:92df17f538a8 | 1873 | |
klauss | 92:92df17f538a8 | 1874 | // envia o ack bye depois atualiza o msg_id |
klauss | 92:92df17f538a8 | 1875 | cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); |
klauss | 91:c2a86b1f8aaa | 1876 | |
klauss | 3:cd9148672e25 | 1877 | delete( call ); |
klauss | 117:e9facba9db27 | 1878 | //cb->re_start_timer(); |
klauss | 0:4d17cd9c8f9d | 1879 | } |
klauss | 0:4d17cd9c8f9d | 1880 | } |
klauss | 82:f55d13babca0 | 1881 | if( already_removed ) if( debug_main || debug_invite ) debug_msg( "Already removed from vector call" ); |
klauss | 114:472502b31a12 | 1882 | |
klauss | 114:472502b31a12 | 1883 | //ok, mas nem sempre o cbx "entrou em call |
klauss | 82:f55d13babca0 | 1884 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 82:f55d13babca0 | 1885 | Call_Box * cb = (Call_Box *)v_cb->get_element( i ); |
klauss | 82:f55d13babca0 | 1886 | if( cb->get_ext() == ext ) { |
klauss | 82:f55d13babca0 | 1887 | already_removed = true; |
klauss | 82:f55d13babca0 | 1888 | if( cb->get_status() != cb_idle ) { |
klauss | 82:f55d13babca0 | 1889 | already_removed = false; |
klauss | 82:f55d13babca0 | 1890 | cb->send_bye(); |
klauss | 82:f55d13babca0 | 1891 | |
klauss | 82:f55d13babca0 | 1892 | ts->return_timeslice( cb->get_timeslice() ); |
klauss | 82:f55d13babca0 | 1893 | cb->set_timeslice( 0x00 ); |
klauss | 82:f55d13babca0 | 1894 | data[ __TIMESLICE_PLACE__ ] = 0x00; |
klauss | 82:f55d13babca0 | 1895 | |
klauss | 82:f55d13babca0 | 1896 | set_status( cb->status, cb_idle ); |
klauss | 82:f55d13babca0 | 1897 | set_status( cb->sip->status, sip_idle ); |
klauss | 82:f55d13babca0 | 1898 | |
klauss | 117:e9facba9db27 | 1899 | send2callboxes( __build_cb_package__( ext, port, __CB_BYE__, |
klauss | 117:e9facba9db27 | 1900 | ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 82:f55d13babca0 | 1901 | |
klauss | 117:e9facba9db27 | 1902 | //cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); |
klauss | 92:92df17f538a8 | 1903 | cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); |
klauss | 117:e9facba9db27 | 1904 | |
klauss | 117:e9facba9db27 | 1905 | //cb->re_start_timer(); |
klauss | 82:f55d13babca0 | 1906 | } |
klauss | 82:f55d13babca0 | 1907 | } |
klauss | 82:f55d13babca0 | 1908 | } |
klauss | 91:c2a86b1f8aaa | 1909 | |
klauss | 82:f55d13babca0 | 1910 | if( already_removed ) if( debug_main || debug_invite ) debug_msg( "Already removed from inviting queue" ); |
klauss | 91:c2a86b1f8aaa | 1911 | |
klauss | 78:1353744f01e1 | 1912 | cb->registry(); |
klauss | 91:c2a86b1f8aaa | 1913 | } else if( debug_invite || debug_main ) debug_msg("Bye from who ? %d", ext ); |
klauss | 91:c2a86b1f8aaa | 1914 | } |
klauss | 91:c2a86b1f8aaa | 1915 | break; |
klauss | 91:c2a86b1f8aaa | 1916 | |
klauss | 0:4d17cd9c8f9d | 1917 | case __INVITE__ : { |
klauss | 114:472502b31a12 | 1918 | if( drop_invite_pkg ){ |
klauss | 117:e9facba9db27 | 1919 | debug_msg("Dropando invite pck msg id :: %d", data[ 0 ] ); |
klauss | 114:472502b31a12 | 1920 | break; |
klauss | 114:472502b31a12 | 1921 | } |
klauss | 63:0d95da692bb4 | 1922 | invite_counter++; |
klauss | 117:e9facba9db27 | 1923 | if( debug_invite ) debug_msg("Request Invite received from Cbx %i", ext); |
klauss | 0:4d17cd9c8f9d | 1924 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 91:c2a86b1f8aaa | 1925 | if( cb == NULL ) { |
klauss | 91:c2a86b1f8aaa | 1926 | if( v_cb->size() < __MAX_CB_IN_A_BRANCH__ ) { |
klauss | 91:c2a86b1f8aaa | 1927 | if( debug_main ) debug_msg( "Adding CBx :: %i", ext ); |
klauss | 91:c2a86b1f8aaa | 1928 | cb = new Call_Box( ext, port ); |
klauss | 91:c2a86b1f8aaa | 1929 | |
klauss | 91:c2a86b1f8aaa | 1930 | if( cb == NULL ) { |
klauss | 91:c2a86b1f8aaa | 1931 | memory_is_over = true; |
klauss | 91:c2a86b1f8aaa | 1932 | if( debug_memory ) debug_msg("Invite allocation cb fail"); |
klauss | 91:c2a86b1f8aaa | 1933 | } else { |
klauss | 91:c2a86b1f8aaa | 1934 | v_cb->add( cb ); |
klauss | 91:c2a86b1f8aaa | 1935 | } |
klauss | 89:0fe315117b00 | 1936 | } |
klauss | 0:4d17cd9c8f9d | 1937 | } |
klauss | 117:e9facba9db27 | 1938 | if( cb != NULL ) { |
klauss | 91:c2a86b1f8aaa | 1939 | cb->set_msg_id( data[ 0 ] ); |
klauss | 117:e9facba9db27 | 1940 | if( cb->status == cb_idle ){ |
klauss | 117:e9facba9db27 | 1941 | cb->set_invite_response_ok(); |
klauss | 117:e9facba9db27 | 1942 | cb->invite_retry_count_reset(); |
klauss | 92:92df17f538a8 | 1943 | } |
klauss | 87:679ee0d594a9 | 1944 | invite_handler( v_call, v_cb, ts, cb ); |
klauss | 87:679ee0d594a9 | 1945 | } |
klauss | 91:c2a86b1f8aaa | 1946 | } |
klauss | 91:c2a86b1f8aaa | 1947 | break; |
klauss | 4:de46f0d9b14d | 1948 | case __REGISTRY__ : { |
klauss | 63:0d95da692bb4 | 1949 | registry_counter++; |
klauss | 78:1353744f01e1 | 1950 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 91:c2a86b1f8aaa | 1951 | if( v_cb->size() < __MAX_CB_IN_A_BRANCH__ ) { |
klauss | 91:c2a86b1f8aaa | 1952 | if( cb == NULL ) { |
klauss | 91:c2a86b1f8aaa | 1953 | if( debug_main ) debug_msg("Adding Cbx :: %d", ext ); |
klauss | 91:c2a86b1f8aaa | 1954 | cb = new Call_Box( ext, port ); |
klauss | 91:c2a86b1f8aaa | 1955 | |
klauss | 91:c2a86b1f8aaa | 1956 | if( cb == NULL ) { |
klauss | 91:c2a86b1f8aaa | 1957 | memory_is_over = true; |
klauss | 91:c2a86b1f8aaa | 1958 | if( debug_memory ) debug_msg("Registry cb allocation fail"); |
klauss | 91:c2a86b1f8aaa | 1959 | } else { |
klauss | 91:c2a86b1f8aaa | 1960 | v_cb->add( cb ); |
klauss | 91:c2a86b1f8aaa | 1961 | if( debug_main ) debug_msg("Added CBx -- %d", ext ); |
klauss | 91:c2a86b1f8aaa | 1962 | } |
klauss | 87:679ee0d594a9 | 1963 | } |
klauss | 0:4d17cd9c8f9d | 1964 | } |
klauss | 78:1353744f01e1 | 1965 | if( debug_main ) debug_msg("Registered %d - %d", ext, port ); |
klauss | 91:c2a86b1f8aaa | 1966 | |
klauss | 87:679ee0d594a9 | 1967 | if( cb != NULL ) cb->registry(); |
klauss | 114:472502b31a12 | 1968 | |
klauss | 91:c2a86b1f8aaa | 1969 | } |
klauss | 91:c2a86b1f8aaa | 1970 | break; |
klauss | 4:de46f0d9b14d | 1971 | case __BOOT__ : { |
klauss | 63:0d95da692bb4 | 1972 | boot_counter++; |
klauss | 99:e80850c51106 | 1973 | if( debug_boot == true ){ |
klauss | 99:e80850c51106 | 1974 | send_msg("Rcv boot pkg from (%d, %d) pkg-id %d", ext, port, data[ 0 ] ); |
klauss | 99:e80850c51106 | 1975 | } |
klauss | 117:e9facba9db27 | 1976 | send2callboxes( __build_cb_package__( ext, port, __REGISTRY__, |
klauss | 117:e9facba9db27 | 1977 | ( char * )data, data[ 0 ] | BIT7, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 117:e9facba9db27 | 1978 | } |
klauss | 117:e9facba9db27 | 1979 | break; |
klauss | 117:e9facba9db27 | 1980 | |
klauss | 117:e9facba9db27 | 1981 | case __TELEMETRY__ : { |
klauss | 117:e9facba9db27 | 1982 | if( debug_telemetry ) send_msg("::Telemetry from %d - %d::", ext, port ); |
klauss | 117:e9facba9db27 | 1983 | build_telemetry_report( ext, port, ( char *)data ); |
klauss | 91:c2a86b1f8aaa | 1984 | } |
klauss | 91:c2a86b1f8aaa | 1985 | break; |
klauss | 99:e80850c51106 | 1986 | |
klauss | 99:e80850c51106 | 1987 | case __FW__ : { |
klauss | 99:e80850c51106 | 1988 | if( debug_fw_print ) send_msg("::FW pkg from %d - %d::", ext, port ); |
klauss | 99:e80850c51106 | 1989 | fw_cbx_pkg( ext, port, ( char *)buffer ); |
klauss | 99:e80850c51106 | 1990 | } |
klauss | 99:e80850c51106 | 1991 | break; |
klauss | 91:c2a86b1f8aaa | 1992 | |
klauss | 114:472502b31a12 | 1993 | case __BOOTLOADER_CBX__ : { |
klauss | 117:e9facba9db27 | 1994 | uint16_t bl_cnt2 = 0; |
klauss | 117:e9facba9db27 | 1995 | //char bl_send_buffer[ BL_SIZE + 2 ]; |
klauss | 117:e9facba9db27 | 1996 | //int ret = bl_cbx_reply_to_eth( ext, ( char * )data ); |
klauss | 117:e9facba9db27 | 1997 | //BLEUBA |
klauss | 117:e9facba9db27 | 1998 | //pc.printf("\r\nCBX RESPONDEU BOOTLOADER!\r\n"); |
klauss | 117:e9facba9db27 | 1999 | if (debug_bootloader) { |
klauss | 117:e9facba9db27 | 2000 | pc.printf("\r\npacote CBX->HDR {"); |
klauss | 117:e9facba9db27 | 2001 | for (bl_cnt2 = 0;bl_cnt2 < BL_SIZE + 1;bl_cnt2++) { |
klauss | 117:e9facba9db27 | 2002 | if ((bl_cnt2 % 30) == 0) { |
klauss | 117:e9facba9db27 | 2003 | pc.printf("\r\n "); |
klauss | 117:e9facba9db27 | 2004 | pc.printf(hex16(bl_cnt2)); |
klauss | 117:e9facba9db27 | 2005 | pc.printf(" : "); |
klauss | 117:e9facba9db27 | 2006 | } |
klauss | 117:e9facba9db27 | 2007 | pc.printf(hex8(data[bl_cnt2])); |
klauss | 117:e9facba9db27 | 2008 | pc.printf(", "); |
klauss | 117:e9facba9db27 | 2009 | } |
klauss | 117:e9facba9db27 | 2010 | pc.printf("\r\n}"); |
klauss | 117:e9facba9db27 | 2011 | } |
klauss | 67:cdedc64d9921 | 2012 | bootloader_cbx_counter++; |
klauss | 117:e9facba9db27 | 2013 | bl_send_buffer[0] = (char)(ext >> 8); |
klauss | 117:e9facba9db27 | 2014 | bl_send_buffer[1] = (char)(ext & 0xff); |
klauss | 117:e9facba9db27 | 2015 | for (bl_cnt2 = 0; bl_cnt2 < BL_SIZE; bl_cnt2++) { |
klauss | 117:e9facba9db27 | 2016 | bl_send_buffer[bl_cnt2 + 2] = data[bl_cnt2 + 1]; |
klauss | 117:e9facba9db27 | 2017 | } |
klauss | 117:e9facba9db27 | 2018 | if (debug_bootloader) { |
klauss | 117:e9facba9db27 | 2019 | pc.printf("\r\npacote HDR->SRV {"); |
klauss | 117:e9facba9db27 | 2020 | for (bl_cnt2 = 0;bl_cnt2 < UDP_BL_SIZE;bl_cnt2++) { |
klauss | 117:e9facba9db27 | 2021 | if ((bl_cnt2 % 30) == 0) { |
klauss | 117:e9facba9db27 | 2022 | pc.printf("\r\n "); |
klauss | 117:e9facba9db27 | 2023 | pc.printf(hex16(bl_cnt2)); |
klauss | 117:e9facba9db27 | 2024 | pc.printf(" : "); |
klauss | 117:e9facba9db27 | 2025 | } |
klauss | 117:e9facba9db27 | 2026 | pc.printf(hex8(bl_send_buffer[bl_cnt2])); |
klauss | 117:e9facba9db27 | 2027 | pc.printf(", "); |
klauss | 117:e9facba9db27 | 2028 | } |
klauss | 117:e9facba9db27 | 2029 | pc.printf("\r\n}"); |
klauss | 117:e9facba9db27 | 2030 | } |
klauss | 117:e9facba9db27 | 2031 | udp_bl_client.sendTo( udp_bl_server, bl_send_buffer, UDP_BL_SIZE ); |
klauss | 91:c2a86b1f8aaa | 2032 | } |
klauss | 91:c2a86b1f8aaa | 2033 | break; |
klauss | 91:c2a86b1f8aaa | 2034 | |
klauss | 114:472502b31a12 | 2035 | case __PROMPT__ : { |
klauss | 78:1353744f01e1 | 2036 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 91:c2a86b1f8aaa | 2037 | |
klauss | 91:c2a86b1f8aaa | 2038 | if( cb == NULL ) { |
klauss | 117:e9facba9db27 | 2039 | send2callboxes( __build_cb_package__( ext, port, __REGISTRY__, |
klauss | 117:e9facba9db27 | 2040 | ( char * )data, ( ( data[ 0 ] & ~BIT7 ) + 1 ), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 117:e9facba9db27 | 2041 | |
klauss | 117:e9facba9db27 | 2042 | if( debug_main ) debug_msg("Adding Cbx :: %d", ext ); |
klauss | 117:e9facba9db27 | 2043 | cb = new Call_Box( ext, port ); |
klauss | 117:e9facba9db27 | 2044 | if( cb == NULL ){ |
klauss | 117:e9facba9db27 | 2045 | memory_is_over = true; |
klauss | 117:e9facba9db27 | 2046 | }else{ |
klauss | 117:e9facba9db27 | 2047 | v_cb->add( cb ); |
klauss | 117:e9facba9db27 | 2048 | if( debug_main ) debug_msg("Added CBx -- %d", ext ); |
klauss | 87:679ee0d594a9 | 2049 | } |
klauss | 48:195c97f12e8e | 2050 | } |
klauss | 91:c2a86b1f8aaa | 2051 | |
klauss | 92:92df17f538a8 | 2052 | if( cb!= NULL ) cb->registry(); |
klauss | 91:c2a86b1f8aaa | 2053 | |
klauss | 91:c2a86b1f8aaa | 2054 | if( xstrmatch( ( uint8_t * )data, ( uint8_t * )"ping" ) ) { |
klauss | 78:1353744f01e1 | 2055 | if( debug_ping ) send_msg( "Prompt pkg from ( %i, %i ) :: Ping", ext, port ); |
klauss | 91:c2a86b1f8aaa | 2056 | } else { |
klauss | 78:1353744f01e1 | 2057 | prompt_counter++; |
klauss | 114:472502b31a12 | 2058 | //fixme isso nao poderia ser resolvido com um sendmsg ? |
klauss | 78:1353744f01e1 | 2059 | send_msg( "Prompt pkg from ( %i, %i ) ::", ext, port ); |
klauss | 91:c2a86b1f8aaa | 2060 | for( register uint8_t i = 0; i < 32; i++ ) { |
klauss | 100:09a23fcd3bdf | 2061 | if( debug_uart3 ) pc.printf("%c", data[ i ] ); |
klauss | 100:09a23fcd3bdf | 2062 | if( i == 15 ) if( debug_uart3 ) pc.printf( "\r\n" ); |
klauss | 78:1353744f01e1 | 2063 | } |
klauss | 100:09a23fcd3bdf | 2064 | if( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 91:c2a86b1f8aaa | 2065 | |
klauss | 114:472502b31a12 | 2066 | if( tcp_session ) { |
klauss | 117:e9facba9db27 | 2067 | char aux[ __CB_BUFFER_SIZE__ + 3 ]; |
klauss | 117:e9facba9db27 | 2068 | strncpy( aux, (char * )data, __CB_BUFFER_SIZE__ ); |
klauss | 78:1353744f01e1 | 2069 | strcat( aux, "\n\r\0" ); |
klauss | 78:1353744f01e1 | 2070 | tcp_client.send_all( ( char *)data, strlen( (char * )data ) ); |
klauss | 78:1353744f01e1 | 2071 | tcp_client.send_all( "\r\n> ", strlen( "\r\n> " ) ); |
klauss | 78:1353744f01e1 | 2072 | } |
klauss | 48:195c97f12e8e | 2073 | } |
klauss | 91:c2a86b1f8aaa | 2074 | } |
klauss | 91:c2a86b1f8aaa | 2075 | break; |
klauss | 0:4d17cd9c8f9d | 2076 | case __AUDIO__ : { |
klauss | 63:0d95da692bb4 | 2077 | audio_counter++; |
klauss | 78:1353744f01e1 | 2078 | VZ_call * call = __find_Call__( v_call, ext ); |
klauss | 91:c2a86b1f8aaa | 2079 | if( call != NULL ) { |
klauss | 117:e9facba9db27 | 2080 | if ( drop_rtp_from_cbx_pkg ) |
klauss | 117:e9facba9db27 | 2081 | { |
klauss | 114:472502b31a12 | 2082 | led2 = !led2; |
klauss | 114:472502b31a12 | 2083 | break; |
klauss | 117:e9facba9db27 | 2084 | } |
klauss | 117:e9facba9db27 | 2085 | else |
klauss | 117:e9facba9db27 | 2086 | { |
klauss | 114:472502b31a12 | 2087 | char * pkg = call->build_eth_package( data + 2 ); |
klauss | 114:472502b31a12 | 2088 | call->send_message( pkg ); |
klauss | 114:472502b31a12 | 2089 | call->cbx_pkg_idle_timer_reset(); |
klauss | 117:e9facba9db27 | 2090 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 117:e9facba9db27 | 2091 | if( cb != NULL ){ |
klauss | 117:e9facba9db27 | 2092 | cb->set_invite_response_ok(); |
klauss | 117:e9facba9db27 | 2093 | cb->invite_retry_count_reset(); |
klauss | 117:e9facba9db27 | 2094 | } |
klauss | 114:472502b31a12 | 2095 | } |
klauss | 117:e9facba9db27 | 2096 | } else { |
klauss | 117:e9facba9db27 | 2097 | if( debug_main ) debug_msg("received missed package from CBx :: %i", ext ); |
klauss | 0:4d17cd9c8f9d | 2098 | } |
klauss | 91:c2a86b1f8aaa | 2099 | } |
klauss | 91:c2a86b1f8aaa | 2100 | break; |
klauss | 114:472502b31a12 | 2101 | }// fim switch |
klauss | 105:a930035b6556 | 2102 | |
klauss | 99:e80850c51106 | 2103 | { // rajada |
klauss | 117:e9facba9db27 | 2104 | if( invite_retry_timer.read_ms() > 30 ) |
klauss | 112:6ae726539ab9 | 2105 | { |
klauss | 99:e80850c51106 | 2106 | invite_retry_timer.reset(); |
klauss | 99:e80850c51106 | 2107 | |
klauss | 112:6ae726539ab9 | 2108 | static int retry_invite_pkg = 0; |
klauss | 112:6ae726539ab9 | 2109 | bool need_retry = false; |
klauss | 112:6ae726539ab9 | 2110 | Call_Box * cb = NULL; |
klauss | 112:6ae726539ab9 | 2111 | |
klauss | 112:6ae726539ab9 | 2112 | for ( register int i = 0; i < v_cb->size(); i++ ) |
klauss | 112:6ae726539ab9 | 2113 | { |
klauss | 112:6ae726539ab9 | 2114 | retry_invite_pkg++; |
klauss | 112:6ae726539ab9 | 2115 | if ( retry_invite_pkg >= v_cb->size() ) retry_invite_pkg = 0; |
klauss | 112:6ae726539ab9 | 2116 | |
klauss | 112:6ae726539ab9 | 2117 | cb = (Call_Box * )v_cb->get_element( i ); |
klauss | 112:6ae726539ab9 | 2118 | if ( cb != NULL ) |
klauss | 112:6ae726539ab9 | 2119 | { |
klauss | 112:6ae726539ab9 | 2120 | if ( ( cb->status == cb_ringing ) || ( cb->status == cb_trying ) || ( cb->status == cb_on_call ) ) |
klauss | 112:6ae726539ab9 | 2121 | { |
klauss | 112:6ae726539ab9 | 2122 | need_retry = true; |
klauss | 99:e80850c51106 | 2123 | break; |
klauss | 99:e80850c51106 | 2124 | } |
klauss | 92:92df17f538a8 | 2125 | } |
klauss | 99:e80850c51106 | 2126 | } |
klauss | 109:a5b8264ffbbc | 2127 | |
klauss | 112:6ae726539ab9 | 2128 | if ( need_retry ) |
klauss | 112:6ae726539ab9 | 2129 | { |
klauss | 112:6ae726539ab9 | 2130 | if( cb->get_invite_response() == false ) |
klauss | 112:6ae726539ab9 | 2131 | { |
klauss | 112:6ae726539ab9 | 2132 | cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); |
klauss | 99:e80850c51106 | 2133 | |
klauss | 112:6ae726539ab9 | 2134 | buffer[ __TIMESLICE_PLACE__ ] = cb->get_timeslice(); |
klauss | 112:6ae726539ab9 | 2135 | |
klauss | 117:e9facba9db27 | 2136 | send2callboxes( __build_cb_package__( cb->get_ext(), cb->get_port(), __INVITE__, ( char * )buffer, |
klauss | 117:e9facba9db27 | 2137 | cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 109:a5b8264ffbbc | 2138 | |
klauss | 112:6ae726539ab9 | 2139 | if( debug_invite ) debug_msg("resend invite OK to Cbx : ( %d, %d )", cb->get_ext(), cb->get_port() ); |
klauss | 117:e9facba9db27 | 2140 | } |
klauss | 117:e9facba9db27 | 2141 | |
klauss | 117:e9facba9db27 | 2142 | if( cb->get_invite_retry_count() == 0 ) |
klauss | 112:6ae726539ab9 | 2143 | { |
klauss | 117:e9facba9db27 | 2144 | cb->send_bye(); |
klauss | 117:e9facba9db27 | 2145 | |
klauss | 117:e9facba9db27 | 2146 | ts->return_timeslice( cb->get_timeslice() ); |
klauss | 117:e9facba9db27 | 2147 | cb->set_timeslice( 0x00 ); |
klauss | 117:e9facba9db27 | 2148 | |
klauss | 117:e9facba9db27 | 2149 | cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); |
klauss | 117:e9facba9db27 | 2150 | |
klauss | 117:e9facba9db27 | 2151 | for( register uint8_t i = 0; i < v_call->size(); i++ ) |
klauss | 112:6ae726539ab9 | 2152 | { |
klauss | 117:e9facba9db27 | 2153 | VZ_call * call = ( VZ_call * )v_call->get_element( i ); |
klauss | 117:e9facba9db27 | 2154 | if( call->get_cb_ext() == cb->get_ext() ) |
klauss | 112:6ae726539ab9 | 2155 | { |
klauss | 117:e9facba9db27 | 2156 | v_call->remove_element( i ); |
klauss | 117:e9facba9db27 | 2157 | if( call != NULL ) delete( call ); |
klauss | 117:e9facba9db27 | 2158 | break; |
klauss | 92:92df17f538a8 | 2159 | } |
klauss | 112:6ae726539ab9 | 2160 | } |
klauss | 117:e9facba9db27 | 2161 | |
klauss | 117:e9facba9db27 | 2162 | if( debug_invite ) debug_msg( "-- No audio pkgs --" ); |
klauss | 117:e9facba9db27 | 2163 | set_status( cb->status, cb_idle ); |
klauss | 117:e9facba9db27 | 2164 | set_status( cb->sip->status, sip_idle ); |
klauss | 92:92df17f538a8 | 2165 | } |
klauss | 92:92df17f538a8 | 2166 | } |
klauss | 112:6ae726539ab9 | 2167 | } |
klauss | 114:472502b31a12 | 2168 | } // fim rajada |
klauss | 114:472502b31a12 | 2169 | |
klauss | 91:c2a86b1f8aaa | 2170 | for( register uint8_t i = 0; i < v_call->size(); i++ ) { |
klauss | 0:4d17cd9c8f9d | 2171 | VZ_call * call = ( VZ_call * )v_call->get_element( i ); |
klauss | 117:e9facba9db27 | 2172 | int length = 0; |
klauss | 117:e9facba9db27 | 2173 | char * tmp = call->get_eth_message( &length ); |
klauss | 117:e9facba9db27 | 2174 | if( tmp != NULL ) { |
klauss | 117:e9facba9db27 | 2175 | int cb_port = 0xffff; |
klauss | 117:e9facba9db27 | 2176 | Call_Box * cb = __find_CB__( v_cb, call->get_cb_ext() ); |
klauss | 117:e9facba9db27 | 2177 | |
klauss | 117:e9facba9db27 | 2178 | if( cb != NULL ) { |
klauss | 117:e9facba9db27 | 2179 | cb_port = cb->get_port(); |
klauss | 117:e9facba9db27 | 2180 | |
klauss | 117:e9facba9db27 | 2181 | if ( drop_rtp_from_ast_pkg ) |
klauss | 117:e9facba9db27 | 2182 | { |
klauss | 117:e9facba9db27 | 2183 | led1 = !led1; |
klauss | 117:e9facba9db27 | 2184 | } |
klauss | 117:e9facba9db27 | 2185 | else |
klauss | 117:e9facba9db27 | 2186 | { |
klauss | 117:e9facba9db27 | 2187 | uint8_t * pkg2cb = __build_cb_package__( call->get_cb_ext(), cb_port, __AUDIO__, |
klauss | 117:e9facba9db27 | 2188 | tmp, __AUDIO__, length, write_buffer ); |
klauss | 117:e9facba9db27 | 2189 | |
klauss | 117:e9facba9db27 | 2190 | send2callboxes( pkg2cb ); |
klauss | 117:e9facba9db27 | 2191 | } |
klauss | 117:e9facba9db27 | 2192 | |
klauss | 117:e9facba9db27 | 2193 | } else if( debug_main ) debug_msg("received missed package from CBx :: %i -- Type :: %i", ext, type ); |
klauss | 0:4d17cd9c8f9d | 2194 | } |
klauss | 14:22a35f575502 | 2195 | } |
klauss | 117:e9facba9db27 | 2196 | |
klauss | 117:e9facba9db27 | 2197 | //if( v_call->size() == 0 ) refresh( v_cb, buffer, write_buffer, NULL ); |
klauss | 114:472502b31a12 | 2198 | |
klauss | 114:472502b31a12 | 2199 | if( timer_sync_refresh.read_ms() > 250 ) { |
klauss | 114:472502b31a12 | 2200 | timer_sync_refresh.reset(); |
klauss | 106:a34fcf9f0e02 | 2201 | |
klauss | 117:e9facba9db27 | 2202 | static uint8_t mode = TIME_TO_REFRESH; |
klauss | 114:472502b31a12 | 2203 | |
klauss | 117:e9facba9db27 | 2204 | if( mode == TIME_TO_REFRESH ) { |
klauss | 117:e9facba9db27 | 2205 | mode = TIME_TO_WAKE_UP; |
klauss | 117:e9facba9db27 | 2206 | refresh( v_cb, buffer, write_buffer, NULL ); |
klauss | 114:472502b31a12 | 2207 | } else { |
klauss | 117:e9facba9db27 | 2208 | mode = TIME_TO_REFRESH; |
klauss | 117:e9facba9db27 | 2209 | if( wake_all ) if( v_call->size() == 0 ) wake_all_up( v_cb, buffer, write_buffer ); |
klauss | 89:0fe315117b00 | 2210 | } |
klauss | 89:0fe315117b00 | 2211 | } |
klauss | 108:18a3702650f3 | 2212 | |
klauss | 117:e9facba9db27 | 2213 | |
klauss | 117:e9facba9db27 | 2214 | //refresh( v_cb, buffer, write_buffer, NULL ); |
klauss | 117:e9facba9db27 | 2215 | |
klauss | 117:e9facba9db27 | 2216 | //Fixme pensar melhor nessa parte durante ligacoes, pode complicar com muitos cbx ... |
klauss | 117:e9facba9db27 | 2217 | //if( v_call->size() == 0 ) registry_aging( v_cb, buffer, write_buffer ); |
klauss | 117:e9facba9db27 | 2218 | |
klauss | 78:1353744f01e1 | 2219 | // check sip messages only for cbx in call ? |
klauss | 78:1353744f01e1 | 2220 | int ext_to__be_removed = sip_manager( v_cb ); |
klauss | 91:c2a86b1f8aaa | 2221 | if( ext_to__be_removed > 0x00 ) { |
klauss | 78:1353744f01e1 | 2222 | Call_Box * cb = __find_CB__( v_cb, ext_to__be_removed ); |
klauss | 91:c2a86b1f8aaa | 2223 | if( cb != NULL ) { |
klauss | 91:c2a86b1f8aaa | 2224 | if( cb->status == cb_on_call ) { |
klauss | 4:de46f0d9b14d | 2225 | ts->return_timeslice( cb->get_timeslice() ); |
klauss | 4:de46f0d9b14d | 2226 | cb->set_timeslice( 0x00 ); |
klauss | 4:de46f0d9b14d | 2227 | buffer[ __TIMESLICE_PLACE__ ] = 0x00; |
klauss | 91:c2a86b1f8aaa | 2228 | |
klauss | 78:1353744f01e1 | 2229 | set_status( cb->status, cb_idle ); |
klauss | 78:1353744f01e1 | 2230 | set_status( cb->sip->status, sip_idle ); |
klauss | 91:c2a86b1f8aaa | 2231 | |
klauss | 91:c2a86b1f8aaa | 2232 | for( register uint8_t i = 0; i < v_call->size(); i++ ) { |
klauss | 4:de46f0d9b14d | 2233 | VZ_call * call = ( VZ_call * )v_call->get_element( i ); |
klauss | 91:c2a86b1f8aaa | 2234 | if( call->get_cb_ext() == ext_to__be_removed ) { |
klauss | 4:de46f0d9b14d | 2235 | v_call->remove_element( i ); |
klauss | 4:de46f0d9b14d | 2236 | delete( call ); |
klauss | 4:de46f0d9b14d | 2237 | } |
klauss | 2:93bec7313ccc | 2238 | } |
klauss | 91:c2a86b1f8aaa | 2239 | |
klauss | 117:e9facba9db27 | 2240 | //cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); |
klauss | 92:92df17f538a8 | 2241 | cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); |
klauss | 117:e9facba9db27 | 2242 | |
klauss | 117:e9facba9db27 | 2243 | //debug_msg("msg_id -- %d", cb->get_msg_id() ); |
klauss | 114:472502b31a12 | 2244 | |
klauss | 117:e9facba9db27 | 2245 | send2callboxes( __build_cb_package__( ext, port, __CB_BYE__, |
klauss | 117:e9facba9db27 | 2246 | ( char * )buffer, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 91:c2a86b1f8aaa | 2247 | |
klauss | 91:c2a86b1f8aaa | 2248 | if( debug_invite ) debug_msg("Received Bye from *"); |
klauss | 114:472502b31a12 | 2249 | //cb->re_start_timer(); |
klauss | 0:4d17cd9c8f9d | 2250 | } |
klauss | 91:c2a86b1f8aaa | 2251 | } else if( debug_main ) debug_msg("Missed bye request from * CBx :: %d", ext ); |
klauss | 114:472502b31a12 | 2252 | } |
klauss | 91:c2a86b1f8aaa | 2253 | |
klauss | 81:3656f00ab3db | 2254 | /* Verifica andamento de ligações para eventualmente encerra-las por timeout */ |
klauss | 117:e9facba9db27 | 2255 | call_manager( v_call, v_cb, buffer, write_buffer, ts ); |
klauss | 91:c2a86b1f8aaa | 2256 | |
klauss | 114:472502b31a12 | 2257 | /* tratamento de pedidos de ligação */ |
klauss | 81:3656f00ab3db | 2258 | invite_handler( v_call, v_cb, ts, NULL ); |
klauss | 114:472502b31a12 | 2259 | |
klauss | 117:e9facba9db27 | 2260 | /* rotina de verificação de TS's perdidos */ |
klauss | 91:c2a86b1f8aaa | 2261 | if( ( v_call->size() == 0 ) && ( ts->remain_timeslices() != __MAX_TIMESLICES__ ) ) { |
klauss | 91:c2a86b1f8aaa | 2262 | bool ts_reset = true; |
klauss | 91:c2a86b1f8aaa | 2263 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 117:e9facba9db27 | 2264 | uint16_t cb_status = ((Call_Box *)v_cb->get_element( i ))->get_status(); |
klauss | 117:e9facba9db27 | 2265 | uint16_t cb_sip_status = ((Call_Box *)v_cb->get_element( i ))->get_sip_status(); |
klauss | 117:e9facba9db27 | 2266 | |
klauss | 117:e9facba9db27 | 2267 | if ((cb_status != cb_idle) and (cb_sip_status != sip_idle)) { |
klauss | 78:1353744f01e1 | 2268 | ts_reset = false; |
klauss | 78:1353744f01e1 | 2269 | break; |
klauss | 78:1353744f01e1 | 2270 | } |
klauss | 117:e9facba9db27 | 2271 | |
klauss | 91:c2a86b1f8aaa | 2272 | } |
klauss | 117:e9facba9db27 | 2273 | if( ts_reset && !bl_start_flag ) |
klauss | 117:e9facba9db27 | 2274 | { |
klauss | 114:472502b31a12 | 2275 | if( debug_invite ) debug_msg("Resetando TS"); |
klauss | 114:472502b31a12 | 2276 | ts->reset(); |
klauss | 78:1353744f01e1 | 2277 | } |
klauss | 0:4d17cd9c8f9d | 2278 | } |
klauss | 117:e9facba9db27 | 2279 | |
klauss | 112:6ae726539ab9 | 2280 | |
klauss | 112:6ae726539ab9 | 2281 | /* rotina "zeradora" de portas RTP */ |
klauss | 117:e9facba9db27 | 2282 | /* |
klauss | 112:6ae726539ab9 | 2283 | for ( register uint8_t i = 0; i < v_cb->size(); i++ ) |
klauss | 112:6ae726539ab9 | 2284 | { |
klauss | 112:6ae726539ab9 | 2285 | Call_Box * cb = (Call_Box *) v_cb->get_element (i); |
klauss | 112:6ae726539ab9 | 2286 | if ( cb != NULL ) |
klauss | 112:6ae726539ab9 | 2287 | { |
klauss | 112:6ae726539ab9 | 2288 | if ( ( cb->get_status () == cb_idle ) && ( cb->get_sip_status () == sip_idle ) && ( cb -> is_rtp_timer_timeout () ) ) |
klauss | 112:6ae726539ab9 | 2289 | { |
klauss | 117:e9facba9db27 | 2290 | if ( debug_rtp ) debug_msg( "%d rtp reset", cb -> get_ext () ); |
klauss | 112:6ae726539ab9 | 2291 | set_status ( cb -> status, cb_idle ); |
klauss | 112:6ae726539ab9 | 2292 | set_status ( cb->sip->status, sip_idle ); |
klauss | 112:6ae726539ab9 | 2293 | cb -> reset_rtp_timer (); |
klauss | 112:6ae726539ab9 | 2294 | cb -> set_rtp_port ( 0 ); |
klauss | 112:6ae726539ab9 | 2295 | } |
klauss | 112:6ae726539ab9 | 2296 | } |
klauss | 112:6ae726539ab9 | 2297 | } |
klauss | 117:e9facba9db27 | 2298 | */ |
klauss | 117:e9facba9db27 | 2299 | |
klauss | 117:e9facba9db27 | 2300 | //invite_pgk_retry_manager( v_call, v_cb, buffer, write_buffer ); |
klauss | 117:e9facba9db27 | 2301 | |
klauss | 117:e9facba9db27 | 2302 | /* escuta se existe algum procedimento de gravação de cbx */ |
klauss | 117:e9facba9db27 | 2303 | //bl_handler(); |
klauss | 114:472502b31a12 | 2304 | |
klauss | 81:3656f00ab3db | 2305 | /* rotina que esvazia possiveis pacotes que não foram transmitidos para evitar conflito */ |
klauss | 72:895ca792c647 | 2306 | tx_buffer_ring_buffer_handler(); |
klauss | 91:c2a86b1f8aaa | 2307 | |
klauss | 30:8dfb6d8de53d | 2308 | type = __DO_NOTHING__; |
klauss | 114:472502b31a12 | 2309 | |
klauss | 81:3656f00ab3db | 2310 | if( eth_status == 0 ) eth_wdt = ETH_CONNECT_TIMEOUT; |
klauss | 114:472502b31a12 | 2311 | |
klauss | 91:c2a86b1f8aaa | 2312 | if( wdt_timer.read() >= 1 ) { |
klauss | 91:c2a86b1f8aaa | 2313 | //FIXME remove myself |
klauss | 114:472502b31a12 | 2314 | //registry_test = true; |
klauss | 114:472502b31a12 | 2315 | //invite_retry_time = true; |
klauss | 114:472502b31a12 | 2316 | |
klauss | 83:b8a1d8fdeaeb | 2317 | uptime++; |
klauss | 91:c2a86b1f8aaa | 2318 | |
klauss | 81:3656f00ab3db | 2319 | wdt_timer.reset(); |
klauss | 91:c2a86b1f8aaa | 2320 | |
klauss | 81:3656f00ab3db | 2321 | if( wdt_show ) debug_wdt = true; |
klauss | 91:c2a86b1f8aaa | 2322 | |
klauss | 81:3656f00ab3db | 2323 | if( external_wdt ) external_wdt--; |
klauss | 81:3656f00ab3db | 2324 | if( pkg_wdt ) pkg_wdt--; |
klauss | 81:3656f00ab3db | 2325 | if( eth_wdt ) eth_wdt--; |
klauss | 91:c2a86b1f8aaa | 2326 | |
klauss | 91:c2a86b1f8aaa | 2327 | if( eth_wdt && external_wdt && pkg_wdt ){ |
klauss | 81:3656f00ab3db | 2328 | wdt.kick(); |
klauss | 81:3656f00ab3db | 2329 | } |
klauss | 114:472502b31a12 | 2330 | } |
klauss | 114:472502b31a12 | 2331 | |
klauss | 91:c2a86b1f8aaa | 2332 | if( debug_wdt ) { |
klauss | 87:679ee0d594a9 | 2333 | send_msg("lpc_low_level_input_counter :: %d", lpc_low_level_input_counter ); |
klauss | 87:679ee0d594a9 | 2334 | lpc_low_level_input_counter = 0; |
klauss | 91:c2a86b1f8aaa | 2335 | |
klauss | 81:3656f00ab3db | 2336 | debug_wdt = false; |
klauss | 91:c2a86b1f8aaa | 2337 | if( eth_status == 0 ) { |
klauss | 91:c2a86b1f8aaa | 2338 | send_msg( "Wdt last reset: %s - status_eth :: Connected - Extern Wdt idle for :: %3d sec ( %3d ) - Rx from CBx idle for :: %3d sec ( %3d )", |
klauss | 91:c2a86b1f8aaa | 2339 | ( wdt.WatchdogCausedReset() ) ? "true" : "false", |
klauss | 91:c2a86b1f8aaa | 2340 | EXTERN_WDT_IDLE - external_wdt, |
klauss | 91:c2a86b1f8aaa | 2341 | EXTERN_WDT_IDLE, |
klauss | 91:c2a86b1f8aaa | 2342 | RX_CB_IDLE - pkg_wdt, |
klauss | 91:c2a86b1f8aaa | 2343 | RX_CB_IDLE |
klauss | 91:c2a86b1f8aaa | 2344 | ); |
klauss | 91:c2a86b1f8aaa | 2345 | } else { |
klauss | 91:c2a86b1f8aaa | 2346 | send_msg( "Wdt last reset: %s - status_eth :: Disconnected :: since %3d sec - Extern Wdt idle for :: %3d sec ( %3d ) - Rx from CBx idle for :: %3d sec ( %3d )", |
klauss | 91:c2a86b1f8aaa | 2347 | ( wdt.WatchdogCausedReset() ) ? "true" : "false", |
klauss | 91:c2a86b1f8aaa | 2348 | ETH_CONNECT_TIMEOUT - eth_wdt, |
klauss | 91:c2a86b1f8aaa | 2349 | EXTERN_WDT_IDLE - external_wdt, |
klauss | 91:c2a86b1f8aaa | 2350 | EXTERN_WDT_IDLE, |
klauss | 91:c2a86b1f8aaa | 2351 | RX_CB_IDLE - pkg_wdt, |
klauss | 91:c2a86b1f8aaa | 2352 | RX_CB_IDLE |
klauss | 91:c2a86b1f8aaa | 2353 | ); |
klauss | 81:3656f00ab3db | 2354 | } |
klauss | 114:472502b31a12 | 2355 | } |
klauss | 114:472502b31a12 | 2356 | } |
klauss | 0:4d17cd9c8f9d | 2357 | } |