![](/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@101:162c28286c29, 2015-02-13 (annotated)
- Committer:
- klauss
- Date:
- Fri Feb 13 18:44:45 2015 +0000
- Revision:
- 101:162c28286c29
- Parent:
- 100:09a23fcd3bdf
- Child:
- 102:98c7155e8bea
validando o clock
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 91:c2a86b1f8aaa | 1 | #include "telemetry.h" |
klauss | 91:c2a86b1f8aaa | 2 | #include "eth.h" |
klauss | 91:c2a86b1f8aaa | 3 | #include "bits.h" |
klauss | 74:81c47fff88a5 | 4 | #include "UART3Interrupt.h" // for RXBuffer[ __CB_BUFFER_SIZE__ ]; |
klauss | 91:c2a86b1f8aaa | 5 | #include "utils.h" |
klauss | 91:c2a86b1f8aaa | 6 | #include "parallelcpld.h" |
klauss | 91:c2a86b1f8aaa | 7 | #include "debug.h" |
klauss | 91:c2a86b1f8aaa | 8 | #include "flood.h" |
klauss | 91:c2a86b1f8aaa | 9 | #include "bootloader_cbx.h" |
klauss | 91:c2a86b1f8aaa | 10 | #include "call_manager.h" |
klauss | 91:c2a86b1f8aaa | 11 | #include "call_box_manager.h" |
klauss | 91:c2a86b1f8aaa | 12 | #include "sip_manager.h" |
klauss | 74:81c47fff88a5 | 13 | #include "shared_variables.h" |
klauss | 74:81c47fff88a5 | 14 | #include "prompt.h" |
klauss | 0:4d17cd9c8f9d | 15 | #include "configs.h" |
klauss | 87:679ee0d594a9 | 16 | #include "sdram.h" |
klauss | 99:e80850c51106 | 17 | #include "fw.h" |
klauss | 0:4d17cd9c8f9d | 18 | |
klauss | 87:679ee0d594a9 | 19 | volatile u16_t lpc_low_level_input_counter = 0; |
klauss | 85:b6f2dc1d0f4f | 20 | |
klauss | 91:c2a86b1f8aaa | 21 | int main() |
klauss | 91:c2a86b1f8aaa | 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 | 87:679ee0d594a9 | 31 | send_msg("******* Failed to initialize SDRAM *******"); |
klauss | 87:679ee0d594a9 | 32 | return 1; |
klauss | 89:0fe315117b00 | 33 | } else { |
klauss | 87:679ee0d594a9 | 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 | 89:0fe315117b00 | 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 | 87:679ee0d594a9 | 47 | send_msg("******* Cannot connect to eth *******"); |
klauss | 91:c2a86b1f8aaa | 48 | } else { |
klauss | 81:3656f00ab3db | 49 | send_msg("******* Connection eth - ok *******"); |
klauss | 78:1353744f01e1 | 50 | init_prompt_eth(); |
klauss | 82:f55d13babca0 | 51 | init_external_wdt() |
klauss | 8:e3bfe62a477e | 52 | } |
klauss | 91:c2a86b1f8aaa | 53 | |
klauss | 78:1353744f01e1 | 54 | Timer sync_timer, led_sync_timer; |
klauss | 78:1353744f01e1 | 55 | sync_timer.start(), led_sync_timer.start(); |
klauss | 91:c2a86b1f8aaa | 56 | |
klauss | 0:4d17cd9c8f9d | 57 | /* representa ramal do call box */ |
klauss | 0:4d17cd9c8f9d | 58 | int ext = 0; |
klauss | 91:c2a86b1f8aaa | 59 | |
klauss | 0:4d17cd9c8f9d | 60 | /* representa porta do call box */ |
klauss | 78:1353744f01e1 | 61 | int port = 0; |
klauss | 91:c2a86b1f8aaa | 62 | |
klauss | 0:4d17cd9c8f9d | 63 | /* buffer para onde se copia os dados vindos do cb para tratameno interno */ |
klauss | 91:c2a86b1f8aaa | 64 | uint8_t buffer[ __CB_BUFFER_SIZE__ ]; |
klauss | 91:c2a86b1f8aaa | 65 | |
klauss | 0:4d17cd9c8f9d | 66 | /* buffer de escrita do pacote de saida que sera enviado pro cb / servidor */ |
klauss | 0:4d17cd9c8f9d | 67 | uint8_t write_buffer[ __CB_BUFFER_SIZE__ ]; |
klauss | 91:c2a86b1f8aaa | 68 | |
klauss | 0:4d17cd9c8f9d | 69 | /* ponteiro que aponta para os dados vindo do CPLD */ |
klauss | 0:4d17cd9c8f9d | 70 | uint8_t * buffer_from_cb_ptr = ( uint8_t * )RXBuffer; |
klauss | 91:c2a86b1f8aaa | 71 | |
klauss | 62:07e5bdc9f8f7 | 72 | /* Armazena o ultimo pacote recebido dos CBx */ |
klauss | 62:07e5bdc9f8f7 | 73 | uint8_t cb_rx_buffer[ __CB_BUFFER_SIZE__ ]; |
klauss | 91:c2a86b1f8aaa | 74 | |
klauss | 0:4d17cd9c8f9d | 75 | /* referencia para os dados contidos no pacote, sem o header */ |
klauss | 0:4d17cd9c8f9d | 76 | uint8_t * data = NULL; |
klauss | 91:c2a86b1f8aaa | 77 | |
klauss | 0:4d17cd9c8f9d | 78 | /* gerencia o tipo do pacote para providenciar tratamento adequado */ |
klauss | 0:4d17cd9c8f9d | 79 | volatile uint8_t type = __DO_NOTHING__; |
klauss | 91:c2a86b1f8aaa | 80 | |
klauss | 87:679ee0d594a9 | 81 | /* representa a lista dos Call Boxes atualmente recfonhecidos pela cabeceira */ |
klauss | 0:4d17cd9c8f9d | 82 | Vector * v_cb = new Vector(); |
klauss | 91:c2a86b1f8aaa | 83 | |
klauss | 0:4d17cd9c8f9d | 84 | /* representa a lista de ligacoes ativas na cabeceira */ |
klauss | 0:4d17cd9c8f9d | 85 | Vector * v_call = new Vector(); |
klauss | 91:c2a86b1f8aaa | 86 | |
klauss | 0:4d17cd9c8f9d | 87 | /* gerencia a distribuicao de timeslice para os call boxes */ |
klauss | 0:4d17cd9c8f9d | 88 | Timeslice * ts = new Timeslice(); |
klauss | 91:c2a86b1f8aaa | 89 | if( ts == NULL ) { |
klauss | 89:0fe315117b00 | 90 | memory_is_over = true; |
klauss | 89:0fe315117b00 | 91 | if( debug_memory ) debug_msg("TS allocation fail"); |
klauss | 89:0fe315117b00 | 92 | } |
klauss | 91:c2a86b1f8aaa | 93 | |
klauss | 81:3656f00ab3db | 94 | /* instancia o vetor de call boxes // calls */ |
klauss | 91:c2a86b1f8aaa | 95 | if( v_cb == NULL ) { |
klauss | 91:c2a86b1f8aaa | 96 | while( v_cb == NULL ) { |
klauss | 0:4d17cd9c8f9d | 97 | Vector * v_cb = new Vector(); |
klauss | 91:c2a86b1f8aaa | 98 | if( sync_timer.read() > 5 ) { |
klauss | 48:195c97f12e8e | 99 | send_msg("Erro ao alocar o vetor de CBx"); |
klauss | 78:1353744f01e1 | 100 | sync_timer.reset(); |
klauss | 0:4d17cd9c8f9d | 101 | } |
klauss | 0:4d17cd9c8f9d | 102 | } |
klauss | 91:c2a86b1f8aaa | 103 | } else if( v_call == NULL ) { |
klauss | 91:c2a86b1f8aaa | 104 | while( v_call == NULL ) { |
klauss | 0:4d17cd9c8f9d | 105 | Vector * v_call = new Vector(); |
klauss | 91:c2a86b1f8aaa | 106 | if( sync_timer.read() > 5 ) { |
klauss | 48:195c97f12e8e | 107 | send_msg("Erro ao alocar o vetor de Calls"); |
klauss | 78:1353744f01e1 | 108 | sync_timer.reset(); |
klauss | 0:4d17cd9c8f9d | 109 | } |
klauss | 0:4d17cd9c8f9d | 110 | } |
klauss | 0:4d17cd9c8f9d | 111 | } |
klauss | 91:c2a86b1f8aaa | 112 | |
klauss | 91:c2a86b1f8aaa | 113 | if( v_cb == NULL ) { |
klauss | 89:0fe315117b00 | 114 | memory_is_over = true; |
klauss | 89:0fe315117b00 | 115 | if( debug_memory ) debug_msg("Call_Box vector allocation fail"); |
klauss | 89:0fe315117b00 | 116 | } |
klauss | 91:c2a86b1f8aaa | 117 | |
klauss | 91:c2a86b1f8aaa | 118 | if( v_call == NULL ) { |
klauss | 89:0fe315117b00 | 119 | memory_is_over = true; |
klauss | 89:0fe315117b00 | 120 | if( debug_memory ) debug_msg("Call vector allocation fail"); |
klauss | 89:0fe315117b00 | 121 | } |
klauss | 91:c2a86b1f8aaa | 122 | |
klauss | 91:c2a86b1f8aaa | 123 | for( register uint16_t i = 0; i < __CB_BUFFER_SIZE__; i++ ) { |
klauss | 63:0d95da692bb4 | 124 | cb_rx_buffer[ i ] = 0; |
klauss | 63:0d95da692bb4 | 125 | cb_tx_buffer[ i ] = 0; |
klauss | 63:0d95da692bb4 | 126 | } |
klauss | 91:c2a86b1f8aaa | 127 | |
klauss | 0:4d17cd9c8f9d | 128 | reset_leds(); |
klauss | 91:c2a86b1f8aaa | 129 | |
klauss | 33:735fd60e96d8 | 130 | udp_timer.start(); |
klauss | 91:c2a86b1f8aaa | 131 | |
klauss | 68:b54993674190 | 132 | init_telemetry_handler(); |
klauss | 99:e80850c51106 | 133 | |
klauss | 99:e80850c51106 | 134 | //debug_msg(""); |
klauss | 99:e80850c51106 | 135 | init_fw_handler(); |
klauss | 99:e80850c51106 | 136 | //debug_msg(""); |
klauss | 99:e80850c51106 | 137 | |
klauss | 99:e80850c51106 | 138 | led2 = 0; |
klauss | 81:3656f00ab3db | 139 | init_ranges(); |
klauss | 91:c2a86b1f8aaa | 140 | |
klauss | 80:61d61c9eb75c | 141 | init_refresh(); |
klauss | 91:c2a86b1f8aaa | 142 | |
klauss | 78:1353744f01e1 | 143 | init_aging(); |
klauss | 91:c2a86b1f8aaa | 144 | |
klauss | 89:0fe315117b00 | 145 | init_sync_refresh(); |
klauss | 101:162c28286c29 | 146 | |
klauss | 101:162c28286c29 | 147 | init_clock(); |
klauss | 91:c2a86b1f8aaa | 148 | |
klauss | 81:3656f00ab3db | 149 | //init_invite_pgk_retry_manager(); |
klauss | 91:c2a86b1f8aaa | 150 | |
klauss | 81:3656f00ab3db | 151 | //void init_bye_pgk_retry_manager(); |
klauss | 91:c2a86b1f8aaa | 152 | |
klauss | 62:07e5bdc9f8f7 | 153 | static uint8_t count = 0; |
klauss | 91:c2a86b1f8aaa | 154 | |
klauss | 89:0fe315117b00 | 155 | //short int bl_ret = init_bl_handler(); |
klauss | 89:0fe315117b00 | 156 | //if( dbl ) send_msg("Valor de retorno do bl_habdler = %d", bl_ret ); |
klauss | 91:c2a86b1f8aaa | 157 | |
klauss | 78:1353744f01e1 | 158 | uint8_t max_registered_cbx = 0; |
klauss | 91:c2a86b1f8aaa | 159 | |
klauss | 81:3656f00ab3db | 160 | bool wake_all = false; |
klauss | 91:c2a86b1f8aaa | 161 | |
klauss | 81:3656f00ab3db | 162 | uint16_t pkg_wdt = RX_CB_IDLE; |
klauss | 81:3656f00ab3db | 163 | uint16_t eth_wdt = ETH_CONNECT_TIMEOUT; |
klauss | 83:b8a1d8fdeaeb | 164 | uint32_t uptime = 0; |
klauss | 99:e80850c51106 | 165 | led1 = 0; |
klauss | 68:b54993674190 | 166 | send_msg("Ready"); |
klauss | 91:c2a86b1f8aaa | 167 | |
klauss | 92:92df17f538a8 | 168 | //bool registry_test = false; |
klauss | 92:92df17f538a8 | 169 | //static int next_value = 5002; |
klauss | 92:92df17f538a8 | 170 | //static int nex_test_registry = next_value; |
klauss | 92:92df17f538a8 | 171 | |
klauss | 99:e80850c51106 | 172 | //bool invite_retry_time = false; |
klauss | 99:e80850c51106 | 173 | Timer invite_retry_timer; |
klauss | 99:e80850c51106 | 174 | invite_retry_timer.start(); |
klauss | 100:09a23fcd3bdf | 175 | debug_uart3 = false; |
klauss | 91:c2a86b1f8aaa | 176 | |
klauss | 78:1353744f01e1 | 177 | /*------------------------------------------ main loop ---------------------------------------------------------------*/ |
klauss | 91:c2a86b1f8aaa | 178 | while( true ) { |
klauss | 99:e80850c51106 | 179 | reset_leds(); |
klauss | 100:09a23fcd3bdf | 180 | // need be removed; |
klauss | 99:e80850c51106 | 181 | |
klauss | 78:1353744f01e1 | 182 | if( v_cb->size() > max_registered_cbx ) max_registered_cbx = v_cb->size(); |
klauss | 91:c2a86b1f8aaa | 183 | |
klauss | 91:c2a86b1f8aaa | 184 | if( sync_timer.read() > 5 ) { |
klauss | 78:1353744f01e1 | 185 | sync_timer.reset(); |
klauss | 91:c2a86b1f8aaa | 186 | |
klauss | 91:c2a86b1f8aaa | 187 | if( debug_cks == true ) { |
klauss | 81:3656f00ab3db | 188 | pcks_s = true; |
klauss | 78:1353744f01e1 | 189 | } |
klauss | 91:c2a86b1f8aaa | 190 | |
klauss | 91:c2a86b1f8aaa | 191 | if( debug_alive == true ) { |
klauss | 81:3656f00ab3db | 192 | pshowcb = true; |
klauss | 78:1353744f01e1 | 193 | } |
klauss | 100:09a23fcd3bdf | 194 | |
klauss | 100:09a23fcd3bdf | 195 | |
klauss | 91:c2a86b1f8aaa | 196 | if( !( ++count % 15 ) ) { |
klauss | 91:c2a86b1f8aaa | 197 | if( eth_status ) { |
klauss | 78:1353744f01e1 | 198 | eth_status = __init_eth__(); |
klauss | 91:c2a86b1f8aaa | 199 | if( eth_status ) { |
klauss | 78:1353744f01e1 | 200 | if( debug_main ) debug_msg("Cannot connect to eth"); |
klauss | 91:c2a86b1f8aaa | 201 | } else { |
klauss | 78:1353744f01e1 | 202 | if( debug_main ) debug_msg("Connection eth - ok"); |
klauss | 78:1353744f01e1 | 203 | init_prompt_eth(); |
klauss | 82:f55d13babca0 | 204 | init_external_wdt() |
klauss | 78:1353744f01e1 | 205 | } |
klauss | 78:1353744f01e1 | 206 | } |
klauss | 78:1353744f01e1 | 207 | } |
klauss | 100:09a23fcd3bdf | 208 | |
klauss | 81:3656f00ab3db | 209 | //35 sec. |
klauss | 91:c2a86b1f8aaa | 210 | if( ( count > 7 ) && ( wake_all == false ) ) { |
klauss | 81:3656f00ab3db | 211 | wake_all = true; |
klauss | 78:1353744f01e1 | 212 | if( debug_wake == true ) send_msg( "Time to wake" ); |
klauss | 78:1353744f01e1 | 213 | } |
klauss | 78:1353744f01e1 | 214 | } |
klauss | 91:c2a86b1f8aaa | 215 | |
klauss | 68:b54993674190 | 216 | //FIXMEj colocar uma condicao aqui caso necessario pra nao comprometer ligacoes ... |
klauss | 35:96885a7931f0 | 217 | prompt_process( NULL ); |
klauss | 91:c2a86b1f8aaa | 218 | |
klauss | 91:c2a86b1f8aaa | 219 | if( r_stats ) { |
klauss | 91:c2a86b1f8aaa | 220 | boot_counter = 0; |
klauss | 91:c2a86b1f8aaa | 221 | registry_counter = 0; |
klauss | 91:c2a86b1f8aaa | 222 | invite_counter = 0; |
klauss | 91:c2a86b1f8aaa | 223 | audio_counter = 0; |
klauss | 91:c2a86b1f8aaa | 224 | telemetry_counter = 0; |
klauss | 91:c2a86b1f8aaa | 225 | cb_bye_counter = 0; |
klauss | 91:c2a86b1f8aaa | 226 | prompt_counter = 0; |
klauss | 91:c2a86b1f8aaa | 227 | flood_counter = 0; |
klauss | 67:cdedc64d9921 | 228 | bootloader_cbx_counter = 0; |
klauss | 99:e80850c51106 | 229 | cb_stats_counter = 0; |
klauss | 63:0d95da692bb4 | 230 | r_stats = false; |
klauss | 63:0d95da692bb4 | 231 | stats = true; |
klauss | 63:0d95da692bb4 | 232 | } |
klauss | 91:c2a86b1f8aaa | 233 | |
klauss | 91:c2a86b1f8aaa | 234 | if( stats ) { |
klauss | 63:0d95da692bb4 | 235 | char str[ 200 ]; |
klauss | 99:e80850c51106 | 236 | 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 | 99:e80850c51106 | 237 | 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 | 238 | send_msg( str ); |
klauss | 63:0d95da692bb4 | 239 | stats =false; |
klauss | 63:0d95da692bb4 | 240 | } |
klauss | 91:c2a86b1f8aaa | 241 | |
klauss | 91:c2a86b1f8aaa | 242 | if( list ) { |
klauss | 78:1353744f01e1 | 243 | uint8_t missed_cb = ( ( max_ext - min_ext ) + 1 ) - v_cb->size(); |
klauss | 91:c2a86b1f8aaa | 244 | |
klauss | 78:1353744f01e1 | 245 | if( ( max_ext % 2 ) == 0 ) missed_cb++; |
klauss | 91:c2a86b1f8aaa | 246 | |
klauss | 78:1353744f01e1 | 247 | if( min_ext % 2 ) missed_cb++; |
klauss | 91:c2a86b1f8aaa | 248 | |
klauss | 78:1353744f01e1 | 249 | if( min_ext == 0 && max_ext == 0 ) missed_cb = 0; |
klauss | 91:c2a86b1f8aaa | 250 | |
klauss | 78:1353744f01e1 | 251 | 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 | 252 | if( v_cb->size() == 1 ) { |
klauss | 78:1353744f01e1 | 253 | send_msg(" %d ", ( ( Call_Box * )v_cb->get_element( 0 ) )->get_ext() ); |
klauss | 91:c2a86b1f8aaa | 254 | } else if( v_cb->size() > 1 ) { |
klauss | 62:07e5bdc9f8f7 | 255 | char str[ 1024 ]; |
klauss | 78:1353744f01e1 | 256 | int ext_list[ __MAX_CB_IN_A_BRANCH__ ]; |
klauss | 62:07e5bdc9f8f7 | 257 | register int i = 0; |
klauss | 91:c2a86b1f8aaa | 258 | for( ; i < v_cb->size(); i++ ) { |
klauss | 78:1353744f01e1 | 259 | ext_list[ i ] = ( ( Call_Box * )v_cb->get_element( i ) )->get_ext(); |
klauss | 62:07e5bdc9f8f7 | 260 | } |
klauss | 91:c2a86b1f8aaa | 261 | |
klauss | 62:07e5bdc9f8f7 | 262 | qsort( ext_list, v_cb->size(), sizeof( int ), ls_comp ); |
klauss | 91:c2a86b1f8aaa | 263 | |
klauss | 62:07e5bdc9f8f7 | 264 | char aux[ 16 ]; |
klauss | 78:1353744f01e1 | 265 | strcpy( str, "\r\n> " ); |
klauss | 91:c2a86b1f8aaa | 266 | for( i = 0; i < v_cb->size() - 1; i++ ) { |
klauss | 62:07e5bdc9f8f7 | 267 | sprintf( aux, "%i, ", ext_list[ i ] ); |
klauss | 62:07e5bdc9f8f7 | 268 | strcat( str, aux ); |
klauss | 78:1353744f01e1 | 269 | if( ( i != 0 ) && !( ( i + 1 ) % 16 ) ) strcat( str, "\r\n> " ); |
klauss | 62:07e5bdc9f8f7 | 270 | } |
klauss | 62:07e5bdc9f8f7 | 271 | sprintf( aux, "%i ", ext_list[ i ] ); |
klauss | 62:07e5bdc9f8f7 | 272 | strcat( str, aux ); |
klauss | 62:07e5bdc9f8f7 | 273 | send_msg( "%s", str ); |
klauss | 62:07e5bdc9f8f7 | 274 | } |
klauss | 91:c2a86b1f8aaa | 275 | list = false; |
klauss | 62:07e5bdc9f8f7 | 276 | } |
klauss | 91:c2a86b1f8aaa | 277 | |
klauss | 91:c2a86b1f8aaa | 278 | if( long_list ) { |
klauss | 81:3656f00ab3db | 279 | //FIXME implementar um algoritmo que me mostre o timeout de cada cbx do lado da linha, desse. |
klauss | 85:b6f2dc1d0f4f | 280 | /* |
klauss | 81:3656f00ab3db | 281 | uint8_t missed_cb = ( ( max_ext - min_ext ) + 1 ) - v_cb->size(); |
klauss | 91:c2a86b1f8aaa | 282 | |
klauss | 81:3656f00ab3db | 283 | if( ( max_ext % 2 ) == 0 ) missed_cb++; |
klauss | 91:c2a86b1f8aaa | 284 | |
klauss | 81:3656f00ab3db | 285 | if( min_ext % 2 ) missed_cb++; |
klauss | 91:c2a86b1f8aaa | 286 | |
klauss | 81:3656f00ab3db | 287 | if( min_ext == 0 && max_ext == 0 ) missed_cb = 0; |
klauss | 91:c2a86b1f8aaa | 288 | |
klauss | 81:3656f00ab3db | 289 | 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 | 81:3656f00ab3db | 290 | if( v_cb->size() == 1 ){ |
klauss | 81:3656f00ab3db | 291 | send_msg(" %d ", ( ( Call_Box * )v_cb->get_element( 0 ) )->get_ext() ); |
klauss | 81:3656f00ab3db | 292 | }else if( v_cb->size() > 1 ){ |
klauss | 81:3656f00ab3db | 293 | char str[ 1024 ]; |
klauss | 81:3656f00ab3db | 294 | int ext_list[ __MAX_CB_IN_A_BRANCH__ ]; |
klauss | 81:3656f00ab3db | 295 | register int i = 0; |
klauss | 81:3656f00ab3db | 296 | for( ; i < ( v_cb->size() * 2 ); i += 2 ){ |
klauss | 81:3656f00ab3db | 297 | ext_list[ i ] = ( ( Call_Box * )v_cb->get_element( i ) )->get_ext(); |
klauss | 81:3656f00ab3db | 298 | ext_list[ i + 1 ] = ( ( Call_Box * )v_cb->get_element( i ) )->get_elapsed_time(); |
klauss | 81:3656f00ab3db | 299 | } |
klauss | 91:c2a86b1f8aaa | 300 | |
klauss | 81:3656f00ab3db | 301 | qsort( ext_list, v_cb->size(), sizeof( int ) * 2, ls_comp ); |
klauss | 91:c2a86b1f8aaa | 302 | |
klauss | 81:3656f00ab3db | 303 | char aux[ 16 ]; |
klauss | 81:3656f00ab3db | 304 | strcpy( str, "\r\n> " ); |
klauss | 81:3656f00ab3db | 305 | for( i = 0; i < ( v_cb->size() * 2 ) - 2; i++ ){ |
klauss | 81:3656f00ab3db | 306 | sprintf( aux, "%i - %i,", ext_list[ i ], ext_list[ i + 1 ] ); |
klauss | 81:3656f00ab3db | 307 | strcat( str, aux ); |
klauss | 81:3656f00ab3db | 308 | strcat( str, "\r\n> " ); |
klauss | 81:3656f00ab3db | 309 | } |
klauss | 81:3656f00ab3db | 310 | sprintf( aux, "%i - %i,", ext_list[ i ], ext_list[ i + 1 ] ); |
klauss | 81:3656f00ab3db | 311 | strcat( str, aux ); |
klauss | 81:3656f00ab3db | 312 | send_msg( "%s", str ); |
klauss | 81:3656f00ab3db | 313 | } |
klauss | 85:b6f2dc1d0f4f | 314 | */ |
klauss | 91:c2a86b1f8aaa | 315 | long_list = false; |
klauss | 52:12930cef17c4 | 316 | } |
klauss | 91:c2a86b1f8aaa | 317 | |
klauss | 91:c2a86b1f8aaa | 318 | if( pshowcb == true ) { |
klauss | 78:1353744f01e1 | 319 | 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 | 320 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 30:8dfb6d8de53d | 321 | Call_Box * cb = ( Call_Box * )v_cb->get_element( i ); |
klauss | 78:1353744f01e1 | 322 | char cb_status[ 32 ]; |
klauss | 78:1353744f01e1 | 323 | char cb_sip_status[ 32 ]; |
klauss | 91:c2a86b1f8aaa | 324 | switch( cb->status ) { |
klauss | 91:c2a86b1f8aaa | 325 | case cb_idle : { |
klauss | 91:c2a86b1f8aaa | 326 | strcpy( cb_status, "cb_idle" ); |
klauss | 91:c2a86b1f8aaa | 327 | break; |
klauss | 91:c2a86b1f8aaa | 328 | } |
klauss | 91:c2a86b1f8aaa | 329 | case cb_ringing : { |
klauss | 91:c2a86b1f8aaa | 330 | strcpy( cb_status, "cb_ringing" ); |
klauss | 91:c2a86b1f8aaa | 331 | break; |
klauss | 91:c2a86b1f8aaa | 332 | } |
klauss | 91:c2a86b1f8aaa | 333 | case cb_trying : { |
klauss | 91:c2a86b1f8aaa | 334 | strcpy( cb_status,"cb_trying" ); |
klauss | 91:c2a86b1f8aaa | 335 | break; |
klauss | 91:c2a86b1f8aaa | 336 | } |
klauss | 91:c2a86b1f8aaa | 337 | case cb_on_call : { |
klauss | 91:c2a86b1f8aaa | 338 | strcpy( cb_status, "cb_on_call" ); |
klauss | 91:c2a86b1f8aaa | 339 | break; |
klauss | 91:c2a86b1f8aaa | 340 | } |
klauss | 91:c2a86b1f8aaa | 341 | case cb_busy : { |
klauss | 91:c2a86b1f8aaa | 342 | strcpy( cb_status, "cb_busy" ); |
klauss | 91:c2a86b1f8aaa | 343 | break; |
klauss | 91:c2a86b1f8aaa | 344 | } |
klauss | 91:c2a86b1f8aaa | 345 | case cb_denied : { |
klauss | 91:c2a86b1f8aaa | 346 | strcpy( cb_status, "cb_denied" ); |
klauss | 91:c2a86b1f8aaa | 347 | break; |
klauss | 91:c2a86b1f8aaa | 348 | } |
klauss | 78:1353744f01e1 | 349 | } |
klauss | 91:c2a86b1f8aaa | 350 | switch( cb->sip->status ) { |
klauss | 91:c2a86b1f8aaa | 351 | case sip_idle : { |
klauss | 91:c2a86b1f8aaa | 352 | strcpy( cb_sip_status, "sip_idle" ); |
klauss | 91:c2a86b1f8aaa | 353 | break; |
klauss | 91:c2a86b1f8aaa | 354 | } |
klauss | 91:c2a86b1f8aaa | 355 | case sip_waiting_trying : { |
klauss | 91:c2a86b1f8aaa | 356 | strcpy( cb_sip_status, "sip_waiting_trying" ); |
klauss | 91:c2a86b1f8aaa | 357 | break; |
klauss | 91:c2a86b1f8aaa | 358 | } |
klauss | 91:c2a86b1f8aaa | 359 | case sip_trying : { |
klauss | 91:c2a86b1f8aaa | 360 | strcpy( cb_sip_status, "sip_trying" ); |
klauss | 91:c2a86b1f8aaa | 361 | break; |
klauss | 91:c2a86b1f8aaa | 362 | } |
klauss | 91:c2a86b1f8aaa | 363 | case sip_ringing : { |
klauss | 91:c2a86b1f8aaa | 364 | strcpy( cb_sip_status, "sip_ringing" ); |
klauss | 91:c2a86b1f8aaa | 365 | break; |
klauss | 91:c2a86b1f8aaa | 366 | } |
klauss | 91:c2a86b1f8aaa | 367 | case sip_busy : { |
klauss | 91:c2a86b1f8aaa | 368 | strcpy( cb_sip_status, "sip_busy" ); |
klauss | 91:c2a86b1f8aaa | 369 | break; |
klauss | 91:c2a86b1f8aaa | 370 | } |
klauss | 91:c2a86b1f8aaa | 371 | case sip_ok : { |
klauss | 91:c2a86b1f8aaa | 372 | strcpy( cb_sip_status, "sip_ok" ); |
klauss | 91:c2a86b1f8aaa | 373 | break; |
klauss | 91:c2a86b1f8aaa | 374 | } |
klauss | 91:c2a86b1f8aaa | 375 | case sip_on_call : { |
klauss | 91:c2a86b1f8aaa | 376 | strcpy( cb_sip_status, "sip_on_call" ); |
klauss | 91:c2a86b1f8aaa | 377 | break; |
klauss | 91:c2a86b1f8aaa | 378 | } |
klauss | 91:c2a86b1f8aaa | 379 | case sip_denied : { |
klauss | 91:c2a86b1f8aaa | 380 | strcpy( cb_sip_status, "sip_denied" ); |
klauss | 91:c2a86b1f8aaa | 381 | break; |
klauss | 91:c2a86b1f8aaa | 382 | } |
klauss | 78:1353744f01e1 | 383 | } |
klauss | 78:1353744f01e1 | 384 | char cbx_to_string[ 254 ]; |
klauss | 78:1353744f01e1 | 385 | char aux[ 16 ]; |
klauss | 78:1353744f01e1 | 386 | strcpy( cbx_to_string, "Ext :: " ); |
klauss | 78:1353744f01e1 | 387 | itoa( cb->get_ext(), aux , 10 ); |
klauss | 98:43b45f26b430 | 388 | strcat( cbx_to_string, aux ); |
klauss | 97:8985817e8847 | 389 | strcat( cbx_to_string, " :: Port :: " ); |
klauss | 97:8985817e8847 | 390 | itoa( cb->get_port(), aux , 10 ); |
klauss | 78:1353744f01e1 | 391 | strcat( cbx_to_string, aux ); |
klauss | 78:1353744f01e1 | 392 | strcat( cbx_to_string, " :: Status -- " ); |
klauss | 78:1353744f01e1 | 393 | strcat( cbx_to_string, cb_status ); |
klauss | 78:1353744f01e1 | 394 | strcat( cbx_to_string, " - " ); |
klauss | 78:1353744f01e1 | 395 | strcat( cbx_to_string, cb_sip_status ); |
klauss | 91:c2a86b1f8aaa | 396 | if( cb->get_timeslice() != 0 ) { |
klauss | 78:1353744f01e1 | 397 | strcat( cbx_to_string, " -- on TimeSlice :: " ); |
klauss | 78:1353744f01e1 | 398 | itoa( cb->get_timeslice(), aux , 10 ); |
klauss | 78:1353744f01e1 | 399 | strcat( cbx_to_string, aux ); |
klauss | 78:1353744f01e1 | 400 | } |
klauss | 78:1353744f01e1 | 401 | send_msg( cbx_to_string ); |
klauss | 48:195c97f12e8e | 402 | } |
klauss | 78:1353744f01e1 | 403 | pshowcb = false; |
klauss | 48:195c97f12e8e | 404 | } |
klauss | 97:8985817e8847 | 405 | |
klauss | 97:8985817e8847 | 406 | if( show_sip == true ){ |
klauss | 97:8985817e8847 | 407 | show_sip = false; |
klauss | 99:e80850c51106 | 408 | send_msg(":: Sip :: %u", v_cb->size() ); |
klauss | 97:8985817e8847 | 409 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 97:8985817e8847 | 410 | Call_Box * cb = ( Call_Box * )v_cb->get_element( i ); |
klauss | 99:e80850c51106 | 411 | send_msg("ext :: %d -- port :: %d -- timer %d", cb->get_sip_ext(), cb->get_sip_port(), cb->get_timer() ); |
klauss | 97:8985817e8847 | 412 | } |
klauss | 97:8985817e8847 | 413 | } |
klauss | 91:c2a86b1f8aaa | 414 | |
klauss | 81:3656f00ab3db | 415 | if( pflood == true ) flood(); |
klauss | 91:c2a86b1f8aaa | 416 | |
klauss | 91:c2a86b1f8aaa | 417 | if( debug_eth ) { |
klauss | 81:3656f00ab3db | 418 | debug_eth = false; |
klauss | 81:3656f00ab3db | 419 | send_msg("Eth status %s", ( eth_status == 0 ) ? "Connected" : "Disconnected" ); |
klauss | 81:3656f00ab3db | 420 | } |
klauss | 91:c2a86b1f8aaa | 421 | |
klauss | 91:c2a86b1f8aaa | 422 | if( status != __WAITING__ ) { |
klauss | 81:3656f00ab3db | 423 | pkg_wdt = RX_CB_IDLE; |
klauss | 86:bf7b0d4c3232 | 424 | xmemcpy( cb_rx_buffer, buffer_from_cb_ptr, __CB_BUFFER_SIZE__ ); |
klauss | 0:4d17cd9c8f9d | 425 | status = __WAITING__; |
klauss | 81:3656f00ab3db | 426 | missed_pkg--; |
klauss | 91:c2a86b1f8aaa | 427 | xmemcpy( buffer, cb_rx_buffer, __CB_BUFFER_SIZE__ ); |
klauss | 98:43b45f26b430 | 428 | |
klauss | 98:43b45f26b430 | 429 | /* |
klauss | 98:43b45f26b430 | 430 | { |
klauss | 98:43b45f26b430 | 431 | uint16_t e, p; |
klauss | 98:43b45f26b430 | 432 | e = buffer[0]; |
klauss | 98:43b45f26b430 | 433 | e <<= 8; |
klauss | 98:43b45f26b430 | 434 | e |= buffer[1]; |
klauss | 98:43b45f26b430 | 435 | p = buffer[2]; |
klauss | 98:43b45f26b430 | 436 | p <<= 8; |
klauss | 98:43b45f26b430 | 437 | p |= buffer[3]; |
klauss | 98:43b45f26b430 | 438 | //if (e != (p+100)) { |
klauss | 98:43b45f26b430 | 439 | if( ( buffer[0] == 0x14 ) && ( buffer[1] == 0x0a ) ) { |
klauss | 98:43b45f26b430 | 440 | int i; |
klauss | 98:43b45f26b430 | 441 | char s[400], ss[4];; |
klauss | 98:43b45f26b430 | 442 | strcpy(s,"OPS-PKG:"); |
klauss | 98:43b45f26b430 | 443 | for (i=0; i<40; i++) { |
klauss | 98:43b45f26b430 | 444 | sprintf(ss," %02x",buffer[i]); |
klauss | 98:43b45f26b430 | 445 | strcat(s,ss); |
klauss | 98:43b45f26b430 | 446 | } |
klauss | 98:43b45f26b430 | 447 | debug_msg( s ); |
klauss | 98:43b45f26b430 | 448 | } |
klauss | 98:43b45f26b430 | 449 | } |
klauss | 98:43b45f26b430 | 450 | */ |
klauss | 98:43b45f26b430 | 451 | |
klauss | 91:c2a86b1f8aaa | 452 | if( debug_cpld ) { |
klauss | 81:3656f00ab3db | 453 | rx = true; |
klauss | 81:3656f00ab3db | 454 | tx = true; |
klauss | 81:3656f00ab3db | 455 | } |
klauss | 91:c2a86b1f8aaa | 456 | |
klauss | 91:c2a86b1f8aaa | 457 | if( rx ) { |
klauss | 81:3656f00ab3db | 458 | char str[ 1024 ]; |
klauss | 81:3656f00ab3db | 459 | strcpy( str, "RX :: \n\r " ); |
klauss | 91:c2a86b1f8aaa | 460 | for( register uint16_t i = 0; i < __CB_BUFFER_SIZE__; i++ ) { |
klauss | 81:3656f00ab3db | 461 | char tmp[ 16 ]; |
klauss | 81:3656f00ab3db | 462 | strcat( str, itoa( cb_rx_buffer[ i ], tmp, 16 ) ); |
klauss | 81:3656f00ab3db | 463 | if( ( i != 0 ) && !( ( i + 1 ) % 50 ) ) strcat( str, "\n\r " ); |
klauss | 91:c2a86b1f8aaa | 464 | |
klauss | 81:3656f00ab3db | 465 | else strcat( str, " " ); |
klauss | 81:3656f00ab3db | 466 | } |
klauss | 81:3656f00ab3db | 467 | send_msg( "%s", str ); |
klauss | 91:c2a86b1f8aaa | 468 | rx = false; |
klauss | 81:3656f00ab3db | 469 | } |
klauss | 91:c2a86b1f8aaa | 470 | |
klauss | 34:f19d9735428e | 471 | data = __parse_vz_pkg__( &ext, &port, &type, buffer ); |
klauss | 91:c2a86b1f8aaa | 472 | |
klauss | 91:c2a86b1f8aaa | 473 | if( data != NULL ) { |
klauss | 78:1353744f01e1 | 474 | if( min_ext == 0 ) min_ext = ext; |
klauss | 91:c2a86b1f8aaa | 475 | |
klauss | 78:1353744f01e1 | 476 | if( ext > max_ext ) max_ext = ext; |
klauss | 91:c2a86b1f8aaa | 477 | |
klauss | 78:1353744f01e1 | 478 | if( ext < min_ext ) min_ext = ext; |
klauss | 99:e80850c51106 | 479 | |
klauss | 99:e80850c51106 | 480 | if( debug_fw ){ |
klauss | 99:e80850c51106 | 481 | fw_cbx_pkg( ext, port, ( char *)buffer ); |
klauss | 99:e80850c51106 | 482 | } |
klauss | 99:e80850c51106 | 483 | |
klauss | 99:e80850c51106 | 484 | if( type == __TELEMETRY__ ) telemetry_counter++; |
klauss | 91:c2a86b1f8aaa | 485 | |
klauss | 91:c2a86b1f8aaa | 486 | if( type != __AUDIO__ ) { |
klauss | 99:e80850c51106 | 487 | if( |
klauss | 99:e80850c51106 | 488 | type == __TELEMETRY__ || |
klauss | 99:e80850c51106 | 489 | type == __CB_STATS__ || |
klauss | 99:e80850c51106 | 490 | type == __FW1__ || |
klauss | 99:e80850c51106 | 491 | type == __FW2__ || |
klauss | 99:e80850c51106 | 492 | type == __FW3__ || |
klauss | 99:e80850c51106 | 493 | type == __FW4__ || |
klauss | 99:e80850c51106 | 494 | type == __FW5__ || |
klauss | 99:e80850c51106 | 495 | type == __FW6__ |
klauss | 99:e80850c51106 | 496 | ) type = __FW__; |
klauss | 99:e80850c51106 | 497 | |
klauss | 99:e80850c51106 | 498 | if( debug_cb_rx == true ){ |
klauss | 99:e80850c51106 | 499 | send_msg("Pkg from CBx :: ( %d, %d ) -- Type :: %d", ext, port, type ); |
klauss | 99:e80850c51106 | 500 | } |
klauss | 99:e80850c51106 | 501 | |
klauss | 0:4d17cd9c8f9d | 502 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 91:c2a86b1f8aaa | 503 | if( cb != NULL ) { |
klauss | 92:92df17f538a8 | 504 | if( data[ 0 ] & BIT7 ) { |
klauss | 91:c2a86b1f8aaa | 505 | if( type == __BOOT__ ) { |
klauss | 91:c2a86b1f8aaa | 506 | send2callboxes( __build_cb_package__( ext, port, __REGISTRY__, |
klauss | 92:92df17f538a8 | 507 | ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 92:92df17f538a8 | 508 | } else { |
klauss | 81:3656f00ab3db | 509 | if( debug_main ) debug_msg("Received ack pkg with seq_num %d", data[ 0 ] ); |
klauss | 91:c2a86b1f8aaa | 510 | |
klauss | 91:c2a86b1f8aaa | 511 | switch( type ) { |
klauss | 81:3656f00ab3db | 512 | case __INVITE__ : { |
klauss | 81:3656f00ab3db | 513 | if( debug_main || debug_invite ) debug_msg("Invite Ack from %d on msg_id %d", ext, cb->get_msg_id() ); |
klauss | 92:92df17f538a8 | 514 | //cb->first_invite_response_ok(); |
klauss | 91:c2a86b1f8aaa | 515 | break; |
klauss | 81:3656f00ab3db | 516 | } |
klauss | 81:3656f00ab3db | 517 | case __CB_BYE__ : { |
klauss | 81:3656f00ab3db | 518 | if( debug_main || debug_invite ) debug_msg("BYE Ack from %d on msg_id %d", ext, cb->get_msg_id() ); |
klauss | 81:3656f00ab3db | 519 | cb->set_bye_response_ok(); |
klauss | 91:c2a86b1f8aaa | 520 | break; |
klauss | 81:3656f00ab3db | 521 | } |
klauss | 81:3656f00ab3db | 522 | case __REGISTRY__ : { |
klauss | 81:3656f00ab3db | 523 | if( debug_main || debug_aging ) debug_msg("Registry ACK from %d in pkg :: %d", ext, cb->get_msg_id() ); |
klauss | 81:3656f00ab3db | 524 | break; |
klauss | 81:3656f00ab3db | 525 | } |
klauss | 81:3656f00ab3db | 526 | default : { |
klauss | 91:c2a86b1f8aaa | 527 | if( debug_main || debug_aging ) debug_msg("ACK from %d in pkg :: %d :: type %d", ext, cb->get_msg_id(), type ); |
klauss | 91:c2a86b1f8aaa | 528 | } |
klauss | 81:3656f00ab3db | 529 | } |
klauss | 92:92df17f538a8 | 530 | if( type != __REGISTRY__ && type != __CB_BYE__ ) type = __DO_NOTHING__; |
klauss | 92:92df17f538a8 | 531 | if( type == __CB_BYE__ ){ |
klauss | 92:92df17f538a8 | 532 | VZ_call * call = __find_Call__( v_call, ext ); |
klauss | 92:92df17f538a8 | 533 | if( call != NULL ){ |
klauss | 92:92df17f538a8 | 534 | if( call->get_elapsed_time() < 120000 ){ |
klauss | 92:92df17f538a8 | 535 | if( debug_invite ) debug_msg("%d ack bye ignored", ext ); |
klauss | 92:92df17f538a8 | 536 | type = __DO_NOTHING__; |
klauss | 92:92df17f538a8 | 537 | } |
klauss | 92:92df17f538a8 | 538 | } |
klauss | 92:92df17f538a8 | 539 | } |
klauss | 0:4d17cd9c8f9d | 540 | } |
klauss | 0:4d17cd9c8f9d | 541 | } |
klauss | 0:4d17cd9c8f9d | 542 | } |
klauss | 0:4d17cd9c8f9d | 543 | } |
klauss | 91:c2a86b1f8aaa | 544 | } else type = __DO_NOTHING__; |
klauss | 0:4d17cd9c8f9d | 545 | } |
klauss | 91:c2a86b1f8aaa | 546 | |
klauss | 91:c2a86b1f8aaa | 547 | if( main_test == true ) { |
klauss | 87:679ee0d594a9 | 548 | main_test = false; |
klauss | 85:b6f2dc1d0f4f | 549 | send_msg("CB_New (%u) -- CB_Delete (%u)", cb_new_counter, cb_delete_counter ); |
klauss | 85:b6f2dc1d0f4f | 550 | send_msg("SIP_New (%u) -- SIP_Delete (%u)", sip_new_counter, sip_delete_counter ); |
klauss | 87:679ee0d594a9 | 551 | send_msg("RTP_header_New (%u) -- RTP_header_Delete (%u)", rtp_header_new_counter, rtp_header_delete_counter ); |
klauss | 87:679ee0d594a9 | 552 | send_msg("RTP_body_New (%u) -- RTP_body_Delete (%u)", rtp_body_new_counter, rtp_body_delete_counter ); |
klauss | 91:c2a86b1f8aaa | 553 | send_msg("Call_New (%u) -- Call_Delete (%u)", call_new_counter, call_delete_counter ); |
klauss | 87:679ee0d594a9 | 554 | send_msg("lpc_low_level_input_counter :: %d", lpc_low_level_input_counter ); |
klauss | 87:679ee0d594a9 | 555 | send_msg("Memory is %s", ( memory_is_over ) ? "Over" : "Ok" ); |
klauss | 81:3656f00ab3db | 556 | send_msg("Missed_Pkg :: %d ::", missed_pkg ); |
klauss | 87:679ee0d594a9 | 557 | send_msg("Sizeof Sip :: %u", sizeof( Sip ) ); |
klauss | 87:679ee0d594a9 | 558 | send_msg("Sizeof Call_Box :: %u", sizeof( Call_Box ) ); |
klauss | 87:679ee0d594a9 | 559 | send_msg("Sizeof VZ_call :: %u", sizeof( VZ_call ) ); |
klauss | 87:679ee0d594a9 | 560 | send_msg("Sizeof RTP :: %u", sizeof( RTP ) ); |
klauss | 87:679ee0d594a9 | 561 | send_msg("Sizeof RTP_Header :: %u", sizeof( RTP_Header ) ); |
klauss | 87:679ee0d594a9 | 562 | send_msg("Sizeof RTP_Body :: %u", sizeof( RTP_Body ) ); |
klauss | 87:679ee0d594a9 | 563 | send_msg("Sizeof Vector :: %u", sizeof( Vector ) ); |
klauss | 87:679ee0d594a9 | 564 | send_msg("Sizeof Timeslice :: %u", sizeof( Timeslice ) ); |
klauss | 87:679ee0d594a9 | 565 | send_msg("Sizeof Watchdog :: %u", sizeof( Watchdog ) ); |
klauss | 81:3656f00ab3db | 566 | } |
klauss | 91:c2a86b1f8aaa | 567 | |
klauss | 92:92df17f538a8 | 568 | //static int wdt_count = 0; |
klauss | 92:92df17f538a8 | 569 | /* |
klauss | 91:c2a86b1f8aaa | 570 | if( registry_test == true ) { |
klauss | 91:c2a86b1f8aaa | 571 | registry_test = false; |
klauss | 91:c2a86b1f8aaa | 572 | |
klauss | 91:c2a86b1f8aaa | 573 | if( wdt_count++ > 5 || v_cb->size() < 66 ) { |
klauss | 89:0fe315117b00 | 574 | wdt_count = 0; |
klauss | 91:c2a86b1f8aaa | 575 | |
klauss | 91:c2a86b1f8aaa | 576 | if( type == __DO_NOTHING__ ) { |
klauss | 91:c2a86b1f8aaa | 577 | if( next_value < ( 5002 + __MAX_CB_IN_A_BRANCH__ - 2 ) ) { |
klauss | 91:c2a86b1f8aaa | 578 | //type = __REGISTRY__; |
klauss | 89:0fe315117b00 | 579 | data = buffer; |
klauss | 89:0fe315117b00 | 580 | ext = next_value; |
klauss | 89:0fe315117b00 | 581 | port = next_value++; |
klauss | 91:c2a86b1f8aaa | 582 | } else { |
klauss | 91:c2a86b1f8aaa | 583 | if( nex_test_registry > ( 5002 + __MAX_CB_IN_A_BRANCH__ - 1 - 2 ) ) nex_test_registry = 5002; |
klauss | 91:c2a86b1f8aaa | 584 | //type = __REGISTRY__; |
klauss | 89:0fe315117b00 | 585 | data = buffer; |
klauss | 89:0fe315117b00 | 586 | ext = nex_test_registry; |
klauss | 89:0fe315117b00 | 587 | port = nex_test_registry++; |
klauss | 89:0fe315117b00 | 588 | } |
klauss | 86:bf7b0d4c3232 | 589 | } |
klauss | 86:bf7b0d4c3232 | 590 | } |
klauss | 86:bf7b0d4c3232 | 591 | } |
klauss | 92:92df17f538a8 | 592 | */ |
klauss | 92:92df17f538a8 | 593 | |
klauss | 91:c2a86b1f8aaa | 594 | { |
klauss | 91:c2a86b1f8aaa | 595 | fd_set fdSet; |
klauss | 91:c2a86b1f8aaa | 596 | FD_ZERO(&fdSet); |
klauss | 91:c2a86b1f8aaa | 597 | |
klauss | 91:c2a86b1f8aaa | 598 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 91:c2a86b1f8aaa | 599 | Call_Box * cb = (Call_Box *)v_cb->get_element( i ); |
klauss | 91:c2a86b1f8aaa | 600 | FD_SET( cb->get_sip_socket_fd(), &fdSet); |
klauss | 91:c2a86b1f8aaa | 601 | } |
klauss | 91:c2a86b1f8aaa | 602 | |
klauss | 91:c2a86b1f8aaa | 603 | FD_SET( udp_wdt_client.get_fd(), &fdSet); |
klauss | 91:c2a86b1f8aaa | 604 | |
klauss | 91:c2a86b1f8aaa | 605 | struct timeval t; |
klauss | 91:c2a86b1f8aaa | 606 | t.tv_sec = 0; |
klauss | 91:c2a86b1f8aaa | 607 | t.tv_usec = 0; |
klauss | 91:c2a86b1f8aaa | 608 | int ret = lwip_select( FD_SETSIZE, &fdSet, NULL, NULL, &t ); |
klauss | 91:c2a86b1f8aaa | 609 | |
klauss | 101:162c28286c29 | 610 | if( ret > 0 ) { |
klauss | 91:c2a86b1f8aaa | 611 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 91:c2a86b1f8aaa | 612 | Call_Box * cb = (Call_Box *)v_cb->get_element( i ); |
klauss | 91:c2a86b1f8aaa | 613 | int fd = cb->get_sip_socket_fd(); |
klauss | 91:c2a86b1f8aaa | 614 | if( FD_ISSET( fd, &fdSet ) ) { |
klauss | 91:c2a86b1f8aaa | 615 | int rcv = cb->sip_udp_incomming_pkg(); |
klauss | 91:c2a86b1f8aaa | 616 | } |
klauss | 91:c2a86b1f8aaa | 617 | } |
klauss | 91:c2a86b1f8aaa | 618 | if( FD_ISSET( udp_wdt_client.get_fd(), &fdSet ) ) { |
klauss | 91:c2a86b1f8aaa | 619 | char wake_msg[ 768 ]; |
klauss | 91:c2a86b1f8aaa | 620 | Endpoint udp_wdt_server; |
klauss | 91:c2a86b1f8aaa | 621 | |
klauss | 91:c2a86b1f8aaa | 622 | if( udp_wdt_client.receiveFrom( udp_wdt_server, wake_msg, sizeof( wake_msg ) ) > 0 ){ |
klauss | 91:c2a86b1f8aaa | 623 | if( !( strncmp( wake_msg, "alive", 5 ) ) ) { |
klauss | 91:c2a86b1f8aaa | 624 | // Just ckeck but not set 'alive?' |
klauss | 91:c2a86b1f8aaa | 625 | // 'alive*' - force wdt tick right now |
klauss | 91:c2a86b1f8aaa | 626 | // Ckecking and set 'alive' |
klauss | 91:c2a86b1f8aaa | 627 | bool question_alive = ( wake_msg[ 5 ] == '?' ); |
klauss | 91:c2a86b1f8aaa | 628 | if( wake_msg[ 5 ] == '*' ) wdt.kick(); |
klauss | 99:e80850c51106 | 629 | |
klauss | 99:e80850c51106 | 630 | snprintf( wake_msg, 48,"wdt:%u,%u,%u,%c,%u,%u,%u,%u,%u:", |
klauss | 99:e80850c51106 | 631 | uptime, |
klauss | 99:e80850c51106 | 632 | invite_counter, |
klauss | 99:e80850c51106 | 633 | external_wdt, |
klauss | 99:e80850c51106 | 634 | ( wdt.WatchdogCausedReset() ) ? '1' : '0', |
klauss | 99:e80850c51106 | 635 | cb_new_counter, |
klauss | 99:e80850c51106 | 636 | v_cb->size(), |
klauss | 99:e80850c51106 | 637 | ts->remain_timeslices(), |
klauss | 99:e80850c51106 | 638 | sip_socket_send_failure, |
klauss | 99:e80850c51106 | 639 | v_call->size() |
klauss | 99:e80850c51106 | 640 | ); |
klauss | 92:92df17f538a8 | 641 | wake_msg[ 768 - 1 ] = 0; |
klauss | 91:c2a86b1f8aaa | 642 | udp_wdt_client.sendTo( udp_wdt_server, wake_msg, strlen( wake_msg ) ); |
klauss | 91:c2a86b1f8aaa | 643 | |
klauss | 91:c2a86b1f8aaa | 644 | if( ( (!question_alive) && ( cb_new_counter <= __MAX_CB_IN_A_BRANCH__ ) && ( cb_new_counter >= 2 ) ) ) { |
klauss | 91:c2a86b1f8aaa | 645 | external_wdt = EXTERN_WDT_IDLE; |
klauss | 91:c2a86b1f8aaa | 646 | } |
klauss | 91:c2a86b1f8aaa | 647 | } else if( !( strncmp( wake_msg, "reset", 5 ) ) ) { |
klauss | 91:c2a86b1f8aaa | 648 | external_wdt = 0; |
klauss | 91:c2a86b1f8aaa | 649 | |
klauss | 91:c2a86b1f8aaa | 650 | sprintf( wake_msg, "rst:%u:", uptime ); |
klauss | 91:c2a86b1f8aaa | 651 | udp_wdt_client.sendTo( udp_wdt_server, wake_msg, strlen( wake_msg ) ); |
klauss | 91:c2a86b1f8aaa | 652 | } |
klauss | 91:c2a86b1f8aaa | 653 | } |
klauss | 91:c2a86b1f8aaa | 654 | } |
klauss | 91:c2a86b1f8aaa | 655 | } |
klauss | 91:c2a86b1f8aaa | 656 | } |
klauss | 91:c2a86b1f8aaa | 657 | |
klauss | 91:c2a86b1f8aaa | 658 | if( reset_cks == true ) { |
klauss | 81:3656f00ab3db | 659 | pkg_cksok = 0; |
klauss | 81:3656f00ab3db | 660 | pkg_ckserr = 0; |
klauss | 99:e80850c51106 | 661 | pkg_zero = 0; |
klauss | 81:3656f00ab3db | 662 | reset_cks = false; |
klauss | 99:e80850c51106 | 663 | out_of_range = 0; |
klauss | 99:e80850c51106 | 664 | missed_pkg = 0; |
klauss | 100:09a23fcd3bdf | 665 | delayed_pkg_to_cb = 0; |
klauss | 99:e80850c51106 | 666 | cpld_pkg_tx_counter = 0; |
klauss | 99:e80850c51106 | 667 | cpld_pkg_rx_counter = 0; |
klauss | 81:3656f00ab3db | 668 | pcks_s = true; |
klauss | 81:3656f00ab3db | 669 | } |
klauss | 91:c2a86b1f8aaa | 670 | |
klauss | 91:c2a86b1f8aaa | 671 | if( pcks_s == true ) { |
klauss | 99:e80850c51106 | 672 | send_msg("PKG_CKS OK: %d :: PKG_CKS ERR: %d :: PKG_0: %d :: Out_of_range: %d :: Miss_Pkg :: %d" |
klauss | 100:09a23fcd3bdf | 673 | "\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 | 674 | pcks_s = false; |
klauss | 81:3656f00ab3db | 675 | } |
klauss | 91:c2a86b1f8aaa | 676 | |
klauss | 100:09a23fcd3bdf | 677 | if( flood_bug_pkg ){ |
klauss | 100:09a23fcd3bdf | 678 | static int id = 0x10; |
klauss | 100:09a23fcd3bdf | 679 | if( id < 10 ) id = 0x0b; |
klauss | 100:09a23fcd3bdf | 680 | send2callboxes( __build_cb_package__( 5828, 5123, __REGISTRY__, |
klauss | 100:09a23fcd3bdf | 681 | ( char * )buffer, id++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 100:09a23fcd3bdf | 682 | } |
klauss | 100:09a23fcd3bdf | 683 | |
klauss | 91:c2a86b1f8aaa | 684 | if( led_sync_timer.read() > 1 ) { |
klauss | 78:1353744f01e1 | 685 | led_sync_timer.reset(); |
klauss | 78:1353744f01e1 | 686 | led3 = !led3; |
klauss | 78:1353744f01e1 | 687 | CAB_LED = !CAB_LED; |
klauss | 78:1353744f01e1 | 688 | } |
klauss | 91:c2a86b1f8aaa | 689 | |
klauss | 91:c2a86b1f8aaa | 690 | switch( type ) { |
klauss | 91:c2a86b1f8aaa | 691 | case __DO_NOTHING__ : |
klauss | 91:c2a86b1f8aaa | 692 | {} |
klauss | 91:c2a86b1f8aaa | 693 | break; |
klauss | 91:c2a86b1f8aaa | 694 | |
klauss | 0:4d17cd9c8f9d | 695 | case __CB_BYE__ : { |
klauss | 63:0d95da692bb4 | 696 | cb_bye_counter++; |
klauss | 0:4d17cd9c8f9d | 697 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 91:c2a86b1f8aaa | 698 | if( cb != NULL ) { |
klauss | 81:3656f00ab3db | 699 | 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 | 700 | data[ 0 ] |= BIT7; |
klauss | 0:4d17cd9c8f9d | 701 | cb->set_msg_id( data[ 0 ] ); |
klauss | 81:3656f00ab3db | 702 | if( debug_main || debug_invite ) debug_msg( "Request bye from CBx " ); |
klauss | 92:92df17f538a8 | 703 | |
klauss | 81:3656f00ab3db | 704 | bool already_removed = true; |
klauss | 91:c2a86b1f8aaa | 705 | for( register uint8_t i = 0; i < v_call->size(); i++ ) { |
klauss | 0:4d17cd9c8f9d | 706 | VZ_call * call = (VZ_call *)v_call->get_element( i ); |
klauss | 91:c2a86b1f8aaa | 707 | if( call->get_cb_ext() == ext ) { |
klauss | 81:3656f00ab3db | 708 | already_removed = false; |
klauss | 4:de46f0d9b14d | 709 | cb->send_bye(); |
klauss | 91:c2a86b1f8aaa | 710 | |
klauss | 0:4d17cd9c8f9d | 711 | ts->return_timeslice( cb->get_timeslice() ); |
klauss | 0:4d17cd9c8f9d | 712 | cb->set_timeslice( 0x00 ); |
klauss | 78:1353744f01e1 | 713 | data[ __TIMESLICE_PLACE__ ] = 0x00; |
klauss | 91:c2a86b1f8aaa | 714 | |
klauss | 0:4d17cd9c8f9d | 715 | set_status( cb->status, cb_idle ); |
klauss | 78:1353744f01e1 | 716 | set_status( cb->sip->status, sip_idle ); |
klauss | 91:c2a86b1f8aaa | 717 | |
klauss | 81:3656f00ab3db | 718 | v_call->remove_element( i ); |
klauss | 91:c2a86b1f8aaa | 719 | |
klauss | 74:81c47fff88a5 | 720 | send2callboxes( __build_cb_package__( ext, port, __CB_BYE__, |
klauss | 0:4d17cd9c8f9d | 721 | ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 92:92df17f538a8 | 722 | |
klauss | 92:92df17f538a8 | 723 | // envia o ack bye depois atualiza o msg_id |
klauss | 92:92df17f538a8 | 724 | cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); |
klauss | 91:c2a86b1f8aaa | 725 | |
klauss | 3:cd9148672e25 | 726 | delete( call ); |
klauss | 0:4d17cd9c8f9d | 727 | } |
klauss | 0:4d17cd9c8f9d | 728 | } |
klauss | 82:f55d13babca0 | 729 | if( already_removed ) if( debug_main || debug_invite ) debug_msg( "Already removed from vector call" ); |
klauss | 91:c2a86b1f8aaa | 730 | |
klauss | 82:f55d13babca0 | 731 | //ok, mas nem sempre o cbx "entrou em call |
klauss | 82:f55d13babca0 | 732 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 82:f55d13babca0 | 733 | Call_Box * cb = (Call_Box *)v_cb->get_element( i ); |
klauss | 82:f55d13babca0 | 734 | if( cb->get_ext() == ext ) { |
klauss | 82:f55d13babca0 | 735 | already_removed = true; |
klauss | 82:f55d13babca0 | 736 | if( cb->get_status() != cb_idle ) { |
klauss | 82:f55d13babca0 | 737 | already_removed = false; |
klauss | 82:f55d13babca0 | 738 | cb->send_bye(); |
klauss | 82:f55d13babca0 | 739 | |
klauss | 82:f55d13babca0 | 740 | ts->return_timeslice( cb->get_timeslice() ); |
klauss | 82:f55d13babca0 | 741 | cb->set_timeslice( 0x00 ); |
klauss | 82:f55d13babca0 | 742 | data[ __TIMESLICE_PLACE__ ] = 0x00; |
klauss | 82:f55d13babca0 | 743 | |
klauss | 82:f55d13babca0 | 744 | set_status( cb->status, cb_idle ); |
klauss | 82:f55d13babca0 | 745 | set_status( cb->sip->status, sip_idle ); |
klauss | 82:f55d13babca0 | 746 | |
klauss | 82:f55d13babca0 | 747 | send2callboxes( __build_cb_package__( ext, port, __CB_BYE__, |
klauss | 92:92df17f538a8 | 748 | ( char * )data, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 82:f55d13babca0 | 749 | |
klauss | 92:92df17f538a8 | 750 | cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); |
klauss | 82:f55d13babca0 | 751 | } |
klauss | 82:f55d13babca0 | 752 | } |
klauss | 82:f55d13babca0 | 753 | } |
klauss | 91:c2a86b1f8aaa | 754 | |
klauss | 82:f55d13babca0 | 755 | if( already_removed ) if( debug_main || debug_invite ) debug_msg( "Already removed from inviting queue" ); |
klauss | 91:c2a86b1f8aaa | 756 | |
klauss | 78:1353744f01e1 | 757 | cb->registry(); |
klauss | 91:c2a86b1f8aaa | 758 | } else if( debug_invite || debug_main ) debug_msg("Bye from who ? %d", ext ); |
klauss | 91:c2a86b1f8aaa | 759 | } |
klauss | 91:c2a86b1f8aaa | 760 | break; |
klauss | 91:c2a86b1f8aaa | 761 | |
klauss | 0:4d17cd9c8f9d | 762 | case __INVITE__ : { |
klauss | 63:0d95da692bb4 | 763 | invite_counter++; |
klauss | 78:1353744f01e1 | 764 | if( debug_invite ) debug_msg("Request Invite received from Cbx %i", ext); |
klauss | 0:4d17cd9c8f9d | 765 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 91:c2a86b1f8aaa | 766 | if( cb == NULL ) { |
klauss | 91:c2a86b1f8aaa | 767 | if( v_cb->size() < __MAX_CB_IN_A_BRANCH__ ) { |
klauss | 91:c2a86b1f8aaa | 768 | if( debug_main ) debug_msg( "Adding CBx :: %i", ext ); |
klauss | 91:c2a86b1f8aaa | 769 | cb = new Call_Box( ext, port ); |
klauss | 91:c2a86b1f8aaa | 770 | |
klauss | 91:c2a86b1f8aaa | 771 | if( cb == NULL ) { |
klauss | 91:c2a86b1f8aaa | 772 | memory_is_over = true; |
klauss | 91:c2a86b1f8aaa | 773 | if( debug_memory ) debug_msg("Invite allocation cb fail"); |
klauss | 91:c2a86b1f8aaa | 774 | } else { |
klauss | 91:c2a86b1f8aaa | 775 | v_cb->add( cb ); |
klauss | 91:c2a86b1f8aaa | 776 | } |
klauss | 89:0fe315117b00 | 777 | } |
klauss | 0:4d17cd9c8f9d | 778 | } |
klauss | 91:c2a86b1f8aaa | 779 | if( cb != NULL ) { |
klauss | 91:c2a86b1f8aaa | 780 | cb->set_msg_id( data[ 0 ] ); |
klauss | 92:92df17f538a8 | 781 | if( cb->status == cb_idle ){ |
klauss | 92:92df17f538a8 | 782 | cb->set_invite_response_ok(); |
klauss | 92:92df17f538a8 | 783 | cb->invite_retry_count_reset(); |
klauss | 92:92df17f538a8 | 784 | } |
klauss | 87:679ee0d594a9 | 785 | invite_handler( v_call, v_cb, ts, cb ); |
klauss | 87:679ee0d594a9 | 786 | } |
klauss | 91:c2a86b1f8aaa | 787 | } |
klauss | 91:c2a86b1f8aaa | 788 | break; |
klauss | 4:de46f0d9b14d | 789 | case __REGISTRY__ : { |
klauss | 63:0d95da692bb4 | 790 | registry_counter++; |
klauss | 78:1353744f01e1 | 791 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 91:c2a86b1f8aaa | 792 | if( v_cb->size() < __MAX_CB_IN_A_BRANCH__ ) { |
klauss | 91:c2a86b1f8aaa | 793 | if( cb == NULL ) { |
klauss | 91:c2a86b1f8aaa | 794 | if( debug_main ) debug_msg("Adding Cbx :: %d", ext ); |
klauss | 91:c2a86b1f8aaa | 795 | cb = new Call_Box( ext, port ); |
klauss | 91:c2a86b1f8aaa | 796 | |
klauss | 91:c2a86b1f8aaa | 797 | if( cb == NULL ) { |
klauss | 91:c2a86b1f8aaa | 798 | memory_is_over = true; |
klauss | 91:c2a86b1f8aaa | 799 | if( debug_memory ) debug_msg("Registry cb allocation fail"); |
klauss | 91:c2a86b1f8aaa | 800 | } else { |
klauss | 91:c2a86b1f8aaa | 801 | v_cb->add( cb ); |
klauss | 91:c2a86b1f8aaa | 802 | if( debug_main ) debug_msg("Added CBx -- %d", ext ); |
klauss | 91:c2a86b1f8aaa | 803 | } |
klauss | 87:679ee0d594a9 | 804 | } |
klauss | 0:4d17cd9c8f9d | 805 | } |
klauss | 78:1353744f01e1 | 806 | if( debug_main ) debug_msg("Registered %d - %d", ext, port ); |
klauss | 91:c2a86b1f8aaa | 807 | |
klauss | 87:679ee0d594a9 | 808 | if( cb != NULL ) cb->registry(); |
klauss | 91:c2a86b1f8aaa | 809 | |
klauss | 91:c2a86b1f8aaa | 810 | } |
klauss | 91:c2a86b1f8aaa | 811 | break; |
klauss | 4:de46f0d9b14d | 812 | case __BOOT__ : { |
klauss | 63:0d95da692bb4 | 813 | boot_counter++; |
klauss | 99:e80850c51106 | 814 | if( debug_boot == true ){ |
klauss | 99:e80850c51106 | 815 | send_msg("Rcv boot pkg from (%d, %d) pkg-id %d", ext, port, data[ 0 ] ); |
klauss | 99:e80850c51106 | 816 | } |
klauss | 91:c2a86b1f8aaa | 817 | send2callboxes( __build_cb_package__( ext, port, __REGISTRY__, |
klauss | 92:92df17f538a8 | 818 | ( char * )data, data[ 0 ] | BIT7, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 91:c2a86b1f8aaa | 819 | } |
klauss | 91:c2a86b1f8aaa | 820 | break; |
klauss | 99:e80850c51106 | 821 | |
klauss | 4:de46f0d9b14d | 822 | case __TELEMETRY__ : { |
klauss | 78:1353744f01e1 | 823 | if( debug_telemetry ) send_msg("::Telemetry from %d - %d::", ext, port ); |
klauss | 91:c2a86b1f8aaa | 824 | build_telemetry_report( ext, port, ( char *)data ); |
klauss | 91:c2a86b1f8aaa | 825 | } |
klauss | 91:c2a86b1f8aaa | 826 | break; |
klauss | 99:e80850c51106 | 827 | |
klauss | 99:e80850c51106 | 828 | case __FW__ : { |
klauss | 99:e80850c51106 | 829 | if( debug_fw_print ) send_msg("::FW pkg from %d - %d::", ext, port ); |
klauss | 99:e80850c51106 | 830 | fw_cbx_pkg( ext, port, ( char *)buffer ); |
klauss | 99:e80850c51106 | 831 | } |
klauss | 99:e80850c51106 | 832 | break; |
klauss | 91:c2a86b1f8aaa | 833 | |
klauss | 67:cdedc64d9921 | 834 | case __BOOTLOADER_CBX__ : { |
klauss | 67:cdedc64d9921 | 835 | bootloader_cbx_counter++; |
klauss | 91:c2a86b1f8aaa | 836 | } |
klauss | 91:c2a86b1f8aaa | 837 | break; |
klauss | 91:c2a86b1f8aaa | 838 | |
klauss | 36:728498a78e1e | 839 | case __PROMPT__ : { |
klauss | 78:1353744f01e1 | 840 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 91:c2a86b1f8aaa | 841 | |
klauss | 91:c2a86b1f8aaa | 842 | if( cb == NULL ) { |
klauss | 78:1353744f01e1 | 843 | if( debug_main ) debug_msg("Adding Cbx :: %d", ext ); |
klauss | 78:1353744f01e1 | 844 | cb = new Call_Box( ext, port ); |
klauss | 87:679ee0d594a9 | 845 | if( cb == NULL ){ |
klauss | 87:679ee0d594a9 | 846 | memory_is_over = true; |
klauss | 87:679ee0d594a9 | 847 | }else{ |
klauss | 87:679ee0d594a9 | 848 | v_cb->add( cb ); |
klauss | 87:679ee0d594a9 | 849 | if( debug_main ) debug_msg("Added CBx -- %d", ext ); |
klauss | 87:679ee0d594a9 | 850 | } |
klauss | 48:195c97f12e8e | 851 | } |
klauss | 91:c2a86b1f8aaa | 852 | |
klauss | 92:92df17f538a8 | 853 | if( cb!= NULL ) cb->registry(); |
klauss | 91:c2a86b1f8aaa | 854 | |
klauss | 91:c2a86b1f8aaa | 855 | if( xstrmatch( ( uint8_t * )data, ( uint8_t * )"ping" ) ) { |
klauss | 78:1353744f01e1 | 856 | if( debug_ping ) send_msg( "Prompt pkg from ( %i, %i ) :: Ping", ext, port ); |
klauss | 91:c2a86b1f8aaa | 857 | } else { |
klauss | 78:1353744f01e1 | 858 | prompt_counter++; |
klauss | 78:1353744f01e1 | 859 | //fixme isso nao poderia ser resolvido com um sendmsg ? |
klauss | 78:1353744f01e1 | 860 | send_msg( "Prompt pkg from ( %i, %i ) ::", ext, port ); |
klauss | 91:c2a86b1f8aaa | 861 | for( register uint8_t i = 0; i < 32; i++ ) { |
klauss | 100:09a23fcd3bdf | 862 | if( debug_uart3 ) pc.printf("%c", data[ i ] ); |
klauss | 100:09a23fcd3bdf | 863 | if( i == 15 ) if( debug_uart3 ) pc.printf( "\r\n" ); |
klauss | 78:1353744f01e1 | 864 | } |
klauss | 100:09a23fcd3bdf | 865 | if( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 91:c2a86b1f8aaa | 866 | |
klauss | 91:c2a86b1f8aaa | 867 | if( tcp_session ) { |
klauss | 78:1353744f01e1 | 868 | char aux[ __CB_BUFFER_SIZE__ + 3 ]; |
klauss | 78:1353744f01e1 | 869 | strncpy( aux, (char * )data, __CB_BUFFER_SIZE__ ); |
klauss | 78:1353744f01e1 | 870 | strcat( aux, "\n\r\0" ); |
klauss | 78:1353744f01e1 | 871 | tcp_client.send_all( ( char *)data, strlen( (char * )data ) ); |
klauss | 78:1353744f01e1 | 872 | tcp_client.send_all( "\r\n> ", strlen( "\r\n> " ) ); |
klauss | 78:1353744f01e1 | 873 | } |
klauss | 48:195c97f12e8e | 874 | } |
klauss | 91:c2a86b1f8aaa | 875 | } |
klauss | 91:c2a86b1f8aaa | 876 | break; |
klauss | 0:4d17cd9c8f9d | 877 | case __AUDIO__ : { |
klauss | 63:0d95da692bb4 | 878 | audio_counter++; |
klauss | 78:1353744f01e1 | 879 | VZ_call * call = __find_Call__( v_call, ext ); |
klauss | 91:c2a86b1f8aaa | 880 | if( call != NULL ) { |
klauss | 91:c2a86b1f8aaa | 881 | char * pkg = call->build_eth_package( data + 2 ); |
klauss | 0:4d17cd9c8f9d | 882 | call->send_message( pkg ); |
klauss | 92:92df17f538a8 | 883 | call->cbx_pkg_idle_timer_reset(); |
klauss | 78:1353744f01e1 | 884 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 92:92df17f538a8 | 885 | if( cb != NULL ){ |
klauss | 99:e80850c51106 | 886 | //cb->reset_elapsed_time(); |
klauss | 92:92df17f538a8 | 887 | cb->set_invite_response_ok(); |
klauss | 92:92df17f538a8 | 888 | cb->invite_retry_count_reset(); |
klauss | 92:92df17f538a8 | 889 | } |
klauss | 91:c2a86b1f8aaa | 890 | } else { |
klauss | 78:1353744f01e1 | 891 | if( debug_main ) debug_msg("received missed package from CBx :: %i", ext ); |
klauss | 0:4d17cd9c8f9d | 892 | } |
klauss | 91:c2a86b1f8aaa | 893 | } |
klauss | 91:c2a86b1f8aaa | 894 | break; |
klauss | 9:ffa64f38ef9c | 895 | }// fim switch |
klauss | 92:92df17f538a8 | 896 | |
klauss | 99:e80850c51106 | 897 | { // rajada |
klauss | 99:e80850c51106 | 898 | //if( invite_retry_time == true ){ |
klauss | 99:e80850c51106 | 899 | // invite_retry_time = false; |
klauss | 99:e80850c51106 | 900 | if( invite_retry_timer.read_ms() > 30 ) { |
klauss | 99:e80850c51106 | 901 | invite_retry_timer.reset(); |
klauss | 92:92df17f538a8 | 902 | static int retry_invite_pkg = 0; |
klauss | 99:e80850c51106 | 903 | |
klauss | 92:92df17f538a8 | 904 | if( retry_invite_pkg >= v_cb->size() ) retry_invite_pkg = 0; |
klauss | 99:e80850c51106 | 905 | |
klauss | 99:e80850c51106 | 906 | register int i = 0; |
klauss | 99:e80850c51106 | 907 | for( ; i < v_cb->size(); i++ ) { |
klauss | 99:e80850c51106 | 908 | Call_Box * cb = (Call_Box * )v_cb->get_element( i ); |
klauss | 99:e80850c51106 | 909 | if( ( cb->status == cb_ringing ) || ( cb->status == cb_trying ) || ( cb->status == cb_on_call ) ) { |
klauss | 99:e80850c51106 | 910 | if( i > retry_invite_pkg ) { |
klauss | 99:e80850c51106 | 911 | retry_invite_pkg = i; |
klauss | 99:e80850c51106 | 912 | break; |
klauss | 99:e80850c51106 | 913 | } |
klauss | 92:92df17f538a8 | 914 | } |
klauss | 99:e80850c51106 | 915 | } |
klauss | 99:e80850c51106 | 916 | |
klauss | 99:e80850c51106 | 917 | if( i != v_cb->size() ){ |
klauss | 99:e80850c51106 | 918 | Call_Box * cb = (Call_Box *)v_cb->get_element( retry_invite_pkg++ ); |
klauss | 99:e80850c51106 | 919 | |
klauss | 99:e80850c51106 | 920 | if( ( cb->status == cb_ringing ) || ( cb->status == cb_trying ) || ( cb->status == cb_on_call ) ) { |
klauss | 99:e80850c51106 | 921 | if( cb->get_invite_response() == false ) { |
klauss | 99:e80850c51106 | 922 | //cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); |
klauss | 99:e80850c51106 | 923 | cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); |
klauss | 99:e80850c51106 | 924 | |
klauss | 99:e80850c51106 | 925 | buffer[ __TIMESLICE_PLACE__ ] = cb->get_timeslice(); |
klauss | 99:e80850c51106 | 926 | |
klauss | 99:e80850c51106 | 927 | send2callboxes( __build_cb_package__( cb->get_ext(), cb->get_port(), __INVITE__, ( char * )buffer, |
klauss | 99:e80850c51106 | 928 | cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 99:e80850c51106 | 929 | if( debug_invite ) debug_msg("resend invite OK to Cbx : ( %d, %d )", cb->get_ext(), cb->get_port() ); |
klauss | 99:e80850c51106 | 930 | } |
klauss | 99:e80850c51106 | 931 | if( cb->get_invite_retry_count() == 0 ) { |
klauss | 99:e80850c51106 | 932 | cb->send_bye(); |
klauss | 92:92df17f538a8 | 933 | |
klauss | 99:e80850c51106 | 934 | ts->return_timeslice( cb->get_timeslice() ); |
klauss | 99:e80850c51106 | 935 | cb->set_timeslice( 0x00 ); |
klauss | 99:e80850c51106 | 936 | |
klauss | 99:e80850c51106 | 937 | //cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); |
klauss | 99:e80850c51106 | 938 | cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); |
klauss | 99:e80850c51106 | 939 | |
klauss | 99:e80850c51106 | 940 | for( register uint8_t i = 0; i < v_call->size(); i++ ) { |
klauss | 99:e80850c51106 | 941 | VZ_call * call = ( VZ_call * )v_call->get_element( i ); |
klauss | 99:e80850c51106 | 942 | if( call->get_cb_ext() == cb->get_ext() ) { |
klauss | 99:e80850c51106 | 943 | v_call->remove_element( i ); |
klauss | 99:e80850c51106 | 944 | if( call != NULL ) delete( call ); |
klauss | 99:e80850c51106 | 945 | break; |
klauss | 99:e80850c51106 | 946 | } |
klauss | 92:92df17f538a8 | 947 | } |
klauss | 99:e80850c51106 | 948 | |
klauss | 99:e80850c51106 | 949 | if( debug_invite ) debug_msg( "-- No audio pkgs --" ); |
klauss | 99:e80850c51106 | 950 | set_status( cb->status, cb_idle ); |
klauss | 99:e80850c51106 | 951 | set_status( cb->sip->status, sip_idle ); |
klauss | 92:92df17f538a8 | 952 | } |
klauss | 92:92df17f538a8 | 953 | } |
klauss | 92:92df17f538a8 | 954 | } |
klauss | 92:92df17f538a8 | 955 | } |
klauss | 92:92df17f538a8 | 956 | } |
klauss | 91:c2a86b1f8aaa | 957 | |
klauss | 91:c2a86b1f8aaa | 958 | for( register uint8_t i = 0; i < v_call->size(); i++ ) { |
klauss | 0:4d17cd9c8f9d | 959 | VZ_call * call = ( VZ_call * )v_call->get_element( i ); |
klauss | 0:4d17cd9c8f9d | 960 | int length = 0; |
klauss | 0:4d17cd9c8f9d | 961 | char * tmp = call->get_eth_message( &length ); |
klauss | 91:c2a86b1f8aaa | 962 | if( tmp != NULL ) { |
klauss | 0:4d17cd9c8f9d | 963 | int cb_port = 0xffff; |
klauss | 78:1353744f01e1 | 964 | Call_Box * cb = __find_CB__( v_cb, call->get_cb_ext() ); |
klauss | 91:c2a86b1f8aaa | 965 | |
klauss | 91:c2a86b1f8aaa | 966 | if( cb != NULL ) { |
klauss | 4:de46f0d9b14d | 967 | cb_port = cb->get_port(); |
klauss | 91:c2a86b1f8aaa | 968 | |
klauss | 91:c2a86b1f8aaa | 969 | uint8_t * pkg2cb = __build_cb_package__( call->get_cb_ext(), cb_port, __AUDIO__, |
klauss | 100:09a23fcd3bdf | 970 | tmp, __AUDIO__, length, write_buffer ); |
klauss | 99:e80850c51106 | 971 | |
klauss | 100:09a23fcd3bdf | 972 | send2callboxes( pkg2cb ); |
klauss | 99:e80850c51106 | 973 | |
klauss | 91:c2a86b1f8aaa | 974 | } else if( debug_main ) debug_msg("received missed package from CBx :: %i -- Type :: %i", ext, type ); |
klauss | 0:4d17cd9c8f9d | 975 | } |
klauss | 14:22a35f575502 | 976 | } |
klauss | 92:92df17f538a8 | 977 | |
klauss | 81:3656f00ab3db | 978 | //if( v_call->size() == 0 ) refresh( v_cb, buffer, write_buffer, NULL ); |
klauss | 91:c2a86b1f8aaa | 979 | |
klauss | 99:e80850c51106 | 980 | if( timer_sync_refresh.read_ms() > 250 ) { |
klauss | 89:0fe315117b00 | 981 | timer_sync_refresh.reset(); |
klauss | 91:c2a86b1f8aaa | 982 | |
klauss | 89:0fe315117b00 | 983 | static uint8_t mode = TIME_TO_REFRESH; |
klauss | 91:c2a86b1f8aaa | 984 | |
klauss | 91:c2a86b1f8aaa | 985 | if( mode == TIME_TO_REFRESH ) { |
klauss | 89:0fe315117b00 | 986 | mode = TIME_TO_WAKE_UP; |
klauss | 89:0fe315117b00 | 987 | refresh( v_cb, buffer, write_buffer, NULL ); |
klauss | 91:c2a86b1f8aaa | 988 | } else { |
klauss | 89:0fe315117b00 | 989 | mode = TIME_TO_REFRESH; |
klauss | 91:c2a86b1f8aaa | 990 | if( wake_all ) if( v_call->size() == 0 ) wake_all_up( v_cb, buffer, write_buffer ); |
klauss | 89:0fe315117b00 | 991 | } |
klauss | 89:0fe315117b00 | 992 | } |
klauss | 91:c2a86b1f8aaa | 993 | |
klauss | 91:c2a86b1f8aaa | 994 | |
klauss | 89:0fe315117b00 | 995 | //refresh( v_cb, buffer, write_buffer, NULL ); |
klauss | 91:c2a86b1f8aaa | 996 | |
klauss | 78:1353744f01e1 | 997 | //Fixme pensar melhor nessa parte durante ligacoes, pode complicar com muitos cbx ... |
klauss | 81:3656f00ab3db | 998 | //if( v_call->size() == 0 ) registry_aging( v_cb, buffer, write_buffer ); |
klauss | 91:c2a86b1f8aaa | 999 | |
klauss | 78:1353744f01e1 | 1000 | // check sip messages only for cbx in call ? |
klauss | 78:1353744f01e1 | 1001 | int ext_to__be_removed = sip_manager( v_cb ); |
klauss | 91:c2a86b1f8aaa | 1002 | if( ext_to__be_removed > 0x00 ) { |
klauss | 78:1353744f01e1 | 1003 | Call_Box * cb = __find_CB__( v_cb, ext_to__be_removed ); |
klauss | 91:c2a86b1f8aaa | 1004 | if( cb != NULL ) { |
klauss | 91:c2a86b1f8aaa | 1005 | if( cb->status == cb_on_call ) { |
klauss | 4:de46f0d9b14d | 1006 | ts->return_timeslice( cb->get_timeslice() ); |
klauss | 4:de46f0d9b14d | 1007 | cb->set_timeslice( 0x00 ); |
klauss | 4:de46f0d9b14d | 1008 | buffer[ __TIMESLICE_PLACE__ ] = 0x00; |
klauss | 91:c2a86b1f8aaa | 1009 | |
klauss | 78:1353744f01e1 | 1010 | set_status( cb->status, cb_idle ); |
klauss | 78:1353744f01e1 | 1011 | set_status( cb->sip->status, sip_idle ); |
klauss | 91:c2a86b1f8aaa | 1012 | |
klauss | 91:c2a86b1f8aaa | 1013 | for( register uint8_t i = 0; i < v_call->size(); i++ ) { |
klauss | 4:de46f0d9b14d | 1014 | VZ_call * call = ( VZ_call * )v_call->get_element( i ); |
klauss | 91:c2a86b1f8aaa | 1015 | if( call->get_cb_ext() == ext_to__be_removed ) { |
klauss | 4:de46f0d9b14d | 1016 | v_call->remove_element( i ); |
klauss | 4:de46f0d9b14d | 1017 | delete( call ); |
klauss | 4:de46f0d9b14d | 1018 | } |
klauss | 2:93bec7313ccc | 1019 | } |
klauss | 91:c2a86b1f8aaa | 1020 | |
klauss | 92:92df17f538a8 | 1021 | //cb->set_msg_id( ( cb->get_msg_id() & ~BIT7 ) + 1 ); |
klauss | 92:92df17f538a8 | 1022 | cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); |
klauss | 91:c2a86b1f8aaa | 1023 | |
klauss | 82:f55d13babca0 | 1024 | //debug_msg("msg_id -- %d", cb->get_msg_id() ); |
klauss | 91:c2a86b1f8aaa | 1025 | |
klauss | 91:c2a86b1f8aaa | 1026 | send2callboxes( __build_cb_package__( ext, port, __CB_BYE__, |
klauss | 4:de46f0d9b14d | 1027 | ( char * )buffer, cb->get_msg_id(), __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 91:c2a86b1f8aaa | 1028 | |
klauss | 91:c2a86b1f8aaa | 1029 | if( debug_invite ) debug_msg("Received Bye from *"); |
klauss | 99:e80850c51106 | 1030 | //cb->re_start_timer(); |
klauss | 0:4d17cd9c8f9d | 1031 | } |
klauss | 91:c2a86b1f8aaa | 1032 | } else if( debug_main ) debug_msg("Missed bye request from * CBx :: %d", ext ); |
klauss | 0:4d17cd9c8f9d | 1033 | } |
klauss | 91:c2a86b1f8aaa | 1034 | |
klauss | 81:3656f00ab3db | 1035 | /* Verifica andamento de ligações para eventualmente encerra-las por timeout */ |
klauss | 10:22da1a0ac1e1 | 1036 | call_manager( v_call, v_cb, buffer, write_buffer, ts ); |
klauss | 91:c2a86b1f8aaa | 1037 | |
klauss | 81:3656f00ab3db | 1038 | /* tratamento de pedidos de ligação */ |
klauss | 81:3656f00ab3db | 1039 | invite_handler( v_call, v_cb, ts, NULL ); |
klauss | 91:c2a86b1f8aaa | 1040 | |
klauss | 81:3656f00ab3db | 1041 | /* rotina de verificação de TS's perdidos */ |
klauss | 91:c2a86b1f8aaa | 1042 | if( ( v_call->size() == 0 ) && ( ts->remain_timeslices() != __MAX_TIMESLICES__ ) ) { |
klauss | 91:c2a86b1f8aaa | 1043 | bool ts_reset = true; |
klauss | 91:c2a86b1f8aaa | 1044 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 82:f55d13babca0 | 1045 | if ( ( ( Call_Box * )v_cb->get_element( i ) )->get_status() != cb_idle && |
klauss | 91:c2a86b1f8aaa | 1046 | ( ( Call_Box * )v_cb->get_element( i ) )->get_sip_status() != sip_idle ) { |
klauss | 78:1353744f01e1 | 1047 | ts_reset = false; |
klauss | 78:1353744f01e1 | 1048 | break; |
klauss | 78:1353744f01e1 | 1049 | } |
klauss | 91:c2a86b1f8aaa | 1050 | } |
klauss | 91:c2a86b1f8aaa | 1051 | if( ts_reset ) { |
klauss | 81:3656f00ab3db | 1052 | if( debug_invite ) debug_msg("Resetando TS"); |
klauss | 78:1353744f01e1 | 1053 | ts->reset(); |
klauss | 78:1353744f01e1 | 1054 | } |
klauss | 0:4d17cd9c8f9d | 1055 | } |
klauss | 91:c2a86b1f8aaa | 1056 | |
klauss | 81:3656f00ab3db | 1057 | //invite_pgk_retry_manager( v_call, v_cb, buffer, write_buffer ); |
klauss | 91:c2a86b1f8aaa | 1058 | |
klauss | 81:3656f00ab3db | 1059 | /* escuta se existe algum procedimento de gravação de cbx */ |
klauss | 91:c2a86b1f8aaa | 1060 | //bl_handler(); |
klauss | 91:c2a86b1f8aaa | 1061 | |
klauss | 81:3656f00ab3db | 1062 | /* rotina que esvazia possiveis pacotes que não foram transmitidos para evitar conflito */ |
klauss | 72:895ca792c647 | 1063 | tx_buffer_ring_buffer_handler(); |
klauss | 91:c2a86b1f8aaa | 1064 | |
klauss | 30:8dfb6d8de53d | 1065 | type = __DO_NOTHING__; |
klauss | 91:c2a86b1f8aaa | 1066 | |
klauss | 81:3656f00ab3db | 1067 | if( eth_status == 0 ) eth_wdt = ETH_CONNECT_TIMEOUT; |
klauss | 91:c2a86b1f8aaa | 1068 | |
klauss | 91:c2a86b1f8aaa | 1069 | if( wdt_timer.read() >= 1 ) { |
klauss | 91:c2a86b1f8aaa | 1070 | //FIXME remove myself |
klauss | 92:92df17f538a8 | 1071 | //registry_test = true; |
klauss | 99:e80850c51106 | 1072 | //invite_retry_time = true; |
klauss | 91:c2a86b1f8aaa | 1073 | |
klauss | 83:b8a1d8fdeaeb | 1074 | uptime++; |
klauss | 101:162c28286c29 | 1075 | |
klauss | 101:162c28286c29 | 1076 | current_time++; |
klauss | 91:c2a86b1f8aaa | 1077 | |
klauss | 81:3656f00ab3db | 1078 | wdt_timer.reset(); |
klauss | 91:c2a86b1f8aaa | 1079 | |
klauss | 81:3656f00ab3db | 1080 | if( wdt_show ) debug_wdt = true; |
klauss | 91:c2a86b1f8aaa | 1081 | |
klauss | 81:3656f00ab3db | 1082 | if( external_wdt ) external_wdt--; |
klauss | 81:3656f00ab3db | 1083 | if( pkg_wdt ) pkg_wdt--; |
klauss | 81:3656f00ab3db | 1084 | if( eth_wdt ) eth_wdt--; |
klauss | 91:c2a86b1f8aaa | 1085 | |
klauss | 91:c2a86b1f8aaa | 1086 | if( eth_wdt && external_wdt && pkg_wdt ){ |
klauss | 81:3656f00ab3db | 1087 | wdt.kick(); |
klauss | 81:3656f00ab3db | 1088 | } |
klauss | 81:3656f00ab3db | 1089 | } |
klauss | 91:c2a86b1f8aaa | 1090 | |
klauss | 91:c2a86b1f8aaa | 1091 | if( debug_wdt ) { |
klauss | 87:679ee0d594a9 | 1092 | send_msg("lpc_low_level_input_counter :: %d", lpc_low_level_input_counter ); |
klauss | 87:679ee0d594a9 | 1093 | lpc_low_level_input_counter = 0; |
klauss | 91:c2a86b1f8aaa | 1094 | |
klauss | 81:3656f00ab3db | 1095 | debug_wdt = false; |
klauss | 91:c2a86b1f8aaa | 1096 | if( eth_status == 0 ) { |
klauss | 91:c2a86b1f8aaa | 1097 | 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 | 1098 | ( wdt.WatchdogCausedReset() ) ? "true" : "false", |
klauss | 91:c2a86b1f8aaa | 1099 | EXTERN_WDT_IDLE - external_wdt, |
klauss | 91:c2a86b1f8aaa | 1100 | EXTERN_WDT_IDLE, |
klauss | 91:c2a86b1f8aaa | 1101 | RX_CB_IDLE - pkg_wdt, |
klauss | 91:c2a86b1f8aaa | 1102 | RX_CB_IDLE |
klauss | 91:c2a86b1f8aaa | 1103 | ); |
klauss | 91:c2a86b1f8aaa | 1104 | } else { |
klauss | 91:c2a86b1f8aaa | 1105 | 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 | 1106 | ( wdt.WatchdogCausedReset() ) ? "true" : "false", |
klauss | 91:c2a86b1f8aaa | 1107 | ETH_CONNECT_TIMEOUT - eth_wdt, |
klauss | 91:c2a86b1f8aaa | 1108 | EXTERN_WDT_IDLE - external_wdt, |
klauss | 91:c2a86b1f8aaa | 1109 | EXTERN_WDT_IDLE, |
klauss | 91:c2a86b1f8aaa | 1110 | RX_CB_IDLE - pkg_wdt, |
klauss | 91:c2a86b1f8aaa | 1111 | RX_CB_IDLE |
klauss | 91:c2a86b1f8aaa | 1112 | ); |
klauss | 81:3656f00ab3db | 1113 | } |
klauss | 81:3656f00ab3db | 1114 | } |
klauss | 0:4d17cd9c8f9d | 1115 | } |
klauss | 0:4d17cd9c8f9d | 1116 | } |