![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
prompt.cpp@112:6ae726539ab9, 2015-04-13 (annotated)
- Committer:
- klauss
- Date:
- Mon Apr 13 12:16:21 2015 +0000
- Revision:
- 112:6ae726539ab9
- Parent:
- 109:a5b8264ffbbc
- Child:
- 113:db67ae00550e
colinas - ramo 3 - 2014 - 04 - 11
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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 20 | int str2uint ( char * s, unsigned int * val ){ |
klauss | 109:a5b8264ffbbc | 21 | int i = 0; |
klauss | 109:a5b8264ffbbc | 22 | unsigned int ret = 0; |
klauss | 109:a5b8264ffbbc | 23 | for (;;) { |
klauss | 109:a5b8264ffbbc | 24 | if (s[i] < '0') { |
klauss | 109:a5b8264ffbbc | 25 | *val = ret; |
klauss | 109:a5b8264ffbbc | 26 | return i; |
klauss | 109:a5b8264ffbbc | 27 | } |
klauss | 109:a5b8264ffbbc | 28 | ret *= 10; |
klauss | 109:a5b8264ffbbc | 29 | ret += s[i] - '0'; |
klauss | 109:a5b8264ffbbc | 30 | i++; |
klauss | 109:a5b8264ffbbc | 31 | } |
klauss | 109:a5b8264ffbbc | 32 | } |
klauss | 19:ab2088e0dec6 | 33 | |
klauss | 109:a5b8264ffbbc | 34 | // operantion with the system config files |
klauss | 109:a5b8264ffbbc | 35 | void files( const char type ){ |
klauss | 109:a5b8264ffbbc | 36 | // show files |
klauss | 109:a5b8264ffbbc | 37 | if (type == 's' ){ |
klauss | 109:a5b8264ffbbc | 38 | if( debug_uart3 ) pc.printf("Header IP " ); |
klauss | 109:a5b8264ffbbc | 39 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 40 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Header IP " ); |
klauss | 109:a5b8264ffbbc | 41 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 42 | |
klauss | 109:a5b8264ffbbc | 43 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 44 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 45 | } |
klauss | 109:a5b8264ffbbc | 46 | } |
klauss | 109:a5b8264ffbbc | 47 | |
klauss | 109:a5b8264ffbbc | 48 | cat("/qspi/myip.txt"); |
klauss | 109:a5b8264ffbbc | 49 | |
klauss | 109:a5b8264ffbbc | 50 | if( debug_uart3 ) pc.printf("Header ext "); |
klauss | 109:a5b8264ffbbc | 51 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 52 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Header ext " ); |
klauss | 109:a5b8264ffbbc | 53 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 54 | |
klauss | 109:a5b8264ffbbc | 55 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 56 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 57 | } |
klauss | 109:a5b8264ffbbc | 58 | } |
klauss | 109:a5b8264ffbbc | 59 | |
klauss | 109:a5b8264ffbbc | 60 | cat("/qspi/myext.txt"); |
klauss | 109:a5b8264ffbbc | 61 | |
klauss | 109:a5b8264ffbbc | 62 | if( debug_uart3 ) pc.printf("Header port "); |
klauss | 109:a5b8264ffbbc | 63 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 64 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Header port " ); |
klauss | 109:a5b8264ffbbc | 65 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 66 | |
klauss | 109:a5b8264ffbbc | 67 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 68 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 69 | } |
klauss | 109:a5b8264ffbbc | 70 | } |
klauss | 109:a5b8264ffbbc | 71 | |
klauss | 109:a5b8264ffbbc | 72 | cat("/qspi/mysipport.txt"); |
klauss | 109:a5b8264ffbbc | 73 | |
klauss | 109:a5b8264ffbbc | 74 | if( debug_uart3 ) pc.printf("Server IP "); |
klauss | 109:a5b8264ffbbc | 75 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 76 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Server IP " ); |
klauss | 109:a5b8264ffbbc | 77 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 78 | |
klauss | 109:a5b8264ffbbc | 79 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 80 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 81 | } |
klauss | 109:a5b8264ffbbc | 82 | } |
klauss | 109:a5b8264ffbbc | 83 | |
klauss | 109:a5b8264ffbbc | 84 | cat("/qspi/serverip.txt"); |
klauss | 109:a5b8264ffbbc | 85 | |
klauss | 109:a5b8264ffbbc | 86 | if( debug_uart3 ) pc.printf("Server ext "); |
klauss | 109:a5b8264ffbbc | 87 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 88 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Server ext " ); |
klauss | 109:a5b8264ffbbc | 89 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 90 | |
klauss | 109:a5b8264ffbbc | 91 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 92 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 93 | } |
klauss | 109:a5b8264ffbbc | 94 | } |
klauss | 109:a5b8264ffbbc | 95 | |
klauss | 109:a5b8264ffbbc | 96 | cat("/qspi/peerext.txt"); |
klauss | 109:a5b8264ffbbc | 97 | |
klauss | 109:a5b8264ffbbc | 98 | if( debug_uart3 ) pc.printf("Server port "); |
klauss | 109:a5b8264ffbbc | 99 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 100 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Server port " ); |
klauss | 109:a5b8264ffbbc | 101 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 102 | |
klauss | 109:a5b8264ffbbc | 103 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 104 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 105 | } |
klauss | 109:a5b8264ffbbc | 106 | } |
klauss | 109:a5b8264ffbbc | 107 | cat("/qspi/serverport.txt"); |
klauss | 109:a5b8264ffbbc | 108 | |
klauss | 109:a5b8264ffbbc | 109 | if( debug_uart3 ) pc.printf("Mascara de rede "); |
klauss | 109:a5b8264ffbbc | 110 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 111 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Mascara de rede " ); |
klauss | 109:a5b8264ffbbc | 112 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 113 | |
klauss | 109:a5b8264ffbbc | 114 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 115 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 116 | } |
klauss | 109:a5b8264ffbbc | 117 | } |
klauss | 109:a5b8264ffbbc | 118 | cat("/qspi/mymask.txt"); |
klauss | 109:a5b8264ffbbc | 119 | |
klauss | 109:a5b8264ffbbc | 120 | if( debug_uart3 ) pc.printf("Gateway IP "); |
klauss | 109:a5b8264ffbbc | 121 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 122 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Gateway IP " ); |
klauss | 109:a5b8264ffbbc | 123 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 124 | |
klauss | 109:a5b8264ffbbc | 125 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 126 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 127 | } |
klauss | 109:a5b8264ffbbc | 128 | } |
klauss | 109:a5b8264ffbbc | 129 | cat("/qspi/mygateway.txt"); |
klauss | 109:a5b8264ffbbc | 130 | |
klauss | 109:a5b8264ffbbc | 131 | if( debug_uart3 ) pc.printf("UDP Port "); |
klauss | 109:a5b8264ffbbc | 132 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 133 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "UDP Port " ); |
klauss | 109:a5b8264ffbbc | 134 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 135 | |
klauss | 109:a5b8264ffbbc | 136 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 137 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 138 | } |
klauss | 109:a5b8264ffbbc | 139 | } |
klauss | 109:a5b8264ffbbc | 140 | |
klauss | 109:a5b8264ffbbc | 141 | cat("/qspi/udpport.txt"); |
klauss | 109:a5b8264ffbbc | 142 | |
klauss | 109:a5b8264ffbbc | 143 | if( debug_uart3 ) pc.printf("TCP Port "); |
klauss | 109:a5b8264ffbbc | 144 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 145 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "TCP Port " ); |
klauss | 109:a5b8264ffbbc | 146 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 147 | |
klauss | 109:a5b8264ffbbc | 148 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 149 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 150 | } |
klauss | 109:a5b8264ffbbc | 151 | } |
klauss | 109:a5b8264ffbbc | 152 | |
klauss | 109:a5b8264ffbbc | 153 | cat("/qspi/tcpport.txt"); |
klauss | 109:a5b8264ffbbc | 154 | |
klauss | 109:a5b8264ffbbc | 155 | if( debug_uart3 ) pc.printf("Telemetry Server IP "); |
klauss | 109:a5b8264ffbbc | 156 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 157 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Telemetry Server IP " ); |
klauss | 109:a5b8264ffbbc | 158 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 159 | |
klauss | 109:a5b8264ffbbc | 160 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 161 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 162 | } |
klauss | 109:a5b8264ffbbc | 163 | } |
klauss | 109:a5b8264ffbbc | 164 | |
klauss | 109:a5b8264ffbbc | 165 | cat("/qspi/telemetry_ip.txt"); |
klauss | 109:a5b8264ffbbc | 166 | |
klauss | 109:a5b8264ffbbc | 167 | if( debug_uart3 ) pc.printf("Telemetry Server Port "); |
klauss | 109:a5b8264ffbbc | 168 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 169 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Telemetry Server Port " ); |
klauss | 109:a5b8264ffbbc | 170 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 171 | |
klauss | 109:a5b8264ffbbc | 172 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 173 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 174 | } |
klauss | 109:a5b8264ffbbc | 175 | } |
klauss | 109:a5b8264ffbbc | 176 | |
klauss | 109:a5b8264ffbbc | 177 | cat("/qspi/telemetry_port.txt"); |
klauss | 109:a5b8264ffbbc | 178 | |
klauss | 109:a5b8264ffbbc | 179 | /* |
klauss | 109:a5b8264ffbbc | 180 | if( debug_uart3 ) pc.printf("FW Server IP "); |
klauss | 109:a5b8264ffbbc | 181 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 182 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FW Server IP " ); |
klauss | 109:a5b8264ffbbc | 183 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 184 | |
klauss | 109:a5b8264ffbbc | 185 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 186 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 187 | } |
klauss | 109:a5b8264ffbbc | 188 | } |
klauss | 109:a5b8264ffbbc | 189 | |
klauss | 109:a5b8264ffbbc | 190 | cat("/qspi/fw_ip.txt"); |
klauss | 109:a5b8264ffbbc | 191 | |
klauss | 109:a5b8264ffbbc | 192 | if( debug_uart3 ) pc.printf("FW Server Port "); |
klauss | 109:a5b8264ffbbc | 193 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 194 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Fw Server Port " ); |
klauss | 109:a5b8264ffbbc | 195 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 196 | |
klauss | 109:a5b8264ffbbc | 197 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 198 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 199 | } |
klauss | 109:a5b8264ffbbc | 200 | } |
klauss | 109:a5b8264ffbbc | 201 | |
klauss | 109:a5b8264ffbbc | 202 | cat("/qspi/fw_port.txt"); |
klauss | 109:a5b8264ffbbc | 203 | */ |
klauss | 109:a5b8264ffbbc | 204 | |
klauss | 109:a5b8264ffbbc | 205 | if( debug_uart3 ) pc.printf("FW Server IP "); |
klauss | 109:a5b8264ffbbc | 206 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 207 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FW Server IP " ); |
klauss | 109:a5b8264ffbbc | 208 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 209 | |
klauss | 109:a5b8264ffbbc | 210 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 211 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 212 | } |
klauss | 109:a5b8264ffbbc | 213 | } |
klauss | 109:a5b8264ffbbc | 214 | |
klauss | 109:a5b8264ffbbc | 215 | cat("/qspi/fw_ip.txt"); |
klauss | 109:a5b8264ffbbc | 216 | |
klauss | 109:a5b8264ffbbc | 217 | if( debug_uart3 ) pc.printf("FW Server Port "); |
klauss | 109:a5b8264ffbbc | 218 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 219 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FW Server Port " ); |
klauss | 109:a5b8264ffbbc | 220 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 221 | |
klauss | 109:a5b8264ffbbc | 222 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 223 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 224 | } |
klauss | 109:a5b8264ffbbc | 225 | } |
klauss | 109:a5b8264ffbbc | 226 | |
klauss | 109:a5b8264ffbbc | 227 | cat("/qspi/fw_port.txt"); |
klauss | 109:a5b8264ffbbc | 228 | |
klauss | 109:a5b8264ffbbc | 229 | if( debug_uart3 ) pc.printf("Max Ext "); |
klauss | 109:a5b8264ffbbc | 230 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 231 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Max Ext " ); |
klauss | 109:a5b8264ffbbc | 232 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 233 | |
klauss | 109:a5b8264ffbbc | 234 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 235 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 236 | } |
klauss | 109:a5b8264ffbbc | 237 | } |
klauss | 109:a5b8264ffbbc | 238 | |
klauss | 109:a5b8264ffbbc | 239 | cat("/qspi/maxext.txt"); |
klauss | 109:a5b8264ffbbc | 240 | |
klauss | 109:a5b8264ffbbc | 241 | if( debug_uart3 ) pc.printf("Min Ext "); |
klauss | 109:a5b8264ffbbc | 242 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 243 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Min Ext " ); |
klauss | 109:a5b8264ffbbc | 244 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 245 | |
klauss | 109:a5b8264ffbbc | 246 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 247 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 248 | } |
klauss | 109:a5b8264ffbbc | 249 | } |
klauss | 109:a5b8264ffbbc | 250 | |
klauss | 109:a5b8264ffbbc | 251 | cat("/qspi/minext.txt"); |
klauss | 109:a5b8264ffbbc | 252 | |
klauss | 109:a5b8264ffbbc | 253 | |
klauss | 109:a5b8264ffbbc | 254 | //*------------ formatando a saida ----------------*// |
klauss | 109:a5b8264ffbbc | 255 | strcpy( last_cmd, tmp_cmd ); |
klauss | 109:a5b8264ffbbc | 256 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 257 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 258 | |
klauss | 109:a5b8264ffbbc | 259 | if( tcp_session ) tcp_client.send_all( "\n\r> " , strlen( "\n\r> " ) ); |
klauss | 109:a5b8264ffbbc | 260 | |
klauss | 109:a5b8264ffbbc | 261 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 262 | udp_server.sendTo( udp_client, "\n\r> ", strlen( "\n\r> " ) ); |
klauss | 109:a5b8264ffbbc | 263 | } |
klauss | 109:a5b8264ffbbc | 264 | } |
klauss | 109:a5b8264ffbbc | 265 | |
klauss | 109:a5b8264ffbbc | 266 | if (type == 'c' ){ |
klauss | 109:a5b8264ffbbc | 267 | // close all files |
klauss | 109:a5b8264ffbbc | 268 | //debug_msg(""); |
klauss | 109:a5b8264ffbbc | 269 | if( fip ) fclose( fip ); |
klauss | 109:a5b8264ffbbc | 270 | if( fmask ) fclose( fmask ); |
klauss | 109:a5b8264ffbbc | 271 | if( fgate ) fclose( fgate ); |
klauss | 109:a5b8264ffbbc | 272 | if( fport )fclose( fport ); |
klauss | 109:a5b8264ffbbc | 273 | if( fsip ) fclose( fsip ); |
klauss | 109:a5b8264ffbbc | 274 | if( fsport ) fclose( fsport ); |
klauss | 109:a5b8264ffbbc | 275 | if( fext ) fclose( fext ); |
klauss | 109:a5b8264ffbbc | 276 | if( fserext ) fclose( fserext ); |
klauss | 109:a5b8264ffbbc | 277 | if( fudpport ) fclose( fudpport ); |
klauss | 109:a5b8264ffbbc | 278 | if( ftcpport ) fclose( ftcpport ); |
klauss | 109:a5b8264ffbbc | 279 | if( fmax ) fclose( fmax ); |
klauss | 109:a5b8264ffbbc | 280 | if( fmin ) fclose( fmin ); |
klauss | 109:a5b8264ffbbc | 281 | if( ftip ) fclose( ftip ); |
klauss | 109:a5b8264ffbbc | 282 | if( ftport ) fclose( ftport ); |
klauss | 109:a5b8264ffbbc | 283 | if( ffwip ) fclose( ffwip ); |
klauss | 109:a5b8264ffbbc | 284 | if( ffwport) fclose( ffwport ); |
klauss | 109:a5b8264ffbbc | 285 | //debug_msg(""); |
klauss | 109:a5b8264ffbbc | 286 | } |
klauss | 109:a5b8264ffbbc | 287 | |
klauss | 109:a5b8264ffbbc | 288 | if (type == 'i' ){ |
klauss | 109:a5b8264ffbbc | 289 | //debug_msg(""); |
klauss | 109:a5b8264ffbbc | 290 | // Check if files exist, if not create the files |
klauss | 109:a5b8264ffbbc | 291 | //fixme criar um bool pra cada file |
klauss | 109:a5b8264ffbbc | 292 | bool exists = true; |
klauss | 109:a5b8264ffbbc | 293 | |
klauss | 109:a5b8264ffbbc | 294 | fip = fopen("/qspi/myip.txt", "r"); |
klauss | 109:a5b8264ffbbc | 295 | if( fip == NULL){ |
klauss | 109:a5b8264ffbbc | 296 | set_ip( __MY_IP__ ); |
klauss | 109:a5b8264ffbbc | 297 | exists = false; |
klauss | 109:a5b8264ffbbc | 298 | } |
klauss | 109:a5b8264ffbbc | 299 | //fclose( fip ); |
klauss | 109:a5b8264ffbbc | 300 | |
klauss | 109:a5b8264ffbbc | 301 | fserext = fopen("/qspi/myext.txt", "r"); |
klauss | 109:a5b8264ffbbc | 302 | if( fserext == NULL ){ |
klauss | 109:a5b8264ffbbc | 303 | set_header_ext( __MY_EXT__ ); |
klauss | 109:a5b8264ffbbc | 304 | exists = false; |
klauss | 109:a5b8264ffbbc | 305 | } |
klauss | 109:a5b8264ffbbc | 306 | //fclose( fserext ); |
klauss | 109:a5b8264ffbbc | 307 | |
klauss | 109:a5b8264ffbbc | 308 | fport = fopen("/qspi/mysipport.txt", "r"); |
klauss | 109:a5b8264ffbbc | 309 | if (fport == NULL){ |
klauss | 109:a5b8264ffbbc | 310 | set_header_sip_port( __MY_PORT__ ); |
klauss | 109:a5b8264ffbbc | 311 | exists = false; |
klauss | 109:a5b8264ffbbc | 312 | } |
klauss | 109:a5b8264ffbbc | 313 | //fclose( fport ); |
klauss | 109:a5b8264ffbbc | 314 | |
klauss | 109:a5b8264ffbbc | 315 | fsip = fopen("/qspi/serverip.txt", "r"); |
klauss | 109:a5b8264ffbbc | 316 | if (fsip == NULL){ |
klauss | 109:a5b8264ffbbc | 317 | set_server_ip( __SERVER_IP__ ); |
klauss | 109:a5b8264ffbbc | 318 | exists = false; |
klauss | 109:a5b8264ffbbc | 319 | } |
klauss | 109:a5b8264ffbbc | 320 | //fclose( fsip ); |
klauss | 109:a5b8264ffbbc | 321 | |
klauss | 109:a5b8264ffbbc | 322 | fext = fopen("/qspi/peerext.txt", "r"); |
klauss | 109:a5b8264ffbbc | 323 | if ( fext == NULL ){ |
klauss | 109:a5b8264ffbbc | 324 | set_server_ext( __PEER_EXT__ ); |
klauss | 109:a5b8264ffbbc | 325 | exists = false; |
klauss | 109:a5b8264ffbbc | 326 | } |
klauss | 109:a5b8264ffbbc | 327 | //fclose( fext ); |
klauss | 109:a5b8264ffbbc | 328 | |
klauss | 109:a5b8264ffbbc | 329 | fsport = fopen("/qspi/serverport.txt", "r"); |
klauss | 109:a5b8264ffbbc | 330 | if (fsport == NULL){ |
klauss | 109:a5b8264ffbbc | 331 | set_server_port( __SERVER_PORT__ ); |
klauss | 109:a5b8264ffbbc | 332 | exists = false; |
klauss | 109:a5b8264ffbbc | 333 | } |
klauss | 109:a5b8264ffbbc | 334 | //fclose( fsport ); |
klauss | 109:a5b8264ffbbc | 335 | |
klauss | 109:a5b8264ffbbc | 336 | fmask = fopen("/qspi/mymask.txt", "r"); |
klauss | 109:a5b8264ffbbc | 337 | if (fmask == NULL){ |
klauss | 109:a5b8264ffbbc | 338 | set_mask( __MY_MSK__ ); |
klauss | 109:a5b8264ffbbc | 339 | exists = false; |
klauss | 109:a5b8264ffbbc | 340 | } |
klauss | 109:a5b8264ffbbc | 341 | //fclose( fmask ); |
klauss | 109:a5b8264ffbbc | 342 | |
klauss | 109:a5b8264ffbbc | 343 | fgate = fopen("/qspi/mygateway.txt", "r"); |
klauss | 109:a5b8264ffbbc | 344 | if (fgate == NULL){ |
klauss | 109:a5b8264ffbbc | 345 | set_gateway( __MY_GTW__ ); |
klauss | 109:a5b8264ffbbc | 346 | exists = false; |
klauss | 109:a5b8264ffbbc | 347 | } |
klauss | 109:a5b8264ffbbc | 348 | //fclose( fgate ); |
klauss | 109:a5b8264ffbbc | 349 | |
klauss | 109:a5b8264ffbbc | 350 | fudpport = fopen("/qspi/udpport.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 351 | if( fudpport == NULL ){ |
klauss | 109:a5b8264ffbbc | 352 | set_udp_port_listener( UDP_PORT_LISTENER ); |
klauss | 109:a5b8264ffbbc | 353 | exists = false; |
klauss | 109:a5b8264ffbbc | 354 | } |
klauss | 109:a5b8264ffbbc | 355 | //fclose( fudpport ); |
klauss | 109:a5b8264ffbbc | 356 | |
klauss | 109:a5b8264ffbbc | 357 | ftcpport = fopen("/qspi/tcpport.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 358 | if( ftcpport == NULL ){ |
klauss | 109:a5b8264ffbbc | 359 | set_tcp_port_listener( TCP_PORT_LISTENER ); |
klauss | 109:a5b8264ffbbc | 360 | exists = false; |
klauss | 109:a5b8264ffbbc | 361 | } |
klauss | 109:a5b8264ffbbc | 362 | //fclose( ftcpport ); |
klauss | 109:a5b8264ffbbc | 363 | |
klauss | 109:a5b8264ffbbc | 364 | ftip = fopen("/qspi/telemetry_ip.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 365 | if( ftip == NULL ){ |
klauss | 109:a5b8264ffbbc | 366 | set_telemetry_ip( __TELEMETRY_SERVER_IP__ ); |
klauss | 109:a5b8264ffbbc | 367 | exists = false; |
klauss | 109:a5b8264ffbbc | 368 | } |
klauss | 109:a5b8264ffbbc | 369 | //fclose( ftip ); |
klauss | 109:a5b8264ffbbc | 370 | |
klauss | 109:a5b8264ffbbc | 371 | ftport = fopen("/qspi/telemetry_port.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 372 | if( ftport == NULL ){ |
klauss | 109:a5b8264ffbbc | 373 | set_telemetry_port( __TELEMETRY_SERVER_PORT__ ); |
klauss | 109:a5b8264ffbbc | 374 | exists = false; |
klauss | 109:a5b8264ffbbc | 375 | } |
klauss | 109:a5b8264ffbbc | 376 | //fclose( ftport ); |
klauss | 109:a5b8264ffbbc | 377 | |
klauss | 109:a5b8264ffbbc | 378 | //debug_msg(""); |
klauss | 109:a5b8264ffbbc | 379 | ffwip = fopen("/qspi/fw_ip.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 380 | if( ffwip == NULL ){ |
klauss | 109:a5b8264ffbbc | 381 | set_fw_ip( __FW_SERVER_IP__ ); |
klauss | 109:a5b8264ffbbc | 382 | exists = false; |
klauss | 109:a5b8264ffbbc | 383 | } |
klauss | 109:a5b8264ffbbc | 384 | //debug_msg(""); |
klauss | 109:a5b8264ffbbc | 385 | //fclose( ffwip ); |
klauss | 109:a5b8264ffbbc | 386 | //debug_msg(""); |
klauss | 109:a5b8264ffbbc | 387 | ffwport = fopen("/qspi/fw_port.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 388 | if( ffwport == NULL ){ |
klauss | 109:a5b8264ffbbc | 389 | set_fw_port( __FW_SERVER_PORT__ ); |
klauss | 109:a5b8264ffbbc | 390 | exists = false; |
klauss | 109:a5b8264ffbbc | 391 | } |
klauss | 109:a5b8264ffbbc | 392 | //fclose( ffwport ); |
klauss | 109:a5b8264ffbbc | 393 | //debug_msg(""); |
klauss | 109:a5b8264ffbbc | 394 | fmax = fopen("/qspi/maxext.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 395 | //debug_msg(""); |
klauss | 109:a5b8264ffbbc | 396 | if( fmax == NULL ){ |
klauss | 109:a5b8264ffbbc | 397 | //debug_msg(""); |
klauss | 109:a5b8264ffbbc | 398 | set_max_ext( MAX_EXT ); |
klauss | 109:a5b8264ffbbc | 399 | //debug_msg(""); |
klauss | 109:a5b8264ffbbc | 400 | exists = false; |
klauss | 109:a5b8264ffbbc | 401 | //debug_msg(""); |
klauss | 109:a5b8264ffbbc | 402 | } |
klauss | 109:a5b8264ffbbc | 403 | //fclose( fmax ); |
klauss | 109:a5b8264ffbbc | 404 | //debug_msg(""); |
klauss | 109:a5b8264ffbbc | 405 | fmin = fopen("/qspi/minext.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 406 | if( fmin == NULL ){ |
klauss | 109:a5b8264ffbbc | 407 | set_min_ext( MIN_EXT ); |
klauss | 109:a5b8264ffbbc | 408 | exists = false; |
klauss | 109:a5b8264ffbbc | 409 | } |
klauss | 109:a5b8264ffbbc | 410 | //fclose( fmin ); |
klauss | 109:a5b8264ffbbc | 411 | //debug_msg(""); |
klauss | 109:a5b8264ffbbc | 412 | if( !exists ){ |
klauss | 109:a5b8264ffbbc | 413 | if( debug_uart3 ) pc.printf("\n\rDefault configurations set!\n\r"); |
klauss | 109:a5b8264ffbbc | 414 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 415 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Default configurations set!\n\r"); |
klauss | 109:a5b8264ffbbc | 416 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 417 | if( tcp_session ){ |
klauss | 109:a5b8264ffbbc | 418 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 419 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 420 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 421 | } |
klauss | 109:a5b8264ffbbc | 422 | } |
klauss | 109:a5b8264ffbbc | 423 | } |
klauss | 109:a5b8264ffbbc | 424 | //debug_msg(""); |
klauss | 109:a5b8264ffbbc | 425 | reset_leds(); |
klauss | 109:a5b8264ffbbc | 426 | } |
klauss | 109:a5b8264ffbbc | 427 | |
klauss | 109:a5b8264ffbbc | 428 | if (type == 'r' ){ |
klauss | 109:a5b8264ffbbc | 429 | // Just open for read |
klauss | 109:a5b8264ffbbc | 430 | fip = fopen("/qspi/myip.txt", "r"); |
klauss | 109:a5b8264ffbbc | 431 | fmask = fopen("/qspi/mymask.txt", "r"); |
klauss | 109:a5b8264ffbbc | 432 | fgate = fopen("/qspi/mygateway.txt", "r"); |
klauss | 109:a5b8264ffbbc | 433 | fport = fopen("/qspi/mysipport.txt", "r"); |
klauss | 109:a5b8264ffbbc | 434 | fsip = fopen("/qspi/serverip.txt", "r"); |
klauss | 109:a5b8264ffbbc | 435 | fsport = fopen("/qspi/serverport.txt", "r"); |
klauss | 109:a5b8264ffbbc | 436 | fext = fopen( "/qspi/myext.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 437 | fserext = fopen( "/qspi/peerext.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 438 | fudpport = fopen( "/qspi/udpport.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 439 | ftcpport = fopen( "/qspi/tcpport.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 440 | ftip = fopen("/qspi/telemetry_ip.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 441 | ftport = fopen("/qspi/telemetry_port.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 442 | ffwip = fopen("/qspi/fw_ip.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 443 | ffwport = fopen("/qspi/fw_port.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 444 | fmax = fopen("/qspi/maxext.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 445 | fmin = fopen("/qspi/minext.txt", "r" ); |
klauss | 109:a5b8264ffbbc | 446 | } |
klauss | 109:a5b8264ffbbc | 447 | |
klauss | 109:a5b8264ffbbc | 448 | if( type == 'w'){ |
klauss | 109:a5b8264ffbbc | 449 | // Create and write the default configs |
klauss | 109:a5b8264ffbbc | 450 | |
klauss | 109:a5b8264ffbbc | 451 | set_ip( __MY_IP__ ); |
klauss | 109:a5b8264ffbbc | 452 | |
klauss | 109:a5b8264ffbbc | 453 | set_header_sip_port( __MY_PORT__ ); |
klauss | 109:a5b8264ffbbc | 454 | |
klauss | 109:a5b8264ffbbc | 455 | set_header_ext( __MY_EXT__ ); |
klauss | 109:a5b8264ffbbc | 456 | |
klauss | 109:a5b8264ffbbc | 457 | set_server_ip( __SERVER_IP__ ); |
klauss | 109:a5b8264ffbbc | 458 | |
klauss | 109:a5b8264ffbbc | 459 | set_server_ext( __PEER_EXT__ ); |
klauss | 109:a5b8264ffbbc | 460 | |
klauss | 109:a5b8264ffbbc | 461 | set_server_port( __SERVER_PORT__ ); |
klauss | 109:a5b8264ffbbc | 462 | |
klauss | 109:a5b8264ffbbc | 463 | set_mask( __MY_MSK__ ); |
klauss | 109:a5b8264ffbbc | 464 | |
klauss | 109:a5b8264ffbbc | 465 | set_gateway( __MY_GTW__ ); |
klauss | 109:a5b8264ffbbc | 466 | |
klauss | 109:a5b8264ffbbc | 467 | set_udp_port_listener( UDP_PORT_LISTENER ); |
klauss | 109:a5b8264ffbbc | 468 | |
klauss | 109:a5b8264ffbbc | 469 | set_tcp_port_listener( TCP_PORT_LISTENER ); |
klauss | 109:a5b8264ffbbc | 470 | |
klauss | 109:a5b8264ffbbc | 471 | set_telemetry_ip( __TELEMETRY_SERVER_IP__ ); |
klauss | 109:a5b8264ffbbc | 472 | |
klauss | 109:a5b8264ffbbc | 473 | set_telemetry_port( __TELEMETRY_SERVER_PORT__ ); |
klauss | 109:a5b8264ffbbc | 474 | |
klauss | 109:a5b8264ffbbc | 475 | set_fw_ip( __FW_SERVER_IP__ ); |
klauss | 109:a5b8264ffbbc | 476 | |
klauss | 109:a5b8264ffbbc | 477 | set_fw_port( __FW_SERVER_PORT__ ); |
klauss | 109:a5b8264ffbbc | 478 | |
klauss | 109:a5b8264ffbbc | 479 | set_max_ext( MAX_EXT ); |
klauss | 109:a5b8264ffbbc | 480 | |
klauss | 109:a5b8264ffbbc | 481 | set_min_ext( MIN_EXT ); |
klauss | 109:a5b8264ffbbc | 482 | |
klauss | 109:a5b8264ffbbc | 483 | strcpy( last_cmd, tmp_cmd ); |
klauss | 109:a5b8264ffbbc | 484 | |
klauss | 109:a5b8264ffbbc | 485 | if( debug_uart3 ) pc.printf("\n\rDefault configurations set!\n\r"); |
klauss | 109:a5b8264ffbbc | 486 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 487 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rDefault configurations set!\n\r"); |
klauss | 109:a5b8264ffbbc | 488 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 489 | if( tcp_session ){ |
klauss | 109:a5b8264ffbbc | 490 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 491 | }else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 492 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 493 | } |
klauss | 109:a5b8264ffbbc | 494 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 495 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 496 | } |
klauss | 109:a5b8264ffbbc | 497 | } |
klauss | 109:a5b8264ffbbc | 498 | |
klauss | 109:a5b8264ffbbc | 499 | if (type == 'e'){ |
klauss | 109:a5b8264ffbbc | 500 | //Erase configs |
klauss | 109:a5b8264ffbbc | 501 | fip = fopen("/qspi/myip.txt", "w"); |
klauss | 109:a5b8264ffbbc | 502 | fmask = fopen("/qspi/mymask.txt", "w"); |
klauss | 109:a5b8264ffbbc | 503 | fgate = fopen("/qspi/mygateway.txt", "w"); |
klauss | 109:a5b8264ffbbc | 504 | fport = fopen("/qspi/mysipport.txt", "w"); |
klauss | 109:a5b8264ffbbc | 505 | fsip = fopen("/qspi/serverip.txt", "w"); |
klauss | 109:a5b8264ffbbc | 506 | fsport = fopen("/qspi/serverport.txt", "w"); |
klauss | 109:a5b8264ffbbc | 507 | fext = fopen( "/qspi/myext.txt", "w" ); |
klauss | 109:a5b8264ffbbc | 508 | fserext = fopen( "/qspi/peerext.txt", "w" ); |
klauss | 109:a5b8264ffbbc | 509 | fudpport = fopen( "/qspi/udpport.txt", "w" ); |
klauss | 109:a5b8264ffbbc | 510 | ftcpport = fopen( "/qspi/tcpport.txt", "w" ); |
klauss | 109:a5b8264ffbbc | 511 | ftip = fopen("/qspi/telemetry_ip.txt", "w" ); |
klauss | 109:a5b8264ffbbc | 512 | ftport = fopen("/qspi/telemetry_port.txt", "w" ); |
klauss | 109:a5b8264ffbbc | 513 | ffwip = fopen("/qspi/fw_ip.txt", "w" ); |
klauss | 109:a5b8264ffbbc | 514 | ffwport = fopen("/qspi/fw_port.txt", "w" ); |
klauss | 109:a5b8264ffbbc | 515 | fmax = fopen("/qspi/maxext.txt", "w" ); |
klauss | 109:a5b8264ffbbc | 516 | fmin = fopen("/qspi/minext.txt", "w" ); |
klauss | 109:a5b8264ffbbc | 517 | |
klauss | 109:a5b8264ffbbc | 518 | //FIXME verificar se deveria colocar tudo para %s |
klauss | 109:a5b8264ffbbc | 519 | fprintf( fip, "%s\n\r", "" ); |
klauss | 109:a5b8264ffbbc | 520 | fprintf( fport, "%i\n\r", 0 ); |
klauss | 109:a5b8264ffbbc | 521 | fprintf( fext, "%i\n\r", 0 ); |
klauss | 109:a5b8264ffbbc | 522 | |
klauss | 109:a5b8264ffbbc | 523 | fprintf( fsip, "%s\n\r", "" ); |
klauss | 109:a5b8264ffbbc | 524 | fprintf( fserext, "%i\n\r", 0 ); |
klauss | 109:a5b8264ffbbc | 525 | fprintf( fsport, "%i\n\r", 0 ); |
klauss | 109:a5b8264ffbbc | 526 | |
klauss | 109:a5b8264ffbbc | 527 | fprintf( fmask, "%s\n\r","" ); |
klauss | 109:a5b8264ffbbc | 528 | fprintf( fgate, "%s\n\r", "" ); |
klauss | 109:a5b8264ffbbc | 529 | |
klauss | 109:a5b8264ffbbc | 530 | fprintf( fudpport, "%i\n\r", 0 ); |
klauss | 109:a5b8264ffbbc | 531 | fprintf( ftcpport, "%i\n\r", 0 ); |
klauss | 109:a5b8264ffbbc | 532 | |
klauss | 109:a5b8264ffbbc | 533 | fprintf( ftip, "%s\n\r","" ); |
klauss | 109:a5b8264ffbbc | 534 | fprintf( ftport, "%i\n\r",0 ); |
klauss | 109:a5b8264ffbbc | 535 | |
klauss | 109:a5b8264ffbbc | 536 | fprintf( ffwip, "%s\n\r","" ); |
klauss | 109:a5b8264ffbbc | 537 | fprintf( ffwport, "%i\n\r",0 ); |
klauss | 109:a5b8264ffbbc | 538 | |
klauss | 109:a5b8264ffbbc | 539 | fprintf( fmax, "%i\n\r", 0 ); |
klauss | 109:a5b8264ffbbc | 540 | fprintf( fmin, "%i\n\r", 0 ); |
klauss | 109:a5b8264ffbbc | 541 | |
klauss | 109:a5b8264ffbbc | 542 | files('c'); |
klauss | 109:a5b8264ffbbc | 543 | |
klauss | 109:a5b8264ffbbc | 544 | if( debug_uart3 ) pc.printf("\n\rErased configurations set!\n\r"); |
klauss | 109:a5b8264ffbbc | 545 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 546 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rErased configurations set!\n\r"); |
klauss | 109:a5b8264ffbbc | 547 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 548 | if( tcp_session ){ |
klauss | 109:a5b8264ffbbc | 549 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 550 | }else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 551 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 552 | } |
klauss | 109:a5b8264ffbbc | 553 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 554 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 555 | } |
klauss | 109:a5b8264ffbbc | 556 | } |
klauss | 109:a5b8264ffbbc | 557 | } |
klauss | 109:a5b8264ffbbc | 558 | |
klauss | 109:a5b8264ffbbc | 559 | void init_fsystem(){ |
klauss | 109:a5b8264ffbbc | 560 | // init file system and check if files exist |
klauss | 109:a5b8264ffbbc | 561 | if (!qspifs.isformatted()) { |
klauss | 109:a5b8264ffbbc | 562 | qspifs.format(); |
klauss | 109:a5b8264ffbbc | 563 | if( debug_uart3 ) pc.printf("\n\rFile system configured!!\n\r"); |
klauss | 109:a5b8264ffbbc | 564 | } |
klauss | 109:a5b8264ffbbc | 565 | files('i'); // check if the files are created |
klauss | 109:a5b8264ffbbc | 566 | files('c'); |
klauss | 109:a5b8264ffbbc | 567 | send_msg("******* File System Ready *******"); |
klauss | 109:a5b8264ffbbc | 568 | } |
klauss | 109:a5b8264ffbbc | 569 | |
klauss | 109:a5b8264ffbbc | 570 | void init_prompt_eth(){ |
klauss | 109:a5b8264ffbbc | 571 | tcp_server.bind( TCP_PORT_LISTENER ); |
klauss | 109:a5b8264ffbbc | 572 | tcp_server.listen(); |
klauss | 109:a5b8264ffbbc | 573 | //tcp_server.set_blocking( false, 1 ); |
klauss | 109:a5b8264ffbbc | 574 | //udp_server.set_blocking( false, 2 ); |
klauss | 89:0fe315117b00 | 575 | tcp_server.set_blocking( false, 0 ); |
klauss | 109:a5b8264ffbbc | 576 | udp_server.set_blocking( false, 0 ); |
klauss | 109:a5b8264ffbbc | 577 | udp_server.bind( UDP_PORT_LISTENER ); |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 591 | char eth_buffer[ __PROMPT_ETH_BUFFER_SIZE__ ]; |
klauss | 109:a5b8264ffbbc | 592 | uint8_t write_buffer[ __CB_BUFFER_SIZE__ ]; |
klauss | 109:a5b8264ffbbc | 593 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 599 | |
klauss | 109:a5b8264ffbbc | 600 | if( tcp_timer.read() >= TCP_IDLE_MAX_TIME ){ |
klauss | 109:a5b8264ffbbc | 601 | bool close_tcp = true; |
klauss | 109:a5b8264ffbbc | 602 | //if( tcp_alive && ( tcp_timer.read() < TCP_ALIVE_IDLE_MAX_TIME ) ){ |
klauss | 109:a5b8264ffbbc | 603 | // close_tcp = false; |
klauss | 109:a5b8264ffbbc | 604 | //} |
klauss | 109:a5b8264ffbbc | 605 | if( close_tcp ){ |
klauss | 109:a5b8264ffbbc | 606 | tcp_alive = false; |
klauss | 109:a5b8264ffbbc | 607 | tcp_timer.stop(); |
klauss | 109:a5b8264ffbbc | 608 | tcp_timer.reset(); |
klauss | 109:a5b8264ffbbc | 609 | tcp_session = false; |
klauss | 109:a5b8264ffbbc | 610 | debug_buf = __debug_buf__; |
klauss | 109:a5b8264ffbbc | 611 | bufptr = last_bufptr; |
klauss | 109:a5b8264ffbbc | 612 | bufret = 0; |
klauss | 109:a5b8264ffbbc | 613 | from_eth = false; |
klauss | 109:a5b8264ffbbc | 614 | tcp_client.close(); |
klauss | 109:a5b8264ffbbc | 615 | return( NULL ); |
klauss | 109:a5b8264ffbbc | 616 | } |
klauss | 109:a5b8264ffbbc | 617 | } |
klauss | 109:a5b8264ffbbc | 618 | if( !tcp_server.accept( tcp_client ) ){ |
klauss | 109:a5b8264ffbbc | 619 | tcp_session = true; |
klauss | 109:a5b8264ffbbc | 620 | tcp_timer.start(); |
klauss | 109:a5b8264ffbbc | 621 | last_bufptr = bufptr; |
klauss | 109:a5b8264ffbbc | 622 | eth_buffer[ 0 ] = 0; |
klauss | 103:e3cabfc2f533 | 623 | bufret = 0; |
klauss | 109:a5b8264ffbbc | 624 | } |
klauss | 109:a5b8264ffbbc | 625 | if( tcp_session ){ |
klauss | 109:a5b8264ffbbc | 626 | //if( !( (int)tcp_timer.read_ms() % 100 ) ){ |
klauss | 109:a5b8264ffbbc | 627 | //tcp_client.set_blocking( false, 1 ); |
klauss | 109:a5b8264ffbbc | 628 | tcp_client.set_blocking( false, 0 ); |
klauss | 109:a5b8264ffbbc | 629 | int n = tcp_client.receive( eth_buffer, sizeof( eth_buffer ) - 1 ); |
klauss | 109:a5b8264ffbbc | 630 | if( n > 0 ){ |
klauss | 109:a5b8264ffbbc | 631 | tcp_timer.reset(); |
klauss | 109:a5b8264ffbbc | 632 | |
klauss | 109:a5b8264ffbbc | 633 | if( ( n > 2 ) && ( eth_buffer[ n - 2 ] == '\r' ) ) eth_buffer[ n - 2 ] = 0; |
klauss | 109:a5b8264ffbbc | 634 | |
klauss | 109:a5b8264ffbbc | 635 | if( ( n > 1 ) && ( eth_buffer[ n - 1 ] == '\n' ) ) eth_buffer[ n - 1 ] = 0; |
klauss | 109:a5b8264ffbbc | 636 | |
klauss | 109:a5b8264ffbbc | 637 | if( ( n == 1 ) && eth_buffer[ 0 ] == 0x0A ) strcpy( eth_buffer, "\r" ); |
klauss | 109:a5b8264ffbbc | 638 | |
klauss | 109:a5b8264ffbbc | 639 | //if( eth_buffer[ 0 ] == '\r' || eth_buffer[ 1 ] == '\n' || eth_buffer[ 2 ] == 'r' || eth_buffer[ 2 ] == '\n' ) strcpy( eth_buffer, "\r" ); |
klauss | 103:e3cabfc2f533 | 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 | 109:a5b8264ffbbc | 645 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 656 | /*else if( !( strcmp( eth_buffer, "alive" ) ) ){ |
klauss | 109:a5b8264ffbbc | 657 | char wake_msg[ 8 ]; |
klauss | 109:a5b8264ffbbc | 658 | external_wdt = EXTERN_WDT_IDLE; |
klauss | 109:a5b8264ffbbc | 659 | strcpy( wake_msg, "wakeup\n" ); |
klauss | 109:a5b8264ffbbc | 660 | while( !( tcp_client.send_all( wake_msg, strlen( wake_msg ) ) ) ); |
klauss | 109:a5b8264ffbbc | 661 | strcpy( eth_buffer, "0" ); |
klauss | 109:a5b8264ffbbc | 662 | bufret = 0; |
klauss | 109:a5b8264ffbbc | 663 | } |
klauss | 109:a5b8264ffbbc | 664 | */ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 670 | //} |
klauss | 53:bb492a8f115a | 671 | } |
klauss | 109:a5b8264ffbbc | 672 | |
klauss | 109:a5b8264ffbbc | 673 | if( !from_eth ){ |
klauss | 109:a5b8264ffbbc | 674 | if( pc.readable() ){ |
klauss | 109:a5b8264ffbbc | 675 | // imput do teclado |
klauss | 53:bb492a8f115a | 676 | b = pc.getc(); |
klauss | 109:a5b8264ffbbc | 677 | if( b == 0x0D ){ // enter |
klauss | 53:bb492a8f115a | 678 | bufret = 1; |
klauss | 109:a5b8264ffbbc | 679 | }else{ |
klauss | 53:bb492a8f115a | 680 | pc.putc( b ); |
klauss | 109:a5b8264ffbbc | 681 | if( b == 0x08 || b == 0x7F ){ // BS | DEL |
klauss | 109:a5b8264ffbbc | 682 | if( bufptr > 0 ) debug_buf[ --bufptr ] = 0; |
klauss | 109:a5b8264ffbbc | 683 | }else if( b == 0x09 ){ |
klauss | 53:bb492a8f115a | 684 | // ignore tab |
klauss | 109:a5b8264ffbbc | 685 | }else{ |
klauss | 109:a5b8264ffbbc | 686 | debug_buf[bufptr] = b; |
klauss | 53:bb492a8f115a | 687 | bufptr++; |
klauss | 42:480335bdde12 | 688 | } |
klauss | 31:bb5fb28a77df | 689 | } |
klauss | 53:bb492a8f115a | 690 | } |
klauss | 48:195c97f12e8e | 691 | } |
klauss | 109:a5b8264ffbbc | 692 | |
klauss | 109:a5b8264ffbbc | 693 | if( msg_from_cb ){ |
klauss | 109:a5b8264ffbbc | 694 | if( tcp_session ){ |
klauss | 109:a5b8264ffbbc | 695 | tcp_client.send_all( msg_from_cb, strlen( msg_from_cb ) ); |
klauss | 109:a5b8264ffbbc | 696 | }else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 697 | udp_server.sendTo( udp_client, msg_from_cb, strlen( msg_from_cb ) ); |
klauss | 109:a5b8264ffbbc | 698 | } |
klauss | 109:a5b8264ffbbc | 699 | if( debug_uart3 ) pc.printf( "\n\r%s\n\r", msg_from_cb ); |
klauss | 109:a5b8264ffbbc | 700 | } |
klauss | 109:a5b8264ffbbc | 701 | |
klauss | 109:a5b8264ffbbc | 702 | if( flood_silence ){ |
klauss | 109:a5b8264ffbbc | 703 | if( flood_silence_timer.read_ms() > 250 ){ |
klauss | 60:b4ec6beb3be3 | 704 | char cmd[ 16 ] = "flood off"; |
klauss | 60:b4ec6beb3be3 | 705 | int str_end = strlen( cmd ); |
klauss | 60:b4ec6beb3be3 | 706 | cmd[ str_end ] = 0x0D; |
klauss | 60:b4ec6beb3be3 | 707 | cmd[ str_end + 1 ] = 0x00; |
klauss | 109:a5b8264ffbbc | 708 | |
klauss | 60:b4ec6beb3be3 | 709 | int port = convert_ext_to_port( ext_count ); |
klauss | 109:a5b8264ffbbc | 710 | send2callboxes( __build_cb_package__( ext_count, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 109:a5b8264ffbbc | 711 | if( debug_uart3 ) pc.printf("\r\nSilence sent to ext=%d port=%d", ext_count, port ); |
klauss | 109:a5b8264ffbbc | 712 | |
klauss | 109:a5b8264ffbbc | 713 | if( tcp_session ){ |
klauss | 60:b4ec6beb3be3 | 714 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\nSilence sent to ext=%d port=%d", ext_count, port ); |
klauss | 109:a5b8264ffbbc | 715 | //eth_buffer[ strlen( eth_buffer ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 716 | |
klauss | 60:b4ec6beb3be3 | 717 | tcp_client.send_all( eth_buffer, strlen( eth_buffer ) ); |
klauss | 109:a5b8264ffbbc | 718 | }else if( udp_request ){ |
klauss | 60:b4ec6beb3be3 | 719 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\nSilence sent to ext=%d port=%d", ext_count, port ); |
klauss | 109:a5b8264ffbbc | 720 | //eth_buffer[ strlen( eth_buffer ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 721 | |
klauss | 109:a5b8264ffbbc | 722 | udp_server.sendTo( udp_client, eth_buffer, strlen( eth_buffer ) ); |
klauss | 60:b4ec6beb3be3 | 723 | } |
klauss | 60:b4ec6beb3be3 | 724 | flood_silence_timer.reset(); |
klauss | 109:a5b8264ffbbc | 725 | |
klauss | 109:a5b8264ffbbc | 726 | if( ++ext_count > end_ext ){ |
klauss | 60:b4ec6beb3be3 | 727 | flood_silence = false; |
klauss | 60:b4ec6beb3be3 | 728 | flood_silence_timer.stop(); |
klauss | 60:b4ec6beb3be3 | 729 | flood_silence_timer.reset(); |
klauss | 109:a5b8264ffbbc | 730 | |
klauss | 109:a5b8264ffbbc | 731 | if( debug_uart3 ) pc.printf("\r\n> " ); |
klauss | 109:a5b8264ffbbc | 732 | if( tcp_session ){ |
klauss | 60:b4ec6beb3be3 | 733 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\n> " ); |
klauss | 60:b4ec6beb3be3 | 734 | tcp_client.send_all( eth_buffer, strlen( eth_buffer ) ); |
klauss | 109:a5b8264ffbbc | 735 | }else if( udp_request ){ |
klauss | 60:b4ec6beb3be3 | 736 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\n> " ); |
klauss | 109:a5b8264ffbbc | 737 | udp_server.sendTo( udp_client, eth_buffer, strlen( eth_buffer ) ); |
klauss | 60:b4ec6beb3be3 | 738 | } |
klauss | 60:b4ec6beb3be3 | 739 | } |
klauss | 60:b4ec6beb3be3 | 740 | } |
klauss | 60:b4ec6beb3be3 | 741 | } |
klauss | 109:a5b8264ffbbc | 742 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 750 | if( debug_uart3 ) pc.printf("\n\rFlood ON\n\r"); |
klauss | 109:a5b8264ffbbc | 751 | if( from_eth ){ |
klauss | 65:0b653cfe95db | 752 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r" ); |
klauss | 109:a5b8264ffbbc | 753 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 65:0b653cfe95db | 754 | } |
klauss | 65:0b653cfe95db | 755 | } |
klauss | 109:a5b8264ffbbc | 756 | |
klauss | 45:c80574f24dc3 | 757 | // Prompt commands here |
klauss | 58:af7e8788f106 | 758 | if ( bufret == 1 ) { |
klauss | 109:a5b8264ffbbc | 759 | static unsigned int promptcb_last_ext = 0; |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 784 | if( debug_uart3 ) pc.printf("\n\rFlood OFF\n\r"); |
klauss | 109:a5b8264ffbbc | 785 | if( from_eth ){ |
klauss | 59:e1e300880d2d | 786 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood OFF\n\r" ); |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 792 | sprintf( debug_buf, "pcb %i flood off", ext ); |
klauss | 45:c80574f24dc3 | 793 | } |
klauss | 109:a5b8264ffbbc | 794 | |
klauss | 48:195c97f12e8e | 795 | //tratamento dos enters |
klauss | 109:a5b8264ffbbc | 796 | if( !bufptr ){ |
klauss | 45:c80574f24dc3 | 797 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 801 | |
klauss | 109:a5b8264ffbbc | 802 | if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ifconfig" ) ){ |
klauss | 45:c80574f24dc3 | 803 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 804 | if( debug_uart3 ) pc.printf("\n\r"); |
klauss | 45:c80574f24dc3 | 805 | files('s'); |
klauss | 45:c80574f24dc3 | 806 | } |
klauss | 109:a5b8264ffbbc | 807 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 812 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 817 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 821 | } |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 826 | |
klauss | 109:a5b8264ffbbc | 827 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "rtp" ) ) { |
klauss | 109:a5b8264ffbbc | 828 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 829 | dshow_rtp = true; |
klauss | 109:a5b8264ffbbc | 830 | } |
klauss | 109:a5b8264ffbbc | 831 | |
klauss | 109:a5b8264ffbbc | 832 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "callrtp" ) ) { |
klauss | 45:c80574f24dc3 | 833 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 834 | dcallshow_rtp = true; |
klauss | 109:a5b8264ffbbc | 835 | } |
klauss | 109:a5b8264ffbbc | 836 | |
klauss | 109:a5b8264ffbbc | 837 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "format" ) ){ |
klauss | 109:a5b8264ffbbc | 838 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 839 | if( debug_uart3 ) pc.printf("\n\rFormatando o sistema de arquivos... espere o sistema reiniciar\n\r"); |
klauss | 109:a5b8264ffbbc | 840 | |
klauss | 109:a5b8264ffbbc | 841 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 842 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Not Allowed\n\r"); |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 862 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 892 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 898 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 105:a930035b6556 | 910 | |
klauss | 109:a5b8264ffbbc | 911 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "telemetry_ip ", 13 ) ){ |
klauss | 109:a5b8264ffbbc | 912 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 913 | set_telemetry_ip( debug_buf + 13 ); |
klauss | 109:a5b8264ffbbc | 914 | files('s'); |
klauss | 109:a5b8264ffbbc | 915 | } |
klauss | 109:a5b8264ffbbc | 916 | |
klauss | 109:a5b8264ffbbc | 917 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "telemetry_port ", 15 ) ){ |
klauss | 109:a5b8264ffbbc | 918 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 919 | set_telemetry_port( atoi( debug_buf + 15 ) ); |
klauss | 109:a5b8264ffbbc | 920 | files('s'); |
klauss | 109:a5b8264ffbbc | 921 | } |
klauss | 109:a5b8264ffbbc | 922 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 928 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 934 | |
klauss | 109:a5b8264ffbbc | 935 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dconfig" ) ){ |
klauss | 106:a34fcf9f0e02 | 936 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 937 | /* |
klauss | 50:d9b6577a70f5 | 938 | files('e'); |
klauss | 45:c80574f24dc3 | 939 | files('w'); |
klauss | 45:c80574f24dc3 | 940 | files('s'); |
klauss | 109:a5b8264ffbbc | 941 | */ |
klauss | 45:c80574f24dc3 | 942 | } |
klauss | 45:c80574f24dc3 | 943 | |
klauss | 109:a5b8264ffbbc | 944 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset" ) ){ |
klauss | 45:c80574f24dc3 | 945 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 946 | if( debug_uart3 ) pc.printf("\n\rJob is done\n\r"); |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 953 | }else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 961 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dog" ) ){ |
klauss | 45:c80574f24dc3 | 962 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 963 | if( debug_uart3 ) pc.printf("\n\r MUUUUUUUuuuuUUUUUU - I'm not a dog!!!! \n\r"); |
klauss | 109:a5b8264ffbbc | 964 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 965 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "MUUUUUUUuuuuUUUUUU - I'm not a dog!!!!\n\r"); |
klauss | 109:a5b8264ffbbc | 966 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 967 | } |
klauss | 45:c80574f24dc3 | 968 | } |
klauss | 108:18a3702650f3 | 969 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1033 | } |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1048 | |
klauss | 108:18a3702650f3 | 1049 | } |
klauss | 108:18a3702650f3 | 1050 | |
klauss | 107:cf1e43414adb | 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 | 109:a5b8264ffbbc | 1062 | } |
klauss | 109:a5b8264ffbbc | 1063 | |
klauss | 109:a5b8264ffbbc | 1064 | } |
klauss | 109:a5b8264ffbbc | 1065 | |
klauss | 109:a5b8264ffbbc | 1066 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ftq" ) ){ |
klauss | 109:a5b8264ffbbc | 1067 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1068 | if( debug_uart3 ) pc.printf( "\n\rFTQ ON\n\r" ); |
klauss | 109:a5b8264ffbbc | 1069 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 1070 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FTQ On\n\r" ); |
klauss | 109:a5b8264ffbbc | 1071 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 1072 | } |
klauss | 109:a5b8264ffbbc | 1073 | big_bug_pkg = true; |
klauss | 109:a5b8264ffbbc | 1074 | } |
klauss | 109:a5b8264ffbbc | 1075 | |
klauss | 109:a5b8264ffbbc | 1076 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ktq" ) ){ |
klauss | 109:a5b8264ffbbc | 1077 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1078 | if( debug_uart3 ) pc.printf( "\n\rFTQ!!!\n\r" ); |
klauss | 109:a5b8264ffbbc | 1079 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 1080 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FTQ!!!\n\r" ); |
klauss | 109:a5b8264ffbbc | 1081 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 1082 | } |
klauss | 109:a5b8264ffbbc | 1083 | flood_bug_pkg = !flood_bug_pkg; |
klauss | 109:a5b8264ffbbc | 1084 | } |
klauss | 109:a5b8264ffbbc | 1085 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1090 | |
klauss | 109:a5b8264ffbbc | 1091 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drtp ", 5 ) ) { |
klauss | 107:cf1e43414adb | 1092 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ) { |
klauss | 107:cf1e43414adb | 1093 | miss_match = false; |
klauss | 107:cf1e43414adb | 1094 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rRtp Debug ON\n\r" ); |
klauss | 107:cf1e43414adb | 1095 | if( from_eth ) { |
klauss | 107:cf1e43414adb | 1096 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Rtp Debug On\n\r"); |
klauss | 107:cf1e43414adb | 1097 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 1098 | if( tcp_session ) { |
klauss | 107:cf1e43414adb | 1099 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 107:cf1e43414adb | 1100 | } |
klauss | 107:cf1e43414adb | 1101 | } |
klauss | 107:cf1e43414adb | 1102 | debug_rtp = true; |
klauss | 107:cf1e43414adb | 1103 | } |
klauss | 107:cf1e43414adb | 1104 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "off", 3 ) ){ |
klauss | 107:cf1e43414adb | 1105 | miss_match = false; |
klauss | 107:cf1e43414adb | 1106 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rRtp Debug OFF\n\r" ); |
klauss | 107:cf1e43414adb | 1107 | if( from_eth ) { |
klauss | 107:cf1e43414adb | 1108 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Rtp Debug Off\n\r"); |
klauss | 107:cf1e43414adb | 1109 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 1110 | if( tcp_session ) { |
klauss | 107:cf1e43414adb | 1111 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 107:cf1e43414adb | 1112 | } |
klauss | 107:cf1e43414adb | 1113 | } |
klauss | 107:cf1e43414adb | 1114 | debug_rtp = false; |
klauss | 107:cf1e43414adb | 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 | 109:a5b8264ffbbc | 1183 | |
klauss | 109:a5b8264ffbbc | 1184 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "show_sip" ) ){ |
klauss | 109:a5b8264ffbbc | 1185 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1186 | show_sip = true; |
klauss | 109:a5b8264ffbbc | 1187 | } |
klauss | 109:a5b8264ffbbc | 1188 | |
klauss | 109:a5b8264ffbbc | 1189 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_cks" ) ){ |
klauss | 109:a5b8264ffbbc | 1190 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1191 | reset_cks = true; |
klauss | 109:a5b8264ffbbc | 1192 | } |
klauss | 109:a5b8264ffbbc | 1193 | |
klauss | 109:a5b8264ffbbc | 1194 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "malasia" ) ){ |
klauss | 109:a5b8264ffbbc | 1195 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1196 | malasia = !malasia; |
klauss | 109:a5b8264ffbbc | 1197 | } |
klauss | 109:a5b8264ffbbc | 1198 | |
klauss | 109:a5b8264ffbbc | 1199 | //replaced by ls |
klauss | 109:a5b8264ffbbc | 1200 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "status" ) ){ |
klauss | 109:a5b8264ffbbc | 1201 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1202 | list = true; |
klauss | 109:a5b8264ffbbc | 1203 | } |
klauss | 109:a5b8264ffbbc | 1204 | |
klauss | 109:a5b8264ffbbc | 1205 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "wdt" ) ){ |
klauss | 109:a5b8264ffbbc | 1206 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1207 | debug_wdt = true; |
klauss | 109:a5b8264ffbbc | 1208 | } |
klauss | 109:a5b8264ffbbc | 1209 | |
klauss | 109:a5b8264ffbbc | 1210 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "eth" ) ){ |
klauss | 109:a5b8264ffbbc | 1211 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1212 | debug_eth = true; |
klauss | 109:a5b8264ffbbc | 1213 | } |
klauss | 109:a5b8264ffbbc | 1214 | |
klauss | 109:a5b8264ffbbc | 1215 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "types" ) ){ |
klauss | 109:a5b8264ffbbc | 1216 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1217 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1219 | |
klauss | 109:a5b8264ffbbc | 1220 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1222 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1223 | } |
klauss | 105:a930035b6556 | 1224 | } |
klauss | 105:a930035b6556 | 1225 | |
klauss | 109:a5b8264ffbbc | 1226 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "protocol" ) ){ |
klauss | 109:a5b8264ffbbc | 1227 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1228 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1230 | |
klauss | 109:a5b8264ffbbc | 1231 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1233 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 1234 | } |
klauss | 109:a5b8264ffbbc | 1235 | } |
klauss | 109:a5b8264ffbbc | 1236 | |
klauss | 109:a5b8264ffbbc | 1237 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "flood ", 6 ) ){ |
klauss | 109:a5b8264ffbbc | 1238 | if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on", 2 ) ){ |
klauss | 109:a5b8264ffbbc | 1239 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1240 | if( debug_uart3 ) pc.printf("\n\rFlood ON\n\r"); |
klauss | 109:a5b8264ffbbc | 1241 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 1242 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r" ); |
klauss | 109:a5b8264ffbbc | 1243 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1251 | |
klauss | 109:a5b8264ffbbc | 1252 | if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "more", 4 ) ){ |
klauss | 109:a5b8264ffbbc | 1253 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1254 | if( debug_uart3 ) pc.printf("\n\rFlood ON\n\r"); |
klauss | 109:a5b8264ffbbc | 1255 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 1256 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r" ); |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1264 | |
klauss | 109:a5b8264ffbbc | 1265 | if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "off", 3 )) { |
klauss | 104:62646ef786a3 | 1266 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1267 | if( debug_uart3 ) pc.printf("\n\rFlood OFF\n\r"); |
klauss | 109:a5b8264ffbbc | 1268 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1279 | |
klauss | 109:a5b8264ffbbc | 1280 | strcpy( promptcb_last_cmd, debug_buf ); |
klauss | 109:a5b8264ffbbc | 1281 | |
klauss | 109:a5b8264ffbbc | 1282 | if( !( strcmp( debug_buf + 8, "-h" ) && strcmp( debug_buf + 8, "--help" ) ) ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1284 | |
klauss | 109:a5b8264ffbbc | 1285 | if( tcp_session ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1288 | }else{ |
klauss | 109:a5b8264ffbbc | 1289 | ref = debug_buf; |
klauss | 109:a5b8264ffbbc | 1290 | |
klauss | 109:a5b8264ffbbc | 1291 | split = strtok( debug_buf + 8, " " ); |
klauss | 109:a5b8264ffbbc | 1292 | |
klauss | 109:a5b8264ffbbc | 1293 | start_ext = atoi( split ); |
klauss | 109:a5b8264ffbbc | 1294 | |
klauss | 109:a5b8264ffbbc | 1295 | split += strlen( split ) + 1; |
klauss | 109:a5b8264ffbbc | 1296 | |
klauss | 109:a5b8264ffbbc | 1297 | end_ext = atoi( split ); |
klauss | 109:a5b8264ffbbc | 1298 | |
klauss | 109:a5b8264ffbbc | 1299 | debug_buf = ref; |
klauss | 109:a5b8264ffbbc | 1300 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1304 | |
klauss | 109:a5b8264ffbbc | 1305 | ext_count = start_ext; |
klauss | 109:a5b8264ffbbc | 1306 | flood_silence_timer.start(); |
klauss | 109:a5b8264ffbbc | 1307 | }else{ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1309 | |
klauss | 109:a5b8264ffbbc | 1310 | if( tcp_session ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1317 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1321 | if( debug_uart3 ) pc.printf("\n\rDebug ON\n\r"); |
klauss | 109:a5b8264ffbbc | 1322 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1330 | if( debug_uart3 ) pc.printf("\n\rDebug OFF\n\r"); |
klauss | 109:a5b8264ffbbc | 1331 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1337 | if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "show",4 ) ){ |
klauss | 100:09a23fcd3bdf | 1338 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1339 | if( debug_uart3 ) pc.printf("\n\rdsip"); |
klauss | 109:a5b8264ffbbc | 1340 | if( debug_uart3 ) pc.printf("\n\rdebug_alive"); |
klauss | 109:a5b8264ffbbc | 1341 | if( debug_uart3 ) pc.printf("\n\rdebug_prompt"); |
klauss | 109:a5b8264ffbbc | 1342 | if( debug_uart3 ) pc.printf("\n\rdebug_vector"); |
klauss | 109:a5b8264ffbbc | 1343 | if( debug_uart3 ) pc.printf("\n\rdebug_cb"); |
klauss | 109:a5b8264ffbbc | 1344 | if( debug_uart3 ) pc.printf("\n\rdebug_main"); |
klauss | 109:a5b8264ffbbc | 1345 | if( debug_uart3 ) pc.printf("\n\rdcks"); |
klauss | 109:a5b8264ffbbc | 1346 | if( debug_uart3 ) pc.printf("\n\rdebug_cb_rx"); |
klauss | 109:a5b8264ffbbc | 1347 | if( debug_uart3 ) pc.printf("\n\rdebug_cb_tx*"); |
klauss | 109:a5b8264ffbbc | 1348 | if( debug_uart3 ) pc.printf("\n\rdebug_eth_rx*"); |
klauss | 109:a5b8264ffbbc | 1349 | if( debug_uart3 ) pc.printf("\n\rdebug_eth_tx*"); |
klauss | 109:a5b8264ffbbc | 1350 | if( debug_uart3 ) pc.printf("\n\rdebug_file"); |
klauss | 109:a5b8264ffbbc | 1351 | |
klauss | 109:a5b8264ffbbc | 1352 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1358 | |
klauss | 109:a5b8264ffbbc | 1359 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dsip ", 5 ) ){ |
klauss | 109:a5b8264ffbbc | 1360 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ){ |
klauss | 109:a5b8264ffbbc | 1361 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1362 | if( debug_uart3 ) pc.printf( "\n\rSip Debug ON\n\r" ); |
klauss | 109:a5b8264ffbbc | 1363 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1371 | if( debug_uart3 ) pc.printf( "\n\rSip Debug OFF\n\r" ); |
klauss | 109:a5b8264ffbbc | 1372 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1380 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "duart ", 6 ) ){ |
klauss | 109:a5b8264ffbbc | 1381 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ){ |
klauss | 109:a5b8264ffbbc | 1382 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1383 | if( debug_uart3 ) pc.printf( "\n\rEnable UART3 usage\n\r" ); |
klauss | 109:a5b8264ffbbc | 1384 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1392 | if( debug_uart3 ) pc.printf( "\n\rEnable UART3 usage\n\r" ); |
klauss | 109:a5b8264ffbbc | 1393 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1400 | |
klauss | 109:a5b8264ffbbc | 1401 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dprint ", 7 ) ){ |
klauss | 109:a5b8264ffbbc | 1402 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ |
klauss | 109:a5b8264ffbbc | 1403 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1404 | if( debug_uart3 ) pc.printf( "\n\rDebug print On\n\r" ); |
klauss | 109:a5b8264ffbbc | 1405 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 1406 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug print On\n\r" ); |
klauss | 109:a5b8264ffbbc | 1407 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 109:a5b8264ffbbc | 1408 | } |
klauss | 109:a5b8264ffbbc | 1409 | print_values = true; |
klauss | 109:a5b8264ffbbc | 1410 | } |
klauss | 109:a5b8264ffbbc | 1411 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { |
klauss | 98:43b45f26b430 | 1412 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1413 | if( debug_uart3 ) pc.printf( "\n\rDebug print Off\n\r" ); |
klauss | 109:a5b8264ffbbc | 1414 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1417 | } |
klauss | 109:a5b8264ffbbc | 1418 | print_values = false; |
klauss | 109:a5b8264ffbbc | 1419 | } |
klauss | 109:a5b8264ffbbc | 1420 | } |
klauss | 109:a5b8264ffbbc | 1421 | |
klauss | 109:a5b8264ffbbc | 1422 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dmatch ", 7 ) ){ |
klauss | 109:a5b8264ffbbc | 1423 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ |
klauss | 109:a5b8264ffbbc | 1424 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1425 | if( debug_uart3 ) pc.printf( "\n\rPort Match Debug ON\n\r" ); |
klauss | 109:a5b8264ffbbc | 1426 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 1427 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Port Match Debug On\n\r" ); |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1434 | if( debug_uart3 ) pc.printf( "\n\rPort Match Debug OFF\n\r" ); |
klauss | 109:a5b8264ffbbc | 1435 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1442 | |
klauss | 109:a5b8264ffbbc | 1443 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dmuted ", 7 ) ){ |
klauss | 109:a5b8264ffbbc | 1444 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ |
klauss | 81:3656f00ab3db | 1445 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1446 | if( debug_uart3 ) pc.printf( "\n\rMuted Debug ON\n\r" ); |
klauss | 109:a5b8264ffbbc | 1447 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1455 | if( debug_uart3 ) pc.printf( "\n\rMuted Debug OFF\n\r" ); |
klauss | 109:a5b8264ffbbc | 1456 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1463 | |
klauss | 109:a5b8264ffbbc | 1464 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dwdt ", 5 ) ){ |
klauss | 109:a5b8264ffbbc | 1465 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ){ |
klauss | 81:3656f00ab3db | 1466 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1467 | if( debug_uart3 ) pc.printf( "\n\rWdt Debug ON\n\r" ); |
klauss | 109:a5b8264ffbbc | 1468 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1476 | if( debug_uart3 ) pc.printf( "\n\rWdt Debug OFF\n\r" ); |
klauss | 109:a5b8264ffbbc | 1477 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1484 | |
klauss | 109:a5b8264ffbbc | 1485 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drefresh ", 9 ) ){ |
klauss | 109:a5b8264ffbbc | 1486 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "on", 2 ) ){ |
klauss | 81:3656f00ab3db | 1487 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1488 | if( debug_uart3 ) pc.printf( "\n\rRefresh Debug ON\n\r" ); |
klauss | 109:a5b8264ffbbc | 1489 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1497 | if( debug_uart3 ) pc.printf( "\n\rRefresh Debug OFF\n\r" ); |
klauss | 109:a5b8264ffbbc | 1498 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1505 | |
klauss | 109:a5b8264ffbbc | 1506 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dping ", 6 ) ){ |
klauss | 109:a5b8264ffbbc | 1507 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1508 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1509 | if( debug_uart3 ) pc.printf( "\n\rPing Debug ON\n\r" ); |
klauss | 109:a5b8264ffbbc | 1510 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1518 | if( debug_uart3 ) pc.printf( "\n\rPing Debug OFF\n\r" ); |
klauss | 109:a5b8264ffbbc | 1519 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1526 | |
klauss | 109:a5b8264ffbbc | 1527 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dwu ", 4 ) ){ |
klauss | 109:a5b8264ffbbc | 1528 | if (xmemmatch( (uint8_t*)(debug_buf + 4 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1529 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1530 | if( debug_uart3 ) pc.printf( "\n\rWake Up Debug ON\n\r" ); |
klauss | 109:a5b8264ffbbc | 1531 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1539 | if( debug_uart3 ) pc.printf( "\n\rWake Up Debug OFF\n\r" ); |
klauss | 109:a5b8264ffbbc | 1540 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1547 | |
klauss | 109:a5b8264ffbbc | 1548 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "tcp_alive ", 10 ) ){ |
klauss | 109:a5b8264ffbbc | 1549 | if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1550 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1551 | if( debug_uart3 ) pc.printf( "\n\rTCP don't drop mode on\n\r" ); |
klauss | 109:a5b8264ffbbc | 1552 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1560 | if( debug_uart3 ) pc.printf( "\n\rTCP don't drop mode off\n\r" ); |
klauss | 109:a5b8264ffbbc | 1561 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1568 | |
klauss | 109:a5b8264ffbbc | 1569 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "daging ",7 ) ){ |
klauss | 109:a5b8264ffbbc | 1570 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1571 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1572 | if( debug_uart3 ) pc.printf( "\n\rAging Debug ON\n\r" ); |
klauss | 109:a5b8264ffbbc | 1573 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1581 | if( debug_uart3 ) pc.printf( "\n\rAging Debug OFF\n\r" ); |
klauss | 109:a5b8264ffbbc | 1582 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1589 | |
klauss | 109:a5b8264ffbbc | 1590 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcpld ", 6 ) ){ |
klauss | 109:a5b8264ffbbc | 1591 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1592 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1593 | if( debug_uart3 ) pc.printf( "\n\rDCPLD Debug ON\n\r" ); |
klauss | 109:a5b8264ffbbc | 1594 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1600 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 ) ){ |
klauss | 78:1353744f01e1 | 1601 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1602 | if( debug_uart3 ) pc.printf( "\n\rDCPLD Debug OFF\n\r" ); |
klauss | 109:a5b8264ffbbc | 1603 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1611 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcks_err ", 9 ) ){ |
klauss | 109:a5b8264ffbbc | 1612 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "on", 2 ) ){ |
klauss | 105:a930035b6556 | 1613 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1614 | if( debug_uart3 ) pc.printf( "\n\rCKS_ERR Debug ON\n\r" ); |
klauss | 109:a5b8264ffbbc | 1615 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1621 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "off", 3 ) ){ |
klauss | 78:1353744f01e1 | 1622 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1623 | if( debug_uart3 ) pc.printf( "\n\rCKS_ERR Debug OFF\n\r" ); |
klauss | 109:a5b8264ffbbc | 1624 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1631 | |
klauss | 109:a5b8264ffbbc | 1632 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dinvite ", 8 ) ){ |
klauss | 109:a5b8264ffbbc | 1633 | if( xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1634 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1635 | if( debug_uart3 ) pc.printf( "\n\rInvite Debug ON\n\r" ); |
klauss | 109:a5b8264ffbbc | 1636 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1644 | if( debug_uart3 ) pc.printf( "\n\rInvite Debug OFF\n\r" ); |
klauss | 109:a5b8264ffbbc | 1645 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1652 | |
klauss | 109:a5b8264ffbbc | 1653 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dparallel ", 10 ) ){ |
klauss | 109:a5b8264ffbbc | 1654 | if( xmemmatch( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * )"on", 2 ) ){ |
klauss | 72:895ca792c647 | 1655 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1656 | if( debug_uart3 ) pc.printf( "\n\rParallel Write Debug ON\n\r" ); |
klauss | 109:a5b8264ffbbc | 1657 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1665 | if( debug_uart3 ) pc.printf( "\n\rParallel Write Debug OFF\n\r" ); |
klauss | 109:a5b8264ffbbc | 1666 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1673 | |
klauss | 109:a5b8264ffbbc | 1674 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dtelos ", 7 ) ){ |
klauss | 109:a5b8264ffbbc | 1675 | if (xmemmatch( (uint8_t*)( debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ |
klauss | 53:bb492a8f115a | 1676 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1677 | if( debug_uart3 ) pc.printf( "\n\rTelemetry Debug ON\n\r" ); |
klauss | 109:a5b8264ffbbc | 1678 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1686 | if( debug_uart3 ) pc.printf( "\n\rTelemetry Debug OFF\n\r" ); |
klauss | 109:a5b8264ffbbc | 1687 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1694 | |
klauss | 109:a5b8264ffbbc | 1695 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcks ", 5 ) ){ |
klauss | 109:a5b8264ffbbc | 1696 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on",2 ) ){ |
klauss | 45:c80574f24dc3 | 1697 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1698 | if( debug_uart3 ) pc.printf( "\n\rCKS Debug ON\n\r" ); |
klauss | 109:a5b8264ffbbc | 1699 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1707 | if( debug_uart3 ) pc.printf( "\n\rCKS Debug OFF\n\r" ); |
klauss | 109:a5b8264ffbbc | 1708 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1715 | |
klauss | 109:a5b8264ffbbc | 1716 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "promptcb ", 9 ) ){ |
klauss | 78:1353744f01e1 | 1717 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1718 | //static uint8_t id_msg = 0x10; |
klauss | 109:a5b8264ffbbc | 1719 | uint8_t write_buffer[ 300 ]; |
klauss | 78:1353744f01e1 | 1720 | int ext,port; |
klauss | 78:1353744f01e1 | 1721 | char *split, *ref, *cmd; |
klauss | 109:a5b8264ffbbc | 1722 | |
klauss | 78:1353744f01e1 | 1723 | ref = debug_buf; |
klauss | 109:a5b8264ffbbc | 1724 | |
klauss | 78:1353744f01e1 | 1725 | strcat( debug_buf, "\r" ); |
klauss | 109:a5b8264ffbbc | 1726 | |
klauss | 78:1353744f01e1 | 1727 | split = strtok( debug_buf + 9, " " ); |
klauss | 78:1353744f01e1 | 1728 | ext = atoi( split ); |
klauss | 78:1353744f01e1 | 1729 | split = strtok( NULL, " " ); |
klauss | 78:1353744f01e1 | 1730 | port = atoi( split ); |
klauss | 78:1353744f01e1 | 1731 | split += strlen( split ) + 1; |
klauss | 78:1353744f01e1 | 1732 | cmd = split; |
klauss | 109:a5b8264ffbbc | 1733 | |
klauss | 78:1353744f01e1 | 1734 | promptcb_last_ext = ext; |
klauss | 78:1353744f01e1 | 1735 | promptcb_last_port = port; |
klauss | 109:a5b8264ffbbc | 1736 | |
klauss | 78:1353744f01e1 | 1737 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 78:1353744f01e1 | 1738 | strcat( cmd, "\r\r\r\n" ); |
klauss | 109:a5b8264ffbbc | 1739 | |
klauss | 109:a5b8264ffbbc | 1740 | if( debug_uart3 ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); |
klauss | 109:a5b8264ffbbc | 1741 | send2callboxes( __build_cb_package__( ext, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 109:a5b8264ffbbc | 1742 | if( debug_uart3 ) pc.printf("\n\rComando enviado"); |
klauss | 109:a5b8264ffbbc | 1743 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1747 | if( tcp_session ){ |
klauss | 78:1353744f01e1 | 1748 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 109:a5b8264ffbbc | 1749 | }else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 1750 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 78:1353744f01e1 | 1751 | } |
klauss | 78:1353744f01e1 | 1752 | } |
klauss | 109:a5b8264ffbbc | 1753 | |
klauss | 78:1353744f01e1 | 1754 | debug_buf = ref; |
klauss | 78:1353744f01e1 | 1755 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 1756 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 78:1353744f01e1 | 1757 | } |
klauss | 109:a5b8264ffbbc | 1758 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1763 | uint8_t write_buffer[ 300 ], data[ 300 ]; |
klauss | 109:a5b8264ffbbc | 1764 | |
klauss | 92:92df17f538a8 | 1765 | ref = debug_buf; |
klauss | 109:a5b8264ffbbc | 1766 | |
klauss | 92:92df17f538a8 | 1767 | strcat( debug_buf, "\r\r\r\n" ); |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1772 | |
klauss | 109:a5b8264ffbbc | 1773 | if( debug_uart3 ) pc.printf("\r\next=%d port=%d request bye", ext, port ); |
klauss | 109:a5b8264ffbbc | 1774 | send2callboxes( __build_cb_package__( ext, port, __CB_BYE__, (char * )data, 0x20, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 109:a5b8264ffbbc | 1775 | if( debug_uart3 ) pc.printf("\n\rBye enviado"); |
klauss | 109:a5b8264ffbbc | 1776 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1780 | if( tcp_session ){ |
klauss | 92:92df17f538a8 | 1781 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 109:a5b8264ffbbc | 1782 | }else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 1783 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 92:92df17f538a8 | 1784 | } |
klauss | 92:92df17f538a8 | 1785 | } |
klauss | 109:a5b8264ffbbc | 1786 | |
klauss | 92:92df17f538a8 | 1787 | debug_buf = ref; |
klauss | 92:92df17f538a8 | 1788 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 1789 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 92:92df17f538a8 | 1790 | } |
klauss | 109:a5b8264ffbbc | 1791 | |
klauss | 45:c80574f24dc3 | 1792 | //promptcb ramal porta comando |
klauss | 50:d9b6577a70f5 | 1793 | //FIXME colocar a parte eth de novo |
klauss | 59:e1e300880d2d | 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 | 109:a5b8264ffbbc | 1798 | |
klauss | 62:07e5bdc9f8f7 | 1799 | ref = debug_buf; |
klauss | 109:a5b8264ffbbc | 1800 | |
klauss | 74:81c47fff88a5 | 1801 | strcat( debug_buf, "\r" ); |
klauss | 109:a5b8264ffbbc | 1802 | |
klauss | 48:195c97f12e8e | 1803 | split = strtok( debug_buf + 4, " " ); |
klauss | 48:195c97f12e8e | 1804 | ext = atoi( split ); |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1809 | |
klauss | 48:195c97f12e8e | 1810 | promptcb_last_ext = ext; |
klauss | 48:195c97f12e8e | 1811 | promptcb_last_port = port; |
klauss | 109:a5b8264ffbbc | 1812 | |
klauss | 55:2f5e7374af9d | 1813 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 109:a5b8264ffbbc | 1814 | strcat( cmd, "\r\r\r\n" ); |
klauss | 109:a5b8264ffbbc | 1815 | |
klauss | 109:a5b8264ffbbc | 1816 | //send_msg( "Tamanho do cmd == %d", strlen( cmd ) ); |
klauss | 109:a5b8264ffbbc | 1817 | |
klauss | 109:a5b8264ffbbc | 1818 | //for( register uint16_t i = strlen( cmd ); i < __CB_BUFFER_SIZE__; i++ ) cmd[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 1819 | |
klauss | 109:a5b8264ffbbc | 1820 | if( debug_uart3 ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); |
klauss | 109:a5b8264ffbbc | 1821 | send2callboxes( __build_cb_package__( ext, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 109:a5b8264ffbbc | 1822 | if( debug_uart3 ) pc.printf("\n\rComando enviado"); |
klauss | 109:a5b8264ffbbc | 1823 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1827 | if( tcp_session ){ |
klauss | 62:07e5bdc9f8f7 | 1828 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 109:a5b8264ffbbc | 1829 | }else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 1830 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 62:07e5bdc9f8f7 | 1831 | } |
klauss | 54:448d57291be6 | 1832 | } |
klauss | 109:a5b8264ffbbc | 1833 | |
klauss | 48:195c97f12e8e | 1834 | debug_buf = ref; |
klauss | 109:a5b8264ffbbc | 1835 | //bufptr = 0; |
klauss | 109:a5b8264ffbbc | 1836 | //debug_buf[ 0 ] = 0; |
klauss | 62:07e5bdc9f8f7 | 1837 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 1838 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 45:c80574f24dc3 | 1839 | } |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1845 | |
klauss | 98:43b45f26b430 | 1846 | ref = debug_buf; |
klauss | 109:a5b8264ffbbc | 1847 | |
klauss | 98:43b45f26b430 | 1848 | strcat( debug_buf, "\r" ); |
klauss | 109:a5b8264ffbbc | 1849 | |
klauss | 98:43b45f26b430 | 1850 | split = strtok( debug_buf + 4, " " ); |
klauss | 98:43b45f26b430 | 1851 | ext = atoi( split ); |
klauss | 109:a5b8264ffbbc | 1852 | |
klauss | 98:43b45f26b430 | 1853 | split += strlen( split ) + 1; |
klauss | 98:43b45f26b430 | 1854 | split = strtok( NULL, " " ); |
klauss | 98:43b45f26b430 | 1855 | port = atoi( split ); |
klauss | 109:a5b8264ffbbc | 1856 | |
klauss | 98:43b45f26b430 | 1857 | split += strlen( split ) + 1; |
klauss | 98:43b45f26b430 | 1858 | cmd = split; |
klauss | 109:a5b8264ffbbc | 1859 | |
klauss | 98:43b45f26b430 | 1860 | promptcb_last_ext = ext; |
klauss | 98:43b45f26b430 | 1861 | promptcb_last_port = port; |
klauss | 109:a5b8264ffbbc | 1862 | |
klauss | 98:43b45f26b430 | 1863 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 109:a5b8264ffbbc | 1864 | strcat( cmd, "\r\r\r\n" ); |
klauss | 109:a5b8264ffbbc | 1865 | |
klauss | 109:a5b8264ffbbc | 1866 | if( debug_uart3 ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); |
klauss | 109:a5b8264ffbbc | 1867 | send2callboxes( __build_cb_package__( ext, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 109:a5b8264ffbbc | 1868 | if( debug_uart3 ) pc.printf("\n\rComando enviado"); |
klauss | 109:a5b8264ffbbc | 1869 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 1873 | if( tcp_session ){ |
klauss | 98:43b45f26b430 | 1874 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 109:a5b8264ffbbc | 1875 | }else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 1876 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 98:43b45f26b430 | 1877 | } |
klauss | 98:43b45f26b430 | 1878 | } |
klauss | 109:a5b8264ffbbc | 1879 | |
klauss | 98:43b45f26b430 | 1880 | debug_buf = ref; |
klauss | 98:43b45f26b430 | 1881 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 1882 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 1883 | } |
klauss | 109:a5b8264ffbbc | 1884 | |
klauss | 109:a5b8264ffbbc | 1885 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_cb ", 9 )) { |
klauss | 109:a5b8264ffbbc | 1886 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1887 | char *split; |
klauss | 109:a5b8264ffbbc | 1888 | |
klauss | 109:a5b8264ffbbc | 1889 | split = strtok( debug_buf + 9, " " ); |
klauss | 109:a5b8264ffbbc | 1890 | if( 0 == ( strcasecmp( split, "all" ) ) ) |
klauss | 109:a5b8264ffbbc | 1891 | { |
klauss | 109:a5b8264ffbbc | 1892 | print_cb_all = true; |
klauss | 109:a5b8264ffbbc | 1893 | } |
klauss | 109:a5b8264ffbbc | 1894 | else |
klauss | 109:a5b8264ffbbc | 1895 | { |
klauss | 109:a5b8264ffbbc | 1896 | print_cb_var = true; |
klauss | 109:a5b8264ffbbc | 1897 | print_this_cb = atoi( split ); |
klauss | 109:a5b8264ffbbc | 1898 | } |
klauss | 109:a5b8264ffbbc | 1899 | |
klauss | 109:a5b8264ffbbc | 1900 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 1901 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 1902 | } |
klauss | 109:a5b8264ffbbc | 1903 | |
klauss | 109:a5b8264ffbbc | 1904 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "frtp ", 5 )) { |
klauss | 109:a5b8264ffbbc | 1905 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1906 | char *split; |
klauss | 109:a5b8264ffbbc | 1907 | |
klauss | 109:a5b8264ffbbc | 1908 | split = strtok( debug_buf + 5, " " ); |
klauss | 109:a5b8264ffbbc | 1909 | frtp = true; |
klauss | 109:a5b8264ffbbc | 1910 | frtp_target = atoi( split ); |
klauss | 109:a5b8264ffbbc | 1911 | |
klauss | 109:a5b8264ffbbc | 1912 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 1913 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 1914 | } |
klauss | 109:a5b8264ffbbc | 1915 | |
klauss | 109:a5b8264ffbbc | 1916 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "rrtp ", 5 )) { |
klauss | 109:a5b8264ffbbc | 1917 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1918 | char *split; |
klauss | 109:a5b8264ffbbc | 1919 | |
klauss | 109:a5b8264ffbbc | 1920 | split = strtok( debug_buf + 5, " " ); |
klauss | 109:a5b8264ffbbc | 1921 | rescue_rtp = true; |
klauss | 109:a5b8264ffbbc | 1922 | rescue_rtp_target = atoi( split ); |
klauss | 109:a5b8264ffbbc | 1923 | |
klauss | 109:a5b8264ffbbc | 1924 | split += strlen( split ) + 1; |
klauss | 109:a5b8264ffbbc | 1925 | split = strtok( NULL, " " ); |
klauss | 109:a5b8264ffbbc | 1926 | rescue_rtp_value = atoi( split ); |
klauss | 109:a5b8264ffbbc | 1927 | |
klauss | 109:a5b8264ffbbc | 1928 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 1929 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 1930 | } |
klauss | 109:a5b8264ffbbc | 1931 | |
klauss | 109:a5b8264ffbbc | 1932 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_hex_cb ", 13 )) { |
klauss | 109:a5b8264ffbbc | 1933 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1934 | char *split; |
klauss | 109:a5b8264ffbbc | 1935 | |
klauss | 109:a5b8264ffbbc | 1936 | split = strtok( debug_buf + 13, " " ); |
klauss | 109:a5b8264ffbbc | 1937 | if( 0 == ( strcasecmp( split, "all" ) ) ) |
klauss | 109:a5b8264ffbbc | 1938 | { |
klauss | 109:a5b8264ffbbc | 1939 | print_hex_cb_all = true; |
klauss | 109:a5b8264ffbbc | 1940 | } |
klauss | 109:a5b8264ffbbc | 1941 | else |
klauss | 109:a5b8264ffbbc | 1942 | { |
klauss | 109:a5b8264ffbbc | 1943 | print_hex_cb_var = true; |
klauss | 109:a5b8264ffbbc | 1944 | print_hex_this_cb = atoi( split ); |
klauss | 109:a5b8264ffbbc | 1945 | } |
klauss | 109:a5b8264ffbbc | 1946 | |
klauss | 109:a5b8264ffbbc | 1947 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 1948 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 1949 | } |
klauss | 109:a5b8264ffbbc | 1950 | |
klauss | 109:a5b8264ffbbc | 1951 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_sip ", 10 )) { |
klauss | 109:a5b8264ffbbc | 1952 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1953 | char *split; |
klauss | 109:a5b8264ffbbc | 1954 | |
klauss | 109:a5b8264ffbbc | 1955 | split = strtok( debug_buf + 10, " " ); |
klauss | 109:a5b8264ffbbc | 1956 | if( 0 == ( strcasecmp( split, "all" ) ) ) |
klauss | 109:a5b8264ffbbc | 1957 | { |
klauss | 109:a5b8264ffbbc | 1958 | print_sip_all = true; |
klauss | 109:a5b8264ffbbc | 1959 | } |
klauss | 109:a5b8264ffbbc | 1960 | else |
klauss | 109:a5b8264ffbbc | 1961 | { |
klauss | 109:a5b8264ffbbc | 1962 | print_sip_var = true; |
klauss | 109:a5b8264ffbbc | 1963 | print_this_sip = atoi( split ); |
klauss | 109:a5b8264ffbbc | 1964 | } |
klauss | 109:a5b8264ffbbc | 1965 | |
klauss | 109:a5b8264ffbbc | 1966 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 1967 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 98:43b45f26b430 | 1968 | } |
klauss | 109:a5b8264ffbbc | 1969 | |
klauss | 109:a5b8264ffbbc | 1970 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_hex_sip ", 14 )) { |
klauss | 109:a5b8264ffbbc | 1971 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1972 | char *split; |
klauss | 109:a5b8264ffbbc | 1973 | |
klauss | 109:a5b8264ffbbc | 1974 | split = strtok( debug_buf + 14, " " ); |
klauss | 109:a5b8264ffbbc | 1975 | if( 0 == ( strcasecmp( split, "all" ) ) ) |
klauss | 109:a5b8264ffbbc | 1976 | { |
klauss | 109:a5b8264ffbbc | 1977 | print_hex_sip_all = true; |
klauss | 109:a5b8264ffbbc | 1978 | } |
klauss | 109:a5b8264ffbbc | 1979 | else |
klauss | 109:a5b8264ffbbc | 1980 | { |
klauss | 109:a5b8264ffbbc | 1981 | print_hex_sip_var = true; |
klauss | 109:a5b8264ffbbc | 1982 | print_hex_this_sip = atoi( split ); |
klauss | 109:a5b8264ffbbc | 1983 | } |
klauss | 109:a5b8264ffbbc | 1984 | |
klauss | 109:a5b8264ffbbc | 1985 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 1986 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 1987 | } |
klauss | 109:a5b8264ffbbc | 1988 | |
klauss | 109:a5b8264ffbbc | 1989 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_call ", 11 ) ) |
klauss | 109:a5b8264ffbbc | 1990 | { |
klauss | 109:a5b8264ffbbc | 1991 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 1992 | char *split; |
klauss | 109:a5b8264ffbbc | 1993 | |
klauss | 109:a5b8264ffbbc | 1994 | split = strtok( debug_buf + 11, " " ); |
klauss | 109:a5b8264ffbbc | 1995 | if( 0 == ( strcasecmp( split, "all" ) ) ) |
klauss | 109:a5b8264ffbbc | 1996 | { |
klauss | 109:a5b8264ffbbc | 1997 | print_call_all = true; |
klauss | 109:a5b8264ffbbc | 1998 | } |
klauss | 109:a5b8264ffbbc | 1999 | else |
klauss | 109:a5b8264ffbbc | 2000 | { |
klauss | 109:a5b8264ffbbc | 2001 | print_call_var = true; |
klauss | 109:a5b8264ffbbc | 2002 | print_this_call = atoi( split ); |
klauss | 109:a5b8264ffbbc | 2003 | } |
klauss | 109:a5b8264ffbbc | 2004 | |
klauss | 109:a5b8264ffbbc | 2005 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 2006 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 2007 | } |
klauss | 109:a5b8264ffbbc | 2008 | |
klauss | 109:a5b8264ffbbc | 2009 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_hex_call ", 15 ) ) |
klauss | 109:a5b8264ffbbc | 2010 | { |
klauss | 109:a5b8264ffbbc | 2011 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 2012 | char *split; |
klauss | 109:a5b8264ffbbc | 2013 | |
klauss | 109:a5b8264ffbbc | 2014 | split = strtok( debug_buf + 15, " " ); |
klauss | 109:a5b8264ffbbc | 2015 | if( 0 == ( strcasecmp( split, "all" ) ) ) |
klauss | 109:a5b8264ffbbc | 2016 | { |
klauss | 109:a5b8264ffbbc | 2017 | print_hex_call_all = true; |
klauss | 109:a5b8264ffbbc | 2018 | } |
klauss | 109:a5b8264ffbbc | 2019 | else |
klauss | 109:a5b8264ffbbc | 2020 | { |
klauss | 109:a5b8264ffbbc | 2021 | print_hex_call_var = true; |
klauss | 109:a5b8264ffbbc | 2022 | print_hex_this_call = atoi( split ); |
klauss | 109:a5b8264ffbbc | 2023 | } |
klauss | 109:a5b8264ffbbc | 2024 | |
klauss | 109:a5b8264ffbbc | 2025 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 2026 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 2027 | } |
klauss | 109:a5b8264ffbbc | 2028 | |
klauss | 109:a5b8264ffbbc | 2029 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_rtp ", 10 ) ) |
klauss | 109:a5b8264ffbbc | 2030 | { |
klauss | 109:a5b8264ffbbc | 2031 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 2032 | char *split; |
klauss | 109:a5b8264ffbbc | 2033 | |
klauss | 109:a5b8264ffbbc | 2034 | split = strtok( debug_buf + 10, " " ); |
klauss | 109:a5b8264ffbbc | 2035 | if( 0 == ( strcasecmp( split, "all" ) ) ) |
klauss | 109:a5b8264ffbbc | 2036 | { |
klauss | 109:a5b8264ffbbc | 2037 | print_rtp_all = true; |
klauss | 109:a5b8264ffbbc | 2038 | } |
klauss | 109:a5b8264ffbbc | 2039 | else |
klauss | 109:a5b8264ffbbc | 2040 | { |
klauss | 109:a5b8264ffbbc | 2041 | print_rtp_var = true; |
klauss | 109:a5b8264ffbbc | 2042 | print_this_rtp = atoi( split ); |
klauss | 109:a5b8264ffbbc | 2043 | } |
klauss | 109:a5b8264ffbbc | 2044 | |
klauss | 109:a5b8264ffbbc | 2045 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 2046 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 2047 | } |
klauss | 109:a5b8264ffbbc | 2048 | |
klauss | 109:a5b8264ffbbc | 2049 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_hex_rtp ", 14 ) ) |
klauss | 109:a5b8264ffbbc | 2050 | { |
klauss | 109:a5b8264ffbbc | 2051 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 2052 | char *split; |
klauss | 109:a5b8264ffbbc | 2053 | |
klauss | 109:a5b8264ffbbc | 2054 | split = strtok( debug_buf + 14, " " ); |
klauss | 109:a5b8264ffbbc | 2055 | if( 0 == ( strcasecmp( split, "all" ) ) ) |
klauss | 109:a5b8264ffbbc | 2056 | { |
klauss | 109:a5b8264ffbbc | 2057 | print_hex_rtp_all = true; |
klauss | 109:a5b8264ffbbc | 2058 | } |
klauss | 109:a5b8264ffbbc | 2059 | else |
klauss | 109:a5b8264ffbbc | 2060 | { |
klauss | 109:a5b8264ffbbc | 2061 | print_hex_rtp_var = true; |
klauss | 109:a5b8264ffbbc | 2062 | print_hex_this_rtp = atoi( split ); |
klauss | 109:a5b8264ffbbc | 2063 | } |
klauss | 109:a5b8264ffbbc | 2064 | |
klauss | 109:a5b8264ffbbc | 2065 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 2066 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 2067 | } |
klauss | 109:a5b8264ffbbc | 2068 | |
klauss | 109:a5b8264ffbbc | 2069 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "log ", 4 )) { |
klauss | 109:a5b8264ffbbc | 2070 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 2071 | |
klauss | 109:a5b8264ffbbc | 2072 | char * split = strtok( debug_buf + 4, " " ); |
klauss | 109:a5b8264ffbbc | 2073 | |
klauss | 109:a5b8264ffbbc | 2074 | { |
klauss | 109:a5b8264ffbbc | 2075 | print_cb_var = true; |
klauss | 109:a5b8264ffbbc | 2076 | print_this_cb = atoi( split ); |
klauss | 109:a5b8264ffbbc | 2077 | print_sip_var = true; |
klauss | 109:a5b8264ffbbc | 2078 | print_this_sip = print_this_cb; |
klauss | 109:a5b8264ffbbc | 2079 | print_call_var = true; |
klauss | 109:a5b8264ffbbc | 2080 | print_this_call = print_this_cb; |
klauss | 109:a5b8264ffbbc | 2081 | print_rtp_var = true; |
klauss | 109:a5b8264ffbbc | 2082 | print_this_rtp = print_this_cb; |
klauss | 109:a5b8264ffbbc | 2083 | } |
klauss | 109:a5b8264ffbbc | 2084 | |
klauss | 109:a5b8264ffbbc | 2085 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 2086 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 2087 | } |
klauss | 109:a5b8264ffbbc | 2088 | |
klauss | 109:a5b8264ffbbc | 2089 | |
klauss | 99:e80850c51106 | 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 | 109:a5b8264ffbbc | 2094 | |
klauss | 99:e80850c51106 | 2095 | ref = debug_buf; |
klauss | 109:a5b8264ffbbc | 2096 | |
klauss | 99:e80850c51106 | 2097 | strcat( debug_buf, "\r" ); |
klauss | 109:a5b8264ffbbc | 2098 | |
klauss | 99:e80850c51106 | 2099 | split = strtok( debug_buf + 5, " " ); |
klauss | 99:e80850c51106 | 2100 | ext = atoi( split ); |
klauss | 109:a5b8264ffbbc | 2101 | |
klauss | 99:e80850c51106 | 2102 | split += strlen( split ) + 1; |
klauss | 99:e80850c51106 | 2103 | split = strtok( NULL, " " ); |
klauss | 99:e80850c51106 | 2104 | port = atoi( split ); |
klauss | 109:a5b8264ffbbc | 2105 | |
klauss | 99:e80850c51106 | 2106 | strcpy( cmd, "ping\r\n" ); |
klauss | 109:a5b8264ffbbc | 2107 | |
klauss | 99:e80850c51106 | 2108 | promptcb_last_ext = ext; |
klauss | 99:e80850c51106 | 2109 | promptcb_last_port = port; |
klauss | 109:a5b8264ffbbc | 2110 | |
klauss | 99:e80850c51106 | 2111 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 99:e80850c51106 | 2112 | strcat( cmd, "\r\r\r\n" ); |
klauss | 109:a5b8264ffbbc | 2113 | |
klauss | 109:a5b8264ffbbc | 2114 | for( register uint8_t i = 0; i < 3; i++ ){ |
klauss | 109:a5b8264ffbbc | 2115 | if( debug_uart3 ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); |
klauss | 109:a5b8264ffbbc | 2116 | send2callboxes( __build_cb_package__( ext, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 109:a5b8264ffbbc | 2117 | if( debug_uart3 ) pc.printf("\n\rComando enviado"); |
klauss | 109:a5b8264ffbbc | 2118 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2122 | if( tcp_session ){ |
klauss | 99:e80850c51106 | 2123 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 109:a5b8264ffbbc | 2124 | }else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2125 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 99:e80850c51106 | 2126 | } |
klauss | 99:e80850c51106 | 2127 | } |
klauss | 99:e80850c51106 | 2128 | } |
klauss | 109:a5b8264ffbbc | 2129 | |
klauss | 99:e80850c51106 | 2130 | debug_buf = ref; |
klauss | 99:e80850c51106 | 2131 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 2132 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 99:e80850c51106 | 2133 | } |
klauss | 109:a5b8264ffbbc | 2134 | |
klauss | 109:a5b8264ffbbc | 2135 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2160 | if( debug_uart3 ) pc.printf("\r\nDebug Main ON"); |
klauss | 109:a5b8264ffbbc | 2161 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2169 | if( debug_uart3 ) pc.printf("\r\nDebug Main OFF"); |
klauss | 109:a5b8264ffbbc | 2170 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2177 | |
klauss | 109:a5b8264ffbbc | 2178 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dout ", 5 ) ){ |
klauss | 109:a5b8264ffbbc | 2179 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "on", 2 ) ){ |
klauss | 81:3656f00ab3db | 2180 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 2181 | if( debug_uart3 ) pc.printf("\r\nOut Debug ON"); |
klauss | 109:a5b8264ffbbc | 2182 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2188 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "off", 3 ) ){ |
klauss | 81:3656f00ab3db | 2189 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 2190 | if( debug_uart3 ) pc.printf("\r\nOut Debug OFF"); |
klauss | 109:a5b8264ffbbc | 2191 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2198 | |
klauss | 109:a5b8264ffbbc | 2199 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dboot ", 6 ) ){ |
klauss | 109:a5b8264ffbbc | 2200 | if (xmemmatch( (uint8_t*)( debug_buf + 6 ), (uint8_t*) "on", 2 ) ){ |
klauss | 99:e80850c51106 | 2201 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 2202 | if( debug_uart3 ) pc.printf("\r\nBoot Debug ON"); |
klauss | 109:a5b8264ffbbc | 2203 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2209 | if (xmemmatch( (uint8_t*)( debug_buf + 6 ), (uint8_t*) "off", 3 ) ){ |
klauss | 99:e80850c51106 | 2210 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 2211 | if( debug_uart3 ) pc.printf("\r\nBoot Debug OFF"); |
klauss | 109:a5b8264ffbbc | 2212 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2219 | |
klauss | 109:a5b8264ffbbc | 2220 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dfw ", 4 ) ){ |
klauss | 109:a5b8264ffbbc | 2221 | if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "on", 2 ) ){ |
klauss | 99:e80850c51106 | 2222 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 2223 | if( debug_uart3 ) pc.printf("\r\nFW Debug ON"); |
klauss | 109:a5b8264ffbbc | 2224 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2230 | if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "off", 3 ) ){ |
klauss | 99:e80850c51106 | 2231 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 2232 | if( debug_uart3 ) pc.printf("\r\nFW Debug OFF"); |
klauss | 109:a5b8264ffbbc | 2233 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2240 | |
klauss | 109:a5b8264ffbbc | 2241 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dfwp ", 5 ) ){ |
klauss | 109:a5b8264ffbbc | 2242 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "on", 2 ) ){ |
klauss | 99:e80850c51106 | 2243 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 2244 | if( debug_uart3 ) pc.printf("\r\nFWPrint Debug ON"); |
klauss | 109:a5b8264ffbbc | 2245 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2251 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "off", 3 ) ){ |
klauss | 99:e80850c51106 | 2252 | miss_match = false; |
klauss | 109:a5b8264ffbbc | 2253 | if( debug_uart3 ) pc.printf("\r\nFWPrint Debug OFF"); |
klauss | 109:a5b8264ffbbc | 2254 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2265 | if( debug_uart3 ) pc.printf("\tDebug Cbx Rx ON"); |
klauss | 109:a5b8264ffbbc | 2266 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2274 | if( debug_uart3 ) pc.printf("\tDebug Cbx Rx OFF"); |
klauss | 109:a5b8264ffbbc | 2275 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2286 | if( debug_uart3 ) pc.printf("\tDebug Cbx Rx ON"); |
klauss | 109:a5b8264ffbbc | 2287 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2295 | if( debug_uart3 ) pc.printf("\tDebug Cbx Rx OFF"); |
klauss | 109:a5b8264ffbbc | 2296 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2307 | if( debug_uart3 ) pc.printf("\tDebug File ON"); |
klauss | 109:a5b8264ffbbc | 2308 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2316 | if( debug_uart3 ) pc.printf("Debug File OFF"); |
klauss | 109:a5b8264ffbbc | 2317 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2327 | if( debug_uart3 ) pc.printf("\n\r****************************PROMPT HELP******************\n\r"); |
klauss | 109:a5b8264ffbbc | 2328 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 2329 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "\n\r****************************PROMPT HELP******************\n\r" ); |
klauss | 109:a5b8264ffbbc | 2330 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2331 | |
klauss | 109:a5b8264ffbbc | 2332 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2333 | while( !( udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 2334 | } |
klauss | 44:cc4996469404 | 2335 | } |
klauss | 109:a5b8264ffbbc | 2336 | |
klauss | 109:a5b8264ffbbc | 2337 | if( debug_uart3 ) pc.printf("ifconfig - mostra o arquivo de configuracao do sistema\n\r"); |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2340 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2341 | |
klauss | 109:a5b8264ffbbc | 2342 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2343 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 2344 | } |
klauss | 109:a5b8264ffbbc | 2345 | } |
klauss | 109:a5b8264ffbbc | 2346 | if( debug_uart3 ) pc.printf("dconfig - volta as configuracoes do sistema para o padrao de fabrica\n\r"); |
klauss | 109:a5b8264ffbbc | 2347 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2348 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "dconfig - volta as configuracoes do sistema para o padrao de fabrica\n\r" ); |
klauss | 109:a5b8264ffbbc | 2349 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2350 | |
klauss | 109:a5b8264ffbbc | 2351 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2352 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2353 | } |
klauss | 45:c80574f24dc3 | 2354 | } |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2356 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2358 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2359 | |
klauss | 109:a5b8264ffbbc | 2360 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2361 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2362 | } |
klauss | 45:c80574f24dc3 | 2363 | } |
klauss | 109:a5b8264ffbbc | 2364 | if( debug_uart3 ) pc.printf("pcb porta comando - envia o <comando> para o cbx <ramal> e <porta> executar\n\r"); |
klauss | 109:a5b8264ffbbc | 2365 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2367 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2368 | |
klauss | 109:a5b8264ffbbc | 2369 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2370 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2371 | } |
klauss | 45:c80574f24dc3 | 2372 | } |
klauss | 109:a5b8264ffbbc | 2373 | if( debug_uart3 ) pc.printf("format - formata o sistema de arquivos\n\r"); |
klauss | 109:a5b8264ffbbc | 2374 | //desabilitado via eth |
klauss | 109:a5b8264ffbbc | 2375 | /* |
klauss | 109:a5b8264ffbbc | 2376 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2377 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "format - formata o sistema de arquivos\n\r" ); |
klauss | 109:a5b8264ffbbc | 2378 | if( tcp_session ) tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 2379 | |
klauss | 109:a5b8264ffbbc | 2380 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2381 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2382 | } |
klauss | 45:c80574f24dc3 | 2383 | } |
klauss | 109:a5b8264ffbbc | 2384 | */ |
klauss | 109:a5b8264ffbbc | 2385 | if( debug_uart3 ) pc.printf("reset - resta o sistema\n\r"); |
klauss | 109:a5b8264ffbbc | 2386 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 2387 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "reset - resta o sistema\n\r" ); |
klauss | 109:a5b8264ffbbc | 2388 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2389 | |
klauss | 109:a5b8264ffbbc | 2390 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2391 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 2392 | } |
klauss | 109:a5b8264ffbbc | 2393 | } |
klauss | 109:a5b8264ffbbc | 2394 | if( debug_uart3 ) pc.printf("ipset [ip] - Configura o IP da cabeceira\n\r"); |
klauss | 109:a5b8264ffbbc | 2395 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2396 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ipset [ip] - Configura o IP da cabeceira\n\r" ); |
klauss | 109:a5b8264ffbbc | 2397 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2398 | |
klauss | 109:a5b8264ffbbc | 2399 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2400 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2401 | } |
klauss | 45:c80574f24dc3 | 2402 | } |
klauss | 109:a5b8264ffbbc | 2403 | if( debug_uart3 ) pc.printf("extset [ext] - Configura a ext da cabeceira\n\r"); |
klauss | 109:a5b8264ffbbc | 2404 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2405 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "extset [ext] - Configura a ext da cabeceira\n\r" ); |
klauss | 109:a5b8264ffbbc | 2406 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2407 | |
klauss | 109:a5b8264ffbbc | 2408 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2409 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2410 | } |
klauss | 45:c80574f24dc3 | 2411 | } |
klauss | 109:a5b8264ffbbc | 2412 | if( debug_uart3 ) pc.printf("msipport [port] - Configura a porta SIP da cabeceira\n\r"); |
klauss | 109:a5b8264ffbbc | 2413 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2414 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "msipport [port] - Configura a porta SIP da cabeceira\n\r" ); |
klauss | 109:a5b8264ffbbc | 2415 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2416 | |
klauss | 109:a5b8264ffbbc | 2417 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2418 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2419 | } |
klauss | 45:c80574f24dc3 | 2420 | } |
klauss | 109:a5b8264ffbbc | 2421 | if( debug_uart3 ) pc.printf("serverip [ip] - Configura o ip do servidor asterisk\n\r"); |
klauss | 109:a5b8264ffbbc | 2422 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2423 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "serverip [ip] - Configura o ip do servidor asterisk\n\r" ); |
klauss | 109:a5b8264ffbbc | 2424 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2425 | |
klauss | 109:a5b8264ffbbc | 2426 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2427 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2428 | } |
klauss | 45:c80574f24dc3 | 2429 | } |
klauss | 109:a5b8264ffbbc | 2430 | if( debug_uart3 ) pc.printf("serextset [ext] - Configura a server ext da cabeceira\n\r"); |
klauss | 109:a5b8264ffbbc | 2431 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2432 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "serextset [ext] - Configura a server ext da cabeceira\n\r" ); |
klauss | 109:a5b8264ffbbc | 2433 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2434 | |
klauss | 109:a5b8264ffbbc | 2435 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2436 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2437 | } |
klauss | 45:c80574f24dc3 | 2438 | } |
klauss | 109:a5b8264ffbbc | 2439 | if( debug_uart3 ) pc.printf("ssport [port] - Configura a porta SIP do servidor asterisk\n\r"); |
klauss | 109:a5b8264ffbbc | 2440 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2441 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ssport [port] - Configura a porta SIP do servidor asterisk\n\r" ); |
klauss | 109:a5b8264ffbbc | 2442 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2443 | |
klauss | 109:a5b8264ffbbc | 2444 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2445 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2446 | } |
klauss | 45:c80574f24dc3 | 2447 | } |
klauss | 109:a5b8264ffbbc | 2448 | if( debug_uart3 ) pc.printf("maskset [mask] - Configura a mascara da cabeceira\n\r"); |
klauss | 109:a5b8264ffbbc | 2449 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2450 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "maskset [mask] - Configura a mascara da cabeceira\n\r" ); |
klauss | 109:a5b8264ffbbc | 2451 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2452 | |
klauss | 109:a5b8264ffbbc | 2453 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2454 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2455 | } |
klauss | 45:c80574f24dc3 | 2456 | } |
klauss | 109:a5b8264ffbbc | 2457 | if( debug_uart3 ) pc.printf("gatewayset [gateway] - Configura o gateway da cabeceira\n\r"); |
klauss | 109:a5b8264ffbbc | 2458 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2459 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "gatewayset [gateway] - Configura o gateway da cabeceira\n\r" ); |
klauss | 109:a5b8264ffbbc | 2460 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2461 | |
klauss | 109:a5b8264ffbbc | 2462 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2463 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2464 | } |
klauss | 45:c80574f24dc3 | 2465 | } |
klauss | 109:a5b8264ffbbc | 2466 | if( debug_uart3 ) pc.printf("telemetry_ip - Configura o IP do servidor de telemetria\n\r"); |
klauss | 109:a5b8264ffbbc | 2467 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2468 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "telemetry_ip - Configura o IP do servidor de telemetria\n\r" ); |
klauss | 109:a5b8264ffbbc | 2469 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2470 | |
klauss | 109:a5b8264ffbbc | 2471 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2472 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 56:c64bcbaa621a | 2473 | } |
klauss | 56:c64bcbaa621a | 2474 | } |
klauss | 109:a5b8264ffbbc | 2475 | if( debug_uart3 ) pc.printf("telemetry_port - Configura a port do servidor de telemetria\n\r"); |
klauss | 109:a5b8264ffbbc | 2476 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2477 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "telemetry_port - Configura a port do servidor de telemetria\n\r" ); |
klauss | 109:a5b8264ffbbc | 2478 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2479 | |
klauss | 109:a5b8264ffbbc | 2480 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2481 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 99:e80850c51106 | 2482 | } |
klauss | 99:e80850c51106 | 2483 | } |
klauss | 109:a5b8264ffbbc | 2484 | |
klauss | 109:a5b8264ffbbc | 2485 | if( debug_uart3 ) pc.printf("fw_ip - Configura o IP do servidor de fw\n\r"); |
klauss | 109:a5b8264ffbbc | 2486 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2487 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "fw_ip - Configura o IP do servidor de fw\n\r" ); |
klauss | 109:a5b8264ffbbc | 2488 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2489 | |
klauss | 109:a5b8264ffbbc | 2490 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2491 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 99:e80850c51106 | 2492 | } |
klauss | 99:e80850c51106 | 2493 | } |
klauss | 109:a5b8264ffbbc | 2494 | if( debug_uart3 ) pc.printf("fw_port - Configura a porta do servidor de fw\n\r"); |
klauss | 109:a5b8264ffbbc | 2495 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2496 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "fw_port - Configura a porta do servidor de fw\n\r" ); |
klauss | 109:a5b8264ffbbc | 2497 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2498 | |
klauss | 109:a5b8264ffbbc | 2499 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2500 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 2501 | } |
klauss | 109:a5b8264ffbbc | 2502 | } |
klauss | 109:a5b8264ffbbc | 2503 | |
klauss | 109:a5b8264ffbbc | 2504 | if( debug_uart3 ) pc.printf("maxext - Configura o maior ramal possivel de ser registrado nesse ramo\n\r"); |
klauss | 109:a5b8264ffbbc | 2505 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 2506 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "maxext - Configura o maior ramal possivel de ser registrado nesse ramo\n\r" ); |
klauss | 109:a5b8264ffbbc | 2507 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2508 | |
klauss | 109:a5b8264ffbbc | 2509 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2510 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 81:3656f00ab3db | 2511 | } |
klauss | 81:3656f00ab3db | 2512 | } |
klauss | 109:a5b8264ffbbc | 2513 | |
klauss | 109:a5b8264ffbbc | 2514 | if( debug_uart3 ) pc.printf("minext - Configura o menor ramal possivel de ser registrado nesse ramo\n\r"); |
klauss | 109:a5b8264ffbbc | 2515 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 2516 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "minext - Configura o menor ramal possivel de ser registrado nesse ramo\n\r" ); |
klauss | 109:a5b8264ffbbc | 2517 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2518 | |
klauss | 109:a5b8264ffbbc | 2519 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2520 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 81:3656f00ab3db | 2521 | } |
klauss | 81:3656f00ab3db | 2522 | } |
klauss | 109:a5b8264ffbbc | 2523 | |
klauss | 109:a5b8264ffbbc | 2524 | if( debug_uart3 ) pc.printf("showcb - lista os Cbx registrados na header\n\r"); |
klauss | 109:a5b8264ffbbc | 2525 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 2526 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "showcb - lista os Cbx registrados na header\n\r" ); |
klauss | 109:a5b8264ffbbc | 2527 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2528 | |
klauss | 109:a5b8264ffbbc | 2529 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2530 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2531 | } |
klauss | 45:c80574f24dc3 | 2532 | } |
klauss | 109:a5b8264ffbbc | 2533 | /* |
klauss | 109:a5b8264ffbbc | 2534 | if( debug_uart3 ) pc.printf("status - lista resumida de cbx registrados na header\n\r"); |
klauss | 109:a5b8264ffbbc | 2535 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2536 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "showcb - lista resumida de cbx registrados na header\n\r" ); |
klauss | 109:a5b8264ffbbc | 2537 | if( tcp_session ) tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 2538 | |
klauss | 109:a5b8264ffbbc | 2539 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2540 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 52:12930cef17c4 | 2541 | } |
klauss | 52:12930cef17c4 | 2542 | } |
klauss | 109:a5b8264ffbbc | 2543 | */ |
klauss | 109:a5b8264ffbbc | 2544 | if( debug_uart3 ) pc.printf("cks - exibe estatisticas de check sum\n\r"); |
klauss | 109:a5b8264ffbbc | 2545 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2546 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "cks - exibe estatisticas de check sum\n\r" ); |
klauss | 109:a5b8264ffbbc | 2547 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2548 | |
klauss | 109:a5b8264ffbbc | 2549 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2550 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2551 | } |
klauss | 45:c80574f24dc3 | 2552 | } |
klauss | 109:a5b8264ffbbc | 2553 | if( debug_uart3 ) pc.printf("reset_cks - reseta estatisticas de check sum\n\r"); |
klauss | 109:a5b8264ffbbc | 2554 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2555 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "reset_cks - reseta estatisticas de check sum\n\r" ); |
klauss | 109:a5b8264ffbbc | 2556 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2557 | |
klauss | 109:a5b8264ffbbc | 2558 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2559 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2560 | } |
klauss | 45:c80574f24dc3 | 2561 | } |
klauss | 109:a5b8264ffbbc | 2562 | |
klauss | 109:a5b8264ffbbc | 2563 | if( debug_uart3 ) pc.printf(". - executa o comando anterior novamente\n\r"); |
klauss | 109:a5b8264ffbbc | 2564 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2565 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, ". - executa o comando anterior novamente\n\r" ); |
klauss | 109:a5b8264ffbbc | 2566 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2567 | |
klauss | 109:a5b8264ffbbc | 2568 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2569 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 62:07e5bdc9f8f7 | 2570 | } |
klauss | 62:07e5bdc9f8f7 | 2571 | } |
klauss | 109:a5b8264ffbbc | 2572 | if( debug_uart3 ) pc.printf("debug [on|off|show] - seleciona debugs gerais | lista de debugs \n\r"); |
klauss | 109:a5b8264ffbbc | 2573 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2574 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "debug [on|off|show] - seleciona debugs gerais | lista de debugs \n\r" ); |
klauss | 109:a5b8264ffbbc | 2575 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2576 | |
klauss | 109:a5b8264ffbbc | 2577 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2578 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 65:0b653cfe95db | 2579 | } |
klauss | 65:0b653cfe95db | 2580 | } |
klauss | 109:a5b8264ffbbc | 2581 | if( debug_uart3 ) pc.printf("{ flood [ on | off ] | [+|-] } - simula envio de pacotes de audio\n\r"); |
klauss | 109:a5b8264ffbbc | 2582 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2583 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "{ flood [ on | off ] | [+|-] } - simula envio de pacotes de audio\n\r"); |
klauss | 109:a5b8264ffbbc | 2584 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2585 | |
klauss | 109:a5b8264ffbbc | 2586 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2587 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 2588 | } |
klauss | 109:a5b8264ffbbc | 2589 | } |
klauss | 109:a5b8264ffbbc | 2590 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2592 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2594 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2595 | |
klauss | 109:a5b8264ffbbc | 2596 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2597 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 2598 | } |
klauss | 45:c80574f24dc3 | 2599 | } |
klauss | 109:a5b8264ffbbc | 2600 | |
klauss | 109:a5b8264ffbbc | 2601 | if( debug_uart3 ) pc.printf("++ ext - Header flood on, ext flood on\n\r"); |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2604 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2605 | |
klauss | 109:a5b8264ffbbc | 2606 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2607 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 66:3f1d22e69e7b | 2608 | } |
klauss | 66:3f1d22e69e7b | 2609 | } |
klauss | 109:a5b8264ffbbc | 2610 | |
klauss | 109:a5b8264ffbbc | 2611 | if( debug_uart3 ) pc.printf("-- ext - Header flood off, ext flood off\n\r"); |
klauss | 109:a5b8264ffbbc | 2612 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2613 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "++ ext - Header flood on, ext flood on\n\r"); |
klauss | 109:a5b8264ffbbc | 2614 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2615 | |
klauss | 109:a5b8264ffbbc | 2616 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2617 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 64:5b011d5707d2 | 2618 | } |
klauss | 64:5b011d5707d2 | 2619 | } |
klauss | 109:a5b8264ffbbc | 2620 | |
klauss | 109:a5b8264ffbbc | 2621 | if( debug_uart3 ) pc.printf("rx - Exibe ultimo pacote recebido dos CBx\n\r"); |
klauss | 109:a5b8264ffbbc | 2622 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2623 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "rx - Exibe ultimo pacote recebido dos CBx\n\r"); |
klauss | 109:a5b8264ffbbc | 2624 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2625 | |
klauss | 109:a5b8264ffbbc | 2626 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2627 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 64:5b011d5707d2 | 2628 | } |
klauss | 64:5b011d5707d2 | 2629 | } |
klauss | 109:a5b8264ffbbc | 2630 | if( debug_uart3 ) pc.printf("tx - Exibe ultimo pacote enviado para os CBx\n\r"); |
klauss | 109:a5b8264ffbbc | 2631 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2632 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "tx - Exibe ultimo pacote enviado para os CBx\n\r"); |
klauss | 109:a5b8264ffbbc | 2633 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2634 | |
klauss | 109:a5b8264ffbbc | 2635 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2636 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 64:5b011d5707d2 | 2637 | } |
klauss | 64:5b011d5707d2 | 2638 | } |
klauss | 109:a5b8264ffbbc | 2639 | if( debug_uart3 ) pc.printf("ls | status - Exibe uma lista ordenada por ext do CBx registrados na Header\n\r"); |
klauss | 109:a5b8264ffbbc | 2640 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2641 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ls | status - Exibe uma lista ordenada por ext do CBx registrados na Header\n\r"); |
klauss | 109:a5b8264ffbbc | 2642 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2643 | |
klauss | 109:a5b8264ffbbc | 2644 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2645 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 104:62646ef786a3 | 2646 | } |
klauss | 104:62646ef786a3 | 2647 | } |
klauss | 109:a5b8264ffbbc | 2648 | if( debug_uart3 ) pc.printf("types - Lista os types usados no protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 109:a5b8264ffbbc | 2649 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2650 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "types - Lista os types usados no protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 109:a5b8264ffbbc | 2651 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2652 | |
klauss | 109:a5b8264ffbbc | 2653 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2654 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 104:62646ef786a3 | 2655 | } |
klauss | 104:62646ef786a3 | 2656 | } |
klauss | 109:a5b8264ffbbc | 2657 | if( debug_uart3 ) pc.printf("protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 109:a5b8264ffbbc | 2658 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2659 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 109:a5b8264ffbbc | 2660 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 109:a5b8264ffbbc | 2661 | |
klauss | 109:a5b8264ffbbc | 2662 | else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2663 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 2664 | } |
klauss | 109:a5b8264ffbbc | 2665 | } |
klauss | 109:a5b8264ffbbc | 2666 | |
klauss | 109:a5b8264ffbbc | 2667 | if( debug_uart3 ) pc.printf("PROMPT VERSION: V%d\n\r",PVERSION); |
klauss | 109:a5b8264ffbbc | 2668 | //Obs :: a ultima linha nao mandamos direto pro tcp porque ela eh enviada fora desse escopo |
klauss | 109:a5b8264ffbbc | 2669 | if( from_eth ) snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "PROMPT VERSION: V%d\n\r",PVERSION); |
klauss | 105:a930035b6556 | 2670 | } |
klauss | 109:a5b8264ffbbc | 2671 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2676 | |
klauss | 105:a930035b6556 | 2677 | ext = atoi( debug_buf + 7 ); |
klauss | 105:a930035b6556 | 2678 | port = convert_ext_to_port( ext ); |
klauss | 109:a5b8264ffbbc | 2679 | |
klauss | 105:a930035b6556 | 2680 | strcpy( cmd, ( ext % 2 ) ? "call init B" : "call init A" ); |
klauss | 109:a5b8264ffbbc | 2681 | |
klauss | 105:a930035b6556 | 2682 | if( ext % 2 ) ext--; |
klauss | 109:a5b8264ffbbc | 2683 | |
klauss | 105:a930035b6556 | 2684 | promptcb_last_ext = ext; |
klauss | 105:a930035b6556 | 2685 | promptcb_last_port = port; |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2691 | |
klauss | 109:a5b8264ffbbc | 2692 | if( debug_uart3 ) pc.printf("\r\next=%d port=%d\r\ncmd=%s\r\n", ext, port, cmd ); |
klauss | 109:a5b8264ffbbc | 2693 | |
klauss | 109:a5b8264ffbbc | 2694 | if( debug_uart3 ) pc.printf("\n\r--------------------------------------------------------\n\r"); |
klauss | 109:a5b8264ffbbc | 2695 | for( uint16_t i = 0; i < strlen( cmd ) ; i++ ) if( debug_uart3 ) pc.printf( "%02x ", cmd[ i ] ); |
klauss | 109:a5b8264ffbbc | 2696 | |
klauss | 109:a5b8264ffbbc | 2697 | send2callboxes( __build_cb_package__( ext, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 109:a5b8264ffbbc | 2698 | if( debug_uart3 ) pc.printf("\n\r--------------------------------------------------------\n\r"); |
klauss | 109:a5b8264ffbbc | 2699 | for( uint16_t i = 0; i < 300 ; i++ ){ |
klauss | 109:a5b8264ffbbc | 2700 | if( debug_uart3 ) pc.printf( "%02x ", write_buffer[ i ] ); |
klauss | 109:a5b8264ffbbc | 2701 | if( i != 0 && !( ( i + 1 ) % 30 ) ) if( debug_uart3 ) pc.printf("\n\r"); |
klauss | 109:a5b8264ffbbc | 2702 | } |
klauss | 109:a5b8264ffbbc | 2703 | |
klauss | 109:a5b8264ffbbc | 2704 | |
klauss | 109:a5b8264ffbbc | 2705 | if( debug_uart3 ) pc.printf("\n\rComando enviado\n\r"); |
klauss | 109:a5b8264ffbbc | 2706 | |
klauss | 109:a5b8264ffbbc | 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 | 109:a5b8264ffbbc | 2710 | if( tcp_session ){ |
klauss | 105:a930035b6556 | 2711 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 109:a5b8264ffbbc | 2712 | }else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2713 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 105:a930035b6556 | 2714 | } |
klauss | 105:a930035b6556 | 2715 | } |
klauss | 104:62646ef786a3 | 2716 | |
klauss | 104:62646ef786a3 | 2717 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 2718 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 105:a930035b6556 | 2719 | } |
klauss | 106:a34fcf9f0e02 | 2720 | |
klauss | 109:a5b8264ffbbc | 2721 | if( miss_match ){ |
klauss | 109:a5b8264ffbbc | 2722 | if( debug_uart3 ) pc.printf("\n\r> %s: command not found\n\r", debug_buf ); |
klauss | 109:a5b8264ffbbc | 2723 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2724 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "> %s: command not found\n ", debug_buf ); |
klauss | 109:a5b8264ffbbc | 2725 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 106:a34fcf9f0e02 | 2726 | } |
klauss | 106:a34fcf9f0e02 | 2727 | } |
klauss | 109:a5b8264ffbbc | 2728 | else{ |
klauss | 109:a5b8264ffbbc | 2729 | if( from_eth && strlen( debug_buf ) > 2 ) strcpy( last_cmd, tmp_cmd ); |
klauss | 106:a34fcf9f0e02 | 2730 | |
klauss | 109:a5b8264ffbbc | 2731 | else if( strlen( debug_buf ) > 2 ) strcpy( last_cmd, tmp_cmd ); |
klauss | 105:a930035b6556 | 2732 | } |
klauss | 109:a5b8264ffbbc | 2733 | } |
klauss | 109:a5b8264ffbbc | 2734 | if( b == 0x0D || bufret == 1 || bufptr > DEBUGBUFSIZE ){ |
klauss | 109:a5b8264ffbbc | 2735 | bufret = 0; |
klauss | 109:a5b8264ffbbc | 2736 | if( from_eth ){ |
klauss | 109:a5b8264ffbbc | 2737 | from_eth = false; |
klauss | 109:a5b8264ffbbc | 2738 | |
klauss | 109:a5b8264ffbbc | 2739 | if( debug_buf[ strlen( debug_buf ) - 1 ] == '\r' || debug_buf[ strlen( debug_buf ) - 1 ] == '\n' ) strcat( debug_buf, "> " ); |
klauss | 109:a5b8264ffbbc | 2740 | |
klauss | 109:a5b8264ffbbc | 2741 | else strcat( debug_buf, "\n\r> " ); |
klauss | 109:a5b8264ffbbc | 2742 | |
klauss | 109:a5b8264ffbbc | 2743 | if( tcp_session ){ |
klauss | 109:a5b8264ffbbc | 2744 | |
klauss | 105:a930035b6556 | 2745 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 2746 | |
klauss | 109:a5b8264ffbbc | 2747 | }else if( udp_request ){ |
klauss | 109:a5b8264ffbbc | 2748 | |
klauss | 109:a5b8264ffbbc | 2749 | int sent = udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 109:a5b8264ffbbc | 2750 | |
klauss | 109:a5b8264ffbbc | 2751 | udp_request = false; |
klauss | 105:a930035b6556 | 2752 | } |
klauss | 109:a5b8264ffbbc | 2753 | for( register uint16_t i = 0; i < __PROMPT_ETH_BUFFER_SIZE__; i++ ) eth_buffer[ i ] = 0; |
klauss | 109:a5b8264ffbbc | 2754 | debug_buf = __debug_buf__; |
klauss | 109:a5b8264ffbbc | 2755 | bufptr = last_bufptr; |
klauss | 109:a5b8264ffbbc | 2756 | }else{ |
klauss | 54:448d57291be6 | 2757 | bufptr = 0; |
klauss | 109:a5b8264ffbbc | 2758 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 45:c80574f24dc3 | 2759 | } |
klauss | 109:a5b8264ffbbc | 2760 | pc.putc(0x0A); |
klauss | 109:a5b8264ffbbc | 2761 | pc.putc(0x0D); |
klauss | 109:a5b8264ffbbc | 2762 | if( debug_uart3 ) pc.printf("> "); |
klauss | 109:a5b8264ffbbc | 2763 | } |
klauss | 109:a5b8264ffbbc | 2764 | return( NULL ); |
klauss | 54:448d57291be6 | 2765 | } |