Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
prompt.cpp@117:e9facba9db27, 2015-04-23 (annotated)
- Committer:
- klauss
- Date:
- Thu Apr 23 21:53:28 2015 +0000
- Revision:
- 117:e9facba9db27
- Parent:
- 116:39a41ebb675c
- Child:
- 119:ee6a53069455
merge dos fw contendo as funcionalidade de bootloader e o fw que estava em campo na ultima vistoria
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 44:cc4996469404 | 1 | #include "prompt.h" |
klauss | 45:c80574f24dc3 | 2 | |
klauss | 60:b4ec6beb3be3 | 3 | bool flood_silence = false; |
klauss | 65:0b653cfe95db | 4 | bool delayed_flood = false; |
klauss | 63:0d95da692bb4 | 5 | |
klauss | 78:1353744f01e1 | 6 | Timer tcp_timer; |
klauss | 78:1353744f01e1 | 7 | bool tcp_alive = false; |
klauss | 19:ab2088e0dec6 | 8 | |
klauss | 58:af7e8788f106 | 9 | char __debug_buf__[ DEBUGBUFSIZE ]; |
klauss | 35:96885a7931f0 | 10 | char * debug_buf = __debug_buf__; |
klauss | 58:af7e8788f106 | 11 | char last_cmd[ DEBUGBUFSIZE ]; |
klauss | 58:af7e8788f106 | 12 | char tmp_cmd[ DEBUGBUFSIZE ] = "help"; |
klauss | 30:8dfb6d8de53d | 13 | char last_debug_buf[ DEBUGBUFSIZE ] = "help"; |
klauss | 60:b4ec6beb3be3 | 14 | |
klauss | 117:e9facba9db27 | 15 | FILE *fip, *fmask, *fgate, *fport, *fsip, *fsport, *fext, *fserext, *fudpport, *ftcpport, *ftip, *ftport, *ffwip, *ffwport, *fmax, *fmin; |
klauss | 81:3656f00ab3db | 16 | |
klauss | 19:ab2088e0dec6 | 17 | uint8_t bufptr = 0; |
klauss | 35:96885a7931f0 | 18 | uint8_t last_bufptr = 0; |
klauss | 19:ab2088e0dec6 | 19 | |
klauss | 117:e9facba9db27 | 20 | int str2uint ( char * s, unsigned int * val ){ |
klauss | 117:e9facba9db27 | 21 | int i = 0; |
klauss | 117:e9facba9db27 | 22 | unsigned int ret = 0; |
klauss | 117:e9facba9db27 | 23 | for (;;) { |
klauss | 117:e9facba9db27 | 24 | if (s[i] < '0') { |
klauss | 117:e9facba9db27 | 25 | *val = ret; |
klauss | 117:e9facba9db27 | 26 | return i; |
klauss | 117:e9facba9db27 | 27 | } |
klauss | 117:e9facba9db27 | 28 | ret *= 10; |
klauss | 117:e9facba9db27 | 29 | ret += s[i] - '0'; |
klauss | 117:e9facba9db27 | 30 | i++; |
klauss | 117:e9facba9db27 | 31 | } |
klauss | 117:e9facba9db27 | 32 | } |
klauss | 19:ab2088e0dec6 | 33 | |
klauss | 117:e9facba9db27 | 34 | // operantion with the system config files |
klauss | 117:e9facba9db27 | 35 | void files( const char type ){ |
klauss | 117:e9facba9db27 | 36 | // show files |
klauss | 117:e9facba9db27 | 37 | if (type == 's' ){ |
klauss | 117:e9facba9db27 | 38 | if( debug_uart3 ) pc.printf("Header IP " ); |
klauss | 117:e9facba9db27 | 39 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 40 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Header IP " ); |
klauss | 117:e9facba9db27 | 41 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 42 | |
klauss | 117:e9facba9db27 | 43 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 44 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 45 | } |
klauss | 117:e9facba9db27 | 46 | } |
klauss | 117:e9facba9db27 | 47 | |
klauss | 117:e9facba9db27 | 48 | cat("/qspi/myip.txt"); |
klauss | 117:e9facba9db27 | 49 | |
klauss | 117:e9facba9db27 | 50 | if( debug_uart3 ) pc.printf("Header ext "); |
klauss | 117:e9facba9db27 | 51 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 52 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Header ext " ); |
klauss | 117:e9facba9db27 | 53 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 54 | |
klauss | 117:e9facba9db27 | 55 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 56 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 57 | } |
klauss | 117:e9facba9db27 | 58 | } |
klauss | 117:e9facba9db27 | 59 | |
klauss | 117:e9facba9db27 | 60 | cat("/qspi/myext.txt"); |
klauss | 117:e9facba9db27 | 61 | |
klauss | 117:e9facba9db27 | 62 | if( debug_uart3 ) pc.printf("Header port "); |
klauss | 117:e9facba9db27 | 63 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 64 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Header port " ); |
klauss | 117:e9facba9db27 | 65 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 66 | |
klauss | 117:e9facba9db27 | 67 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 68 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 69 | } |
klauss | 117:e9facba9db27 | 70 | } |
klauss | 117:e9facba9db27 | 71 | |
klauss | 117:e9facba9db27 | 72 | cat("/qspi/mysipport.txt"); |
klauss | 117:e9facba9db27 | 73 | |
klauss | 117:e9facba9db27 | 74 | if( debug_uart3 ) pc.printf("Server IP "); |
klauss | 117:e9facba9db27 | 75 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 76 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Server IP " ); |
klauss | 117:e9facba9db27 | 77 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 78 | |
klauss | 117:e9facba9db27 | 79 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 80 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 81 | } |
klauss | 117:e9facba9db27 | 82 | } |
klauss | 117:e9facba9db27 | 83 | |
klauss | 117:e9facba9db27 | 84 | cat("/qspi/serverip.txt"); |
klauss | 117:e9facba9db27 | 85 | |
klauss | 117:e9facba9db27 | 86 | if( debug_uart3 ) pc.printf("Server ext "); |
klauss | 117:e9facba9db27 | 87 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 88 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Server ext " ); |
klauss | 117:e9facba9db27 | 89 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 90 | |
klauss | 117:e9facba9db27 | 91 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 92 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 93 | } |
klauss | 117:e9facba9db27 | 94 | } |
klauss | 117:e9facba9db27 | 95 | |
klauss | 117:e9facba9db27 | 96 | cat("/qspi/peerext.txt"); |
klauss | 117:e9facba9db27 | 97 | |
klauss | 117:e9facba9db27 | 98 | if( debug_uart3 ) pc.printf("Server port "); |
klauss | 117:e9facba9db27 | 99 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 100 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Server port " ); |
klauss | 117:e9facba9db27 | 101 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 102 | |
klauss | 117:e9facba9db27 | 103 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 104 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 105 | } |
klauss | 117:e9facba9db27 | 106 | } |
klauss | 117:e9facba9db27 | 107 | cat("/qspi/serverport.txt"); |
klauss | 117:e9facba9db27 | 108 | |
klauss | 117:e9facba9db27 | 109 | if( debug_uart3 ) pc.printf("Mascara de rede "); |
klauss | 117:e9facba9db27 | 110 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 111 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Mascara de rede " ); |
klauss | 117:e9facba9db27 | 112 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 113 | |
klauss | 117:e9facba9db27 | 114 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 115 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 116 | } |
klauss | 117:e9facba9db27 | 117 | } |
klauss | 117:e9facba9db27 | 118 | cat("/qspi/mymask.txt"); |
klauss | 117:e9facba9db27 | 119 | |
klauss | 117:e9facba9db27 | 120 | if( debug_uart3 ) pc.printf("Gateway IP "); |
klauss | 117:e9facba9db27 | 121 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 122 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Gateway IP " ); |
klauss | 117:e9facba9db27 | 123 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 124 | |
klauss | 117:e9facba9db27 | 125 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 126 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 127 | } |
klauss | 117:e9facba9db27 | 128 | } |
klauss | 117:e9facba9db27 | 129 | cat("/qspi/mygateway.txt"); |
klauss | 117:e9facba9db27 | 130 | |
klauss | 117:e9facba9db27 | 131 | if( debug_uart3 ) pc.printf("UDP Port "); |
klauss | 117:e9facba9db27 | 132 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 133 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "UDP Port " ); |
klauss | 117:e9facba9db27 | 134 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 135 | |
klauss | 117:e9facba9db27 | 136 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 137 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 138 | } |
klauss | 117:e9facba9db27 | 139 | } |
klauss | 117:e9facba9db27 | 140 | |
klauss | 117:e9facba9db27 | 141 | cat("/qspi/udpport.txt"); |
klauss | 117:e9facba9db27 | 142 | |
klauss | 117:e9facba9db27 | 143 | if( debug_uart3 ) pc.printf("TCP Port "); |
klauss | 117:e9facba9db27 | 144 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 145 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "TCP Port " ); |
klauss | 117:e9facba9db27 | 146 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 147 | |
klauss | 117:e9facba9db27 | 148 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 149 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 150 | } |
klauss | 117:e9facba9db27 | 151 | } |
klauss | 117:e9facba9db27 | 152 | |
klauss | 117:e9facba9db27 | 153 | cat("/qspi/tcpport.txt"); |
klauss | 117:e9facba9db27 | 154 | |
klauss | 117:e9facba9db27 | 155 | if( debug_uart3 ) pc.printf("Telemetry Server IP "); |
klauss | 117:e9facba9db27 | 156 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 157 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Telemetry Server IP " ); |
klauss | 117:e9facba9db27 | 158 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 159 | |
klauss | 117:e9facba9db27 | 160 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 161 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 162 | } |
klauss | 117:e9facba9db27 | 163 | } |
klauss | 117:e9facba9db27 | 164 | |
klauss | 117:e9facba9db27 | 165 | cat("/qspi/telemetry_ip.txt"); |
klauss | 117:e9facba9db27 | 166 | |
klauss | 117:e9facba9db27 | 167 | if( debug_uart3 ) pc.printf("Telemetry Server Port "); |
klauss | 117:e9facba9db27 | 168 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 169 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Telemetry Server Port " ); |
klauss | 117:e9facba9db27 | 170 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 171 | |
klauss | 117:e9facba9db27 | 172 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 173 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 174 | } |
klauss | 117:e9facba9db27 | 175 | } |
klauss | 117:e9facba9db27 | 176 | |
klauss | 117:e9facba9db27 | 177 | cat("/qspi/telemetry_port.txt"); |
klauss | 117:e9facba9db27 | 178 | |
klauss | 117:e9facba9db27 | 179 | /* |
klauss | 117:e9facba9db27 | 180 | if( debug_uart3 ) pc.printf("FW Server IP "); |
klauss | 117:e9facba9db27 | 181 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 182 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FW Server IP " ); |
klauss | 117:e9facba9db27 | 183 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 184 | |
klauss | 117:e9facba9db27 | 185 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 186 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 187 | } |
klauss | 117:e9facba9db27 | 188 | } |
klauss | 117:e9facba9db27 | 189 | |
klauss | 117:e9facba9db27 | 190 | cat("/qspi/fw_ip.txt"); |
klauss | 117:e9facba9db27 | 191 | |
klauss | 117:e9facba9db27 | 192 | if( debug_uart3 ) pc.printf("FW Server Port "); |
klauss | 117:e9facba9db27 | 193 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 194 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Fw Server Port " ); |
klauss | 117:e9facba9db27 | 195 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 196 | |
klauss | 117:e9facba9db27 | 197 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 198 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 199 | } |
klauss | 117:e9facba9db27 | 200 | } |
klauss | 117:e9facba9db27 | 201 | |
klauss | 117:e9facba9db27 | 202 | cat("/qspi/fw_port.txt"); |
klauss | 117:e9facba9db27 | 203 | */ |
klauss | 117:e9facba9db27 | 204 | |
klauss | 117:e9facba9db27 | 205 | if( debug_uart3 ) pc.printf("FW Server IP "); |
klauss | 117:e9facba9db27 | 206 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 207 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FW Server IP " ); |
klauss | 117:e9facba9db27 | 208 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 209 | |
klauss | 117:e9facba9db27 | 210 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 211 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 212 | } |
klauss | 117:e9facba9db27 | 213 | } |
klauss | 117:e9facba9db27 | 214 | |
klauss | 117:e9facba9db27 | 215 | cat("/qspi/fw_ip.txt"); |
klauss | 117:e9facba9db27 | 216 | |
klauss | 117:e9facba9db27 | 217 | if( debug_uart3 ) pc.printf("FW Server Port "); |
klauss | 117:e9facba9db27 | 218 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 219 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FW Server Port " ); |
klauss | 117:e9facba9db27 | 220 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 221 | |
klauss | 117:e9facba9db27 | 222 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 223 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 224 | } |
klauss | 117:e9facba9db27 | 225 | } |
klauss | 117:e9facba9db27 | 226 | |
klauss | 117:e9facba9db27 | 227 | cat("/qspi/fw_port.txt"); |
klauss | 117:e9facba9db27 | 228 | |
klauss | 117:e9facba9db27 | 229 | if( debug_uart3 ) pc.printf("Max Ext "); |
klauss | 117:e9facba9db27 | 230 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 231 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Max Ext " ); |
klauss | 117:e9facba9db27 | 232 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 233 | |
klauss | 117:e9facba9db27 | 234 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 235 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 236 | } |
klauss | 117:e9facba9db27 | 237 | } |
klauss | 117:e9facba9db27 | 238 | |
klauss | 117:e9facba9db27 | 239 | cat("/qspi/maxext.txt"); |
klauss | 117:e9facba9db27 | 240 | |
klauss | 117:e9facba9db27 | 241 | if( debug_uart3 ) pc.printf("Min Ext "); |
klauss | 117:e9facba9db27 | 242 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 243 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Min Ext " ); |
klauss | 117:e9facba9db27 | 244 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 245 | |
klauss | 117:e9facba9db27 | 246 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 247 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 248 | } |
klauss | 117:e9facba9db27 | 249 | } |
klauss | 117:e9facba9db27 | 250 | |
klauss | 117:e9facba9db27 | 251 | cat("/qspi/minext.txt"); |
klauss | 117:e9facba9db27 | 252 | |
klauss | 117:e9facba9db27 | 253 | |
klauss | 117:e9facba9db27 | 254 | //*------------ formatando a saida ----------------*// |
klauss | 117:e9facba9db27 | 255 | strcpy( last_cmd, tmp_cmd ); |
klauss | 117:e9facba9db27 | 256 | bufptr = 0; |
klauss | 117:e9facba9db27 | 257 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 117:e9facba9db27 | 258 | |
klauss | 117:e9facba9db27 | 259 | if( tcp_session ) tcp_client.send_all( "\n\r> " , strlen( "\n\r> " ) ); |
klauss | 117:e9facba9db27 | 260 | |
klauss | 117:e9facba9db27 | 261 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 262 | udp_server.sendTo( udp_client, "\n\r> ", strlen( "\n\r> " ) ); |
klauss | 117:e9facba9db27 | 263 | } |
klauss | 117:e9facba9db27 | 264 | } |
klauss | 117:e9facba9db27 | 265 | |
klauss | 117:e9facba9db27 | 266 | if (type == 'c' ){ |
klauss | 117:e9facba9db27 | 267 | // close all files |
klauss | 117:e9facba9db27 | 268 | //debug_msg(""); |
klauss | 117:e9facba9db27 | 269 | if( fip ) fclose( fip ); |
klauss | 117:e9facba9db27 | 270 | if( fmask ) fclose( fmask ); |
klauss | 117:e9facba9db27 | 271 | if( fgate ) fclose( fgate ); |
klauss | 117:e9facba9db27 | 272 | if( fport )fclose( fport ); |
klauss | 117:e9facba9db27 | 273 | if( fsip ) fclose( fsip ); |
klauss | 117:e9facba9db27 | 274 | if( fsport ) fclose( fsport ); |
klauss | 117:e9facba9db27 | 275 | if( fext ) fclose( fext ); |
klauss | 117:e9facba9db27 | 276 | if( fserext ) fclose( fserext ); |
klauss | 117:e9facba9db27 | 277 | if( fudpport ) fclose( fudpport ); |
klauss | 117:e9facba9db27 | 278 | if( ftcpport ) fclose( ftcpport ); |
klauss | 117:e9facba9db27 | 279 | if( fmax ) fclose( fmax ); |
klauss | 117:e9facba9db27 | 280 | if( fmin ) fclose( fmin ); |
klauss | 117:e9facba9db27 | 281 | if( ftip ) fclose( ftip ); |
klauss | 117:e9facba9db27 | 282 | if( ftport ) fclose( ftport ); |
klauss | 117:e9facba9db27 | 283 | if( ffwip ) fclose( ffwip ); |
klauss | 117:e9facba9db27 | 284 | if( ffwport) fclose( ffwport ); |
klauss | 117:e9facba9db27 | 285 | //debug_msg(""); |
klauss | 117:e9facba9db27 | 286 | } |
klauss | 117:e9facba9db27 | 287 | |
klauss | 117:e9facba9db27 | 288 | if (type == 'i' ){ |
klauss | 117:e9facba9db27 | 289 | //debug_msg(""); |
klauss | 117:e9facba9db27 | 290 | // Check if files exist, if not create the files |
klauss | 117:e9facba9db27 | 291 | //fixme criar um bool pra cada file |
klauss | 117:e9facba9db27 | 292 | bool exists = true; |
klauss | 117:e9facba9db27 | 293 | |
klauss | 117:e9facba9db27 | 294 | fip = fopen("/qspi/myip.txt", "r"); |
klauss | 117:e9facba9db27 | 295 | if( fip == NULL){ |
klauss | 117:e9facba9db27 | 296 | set_ip( __MY_IP__ ); |
klauss | 117:e9facba9db27 | 297 | exists = false; |
klauss | 117:e9facba9db27 | 298 | } |
klauss | 117:e9facba9db27 | 299 | //fclose( fip ); |
klauss | 117:e9facba9db27 | 300 | |
klauss | 117:e9facba9db27 | 301 | fserext = fopen("/qspi/myext.txt", "r"); |
klauss | 117:e9facba9db27 | 302 | if( fserext == NULL ){ |
klauss | 117:e9facba9db27 | 303 | set_header_ext( __MY_EXT__ ); |
klauss | 117:e9facba9db27 | 304 | exists = false; |
klauss | 117:e9facba9db27 | 305 | } |
klauss | 117:e9facba9db27 | 306 | //fclose( fserext ); |
klauss | 117:e9facba9db27 | 307 | |
klauss | 117:e9facba9db27 | 308 | fport = fopen("/qspi/mysipport.txt", "r"); |
klauss | 117:e9facba9db27 | 309 | if (fport == NULL){ |
klauss | 117:e9facba9db27 | 310 | set_header_sip_port( __MY_PORT__ ); |
klauss | 117:e9facba9db27 | 311 | exists = false; |
klauss | 117:e9facba9db27 | 312 | } |
klauss | 117:e9facba9db27 | 313 | //fclose( fport ); |
klauss | 117:e9facba9db27 | 314 | |
klauss | 117:e9facba9db27 | 315 | fsip = fopen("/qspi/serverip.txt", "r"); |
klauss | 117:e9facba9db27 | 316 | if (fsip == NULL){ |
klauss | 117:e9facba9db27 | 317 | set_server_ip( __SERVER_IP__ ); |
klauss | 117:e9facba9db27 | 318 | exists = false; |
klauss | 117:e9facba9db27 | 319 | } |
klauss | 117:e9facba9db27 | 320 | //fclose( fsip ); |
klauss | 117:e9facba9db27 | 321 | |
klauss | 117:e9facba9db27 | 322 | fext = fopen("/qspi/peerext.txt", "r"); |
klauss | 117:e9facba9db27 | 323 | if ( fext == NULL ){ |
klauss | 117:e9facba9db27 | 324 | set_server_ext( __PEER_EXT__ ); |
klauss | 117:e9facba9db27 | 325 | exists = false; |
klauss | 117:e9facba9db27 | 326 | } |
klauss | 117:e9facba9db27 | 327 | //fclose( fext ); |
klauss | 117:e9facba9db27 | 328 | |
klauss | 117:e9facba9db27 | 329 | fsport = fopen("/qspi/serverport.txt", "r"); |
klauss | 117:e9facba9db27 | 330 | if (fsport == NULL){ |
klauss | 117:e9facba9db27 | 331 | set_server_port( __SERVER_PORT__ ); |
klauss | 117:e9facba9db27 | 332 | exists = false; |
klauss | 117:e9facba9db27 | 333 | } |
klauss | 117:e9facba9db27 | 334 | //fclose( fsport ); |
klauss | 117:e9facba9db27 | 335 | |
klauss | 117:e9facba9db27 | 336 | fmask = fopen("/qspi/mymask.txt", "r"); |
klauss | 117:e9facba9db27 | 337 | if (fmask == NULL){ |
klauss | 117:e9facba9db27 | 338 | set_mask( __MY_MSK__ ); |
klauss | 117:e9facba9db27 | 339 | exists = false; |
klauss | 117:e9facba9db27 | 340 | } |
klauss | 117:e9facba9db27 | 341 | //fclose( fmask ); |
klauss | 117:e9facba9db27 | 342 | |
klauss | 117:e9facba9db27 | 343 | fgate = fopen("/qspi/mygateway.txt", "r"); |
klauss | 117:e9facba9db27 | 344 | if (fgate == NULL){ |
klauss | 117:e9facba9db27 | 345 | set_gateway( __MY_GTW__ ); |
klauss | 117:e9facba9db27 | 346 | exists = false; |
klauss | 117:e9facba9db27 | 347 | } |
klauss | 117:e9facba9db27 | 348 | //fclose( fgate ); |
klauss | 117:e9facba9db27 | 349 | |
klauss | 117:e9facba9db27 | 350 | fudpport = fopen("/qspi/udpport.txt", "r" ); |
klauss | 117:e9facba9db27 | 351 | if( fudpport == NULL ){ |
klauss | 117:e9facba9db27 | 352 | set_udp_port_listener( UDP_PORT_LISTENER ); |
klauss | 117:e9facba9db27 | 353 | exists = false; |
klauss | 117:e9facba9db27 | 354 | } |
klauss | 117:e9facba9db27 | 355 | //fclose( fudpport ); |
klauss | 117:e9facba9db27 | 356 | |
klauss | 117:e9facba9db27 | 357 | ftcpport = fopen("/qspi/tcpport.txt", "r" ); |
klauss | 117:e9facba9db27 | 358 | if( ftcpport == NULL ){ |
klauss | 117:e9facba9db27 | 359 | set_tcp_port_listener( TCP_PORT_LISTENER ); |
klauss | 117:e9facba9db27 | 360 | exists = false; |
klauss | 117:e9facba9db27 | 361 | } |
klauss | 117:e9facba9db27 | 362 | //fclose( ftcpport ); |
klauss | 117:e9facba9db27 | 363 | |
klauss | 117:e9facba9db27 | 364 | ftip = fopen("/qspi/telemetry_ip.txt", "r" ); |
klauss | 117:e9facba9db27 | 365 | if( ftip == NULL ){ |
klauss | 117:e9facba9db27 | 366 | set_telemetry_ip( __TELEMETRY_SERVER_IP__ ); |
klauss | 117:e9facba9db27 | 367 | exists = false; |
klauss | 117:e9facba9db27 | 368 | } |
klauss | 117:e9facba9db27 | 369 | //fclose( ftip ); |
klauss | 117:e9facba9db27 | 370 | |
klauss | 117:e9facba9db27 | 371 | ftport = fopen("/qspi/telemetry_port.txt", "r" ); |
klauss | 117:e9facba9db27 | 372 | if( ftport == NULL ){ |
klauss | 117:e9facba9db27 | 373 | set_telemetry_port( __TELEMETRY_SERVER_PORT__ ); |
klauss | 117:e9facba9db27 | 374 | exists = false; |
klauss | 117:e9facba9db27 | 375 | } |
klauss | 117:e9facba9db27 | 376 | //fclose( ftport ); |
klauss | 117:e9facba9db27 | 377 | |
klauss | 117:e9facba9db27 | 378 | //debug_msg(""); |
klauss | 117:e9facba9db27 | 379 | ffwip = fopen("/qspi/fw_ip.txt", "r" ); |
klauss | 117:e9facba9db27 | 380 | if( ffwip == NULL ){ |
klauss | 117:e9facba9db27 | 381 | set_fw_ip( __FW_SERVER_IP__ ); |
klauss | 117:e9facba9db27 | 382 | exists = false; |
klauss | 117:e9facba9db27 | 383 | } |
klauss | 117:e9facba9db27 | 384 | //debug_msg(""); |
klauss | 117:e9facba9db27 | 385 | //fclose( ffwip ); |
klauss | 117:e9facba9db27 | 386 | //debug_msg(""); |
klauss | 117:e9facba9db27 | 387 | ffwport = fopen("/qspi/fw_port.txt", "r" ); |
klauss | 117:e9facba9db27 | 388 | if( ffwport == NULL ){ |
klauss | 117:e9facba9db27 | 389 | set_fw_port( __FW_SERVER_PORT__ ); |
klauss | 117:e9facba9db27 | 390 | exists = false; |
klauss | 117:e9facba9db27 | 391 | } |
klauss | 117:e9facba9db27 | 392 | //fclose( ffwport ); |
klauss | 117:e9facba9db27 | 393 | //debug_msg(""); |
klauss | 117:e9facba9db27 | 394 | fmax = fopen("/qspi/maxext.txt", "r" ); |
klauss | 117:e9facba9db27 | 395 | //debug_msg(""); |
klauss | 117:e9facba9db27 | 396 | if( fmax == NULL ){ |
klauss | 117:e9facba9db27 | 397 | //debug_msg(""); |
klauss | 117:e9facba9db27 | 398 | set_max_ext( MAX_EXT ); |
klauss | 117:e9facba9db27 | 399 | //debug_msg(""); |
klauss | 117:e9facba9db27 | 400 | exists = false; |
klauss | 117:e9facba9db27 | 401 | //debug_msg(""); |
klauss | 117:e9facba9db27 | 402 | } |
klauss | 117:e9facba9db27 | 403 | //fclose( fmax ); |
klauss | 117:e9facba9db27 | 404 | //debug_msg(""); |
klauss | 117:e9facba9db27 | 405 | fmin = fopen("/qspi/minext.txt", "r" ); |
klauss | 117:e9facba9db27 | 406 | if( fmin == NULL ){ |
klauss | 117:e9facba9db27 | 407 | set_min_ext( MIN_EXT ); |
klauss | 117:e9facba9db27 | 408 | exists = false; |
klauss | 117:e9facba9db27 | 409 | } |
klauss | 117:e9facba9db27 | 410 | //fclose( fmin ); |
klauss | 117:e9facba9db27 | 411 | //debug_msg(""); |
klauss | 117:e9facba9db27 | 412 | if( !exists ){ |
klauss | 117:e9facba9db27 | 413 | if( debug_uart3 ) pc.printf("\n\rDefault configurations set!\n\r"); |
klauss | 117:e9facba9db27 | 414 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 415 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Default configurations set!\n\r"); |
klauss | 117:e9facba9db27 | 416 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 117:e9facba9db27 | 417 | if( tcp_session ){ |
klauss | 117:e9facba9db27 | 418 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 419 | bufptr = 0; |
klauss | 117:e9facba9db27 | 420 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 117:e9facba9db27 | 421 | } |
klauss | 117:e9facba9db27 | 422 | } |
klauss | 117:e9facba9db27 | 423 | } |
klauss | 117:e9facba9db27 | 424 | //debug_msg(""); |
klauss | 117:e9facba9db27 | 425 | reset_leds(); |
klauss | 117:e9facba9db27 | 426 | } |
klauss | 117:e9facba9db27 | 427 | |
klauss | 117:e9facba9db27 | 428 | if (type == 'r' ){ |
klauss | 117:e9facba9db27 | 429 | // Just open for read |
klauss | 117:e9facba9db27 | 430 | fip = fopen("/qspi/myip.txt", "r"); |
klauss | 117:e9facba9db27 | 431 | fmask = fopen("/qspi/mymask.txt", "r"); |
klauss | 117:e9facba9db27 | 432 | fgate = fopen("/qspi/mygateway.txt", "r"); |
klauss | 117:e9facba9db27 | 433 | fport = fopen("/qspi/mysipport.txt", "r"); |
klauss | 117:e9facba9db27 | 434 | fsip = fopen("/qspi/serverip.txt", "r"); |
klauss | 117:e9facba9db27 | 435 | fsport = fopen("/qspi/serverport.txt", "r"); |
klauss | 117:e9facba9db27 | 436 | fext = fopen( "/qspi/myext.txt", "r" ); |
klauss | 117:e9facba9db27 | 437 | fserext = fopen( "/qspi/peerext.txt", "r" ); |
klauss | 117:e9facba9db27 | 438 | fudpport = fopen( "/qspi/udpport.txt", "r" ); |
klauss | 117:e9facba9db27 | 439 | ftcpport = fopen( "/qspi/tcpport.txt", "r" ); |
klauss | 117:e9facba9db27 | 440 | ftip = fopen("/qspi/telemetry_ip.txt", "r" ); |
klauss | 117:e9facba9db27 | 441 | ftport = fopen("/qspi/telemetry_port.txt", "r" ); |
klauss | 117:e9facba9db27 | 442 | ffwip = fopen("/qspi/fw_ip.txt", "r" ); |
klauss | 117:e9facba9db27 | 443 | ffwport = fopen("/qspi/fw_port.txt", "r" ); |
klauss | 117:e9facba9db27 | 444 | fmax = fopen("/qspi/maxext.txt", "r" ); |
klauss | 117:e9facba9db27 | 445 | fmin = fopen("/qspi/minext.txt", "r" ); |
klauss | 117:e9facba9db27 | 446 | } |
klauss | 117:e9facba9db27 | 447 | |
klauss | 117:e9facba9db27 | 448 | if( type == 'w'){ |
klauss | 117:e9facba9db27 | 449 | // Create and write the default configs |
klauss | 117:e9facba9db27 | 450 | |
klauss | 117:e9facba9db27 | 451 | set_ip( __MY_IP__ ); |
klauss | 117:e9facba9db27 | 452 | |
klauss | 117:e9facba9db27 | 453 | set_header_sip_port( __MY_PORT__ ); |
klauss | 117:e9facba9db27 | 454 | |
klauss | 117:e9facba9db27 | 455 | set_header_ext( __MY_EXT__ ); |
klauss | 117:e9facba9db27 | 456 | |
klauss | 117:e9facba9db27 | 457 | set_server_ip( __SERVER_IP__ ); |
klauss | 117:e9facba9db27 | 458 | |
klauss | 117:e9facba9db27 | 459 | set_server_ext( __PEER_EXT__ ); |
klauss | 117:e9facba9db27 | 460 | |
klauss | 117:e9facba9db27 | 461 | set_server_port( __SERVER_PORT__ ); |
klauss | 117:e9facba9db27 | 462 | |
klauss | 117:e9facba9db27 | 463 | set_mask( __MY_MSK__ ); |
klauss | 117:e9facba9db27 | 464 | |
klauss | 117:e9facba9db27 | 465 | set_gateway( __MY_GTW__ ); |
klauss | 117:e9facba9db27 | 466 | |
klauss | 117:e9facba9db27 | 467 | set_udp_port_listener( UDP_PORT_LISTENER ); |
klauss | 117:e9facba9db27 | 468 | |
klauss | 117:e9facba9db27 | 469 | set_tcp_port_listener( TCP_PORT_LISTENER ); |
klauss | 117:e9facba9db27 | 470 | |
klauss | 117:e9facba9db27 | 471 | set_telemetry_ip( __TELEMETRY_SERVER_IP__ ); |
klauss | 117:e9facba9db27 | 472 | |
klauss | 117:e9facba9db27 | 473 | set_telemetry_port( __TELEMETRY_SERVER_PORT__ ); |
klauss | 117:e9facba9db27 | 474 | |
klauss | 117:e9facba9db27 | 475 | set_fw_ip( __FW_SERVER_IP__ ); |
klauss | 117:e9facba9db27 | 476 | |
klauss | 117:e9facba9db27 | 477 | set_fw_port( __FW_SERVER_PORT__ ); |
klauss | 117:e9facba9db27 | 478 | |
klauss | 117:e9facba9db27 | 479 | set_max_ext( MAX_EXT ); |
klauss | 117:e9facba9db27 | 480 | |
klauss | 117:e9facba9db27 | 481 | set_min_ext( MIN_EXT ); |
klauss | 117:e9facba9db27 | 482 | |
klauss | 117:e9facba9db27 | 483 | strcpy( last_cmd, tmp_cmd ); |
klauss | 117:e9facba9db27 | 484 | |
klauss | 117:e9facba9db27 | 485 | if( debug_uart3 ) pc.printf("\n\rDefault configurations set!\n\r"); |
klauss | 117:e9facba9db27 | 486 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 487 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rDefault configurations set!\n\r"); |
klauss | 117:e9facba9db27 | 488 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 117:e9facba9db27 | 489 | if( tcp_session ){ |
klauss | 117:e9facba9db27 | 490 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 491 | }else if( udp_request ){ |
klauss | 117:e9facba9db27 | 492 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 493 | } |
klauss | 117:e9facba9db27 | 494 | bufptr = 0; |
klauss | 117:e9facba9db27 | 495 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 117:e9facba9db27 | 496 | } |
klauss | 117:e9facba9db27 | 497 | } |
klauss | 117:e9facba9db27 | 498 | |
klauss | 117:e9facba9db27 | 499 | if (type == 'e'){ |
klauss | 117:e9facba9db27 | 500 | //Erase configs |
klauss | 117:e9facba9db27 | 501 | fip = fopen("/qspi/myip.txt", "w"); |
klauss | 117:e9facba9db27 | 502 | fmask = fopen("/qspi/mymask.txt", "w"); |
klauss | 117:e9facba9db27 | 503 | fgate = fopen("/qspi/mygateway.txt", "w"); |
klauss | 117:e9facba9db27 | 504 | fport = fopen("/qspi/mysipport.txt", "w"); |
klauss | 117:e9facba9db27 | 505 | fsip = fopen("/qspi/serverip.txt", "w"); |
klauss | 117:e9facba9db27 | 506 | fsport = fopen("/qspi/serverport.txt", "w"); |
klauss | 117:e9facba9db27 | 507 | fext = fopen( "/qspi/myext.txt", "w" ); |
klauss | 117:e9facba9db27 | 508 | fserext = fopen( "/qspi/peerext.txt", "w" ); |
klauss | 117:e9facba9db27 | 509 | fudpport = fopen( "/qspi/udpport.txt", "w" ); |
klauss | 117:e9facba9db27 | 510 | ftcpport = fopen( "/qspi/tcpport.txt", "w" ); |
klauss | 117:e9facba9db27 | 511 | ftip = fopen("/qspi/telemetry_ip.txt", "w" ); |
klauss | 117:e9facba9db27 | 512 | ftport = fopen("/qspi/telemetry_port.txt", "w" ); |
klauss | 117:e9facba9db27 | 513 | ffwip = fopen("/qspi/fw_ip.txt", "w" ); |
klauss | 117:e9facba9db27 | 514 | ffwport = fopen("/qspi/fw_port.txt", "w" ); |
klauss | 117:e9facba9db27 | 515 | fmax = fopen("/qspi/maxext.txt", "w" ); |
klauss | 117:e9facba9db27 | 516 | fmin = fopen("/qspi/minext.txt", "w" ); |
klauss | 117:e9facba9db27 | 517 | |
klauss | 117:e9facba9db27 | 518 | //FIXME verificar se deveria colocar tudo para %s |
klauss | 117:e9facba9db27 | 519 | fprintf( fip, "%s\n\r", "" ); |
klauss | 117:e9facba9db27 | 520 | fprintf( fport, "%i\n\r", 0 ); |
klauss | 117:e9facba9db27 | 521 | fprintf( fext, "%i\n\r", 0 ); |
klauss | 117:e9facba9db27 | 522 | |
klauss | 117:e9facba9db27 | 523 | fprintf( fsip, "%s\n\r", "" ); |
klauss | 117:e9facba9db27 | 524 | fprintf( fserext, "%i\n\r", 0 ); |
klauss | 117:e9facba9db27 | 525 | fprintf( fsport, "%i\n\r", 0 ); |
klauss | 117:e9facba9db27 | 526 | |
klauss | 117:e9facba9db27 | 527 | fprintf( fmask, "%s\n\r","" ); |
klauss | 117:e9facba9db27 | 528 | fprintf( fgate, "%s\n\r", "" ); |
klauss | 117:e9facba9db27 | 529 | |
klauss | 117:e9facba9db27 | 530 | fprintf( fudpport, "%i\n\r", 0 ); |
klauss | 117:e9facba9db27 | 531 | fprintf( ftcpport, "%i\n\r", 0 ); |
klauss | 117:e9facba9db27 | 532 | |
klauss | 117:e9facba9db27 | 533 | fprintf( ftip, "%s\n\r","" ); |
klauss | 117:e9facba9db27 | 534 | fprintf( ftport, "%i\n\r",0 ); |
klauss | 117:e9facba9db27 | 535 | |
klauss | 117:e9facba9db27 | 536 | fprintf( ffwip, "%s\n\r","" ); |
klauss | 117:e9facba9db27 | 537 | fprintf( ffwport, "%i\n\r",0 ); |
klauss | 117:e9facba9db27 | 538 | |
klauss | 117:e9facba9db27 | 539 | fprintf( fmax, "%i\n\r", 0 ); |
klauss | 117:e9facba9db27 | 540 | fprintf( fmin, "%i\n\r", 0 ); |
klauss | 117:e9facba9db27 | 541 | |
klauss | 117:e9facba9db27 | 542 | files('c'); |
klauss | 117:e9facba9db27 | 543 | |
klauss | 117:e9facba9db27 | 544 | if( debug_uart3 ) pc.printf("\n\rErased configurations set!\n\r"); |
klauss | 117:e9facba9db27 | 545 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 546 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rErased configurations set!\n\r"); |
klauss | 117:e9facba9db27 | 547 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 117:e9facba9db27 | 548 | if( tcp_session ){ |
klauss | 117:e9facba9db27 | 549 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 550 | }else if( udp_request ){ |
klauss | 117:e9facba9db27 | 551 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 552 | } |
klauss | 117:e9facba9db27 | 553 | bufptr = 0; |
klauss | 117:e9facba9db27 | 554 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 117:e9facba9db27 | 555 | } |
klauss | 117:e9facba9db27 | 556 | } |
klauss | 117:e9facba9db27 | 557 | } |
klauss | 117:e9facba9db27 | 558 | |
klauss | 117:e9facba9db27 | 559 | void init_fsystem(){ |
klauss | 117:e9facba9db27 | 560 | // init file system and check if files exist |
klauss | 117:e9facba9db27 | 561 | if (!qspifs.isformatted()) { |
klauss | 117:e9facba9db27 | 562 | qspifs.format(); |
klauss | 117:e9facba9db27 | 563 | if( debug_uart3 ) pc.printf("\n\rFile system configured!!\n\r"); |
klauss | 117:e9facba9db27 | 564 | } |
klauss | 117:e9facba9db27 | 565 | files('i'); // check if the files are created |
klauss | 117:e9facba9db27 | 566 | files('c'); |
klauss | 117:e9facba9db27 | 567 | send_msg("******* File System Ready *******"); |
klauss | 117:e9facba9db27 | 568 | } |
klauss | 117:e9facba9db27 | 569 | |
klauss | 117:e9facba9db27 | 570 | void init_prompt_eth(){ |
klauss | 117:e9facba9db27 | 571 | tcp_server.bind( TCP_PORT_LISTENER ); |
klauss | 117:e9facba9db27 | 572 | tcp_server.listen(); |
klauss | 117:e9facba9db27 | 573 | //tcp_server.set_blocking( false, 1 ); |
klauss | 117:e9facba9db27 | 574 | //udp_server.set_blocking( false, 2 ); |
klauss | 89:0fe315117b00 | 575 | tcp_server.set_blocking( false, 0 ); |
klauss | 117:e9facba9db27 | 576 | udp_server.set_blocking( false, 0 ); |
klauss | 117:e9facba9db27 | 577 | udp_server.bind( UDP_PORT_LISTENER ); |
klauss | 117:e9facba9db27 | 578 | if( debug_uart3 ) pc.printf("******* Prompt eth Ready *******\n\r"); |
klauss | 19:ab2088e0dec6 | 579 | } |
klauss | 19:ab2088e0dec6 | 580 | |
klauss | 28:94aec56c6329 | 581 | // main prompt process |
klauss | 117:e9facba9db27 | 582 | char * prompt_process( char * msg_from_cb ){ |
klauss | 28:94aec56c6329 | 583 | //FIXME dar flush na serial |
klauss | 19:ab2088e0dec6 | 584 | volatile char b = 0; |
klauss | 19:ab2088e0dec6 | 585 | static uint8_t bufret = 0; |
klauss | 30:8dfb6d8de53d | 586 | static Timer flood_timeout; |
klauss | 60:b4ec6beb3be3 | 587 | static Timer flood_silence_timer; |
klauss | 60:b4ec6beb3be3 | 588 | static uint8_t id_msg = 0x10; |
klauss | 60:b4ec6beb3be3 | 589 | static int start_ext, end_ext, ext_count; |
klauss | 36:728498a78e1e | 590 | bool miss_match = true; |
klauss | 114:472502b31a12 | 591 | char eth_buffer[ __PROMPT_ETH_BUFFER_SIZE__ ]; |
klauss | 117:e9facba9db27 | 592 | uint8_t write_buffer[ __CB_BUFFER_SIZE__ ]; |
klauss | 114:472502b31a12 | 593 | |
klauss | 114:472502b31a12 | 594 | if( flood_timeout.read() > 60 ){ |
klauss | 45:c80574f24dc3 | 595 | pflood = 0; |
klauss | 45:c80574f24dc3 | 596 | flood_timeout.stop(); |
klauss | 45:c80574f24dc3 | 597 | flood_timeout.reset(); |
klauss | 45:c80574f24dc3 | 598 | } |
klauss | 114:472502b31a12 | 599 | |
klauss | 117:e9facba9db27 | 600 | if( tcp_timer.read() >= TCP_IDLE_MAX_TIME ){ |
klauss | 117:e9facba9db27 | 601 | bool close_tcp = true; |
klauss | 117:e9facba9db27 | 602 | //if( tcp_alive && ( tcp_timer.read() < TCP_ALIVE_IDLE_MAX_TIME ) ){ |
klauss | 117:e9facba9db27 | 603 | // close_tcp = false; |
klauss | 117:e9facba9db27 | 604 | //} |
klauss | 117:e9facba9db27 | 605 | if( close_tcp ){ |
klauss | 117:e9facba9db27 | 606 | tcp_alive = false; |
klauss | 117:e9facba9db27 | 607 | tcp_timer.stop(); |
klauss | 117:e9facba9db27 | 608 | tcp_timer.reset(); |
klauss | 117:e9facba9db27 | 609 | tcp_session = false; |
klauss | 117:e9facba9db27 | 610 | debug_buf = __debug_buf__; |
klauss | 117:e9facba9db27 | 611 | bufptr = last_bufptr; |
klauss | 117:e9facba9db27 | 612 | bufret = 0; |
klauss | 117:e9facba9db27 | 613 | from_eth = false; |
klauss | 117:e9facba9db27 | 614 | tcp_client.close(); |
klauss | 117:e9facba9db27 | 615 | return( NULL ); |
klauss | 117:e9facba9db27 | 616 | } |
klauss | 117:e9facba9db27 | 617 | } |
klauss | 117:e9facba9db27 | 618 | if( !tcp_server.accept( tcp_client ) ){ |
klauss | 117:e9facba9db27 | 619 | tcp_session = true; |
klauss | 117:e9facba9db27 | 620 | tcp_timer.start(); |
klauss | 117:e9facba9db27 | 621 | last_bufptr = bufptr; |
klauss | 117:e9facba9db27 | 622 | eth_buffer[ 0 ] = 0; |
klauss | 116:39a41ebb675c | 623 | bufret = 0; |
klauss | 117:e9facba9db27 | 624 | } |
klauss | 117:e9facba9db27 | 625 | if( tcp_session ){ |
klauss | 117:e9facba9db27 | 626 | //if( !( (int)tcp_timer.read_ms() % 100 ) ){ |
klauss | 117:e9facba9db27 | 627 | //tcp_client.set_blocking( false, 1 ); |
klauss | 117:e9facba9db27 | 628 | tcp_client.set_blocking( false, 0 ); |
klauss | 117:e9facba9db27 | 629 | int n = tcp_client.receive( eth_buffer, sizeof( eth_buffer ) - 1 ); |
klauss | 117:e9facba9db27 | 630 | if( n > 0 ){ |
klauss | 117:e9facba9db27 | 631 | tcp_timer.reset(); |
klauss | 117:e9facba9db27 | 632 | |
klauss | 117:e9facba9db27 | 633 | if( ( n > 2 ) && ( eth_buffer[ n - 2 ] == '\r' ) ) eth_buffer[ n - 2 ] = 0; |
klauss | 117:e9facba9db27 | 634 | |
klauss | 117:e9facba9db27 | 635 | if( ( n > 1 ) && ( eth_buffer[ n - 1 ] == '\n' ) ) eth_buffer[ n - 1 ] = 0; |
klauss | 117:e9facba9db27 | 636 | |
klauss | 117:e9facba9db27 | 637 | if( ( n == 1 ) && eth_buffer[ 0 ] == 0x0A ) strcpy( eth_buffer, "\r" ); |
klauss | 117:e9facba9db27 | 638 | |
klauss | 117:e9facba9db27 | 639 | //if( eth_buffer[ 0 ] == '\r' || eth_buffer[ 1 ] == '\n' || eth_buffer[ 2 ] == 'r' || eth_buffer[ 2 ] == '\n' ) strcpy( eth_buffer, "\r" ); |
klauss | 116:39a41ebb675c | 640 | |
klauss | 105:a930035b6556 | 641 | bufptr = strlen( eth_buffer ); |
klauss | 105:a930035b6556 | 642 | debug_buf = eth_buffer; |
klauss | 105:a930035b6556 | 643 | from_eth = true; |
klauss | 105:a930035b6556 | 644 | bufret = 1; |
klauss | 117:e9facba9db27 | 645 | |
klauss | 117:e9facba9db27 | 646 | if( !( strcmp( eth_buffer, "quit" ) ) ){ |
klauss | 105:a930035b6556 | 647 | tcp_timer.reset(); |
klauss | 105:a930035b6556 | 648 | debug_buf = __debug_buf__; |
klauss | 105:a930035b6556 | 649 | bufptr = last_bufptr; |
klauss | 105:a930035b6556 | 650 | from_eth = false; |
klauss | 105:a930035b6556 | 651 | tcp_session = false; |
klauss | 105:a930035b6556 | 652 | tcp_client.close(); |
klauss | 105:a930035b6556 | 653 | bufret = 0; |
klauss | 105:a930035b6556 | 654 | return( NULL ); |
klauss | 105:a930035b6556 | 655 | } |
klauss | 117:e9facba9db27 | 656 | /*else if( !( strcmp( eth_buffer, "alive" ) ) ){ |
klauss | 117:e9facba9db27 | 657 | char wake_msg[ 8 ]; |
klauss | 117:e9facba9db27 | 658 | external_wdt = EXTERN_WDT_IDLE; |
klauss | 117:e9facba9db27 | 659 | strcpy( wake_msg, "wakeup\n" ); |
klauss | 117:e9facba9db27 | 660 | while( !( tcp_client.send_all( wake_msg, strlen( wake_msg ) ) ) ); |
klauss | 117:e9facba9db27 | 661 | strcpy( eth_buffer, "0" ); |
klauss | 117:e9facba9db27 | 662 | bufret = 0; |
klauss | 117:e9facba9db27 | 663 | } |
klauss | 117:e9facba9db27 | 664 | */ |
klauss | 117:e9facba9db27 | 665 | }else{ |
klauss | 48:195c97f12e8e | 666 | debug_buf = __debug_buf__; |
klauss | 48:195c97f12e8e | 667 | bufptr = last_bufptr; |
klauss | 57:78f7191a8b69 | 668 | from_eth = false; |
klauss | 45:c80574f24dc3 | 669 | } |
klauss | 117:e9facba9db27 | 670 | //} |
klauss | 117:e9facba9db27 | 671 | } |
klauss | 117:e9facba9db27 | 672 | |
klauss | 117:e9facba9db27 | 673 | if( !from_eth ){ |
klauss | 117:e9facba9db27 | 674 | if( pc.readable() ){ |
klauss | 117:e9facba9db27 | 675 | // imput do teclado |
klauss | 117:e9facba9db27 | 676 | b = pc.getc(); |
klauss | 117:e9facba9db27 | 677 | if( b == 0x0D ){ // enter |
klauss | 117:e9facba9db27 | 678 | bufret = 1; |
klauss | 117:e9facba9db27 | 679 | }else{ |
klauss | 117:e9facba9db27 | 680 | pc.putc( b ); |
klauss | 117:e9facba9db27 | 681 | if( b == 0x08 || b == 0x7F ){ // BS | DEL |
klauss | 117:e9facba9db27 | 682 | if( bufptr > 0 ) debug_buf[ --bufptr ] = 0; |
klauss | 117:e9facba9db27 | 683 | }else if( b == 0x09 ){ |
klauss | 117:e9facba9db27 | 684 | // ignore tab |
klauss | 117:e9facba9db27 | 685 | }else{ |
klauss | 117:e9facba9db27 | 686 | debug_buf[bufptr] = b; |
klauss | 117:e9facba9db27 | 687 | bufptr++; |
klauss | 117:e9facba9db27 | 688 | } |
klauss | 117:e9facba9db27 | 689 | } |
klauss | 116:39a41ebb675c | 690 | } |
klauss | 53:bb492a8f115a | 691 | } |
klauss | 117:e9facba9db27 | 692 | |
klauss | 117:e9facba9db27 | 693 | if( msg_from_cb ){ |
klauss | 117:e9facba9db27 | 694 | if( tcp_session ){ |
klauss | 117:e9facba9db27 | 695 | tcp_client.send_all( msg_from_cb, strlen( msg_from_cb ) ); |
klauss | 117:e9facba9db27 | 696 | }else if( udp_request ){ |
klauss | 117:e9facba9db27 | 697 | udp_server.sendTo( udp_client, msg_from_cb, strlen( msg_from_cb ) ); |
klauss | 117:e9facba9db27 | 698 | } |
klauss | 117:e9facba9db27 | 699 | if( debug_uart3 ) pc.printf( "\n\r%s\n\r", msg_from_cb ); |
klauss | 113:db67ae00550e | 700 | } |
klauss | 114:472502b31a12 | 701 | |
klauss | 114:472502b31a12 | 702 | if( flood_silence ){ |
klauss | 114:472502b31a12 | 703 | if( flood_silence_timer.read_ms() > 250 ){ |
klauss | 113:db67ae00550e | 704 | char cmd[ 16 ] = "flood off"; |
klauss | 113:db67ae00550e | 705 | int str_end = strlen( cmd ); |
klauss | 113:db67ae00550e | 706 | cmd[ str_end ] = 0x0D; |
klauss | 113:db67ae00550e | 707 | cmd[ str_end + 1 ] = 0x00; |
klauss | 117:e9facba9db27 | 708 | |
klauss | 113:db67ae00550e | 709 | int port = convert_ext_to_port( ext_count ); |
klauss | 117:e9facba9db27 | 710 | send2callboxes( __build_cb_package__( ext_count, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 117:e9facba9db27 | 711 | if( debug_uart3 ) pc.printf("\r\nSilence sent to ext=%d port=%d", ext_count, port ); |
klauss | 117:e9facba9db27 | 712 | |
klauss | 117:e9facba9db27 | 713 | if( tcp_session ){ |
klauss | 113:db67ae00550e | 714 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\nSilence sent to ext=%d port=%d", ext_count, port ); |
klauss | 117:e9facba9db27 | 715 | //eth_buffer[ strlen( eth_buffer ) - 1 ] = '\0'; |
klauss | 117:e9facba9db27 | 716 | |
klauss | 113:db67ae00550e | 717 | tcp_client.send_all( eth_buffer, strlen( eth_buffer ) ); |
klauss | 117:e9facba9db27 | 718 | }else if( udp_request ){ |
klauss | 113:db67ae00550e | 719 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\nSilence sent to ext=%d port=%d", ext_count, port ); |
klauss | 117:e9facba9db27 | 720 | //eth_buffer[ strlen( eth_buffer ) - 1 ] = '\0'; |
klauss | 117:e9facba9db27 | 721 | |
klauss | 117:e9facba9db27 | 722 | udp_server.sendTo( udp_client, eth_buffer, strlen( eth_buffer ) ); |
klauss | 113:db67ae00550e | 723 | } |
klauss | 113:db67ae00550e | 724 | flood_silence_timer.reset(); |
klauss | 114:472502b31a12 | 725 | |
klauss | 117:e9facba9db27 | 726 | if( ++ext_count > end_ext ){ |
klauss | 113:db67ae00550e | 727 | flood_silence = false; |
klauss | 113:db67ae00550e | 728 | flood_silence_timer.stop(); |
klauss | 113:db67ae00550e | 729 | flood_silence_timer.reset(); |
klauss | 117:e9facba9db27 | 730 | |
klauss | 117:e9facba9db27 | 731 | if( debug_uart3 ) pc.printf("\r\n> " ); |
klauss | 117:e9facba9db27 | 732 | if( tcp_session ){ |
klauss | 113:db67ae00550e | 733 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\n> " ); |
klauss | 113:db67ae00550e | 734 | tcp_client.send_all( eth_buffer, strlen( eth_buffer ) ); |
klauss | 117:e9facba9db27 | 735 | }else if( udp_request ){ |
klauss | 113:db67ae00550e | 736 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\n> " ); |
klauss | 117:e9facba9db27 | 737 | udp_server.sendTo( udp_client, eth_buffer, strlen( eth_buffer ) ); |
klauss | 113:db67ae00550e | 738 | } |
klauss | 31:bb5fb28a77df | 739 | } |
klauss | 53:bb492a8f115a | 740 | } |
klauss | 48:195c97f12e8e | 741 | } |
klauss | 114:472502b31a12 | 742 | |
klauss | 114:472502b31a12 | 743 | if( delayed_flood ){ |
klauss | 65:0b653cfe95db | 744 | tflood.start(); |
klauss | 65:0b653cfe95db | 745 | tflood.reset(); |
klauss | 65:0b653cfe95db | 746 | floodcount =0; |
klauss | 65:0b653cfe95db | 747 | pflood = 1; |
klauss | 65:0b653cfe95db | 748 | flood_timeout.start(); |
klauss | 65:0b653cfe95db | 749 | delayed_flood = false; |
klauss | 114:472502b31a12 | 750 | if( debug_uart3 ) pc.printf("\n\rFlood ON\n\r"); |
klauss | 114:472502b31a12 | 751 | if( from_eth ){ |
klauss | 65:0b653cfe95db | 752 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r" ); |
klauss | 114:472502b31a12 | 753 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 65:0b653cfe95db | 754 | } |
klauss | 65:0b653cfe95db | 755 | } |
klauss | 114:472502b31a12 | 756 | |
klauss | 45:c80574f24dc3 | 757 | // Prompt commands here |
klauss | 58:af7e8788f106 | 758 | if ( bufret == 1 ) { |
klauss | 114:472502b31a12 | 759 | static unsigned int promptcb_last_ext = 0; |
klauss | 114:472502b31a12 | 760 | static unsigned int promptcb_last_port = 0; |
klauss | 55:2f5e7374af9d | 761 | static char promptcb_last_cmd[ 300 ]; |
klauss | 60:b4ec6beb3be3 | 762 | |
klauss | 58:af7e8788f106 | 763 | strcpy( tmp_cmd, debug_buf ); |
klauss | 114:472502b31a12 | 764 | if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "." ) ){ |
klauss | 45:c80574f24dc3 | 765 | miss_match = false; |
klauss | 58:af7e8788f106 | 766 | strcpy( debug_buf, last_cmd ); |
klauss | 58:af7e8788f106 | 767 | strcpy( tmp_cmd, debug_buf ); |
klauss | 114:472502b31a12 | 768 | }else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "+" ) ){ |
klauss | 59:e1e300880d2d | 769 | miss_match = false; |
klauss | 59:e1e300880d2d | 770 | strcpy( debug_buf, "flood on" ); |
klauss | 59:e1e300880d2d | 771 | strcpy( tmp_cmd, debug_buf ); |
klauss | 114:472502b31a12 | 772 | }else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "-" ) ){ |
klauss | 59:e1e300880d2d | 773 | miss_match = false; |
klauss | 59:e1e300880d2d | 774 | strcpy( debug_buf, "flood off" ); |
klauss | 59:e1e300880d2d | 775 | strcpy( tmp_cmd, debug_buf ); |
klauss | 114:472502b31a12 | 776 | }else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "++ ", 3 ) ){ |
klauss | 59:e1e300880d2d | 777 | miss_match = false; |
klauss | 65:0b653cfe95db | 778 | delayed_flood = true; |
klauss | 59:e1e300880d2d | 779 | int ext = atoi( debug_buf + 3 ); |
klauss | 59:e1e300880d2d | 780 | sprintf( debug_buf, "pcb %i flood on", ext ); |
klauss | 114:472502b31a12 | 781 | }else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "-- ", 3 ) ){ |
klauss | 59:e1e300880d2d | 782 | miss_match = false; |
klauss | 59:e1e300880d2d | 783 | int ext = atoi( debug_buf + 3 ); |
klauss | 114:472502b31a12 | 784 | if( debug_uart3 ) pc.printf("\n\rFlood OFF\n\r"); |
klauss | 114:472502b31a12 | 785 | if( from_eth ){ |
klauss | 59:e1e300880d2d | 786 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood OFF\n\r" ); |
klauss | 114:472502b31a12 | 787 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 59:e1e300880d2d | 788 | } |
klauss | 59:e1e300880d2d | 789 | pflood = 0; |
klauss | 59:e1e300880d2d | 790 | tflood.stop(); |
klauss | 59:e1e300880d2d | 791 | flood_timeout.reset(); |
klauss | 114:472502b31a12 | 792 | sprintf( debug_buf, "pcb %i flood off", ext ); |
klauss | 45:c80574f24dc3 | 793 | } |
klauss | 114:472502b31a12 | 794 | |
klauss | 48:195c97f12e8e | 795 | //tratamento dos enters |
klauss | 114:472502b31a12 | 796 | if( !bufptr ){ |
klauss | 45:c80574f24dc3 | 797 | miss_match = false; |
klauss | 114:472502b31a12 | 798 | }else if( bufptr == 1 ) { |
klauss | 48:195c97f12e8e | 799 | if( debug_buf[ 0 ] == 0x0D || debug_buf[ 0 ] == 0x0D ) miss_match = false; |
klauss | 48:195c97f12e8e | 800 | } |
klauss | 114:472502b31a12 | 801 | |
klauss | 114:472502b31a12 | 802 | if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ifconfig" ) ){ |
klauss | 45:c80574f24dc3 | 803 | miss_match = false; |
klauss | 114:472502b31a12 | 804 | if( debug_uart3 ) pc.printf("\n\r"); |
klauss | 45:c80574f24dc3 | 805 | files('s'); |
klauss | 45:c80574f24dc3 | 806 | } |
klauss | 114:472502b31a12 | 807 | |
klauss | 114:472502b31a12 | 808 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "rx" ) ){ |
klauss | 62:07e5bdc9f8f7 | 809 | miss_match = false; |
klauss | 62:07e5bdc9f8f7 | 810 | rx = true; |
klauss | 62:07e5bdc9f8f7 | 811 | } |
klauss | 114:472502b31a12 | 812 | |
klauss | 114:472502b31a12 | 813 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "tx" ) ){ |
klauss | 63:0d95da692bb4 | 814 | miss_match = false; |
klauss | 63:0d95da692bb4 | 815 | tx = true; |
klauss | 63:0d95da692bb4 | 816 | } |
klauss | 114:472502b31a12 | 817 | |
klauss | 114:472502b31a12 | 818 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "stats" ) ){ |
klauss | 63:0d95da692bb4 | 819 | miss_match = false; |
klauss | 63:0d95da692bb4 | 820 | stats = true; |
klauss | 114:472502b31a12 | 821 | } |
klauss | 114:472502b31a12 | 822 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_stats" ) ){ |
klauss | 63:0d95da692bb4 | 823 | miss_match = false; |
klauss | 63:0d95da692bb4 | 824 | r_stats = true; |
klauss | 63:0d95da692bb4 | 825 | } |
klauss | 114:472502b31a12 | 826 | |
klauss | 114:472502b31a12 | 827 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "rtp" ) ) { |
klauss | 114:472502b31a12 | 828 | miss_match = false; |
klauss | 114:472502b31a12 | 829 | dshow_rtp = true; |
klauss | 114:472502b31a12 | 830 | } |
klauss | 114:472502b31a12 | 831 | |
klauss | 114:472502b31a12 | 832 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "callrtp" ) ) { |
klauss | 45:c80574f24dc3 | 833 | miss_match = false; |
klauss | 114:472502b31a12 | 834 | dcallshow_rtp = true; |
klauss | 114:472502b31a12 | 835 | } |
klauss | 114:472502b31a12 | 836 | |
klauss | 114:472502b31a12 | 837 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "format" ) ){ |
klauss | 114:472502b31a12 | 838 | miss_match = false; |
klauss | 114:472502b31a12 | 839 | if( debug_uart3 ) pc.printf("\n\rFormatando o sistema de arquivos... espere o sistema reiniciar\n\r"); |
klauss | 114:472502b31a12 | 840 | |
klauss | 114:472502b31a12 | 841 | if( from_eth ){ |
klauss | 114:472502b31a12 | 842 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Not Allowed\n\r"); |
klauss | 114:472502b31a12 | 843 | }else{ |
klauss | 62:07e5bdc9f8f7 | 844 | files('e'); |
klauss | 62:07e5bdc9f8f7 | 845 | files('w'); |
klauss | 62:07e5bdc9f8f7 | 846 | __disable_irq(); |
klauss | 62:07e5bdc9f8f7 | 847 | NVIC_SystemReset(); |
klauss | 42:480335bdde12 | 848 | } |
klauss | 45:c80574f24dc3 | 849 | } |
klauss | 45:c80574f24dc3 | 850 | |
klauss | 59:e1e300880d2d | 851 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ipset ", 6 )) { |
klauss | 45:c80574f24dc3 | 852 | miss_match = false; |
klauss | 54:448d57291be6 | 853 | set_ip( debug_buf + 6 ); |
klauss | 45:c80574f24dc3 | 854 | files('s'); |
klauss | 45:c80574f24dc3 | 855 | } |
klauss | 109:a5b8264ffbbc | 856 | |
klauss | 114:472502b31a12 | 857 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "extset ", 7 ) ){ |
klauss | 45:c80574f24dc3 | 858 | miss_match = false; |
klauss | 55:2f5e7374af9d | 859 | set_header_ext( atoi( debug_buf + 7 ) ); |
klauss | 45:c80574f24dc3 | 860 | files('s'); |
klauss | 45:c80574f24dc3 | 861 | } |
klauss | 114:472502b31a12 | 862 | |
klauss | 114:472502b31a12 | 863 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serextset ", 10 ) ){ |
klauss | 45:c80574f24dc3 | 864 | miss_match = false; |
klauss | 55:2f5e7374af9d | 865 | set_server_ext( atoi( debug_buf + 10 ) ); |
klauss | 45:c80574f24dc3 | 866 | files('s'); |
klauss | 45:c80574f24dc3 | 867 | } |
klauss | 45:c80574f24dc3 | 868 | |
klauss | 114:472502b31a12 | 869 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "maskset ",8 ) ){ |
klauss | 45:c80574f24dc3 | 870 | miss_match = false; |
klauss | 55:2f5e7374af9d | 871 | set_mask( debug_buf + 8 ); |
klauss | 45:c80574f24dc3 | 872 | files('s'); |
klauss | 45:c80574f24dc3 | 873 | } |
klauss | 45:c80574f24dc3 | 874 | |
klauss | 114:472502b31a12 | 875 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "gatewayset ",11 ) ){ |
klauss | 45:c80574f24dc3 | 876 | miss_match = false; |
klauss | 55:2f5e7374af9d | 877 | set_gateway( debug_buf + 11 ); |
klauss | 45:c80574f24dc3 | 878 | files('s'); |
klauss | 45:c80574f24dc3 | 879 | } |
klauss | 45:c80574f24dc3 | 880 | |
klauss | 114:472502b31a12 | 881 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "msipport ",9 ) ){ |
klauss | 45:c80574f24dc3 | 882 | miss_match = false; |
klauss | 55:2f5e7374af9d | 883 | set_header_sip_port( atoi( debug_buf + 9 ) ); |
klauss | 45:c80574f24dc3 | 884 | files('s'); |
klauss | 45:c80574f24dc3 | 885 | } |
klauss | 45:c80574f24dc3 | 886 | |
klauss | 114:472502b31a12 | 887 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serverip ",9 ) ){ |
klauss | 45:c80574f24dc3 | 888 | miss_match = false; |
klauss | 55:2f5e7374af9d | 889 | set_server_ip( debug_buf + 9 ); |
klauss | 45:c80574f24dc3 | 890 | files('s'); |
klauss | 45:c80574f24dc3 | 891 | } |
klauss | 114:472502b31a12 | 892 | |
klauss | 114:472502b31a12 | 893 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "maxext ", 7 ) ){ |
klauss | 81:3656f00ab3db | 894 | miss_match = false; |
klauss | 81:3656f00ab3db | 895 | set_max_ext( atoi( debug_buf + 7 ) ); |
klauss | 81:3656f00ab3db | 896 | files('s'); |
klauss | 81:3656f00ab3db | 897 | } |
klauss | 114:472502b31a12 | 898 | |
klauss | 114:472502b31a12 | 899 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "minext ", 7 ) ){ |
klauss | 81:3656f00ab3db | 900 | miss_match = false; |
klauss | 81:3656f00ab3db | 901 | set_min_ext( atoi( debug_buf + 7 ) ); |
klauss | 81:3656f00ab3db | 902 | files('s'); |
klauss | 81:3656f00ab3db | 903 | } |
klauss | 45:c80574f24dc3 | 904 | |
klauss | 114:472502b31a12 | 905 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ssport ", 7 ) ){ |
klauss | 45:c80574f24dc3 | 906 | miss_match = false; |
klauss | 55:2f5e7374af9d | 907 | set_server_port( atoi( debug_buf + 7 ) ); |
klauss | 45:c80574f24dc3 | 908 | files('s'); |
klauss | 45:c80574f24dc3 | 909 | } |
klauss | 117:e9facba9db27 | 910 | |
klauss | 117:e9facba9db27 | 911 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "telemetry_ip ", 13 ) ){ |
klauss | 117:e9facba9db27 | 912 | miss_match = false; |
klauss | 117:e9facba9db27 | 913 | set_telemetry_ip( debug_buf + 13 ); |
klauss | 117:e9facba9db27 | 914 | files('s'); |
klauss | 117:e9facba9db27 | 915 | } |
klauss | 117:e9facba9db27 | 916 | |
klauss | 117:e9facba9db27 | 917 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "telemetry_port ", 15 ) ){ |
klauss | 117:e9facba9db27 | 918 | miss_match = false; |
klauss | 117:e9facba9db27 | 919 | set_telemetry_port( atoi( debug_buf + 15 ) ); |
klauss | 117:e9facba9db27 | 920 | files('s'); |
klauss | 117:e9facba9db27 | 921 | } |
klauss | 114:472502b31a12 | 922 | |
klauss | 114:472502b31a12 | 923 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "fw_ip ", 6 ) ){ |
klauss | 99:e80850c51106 | 924 | miss_match = false; |
klauss | 99:e80850c51106 | 925 | set_fw_ip( debug_buf + 6 ); |
klauss | 99:e80850c51106 | 926 | files('s'); |
klauss | 99:e80850c51106 | 927 | } |
klauss | 114:472502b31a12 | 928 | |
klauss | 114:472502b31a12 | 929 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "fw_port ", 8 ) ){ |
klauss | 99:e80850c51106 | 930 | miss_match = false; |
klauss | 99:e80850c51106 | 931 | set_fw_port( atoi( debug_buf + 8 ) ); |
klauss | 99:e80850c51106 | 932 | files('s'); |
klauss | 99:e80850c51106 | 933 | } |
klauss | 114:472502b31a12 | 934 | |
klauss | 114:472502b31a12 | 935 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dconfig" ) ){ |
klauss | 113:db67ae00550e | 936 | miss_match = false; |
klauss | 114:472502b31a12 | 937 | /* |
klauss | 50:d9b6577a70f5 | 938 | files('e'); |
klauss | 45:c80574f24dc3 | 939 | files('w'); |
klauss | 45:c80574f24dc3 | 940 | files('s'); |
klauss | 114:472502b31a12 | 941 | */ |
klauss | 45:c80574f24dc3 | 942 | } |
klauss | 45:c80574f24dc3 | 943 | |
klauss | 117:e9facba9db27 | 944 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset" ) ){ |
klauss | 45:c80574f24dc3 | 945 | miss_match = false; |
klauss | 117:e9facba9db27 | 946 | if( debug_uart3 ) pc.printf("\n\rJob is done\n\r"); |
klauss | 117:e9facba9db27 | 947 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 948 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Job is done\n\r"); |
klauss | 45:c80574f24dc3 | 949 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 117:e9facba9db27 | 950 | if( tcp_session ){ |
klauss | 45:c80574f24dc3 | 951 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 952 | tcp_client.close(); |
klauss | 117:e9facba9db27 | 953 | }else if( udp_request ){ |
klauss | 117:e9facba9db27 | 954 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 42:480335bdde12 | 955 | } |
klauss | 45:c80574f24dc3 | 956 | } |
klauss | 48:195c97f12e8e | 957 | __disable_irq(); |
klauss | 45:c80574f24dc3 | 958 | NVIC_SystemReset(); |
klauss | 45:c80574f24dc3 | 959 | } |
klauss | 45:c80574f24dc3 | 960 | |
klauss | 114:472502b31a12 | 961 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dog" ) ){ |
klauss | 45:c80574f24dc3 | 962 | miss_match = false; |
klauss | 114:472502b31a12 | 963 | if( debug_uart3 ) pc.printf("\n\r MUUUUUUUuuuuUUUUUU - I'm not a dog!!!! \n\r"); |
klauss | 114:472502b31a12 | 964 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 965 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "MUUUUUUUuuuuUUUUUU - I'm not a dog!!!!\n\r"); |
klauss | 114:472502b31a12 | 966 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 967 | } |
klauss | 45:c80574f24dc3 | 968 | } |
klauss | 108:18a3702650f3 | 969 | |
klauss | 114:472502b31a12 | 970 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dep" ) ){ |
klauss | 105:a930035b6556 | 971 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 972 | drop_entendi_pkg = !drop_entendi_pkg; |
klauss | 109:a5b8264ffbbc | 973 | if ( drop_entendi_pkg ) |
klauss | 109:a5b8264ffbbc | 974 | { |
klauss | 112:6ae726539ab9 | 975 | debug_msg ("Entendi pkgs will be droped"); |
klauss | 109:a5b8264ffbbc | 976 | } |
klauss | 109:a5b8264ffbbc | 977 | else |
klauss | 109:a5b8264ffbbc | 978 | { |
klauss | 112:6ae726539ab9 | 979 | debug_msg ("Entendi pkgs don't will be droped"); |
klauss | 109:a5b8264ffbbc | 980 | } |
klauss | 105:a930035b6556 | 981 | } |
klauss | 105:a930035b6556 | 982 | |
klauss | 109:a5b8264ffbbc | 983 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dita" ) ){ |
klauss | 97:8985817e8847 | 984 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 985 | drop_invite_to_ast_pkg = !drop_invite_to_ast_pkg; |
klauss | 109:a5b8264ffbbc | 986 | if ( drop_invite_to_ast_pkg ) |
klauss | 109:a5b8264ffbbc | 987 | { |
klauss | 109:a5b8264ffbbc | 988 | debug_msg ("Invite pkgs to ast will be droped"); |
klauss | 64:5b011d5707d2 | 989 | } |
klauss | 109:a5b8264ffbbc | 990 | else |
klauss | 109:a5b8264ffbbc | 991 | { |
klauss | 109:a5b8264ffbbc | 992 | debug_msg ("Invite pkgs to ast don't will be droped"); |
klauss | 64:5b011d5707d2 | 993 | } |
klauss | 64:5b011d5707d2 | 994 | } |
klauss | 105:a930035b6556 | 995 | |
klauss | 109:a5b8264ffbbc | 996 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dop" ) ){ |
klauss | 109:a5b8264ffbbc | 997 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 998 | drop_ok_pkg = !drop_ok_pkg; |
klauss | 109:a5b8264ffbbc | 999 | if ( drop_ok_pkg ) |
klauss | 109:a5b8264ffbbc | 1000 | { |
klauss | 109:a5b8264ffbbc | 1001 | debug_msg ("Ok pkgs will be droped"); |
klauss | 45:c80574f24dc3 | 1002 | } |
klauss | 109:a5b8264ffbbc | 1003 | else |
klauss | 109:a5b8264ffbbc | 1004 | { |
klauss | 109:a5b8264ffbbc | 1005 | debug_msg ("Ok pkgs don't will be droped"); |
klauss | 61:06e77dff6f00 | 1006 | } |
klauss | 109:a5b8264ffbbc | 1007 | } |
klauss | 105:a930035b6556 | 1008 | |
klauss | 109:a5b8264ffbbc | 1009 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dip" ) ){ |
klauss | 60:b4ec6beb3be3 | 1010 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1011 | drop_invite_pkg = !drop_invite_pkg; |
klauss | 109:a5b8264ffbbc | 1012 | if ( drop_invite_pkg ) |
klauss | 109:a5b8264ffbbc | 1013 | { |
klauss | 109:a5b8264ffbbc | 1014 | debug_msg ("invite pkgs from cbx will be droped"); |
klauss | 109:a5b8264ffbbc | 1015 | } |
klauss | 109:a5b8264ffbbc | 1016 | else |
klauss | 109:a5b8264ffbbc | 1017 | { |
klauss | 109:a5b8264ffbbc | 1018 | debug_msg ("invite pkgs from cbx don't will be droped"); |
klauss | 48:195c97f12e8e | 1019 | } |
klauss | 114:472502b31a12 | 1020 | |
klauss | 109:a5b8264ffbbc | 1021 | } |
klauss | 109:a5b8264ffbbc | 1022 | |
klauss | 109:a5b8264ffbbc | 1023 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dap" ) ){ |
klauss | 109:a5b8264ffbbc | 1024 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1025 | drop_ack_pkg = !drop_ack_pkg; |
klauss | 109:a5b8264ffbbc | 1026 | if ( drop_ack_pkg ) |
klauss | 109:a5b8264ffbbc | 1027 | { |
klauss | 109:a5b8264ffbbc | 1028 | debug_msg ("ack pkgs will be droped"); |
klauss | 109:a5b8264ffbbc | 1029 | } |
klauss | 109:a5b8264ffbbc | 1030 | else |
klauss | 109:a5b8264ffbbc | 1031 | { |
klauss | 109:a5b8264ffbbc | 1032 | debug_msg ("ack pkgs don't will be droped"); |
klauss | 114:472502b31a12 | 1033 | } |
klauss | 114:472502b31a12 | 1034 | |
klauss | 45:c80574f24dc3 | 1035 | } |
klauss | 105:a930035b6556 | 1036 | |
klauss | 109:a5b8264ffbbc | 1037 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "drfa" ) ){ |
klauss | 109:a5b8264ffbbc | 1038 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1039 | drop_rtp_from_ast_pkg = !drop_rtp_from_ast_pkg; |
klauss | 109:a5b8264ffbbc | 1040 | if ( drop_rtp_from_ast_pkg ) |
klauss | 109:a5b8264ffbbc | 1041 | { |
klauss | 109:a5b8264ffbbc | 1042 | debug_msg ("rtp pkgs from ast don't will be droped"); |
klauss | 42:480335bdde12 | 1043 | } |
klauss | 109:a5b8264ffbbc | 1044 | else |
klauss | 109:a5b8264ffbbc | 1045 | { |
klauss | 109:a5b8264ffbbc | 1046 | debug_msg ("rtp pkgs from ast don't will be droped"); |
klauss | 78:1353744f01e1 | 1047 | } |
klauss | 117:e9facba9db27 | 1048 | |
klauss | 114:472502b31a12 | 1049 | } |
klauss | 114:472502b31a12 | 1050 | |
klauss | 117:e9facba9db27 | 1051 | |
klauss | 109:a5b8264ffbbc | 1052 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "drfc" ) ){ |
klauss | 109:a5b8264ffbbc | 1053 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1054 | drop_rtp_from_cbx_pkg = !drop_rtp_from_cbx_pkg; |
klauss | 109:a5b8264ffbbc | 1055 | if ( drop_rtp_from_cbx_pkg ) |
klauss | 109:a5b8264ffbbc | 1056 | { |
klauss | 109:a5b8264ffbbc | 1057 | debug_msg ("rtp pkgs from cbx will be droped"); |
klauss | 109:a5b8264ffbbc | 1058 | } |
klauss | 109:a5b8264ffbbc | 1059 | else |
klauss | 109:a5b8264ffbbc | 1060 | { |
klauss | 109:a5b8264ffbbc | 1061 | debug_msg ("rtp pkgs from cbx don't will be droped"); |
klauss | 117:e9facba9db27 | 1062 | } |
klauss | 117:e9facba9db27 | 1063 | |
klauss | 109:a5b8264ffbbc | 1064 | } |
klauss | 114:472502b31a12 | 1065 | |
klauss | 114:472502b31a12 | 1066 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ftq" ) ){ |
klauss | 109:a5b8264ffbbc | 1067 | miss_match = false; |
klauss | 114:472502b31a12 | 1068 | if( debug_uart3 ) pc.printf( "\n\rFTQ ON\n\r" ); |
klauss | 114:472502b31a12 | 1069 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1070 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FTQ On\n\r" ); |
klauss | 114:472502b31a12 | 1071 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 114:472502b31a12 | 1072 | } |
klauss | 114:472502b31a12 | 1073 | big_bug_pkg = true; |
klauss | 109:a5b8264ffbbc | 1074 | } |
klauss | 114:472502b31a12 | 1075 | |
klauss | 114:472502b31a12 | 1076 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ktq" ) ){ |
klauss | 109:a5b8264ffbbc | 1077 | miss_match = false; |
klauss | 114:472502b31a12 | 1078 | if( debug_uart3 ) pc.printf( "\n\rFTQ!!!\n\r" ); |
klauss | 114:472502b31a12 | 1079 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1080 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FTQ!!!\n\r" ); |
klauss | 114:472502b31a12 | 1081 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 114:472502b31a12 | 1082 | } |
klauss | 114:472502b31a12 | 1083 | flood_bug_pkg = !flood_bug_pkg; |
klauss | 109:a5b8264ffbbc | 1084 | } |
klauss | 114:472502b31a12 | 1085 | |
klauss | 114:472502b31a12 | 1086 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ls" ) ){ |
klauss | 109:a5b8264ffbbc | 1087 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1088 | list = true; |
klauss | 109:a5b8264ffbbc | 1089 | } |
klauss | 114:472502b31a12 | 1090 | |
klauss | 114:472502b31a12 | 1091 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drtp ", 5 ) ) { |
klauss | 114:472502b31a12 | 1092 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ) { |
klauss | 114:472502b31a12 | 1093 | miss_match = false; |
klauss | 114:472502b31a12 | 1094 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rRtp Debug ON\n\r" ); |
klauss | 114:472502b31a12 | 1095 | if( from_eth ) { |
klauss | 114:472502b31a12 | 1096 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Rtp Debug On\n\r"); |
klauss | 114:472502b31a12 | 1097 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 114:472502b31a12 | 1098 | if( tcp_session ) { |
klauss | 114:472502b31a12 | 1099 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 114:472502b31a12 | 1100 | } |
klauss | 114:472502b31a12 | 1101 | } |
klauss | 114:472502b31a12 | 1102 | debug_rtp = true; |
klauss | 114:472502b31a12 | 1103 | } |
klauss | 114:472502b31a12 | 1104 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "off", 3 ) ){ |
klauss | 114:472502b31a12 | 1105 | miss_match = false; |
klauss | 114:472502b31a12 | 1106 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rRtp Debug OFF\n\r" ); |
klauss | 114:472502b31a12 | 1107 | if( from_eth ) { |
klauss | 114:472502b31a12 | 1108 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Rtp Debug Off\n\r"); |
klauss | 114:472502b31a12 | 1109 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 114:472502b31a12 | 1110 | if( tcp_session ) { |
klauss | 114:472502b31a12 | 1111 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 114:472502b31a12 | 1112 | } |
klauss | 114:472502b31a12 | 1113 | } |
klauss | 114:472502b31a12 | 1114 | debug_rtp = false; |
klauss | 114:472502b31a12 | 1115 | } |
klauss | 107:cf1e43414adb | 1116 | } |
klauss | 107:cf1e43414adb | 1117 | |
klauss | 109:a5b8264ffbbc | 1118 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "deleted" ) ) { |
klauss | 109:a5b8264ffbbc | 1119 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1120 | send_msg("::%d::", deleted_sip ); |
klauss | 109:a5b8264ffbbc | 1121 | } |
klauss | 109:a5b8264ffbbc | 1122 | |
klauss | 109:a5b8264ffbbc | 1123 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "print_v_cb" ) ) { |
klauss | 109:a5b8264ffbbc | 1124 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1125 | print_v_cb = true; |
klauss | 109:a5b8264ffbbc | 1126 | } |
klauss | 109:a5b8264ffbbc | 1127 | |
klauss | 109:a5b8264ffbbc | 1128 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "print_v_call" ) ) { |
klauss | 109:a5b8264ffbbc | 1129 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1130 | print_v_call = true; |
klauss | 109:a5b8264ffbbc | 1131 | } |
klauss | 109:a5b8264ffbbc | 1132 | |
klauss | 109:a5b8264ffbbc | 1133 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ls -l" ) ){ |
klauss | 109:a5b8264ffbbc | 1134 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1135 | long_list = true; |
klauss | 109:a5b8264ffbbc | 1136 | } |
klauss | 109:a5b8264ffbbc | 1137 | |
klauss | 109:a5b8264ffbbc | 1138 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "tt" ) ){ |
klauss | 109:a5b8264ffbbc | 1139 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1140 | main_test = !main_test; |
klauss | 109:a5b8264ffbbc | 1141 | } |
klauss | 109:a5b8264ffbbc | 1142 | |
klauss | 112:6ae726539ab9 | 1143 | |
klauss | 112:6ae726539ab9 | 1144 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "cogumelo" ) ){ |
klauss | 112:6ae726539ab9 | 1145 | miss_match = false; |
klauss | 112:6ae726539ab9 | 1146 | cogumelo = true; |
klauss | 112:6ae726539ab9 | 1147 | } |
klauss | 112:6ae726539ab9 | 1148 | |
klauss | 112:6ae726539ab9 | 1149 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "registra" ) ){ |
klauss | 112:6ae726539ab9 | 1150 | miss_match = false; |
klauss | 112:6ae726539ab9 | 1151 | registra = true; |
klauss | 112:6ae726539ab9 | 1152 | } |
klauss | 112:6ae726539ab9 | 1153 | |
klauss | 112:6ae726539ab9 | 1154 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "gnomo" ) ){ |
klauss | 112:6ae726539ab9 | 1155 | miss_match = false; |
klauss | 112:6ae726539ab9 | 1156 | gnomo = true; |
klauss | 112:6ae726539ab9 | 1157 | } |
klauss | 112:6ae726539ab9 | 1158 | |
klauss | 109:a5b8264ffbbc | 1159 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "tango" ) ){ |
klauss | 109:a5b8264ffbbc | 1160 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1161 | tango = !tango; |
klauss | 109:a5b8264ffbbc | 1162 | } |
klauss | 109:a5b8264ffbbc | 1163 | |
klauss | 109:a5b8264ffbbc | 1164 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "canada" ) ){ |
klauss | 109:a5b8264ffbbc | 1165 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1166 | canada = !canada; |
klauss | 109:a5b8264ffbbc | 1167 | } |
klauss | 109:a5b8264ffbbc | 1168 | |
klauss | 109:a5b8264ffbbc | 1169 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "america" ) ){ |
klauss | 109:a5b8264ffbbc | 1170 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1171 | america = !america; |
klauss | 109:a5b8264ffbbc | 1172 | } |
klauss | 109:a5b8264ffbbc | 1173 | |
klauss | 109:a5b8264ffbbc | 1174 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "york" ) ){ |
klauss | 109:a5b8264ffbbc | 1175 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1176 | york = !york; |
klauss | 109:a5b8264ffbbc | 1177 | } |
klauss | 109:a5b8264ffbbc | 1178 | |
klauss | 109:a5b8264ffbbc | 1179 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "chicago" ) ){ |
klauss | 109:a5b8264ffbbc | 1180 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1181 | chicago = !chicago; |
klauss | 109:a5b8264ffbbc | 1182 | } |
klauss | 114:472502b31a12 | 1183 | |
klauss | 114:472502b31a12 | 1184 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "show_sip" ) ){ |
klauss | 114:472502b31a12 | 1185 | miss_match = false; |
klauss | 114:472502b31a12 | 1186 | show_sip = true; |
klauss | 114:472502b31a12 | 1187 | } |
klauss | 114:472502b31a12 | 1188 | |
klauss | 114:472502b31a12 | 1189 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_cks" ) ){ |
klauss | 114:472502b31a12 | 1190 | miss_match = false; |
klauss | 114:472502b31a12 | 1191 | reset_cks = true; |
klauss | 114:472502b31a12 | 1192 | } |
klauss | 114:472502b31a12 | 1193 | |
klauss | 114:472502b31a12 | 1194 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "malasia" ) ){ |
klauss | 114:472502b31a12 | 1195 | miss_match = false; |
klauss | 114:472502b31a12 | 1196 | malasia = !malasia; |
klauss | 114:472502b31a12 | 1197 | } |
klauss | 114:472502b31a12 | 1198 | |
klauss | 114:472502b31a12 | 1199 | //replaced by ls |
klauss | 114:472502b31a12 | 1200 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "status" ) ){ |
klauss | 109:a5b8264ffbbc | 1201 | miss_match = false; |
klauss | 114:472502b31a12 | 1202 | list = true; |
klauss | 114:472502b31a12 | 1203 | } |
klauss | 114:472502b31a12 | 1204 | |
klauss | 114:472502b31a12 | 1205 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "wdt" ) ){ |
klauss | 114:472502b31a12 | 1206 | miss_match = false; |
klauss | 114:472502b31a12 | 1207 | debug_wdt = true; |
klauss | 114:472502b31a12 | 1208 | } |
klauss | 114:472502b31a12 | 1209 | |
klauss | 114:472502b31a12 | 1210 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "eth" ) ){ |
klauss | 114:472502b31a12 | 1211 | miss_match = false; |
klauss | 114:472502b31a12 | 1212 | debug_eth = true; |
klauss | 114:472502b31a12 | 1213 | } |
klauss | 114:472502b31a12 | 1214 | |
klauss | 114:472502b31a12 | 1215 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "types" ) ){ |
klauss | 114:472502b31a12 | 1216 | miss_match = false; |
klauss | 114:472502b31a12 | 1217 | |
klauss | 114:472502b31a12 | 1218 | if( debug_uart3 ) pc.printf( "\n\rhex :: dec :: Type \n\r0x00 :: 0 :: boot \n\r0x02 :: 2 :: registry \n\r0x04 :: 4 :: invite \n\r0x08 :: 8 :: audio \n\r0x10 :: 16 :: telemetry \n\r0x20 :: 32 :: cb_bye \n\r0x01 :: 1 :: prompt \n\r0x40 :: 64 :: flood \n\r" ); |
klauss | 114:472502b31a12 | 1219 | |
klauss | 114:472502b31a12 | 1220 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1221 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rhex :: dec :: Type \n\r0x00 :: 0 :: boot \n\r0x02 :: 2 :: registry \n\r0x04 :: 4 :: invite \n\r0x08 :: 8 :: audio \n\r0x10 :: 16 :: telemetry \n\r0x20 :: 32 :: cb_bye \n\r0x01 :: 1 :: prompt \n\r0x40 :: 64 :: flood \n\r" ); |
klauss | 114:472502b31a12 | 1222 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1223 | } |
klauss | 105:a930035b6556 | 1224 | } |
klauss | 114:472502b31a12 | 1225 | |
klauss | 114:472502b31a12 | 1226 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "protocol" ) ){ |
klauss | 109:a5b8264ffbbc | 1227 | miss_match = false; |
klauss | 114:472502b31a12 | 1228 | |
klauss | 117:e9facba9db27 | 1229 | if( debug_uart3 ) pc.printf( "\n\r| E | E | P | P | C | C | T | [ Seq_num | Audio ] | 14[ Clock | Audio ] | [ TS | Audio ] | ... |\n\r \n\rE = Ext = Ramal\n\r \n\rP = Port = Porta\n\r \n\rC = Checksum\n\r \n\rT = Type = Tipo\n\r \n\rSeq_num = Sequence Number = Numero de sequencia\n\r \n\rClock = 14 bytes to sync\n\r \n\r... = demais __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__ bytes\n\r" ); |
klauss | 114:472502b31a12 | 1230 | |
klauss | 114:472502b31a12 | 1231 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 1232 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\r| E | E | P | P | C | C | T | [ Seq_num | Audio ] | 14[ Clock | Audio ] | [ TS | Audio ] | ... |\n\r \n\rE = Ext = Ramal\n\r \n\rP = Port = Porta\n\r \n\rC = Checksum\n\r \n\rT = Type = Tipo\n\r \n\rSeq_num = Sequence Number = Numero de sequencia\n\r \n\rClock = 14 bytes to sync\n\r \n\r... = demais __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__ bytes\n\r" ); |
klauss | 114:472502b31a12 | 1233 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 1234 | } |
klauss | 109:a5b8264ffbbc | 1235 | } |
klauss | 114:472502b31a12 | 1236 | |
klauss | 114:472502b31a12 | 1237 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "flood ", 6 ) ){ |
klauss | 114:472502b31a12 | 1238 | if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on", 2 ) ){ |
klauss | 109:a5b8264ffbbc | 1239 | miss_match = false; |
klauss | 114:472502b31a12 | 1240 | if( debug_uart3 ) pc.printf("\n\rFlood ON\n\r"); |
klauss | 114:472502b31a12 | 1241 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1242 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r" ); |
klauss | 109:a5b8264ffbbc | 1243 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 114:472502b31a12 | 1244 | } |
klauss | 109:a5b8264ffbbc | 1245 | tflood.start(); |
klauss | 109:a5b8264ffbbc | 1246 | tflood.reset(); |
klauss | 109:a5b8264ffbbc | 1247 | floodcount =0; |
klauss | 109:a5b8264ffbbc | 1248 | pflood = 1; |
klauss | 109:a5b8264ffbbc | 1249 | flood_timeout.start(); |
klauss | 109:a5b8264ffbbc | 1250 | } |
klauss | 114:472502b31a12 | 1251 | |
klauss | 114:472502b31a12 | 1252 | if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "more", 4 ) ){ |
klauss | 109:a5b8264ffbbc | 1253 | miss_match = false; |
klauss | 114:472502b31a12 | 1254 | if( debug_uart3 ) pc.printf("\n\rFlood ON\n\r"); |
klauss | 114:472502b31a12 | 1255 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1256 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r" ); |
klauss | 114:472502b31a12 | 1257 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 1258 | } |
klauss | 109:a5b8264ffbbc | 1259 | tflood.start(); |
klauss | 109:a5b8264ffbbc | 1260 | tflood.reset(); |
klauss | 109:a5b8264ffbbc | 1261 | floodcount = 0; |
klauss | 109:a5b8264ffbbc | 1262 | pflood = 1; |
klauss | 109:a5b8264ffbbc | 1263 | } |
klauss | 114:472502b31a12 | 1264 | |
klauss | 109:a5b8264ffbbc | 1265 | if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "off", 3 )) { |
klauss | 104:62646ef786a3 | 1266 | miss_match = false; |
klauss | 114:472502b31a12 | 1267 | if( debug_uart3 ) pc.printf("\n\rFlood OFF\n\r"); |
klauss | 114:472502b31a12 | 1268 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1269 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood Off\n\r" ); |
klauss | 104:62646ef786a3 | 1270 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 1271 | } |
klauss | 109:a5b8264ffbbc | 1272 | pflood = 0; |
klauss | 109:a5b8264ffbbc | 1273 | tflood.stop(); |
klauss | 109:a5b8264ffbbc | 1274 | flood_timeout.reset(); |
klauss | 109:a5b8264ffbbc | 1275 | } |
klauss | 114:472502b31a12 | 1276 | }else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "silence ", 8 ) ){ |
klauss | 109:a5b8264ffbbc | 1277 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1278 | char *ref, *split; |
klauss | 114:472502b31a12 | 1279 | |
klauss | 109:a5b8264ffbbc | 1280 | strcpy( promptcb_last_cmd, debug_buf ); |
klauss | 114:472502b31a12 | 1281 | |
klauss | 114:472502b31a12 | 1282 | if( !( strcmp( debug_buf + 8, "-h" ) && strcmp( debug_buf + 8, "--help" ) ) ){ |
klauss | 114:472502b31a12 | 1283 | if( debug_uart3 ) pc.printf("\n\rUsage :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 "); |
klauss | 114:472502b31a12 | 1284 | |
klauss | 114:472502b31a12 | 1285 | if( tcp_session ){ |
klauss | 114:472502b31a12 | 1286 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "Usage :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 " ); |
klauss | 109:a5b8264ffbbc | 1287 | } |
klauss | 114:472502b31a12 | 1288 | }else{ |
klauss | 109:a5b8264ffbbc | 1289 | ref = debug_buf; |
klauss | 114:472502b31a12 | 1290 | |
klauss | 109:a5b8264ffbbc | 1291 | split = strtok( debug_buf + 8, " " ); |
klauss | 114:472502b31a12 | 1292 | |
klauss | 109:a5b8264ffbbc | 1293 | start_ext = atoi( split ); |
klauss | 114:472502b31a12 | 1294 | |
klauss | 109:a5b8264ffbbc | 1295 | split += strlen( split ) + 1; |
klauss | 114:472502b31a12 | 1296 | |
klauss | 109:a5b8264ffbbc | 1297 | end_ext = atoi( split ); |
klauss | 114:472502b31a12 | 1298 | |
klauss | 109:a5b8264ffbbc | 1299 | debug_buf = ref; |
klauss | 114:472502b31a12 | 1300 | |
klauss | 114:472502b31a12 | 1301 | if( start_ext < end_ext && ( end_ext - start_ext ) < 50 ){ |
klauss | 109:a5b8264ffbbc | 1302 | if( start_ext % 2 ) start_ext--; |
klauss | 109:a5b8264ffbbc | 1303 | if( !( end_ext % 2 ) ) end_ext++; |
klauss | 114:472502b31a12 | 1304 | |
klauss | 109:a5b8264ffbbc | 1305 | ext_count = start_ext; |
klauss | 109:a5b8264ffbbc | 1306 | flood_silence_timer.start(); |
klauss | 114:472502b31a12 | 1307 | }else{ |
klauss | 114:472502b31a12 | 1308 | if( debug_uart3 ) pc.printf("\n\rUsage Error :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 "); |
klauss | 114:472502b31a12 | 1309 | |
klauss | 114:472502b31a12 | 1310 | if( tcp_session ){ |
klauss | 114:472502b31a12 | 1311 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "Usage Error :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 " ); |
klauss | 105:a930035b6556 | 1312 | } |
klauss | 104:62646ef786a3 | 1313 | } |
klauss | 109:a5b8264ffbbc | 1314 | flood_silence = true; |
klauss | 104:62646ef786a3 | 1315 | } |
klauss | 104:62646ef786a3 | 1316 | } |
klauss | 114:472502b31a12 | 1317 | |
klauss | 114:472502b31a12 | 1318 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug ",6 ) ){ |
klauss | 109:a5b8264ffbbc | 1319 | if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on",2 )) { |
klauss | 109:a5b8264ffbbc | 1320 | miss_match = false; |
klauss | 114:472502b31a12 | 1321 | if( debug_uart3 ) pc.printf("\n\rDebug ON\n\r"); |
klauss | 114:472502b31a12 | 1322 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1323 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug On\n\r" ); |
klauss | 109:a5b8264ffbbc | 1324 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 1325 | } |
klauss | 109:a5b8264ffbbc | 1326 | debug_alive = true; |
klauss | 109:a5b8264ffbbc | 1327 | } |
klauss | 109:a5b8264ffbbc | 1328 | if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "off",3 )) { |
klauss | 109:a5b8264ffbbc | 1329 | miss_match = false; |
klauss | 114:472502b31a12 | 1330 | if( debug_uart3 ) pc.printf("\n\rDebug OFF\n\r"); |
klauss | 114:472502b31a12 | 1331 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1332 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Off\n\r" ); |
klauss | 109:a5b8264ffbbc | 1333 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 1334 | } |
klauss | 109:a5b8264ffbbc | 1335 | debug_alive = false; |
klauss | 109:a5b8264ffbbc | 1336 | } |
klauss | 114:472502b31a12 | 1337 | if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "show",4 ) ){ |
klauss | 100:09a23fcd3bdf | 1338 | miss_match = false; |
klauss | 114:472502b31a12 | 1339 | if( debug_uart3 ) pc.printf("\n\rdsip"); |
klauss | 114:472502b31a12 | 1340 | if( debug_uart3 ) pc.printf("\n\rdebug_alive"); |
klauss | 114:472502b31a12 | 1341 | if( debug_uart3 ) pc.printf("\n\rdebug_prompt"); |
klauss | 114:472502b31a12 | 1342 | if( debug_uart3 ) pc.printf("\n\rdebug_vector"); |
klauss | 114:472502b31a12 | 1343 | if( debug_uart3 ) pc.printf("\n\rdebug_cb"); |
klauss | 114:472502b31a12 | 1344 | if( debug_uart3 ) pc.printf("\n\rdebug_main"); |
klauss | 114:472502b31a12 | 1345 | if( debug_uart3 ) pc.printf("\n\rdcks"); |
klauss | 114:472502b31a12 | 1346 | if( debug_uart3 ) pc.printf("\n\rdebug_cb_rx"); |
klauss | 114:472502b31a12 | 1347 | if( debug_uart3 ) pc.printf("\n\rdebug_cb_tx*"); |
klauss | 114:472502b31a12 | 1348 | if( debug_uart3 ) pc.printf("\n\rdebug_eth_rx*"); |
klauss | 114:472502b31a12 | 1349 | if( debug_uart3 ) pc.printf("\n\rdebug_eth_tx*"); |
klauss | 114:472502b31a12 | 1350 | if( debug_uart3 ) pc.printf("\n\rdebug_file"); |
klauss | 109:a5b8264ffbbc | 1351 | |
klauss | 114:472502b31a12 | 1352 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1353 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rdsip \n\rdebug_alive \n\rdebug_prompt \n\rdebug_vector \n\rdebug_cb \n\rdebug_main \n\rdcks \n\rdebug_cb_rx \n\rdebug_cb_tx* \n\rdebug_eth_rx* \n\rdebug_eth_tx* \n\rdebug_file\n\r" ); |
klauss | 100:09a23fcd3bdf | 1354 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 1355 | } |
klauss | 109:a5b8264ffbbc | 1356 | } |
klauss | 109:a5b8264ffbbc | 1357 | } |
klauss | 114:472502b31a12 | 1358 | |
klauss | 114:472502b31a12 | 1359 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dsip ", 5 ) ){ |
klauss | 114:472502b31a12 | 1360 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ){ |
klauss | 109:a5b8264ffbbc | 1361 | miss_match = false; |
klauss | 114:472502b31a12 | 1362 | if( debug_uart3 ) pc.printf( "\n\rSip Debug ON\n\r" ); |
klauss | 114:472502b31a12 | 1363 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1364 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Sip Debug On\n\r" ); |
klauss | 109:a5b8264ffbbc | 1365 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 1366 | } |
klauss | 109:a5b8264ffbbc | 1367 | debug_sip = true; |
klauss | 109:a5b8264ffbbc | 1368 | } |
klauss | 109:a5b8264ffbbc | 1369 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) { |
klauss | 109:a5b8264ffbbc | 1370 | miss_match = false; |
klauss | 114:472502b31a12 | 1371 | if( debug_uart3 ) pc.printf( "\n\rSip Debug OFF\n\r" ); |
klauss | 114:472502b31a12 | 1372 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1373 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Sip Debug Off\n\r" ); |
klauss | 109:a5b8264ffbbc | 1374 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 1375 | } |
klauss | 109:a5b8264ffbbc | 1376 | debug_sip = false; |
klauss | 109:a5b8264ffbbc | 1377 | } |
klauss | 109:a5b8264ffbbc | 1378 | } |
klauss | 109:a5b8264ffbbc | 1379 | |
klauss | 114:472502b31a12 | 1380 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "duart ", 6 ) ){ |
klauss | 114:472502b31a12 | 1381 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ){ |
klauss | 109:a5b8264ffbbc | 1382 | miss_match = false; |
klauss | 114:472502b31a12 | 1383 | if( debug_uart3 ) pc.printf( "\n\rEnable UART3 usage\n\r" ); |
klauss | 114:472502b31a12 | 1384 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1385 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Dinable UART3 usage\n\r" ); |
klauss | 109:a5b8264ffbbc | 1386 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 100:09a23fcd3bdf | 1387 | } |
klauss | 100:09a23fcd3bdf | 1388 | debug_uart3 = true; |
klauss | 100:09a23fcd3bdf | 1389 | } |
klauss | 100:09a23fcd3bdf | 1390 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 )) { |
klauss | 100:09a23fcd3bdf | 1391 | miss_match = false; |
klauss | 114:472502b31a12 | 1392 | if( debug_uart3 ) pc.printf( "\n\rEnable UART3 usage\n\r" ); |
klauss | 114:472502b31a12 | 1393 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1394 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Dinable UART3 usage\n\r" ); |
klauss | 100:09a23fcd3bdf | 1395 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 100:09a23fcd3bdf | 1396 | } |
klauss | 100:09a23fcd3bdf | 1397 | debug_uart3 = false; |
klauss | 100:09a23fcd3bdf | 1398 | } |
klauss | 100:09a23fcd3bdf | 1399 | } |
klauss | 114:472502b31a12 | 1400 | |
klauss | 114:472502b31a12 | 1401 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dprint ", 7 ) ){ |
klauss | 114:472502b31a12 | 1402 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ |
klauss | 114:472502b31a12 | 1403 | miss_match = false; |
klauss | 114:472502b31a12 | 1404 | if( debug_uart3 ) pc.printf( "\n\rDebug print On\n\r" ); |
klauss | 114:472502b31a12 | 1405 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1406 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug print On\n\r" ); |
klauss | 114:472502b31a12 | 1407 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 114:472502b31a12 | 1408 | } |
klauss | 114:472502b31a12 | 1409 | print_values = true; |
klauss | 114:472502b31a12 | 1410 | } |
klauss | 114:472502b31a12 | 1411 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { |
klauss | 98:43b45f26b430 | 1412 | miss_match = false; |
klauss | 114:472502b31a12 | 1413 | if( debug_uart3 ) pc.printf( "\n\rDebug print Off\n\r" ); |
klauss | 114:472502b31a12 | 1414 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1415 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug print Off\n\r" ); |
klauss | 98:43b45f26b430 | 1416 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 114:472502b31a12 | 1417 | } |
klauss | 114:472502b31a12 | 1418 | print_values = false; |
klauss | 114:472502b31a12 | 1419 | } |
klauss | 114:472502b31a12 | 1420 | } |
klauss | 114:472502b31a12 | 1421 | |
klauss | 114:472502b31a12 | 1422 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dmatch ", 7 ) ){ |
klauss | 114:472502b31a12 | 1423 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ |
klauss | 114:472502b31a12 | 1424 | miss_match = false; |
klauss | 114:472502b31a12 | 1425 | if( debug_uart3 ) pc.printf( "\n\rPort Match Debug ON\n\r" ); |
klauss | 114:472502b31a12 | 1426 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1427 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Port Match Debug On\n\r" ); |
klauss | 114:472502b31a12 | 1428 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 98:43b45f26b430 | 1429 | } |
klauss | 98:43b45f26b430 | 1430 | debug_port_match = true; |
klauss | 98:43b45f26b430 | 1431 | } |
klauss | 98:43b45f26b430 | 1432 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { |
klauss | 98:43b45f26b430 | 1433 | miss_match = false; |
klauss | 114:472502b31a12 | 1434 | if( debug_uart3 ) pc.printf( "\n\rPort Match Debug OFF\n\r" ); |
klauss | 114:472502b31a12 | 1435 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1436 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Port Match Debug Off\n\r" ); |
klauss | 98:43b45f26b430 | 1437 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 98:43b45f26b430 | 1438 | } |
klauss | 98:43b45f26b430 | 1439 | debug_port_match = false; |
klauss | 98:43b45f26b430 | 1440 | } |
klauss | 98:43b45f26b430 | 1441 | } |
klauss | 114:472502b31a12 | 1442 | |
klauss | 114:472502b31a12 | 1443 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dmuted ", 7 ) ){ |
klauss | 114:472502b31a12 | 1444 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ |
klauss | 81:3656f00ab3db | 1445 | miss_match = false; |
klauss | 114:472502b31a12 | 1446 | if( debug_uart3 ) pc.printf( "\n\rMuted Debug ON\n\r" ); |
klauss | 114:472502b31a12 | 1447 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1448 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Muted Debug On\n\r" ); |
klauss | 81:3656f00ab3db | 1449 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1450 | } |
klauss | 81:3656f00ab3db | 1451 | debug_muted = true; |
klauss | 81:3656f00ab3db | 1452 | } |
klauss | 81:3656f00ab3db | 1453 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { |
klauss | 81:3656f00ab3db | 1454 | miss_match = false; |
klauss | 114:472502b31a12 | 1455 | if( debug_uart3 ) pc.printf( "\n\rMuted Debug OFF\n\r" ); |
klauss | 114:472502b31a12 | 1456 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1457 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Muted Debug Off\n\r" ); |
klauss | 81:3656f00ab3db | 1458 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1459 | } |
klauss | 81:3656f00ab3db | 1460 | debug_muted = false; |
klauss | 81:3656f00ab3db | 1461 | } |
klauss | 81:3656f00ab3db | 1462 | } |
klauss | 114:472502b31a12 | 1463 | |
klauss | 114:472502b31a12 | 1464 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dwdt ", 5 ) ){ |
klauss | 114:472502b31a12 | 1465 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ){ |
klauss | 81:3656f00ab3db | 1466 | miss_match = false; |
klauss | 114:472502b31a12 | 1467 | if( debug_uart3 ) pc.printf( "\n\rWdt Debug ON\n\r" ); |
klauss | 114:472502b31a12 | 1468 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1469 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wdt Debug On\n\r" ); |
klauss | 81:3656f00ab3db | 1470 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1471 | } |
klauss | 81:3656f00ab3db | 1472 | wdt_show = true; |
klauss | 81:3656f00ab3db | 1473 | } |
klauss | 81:3656f00ab3db | 1474 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) { |
klauss | 81:3656f00ab3db | 1475 | miss_match = false; |
klauss | 114:472502b31a12 | 1476 | if( debug_uart3 ) pc.printf( "\n\rWdt Debug OFF\n\r" ); |
klauss | 114:472502b31a12 | 1477 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1478 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wdt Debug Off\n\r" ); |
klauss | 81:3656f00ab3db | 1479 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1480 | } |
klauss | 81:3656f00ab3db | 1481 | wdt_show = false; |
klauss | 81:3656f00ab3db | 1482 | } |
klauss | 81:3656f00ab3db | 1483 | } |
klauss | 114:472502b31a12 | 1484 | |
klauss | 114:472502b31a12 | 1485 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drefresh ", 9 ) ){ |
klauss | 114:472502b31a12 | 1486 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "on", 2 ) ){ |
klauss | 81:3656f00ab3db | 1487 | miss_match = false; |
klauss | 114:472502b31a12 | 1488 | if( debug_uart3 ) pc.printf( "\n\rRefresh Debug ON\n\r" ); |
klauss | 114:472502b31a12 | 1489 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1490 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Refresh Debug On\n\r" ); |
klauss | 81:3656f00ab3db | 1491 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1492 | } |
klauss | 81:3656f00ab3db | 1493 | debug_refresh= true; |
klauss | 81:3656f00ab3db | 1494 | } |
klauss | 81:3656f00ab3db | 1495 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "off",3 )) { |
klauss | 81:3656f00ab3db | 1496 | miss_match = false; |
klauss | 114:472502b31a12 | 1497 | if( debug_uart3 ) pc.printf( "\n\rRefresh Debug OFF\n\r" ); |
klauss | 114:472502b31a12 | 1498 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1499 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Refresh Debug Off\n\r" ); |
klauss | 81:3656f00ab3db | 1500 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1501 | } |
klauss | 81:3656f00ab3db | 1502 | debug_refresh = false; |
klauss | 81:3656f00ab3db | 1503 | } |
klauss | 81:3656f00ab3db | 1504 | } |
klauss | 114:472502b31a12 | 1505 | |
klauss | 114:472502b31a12 | 1506 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dping ", 6 ) ){ |
klauss | 114:472502b31a12 | 1507 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1508 | miss_match = false; |
klauss | 114:472502b31a12 | 1509 | if( debug_uart3 ) pc.printf( "\n\rPing Debug ON\n\r" ); |
klauss | 114:472502b31a12 | 1510 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1511 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Ping Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1512 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1513 | } |
klauss | 78:1353744f01e1 | 1514 | debug_ping = true; |
klauss | 78:1353744f01e1 | 1515 | } |
klauss | 78:1353744f01e1 | 1516 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1517 | miss_match = false; |
klauss | 114:472502b31a12 | 1518 | if( debug_uart3 ) pc.printf( "\n\rPing Debug OFF\n\r" ); |
klauss | 114:472502b31a12 | 1519 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1520 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Ping Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1521 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1522 | } |
klauss | 78:1353744f01e1 | 1523 | debug_ping= false; |
klauss | 78:1353744f01e1 | 1524 | } |
klauss | 78:1353744f01e1 | 1525 | } |
klauss | 114:472502b31a12 | 1526 | |
klauss | 114:472502b31a12 | 1527 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dwu ", 4 ) ){ |
klauss | 114:472502b31a12 | 1528 | if (xmemmatch( (uint8_t*)(debug_buf + 4 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1529 | miss_match = false; |
klauss | 114:472502b31a12 | 1530 | if( debug_uart3 ) pc.printf( "\n\rWake Up Debug ON\n\r" ); |
klauss | 114:472502b31a12 | 1531 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1532 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wake Up Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1533 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1534 | } |
klauss | 78:1353744f01e1 | 1535 | debug_wake = true; |
klauss | 78:1353744f01e1 | 1536 | } |
klauss | 78:1353744f01e1 | 1537 | if (xmemmatch( (uint8_t*)(debug_buf + 4 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1538 | miss_match = false; |
klauss | 114:472502b31a12 | 1539 | if( debug_uart3 ) pc.printf( "\n\rWake Up Debug OFF\n\r" ); |
klauss | 114:472502b31a12 | 1540 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1541 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wake Up Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1542 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1543 | } |
klauss | 78:1353744f01e1 | 1544 | debug_wake = false; |
klauss | 78:1353744f01e1 | 1545 | } |
klauss | 78:1353744f01e1 | 1546 | } |
klauss | 114:472502b31a12 | 1547 | |
klauss | 114:472502b31a12 | 1548 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "tcp_alive ", 10 ) ){ |
klauss | 114:472502b31a12 | 1549 | if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1550 | miss_match = false; |
klauss | 114:472502b31a12 | 1551 | if( debug_uart3 ) pc.printf( "\n\rTCP don't drop mode on\n\r" ); |
klauss | 114:472502b31a12 | 1552 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1553 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "TCP don't drop mode on\n\r" ); |
klauss | 78:1353744f01e1 | 1554 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1555 | } |
klauss | 78:1353744f01e1 | 1556 | tcp_alive = true; |
klauss | 78:1353744f01e1 | 1557 | } |
klauss | 78:1353744f01e1 | 1558 | if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1559 | miss_match = false; |
klauss | 114:472502b31a12 | 1560 | if( debug_uart3 ) pc.printf( "\n\rTCP don't drop mode off\n\r" ); |
klauss | 114:472502b31a12 | 1561 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1562 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "TCP don't drop mode off\n\r" ); |
klauss | 78:1353744f01e1 | 1563 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1564 | } |
klauss | 78:1353744f01e1 | 1565 | tcp_alive = false; |
klauss | 78:1353744f01e1 | 1566 | } |
klauss | 78:1353744f01e1 | 1567 | } |
klauss | 114:472502b31a12 | 1568 | |
klauss | 114:472502b31a12 | 1569 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "daging ",7 ) ){ |
klauss | 114:472502b31a12 | 1570 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1571 | miss_match = false; |
klauss | 114:472502b31a12 | 1572 | if( debug_uart3 ) pc.printf( "\n\rAging Debug ON\n\r" ); |
klauss | 114:472502b31a12 | 1573 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1574 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Aging Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1575 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1576 | } |
klauss | 78:1353744f01e1 | 1577 | debug_aging = true; |
klauss | 78:1353744f01e1 | 1578 | } |
klauss | 78:1353744f01e1 | 1579 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1580 | miss_match = false; |
klauss | 114:472502b31a12 | 1581 | if( debug_uart3 ) pc.printf( "\n\rAging Debug OFF\n\r" ); |
klauss | 114:472502b31a12 | 1582 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1583 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Aging Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1584 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1585 | } |
klauss | 78:1353744f01e1 | 1586 | debug_aging = false; |
klauss | 78:1353744f01e1 | 1587 | } |
klauss | 78:1353744f01e1 | 1588 | } |
klauss | 114:472502b31a12 | 1589 | |
klauss | 114:472502b31a12 | 1590 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcpld ", 6 ) ){ |
klauss | 114:472502b31a12 | 1591 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1592 | miss_match = false; |
klauss | 114:472502b31a12 | 1593 | if( debug_uart3 ) pc.printf( "\n\rDCPLD Debug ON\n\r" ); |
klauss | 114:472502b31a12 | 1594 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1595 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "DCPLD Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1596 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1597 | } |
klauss | 78:1353744f01e1 | 1598 | debug_cpld = true; |
klauss | 78:1353744f01e1 | 1599 | } |
klauss | 114:472502b31a12 | 1600 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 ) ){ |
klauss | 78:1353744f01e1 | 1601 | miss_match = false; |
klauss | 114:472502b31a12 | 1602 | if( debug_uart3 ) pc.printf( "\n\rDCPLD Debug OFF\n\r" ); |
klauss | 114:472502b31a12 | 1603 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1604 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "DCPLD Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1605 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1606 | } |
klauss | 78:1353744f01e1 | 1607 | debug_cpld = false; |
klauss | 78:1353744f01e1 | 1608 | } |
klauss | 78:1353744f01e1 | 1609 | } |
klauss | 78:1353744f01e1 | 1610 | |
klauss | 114:472502b31a12 | 1611 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcks_err ", 9 ) ){ |
klauss | 114:472502b31a12 | 1612 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "on", 2 ) ){ |
klauss | 113:db67ae00550e | 1613 | miss_match = false; |
klauss | 114:472502b31a12 | 1614 | if( debug_uart3 ) pc.printf( "\n\rCKS_ERR Debug ON\n\r" ); |
klauss | 114:472502b31a12 | 1615 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1616 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS_ERR Debug On\n\r" ); |
klauss | 105:a930035b6556 | 1617 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1618 | } |
klauss | 78:1353744f01e1 | 1619 | debug_cks_err = true; |
klauss | 78:1353744f01e1 | 1620 | } |
klauss | 114:472502b31a12 | 1621 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "off", 3 ) ){ |
klauss | 78:1353744f01e1 | 1622 | miss_match = false; |
klauss | 114:472502b31a12 | 1623 | if( debug_uart3 ) pc.printf( "\n\rCKS_ERR Debug OFF\n\r" ); |
klauss | 114:472502b31a12 | 1624 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1625 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS_ERR Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1626 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1627 | } |
klauss | 78:1353744f01e1 | 1628 | debug_cks_err = false; |
klauss | 78:1353744f01e1 | 1629 | } |
klauss | 78:1353744f01e1 | 1630 | } |
klauss | 114:472502b31a12 | 1631 | |
klauss | 114:472502b31a12 | 1632 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dinvite ", 8 ) ){ |
klauss | 114:472502b31a12 | 1633 | if( xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1634 | miss_match = false; |
klauss | 114:472502b31a12 | 1635 | if( debug_uart3 ) pc.printf( "\n\rInvite Debug ON\n\r" ); |
klauss | 114:472502b31a12 | 1636 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1637 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Invite Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1638 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1639 | } |
klauss | 81:3656f00ab3db | 1640 | debug_invite = true; |
klauss | 78:1353744f01e1 | 1641 | } |
klauss | 78:1353744f01e1 | 1642 | if( xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1643 | miss_match = false; |
klauss | 114:472502b31a12 | 1644 | if( debug_uart3 ) pc.printf( "\n\rInvite Debug OFF\n\r" ); |
klauss | 114:472502b31a12 | 1645 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1646 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Invite Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1647 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1648 | } |
klauss | 78:1353744f01e1 | 1649 | debug_invite = 0; |
klauss | 45:c80574f24dc3 | 1650 | } |
klauss | 45:c80574f24dc3 | 1651 | } |
klauss | 114:472502b31a12 | 1652 | |
klauss | 114:472502b31a12 | 1653 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dparallel ", 10 ) ){ |
klauss | 114:472502b31a12 | 1654 | if( xmemmatch( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * )"on", 2 ) ){ |
klauss | 72:895ca792c647 | 1655 | miss_match = false; |
klauss | 114:472502b31a12 | 1656 | if( debug_uart3 ) pc.printf( "\n\rParallel Write Debug ON\n\r" ); |
klauss | 114:472502b31a12 | 1657 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1658 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rParallel Write Debug ON\n\r" ); |
klauss | 72:895ca792c647 | 1659 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 72:895ca792c647 | 1660 | } |
klauss | 72:895ca792c647 | 1661 | dparallel = true; |
klauss | 72:895ca792c647 | 1662 | } |
klauss | 72:895ca792c647 | 1663 | if( xmemmatch( ( uint8_t * )( debug_buf + 10 ), ( uint8_t *)"off", 3 )) { |
klauss | 72:895ca792c647 | 1664 | miss_match = false; |
klauss | 114:472502b31a12 | 1665 | if( debug_uart3 ) pc.printf( "\n\rParallel Write Debug OFF\n\r" ); |
klauss | 114:472502b31a12 | 1666 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1667 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rParallel Write Debug OFF\n\r" ); |
klauss | 72:895ca792c647 | 1668 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 72:895ca792c647 | 1669 | } |
klauss | 72:895ca792c647 | 1670 | dparallel = false; |
klauss | 72:895ca792c647 | 1671 | } |
klauss | 72:895ca792c647 | 1672 | } |
klauss | 114:472502b31a12 | 1673 | |
klauss | 117:e9facba9db27 | 1674 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dtelos ", 7 ) ){ |
klauss | 114:472502b31a12 | 1675 | if (xmemmatch( (uint8_t*)( debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ |
klauss | 53:bb492a8f115a | 1676 | miss_match = false; |
klauss | 114:472502b31a12 | 1677 | if( debug_uart3 ) pc.printf( "\n\rTelemetry Debug ON\n\r" ); |
klauss | 114:472502b31a12 | 1678 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1679 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\rTelemetry Debug On\n\r" ); |
klauss | 53:bb492a8f115a | 1680 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 53:bb492a8f115a | 1681 | } |
klauss | 53:bb492a8f115a | 1682 | debug_telemetry = true; |
klauss | 53:bb492a8f115a | 1683 | } |
klauss | 78:1353744f01e1 | 1684 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off", 3 )) { |
klauss | 53:bb492a8f115a | 1685 | miss_match = false; |
klauss | 114:472502b31a12 | 1686 | if( debug_uart3 ) pc.printf( "\n\rTelemetry Debug OFF\n\r" ); |
klauss | 114:472502b31a12 | 1687 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1688 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\rTelemetry Debug Off\n\r" ); |
klauss | 53:bb492a8f115a | 1689 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 53:bb492a8f115a | 1690 | } |
klauss | 53:bb492a8f115a | 1691 | debug_telemetry = false; |
klauss | 53:bb492a8f115a | 1692 | } |
klauss | 53:bb492a8f115a | 1693 | } |
klauss | 114:472502b31a12 | 1694 | |
klauss | 114:472502b31a12 | 1695 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcks ", 5 ) ){ |
klauss | 114:472502b31a12 | 1696 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on",2 ) ){ |
klauss | 45:c80574f24dc3 | 1697 | miss_match = false; |
klauss | 114:472502b31a12 | 1698 | if( debug_uart3 ) pc.printf( "\n\rCKS Debug ON\n\r" ); |
klauss | 114:472502b31a12 | 1699 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1700 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS Debug On\n\r" ); |
klauss | 45:c80574f24dc3 | 1701 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1702 | } |
klauss | 78:1353744f01e1 | 1703 | debug_cks = true; |
klauss | 45:c80574f24dc3 | 1704 | } |
klauss | 50:d9b6577a70f5 | 1705 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 1706 | miss_match = false; |
klauss | 114:472502b31a12 | 1707 | if( debug_uart3 ) pc.printf( "\n\rCKS Debug OFF\n\r" ); |
klauss | 114:472502b31a12 | 1708 | if( from_eth ){ |
klauss | 114:472502b31a12 | 1709 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS Debug Off\n\r" ); |
klauss | 45:c80574f24dc3 | 1710 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1711 | } |
klauss | 78:1353744f01e1 | 1712 | debug_cks = false; |
klauss | 45:c80574f24dc3 | 1713 | } |
klauss | 45:c80574f24dc3 | 1714 | } |
klauss | 114:472502b31a12 | 1715 | |
klauss | 117:e9facba9db27 | 1716 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "promptcb ", 9 ) ){ |
klauss | 78:1353744f01e1 | 1717 | miss_match = false; |
klauss | 117:e9facba9db27 | 1718 | //static uint8_t id_msg = 0x10; |
klauss | 117:e9facba9db27 | 1719 | uint8_t write_buffer[ 300 ]; |
klauss | 78:1353744f01e1 | 1720 | int ext,port; |
klauss | 78:1353744f01e1 | 1721 | char *split, *ref, *cmd; |
klauss | 117:e9facba9db27 | 1722 | |
klauss | 78:1353744f01e1 | 1723 | ref = debug_buf; |
klauss | 117:e9facba9db27 | 1724 | |
klauss | 78:1353744f01e1 | 1725 | strcat( debug_buf, "\r" ); |
klauss | 117:e9facba9db27 | 1726 | |
klauss | 117:e9facba9db27 | 1727 | split = strtok( debug_buf + 9, " " ); |
klauss | 78:1353744f01e1 | 1728 | ext = atoi( split ); |
klauss | 117:e9facba9db27 | 1729 | split = strtok( NULL, " " ); |
klauss | 117:e9facba9db27 | 1730 | port = atoi( split ); |
klauss | 78:1353744f01e1 | 1731 | split += strlen( split ) + 1; |
klauss | 78:1353744f01e1 | 1732 | cmd = split; |
klauss | 117:e9facba9db27 | 1733 | |
klauss | 78:1353744f01e1 | 1734 | promptcb_last_ext = ext; |
klauss | 78:1353744f01e1 | 1735 | promptcb_last_port = port; |
klauss | 117:e9facba9db27 | 1736 | |
klauss | 78:1353744f01e1 | 1737 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 117:e9facba9db27 | 1738 | strcat( cmd, "\r\r\r\n" ); |
klauss | 117:e9facba9db27 | 1739 | |
klauss | 117:e9facba9db27 | 1740 | if( debug_uart3 ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); |
klauss | 117:e9facba9db27 | 1741 | send2callboxes( __build_cb_package__( ext, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 117:e9facba9db27 | 1742 | if( debug_uart3 ) pc.printf("\n\rComando enviado"); |
klauss | 117:e9facba9db27 | 1743 | |
klauss | 117:e9facba9db27 | 1744 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1745 | char eth_msg[ 512 ]; |
klauss | 78:1353744f01e1 | 1746 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd ); |
klauss | 117:e9facba9db27 | 1747 | if( tcp_session ){ |
klauss | 78:1353744f01e1 | 1748 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 117:e9facba9db27 | 1749 | }else if( udp_request ){ |
klauss | 117:e9facba9db27 | 1750 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 78:1353744f01e1 | 1751 | } |
klauss | 78:1353744f01e1 | 1752 | } |
klauss | 117:e9facba9db27 | 1753 | |
klauss | 78:1353744f01e1 | 1754 | debug_buf = ref; |
klauss | 78:1353744f01e1 | 1755 | bufptr = 0; |
klauss | 117:e9facba9db27 | 1756 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 78:1353744f01e1 | 1757 | } |
klauss | 114:472502b31a12 | 1758 | |
klauss | 114:472502b31a12 | 1759 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "bye ", 4 ) ){ |
klauss | 92:92df17f538a8 | 1760 | miss_match = false; |
klauss | 92:92df17f538a8 | 1761 | int ext,port; |
klauss | 92:92df17f538a8 | 1762 | char *split, *ref; |
klauss | 114:472502b31a12 | 1763 | uint8_t write_buffer[ 300 ], data[ 300 ]; |
klauss | 114:472502b31a12 | 1764 | |
klauss | 92:92df17f538a8 | 1765 | ref = debug_buf; |
klauss | 114:472502b31a12 | 1766 | |
klauss | 92:92df17f538a8 | 1767 | strcat( debug_buf, "\r\r\r\n" ); |
klauss | 114:472502b31a12 | 1768 | |
klauss | 92:92df17f538a8 | 1769 | split = strtok( debug_buf + 4, " " ); |
klauss | 92:92df17f538a8 | 1770 | ext = atoi( split ); |
klauss | 92:92df17f538a8 | 1771 | port = convert_ext_to_port( ext ); |
klauss | 114:472502b31a12 | 1772 | |
klauss | 114:472502b31a12 | 1773 | if( debug_uart3 ) pc.printf("\r\next=%d port=%d request bye", ext, port ); |
klauss | 117:e9facba9db27 | 1774 | send2callboxes( __build_cb_package__( ext, port, __CB_BYE__, (char * )data, 0x20, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 114:472502b31a12 | 1775 | if( debug_uart3 ) pc.printf("\n\rBye enviado"); |
klauss | 114:472502b31a12 | 1776 | |
klauss | 114:472502b31a12 | 1777 | if( from_eth ){ |
klauss | 92:92df17f538a8 | 1778 | char eth_msg[ 512 ]; |
klauss | 92:92df17f538a8 | 1779 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d request bye\n\r", ext, port ); |
klauss | 117:e9facba9db27 | 1780 | if( tcp_session ){ |
klauss | 92:92df17f538a8 | 1781 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 117:e9facba9db27 | 1782 | }else if( udp_request ){ |
klauss | 117:e9facba9db27 | 1783 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 92:92df17f538a8 | 1784 | } |
klauss | 92:92df17f538a8 | 1785 | } |
klauss | 117:e9facba9db27 | 1786 | |
klauss | 92:92df17f538a8 | 1787 | debug_buf = ref; |
klauss | 92:92df17f538a8 | 1788 | bufptr = 0; |
klauss | 114:472502b31a12 | 1789 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 92:92df17f538a8 | 1790 | } |
klauss | 114:472502b31a12 | 1791 | |
klauss | 117:e9facba9db27 | 1792 | //promptcb ramal porta comando |
klauss | 117:e9facba9db27 | 1793 | //FIXME colocar a parte eth de novo |
klauss | 117:e9facba9db27 | 1794 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "pcb ", 4 )) { |
klauss | 45:c80574f24dc3 | 1795 | miss_match = false; |
klauss | 48:195c97f12e8e | 1796 | int ext,port; |
klauss | 54:448d57291be6 | 1797 | char *split, *ref, *cmd; |
klauss | 117:e9facba9db27 | 1798 | |
klauss | 62:07e5bdc9f8f7 | 1799 | ref = debug_buf; |
klauss | 117:e9facba9db27 | 1800 | |
klauss | 74:81c47fff88a5 | 1801 | strcat( debug_buf, "\r" ); |
klauss | 117:e9facba9db27 | 1802 | |
klauss | 48:195c97f12e8e | 1803 | split = strtok( debug_buf + 4, " " ); |
klauss | 48:195c97f12e8e | 1804 | ext = atoi( split ); |
klauss | 117:e9facba9db27 | 1805 | |
klauss | 50:d9b6577a70f5 | 1806 | port = convert_ext_to_port( ext ); |
klauss | 48:195c97f12e8e | 1807 | split += strlen( split ) + 1; |
klauss | 54:448d57291be6 | 1808 | cmd = split; |
klauss | 117:e9facba9db27 | 1809 | |
klauss | 48:195c97f12e8e | 1810 | promptcb_last_ext = ext; |
klauss | 48:195c97f12e8e | 1811 | promptcb_last_port = port; |
klauss | 117:e9facba9db27 | 1812 | |
klauss | 55:2f5e7374af9d | 1813 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 117:e9facba9db27 | 1814 | strcat( cmd, "\r\r\r\n" ); |
klauss | 117:e9facba9db27 | 1815 | |
klauss | 117:e9facba9db27 | 1816 | //send_msg( "Tamanho do cmd == %d", strlen( cmd ) ); |
klauss | 117:e9facba9db27 | 1817 | |
klauss | 117:e9facba9db27 | 1818 | //for( register uint16_t i = strlen( cmd ); i < __CB_BUFFER_SIZE__; i++ ) cmd[ i ] = 0; |
klauss | 117:e9facba9db27 | 1819 | |
klauss | 117:e9facba9db27 | 1820 | if( debug_uart3 ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); |
klauss | 117:e9facba9db27 | 1821 | send2callboxes( __build_cb_package__( ext, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 117:e9facba9db27 | 1822 | if( debug_uart3 ) pc.printf("\n\rComando enviado"); |
klauss | 117:e9facba9db27 | 1823 | |
klauss | 117:e9facba9db27 | 1824 | if( from_eth ){ |
klauss | 62:07e5bdc9f8f7 | 1825 | char eth_msg[ 512 ]; |
klauss | 78:1353744f01e1 | 1826 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd ); |
klauss | 117:e9facba9db27 | 1827 | if( tcp_session ){ |
klauss | 62:07e5bdc9f8f7 | 1828 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 117:e9facba9db27 | 1829 | }else if( udp_request ){ |
klauss | 117:e9facba9db27 | 1830 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 62:07e5bdc9f8f7 | 1831 | } |
klauss | 54:448d57291be6 | 1832 | } |
klauss | 117:e9facba9db27 | 1833 | |
klauss | 48:195c97f12e8e | 1834 | debug_buf = ref; |
klauss | 117:e9facba9db27 | 1835 | //bufptr = 0; |
klauss | 117:e9facba9db27 | 1836 | //debug_buf[ 0 ] = 0; |
klauss | 62:07e5bdc9f8f7 | 1837 | bufptr = 0; |
klauss | 117:e9facba9db27 | 1838 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 45:c80574f24dc3 | 1839 | } |
klauss | 114:472502b31a12 | 1840 | |
klauss | 98:43b45f26b430 | 1841 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "pcc ", 4 )) { |
klauss | 98:43b45f26b430 | 1842 | miss_match = false; |
klauss | 98:43b45f26b430 | 1843 | int ext,port; |
klauss | 98:43b45f26b430 | 1844 | char *split, *ref, *cmd; |
klauss | 117:e9facba9db27 | 1845 | |
klauss | 98:43b45f26b430 | 1846 | ref = debug_buf; |
klauss | 117:e9facba9db27 | 1847 | |
klauss | 98:43b45f26b430 | 1848 | strcat( debug_buf, "\r" ); |
klauss | 117:e9facba9db27 | 1849 | |
klauss | 98:43b45f26b430 | 1850 | split = strtok( debug_buf + 4, " " ); |
klauss | 98:43b45f26b430 | 1851 | ext = atoi( split ); |
klauss | 117:e9facba9db27 | 1852 | |
klauss | 98:43b45f26b430 | 1853 | split += strlen( split ) + 1; |
klauss | 98:43b45f26b430 | 1854 | split = strtok( NULL, " " ); |
klauss | 98:43b45f26b430 | 1855 | port = atoi( split ); |
klauss | 117:e9facba9db27 | 1856 | |
klauss | 98:43b45f26b430 | 1857 | split += strlen( split ) + 1; |
klauss | 98:43b45f26b430 | 1858 | cmd = split; |
klauss | 117:e9facba9db27 | 1859 | |
klauss | 98:43b45f26b430 | 1860 | promptcb_last_ext = ext; |
klauss | 98:43b45f26b430 | 1861 | promptcb_last_port = port; |
klauss | 117:e9facba9db27 | 1862 | |
klauss | 98:43b45f26b430 | 1863 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 117:e9facba9db27 | 1864 | strcat( cmd, "\r\r\r\n" ); |
klauss | 117:e9facba9db27 | 1865 | |
klauss | 117:e9facba9db27 | 1866 | if( debug_uart3 ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); |
klauss | 117:e9facba9db27 | 1867 | send2callboxes( __build_cb_package__( ext, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 117:e9facba9db27 | 1868 | if( debug_uart3 ) pc.printf("\n\rComando enviado"); |
klauss | 117:e9facba9db27 | 1869 | |
klauss | 117:e9facba9db27 | 1870 | if( from_eth ){ |
klauss | 98:43b45f26b430 | 1871 | char eth_msg[ 512 ]; |
klauss | 98:43b45f26b430 | 1872 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd ); |
klauss | 117:e9facba9db27 | 1873 | if( tcp_session ){ |
klauss | 98:43b45f26b430 | 1874 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 117:e9facba9db27 | 1875 | }else if( udp_request ){ |
klauss | 117:e9facba9db27 | 1876 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 98:43b45f26b430 | 1877 | } |
klauss | 98:43b45f26b430 | 1878 | } |
klauss | 117:e9facba9db27 | 1879 | |
klauss | 98:43b45f26b430 | 1880 | debug_buf = ref; |
klauss | 98:43b45f26b430 | 1881 | bufptr = 0; |
klauss | 117:e9facba9db27 | 1882 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 114:472502b31a12 | 1883 | } |
klauss | 114:472502b31a12 | 1884 | |
klauss | 114:472502b31a12 | 1885 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_cb ", 9 )) { |
klauss | 114:472502b31a12 | 1886 | miss_match = false; |
klauss | 114:472502b31a12 | 1887 | char *split; |
klauss | 114:472502b31a12 | 1888 | |
klauss | 114:472502b31a12 | 1889 | split = strtok( debug_buf + 9, " " ); |
klauss | 114:472502b31a12 | 1890 | if( 0 == ( strcasecmp( split, "all" ) ) ) |
klauss | 114:472502b31a12 | 1891 | { |
klauss | 114:472502b31a12 | 1892 | print_cb_all = true; |
klauss | 114:472502b31a12 | 1893 | } |
klauss | 114:472502b31a12 | 1894 | else |
klauss | 114:472502b31a12 | 1895 | { |
klauss | 114:472502b31a12 | 1896 | print_cb_var = true; |
klauss | 114:472502b31a12 | 1897 | print_this_cb = atoi( split ); |
klauss | 114:472502b31a12 | 1898 | } |
klauss | 114:472502b31a12 | 1899 | |
klauss | 114:472502b31a12 | 1900 | bufptr = 0; |
klauss | 114:472502b31a12 | 1901 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 114:472502b31a12 | 1902 | } |
klauss | 114:472502b31a12 | 1903 | |
klauss | 114:472502b31a12 | 1904 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "frtp ", 5 )) { |
klauss | 114:472502b31a12 | 1905 | miss_match = false; |
klauss | 114:472502b31a12 | 1906 | char *split; |
klauss | 114:472502b31a12 | 1907 | |
klauss | 114:472502b31a12 | 1908 | split = strtok( debug_buf + 5, " " ); |
klauss | 114:472502b31a12 | 1909 | frtp = true; |
klauss | 114:472502b31a12 | 1910 | frtp_target = atoi( split ); |
klauss | 114:472502b31a12 | 1911 | |
klauss | 114:472502b31a12 | 1912 | bufptr = 0; |
klauss | 114:472502b31a12 | 1913 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 114:472502b31a12 | 1914 | } |
klauss | 114:472502b31a12 | 1915 | |
klauss | 114:472502b31a12 | 1916 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "rrtp ", 5 )) { |
klauss | 114:472502b31a12 | 1917 | miss_match = false; |
klauss | 114:472502b31a12 | 1918 | char *split; |
klauss | 114:472502b31a12 | 1919 | |
klauss | 114:472502b31a12 | 1920 | split = strtok( debug_buf + 5, " " ); |
klauss | 114:472502b31a12 | 1921 | rescue_rtp = true; |
klauss | 114:472502b31a12 | 1922 | rescue_rtp_target = atoi( split ); |
klauss | 114:472502b31a12 | 1923 | |
klauss | 114:472502b31a12 | 1924 | split += strlen( split ) + 1; |
klauss | 114:472502b31a12 | 1925 | split = strtok( NULL, " " ); |
klauss | 114:472502b31a12 | 1926 | rescue_rtp_value = atoi( split ); |
klauss | 114:472502b31a12 | 1927 | |
klauss | 114:472502b31a12 | 1928 | bufptr = 0; |
klauss | 114:472502b31a12 | 1929 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 114:472502b31a12 | 1930 | } |
klauss | 114:472502b31a12 | 1931 | |
klauss | 114:472502b31a12 | 1932 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_hex_cb ", 13 )) { |
klauss | 114:472502b31a12 | 1933 | miss_match = false; |
klauss | 114:472502b31a12 | 1934 | char *split; |
klauss | 114:472502b31a12 | 1935 | |
klauss | 114:472502b31a12 | 1936 | split = strtok( debug_buf + 13, " " ); |
klauss | 114:472502b31a12 | 1937 | if( 0 == ( strcasecmp( split, "all" ) ) ) |
klauss | 114:472502b31a12 | 1938 | { |
klauss | 114:472502b31a12 | 1939 | print_hex_cb_all = true; |
klauss | 114:472502b31a12 | 1940 | } |
klauss | 114:472502b31a12 | 1941 | else |
klauss | 114:472502b31a12 | 1942 | { |
klauss | 114:472502b31a12 | 1943 | print_hex_cb_var = true; |
klauss | 114:472502b31a12 | 1944 | print_hex_this_cb = atoi( split ); |
klauss | 114:472502b31a12 | 1945 | } |
klauss | 114:472502b31a12 | 1946 | |
klauss | 114:472502b31a12 | 1947 | bufptr = 0; |
klauss | 114:472502b31a12 | 1948 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 114:472502b31a12 | 1949 | } |
klauss | 114:472502b31a12 | 1950 | |
klauss | 114:472502b31a12 | 1951 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_sip ", 10 )) { |
klauss | 114:472502b31a12 | 1952 | miss_match = false; |
klauss | 114:472502b31a12 | 1953 | char *split; |
klauss | 114:472502b31a12 | 1954 | |
klauss | 114:472502b31a12 | 1955 | split = strtok( debug_buf + 10, " " ); |
klauss | 114:472502b31a12 | 1956 | if( 0 == ( strcasecmp( split, "all" ) ) ) |
klauss | 114:472502b31a12 | 1957 | { |
klauss | 114:472502b31a12 | 1958 | print_sip_all = true; |
klauss | 114:472502b31a12 | 1959 | } |
klauss | 114:472502b31a12 | 1960 | else |
klauss | 114:472502b31a12 | 1961 | { |
klauss | 114:472502b31a12 | 1962 | print_sip_var = true; |
klauss | 114:472502b31a12 | 1963 | print_this_sip = atoi( split ); |
klauss | 114:472502b31a12 | 1964 | } |
klauss | 114:472502b31a12 | 1965 | |
klauss | 114:472502b31a12 | 1966 | bufptr = 0; |
klauss | 114:472502b31a12 | 1967 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 98:43b45f26b430 | 1968 | } |
klauss | 114:472502b31a12 | 1969 | |
klauss | 114:472502b31a12 | 1970 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_hex_sip ", 14 )) { |
klauss | 114:472502b31a12 | 1971 | miss_match = false; |
klauss | 114:472502b31a12 | 1972 | char *split; |
klauss | 114:472502b31a12 | 1973 | |
klauss | 114:472502b31a12 | 1974 | split = strtok( debug_buf + 14, " " ); |
klauss | 114:472502b31a12 | 1975 | if( 0 == ( strcasecmp( split, "all" ) ) ) |
klauss | 114:472502b31a12 | 1976 | { |
klauss | 114:472502b31a12 | 1977 | print_hex_sip_all = true; |
klauss | 114:472502b31a12 | 1978 | } |
klauss | 114:472502b31a12 | 1979 | else |
klauss | 114:472502b31a12 | 1980 | { |
klauss | 114:472502b31a12 | 1981 | print_hex_sip_var = true; |
klauss | 114:472502b31a12 | 1982 | print_hex_this_sip = atoi( split ); |
klauss | 114:472502b31a12 | 1983 | } |
klauss | 114:472502b31a12 | 1984 | |
klauss | 114:472502b31a12 | 1985 | bufptr = 0; |
klauss | 114:472502b31a12 | 1986 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 114:472502b31a12 | 1987 | } |
klauss | 114:472502b31a12 | 1988 | |
klauss | 114:472502b31a12 | 1989 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_call ", 11 ) ) |
klauss | 114:472502b31a12 | 1990 | { |
klauss | 114:472502b31a12 | 1991 | miss_match = false; |
klauss | 114:472502b31a12 | 1992 | char *split; |
klauss | 114:472502b31a12 | 1993 | |
klauss | 114:472502b31a12 | 1994 | split = strtok( debug_buf + 11, " " ); |
klauss | 114:472502b31a12 | 1995 | if( 0 == ( strcasecmp( split, "all" ) ) ) |
klauss | 114:472502b31a12 | 1996 | { |
klauss | 114:472502b31a12 | 1997 | print_call_all = true; |
klauss | 114:472502b31a12 | 1998 | } |
klauss | 114:472502b31a12 | 1999 | else |
klauss | 114:472502b31a12 | 2000 | { |
klauss | 114:472502b31a12 | 2001 | print_call_var = true; |
klauss | 114:472502b31a12 | 2002 | print_this_call = atoi( split ); |
klauss | 114:472502b31a12 | 2003 | } |
klauss | 114:472502b31a12 | 2004 | |
klauss | 114:472502b31a12 | 2005 | bufptr = 0; |
klauss | 114:472502b31a12 | 2006 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 114:472502b31a12 | 2007 | } |
klauss | 114:472502b31a12 | 2008 | |
klauss | 114:472502b31a12 | 2009 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_hex_call ", 15 ) ) |
klauss | 114:472502b31a12 | 2010 | { |
klauss | 114:472502b31a12 | 2011 | miss_match = false; |
klauss | 114:472502b31a12 | 2012 | char *split; |
klauss | 114:472502b31a12 | 2013 | |
klauss | 114:472502b31a12 | 2014 | split = strtok( debug_buf + 15, " " ); |
klauss | 114:472502b31a12 | 2015 | if( 0 == ( strcasecmp( split, "all" ) ) ) |
klauss | 114:472502b31a12 | 2016 | { |
klauss | 114:472502b31a12 | 2017 | print_hex_call_all = true; |
klauss | 114:472502b31a12 | 2018 | } |
klauss | 114:472502b31a12 | 2019 | else |
klauss | 114:472502b31a12 | 2020 | { |
klauss | 114:472502b31a12 | 2021 | print_hex_call_var = true; |
klauss | 114:472502b31a12 | 2022 | print_hex_this_call = atoi( split ); |
klauss | 114:472502b31a12 | 2023 | } |
klauss | 114:472502b31a12 | 2024 | |
klauss | 114:472502b31a12 | 2025 | bufptr = 0; |
klauss | 114:472502b31a12 | 2026 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 114:472502b31a12 | 2027 | } |
klauss | 114:472502b31a12 | 2028 | |
klauss | 114:472502b31a12 | 2029 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_rtp ", 10 ) ) |
klauss | 114:472502b31a12 | 2030 | { |
klauss | 114:472502b31a12 | 2031 | miss_match = false; |
klauss | 114:472502b31a12 | 2032 | char *split; |
klauss | 114:472502b31a12 | 2033 | |
klauss | 114:472502b31a12 | 2034 | split = strtok( debug_buf + 10, " " ); |
klauss | 114:472502b31a12 | 2035 | if( 0 == ( strcasecmp( split, "all" ) ) ) |
klauss | 114:472502b31a12 | 2036 | { |
klauss | 114:472502b31a12 | 2037 | print_rtp_all = true; |
klauss | 114:472502b31a12 | 2038 | } |
klauss | 114:472502b31a12 | 2039 | else |
klauss | 114:472502b31a12 | 2040 | { |
klauss | 114:472502b31a12 | 2041 | print_rtp_var = true; |
klauss | 114:472502b31a12 | 2042 | print_this_rtp = atoi( split ); |
klauss | 114:472502b31a12 | 2043 | } |
klauss | 114:472502b31a12 | 2044 | |
klauss | 114:472502b31a12 | 2045 | bufptr = 0; |
klauss | 114:472502b31a12 | 2046 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 114:472502b31a12 | 2047 | } |
klauss | 114:472502b31a12 | 2048 | |
klauss | 114:472502b31a12 | 2049 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_hex_rtp ", 14 ) ) |
klauss | 114:472502b31a12 | 2050 | { |
klauss | 114:472502b31a12 | 2051 | miss_match = false; |
klauss | 114:472502b31a12 | 2052 | char *split; |
klauss | 114:472502b31a12 | 2053 | |
klauss | 114:472502b31a12 | 2054 | split = strtok( debug_buf + 14, " " ); |
klauss | 114:472502b31a12 | 2055 | if( 0 == ( strcasecmp( split, "all" ) ) ) |
klauss | 114:472502b31a12 | 2056 | { |
klauss | 114:472502b31a12 | 2057 | print_hex_rtp_all = true; |
klauss | 114:472502b31a12 | 2058 | } |
klauss | 114:472502b31a12 | 2059 | else |
klauss | 114:472502b31a12 | 2060 | { |
klauss | 114:472502b31a12 | 2061 | print_hex_rtp_var = true; |
klauss | 114:472502b31a12 | 2062 | print_hex_this_rtp = atoi( split ); |
klauss | 114:472502b31a12 | 2063 | } |
klauss | 114:472502b31a12 | 2064 | |
klauss | 114:472502b31a12 | 2065 | bufptr = 0; |
klauss | 114:472502b31a12 | 2066 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 114:472502b31a12 | 2067 | } |
klauss | 114:472502b31a12 | 2068 | |
klauss | 114:472502b31a12 | 2069 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "log ", 4 )) { |
klauss | 114:472502b31a12 | 2070 | miss_match = false; |
klauss | 114:472502b31a12 | 2071 | |
klauss | 114:472502b31a12 | 2072 | char * split = strtok( debug_buf + 4, " " ); |
klauss | 114:472502b31a12 | 2073 | |
klauss | 114:472502b31a12 | 2074 | { |
klauss | 114:472502b31a12 | 2075 | print_cb_var = true; |
klauss | 114:472502b31a12 | 2076 | print_this_cb = atoi( split ); |
klauss | 114:472502b31a12 | 2077 | print_sip_var = true; |
klauss | 114:472502b31a12 | 2078 | print_this_sip = print_this_cb; |
klauss | 114:472502b31a12 | 2079 | print_call_var = true; |
klauss | 114:472502b31a12 | 2080 | print_this_call = print_this_cb; |
klauss | 114:472502b31a12 | 2081 | print_rtp_var = true; |
klauss | 114:472502b31a12 | 2082 | print_this_rtp = print_this_cb; |
klauss | 114:472502b31a12 | 2083 | } |
klauss | 114:472502b31a12 | 2084 | |
klauss | 114:472502b31a12 | 2085 | bufptr = 0; |
klauss | 114:472502b31a12 | 2086 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 114:472502b31a12 | 2087 | } |
klauss | 114:472502b31a12 | 2088 | |
klauss | 114:472502b31a12 | 2089 | |
klauss | 117:e9facba9db27 | 2090 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "rush ", 5 )) { |
klauss | 99:e80850c51106 | 2091 | miss_match = false; |
klauss | 99:e80850c51106 | 2092 | int ext,port; |
klauss | 99:e80850c51106 | 2093 | char *split, *ref, cmd[ 32 ]; |
klauss | 117:e9facba9db27 | 2094 | |
klauss | 99:e80850c51106 | 2095 | ref = debug_buf; |
klauss | 117:e9facba9db27 | 2096 | |
klauss | 99:e80850c51106 | 2097 | strcat( debug_buf, "\r" ); |
klauss | 117:e9facba9db27 | 2098 | |
klauss | 99:e80850c51106 | 2099 | split = strtok( debug_buf + 5, " " ); |
klauss | 99:e80850c51106 | 2100 | ext = atoi( split ); |
klauss | 117:e9facba9db27 | 2101 | |
klauss | 99:e80850c51106 | 2102 | split += strlen( split ) + 1; |
klauss | 99:e80850c51106 | 2103 | split = strtok( NULL, " " ); |
klauss | 99:e80850c51106 | 2104 | port = atoi( split ); |
klauss | 117:e9facba9db27 | 2105 | |
klauss | 99:e80850c51106 | 2106 | strcpy( cmd, "ping\r\n" ); |
klauss | 117:e9facba9db27 | 2107 | |
klauss | 99:e80850c51106 | 2108 | promptcb_last_ext = ext; |
klauss | 99:e80850c51106 | 2109 | promptcb_last_port = port; |
klauss | 117:e9facba9db27 | 2110 | |
klauss | 99:e80850c51106 | 2111 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 99:e80850c51106 | 2112 | strcat( cmd, "\r\r\r\n" ); |
klauss | 117:e9facba9db27 | 2113 | |
klauss | 117:e9facba9db27 | 2114 | for( register uint8_t i = 0; i < 3; i++ ){ |
klauss | 117:e9facba9db27 | 2115 | if( debug_uart3 ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); |
klauss | 117:e9facba9db27 | 2116 | send2callboxes( __build_cb_package__( ext, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 117:e9facba9db27 | 2117 | if( debug_uart3 ) pc.printf("\n\rComando enviado"); |
klauss | 117:e9facba9db27 | 2118 | |
klauss | 117:e9facba9db27 | 2119 | if( from_eth ){ |
klauss | 99:e80850c51106 | 2120 | char eth_msg[ 512 ]; |
klauss | 99:e80850c51106 | 2121 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd ); |
klauss | 117:e9facba9db27 | 2122 | if( tcp_session ){ |
klauss | 99:e80850c51106 | 2123 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 117:e9facba9db27 | 2124 | }else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2125 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 99:e80850c51106 | 2126 | } |
klauss | 99:e80850c51106 | 2127 | } |
klauss | 99:e80850c51106 | 2128 | } |
klauss | 117:e9facba9db27 | 2129 | |
klauss | 99:e80850c51106 | 2130 | debug_buf = ref; |
klauss | 99:e80850c51106 | 2131 | bufptr = 0; |
klauss | 117:e9facba9db27 | 2132 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 99:e80850c51106 | 2133 | } |
klauss | 114:472502b31a12 | 2134 | |
klauss | 114:472502b31a12 | 2135 | |
klauss | 117:e9facba9db27 | 2136 | |
klauss | 59:e1e300880d2d | 2137 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "_pcb",4 )) { |
klauss | 45:c80574f24dc3 | 2138 | miss_match = false; |
klauss | 48:195c97f12e8e | 2139 | debug_buf[ bufptr++ ] = 0x0D; |
klauss | 48:195c97f12e8e | 2140 | debug_buf[ bufptr++ ] = 0x00; |
klauss | 45:c80574f24dc3 | 2141 | |
klauss | 114:472502b31a12 | 2142 | if( debug_uart3 ) pc.printf("\r\next=%d port=%d\r\ncmd=%s\r\n",promptcb_last_ext, promptcb_last_port, debug_buf + 4 ); |
klauss | 117:e9facba9db27 | 2143 | send2callboxes( __build_cb_package__( promptcb_last_ext, promptcb_last_port, __PROMPT__, debug_buf + 4, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 114:472502b31a12 | 2144 | if( debug_uart3 ) pc.printf("\n\rComando enviado\n\r"); |
klauss | 45:c80574f24dc3 | 2145 | } |
klauss | 62:07e5bdc9f8f7 | 2146 | |
klauss | 58:af7e8788f106 | 2147 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "cks",3 )) { |
klauss | 45:c80574f24dc3 | 2148 | miss_match = false; |
klauss | 81:3656f00ab3db | 2149 | pcks_s = true; |
klauss | 45:c80574f24dc3 | 2150 | } |
klauss | 45:c80574f24dc3 | 2151 | |
klauss | 58:af7e8788f106 | 2152 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "showcb",6 )) { |
klauss | 45:c80574f24dc3 | 2153 | miss_match = false; |
klauss | 81:3656f00ab3db | 2154 | pshowcb = true; |
klauss | 45:c80574f24dc3 | 2155 | } |
klauss | 114:472502b31a12 | 2156 | |
klauss | 58:af7e8788f106 | 2157 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_main ", 11 )) { |
klauss | 81:3656f00ab3db | 2158 | if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "on", 2 )) { |
klauss | 45:c80574f24dc3 | 2159 | miss_match = false; |
klauss | 114:472502b31a12 | 2160 | if( debug_uart3 ) pc.printf("\r\nDebug Main ON"); |
klauss | 114:472502b31a12 | 2161 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2162 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Main On\n\r" ); |
klauss | 45:c80574f24dc3 | 2163 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 2164 | } |
klauss | 81:3656f00ab3db | 2165 | debug_main = true; |
klauss | 45:c80574f24dc3 | 2166 | } |
klauss | 81:3656f00ab3db | 2167 | if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "off", 3 )) { |
klauss | 45:c80574f24dc3 | 2168 | miss_match = false; |
klauss | 114:472502b31a12 | 2169 | if( debug_uart3 ) pc.printf("\r\nDebug Main OFF"); |
klauss | 114:472502b31a12 | 2170 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2171 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Main Off\n\r" ); |
klauss | 45:c80574f24dc3 | 2172 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 2173 | } |
klauss | 45:c80574f24dc3 | 2174 | debug_main = 0; |
klauss | 45:c80574f24dc3 | 2175 | } |
klauss | 45:c80574f24dc3 | 2176 | } |
klauss | 114:472502b31a12 | 2177 | |
klauss | 114:472502b31a12 | 2178 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dout ", 5 ) ){ |
klauss | 114:472502b31a12 | 2179 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "on", 2 ) ){ |
klauss | 81:3656f00ab3db | 2180 | miss_match = false; |
klauss | 114:472502b31a12 | 2181 | if( debug_uart3 ) pc.printf("\r\nOut Debug ON"); |
klauss | 114:472502b31a12 | 2182 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2183 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Out Debug On\n\r" ); |
klauss | 81:3656f00ab3db | 2184 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 2185 | } |
klauss | 81:3656f00ab3db | 2186 | debug_out_of_range = true; |
klauss | 81:3656f00ab3db | 2187 | } |
klauss | 114:472502b31a12 | 2188 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "off", 3 ) ){ |
klauss | 81:3656f00ab3db | 2189 | miss_match = false; |
klauss | 114:472502b31a12 | 2190 | if( debug_uart3 ) pc.printf("\r\nOut Debug OFF"); |
klauss | 114:472502b31a12 | 2191 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2192 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Out Debug Off\n\r" ); |
klauss | 81:3656f00ab3db | 2193 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 2194 | } |
klauss | 81:3656f00ab3db | 2195 | debug_out_of_range = false; |
klauss | 81:3656f00ab3db | 2196 | } |
klauss | 81:3656f00ab3db | 2197 | } |
klauss | 114:472502b31a12 | 2198 | |
klauss | 114:472502b31a12 | 2199 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dboot ", 6 ) ){ |
klauss | 114:472502b31a12 | 2200 | if (xmemmatch( (uint8_t*)( debug_buf + 6 ), (uint8_t*) "on", 2 ) ){ |
klauss | 99:e80850c51106 | 2201 | miss_match = false; |
klauss | 114:472502b31a12 | 2202 | if( debug_uart3 ) pc.printf("\r\nBoot Debug ON"); |
klauss | 114:472502b31a12 | 2203 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2204 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Boot Debug On\n\r" ); |
klauss | 99:e80850c51106 | 2205 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 99:e80850c51106 | 2206 | } |
klauss | 99:e80850c51106 | 2207 | debug_boot = true; |
klauss | 99:e80850c51106 | 2208 | } |
klauss | 114:472502b31a12 | 2209 | if (xmemmatch( (uint8_t*)( debug_buf + 6 ), (uint8_t*) "off", 3 ) ){ |
klauss | 99:e80850c51106 | 2210 | miss_match = false; |
klauss | 114:472502b31a12 | 2211 | if( debug_uart3 ) pc.printf("\r\nBoot Debug OFF"); |
klauss | 114:472502b31a12 | 2212 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2213 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Boot Debug Off\n\r" ); |
klauss | 99:e80850c51106 | 2214 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 99:e80850c51106 | 2215 | } |
klauss | 99:e80850c51106 | 2216 | debug_boot = false; |
klauss | 99:e80850c51106 | 2217 | } |
klauss | 99:e80850c51106 | 2218 | } |
klauss | 114:472502b31a12 | 2219 | |
klauss | 114:472502b31a12 | 2220 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dfw ", 4 ) ){ |
klauss | 114:472502b31a12 | 2221 | if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "on", 2 ) ){ |
klauss | 99:e80850c51106 | 2222 | miss_match = false; |
klauss | 114:472502b31a12 | 2223 | if( debug_uart3 ) pc.printf("\r\nFW Debug ON"); |
klauss | 114:472502b31a12 | 2224 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2225 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FW Debug On\n\r" ); |
klauss | 99:e80850c51106 | 2226 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 99:e80850c51106 | 2227 | } |
klauss | 99:e80850c51106 | 2228 | debug_fw = true; |
klauss | 99:e80850c51106 | 2229 | } |
klauss | 114:472502b31a12 | 2230 | if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "off", 3 ) ){ |
klauss | 99:e80850c51106 | 2231 | miss_match = false; |
klauss | 114:472502b31a12 | 2232 | if( debug_uart3 ) pc.printf("\r\nFW Debug OFF"); |
klauss | 114:472502b31a12 | 2233 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2234 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FW Debug Off\n\r" ); |
klauss | 99:e80850c51106 | 2235 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 99:e80850c51106 | 2236 | } |
klauss | 99:e80850c51106 | 2237 | debug_fw = false; |
klauss | 99:e80850c51106 | 2238 | } |
klauss | 99:e80850c51106 | 2239 | } |
klauss | 114:472502b31a12 | 2240 | |
klauss | 114:472502b31a12 | 2241 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dfwp ", 5 ) ){ |
klauss | 114:472502b31a12 | 2242 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "on", 2 ) ){ |
klauss | 99:e80850c51106 | 2243 | miss_match = false; |
klauss | 114:472502b31a12 | 2244 | if( debug_uart3 ) pc.printf("\r\nFWPrint Debug ON"); |
klauss | 114:472502b31a12 | 2245 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2246 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FWPrint Debug On\n\r" ); |
klauss | 99:e80850c51106 | 2247 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 99:e80850c51106 | 2248 | } |
klauss | 99:e80850c51106 | 2249 | debug_fw_print = true; |
klauss | 99:e80850c51106 | 2250 | } |
klauss | 114:472502b31a12 | 2251 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "off", 3 ) ){ |
klauss | 99:e80850c51106 | 2252 | miss_match = false; |
klauss | 114:472502b31a12 | 2253 | if( debug_uart3 ) pc.printf("\r\nFWPrint Debug OFF"); |
klauss | 114:472502b31a12 | 2254 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2255 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FWPrint Debug Off\n\r" ); |
klauss | 99:e80850c51106 | 2256 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 99:e80850c51106 | 2257 | } |
klauss | 99:e80850c51106 | 2258 | debug_fw_print = false; |
klauss | 99:e80850c51106 | 2259 | } |
klauss | 99:e80850c51106 | 2260 | } |
klauss | 114:472502b31a12 | 2261 | |
klauss | 99:e80850c51106 | 2262 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drx ", 4 )) { |
klauss | 99:e80850c51106 | 2263 | if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "on",2 )) { |
klauss | 45:c80574f24dc3 | 2264 | miss_match = false; |
klauss | 114:472502b31a12 | 2265 | if( debug_uart3 ) pc.printf("\tDebug Cbx Rx ON"); |
klauss | 114:472502b31a12 | 2266 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2267 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\tDebug Cbx On Rx on\n\r" ); |
klauss | 45:c80574f24dc3 | 2268 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 2269 | } |
klauss | 81:3656f00ab3db | 2270 | debug_cb_rx = true; |
klauss | 45:c80574f24dc3 | 2271 | } |
klauss | 99:e80850c51106 | 2272 | if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 2273 | miss_match = false; |
klauss | 114:472502b31a12 | 2274 | if( debug_uart3 ) pc.printf("\tDebug Cbx Rx OFF"); |
klauss | 114:472502b31a12 | 2275 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2276 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\tDebug Cbx Rx Off\n\r" ); |
klauss | 45:c80574f24dc3 | 2277 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 2278 | } |
klauss | 99:e80850c51106 | 2279 | debug_cb_rx = false; |
klauss | 99:e80850c51106 | 2280 | } |
klauss | 99:e80850c51106 | 2281 | } |
klauss | 114:472502b31a12 | 2282 | |
klauss | 99:e80850c51106 | 2283 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dtx ", 4 )) { |
klauss | 99:e80850c51106 | 2284 | if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "on",2 )) { |
klauss | 99:e80850c51106 | 2285 | miss_match = false; |
klauss | 114:472502b31a12 | 2286 | if( debug_uart3 ) pc.printf("\tDebug Cbx Rx ON"); |
klauss | 114:472502b31a12 | 2287 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2288 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\tDebug Cbx On Rx on\n\r" ); |
klauss | 99:e80850c51106 | 2289 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 99:e80850c51106 | 2290 | } |
klauss | 99:e80850c51106 | 2291 | debug_cb_tx = true; |
klauss | 99:e80850c51106 | 2292 | } |
klauss | 99:e80850c51106 | 2293 | if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "off",3 )) { |
klauss | 99:e80850c51106 | 2294 | miss_match = false; |
klauss | 114:472502b31a12 | 2295 | if( debug_uart3 ) pc.printf("\tDebug Cbx Rx OFF"); |
klauss | 114:472502b31a12 | 2296 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2297 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\tDebug Cbx Rx Off\n\r" ); |
klauss | 99:e80850c51106 | 2298 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 99:e80850c51106 | 2299 | } |
klauss | 99:e80850c51106 | 2300 | debug_cb_tx = false; |
klauss | 45:c80574f24dc3 | 2301 | } |
klauss | 45:c80574f24dc3 | 2302 | } |
klauss | 114:472502b31a12 | 2303 | |
klauss | 58:af7e8788f106 | 2304 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_file ", 11 )) { |
klauss | 45:c80574f24dc3 | 2305 | if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "on",2 )) { |
klauss | 45:c80574f24dc3 | 2306 | miss_match = false; |
klauss | 114:472502b31a12 | 2307 | if( debug_uart3 ) pc.printf("\tDebug File ON"); |
klauss | 114:472502b31a12 | 2308 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2309 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\tDebug File On\n\r" ); |
klauss | 45:c80574f24dc3 | 2310 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 2311 | } |
klauss | 114:472502b31a12 | 2312 | debug_cb_rx = true; |
klauss | 45:c80574f24dc3 | 2313 | } |
klauss | 45:c80574f24dc3 | 2314 | if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 2315 | miss_match = false; |
klauss | 114:472502b31a12 | 2316 | if( debug_uart3 ) pc.printf("Debug File OFF"); |
klauss | 114:472502b31a12 | 2317 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2318 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug File Off\n\r" ); |
klauss | 45:c80574f24dc3 | 2319 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 2320 | } |
klauss | 114:472502b31a12 | 2321 | debug_cb_rx = false; |
klauss | 45:c80574f24dc3 | 2322 | } |
klauss | 45:c80574f24dc3 | 2323 | } |
klauss | 45:c80574f24dc3 | 2324 | |
klauss | 58:af7e8788f106 | 2325 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "help" )) { |
klauss | 45:c80574f24dc3 | 2326 | miss_match = false; |
klauss | 117:e9facba9db27 | 2327 | if( debug_uart3 ) pc.printf("\n\r****************************PROMPT HELP******************\n\r"); |
klauss | 117:e9facba9db27 | 2328 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 2329 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "\n\r****************************PROMPT HELP******************\n\r" ); |
klauss | 117:e9facba9db27 | 2330 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2331 | |
klauss | 117:e9facba9db27 | 2332 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2333 | while( !( udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 2334 | } |
klauss | 44:cc4996469404 | 2335 | } |
klauss | 117:e9facba9db27 | 2336 | |
klauss | 117:e9facba9db27 | 2337 | if( debug_uart3 ) pc.printf("ifconfig - mostra o arquivo de configuracao do sistema\n\r"); |
klauss | 117:e9facba9db27 | 2338 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 2339 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ifconfig - mostra o arquivo de configuracao do sistema\n\r" ); |
klauss | 117:e9facba9db27 | 2340 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2341 | |
klauss | 117:e9facba9db27 | 2342 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2343 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 2344 | } |
klauss | 117:e9facba9db27 | 2345 | } |
klauss | 117:e9facba9db27 | 2346 | if( debug_uart3 ) pc.printf("dconfig - volta as configuracoes do sistema para o padrao de fabrica\n\r"); |
klauss | 117:e9facba9db27 | 2347 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2348 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "dconfig - volta as configuracoes do sistema para o padrao de fabrica\n\r" ); |
klauss | 117:e9facba9db27 | 2349 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2350 | |
klauss | 117:e9facba9db27 | 2351 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2352 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 2353 | } |
klauss | 117:e9facba9db27 | 2354 | } |
klauss | 117:e9facba9db27 | 2355 | if( debug_uart3 ) pc.printf("callme [ramal porta] - envia o pedido de ligacao para o callbox com o ramal e porta indicada\n\r"); |
klauss | 117:e9facba9db27 | 2356 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2357 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "callme [ramal porta] - envia o pedido de ligacao para o callbox com o ramal e porta indicada\n\r" ); |
klauss | 117:e9facba9db27 | 2358 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2359 | |
klauss | 117:e9facba9db27 | 2360 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2361 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2362 | } |
klauss | 45:c80574f24dc3 | 2363 | } |
klauss | 117:e9facba9db27 | 2364 | if( debug_uart3 ) pc.printf("pcb porta comando - envia o <comando> para o cbx <ramal> e <porta> executar\n\r"); |
klauss | 117:e9facba9db27 | 2365 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2366 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "promptcb ramal porta comando - envia o <comando> para o cbx <ramal> e <porta> executar\n\r" ); |
klauss | 117:e9facba9db27 | 2367 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2368 | |
klauss | 117:e9facba9db27 | 2369 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2370 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2371 | } |
klauss | 45:c80574f24dc3 | 2372 | } |
klauss | 117:e9facba9db27 | 2373 | if( debug_uart3 ) pc.printf("format - formata o sistema de arquivos\n\r"); |
klauss | 117:e9facba9db27 | 2374 | //desabilitado via eth |
klauss | 117:e9facba9db27 | 2375 | /* |
klauss | 117:e9facba9db27 | 2376 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2377 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "format - formata o sistema de arquivos\n\r" ); |
klauss | 117:e9facba9db27 | 2378 | if( tcp_session ) tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 2379 | |
klauss | 117:e9facba9db27 | 2380 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2381 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2382 | } |
klauss | 45:c80574f24dc3 | 2383 | } |
klauss | 117:e9facba9db27 | 2384 | */ |
klauss | 117:e9facba9db27 | 2385 | if( debug_uart3 ) pc.printf("reset - resta o sistema\n\r"); |
klauss | 117:e9facba9db27 | 2386 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 2387 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "reset - resta o sistema\n\r" ); |
klauss | 117:e9facba9db27 | 2388 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2389 | |
klauss | 117:e9facba9db27 | 2390 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2391 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 114:472502b31a12 | 2392 | } |
klauss | 114:472502b31a12 | 2393 | } |
klauss | 117:e9facba9db27 | 2394 | if( debug_uart3 ) pc.printf("ipset [ip] - Configura o IP da cabeceira\n\r"); |
klauss | 117:e9facba9db27 | 2395 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2396 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ipset [ip] - Configura o IP da cabeceira\n\r" ); |
klauss | 117:e9facba9db27 | 2397 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2398 | |
klauss | 117:e9facba9db27 | 2399 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2400 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2401 | } |
klauss | 45:c80574f24dc3 | 2402 | } |
klauss | 117:e9facba9db27 | 2403 | if( debug_uart3 ) pc.printf("extset [ext] - Configura a ext da cabeceira\n\r"); |
klauss | 117:e9facba9db27 | 2404 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2405 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "extset [ext] - Configura a ext da cabeceira\n\r" ); |
klauss | 117:e9facba9db27 | 2406 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2407 | |
klauss | 117:e9facba9db27 | 2408 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2409 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2410 | } |
klauss | 45:c80574f24dc3 | 2411 | } |
klauss | 117:e9facba9db27 | 2412 | if( debug_uart3 ) pc.printf("msipport [port] - Configura a porta SIP da cabeceira\n\r"); |
klauss | 117:e9facba9db27 | 2413 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2414 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "msipport [port] - Configura a porta SIP da cabeceira\n\r" ); |
klauss | 117:e9facba9db27 | 2415 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2416 | |
klauss | 117:e9facba9db27 | 2417 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2418 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2419 | } |
klauss | 45:c80574f24dc3 | 2420 | } |
klauss | 117:e9facba9db27 | 2421 | if( debug_uart3 ) pc.printf("serverip [ip] - Configura o ip do servidor asterisk\n\r"); |
klauss | 117:e9facba9db27 | 2422 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2423 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "serverip [ip] - Configura o ip do servidor asterisk\n\r" ); |
klauss | 117:e9facba9db27 | 2424 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2425 | |
klauss | 117:e9facba9db27 | 2426 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2427 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2428 | } |
klauss | 45:c80574f24dc3 | 2429 | } |
klauss | 117:e9facba9db27 | 2430 | if( debug_uart3 ) pc.printf("serextset [ext] - Configura a server ext da cabeceira\n\r"); |
klauss | 117:e9facba9db27 | 2431 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2432 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "serextset [ext] - Configura a server ext da cabeceira\n\r" ); |
klauss | 117:e9facba9db27 | 2433 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2434 | |
klauss | 117:e9facba9db27 | 2435 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2436 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2437 | } |
klauss | 45:c80574f24dc3 | 2438 | } |
klauss | 117:e9facba9db27 | 2439 | if( debug_uart3 ) pc.printf("ssport [port] - Configura a porta SIP do servidor asterisk\n\r"); |
klauss | 117:e9facba9db27 | 2440 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2441 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ssport [port] - Configura a porta SIP do servidor asterisk\n\r" ); |
klauss | 117:e9facba9db27 | 2442 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2443 | |
klauss | 117:e9facba9db27 | 2444 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2445 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2446 | } |
klauss | 45:c80574f24dc3 | 2447 | } |
klauss | 117:e9facba9db27 | 2448 | if( debug_uart3 ) pc.printf("maskset [mask] - Configura a mascara da cabeceira\n\r"); |
klauss | 117:e9facba9db27 | 2449 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2450 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "maskset [mask] - Configura a mascara da cabeceira\n\r" ); |
klauss | 117:e9facba9db27 | 2451 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2452 | |
klauss | 117:e9facba9db27 | 2453 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2454 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2455 | } |
klauss | 45:c80574f24dc3 | 2456 | } |
klauss | 117:e9facba9db27 | 2457 | if( debug_uart3 ) pc.printf("gatewayset [gateway] - Configura o gateway da cabeceira\n\r"); |
klauss | 117:e9facba9db27 | 2458 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2459 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "gatewayset [gateway] - Configura o gateway da cabeceira\n\r" ); |
klauss | 117:e9facba9db27 | 2460 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2461 | |
klauss | 117:e9facba9db27 | 2462 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2463 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2464 | } |
klauss | 45:c80574f24dc3 | 2465 | } |
klauss | 117:e9facba9db27 | 2466 | if( debug_uart3 ) pc.printf("telemetry_ip - Configura o IP do servidor de telemetria\n\r"); |
klauss | 117:e9facba9db27 | 2467 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2468 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "telemetry_ip - Configura o IP do servidor de telemetria\n\r" ); |
klauss | 117:e9facba9db27 | 2469 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2470 | |
klauss | 117:e9facba9db27 | 2471 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2472 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 56:c64bcbaa621a | 2473 | } |
klauss | 56:c64bcbaa621a | 2474 | } |
klauss | 117:e9facba9db27 | 2475 | if( debug_uart3 ) pc.printf("telemetry_port - Configura a port do servidor de telemetria\n\r"); |
klauss | 117:e9facba9db27 | 2476 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2477 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "telemetry_port - Configura a port do servidor de telemetria\n\r" ); |
klauss | 117:e9facba9db27 | 2478 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2479 | |
klauss | 117:e9facba9db27 | 2480 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2481 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 99:e80850c51106 | 2482 | } |
klauss | 99:e80850c51106 | 2483 | } |
klauss | 117:e9facba9db27 | 2484 | |
klauss | 117:e9facba9db27 | 2485 | if( debug_uart3 ) pc.printf("fw_ip - Configura o IP do servidor de fw\n\r"); |
klauss | 117:e9facba9db27 | 2486 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2487 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "fw_ip - Configura o IP do servidor de fw\n\r" ); |
klauss | 117:e9facba9db27 | 2488 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2489 | |
klauss | 117:e9facba9db27 | 2490 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2491 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 99:e80850c51106 | 2492 | } |
klauss | 99:e80850c51106 | 2493 | } |
klauss | 117:e9facba9db27 | 2494 | if( debug_uart3 ) pc.printf("fw_port - Configura a porta do servidor de fw\n\r"); |
klauss | 117:e9facba9db27 | 2495 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2496 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "fw_port - Configura a porta do servidor de fw\n\r" ); |
klauss | 117:e9facba9db27 | 2497 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2498 | |
klauss | 117:e9facba9db27 | 2499 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2500 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 2501 | } |
klauss | 117:e9facba9db27 | 2502 | } |
klauss | 117:e9facba9db27 | 2503 | |
klauss | 117:e9facba9db27 | 2504 | if( debug_uart3 ) pc.printf("maxext - Configura o maior ramal possivel de ser registrado nesse ramo\n\r"); |
klauss | 117:e9facba9db27 | 2505 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2506 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "maxext - Configura o maior ramal possivel de ser registrado nesse ramo\n\r" ); |
klauss | 117:e9facba9db27 | 2507 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2508 | |
klauss | 117:e9facba9db27 | 2509 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2510 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 81:3656f00ab3db | 2511 | } |
klauss | 81:3656f00ab3db | 2512 | } |
klauss | 117:e9facba9db27 | 2513 | |
klauss | 117:e9facba9db27 | 2514 | if( debug_uart3 ) pc.printf("minext - Configura o menor ramal possivel de ser registrado nesse ramo\n\r"); |
klauss | 117:e9facba9db27 | 2515 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2516 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "minext - Configura o menor ramal possivel de ser registrado nesse ramo\n\r" ); |
klauss | 117:e9facba9db27 | 2517 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2518 | |
klauss | 117:e9facba9db27 | 2519 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2520 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 81:3656f00ab3db | 2521 | } |
klauss | 81:3656f00ab3db | 2522 | } |
klauss | 117:e9facba9db27 | 2523 | |
klauss | 117:e9facba9db27 | 2524 | if( debug_uart3 ) pc.printf("showcb - lista os Cbx registrados na header\n\r"); |
klauss | 117:e9facba9db27 | 2525 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2526 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "showcb - lista os Cbx registrados na header\n\r" ); |
klauss | 117:e9facba9db27 | 2527 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2528 | |
klauss | 117:e9facba9db27 | 2529 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2530 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2531 | } |
klauss | 45:c80574f24dc3 | 2532 | } |
klauss | 117:e9facba9db27 | 2533 | /* |
klauss | 117:e9facba9db27 | 2534 | if( debug_uart3 ) pc.printf("status - lista resumida de cbx registrados na header\n\r"); |
klauss | 117:e9facba9db27 | 2535 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2536 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "showcb - lista resumida de cbx registrados na header\n\r" ); |
klauss | 117:e9facba9db27 | 2537 | if( tcp_session ) tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 2538 | |
klauss | 117:e9facba9db27 | 2539 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2540 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 52:12930cef17c4 | 2541 | } |
klauss | 52:12930cef17c4 | 2542 | } |
klauss | 117:e9facba9db27 | 2543 | */ |
klauss | 117:e9facba9db27 | 2544 | if( debug_uart3 ) pc.printf("cks - exibe estatisticas de check sum\n\r"); |
klauss | 117:e9facba9db27 | 2545 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2546 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "cks - exibe estatisticas de check sum\n\r" ); |
klauss | 117:e9facba9db27 | 2547 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2548 | |
klauss | 117:e9facba9db27 | 2549 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2550 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2551 | } |
klauss | 45:c80574f24dc3 | 2552 | } |
klauss | 117:e9facba9db27 | 2553 | if( debug_uart3 ) pc.printf("reset_cks - reseta estatisticas de check sum\n\r"); |
klauss | 117:e9facba9db27 | 2554 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2555 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "reset_cks - reseta estatisticas de check sum\n\r" ); |
klauss | 117:e9facba9db27 | 2556 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2557 | |
klauss | 117:e9facba9db27 | 2558 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2559 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2560 | } |
klauss | 45:c80574f24dc3 | 2561 | } |
klauss | 117:e9facba9db27 | 2562 | |
klauss | 117:e9facba9db27 | 2563 | if( debug_uart3 ) pc.printf(". - executa o comando anterior novamente\n\r"); |
klauss | 117:e9facba9db27 | 2564 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2565 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, ". - executa o comando anterior novamente\n\r" ); |
klauss | 117:e9facba9db27 | 2566 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2567 | |
klauss | 117:e9facba9db27 | 2568 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2569 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 62:07e5bdc9f8f7 | 2570 | } |
klauss | 62:07e5bdc9f8f7 | 2571 | } |
klauss | 117:e9facba9db27 | 2572 | if( debug_uart3 ) pc.printf("debug [on|off|show] - seleciona debugs gerais | lista de debugs \n\r"); |
klauss | 117:e9facba9db27 | 2573 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2574 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "debug [on|off|show] - seleciona debugs gerais | lista de debugs \n\r" ); |
klauss | 117:e9facba9db27 | 2575 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2576 | |
klauss | 117:e9facba9db27 | 2577 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2578 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 65:0b653cfe95db | 2579 | } |
klauss | 65:0b653cfe95db | 2580 | } |
klauss | 117:e9facba9db27 | 2581 | if( debug_uart3 ) pc.printf("{ flood [ on | off ] | [+|-] } - simula envio de pacotes de audio\n\r"); |
klauss | 117:e9facba9db27 | 2582 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2583 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "{ flood [ on | off ] | [+|-] } - simula envio de pacotes de audio\n\r"); |
klauss | 117:e9facba9db27 | 2584 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2585 | |
klauss | 117:e9facba9db27 | 2586 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2587 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 2588 | } |
klauss | 117:e9facba9db27 | 2589 | } |
klauss | 117:e9facba9db27 | 2590 | |
klauss | 117:e9facba9db27 | 2591 | if( debug_uart3 ) pc.printf("silence <start_ext end_ext> - envia comando de flood off para os ramais no intervalo end_ext - start_ext\n\r"); |
klauss | 117:e9facba9db27 | 2592 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2593 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "silence <start_ext end_ext> - envia comando de flood off para os ramais no intervalo end_ext - start_ext\n\r"); |
klauss | 117:e9facba9db27 | 2594 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2595 | |
klauss | 117:e9facba9db27 | 2596 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2597 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2598 | } |
klauss | 45:c80574f24dc3 | 2599 | } |
klauss | 117:e9facba9db27 | 2600 | |
klauss | 117:e9facba9db27 | 2601 | if( debug_uart3 ) pc.printf("++ ext - Header flood on, ext flood on\n\r"); |
klauss | 117:e9facba9db27 | 2602 | if( from_eth ){ |
klauss | 66:3f1d22e69e7b | 2603 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "++ ext - Header flood on, ext flood on\n\r"); |
klauss | 117:e9facba9db27 | 2604 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2605 | |
klauss | 117:e9facba9db27 | 2606 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2607 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 66:3f1d22e69e7b | 2608 | } |
klauss | 66:3f1d22e69e7b | 2609 | } |
klauss | 117:e9facba9db27 | 2610 | |
klauss | 117:e9facba9db27 | 2611 | if( debug_uart3 ) pc.printf("-- ext - Header flood off, ext flood off\n\r"); |
klauss | 117:e9facba9db27 | 2612 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2613 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "++ ext - Header flood on, ext flood on\n\r"); |
klauss | 117:e9facba9db27 | 2614 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2615 | |
klauss | 117:e9facba9db27 | 2616 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2617 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 64:5b011d5707d2 | 2618 | } |
klauss | 64:5b011d5707d2 | 2619 | } |
klauss | 117:e9facba9db27 | 2620 | |
klauss | 117:e9facba9db27 | 2621 | if( debug_uart3 ) pc.printf("rx - Exibe ultimo pacote recebido dos CBx\n\r"); |
klauss | 117:e9facba9db27 | 2622 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2623 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "rx - Exibe ultimo pacote recebido dos CBx\n\r"); |
klauss | 117:e9facba9db27 | 2624 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2625 | |
klauss | 117:e9facba9db27 | 2626 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2627 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 64:5b011d5707d2 | 2628 | } |
klauss | 64:5b011d5707d2 | 2629 | } |
klauss | 117:e9facba9db27 | 2630 | if( debug_uart3 ) pc.printf("tx - Exibe ultimo pacote enviado para os CBx\n\r"); |
klauss | 117:e9facba9db27 | 2631 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2632 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "tx - Exibe ultimo pacote enviado para os CBx\n\r"); |
klauss | 117:e9facba9db27 | 2633 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2634 | |
klauss | 117:e9facba9db27 | 2635 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2636 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 64:5b011d5707d2 | 2637 | } |
klauss | 64:5b011d5707d2 | 2638 | } |
klauss | 117:e9facba9db27 | 2639 | if( debug_uart3 ) pc.printf("ls | status - Exibe uma lista ordenada por ext do CBx registrados na Header\n\r"); |
klauss | 117:e9facba9db27 | 2640 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2641 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ls | status - Exibe uma lista ordenada por ext do CBx registrados na Header\n\r"); |
klauss | 117:e9facba9db27 | 2642 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2643 | |
klauss | 117:e9facba9db27 | 2644 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2645 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 104:62646ef786a3 | 2646 | } |
klauss | 104:62646ef786a3 | 2647 | } |
klauss | 117:e9facba9db27 | 2648 | if( debug_uart3 ) pc.printf("types - Lista os types usados no protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 117:e9facba9db27 | 2649 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2650 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "types - Lista os types usados no protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 117:e9facba9db27 | 2651 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2652 | |
klauss | 117:e9facba9db27 | 2653 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2654 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 104:62646ef786a3 | 2655 | } |
klauss | 104:62646ef786a3 | 2656 | } |
klauss | 117:e9facba9db27 | 2657 | if( debug_uart3 ) pc.printf("protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 117:e9facba9db27 | 2658 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2659 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 117:e9facba9db27 | 2660 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 117:e9facba9db27 | 2661 | |
klauss | 117:e9facba9db27 | 2662 | else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2663 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 2664 | } |
klauss | 117:e9facba9db27 | 2665 | } |
klauss | 117:e9facba9db27 | 2666 | |
klauss | 117:e9facba9db27 | 2667 | if( debug_uart3 ) pc.printf("PROMPT VERSION: V%d\n\r",PVERSION); |
klauss | 117:e9facba9db27 | 2668 | //Obs :: a ultima linha nao mandamos direto pro tcp porque ela eh enviada fora desse escopo |
klauss | 117:e9facba9db27 | 2669 | if( from_eth ) snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "PROMPT VERSION: V%d\n\r",PVERSION); |
klauss | 105:a930035b6556 | 2670 | } |
klauss | 114:472502b31a12 | 2671 | |
klauss | 117:e9facba9db27 | 2672 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "callme ", 7 )){ |
klauss | 105:a930035b6556 | 2673 | miss_match = false; |
klauss | 105:a930035b6556 | 2674 | int ext,port; |
klauss | 105:a930035b6556 | 2675 | char cmd[ 16 ]; |
klauss | 117:e9facba9db27 | 2676 | |
klauss | 105:a930035b6556 | 2677 | ext = atoi( debug_buf + 7 ); |
klauss | 105:a930035b6556 | 2678 | port = convert_ext_to_port( ext ); |
klauss | 117:e9facba9db27 | 2679 | |
klauss | 105:a930035b6556 | 2680 | strcpy( cmd, ( ext % 2 ) ? "call init B" : "call init A" ); |
klauss | 117:e9facba9db27 | 2681 | |
klauss | 105:a930035b6556 | 2682 | if( ext % 2 ) ext--; |
klauss | 117:e9facba9db27 | 2683 | |
klauss | 105:a930035b6556 | 2684 | promptcb_last_ext = ext; |
klauss | 105:a930035b6556 | 2685 | promptcb_last_port = port; |
klauss | 117:e9facba9db27 | 2686 | |
klauss | 105:a930035b6556 | 2687 | int tmp = strlen( cmd ); |
klauss | 105:a930035b6556 | 2688 | cmd[ tmp ] = 0x0D; |
klauss | 105:a930035b6556 | 2689 | cmd[ tmp + 1 ] = 0x00; |
klauss | 105:a930035b6556 | 2690 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 117:e9facba9db27 | 2691 | |
klauss | 117:e9facba9db27 | 2692 | if( debug_uart3 ) pc.printf("\r\next=%d port=%d\r\ncmd=%s\r\n", ext, port, cmd ); |
klauss | 117:e9facba9db27 | 2693 | |
klauss | 117:e9facba9db27 | 2694 | if( debug_uart3 ) pc.printf("\n\r--------------------------------------------------------\n\r"); |
klauss | 117:e9facba9db27 | 2695 | for( uint16_t i = 0; i < strlen( cmd ) ; i++ ) if( debug_uart3 ) pc.printf( "%02x ", cmd[ i ] ); |
klauss | 117:e9facba9db27 | 2696 | |
klauss | 117:e9facba9db27 | 2697 | send2callboxes( __build_cb_package__( ext, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 117:e9facba9db27 | 2698 | if( debug_uart3 ) pc.printf("\n\r--------------------------------------------------------\n\r"); |
klauss | 117:e9facba9db27 | 2699 | for( uint16_t i = 0; i < 300 ; i++ ){ |
klauss | 117:e9facba9db27 | 2700 | if( debug_uart3 ) pc.printf( "%02x ", write_buffer[ i ] ); |
klauss | 117:e9facba9db27 | 2701 | if( i != 0 && !( ( i + 1 ) % 30 ) ) if( debug_uart3 ) pc.printf("\n\r"); |
klauss | 117:e9facba9db27 | 2702 | } |
klauss | 117:e9facba9db27 | 2703 | |
klauss | 117:e9facba9db27 | 2704 | |
klauss | 117:e9facba9db27 | 2705 | if( debug_uart3 ) pc.printf("\n\rComando enviado\n\r"); |
klauss | 117:e9facba9db27 | 2706 | |
klauss | 117:e9facba9db27 | 2707 | if( from_eth ){ |
klauss | 105:a930035b6556 | 2708 | char eth_msg[ 512 ]; |
klauss | 105:a930035b6556 | 2709 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d\r\ncmd=%s\r\n\n\rComando enviado\n\r", ext, port, cmd ); |
klauss | 117:e9facba9db27 | 2710 | if( tcp_session ){ |
klauss | 105:a930035b6556 | 2711 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 117:e9facba9db27 | 2712 | }else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2713 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 105:a930035b6556 | 2714 | } |
klauss | 105:a930035b6556 | 2715 | } |
klauss | 117:e9facba9db27 | 2716 | |
klauss | 104:62646ef786a3 | 2717 | bufptr = 0; |
klauss | 117:e9facba9db27 | 2718 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 105:a930035b6556 | 2719 | } |
klauss | 106:a34fcf9f0e02 | 2720 | |
klauss | 114:472502b31a12 | 2721 | if( miss_match ){ |
klauss | 114:472502b31a12 | 2722 | if( debug_uart3 ) pc.printf("\n\r> %s: command not found\n\r", debug_buf ); |
klauss | 114:472502b31a12 | 2723 | if( from_eth ){ |
klauss | 114:472502b31a12 | 2724 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "> %s: command not found\n ", debug_buf ); |
klauss | 114:472502b31a12 | 2725 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 106:a34fcf9f0e02 | 2726 | } |
klauss | 106:a34fcf9f0e02 | 2727 | } |
klauss | 114:472502b31a12 | 2728 | else{ |
klauss | 114:472502b31a12 | 2729 | if( from_eth && strlen( debug_buf ) > 2 ) strcpy( last_cmd, tmp_cmd ); |
klauss | 109:a5b8264ffbbc | 2730 | |
klauss | 114:472502b31a12 | 2731 | else if( strlen( debug_buf ) > 2 ) strcpy( last_cmd, tmp_cmd ); |
klauss | 113:db67ae00550e | 2732 | } |
klauss | 114:472502b31a12 | 2733 | } |
klauss | 117:e9facba9db27 | 2734 | if( b == 0x0D || bufret == 1 || bufptr > DEBUGBUFSIZE ){ |
klauss | 114:472502b31a12 | 2735 | bufret = 0; |
klauss | 117:e9facba9db27 | 2736 | if( from_eth ){ |
klauss | 117:e9facba9db27 | 2737 | from_eth = false; |
klauss | 114:472502b31a12 | 2738 | |
klauss | 117:e9facba9db27 | 2739 | if( debug_buf[ strlen( debug_buf ) - 1 ] == '\r' || debug_buf[ strlen( debug_buf ) - 1 ] == '\n' ) strcat( debug_buf, "> " ); |
klauss | 116:39a41ebb675c | 2740 | |
klauss | 117:e9facba9db27 | 2741 | else strcat( debug_buf, "\n\r> " ); |
klauss | 114:472502b31a12 | 2742 | |
klauss | 117:e9facba9db27 | 2743 | if( tcp_session ){ |
klauss | 117:e9facba9db27 | 2744 | |
klauss | 117:e9facba9db27 | 2745 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 2746 | |
klauss | 117:e9facba9db27 | 2747 | }else if( udp_request ){ |
klauss | 117:e9facba9db27 | 2748 | |
klauss | 117:e9facba9db27 | 2749 | int sent = udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 117:e9facba9db27 | 2750 | |
klauss | 117:e9facba9db27 | 2751 | udp_request = false; |
klauss | 116:39a41ebb675c | 2752 | } |
klauss | 117:e9facba9db27 | 2753 | for( register uint16_t i = 0; i < __PROMPT_ETH_BUFFER_SIZE__; i++ ) eth_buffer[ i ] = 0; |
klauss | 117:e9facba9db27 | 2754 | debug_buf = __debug_buf__; |
klauss | 117:e9facba9db27 | 2755 | bufptr = last_bufptr; |
klauss | 117:e9facba9db27 | 2756 | }else{ |
klauss | 117:e9facba9db27 | 2757 | bufptr = 0; |
klauss | 117:e9facba9db27 | 2758 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 116:39a41ebb675c | 2759 | } |
klauss | 117:e9facba9db27 | 2760 | pc.putc(0x0A); |
klauss | 117:e9facba9db27 | 2761 | pc.putc(0x0D); |
klauss | 117:e9facba9db27 | 2762 | if( debug_uart3 ) pc.printf("> "); |
klauss | 117:e9facba9db27 | 2763 | } |
klauss | 117:e9facba9db27 | 2764 | return( NULL ); |
klauss | 54:448d57291be6 | 2765 | } |