![](/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@97:8985817e8847, 2015-01-10 (annotated)
- Committer:
- klauss
- Date:
- Sat Jan 10 23:59:51 2015 +0000
- Revision:
- 97:8985817e8847
- Parent:
- 92:92df17f538a8
- Child:
- 98:43b45f26b430
wip
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 | 81:3656f00ab3db | 15 | FILE *fip, *fmask, *fgate, *fport, *fsip, *fsport, *fext, *fserext, *fudpport, *ftcpport, *ftip, *ftport, *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 | 48:195c97f12e8e | 20 | int str2uint ( char * s, unsigned int * val ){ |
Cola | 21:0bd688722e81 | 21 | int i = 0; |
Cola | 21:0bd688722e81 | 22 | unsigned int ret = 0; |
Cola | 21:0bd688722e81 | 23 | for (;;) { |
Cola | 21:0bd688722e81 | 24 | if (s[i] < '0') { |
Cola | 21:0bd688722e81 | 25 | *val = ret; |
Cola | 21:0bd688722e81 | 26 | return i; |
Cola | 21:0bd688722e81 | 27 | } |
Cola | 21:0bd688722e81 | 28 | ret *= 10; |
Cola | 21:0bd688722e81 | 29 | ret += s[i] - '0'; |
Cola | 21:0bd688722e81 | 30 | i++; |
Cola | 21:0bd688722e81 | 31 | } |
Cola | 21:0bd688722e81 | 32 | } |
klauss | 19:ab2088e0dec6 | 33 | |
klauss | 28:94aec56c6329 | 34 | // operantion with the system config files |
klauss | 42:480335bdde12 | 35 | void files( const char type ){ |
klauss | 42:480335bdde12 | 36 | // show files |
klauss | 42:480335bdde12 | 37 | if (type == 's' ){ |
klauss | 56:c64bcbaa621a | 38 | pc.printf("Header IP " ); |
klauss | 42:480335bdde12 | 39 | if( from_eth ){ |
klauss | 56:c64bcbaa621a | 40 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Header IP " ); |
klauss | 78:1353744f01e1 | 41 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 42 | |
klauss | 45:c80574f24dc3 | 43 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 44 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 45 | } |
klauss | 42:480335bdde12 | 46 | } |
klauss | 81:3656f00ab3db | 47 | |
klauss | 19:ab2088e0dec6 | 48 | cat("/qspi/myip.txt"); |
klauss | 42:480335bdde12 | 49 | |
klauss | 56:c64bcbaa621a | 50 | pc.printf("Header ext "); |
klauss | 42:480335bdde12 | 51 | if( from_eth ){ |
klauss | 56:c64bcbaa621a | 52 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Header ext " ); |
klauss | 78:1353744f01e1 | 53 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 54 | |
klauss | 45:c80574f24dc3 | 55 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 56 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 57 | } |
klauss | 42:480335bdde12 | 58 | } |
klauss | 81:3656f00ab3db | 59 | |
klauss | 28:94aec56c6329 | 60 | cat("/qspi/myext.txt"); |
klauss | 42:480335bdde12 | 61 | |
klauss | 56:c64bcbaa621a | 62 | pc.printf("Header port "); |
klauss | 42:480335bdde12 | 63 | if( from_eth ){ |
klauss | 56:c64bcbaa621a | 64 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Header port " ); |
klauss | 78:1353744f01e1 | 65 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 66 | |
klauss | 45:c80574f24dc3 | 67 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 68 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 69 | } |
klauss | 42:480335bdde12 | 70 | } |
klauss | 81:3656f00ab3db | 71 | |
klauss | 28:94aec56c6329 | 72 | cat("/qspi/mysipport.txt"); |
klauss | 28:94aec56c6329 | 73 | |
klauss | 56:c64bcbaa621a | 74 | pc.printf("Server IP "); |
klauss | 42:480335bdde12 | 75 | if( from_eth ){ |
klauss | 56:c64bcbaa621a | 76 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Server IP " ); |
klauss | 78:1353744f01e1 | 77 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 78 | |
klauss | 45:c80574f24dc3 | 79 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 80 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 81 | } |
klauss | 42:480335bdde12 | 82 | } |
klauss | 81:3656f00ab3db | 83 | |
klauss | 28:94aec56c6329 | 84 | cat("/qspi/serverip.txt"); |
klauss | 42:480335bdde12 | 85 | |
klauss | 56:c64bcbaa621a | 86 | pc.printf("Server ext "); |
klauss | 42:480335bdde12 | 87 | if( from_eth ){ |
klauss | 56:c64bcbaa621a | 88 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Server ext " ); |
klauss | 78:1353744f01e1 | 89 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 90 | |
klauss | 45:c80574f24dc3 | 91 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 92 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 93 | } |
klauss | 42:480335bdde12 | 94 | } |
klauss | 81:3656f00ab3db | 95 | |
klauss | 28:94aec56c6329 | 96 | cat("/qspi/peerext.txt"); |
klauss | 42:480335bdde12 | 97 | |
klauss | 56:c64bcbaa621a | 98 | pc.printf("Server port "); |
klauss | 42:480335bdde12 | 99 | if( from_eth ){ |
klauss | 56:c64bcbaa621a | 100 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Server port " ); |
klauss | 78:1353744f01e1 | 101 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 102 | |
klauss | 45:c80574f24dc3 | 103 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 104 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 105 | } |
klauss | 42:480335bdde12 | 106 | } |
klauss | 28:94aec56c6329 | 107 | cat("/qspi/serverport.txt"); |
klauss | 28:94aec56c6329 | 108 | |
klauss | 56:c64bcbaa621a | 109 | pc.printf("Mascara de rede "); |
klauss | 42:480335bdde12 | 110 | if( from_eth ){ |
klauss | 56:c64bcbaa621a | 111 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Mascara de rede " ); |
klauss | 78:1353744f01e1 | 112 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 113 | |
klauss | 45:c80574f24dc3 | 114 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 115 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 116 | } |
klauss | 42:480335bdde12 | 117 | } |
klauss | 19:ab2088e0dec6 | 118 | cat("/qspi/mymask.txt"); |
klauss | 42:480335bdde12 | 119 | |
klauss | 56:c64bcbaa621a | 120 | pc.printf("Gateway IP "); |
klauss | 42:480335bdde12 | 121 | if( from_eth ){ |
klauss | 56:c64bcbaa621a | 122 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Gateway IP " ); |
klauss | 78:1353744f01e1 | 123 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 124 | |
klauss | 45:c80574f24dc3 | 125 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 126 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 127 | } |
klauss | 42:480335bdde12 | 128 | } |
klauss | 77:e8c0253b57bc | 129 | cat("/qspi/mygateway.txt"); |
klauss | 43:455522f98de5 | 130 | |
klauss | 56:c64bcbaa621a | 131 | pc.printf("UDP Port "); |
klauss | 45:c80574f24dc3 | 132 | if( from_eth ){ |
klauss | 56:c64bcbaa621a | 133 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "UDP Port " ); |
klauss | 78:1353744f01e1 | 134 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 135 | |
klauss | 45:c80574f24dc3 | 136 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 137 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 138 | } |
klauss | 45:c80574f24dc3 | 139 | } |
klauss | 81:3656f00ab3db | 140 | |
klauss | 45:c80574f24dc3 | 141 | cat("/qspi/udpport.txt"); |
klauss | 45:c80574f24dc3 | 142 | |
klauss | 56:c64bcbaa621a | 143 | pc.printf("TCP Port "); |
klauss | 45:c80574f24dc3 | 144 | if( from_eth ){ |
klauss | 56:c64bcbaa621a | 145 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "TCP Port " ); |
klauss | 78:1353744f01e1 | 146 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 147 | |
klauss | 45:c80574f24dc3 | 148 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 149 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 150 | } |
klauss | 45:c80574f24dc3 | 151 | } |
klauss | 81:3656f00ab3db | 152 | |
klauss | 45:c80574f24dc3 | 153 | cat("/qspi/tcpport.txt"); |
klauss | 45:c80574f24dc3 | 154 | |
klauss | 56:c64bcbaa621a | 155 | pc.printf("Telemetry Server IP "); |
klauss | 56:c64bcbaa621a | 156 | if( from_eth ){ |
klauss | 56:c64bcbaa621a | 157 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Telemetry Server IP " ); |
klauss | 78:1353744f01e1 | 158 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 56:c64bcbaa621a | 159 | |
klauss | 56:c64bcbaa621a | 160 | else if( udp_request ){ |
klauss | 56:c64bcbaa621a | 161 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 56:c64bcbaa621a | 162 | } |
klauss | 56:c64bcbaa621a | 163 | } |
klauss | 81:3656f00ab3db | 164 | |
klauss | 56:c64bcbaa621a | 165 | cat("/qspi/telemetry_ip.txt"); |
klauss | 56:c64bcbaa621a | 166 | |
klauss | 56:c64bcbaa621a | 167 | pc.printf("Telemetry Server Port "); |
klauss | 56:c64bcbaa621a | 168 | if( from_eth ){ |
klauss | 56:c64bcbaa621a | 169 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Telemetry Server Port " ); |
klauss | 78:1353744f01e1 | 170 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 56:c64bcbaa621a | 171 | |
klauss | 56:c64bcbaa621a | 172 | else if( udp_request ){ |
klauss | 56:c64bcbaa621a | 173 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 56:c64bcbaa621a | 174 | } |
klauss | 56:c64bcbaa621a | 175 | } |
klauss | 81:3656f00ab3db | 176 | |
klauss | 56:c64bcbaa621a | 177 | cat("/qspi/telemetry_port.txt"); |
klauss | 56:c64bcbaa621a | 178 | |
klauss | 81:3656f00ab3db | 179 | pc.printf("Max Ext "); |
klauss | 81:3656f00ab3db | 180 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 181 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Max Ext " ); |
klauss | 81:3656f00ab3db | 182 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 81:3656f00ab3db | 183 | |
klauss | 81:3656f00ab3db | 184 | else if( udp_request ){ |
klauss | 81:3656f00ab3db | 185 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 81:3656f00ab3db | 186 | } |
klauss | 81:3656f00ab3db | 187 | } |
klauss | 81:3656f00ab3db | 188 | |
klauss | 81:3656f00ab3db | 189 | cat("/qspi/maxext.txt"); |
klauss | 81:3656f00ab3db | 190 | |
klauss | 81:3656f00ab3db | 191 | pc.printf("Min Ext "); |
klauss | 81:3656f00ab3db | 192 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 193 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Min Ext " ); |
klauss | 81:3656f00ab3db | 194 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 81:3656f00ab3db | 195 | |
klauss | 81:3656f00ab3db | 196 | else if( udp_request ){ |
klauss | 81:3656f00ab3db | 197 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 81:3656f00ab3db | 198 | } |
klauss | 81:3656f00ab3db | 199 | } |
klauss | 81:3656f00ab3db | 200 | |
klauss | 81:3656f00ab3db | 201 | cat("/qspi/minext.txt"); |
klauss | 81:3656f00ab3db | 202 | |
klauss | 81:3656f00ab3db | 203 | |
klauss | 81:3656f00ab3db | 204 | //*------------ formatando a saida ----------------*// |
klauss | 58:af7e8788f106 | 205 | strcpy( last_cmd, tmp_cmd ); |
klauss | 43:455522f98de5 | 206 | bufptr = 0; |
klauss | 67:cdedc64d9921 | 207 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 81:3656f00ab3db | 208 | |
klauss | 62:07e5bdc9f8f7 | 209 | if( tcp_session ) tcp_client.send_all( "\n\r> " , strlen( "\n\r> " ) ); |
klauss | 48:195c97f12e8e | 210 | |
klauss | 48:195c97f12e8e | 211 | else if( udp_request ){ |
klauss | 62:07e5bdc9f8f7 | 212 | udp_server.sendTo( udp_client, "\n\r> ", strlen( "\n\r> " ) ); |
klauss | 48:195c97f12e8e | 213 | } |
klauss | 19:ab2088e0dec6 | 214 | } |
klauss | 19:ab2088e0dec6 | 215 | |
klauss | 56:c64bcbaa621a | 216 | if (type == 'c' ){ |
klauss | 56:c64bcbaa621a | 217 | // close all files |
klauss | 28:94aec56c6329 | 218 | fclose( fip ); |
klauss | 28:94aec56c6329 | 219 | fclose( fmask ); |
klauss | 28:94aec56c6329 | 220 | fclose( fgate ); |
klauss | 28:94aec56c6329 | 221 | fclose( fport ); |
klauss | 28:94aec56c6329 | 222 | fclose( fsip ); |
klauss | 28:94aec56c6329 | 223 | fclose( fsport ); |
klauss | 28:94aec56c6329 | 224 | fclose( fext ); |
klauss | 28:94aec56c6329 | 225 | fclose( fserext ); |
klauss | 45:c80574f24dc3 | 226 | fclose( fudpport ); |
klauss | 45:c80574f24dc3 | 227 | fclose( ftcpport ); |
klauss | 81:3656f00ab3db | 228 | fclose( fmax ); |
klauss | 81:3656f00ab3db | 229 | fclose( fmin ); |
klauss | 19:ab2088e0dec6 | 230 | } |
klauss | 19:ab2088e0dec6 | 231 | |
klauss | 56:c64bcbaa621a | 232 | if (type == 'i' ){ |
klauss | 56:c64bcbaa621a | 233 | // Check if files exist, if not create the files |
klauss | 81:3656f00ab3db | 234 | //fixme criar um bool pra cada file |
klauss | 33:735fd60e96d8 | 235 | bool exists = true; |
klauss | 81:3656f00ab3db | 236 | |
klauss | 19:ab2088e0dec6 | 237 | fip = fopen("/qspi/myip.txt", "r"); |
klauss | 56:c64bcbaa621a | 238 | if( fip == NULL){ |
klauss | 56:c64bcbaa621a | 239 | set_ip( __MY_IP__ ); |
klauss | 33:735fd60e96d8 | 240 | exists = false; |
klauss | 19:ab2088e0dec6 | 241 | } |
klauss | 28:94aec56c6329 | 242 | |
klauss | 28:94aec56c6329 | 243 | fserext = fopen("/qspi/myext.txt", "r"); |
klauss | 56:c64bcbaa621a | 244 | if( fserext == NULL ){ |
klauss | 56:c64bcbaa621a | 245 | set_header_ext( __MY_EXT__ ); |
klauss | 56:c64bcbaa621a | 246 | exists = false; |
klauss | 28:94aec56c6329 | 247 | } |
klauss | 56:c64bcbaa621a | 248 | |
klauss | 28:94aec56c6329 | 249 | fport = fopen("/qspi/mysipport.txt", "r"); |
klauss | 28:94aec56c6329 | 250 | if (fport == NULL){ |
klauss | 56:c64bcbaa621a | 251 | set_header_sip_port( __MY_PORT__ ); |
klauss | 33:735fd60e96d8 | 252 | exists = false; |
klauss | 28:94aec56c6329 | 253 | } |
klauss | 28:94aec56c6329 | 254 | fsip = fopen("/qspi/serverip.txt", "r"); |
klauss | 28:94aec56c6329 | 255 | if (fsip == NULL){ |
klauss | 56:c64bcbaa621a | 256 | set_server_ip( __SERVER_IP__ ); |
klauss | 33:735fd60e96d8 | 257 | exists = false; |
klauss | 28:94aec56c6329 | 258 | } |
klauss | 28:94aec56c6329 | 259 | |
klauss | 28:94aec56c6329 | 260 | fext = fopen("/qspi/peerext.txt", "r"); |
klauss | 28:94aec56c6329 | 261 | if ( fext == NULL ){ |
klauss | 56:c64bcbaa621a | 262 | set_server_ext( __PEER_EXT__ ); |
klauss | 33:735fd60e96d8 | 263 | exists = false; |
klauss | 28:94aec56c6329 | 264 | } |
klauss | 28:94aec56c6329 | 265 | fsport = fopen("/qspi/serverport.txt", "r"); |
klauss | 28:94aec56c6329 | 266 | if (fsport == NULL){ |
klauss | 56:c64bcbaa621a | 267 | set_server_port( __SERVER_PORT__ ); |
klauss | 33:735fd60e96d8 | 268 | exists = false; |
klauss | 28:94aec56c6329 | 269 | } |
klauss | 28:94aec56c6329 | 270 | |
klauss | 19:ab2088e0dec6 | 271 | fmask = fopen("/qspi/mymask.txt", "r"); |
klauss | 19:ab2088e0dec6 | 272 | if (fmask == NULL){ |
klauss | 56:c64bcbaa621a | 273 | set_mask( __MY_MSK__ ); |
klauss | 33:735fd60e96d8 | 274 | exists = false; |
klauss | 19:ab2088e0dec6 | 275 | } |
klauss | 19:ab2088e0dec6 | 276 | fgate = fopen("/qspi/mygateway.txt", "r"); |
klauss | 19:ab2088e0dec6 | 277 | if (fgate == NULL){ |
klauss | 56:c64bcbaa621a | 278 | set_gateway( __MY_GTW__ ); |
klauss | 45:c80574f24dc3 | 279 | exists = false; |
klauss | 45:c80574f24dc3 | 280 | } |
klauss | 45:c80574f24dc3 | 281 | fudpport = fopen("/qspi/udpport.txt", "r" ); |
klauss | 45:c80574f24dc3 | 282 | if( fudpport == NULL ){ |
klauss | 56:c64bcbaa621a | 283 | set_udp_port_listener( UDP_PORT_LISTENER ); |
klauss | 45:c80574f24dc3 | 284 | exists = false; |
klauss | 45:c80574f24dc3 | 285 | } |
klauss | 45:c80574f24dc3 | 286 | ftcpport = fopen("/qspi/tcpport.txt", "r" ); |
klauss | 45:c80574f24dc3 | 287 | if( ftcpport == NULL ){ |
klauss | 56:c64bcbaa621a | 288 | set_tcp_port_listener( TCP_PORT_LISTENER ); |
klauss | 33:735fd60e96d8 | 289 | exists = false; |
klauss | 19:ab2088e0dec6 | 290 | } |
klauss | 56:c64bcbaa621a | 291 | |
klauss | 56:c64bcbaa621a | 292 | ftip = fopen("/qspi/telemetry_ip.txt", "r" ); |
klauss | 56:c64bcbaa621a | 293 | if( ftip == NULL ){ |
klauss | 56:c64bcbaa621a | 294 | set_telemetry_ip( __TELEMETRY_SERVER_IP__ ); |
klauss | 56:c64bcbaa621a | 295 | exists = false; |
klauss | 56:c64bcbaa621a | 296 | } |
klauss | 56:c64bcbaa621a | 297 | |
klauss | 56:c64bcbaa621a | 298 | ftport = fopen("/qspi/telemetry_port.txt", "r" ); |
klauss | 56:c64bcbaa621a | 299 | if( ftport == NULL ){ |
klauss | 56:c64bcbaa621a | 300 | set_telemetry_port( __TELEMETRY_SERVER_PORT__ ); |
klauss | 56:c64bcbaa621a | 301 | exists = false; |
klauss | 56:c64bcbaa621a | 302 | } |
klauss | 56:c64bcbaa621a | 303 | |
klauss | 81:3656f00ab3db | 304 | fmax = fopen("/qspi/maxext.txt", "r" ); |
klauss | 81:3656f00ab3db | 305 | if( fmax == NULL ){ |
klauss | 81:3656f00ab3db | 306 | set_max_ext( MAX_EXT ); |
klauss | 81:3656f00ab3db | 307 | exists = false; |
klauss | 81:3656f00ab3db | 308 | } |
klauss | 81:3656f00ab3db | 309 | |
klauss | 81:3656f00ab3db | 310 | fmin = fopen("/qspi/minext.txt", "r" ); |
klauss | 81:3656f00ab3db | 311 | if( fmin == NULL ){ |
klauss | 81:3656f00ab3db | 312 | set_min_ext( MIN_EXT ); |
klauss | 81:3656f00ab3db | 313 | exists = false; |
klauss | 81:3656f00ab3db | 314 | } |
klauss | 81:3656f00ab3db | 315 | |
klauss | 44:cc4996469404 | 316 | if( !exists ){ |
klauss | 44:cc4996469404 | 317 | pc.printf("\n\rDefault configurations set!\n\r"); |
klauss | 44:cc4996469404 | 318 | if( from_eth ){ |
klauss | 44:cc4996469404 | 319 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Default configurations set!\n\r"); |
klauss | 44:cc4996469404 | 320 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 44:cc4996469404 | 321 | if( tcp_session ){ |
klauss | 45:c80574f24dc3 | 322 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 67:cdedc64d9921 | 323 | //debug_buf[ 0 ] = 0; |
klauss | 67:cdedc64d9921 | 324 | //bufptr = 0; |
klauss | 44:cc4996469404 | 325 | bufptr = 0; |
klauss | 67:cdedc64d9921 | 326 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 44:cc4996469404 | 327 | } |
klauss | 44:cc4996469404 | 328 | } |
klauss | 44:cc4996469404 | 329 | } |
klauss | 19:ab2088e0dec6 | 330 | } |
klauss | 19:ab2088e0dec6 | 331 | |
klauss | 56:c64bcbaa621a | 332 | if (type == 'r' ){ |
klauss | 56:c64bcbaa621a | 333 | // Just open for read |
klauss | 19:ab2088e0dec6 | 334 | fip = fopen("/qspi/myip.txt", "r"); |
klauss | 19:ab2088e0dec6 | 335 | fmask = fopen("/qspi/mymask.txt", "r"); |
klauss | 19:ab2088e0dec6 | 336 | fgate = fopen("/qspi/mygateway.txt", "r"); |
klauss | 19:ab2088e0dec6 | 337 | fport = fopen("/qspi/mysipport.txt", "r"); |
klauss | 19:ab2088e0dec6 | 338 | fsip = fopen("/qspi/serverip.txt", "r"); |
klauss | 19:ab2088e0dec6 | 339 | fsport = fopen("/qspi/serverport.txt", "r"); |
klauss | 28:94aec56c6329 | 340 | fext = fopen( "/qspi/myext.txt", "r" ); |
klauss | 28:94aec56c6329 | 341 | fserext = fopen( "/qspi/peerext.txt", "r" ); |
klauss | 45:c80574f24dc3 | 342 | fudpport = fopen( "/qspi/udpport.txt", "r" ); |
klauss | 45:c80574f24dc3 | 343 | ftcpport = fopen( "/qspi/tcpport.txt", "r" ); |
klauss | 56:c64bcbaa621a | 344 | ftip = fopen("/qspi/telemetry_ip.txt", "r" ); |
klauss | 56:c64bcbaa621a | 345 | ftport = fopen("/qspi/telemetry_port.txt", "r" ); |
klauss | 81:3656f00ab3db | 346 | fmax = fopen("/qspi/maxext.txt", "r" ); |
klauss | 81:3656f00ab3db | 347 | fmin = fopen("/qspi/minext.txt", "r" ); |
klauss | 19:ab2088e0dec6 | 348 | } |
klauss | 19:ab2088e0dec6 | 349 | |
klauss | 55:2f5e7374af9d | 350 | if( type == 'w'){ |
klauss | 55:2f5e7374af9d | 351 | // Create and write the default configs |
klauss | 56:c64bcbaa621a | 352 | |
klauss | 56:c64bcbaa621a | 353 | set_ip( __MY_IP__ ); |
klauss | 19:ab2088e0dec6 | 354 | |
klauss | 55:2f5e7374af9d | 355 | set_header_sip_port( __MY_PORT__ ); |
klauss | 56:c64bcbaa621a | 356 | |
klauss | 55:2f5e7374af9d | 357 | set_header_ext( __MY_EXT__ ); |
klauss | 28:94aec56c6329 | 358 | |
klauss | 55:2f5e7374af9d | 359 | set_server_ip( __SERVER_IP__ ); |
klauss | 56:c64bcbaa621a | 360 | |
klauss | 55:2f5e7374af9d | 361 | set_server_ext( __PEER_EXT__ ); |
klauss | 56:c64bcbaa621a | 362 | |
klauss | 55:2f5e7374af9d | 363 | set_server_port( __SERVER_PORT__ ); |
klauss | 56:c64bcbaa621a | 364 | |
klauss | 56:c64bcbaa621a | 365 | set_mask( __MY_MSK__ ); |
klauss | 28:94aec56c6329 | 366 | |
klauss | 55:2f5e7374af9d | 367 | set_gateway( __MY_GTW__ ); |
klauss | 56:c64bcbaa621a | 368 | |
klauss | 56:c64bcbaa621a | 369 | set_udp_port_listener( UDP_PORT_LISTENER ); |
klauss | 45:c80574f24dc3 | 370 | |
klauss | 56:c64bcbaa621a | 371 | set_tcp_port_listener( TCP_PORT_LISTENER ); |
klauss | 56:c64bcbaa621a | 372 | |
klauss | 56:c64bcbaa621a | 373 | set_telemetry_ip( __TELEMETRY_SERVER_IP__ ); |
klauss | 56:c64bcbaa621a | 374 | |
klauss | 56:c64bcbaa621a | 375 | set_telemetry_port( __TELEMETRY_SERVER_PORT__ ); |
klauss | 19:ab2088e0dec6 | 376 | |
klauss | 81:3656f00ab3db | 377 | set_max_ext( MAX_EXT ); |
klauss | 81:3656f00ab3db | 378 | |
klauss | 81:3656f00ab3db | 379 | set_min_ext( MIN_EXT ); |
klauss | 81:3656f00ab3db | 380 | |
klauss | 58:af7e8788f106 | 381 | strcpy( last_cmd, tmp_cmd ); |
klauss | 58:af7e8788f106 | 382 | |
klauss | 44:cc4996469404 | 383 | pc.printf("\n\rDefault configurations set!\n\r"); |
klauss | 44:cc4996469404 | 384 | if( from_eth ){ |
klauss | 44:cc4996469404 | 385 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rDefault configurations set!\n\r"); |
klauss | 44:cc4996469404 | 386 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 44:cc4996469404 | 387 | if( tcp_session ){ |
klauss | 45:c80574f24dc3 | 388 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 389 | }else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 390 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 44:cc4996469404 | 391 | } |
klauss | 67:cdedc64d9921 | 392 | //debug_buf[ 0 ] = 0; |
klauss | 67:cdedc64d9921 | 393 | //bufptr = 0; |
klauss | 45:c80574f24dc3 | 394 | bufptr = 0; |
klauss | 67:cdedc64d9921 | 395 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 44:cc4996469404 | 396 | } |
klauss | 19:ab2088e0dec6 | 397 | } |
klauss | 50:d9b6577a70f5 | 398 | |
klauss | 56:c64bcbaa621a | 399 | if (type == 'e'){ |
klauss | 56:c64bcbaa621a | 400 | //Erase configs |
klauss | 50:d9b6577a70f5 | 401 | fip = fopen("/qspi/myip.txt", "w"); |
klauss | 50:d9b6577a70f5 | 402 | fmask = fopen("/qspi/mymask.txt", "w"); |
klauss | 50:d9b6577a70f5 | 403 | fgate = fopen("/qspi/mygateway.txt", "w"); |
klauss | 50:d9b6577a70f5 | 404 | fport = fopen("/qspi/mysipport.txt", "w"); |
klauss | 50:d9b6577a70f5 | 405 | fsip = fopen("/qspi/serverip.txt", "w"); |
klauss | 50:d9b6577a70f5 | 406 | fsport = fopen("/qspi/serverport.txt", "w"); |
klauss | 50:d9b6577a70f5 | 407 | fext = fopen( "/qspi/myext.txt", "w" ); |
klauss | 50:d9b6577a70f5 | 408 | fserext = fopen( "/qspi/peerext.txt", "w" ); |
klauss | 50:d9b6577a70f5 | 409 | fudpport = fopen( "/qspi/udpport.txt", "w" ); |
klauss | 50:d9b6577a70f5 | 410 | ftcpport = fopen( "/qspi/tcpport.txt", "w" ); |
klauss | 56:c64bcbaa621a | 411 | ftip = fopen("/qspi/telemetry_ip.txt", "w" ); |
klauss | 56:c64bcbaa621a | 412 | ftport = fopen("/qspi/telemetry_port.txt", "w" ); |
klauss | 81:3656f00ab3db | 413 | fmax = fopen("/qspi/maxext.txt", "w" ); |
klauss | 81:3656f00ab3db | 414 | fmin = fopen("/qspi/minext.txt", "w" ); |
klauss | 50:d9b6577a70f5 | 415 | |
klauss | 56:c64bcbaa621a | 416 | //FIXME verificar se deveria colocar tudo para %s |
klauss | 56:c64bcbaa621a | 417 | fprintf( fip, "%s\n\r", "" ); |
klauss | 60:b4ec6beb3be3 | 418 | fprintf( fport, "%i\n\r", 0 ); |
klauss | 60:b4ec6beb3be3 | 419 | fprintf( fext, "%i\n\r", 0 ); |
klauss | 50:d9b6577a70f5 | 420 | |
klauss | 56:c64bcbaa621a | 421 | fprintf( fsip, "%s\n\r", "" ); |
klauss | 60:b4ec6beb3be3 | 422 | fprintf( fserext, "%i\n\r", 0 ); |
klauss | 60:b4ec6beb3be3 | 423 | fprintf( fsport, "%i\n\r", 0 ); |
klauss | 56:c64bcbaa621a | 424 | |
klauss | 56:c64bcbaa621a | 425 | fprintf( fmask, "%s\n\r","" ); |
klauss | 56:c64bcbaa621a | 426 | fprintf( fgate, "%s\n\r", "" ); |
klauss | 50:d9b6577a70f5 | 427 | |
klauss | 60:b4ec6beb3be3 | 428 | fprintf( fudpport, "%i\n\r", 0 ); |
klauss | 60:b4ec6beb3be3 | 429 | fprintf( ftcpport, "%i\n\r", 0 ); |
klauss | 50:d9b6577a70f5 | 430 | |
klauss | 56:c64bcbaa621a | 431 | fprintf( ftip, "%s\n\r","" ); |
klauss | 60:b4ec6beb3be3 | 432 | fprintf( ftport, "%i\n\r",0 ); |
klauss | 56:c64bcbaa621a | 433 | |
klauss | 81:3656f00ab3db | 434 | fprintf( fmax, "%i\n\r", 0 ); |
klauss | 81:3656f00ab3db | 435 | fprintf( fmin, "%i\n\r", 0 ); |
klauss | 81:3656f00ab3db | 436 | |
klauss | 50:d9b6577a70f5 | 437 | files('c'); |
klauss | 50:d9b6577a70f5 | 438 | |
klauss | 50:d9b6577a70f5 | 439 | pc.printf("\n\rErased configurations set!\n\r"); |
klauss | 50:d9b6577a70f5 | 440 | if( from_eth ){ |
klauss | 50:d9b6577a70f5 | 441 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rErased configurations set!\n\r"); |
klauss | 50:d9b6577a70f5 | 442 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 50:d9b6577a70f5 | 443 | if( tcp_session ){ |
klauss | 50:d9b6577a70f5 | 444 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 50:d9b6577a70f5 | 445 | }else if( udp_request ){ |
klauss | 50:d9b6577a70f5 | 446 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 50:d9b6577a70f5 | 447 | } |
klauss | 50:d9b6577a70f5 | 448 | bufptr = 0; |
klauss | 67:cdedc64d9921 | 449 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 50:d9b6577a70f5 | 450 | } |
klauss | 50:d9b6577a70f5 | 451 | } |
klauss | 19:ab2088e0dec6 | 452 | } |
klauss | 79:9bc12aa305a9 | 453 | |
klauss | 26:725cbbedadd5 | 454 | void init_fsystem(){ |
klauss | 26:725cbbedadd5 | 455 | // init file system and check if files exist |
klauss | 26:725cbbedadd5 | 456 | if (!qspifs.isformatted()) { |
klauss | 26:725cbbedadd5 | 457 | qspifs.format(); |
klauss | 44:cc4996469404 | 458 | pc.printf("\n\rFile system configured!!\n\r"); |
klauss | 26:725cbbedadd5 | 459 | } |
klauss | 26:725cbbedadd5 | 460 | files('i'); // check if the files are created |
klauss | 26:725cbbedadd5 | 461 | files('c'); |
klauss | 81:3656f00ab3db | 462 | send_msg("******* File System Ready *******"); |
klauss | 43:455522f98de5 | 463 | } |
klauss | 43:455522f98de5 | 464 | |
klauss | 78:1353744f01e1 | 465 | void init_prompt_eth(){ |
klauss | 45:c80574f24dc3 | 466 | tcp_server.bind( TCP_PORT_LISTENER ); |
klauss | 45:c80574f24dc3 | 467 | tcp_server.listen(); |
klauss | 89:0fe315117b00 | 468 | //tcp_server.set_blocking( false, 1 ); |
klauss | 89:0fe315117b00 | 469 | //udp_server.set_blocking( false, 2 ); |
klauss | 89:0fe315117b00 | 470 | tcp_server.set_blocking( false, 0 ); |
klauss | 89:0fe315117b00 | 471 | udp_server.set_blocking( false, 0 ); |
klauss | 78:1353744f01e1 | 472 | udp_server.bind( UDP_PORT_LISTENER ); |
klauss | 81:3656f00ab3db | 473 | pc.printf("******* Prompt eth Ready *******\n\r"); |
klauss | 19:ab2088e0dec6 | 474 | } |
klauss | 19:ab2088e0dec6 | 475 | |
klauss | 28:94aec56c6329 | 476 | // main prompt process |
klauss | 48:195c97f12e8e | 477 | char * prompt_process( char * msg_from_cb ){ |
klauss | 28:94aec56c6329 | 478 | //FIXME dar flush na serial |
klauss | 19:ab2088e0dec6 | 479 | volatile char b = 0; |
klauss | 19:ab2088e0dec6 | 480 | static uint8_t bufret = 0; |
klauss | 30:8dfb6d8de53d | 481 | static Timer flood_timeout; |
klauss | 60:b4ec6beb3be3 | 482 | static Timer flood_silence_timer; |
klauss | 60:b4ec6beb3be3 | 483 | static uint8_t id_msg = 0x10; |
klauss | 60:b4ec6beb3be3 | 484 | static int start_ext, end_ext, ext_count; |
klauss | 36:728498a78e1e | 485 | bool miss_match = true; |
klauss | 57:78f7191a8b69 | 486 | char eth_buffer[ __PROMPT_ETH_BUFFER_SIZE__ ]; |
klauss | 60:b4ec6beb3be3 | 487 | uint8_t write_buffer[ __CB_BUFFER_SIZE__ ]; |
klauss | 57:78f7191a8b69 | 488 | |
klauss | 45:c80574f24dc3 | 489 | if( flood_timeout.read() > 60 ){ |
klauss | 45:c80574f24dc3 | 490 | pflood = 0; |
klauss | 45:c80574f24dc3 | 491 | flood_timeout.stop(); |
klauss | 45:c80574f24dc3 | 492 | flood_timeout.reset(); |
klauss | 45:c80574f24dc3 | 493 | } |
klauss | 78:1353744f01e1 | 494 | |
klauss | 53:bb492a8f115a | 495 | if( tcp_timer.read() >= TCP_IDLE_MAX_TIME ){ |
klauss | 78:1353744f01e1 | 496 | bool close_tcp = true; |
klauss | 78:1353744f01e1 | 497 | //if( tcp_alive && ( tcp_timer.read() < TCP_ALIVE_IDLE_MAX_TIME ) ){ |
klauss | 78:1353744f01e1 | 498 | // close_tcp = false; |
klauss | 78:1353744f01e1 | 499 | //} |
klauss | 78:1353744f01e1 | 500 | if( close_tcp ){ |
klauss | 78:1353744f01e1 | 501 | tcp_alive = false; |
klauss | 78:1353744f01e1 | 502 | tcp_timer.stop(); |
klauss | 78:1353744f01e1 | 503 | tcp_timer.reset(); |
klauss | 78:1353744f01e1 | 504 | tcp_session = false; |
klauss | 78:1353744f01e1 | 505 | debug_buf = __debug_buf__; |
klauss | 78:1353744f01e1 | 506 | bufptr = last_bufptr; |
klauss | 78:1353744f01e1 | 507 | bufret = 0; |
klauss | 78:1353744f01e1 | 508 | from_eth = false; |
klauss | 78:1353744f01e1 | 509 | tcp_client.close(); |
klauss | 78:1353744f01e1 | 510 | return( NULL ); |
klauss | 78:1353744f01e1 | 511 | } |
klauss | 53:bb492a8f115a | 512 | } |
klauss | 48:195c97f12e8e | 513 | if( !tcp_server.accept( tcp_client ) ){ |
klauss | 48:195c97f12e8e | 514 | tcp_session = true; |
klauss | 53:bb492a8f115a | 515 | tcp_timer.start(); |
klauss | 48:195c97f12e8e | 516 | last_bufptr = bufptr; |
klauss | 53:bb492a8f115a | 517 | eth_buffer[ 0 ] = 0; |
klauss | 48:195c97f12e8e | 518 | bufret = 0; |
klauss | 48:195c97f12e8e | 519 | } |
klauss | 53:bb492a8f115a | 520 | if( tcp_session ){ |
klauss | 57:78f7191a8b69 | 521 | //if( !( (int)tcp_timer.read_ms() % 100 ) ){ |
klauss | 89:0fe315117b00 | 522 | //tcp_client.set_blocking( false, 1 ); |
klauss | 89:0fe315117b00 | 523 | tcp_client.set_blocking( false, 0 ); |
klauss | 53:bb492a8f115a | 524 | int n = tcp_client.receive( eth_buffer, sizeof( eth_buffer ) - 1 ); |
klauss | 53:bb492a8f115a | 525 | if( n > 0 ){ |
klauss | 48:195c97f12e8e | 526 | tcp_timer.reset(); |
klauss | 53:bb492a8f115a | 527 | |
klauss | 53:bb492a8f115a | 528 | if( ( n > 2 ) && ( eth_buffer[ n - 2 ] == '\r' ) ) eth_buffer[ n - 2 ] = 0; |
klauss | 53:bb492a8f115a | 529 | |
klauss | 53:bb492a8f115a | 530 | if( ( n > 1 ) && ( eth_buffer[ n - 1 ] == '\n' ) ) eth_buffer[ n - 1 ] = 0; |
klauss | 53:bb492a8f115a | 531 | |
klauss | 53:bb492a8f115a | 532 | if( ( n == 1 ) && eth_buffer[ 0 ] == 0x0A ) strcpy( eth_buffer, "\r" ); |
klauss | 53:bb492a8f115a | 533 | |
klauss | 53:bb492a8f115a | 534 | //if( eth_buffer[ 0 ] == '\r' || eth_buffer[ 1 ] == '\n' || eth_buffer[ 2 ] == 'r' || eth_buffer[ 2 ] == '\n' ) strcpy( eth_buffer, "\r" ); |
klauss | 62:07e5bdc9f8f7 | 535 | |
klauss | 53:bb492a8f115a | 536 | bufptr = strlen( eth_buffer ); |
klauss | 53:bb492a8f115a | 537 | debug_buf = eth_buffer; |
klauss | 53:bb492a8f115a | 538 | from_eth = true; |
klauss | 53:bb492a8f115a | 539 | bufret = 1; |
klauss | 53:bb492a8f115a | 540 | |
klauss | 53:bb492a8f115a | 541 | if( !( strcmp( eth_buffer, "quit" ) ) ){ |
klauss | 53:bb492a8f115a | 542 | tcp_timer.reset(); |
klauss | 53:bb492a8f115a | 543 | debug_buf = __debug_buf__; |
klauss | 53:bb492a8f115a | 544 | bufptr = last_bufptr; |
klauss | 53:bb492a8f115a | 545 | from_eth = false; |
klauss | 53:bb492a8f115a | 546 | tcp_session = false; |
klauss | 53:bb492a8f115a | 547 | tcp_client.close(); |
klauss | 53:bb492a8f115a | 548 | bufret = 0; |
klauss | 53:bb492a8f115a | 549 | return( NULL ); |
klauss | 82:f55d13babca0 | 550 | } |
klauss | 82:f55d13babca0 | 551 | /*else if( !( strcmp( eth_buffer, "alive" ) ) ){ |
klauss | 79:9bc12aa305a9 | 552 | char wake_msg[ 8 ]; |
klauss | 81:3656f00ab3db | 553 | external_wdt = EXTERN_WDT_IDLE; |
klauss | 81:3656f00ab3db | 554 | strcpy( wake_msg, "wakeup\n" ); |
klauss | 81:3656f00ab3db | 555 | while( !( tcp_client.send_all( wake_msg, strlen( wake_msg ) ) ) ); |
klauss | 81:3656f00ab3db | 556 | strcpy( eth_buffer, "0" ); |
klauss | 81:3656f00ab3db | 557 | bufret = 0; |
klauss | 53:bb492a8f115a | 558 | } |
klauss | 82:f55d13babca0 | 559 | */ |
klauss | 53:bb492a8f115a | 560 | }else{ |
klauss | 48:195c97f12e8e | 561 | debug_buf = __debug_buf__; |
klauss | 48:195c97f12e8e | 562 | bufptr = last_bufptr; |
klauss | 57:78f7191a8b69 | 563 | from_eth = false; |
klauss | 45:c80574f24dc3 | 564 | } |
klauss | 57:78f7191a8b69 | 565 | //} |
klauss | 53:bb492a8f115a | 566 | } |
klauss | 57:78f7191a8b69 | 567 | |
klauss | 53:bb492a8f115a | 568 | if( !from_eth ){ |
klauss | 57:78f7191a8b69 | 569 | if( pc.readable() ){ |
klauss | 53:bb492a8f115a | 570 | // imput do teclado |
klauss | 53:bb492a8f115a | 571 | b = pc.getc(); |
klauss | 53:bb492a8f115a | 572 | if( b == 0x0D ){ // enter |
klauss | 53:bb492a8f115a | 573 | bufret = 1; |
klauss | 53:bb492a8f115a | 574 | }else{ |
klauss | 53:bb492a8f115a | 575 | pc.putc( b ); |
klauss | 53:bb492a8f115a | 576 | if( b == 0x08 || b == 0x7F ){ // BS | DEL |
klauss | 53:bb492a8f115a | 577 | if( bufptr > 0 ) debug_buf[ --bufptr ] = 0; |
klauss | 53:bb492a8f115a | 578 | }else if( b == 0x09 ){ |
klauss | 53:bb492a8f115a | 579 | // ignore tab |
klauss | 53:bb492a8f115a | 580 | }else{ |
klauss | 53:bb492a8f115a | 581 | debug_buf[bufptr] = b; |
klauss | 53:bb492a8f115a | 582 | bufptr++; |
klauss | 42:480335bdde12 | 583 | } |
klauss | 31:bb5fb28a77df | 584 | } |
klauss | 53:bb492a8f115a | 585 | } |
klauss | 48:195c97f12e8e | 586 | } |
klauss | 53:bb492a8f115a | 587 | |
klauss | 48:195c97f12e8e | 588 | if( msg_from_cb ){ |
klauss | 48:195c97f12e8e | 589 | if( tcp_session ){ |
klauss | 48:195c97f12e8e | 590 | tcp_client.send_all( msg_from_cb, strlen( msg_from_cb ) ); |
klauss | 48:195c97f12e8e | 591 | }else if( udp_request ){ |
klauss | 48:195c97f12e8e | 592 | udp_server.sendTo( udp_client, msg_from_cb, strlen( msg_from_cb ) ); |
klauss | 48:195c97f12e8e | 593 | } |
klauss | 48:195c97f12e8e | 594 | pc.printf( "\n\r%s\n\r", msg_from_cb ); |
klauss | 45:c80574f24dc3 | 595 | } |
klauss | 60:b4ec6beb3be3 | 596 | |
klauss | 60:b4ec6beb3be3 | 597 | if( flood_silence ){ |
klauss | 60:b4ec6beb3be3 | 598 | if( flood_silence_timer.read_ms() > 250 ){ |
klauss | 60:b4ec6beb3be3 | 599 | char cmd[ 16 ] = "flood off"; |
klauss | 60:b4ec6beb3be3 | 600 | int str_end = strlen( cmd ); |
klauss | 60:b4ec6beb3be3 | 601 | cmd[ str_end ] = 0x0D; |
klauss | 60:b4ec6beb3be3 | 602 | cmd[ str_end + 1 ] = 0x00; |
klauss | 60:b4ec6beb3be3 | 603 | |
klauss | 60:b4ec6beb3be3 | 604 | int port = convert_ext_to_port( ext_count ); |
klauss | 74:81c47fff88a5 | 605 | send2callboxes( __build_cb_package__( ext_count, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 60:b4ec6beb3be3 | 606 | pc.printf("\r\nSilence sent to ext=%d port=%d", ext_count, port ); |
klauss | 60:b4ec6beb3be3 | 607 | |
klauss | 60:b4ec6beb3be3 | 608 | if( tcp_session ){ |
klauss | 60:b4ec6beb3be3 | 609 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\nSilence sent to ext=%d port=%d", ext_count, port ); |
klauss | 60:b4ec6beb3be3 | 610 | //eth_buffer[ strlen( eth_buffer ) - 1 ] = '\0'; |
klauss | 60:b4ec6beb3be3 | 611 | |
klauss | 60:b4ec6beb3be3 | 612 | tcp_client.send_all( eth_buffer, strlen( eth_buffer ) ); |
klauss | 60:b4ec6beb3be3 | 613 | }else if( udp_request ){ |
klauss | 60:b4ec6beb3be3 | 614 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\nSilence sent to ext=%d port=%d", ext_count, port ); |
klauss | 60:b4ec6beb3be3 | 615 | //eth_buffer[ strlen( eth_buffer ) - 1 ] = '\0'; |
klauss | 60:b4ec6beb3be3 | 616 | |
klauss | 60:b4ec6beb3be3 | 617 | udp_server.sendTo( udp_client, eth_buffer, strlen( eth_buffer ) ); |
klauss | 60:b4ec6beb3be3 | 618 | } |
klauss | 60:b4ec6beb3be3 | 619 | flood_silence_timer.reset(); |
klauss | 60:b4ec6beb3be3 | 620 | |
klauss | 60:b4ec6beb3be3 | 621 | if( ++ext_count > end_ext ){ |
klauss | 60:b4ec6beb3be3 | 622 | flood_silence = false; |
klauss | 60:b4ec6beb3be3 | 623 | flood_silence_timer.stop(); |
klauss | 60:b4ec6beb3be3 | 624 | flood_silence_timer.reset(); |
klauss | 60:b4ec6beb3be3 | 625 | |
klauss | 60:b4ec6beb3be3 | 626 | pc.printf("\r\n> " ); |
klauss | 60:b4ec6beb3be3 | 627 | if( tcp_session ){ |
klauss | 60:b4ec6beb3be3 | 628 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\n> " ); |
klauss | 60:b4ec6beb3be3 | 629 | tcp_client.send_all( eth_buffer, strlen( eth_buffer ) ); |
klauss | 60:b4ec6beb3be3 | 630 | }else if( udp_request ){ |
klauss | 60:b4ec6beb3be3 | 631 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\n> " ); |
klauss | 60:b4ec6beb3be3 | 632 | udp_server.sendTo( udp_client, eth_buffer, strlen( eth_buffer ) ); |
klauss | 60:b4ec6beb3be3 | 633 | } |
klauss | 60:b4ec6beb3be3 | 634 | } |
klauss | 60:b4ec6beb3be3 | 635 | } |
klauss | 60:b4ec6beb3be3 | 636 | } |
klauss | 65:0b653cfe95db | 637 | |
klauss | 65:0b653cfe95db | 638 | if( delayed_flood ){ |
klauss | 65:0b653cfe95db | 639 | tflood.start(); |
klauss | 65:0b653cfe95db | 640 | tflood.reset(); |
klauss | 65:0b653cfe95db | 641 | floodcount =0; |
klauss | 65:0b653cfe95db | 642 | pflood = 1; |
klauss | 65:0b653cfe95db | 643 | flood_timeout.start(); |
klauss | 65:0b653cfe95db | 644 | delayed_flood = false; |
klauss | 65:0b653cfe95db | 645 | pc.printf("\n\rFlood ON\n\r"); |
klauss | 65:0b653cfe95db | 646 | if( from_eth ){ |
klauss | 65:0b653cfe95db | 647 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r" ); |
klauss | 65:0b653cfe95db | 648 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 65:0b653cfe95db | 649 | } |
klauss | 65:0b653cfe95db | 650 | } |
klauss | 45:c80574f24dc3 | 651 | |
klauss | 45:c80574f24dc3 | 652 | // Prompt commands here |
klauss | 58:af7e8788f106 | 653 | if ( bufret == 1 ) { |
klauss | 45:c80574f24dc3 | 654 | static unsigned int promptcb_last_ext = 0; |
klauss | 45:c80574f24dc3 | 655 | static unsigned int promptcb_last_port = 0; |
klauss | 55:2f5e7374af9d | 656 | static char promptcb_last_cmd[ 300 ]; |
klauss | 60:b4ec6beb3be3 | 657 | |
klauss | 58:af7e8788f106 | 658 | strcpy( tmp_cmd, debug_buf ); |
klauss | 59:e1e300880d2d | 659 | if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "." ) ){ |
klauss | 45:c80574f24dc3 | 660 | miss_match = false; |
klauss | 58:af7e8788f106 | 661 | strcpy( debug_buf, last_cmd ); |
klauss | 58:af7e8788f106 | 662 | strcpy( tmp_cmd, debug_buf ); |
klauss | 59:e1e300880d2d | 663 | }else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "+" ) ){ |
klauss | 59:e1e300880d2d | 664 | miss_match = false; |
klauss | 59:e1e300880d2d | 665 | strcpy( debug_buf, "flood on" ); |
klauss | 59:e1e300880d2d | 666 | strcpy( tmp_cmd, debug_buf ); |
klauss | 59:e1e300880d2d | 667 | }else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "-" ) ){ |
klauss | 59:e1e300880d2d | 668 | miss_match = false; |
klauss | 59:e1e300880d2d | 669 | strcpy( debug_buf, "flood off" ); |
klauss | 59:e1e300880d2d | 670 | strcpy( tmp_cmd, debug_buf ); |
klauss | 59:e1e300880d2d | 671 | }else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "++ ", 3 ) ){ |
klauss | 59:e1e300880d2d | 672 | miss_match = false; |
klauss | 65:0b653cfe95db | 673 | delayed_flood = true; |
klauss | 59:e1e300880d2d | 674 | int ext = atoi( debug_buf + 3 ); |
klauss | 59:e1e300880d2d | 675 | sprintf( debug_buf, "pcb %i flood on", ext ); |
klauss | 59:e1e300880d2d | 676 | }else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "-- ", 3 ) ){ |
klauss | 59:e1e300880d2d | 677 | miss_match = false; |
klauss | 59:e1e300880d2d | 678 | int ext = atoi( debug_buf + 3 ); |
klauss | 59:e1e300880d2d | 679 | pc.printf("\n\rFlood OFF\n\r"); |
klauss | 59:e1e300880d2d | 680 | if( from_eth ){ |
klauss | 59:e1e300880d2d | 681 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood OFF\n\r" ); |
klauss | 59:e1e300880d2d | 682 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 59:e1e300880d2d | 683 | } |
klauss | 59:e1e300880d2d | 684 | pflood = 0; |
klauss | 59:e1e300880d2d | 685 | tflood.stop(); |
klauss | 59:e1e300880d2d | 686 | flood_timeout.reset(); |
klauss | 60:b4ec6beb3be3 | 687 | sprintf( debug_buf, "pcb %i flood off", ext ); |
klauss | 45:c80574f24dc3 | 688 | } |
klauss | 45:c80574f24dc3 | 689 | |
klauss | 48:195c97f12e8e | 690 | //tratamento dos enters |
klauss | 45:c80574f24dc3 | 691 | if( !bufptr ){ |
klauss | 45:c80574f24dc3 | 692 | miss_match = false; |
klauss | 48:195c97f12e8e | 693 | }else if( bufptr == 1 ) { |
klauss | 48:195c97f12e8e | 694 | if( debug_buf[ 0 ] == 0x0D || debug_buf[ 0 ] == 0x0D ) miss_match = false; |
klauss | 48:195c97f12e8e | 695 | } |
klauss | 48:195c97f12e8e | 696 | |
klauss | 45:c80574f24dc3 | 697 | if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ifconfig" ) ){ |
klauss | 45:c80574f24dc3 | 698 | miss_match = false; |
klauss | 45:c80574f24dc3 | 699 | pc.printf("\n\r"); |
klauss | 45:c80574f24dc3 | 700 | files('s'); |
klauss | 45:c80574f24dc3 | 701 | } |
klauss | 62:07e5bdc9f8f7 | 702 | |
klauss | 63:0d95da692bb4 | 703 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "rx" ) ){ |
klauss | 62:07e5bdc9f8f7 | 704 | miss_match = false; |
klauss | 62:07e5bdc9f8f7 | 705 | rx = true; |
klauss | 62:07e5bdc9f8f7 | 706 | } |
klauss | 62:07e5bdc9f8f7 | 707 | |
klauss | 63:0d95da692bb4 | 708 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "tx" ) ){ |
klauss | 63:0d95da692bb4 | 709 | miss_match = false; |
klauss | 63:0d95da692bb4 | 710 | tx = true; |
klauss | 63:0d95da692bb4 | 711 | } |
klauss | 63:0d95da692bb4 | 712 | |
klauss | 63:0d95da692bb4 | 713 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "stats" ) ){ |
klauss | 63:0d95da692bb4 | 714 | miss_match = false; |
klauss | 63:0d95da692bb4 | 715 | stats = true; |
klauss | 63:0d95da692bb4 | 716 | } |
klauss | 63:0d95da692bb4 | 717 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_stats" ) ){ |
klauss | 63:0d95da692bb4 | 718 | miss_match = false; |
klauss | 63:0d95da692bb4 | 719 | r_stats = true; |
klauss | 63:0d95da692bb4 | 720 | } |
klauss | 63:0d95da692bb4 | 721 | |
klauss | 59:e1e300880d2d | 722 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "format" ) ){ |
klauss | 45:c80574f24dc3 | 723 | miss_match = false; |
klauss | 50:d9b6577a70f5 | 724 | pc.printf("\n\rFormatando o sistema de arquivos... espere o sistema reiniciar\n\r"); |
klauss | 62:07e5bdc9f8f7 | 725 | |
klauss | 45:c80574f24dc3 | 726 | if( from_eth ){ |
klauss | 62:07e5bdc9f8f7 | 727 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Not Allowed\n\r"); |
klauss | 62:07e5bdc9f8f7 | 728 | }else{ |
klauss | 62:07e5bdc9f8f7 | 729 | files('e'); |
klauss | 62:07e5bdc9f8f7 | 730 | files('w'); |
klauss | 62:07e5bdc9f8f7 | 731 | __disable_irq(); |
klauss | 62:07e5bdc9f8f7 | 732 | NVIC_SystemReset(); |
klauss | 42:480335bdde12 | 733 | } |
klauss | 45:c80574f24dc3 | 734 | } |
klauss | 45:c80574f24dc3 | 735 | |
klauss | 59:e1e300880d2d | 736 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ipset ", 6 )) { |
klauss | 45:c80574f24dc3 | 737 | miss_match = false; |
klauss | 54:448d57291be6 | 738 | set_ip( debug_buf + 6 ); |
klauss | 45:c80574f24dc3 | 739 | files('s'); |
klauss | 45:c80574f24dc3 | 740 | } |
klauss | 45:c80574f24dc3 | 741 | |
klauss | 59:e1e300880d2d | 742 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "extset ", 7 ) ){ |
klauss | 45:c80574f24dc3 | 743 | miss_match = false; |
klauss | 55:2f5e7374af9d | 744 | set_header_ext( atoi( debug_buf + 7 ) ); |
klauss | 45:c80574f24dc3 | 745 | files('s'); |
klauss | 45:c80574f24dc3 | 746 | } |
klauss | 45:c80574f24dc3 | 747 | |
klauss | 59:e1e300880d2d | 748 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serextset ", 10 ) ){ |
klauss | 45:c80574f24dc3 | 749 | miss_match = false; |
klauss | 55:2f5e7374af9d | 750 | set_server_ext( atoi( debug_buf + 10 ) ); |
klauss | 45:c80574f24dc3 | 751 | files('s'); |
klauss | 45:c80574f24dc3 | 752 | } |
klauss | 45:c80574f24dc3 | 753 | |
klauss | 59:e1e300880d2d | 754 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "maskset ",8 ) ){ |
klauss | 45:c80574f24dc3 | 755 | miss_match = false; |
klauss | 55:2f5e7374af9d | 756 | set_mask( debug_buf + 8 ); |
klauss | 45:c80574f24dc3 | 757 | files('s'); |
klauss | 45:c80574f24dc3 | 758 | } |
klauss | 45:c80574f24dc3 | 759 | |
klauss | 59:e1e300880d2d | 760 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "gatewayset ",11 ) ){ |
klauss | 45:c80574f24dc3 | 761 | miss_match = false; |
klauss | 55:2f5e7374af9d | 762 | set_gateway( debug_buf + 11 ); |
klauss | 45:c80574f24dc3 | 763 | files('s'); |
klauss | 45:c80574f24dc3 | 764 | } |
klauss | 45:c80574f24dc3 | 765 | |
klauss | 59:e1e300880d2d | 766 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "msipport ",9 ) ){ |
klauss | 45:c80574f24dc3 | 767 | miss_match = false; |
klauss | 55:2f5e7374af9d | 768 | set_header_sip_port( atoi( debug_buf + 9 ) ); |
klauss | 45:c80574f24dc3 | 769 | files('s'); |
klauss | 45:c80574f24dc3 | 770 | } |
klauss | 45:c80574f24dc3 | 771 | |
klauss | 59:e1e300880d2d | 772 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serverip ",9 ) ){ |
klauss | 45:c80574f24dc3 | 773 | miss_match = false; |
klauss | 55:2f5e7374af9d | 774 | set_server_ip( debug_buf + 9 ); |
klauss | 45:c80574f24dc3 | 775 | files('s'); |
klauss | 45:c80574f24dc3 | 776 | } |
klauss | 81:3656f00ab3db | 777 | |
klauss | 81:3656f00ab3db | 778 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "maxext ", 7 ) ){ |
klauss | 81:3656f00ab3db | 779 | miss_match = false; |
klauss | 81:3656f00ab3db | 780 | set_max_ext( atoi( debug_buf + 7 ) ); |
klauss | 81:3656f00ab3db | 781 | files('s'); |
klauss | 81:3656f00ab3db | 782 | } |
klauss | 81:3656f00ab3db | 783 | |
klauss | 81:3656f00ab3db | 784 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "minext ", 7 ) ){ |
klauss | 81:3656f00ab3db | 785 | miss_match = false; |
klauss | 81:3656f00ab3db | 786 | set_min_ext( atoi( debug_buf + 7 ) ); |
klauss | 81:3656f00ab3db | 787 | files('s'); |
klauss | 81:3656f00ab3db | 788 | } |
klauss | 45:c80574f24dc3 | 789 | |
klauss | 81:3656f00ab3db | 790 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ssport ", 7 ) ){ |
klauss | 45:c80574f24dc3 | 791 | miss_match = false; |
klauss | 55:2f5e7374af9d | 792 | set_server_port( atoi( debug_buf + 7 ) ); |
klauss | 45:c80574f24dc3 | 793 | files('s'); |
klauss | 45:c80574f24dc3 | 794 | } |
klauss | 45:c80574f24dc3 | 795 | |
klauss | 59:e1e300880d2d | 796 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "telemetry_ip ", 13 ) ){ |
klauss | 56:c64bcbaa621a | 797 | miss_match = false; |
klauss | 56:c64bcbaa621a | 798 | set_telemetry_ip( debug_buf + 13 ); |
klauss | 56:c64bcbaa621a | 799 | files('s'); |
klauss | 56:c64bcbaa621a | 800 | } |
klauss | 56:c64bcbaa621a | 801 | |
klauss | 59:e1e300880d2d | 802 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "telemetry_port ", 15 ) ){ |
klauss | 56:c64bcbaa621a | 803 | miss_match = false; |
klauss | 56:c64bcbaa621a | 804 | set_telemetry_port( atoi( debug_buf + 15 ) ); |
klauss | 56:c64bcbaa621a | 805 | files('s'); |
klauss | 56:c64bcbaa621a | 806 | } |
klauss | 45:c80574f24dc3 | 807 | |
klauss | 59:e1e300880d2d | 808 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dconfig" ) ){ |
klauss | 45:c80574f24dc3 | 809 | miss_match = false; |
klauss | 50:d9b6577a70f5 | 810 | files('e'); |
klauss | 45:c80574f24dc3 | 811 | files('w'); |
klauss | 45:c80574f24dc3 | 812 | files('s'); |
klauss | 45:c80574f24dc3 | 813 | } |
klauss | 45:c80574f24dc3 | 814 | |
klauss | 59:e1e300880d2d | 815 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset" ) ){ |
klauss | 45:c80574f24dc3 | 816 | miss_match = false; |
klauss | 45:c80574f24dc3 | 817 | pc.printf("\n\rJob is done\n\r"); |
klauss | 45:c80574f24dc3 | 818 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 819 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Job is done\n\r"); |
klauss | 45:c80574f24dc3 | 820 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 821 | if( tcp_session ){ |
klauss | 45:c80574f24dc3 | 822 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 823 | tcp_client.close(); |
klauss | 45:c80574f24dc3 | 824 | }else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 825 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 42:480335bdde12 | 826 | } |
klauss | 45:c80574f24dc3 | 827 | } |
klauss | 48:195c97f12e8e | 828 | __disable_irq(); |
klauss | 45:c80574f24dc3 | 829 | NVIC_SystemReset(); |
klauss | 45:c80574f24dc3 | 830 | } |
klauss | 45:c80574f24dc3 | 831 | |
klauss | 59:e1e300880d2d | 832 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dog" ) ){ |
klauss | 45:c80574f24dc3 | 833 | miss_match = false; |
klauss | 45:c80574f24dc3 | 834 | pc.printf("\n\r MUUUUUUUuuuuUUUUUU - I'm not a dog!!!! \n\r"); |
klauss | 45:c80574f24dc3 | 835 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 836 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "MUUUUUUUuuuuUUUUUU - I'm not a dog!!!!\n\r"); |
klauss | 67:cdedc64d9921 | 837 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 838 | } |
klauss | 45:c80574f24dc3 | 839 | } |
klauss | 48:195c97f12e8e | 840 | |
klauss | 62:07e5bdc9f8f7 | 841 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ls" ) ){ |
klauss | 62:07e5bdc9f8f7 | 842 | miss_match = false; |
klauss | 62:07e5bdc9f8f7 | 843 | list = true; |
klauss | 62:07e5bdc9f8f7 | 844 | } |
klauss | 62:07e5bdc9f8f7 | 845 | |
klauss | 81:3656f00ab3db | 846 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ls -l" ) ){ |
klauss | 81:3656f00ab3db | 847 | miss_match = false; |
klauss | 81:3656f00ab3db | 848 | long_list = true; |
klauss | 81:3656f00ab3db | 849 | } |
klauss | 81:3656f00ab3db | 850 | |
klauss | 59:e1e300880d2d | 851 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "tt" ) ){ |
klauss | 53:bb492a8f115a | 852 | miss_match = false; |
klauss | 62:07e5bdc9f8f7 | 853 | main_test = !main_test; |
klauss | 53:bb492a8f115a | 854 | } |
klauss | 53:bb492a8f115a | 855 | |
klauss | 97:8985817e8847 | 856 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "show_sip" ) ){ |
klauss | 97:8985817e8847 | 857 | miss_match = false; |
klauss | 97:8985817e8847 | 858 | show_sip = true; |
klauss | 97:8985817e8847 | 859 | } |
klauss | 97:8985817e8847 | 860 | |
klauss | 59:e1e300880d2d | 861 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_cks" ) ){ |
klauss | 52:12930cef17c4 | 862 | miss_match = false; |
klauss | 52:12930cef17c4 | 863 | reset_cks = true; |
klauss | 52:12930cef17c4 | 864 | } |
klauss | 52:12930cef17c4 | 865 | |
klauss | 64:5b011d5707d2 | 866 | //replaced by ls |
klauss | 59:e1e300880d2d | 867 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "status" ) ){ |
klauss | 48:195c97f12e8e | 868 | miss_match = false; |
klauss | 64:5b011d5707d2 | 869 | list = true; |
klauss | 64:5b011d5707d2 | 870 | } |
klauss | 64:5b011d5707d2 | 871 | |
klauss | 81:3656f00ab3db | 872 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "wdt" ) ){ |
klauss | 81:3656f00ab3db | 873 | miss_match = false; |
klauss | 81:3656f00ab3db | 874 | debug_wdt = true; |
klauss | 81:3656f00ab3db | 875 | } |
klauss | 81:3656f00ab3db | 876 | |
klauss | 81:3656f00ab3db | 877 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "eth" ) ){ |
klauss | 81:3656f00ab3db | 878 | miss_match = false; |
klauss | 81:3656f00ab3db | 879 | debug_eth = true; |
klauss | 81:3656f00ab3db | 880 | } |
klauss | 81:3656f00ab3db | 881 | |
klauss | 64:5b011d5707d2 | 882 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "types" ) ){ |
klauss | 64:5b011d5707d2 | 883 | miss_match = false; |
klauss | 64:5b011d5707d2 | 884 | |
klauss | 64:5b011d5707d2 | 885 | 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 | 64:5b011d5707d2 | 886 | |
klauss | 64:5b011d5707d2 | 887 | if( from_eth ){ |
klauss | 64:5b011d5707d2 | 888 | 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 | 64:5b011d5707d2 | 889 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 64:5b011d5707d2 | 890 | } |
klauss | 48:195c97f12e8e | 891 | } |
klauss | 64:5b011d5707d2 | 892 | |
klauss | 64:5b011d5707d2 | 893 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "protocol" ) ){ |
klauss | 64:5b011d5707d2 | 894 | miss_match = false; |
klauss | 64:5b011d5707d2 | 895 | |
klauss | 64:5b011d5707d2 | 896 | 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 | 64:5b011d5707d2 | 897 | |
klauss | 64:5b011d5707d2 | 898 | if( from_eth ){ |
klauss | 64:5b011d5707d2 | 899 | 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 | 64:5b011d5707d2 | 900 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 64:5b011d5707d2 | 901 | } |
klauss | 64:5b011d5707d2 | 902 | } |
klauss | 64:5b011d5707d2 | 903 | |
klauss | 60:b4ec6beb3be3 | 904 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "flood ", 6 ) ){ |
klauss | 60:b4ec6beb3be3 | 905 | if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on", 2 ) ){ |
klauss | 45:c80574f24dc3 | 906 | miss_match = false; |
klauss | 46:a670f187a704 | 907 | pc.printf("\n\rFlood ON\n\r"); |
klauss | 42:480335bdde12 | 908 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 909 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r" ); |
klauss | 45:c80574f24dc3 | 910 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 42:480335bdde12 | 911 | } |
klauss | 45:c80574f24dc3 | 912 | tflood.start(); |
klauss | 45:c80574f24dc3 | 913 | tflood.reset(); |
klauss | 45:c80574f24dc3 | 914 | floodcount =0; |
klauss | 45:c80574f24dc3 | 915 | pflood = 1; |
klauss | 45:c80574f24dc3 | 916 | flood_timeout.start(); |
klauss | 45:c80574f24dc3 | 917 | } |
klauss | 61:06e77dff6f00 | 918 | |
klauss | 61:06e77dff6f00 | 919 | if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "more", 4 ) ){ |
klauss | 61:06e77dff6f00 | 920 | miss_match = false; |
klauss | 61:06e77dff6f00 | 921 | pc.printf("\n\rFlood ON\n\r"); |
klauss | 61:06e77dff6f00 | 922 | if( from_eth ){ |
klauss | 61:06e77dff6f00 | 923 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r" ); |
klauss | 61:06e77dff6f00 | 924 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 61:06e77dff6f00 | 925 | } |
klauss | 61:06e77dff6f00 | 926 | tflood.start(); |
klauss | 61:06e77dff6f00 | 927 | tflood.reset(); |
klauss | 61:06e77dff6f00 | 928 | floodcount = 0; |
klauss | 61:06e77dff6f00 | 929 | pflood = 1; |
klauss | 61:06e77dff6f00 | 930 | } |
klauss | 61:06e77dff6f00 | 931 | |
klauss | 60:b4ec6beb3be3 | 932 | if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "off", 3 )) { |
klauss | 45:c80574f24dc3 | 933 | miss_match = false; |
klauss | 46:a670f187a704 | 934 | pc.printf("\n\rFlood OFF\n\r"); |
klauss | 42:480335bdde12 | 935 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 936 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood Off\n\r" ); |
klauss | 45:c80574f24dc3 | 937 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 42:480335bdde12 | 938 | } |
klauss | 45:c80574f24dc3 | 939 | pflood = 0; |
klauss | 45:c80574f24dc3 | 940 | tflood.stop(); |
klauss | 45:c80574f24dc3 | 941 | flood_timeout.reset(); |
klauss | 31:bb5fb28a77df | 942 | } |
klauss | 60:b4ec6beb3be3 | 943 | }else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "silence ", 8 ) ){ |
klauss | 60:b4ec6beb3be3 | 944 | miss_match = false; |
klauss | 60:b4ec6beb3be3 | 945 | char *ref, *split; |
klauss | 60:b4ec6beb3be3 | 946 | |
klauss | 60:b4ec6beb3be3 | 947 | strcpy( promptcb_last_cmd, debug_buf ); |
klauss | 60:b4ec6beb3be3 | 948 | |
klauss | 65:0b653cfe95db | 949 | if( !( strcmp( debug_buf + 8, "-h" ) && strcmp( debug_buf + 8, "--help" ) ) ){ |
klauss | 65:0b653cfe95db | 950 | 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 | 65:0b653cfe95db | 951 | |
klauss | 65:0b653cfe95db | 952 | if( tcp_session ){ |
klauss | 65:0b653cfe95db | 953 | 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 | 65:0b653cfe95db | 954 | } |
klauss | 65:0b653cfe95db | 955 | }else{ |
klauss | 65:0b653cfe95db | 956 | ref = debug_buf; |
klauss | 65:0b653cfe95db | 957 | |
klauss | 65:0b653cfe95db | 958 | split = strtok( debug_buf + 8, " " ); |
klauss | 65:0b653cfe95db | 959 | |
klauss | 65:0b653cfe95db | 960 | start_ext = atoi( split ); |
klauss | 65:0b653cfe95db | 961 | |
klauss | 65:0b653cfe95db | 962 | split += strlen( split ) + 1; |
klauss | 65:0b653cfe95db | 963 | |
klauss | 65:0b653cfe95db | 964 | end_ext = atoi( split ); |
klauss | 60:b4ec6beb3be3 | 965 | |
klauss | 65:0b653cfe95db | 966 | debug_buf = ref; |
klauss | 65:0b653cfe95db | 967 | |
klauss | 65:0b653cfe95db | 968 | if( start_ext < end_ext && ( end_ext - start_ext ) < 50 ){ |
klauss | 65:0b653cfe95db | 969 | if( start_ext % 2 ) start_ext--; |
klauss | 65:0b653cfe95db | 970 | if( !( end_ext % 2 ) ) end_ext++; |
klauss | 65:0b653cfe95db | 971 | |
klauss | 65:0b653cfe95db | 972 | ext_count = start_ext; |
klauss | 65:0b653cfe95db | 973 | flood_silence_timer.start(); |
klauss | 65:0b653cfe95db | 974 | }else{ |
klauss | 65:0b653cfe95db | 975 | 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 | 65:0b653cfe95db | 976 | |
klauss | 65:0b653cfe95db | 977 | if( tcp_session ){ |
klauss | 65:0b653cfe95db | 978 | 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 | 65:0b653cfe95db | 979 | } |
klauss | 48:195c97f12e8e | 980 | } |
klauss | 65:0b653cfe95db | 981 | flood_silence = true; |
klauss | 48:195c97f12e8e | 982 | } |
klauss | 45:c80574f24dc3 | 983 | } |
klauss | 45:c80574f24dc3 | 984 | |
klauss | 60:b4ec6beb3be3 | 985 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug ",6 ) ){ |
klauss | 45:c80574f24dc3 | 986 | if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on",2 )) { |
klauss | 45:c80574f24dc3 | 987 | miss_match = false; |
klauss | 46:a670f187a704 | 988 | pc.printf("\n\rDebug ON\n\r"); |
klauss | 45:c80574f24dc3 | 989 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 990 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug On\n\r" ); |
klauss | 45:c80574f24dc3 | 991 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 992 | } |
klauss | 78:1353744f01e1 | 993 | debug_alive = true; |
klauss | 45:c80574f24dc3 | 994 | } |
klauss | 45:c80574f24dc3 | 995 | if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 996 | miss_match = false; |
klauss | 46:a670f187a704 | 997 | pc.printf("\n\rDebug OFF\n\r"); |
klauss | 45:c80574f24dc3 | 998 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 999 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Off\n\r" ); |
klauss | 45:c80574f24dc3 | 1000 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 42:480335bdde12 | 1001 | } |
klauss | 78:1353744f01e1 | 1002 | debug_alive = false; |
klauss | 31:bb5fb28a77df | 1003 | } |
klauss | 45:c80574f24dc3 | 1004 | if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "show",4 ) ){ |
klauss | 45:c80574f24dc3 | 1005 | miss_match = false; |
klauss | 50:d9b6577a70f5 | 1006 | pc.printf("\n\rdsip"); |
klauss | 45:c80574f24dc3 | 1007 | pc.printf("\n\rdebug_alive"); |
klauss | 45:c80574f24dc3 | 1008 | pc.printf("\n\rdebug_prompt"); |
klauss | 45:c80574f24dc3 | 1009 | pc.printf("\n\rdebug_vector"); |
klauss | 45:c80574f24dc3 | 1010 | pc.printf("\n\rdebug_cb"); |
klauss | 45:c80574f24dc3 | 1011 | pc.printf("\n\rdebug_main"); |
klauss | 78:1353744f01e1 | 1012 | pc.printf("\n\rdcks"); |
klauss | 45:c80574f24dc3 | 1013 | pc.printf("\n\rdebug_cb_rx"); |
klauss | 45:c80574f24dc3 | 1014 | pc.printf("\n\rdebug_cb_tx*"); |
klauss | 45:c80574f24dc3 | 1015 | pc.printf("\n\rdebug_eth_rx*"); |
klauss | 45:c80574f24dc3 | 1016 | pc.printf("\n\rdebug_eth_tx*"); |
klauss | 45:c80574f24dc3 | 1017 | pc.printf("\n\rdebug_file"); |
klauss | 45:c80574f24dc3 | 1018 | |
klauss | 42:480335bdde12 | 1019 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1020 | 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 | 42:480335bdde12 | 1021 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 42:480335bdde12 | 1022 | } |
klauss | 42:480335bdde12 | 1023 | } |
klauss | 45:c80574f24dc3 | 1024 | } |
klauss | 45:c80574f24dc3 | 1025 | |
klauss | 78:1353744f01e1 | 1026 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dsip ", 5 ) ){ |
klauss | 78:1353744f01e1 | 1027 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ){ |
klauss | 45:c80574f24dc3 | 1028 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1029 | pc.printf( "\n\rSip Debug ON\n\r" ); |
klauss | 45:c80574f24dc3 | 1030 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1031 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Sip Debug On\n\r" ); |
klauss | 45:c80574f24dc3 | 1032 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1033 | } |
klauss | 78:1353744f01e1 | 1034 | debug_sip = true; |
klauss | 45:c80574f24dc3 | 1035 | } |
klauss | 50:d9b6577a70f5 | 1036 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 1037 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1038 | pc.printf( "\n\rSip Debug OFF\n\r" ); |
klauss | 45:c80574f24dc3 | 1039 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1040 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Sip Debug Off\n\r" ); |
klauss | 45:c80574f24dc3 | 1041 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1042 | } |
klauss | 78:1353744f01e1 | 1043 | debug_sip = false; |
klauss | 78:1353744f01e1 | 1044 | } |
klauss | 78:1353744f01e1 | 1045 | } |
klauss | 78:1353744f01e1 | 1046 | |
klauss | 81:3656f00ab3db | 1047 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dmuted ", 7 ) ){ |
klauss | 81:3656f00ab3db | 1048 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ |
klauss | 81:3656f00ab3db | 1049 | miss_match = false; |
klauss | 81:3656f00ab3db | 1050 | pc.printf( "\n\rMuted Debug ON\n\r" ); |
klauss | 81:3656f00ab3db | 1051 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1052 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Muted Debug On\n\r" ); |
klauss | 81:3656f00ab3db | 1053 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1054 | } |
klauss | 81:3656f00ab3db | 1055 | debug_muted = true; |
klauss | 81:3656f00ab3db | 1056 | } |
klauss | 81:3656f00ab3db | 1057 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { |
klauss | 81:3656f00ab3db | 1058 | miss_match = false; |
klauss | 81:3656f00ab3db | 1059 | pc.printf( "\n\rMuted Debug OFF\n\r" ); |
klauss | 81:3656f00ab3db | 1060 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1061 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Muted Debug Off\n\r" ); |
klauss | 81:3656f00ab3db | 1062 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1063 | } |
klauss | 81:3656f00ab3db | 1064 | debug_muted = false; |
klauss | 81:3656f00ab3db | 1065 | } |
klauss | 81:3656f00ab3db | 1066 | } |
klauss | 81:3656f00ab3db | 1067 | |
klauss | 81:3656f00ab3db | 1068 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dwdt ", 5 ) ){ |
klauss | 81:3656f00ab3db | 1069 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ){ |
klauss | 81:3656f00ab3db | 1070 | miss_match = false; |
klauss | 81:3656f00ab3db | 1071 | pc.printf( "\n\rWdt Debug ON\n\r" ); |
klauss | 81:3656f00ab3db | 1072 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1073 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wdt Debug On\n\r" ); |
klauss | 81:3656f00ab3db | 1074 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1075 | } |
klauss | 81:3656f00ab3db | 1076 | wdt_show = true; |
klauss | 81:3656f00ab3db | 1077 | } |
klauss | 81:3656f00ab3db | 1078 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) { |
klauss | 81:3656f00ab3db | 1079 | miss_match = false; |
klauss | 81:3656f00ab3db | 1080 | pc.printf( "\n\rWdt Debug OFF\n\r" ); |
klauss | 81:3656f00ab3db | 1081 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1082 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wdt Debug Off\n\r" ); |
klauss | 81:3656f00ab3db | 1083 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1084 | } |
klauss | 81:3656f00ab3db | 1085 | wdt_show = false; |
klauss | 81:3656f00ab3db | 1086 | } |
klauss | 81:3656f00ab3db | 1087 | } |
klauss | 81:3656f00ab3db | 1088 | |
klauss | 81:3656f00ab3db | 1089 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drefresh ", 9 ) ){ |
klauss | 81:3656f00ab3db | 1090 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "on", 2 ) ){ |
klauss | 81:3656f00ab3db | 1091 | miss_match = false; |
klauss | 81:3656f00ab3db | 1092 | pc.printf( "\n\rRefresh Debug ON\n\r" ); |
klauss | 81:3656f00ab3db | 1093 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1094 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Refresh Debug On\n\r" ); |
klauss | 81:3656f00ab3db | 1095 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1096 | } |
klauss | 81:3656f00ab3db | 1097 | debug_refresh= true; |
klauss | 81:3656f00ab3db | 1098 | } |
klauss | 81:3656f00ab3db | 1099 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "off",3 )) { |
klauss | 81:3656f00ab3db | 1100 | miss_match = false; |
klauss | 81:3656f00ab3db | 1101 | pc.printf( "\n\rRefresh Debug OFF\n\r" ); |
klauss | 81:3656f00ab3db | 1102 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1103 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Refresh Debug Off\n\r" ); |
klauss | 81:3656f00ab3db | 1104 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1105 | } |
klauss | 81:3656f00ab3db | 1106 | debug_refresh = false; |
klauss | 81:3656f00ab3db | 1107 | } |
klauss | 81:3656f00ab3db | 1108 | } |
klauss | 81:3656f00ab3db | 1109 | |
klauss | 78:1353744f01e1 | 1110 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dping ", 6 ) ){ |
klauss | 78:1353744f01e1 | 1111 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1112 | miss_match = false; |
klauss | 78:1353744f01e1 | 1113 | pc.printf( "\n\rPing Debug ON\n\r" ); |
klauss | 78:1353744f01e1 | 1114 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1115 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Ping Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1116 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1117 | } |
klauss | 78:1353744f01e1 | 1118 | debug_ping = true; |
klauss | 78:1353744f01e1 | 1119 | } |
klauss | 78:1353744f01e1 | 1120 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1121 | miss_match = false; |
klauss | 78:1353744f01e1 | 1122 | pc.printf( "\n\rPing Debug OFF\n\r" ); |
klauss | 78:1353744f01e1 | 1123 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1124 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Ping Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1125 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1126 | } |
klauss | 78:1353744f01e1 | 1127 | debug_ping= false; |
klauss | 78:1353744f01e1 | 1128 | } |
klauss | 78:1353744f01e1 | 1129 | } |
klauss | 78:1353744f01e1 | 1130 | |
klauss | 78:1353744f01e1 | 1131 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dwu ", 4 ) ){ |
klauss | 78:1353744f01e1 | 1132 | if (xmemmatch( (uint8_t*)(debug_buf + 4 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1133 | miss_match = false; |
klauss | 78:1353744f01e1 | 1134 | pc.printf( "\n\rWake Up Debug ON\n\r" ); |
klauss | 78:1353744f01e1 | 1135 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1136 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wake Up Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1137 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1138 | } |
klauss | 78:1353744f01e1 | 1139 | debug_wake = true; |
klauss | 78:1353744f01e1 | 1140 | } |
klauss | 78:1353744f01e1 | 1141 | if (xmemmatch( (uint8_t*)(debug_buf + 4 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1142 | miss_match = false; |
klauss | 78:1353744f01e1 | 1143 | pc.printf( "\n\rWake Up Debug OFF\n\r" ); |
klauss | 78:1353744f01e1 | 1144 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1145 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wake Up Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1146 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1147 | } |
klauss | 78:1353744f01e1 | 1148 | debug_wake = false; |
klauss | 78:1353744f01e1 | 1149 | } |
klauss | 78:1353744f01e1 | 1150 | } |
klauss | 78:1353744f01e1 | 1151 | |
klauss | 78:1353744f01e1 | 1152 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "tcp_alive ", 10 ) ){ |
klauss | 78:1353744f01e1 | 1153 | if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1154 | miss_match = false; |
klauss | 78:1353744f01e1 | 1155 | pc.printf( "\n\rTCP don't drop mode on\n\r" ); |
klauss | 78:1353744f01e1 | 1156 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1157 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "TCP don't drop mode on\n\r" ); |
klauss | 78:1353744f01e1 | 1158 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1159 | } |
klauss | 78:1353744f01e1 | 1160 | tcp_alive = true; |
klauss | 78:1353744f01e1 | 1161 | } |
klauss | 78:1353744f01e1 | 1162 | if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1163 | miss_match = false; |
klauss | 78:1353744f01e1 | 1164 | pc.printf( "\n\rTCP don't drop mode off\n\r" ); |
klauss | 78:1353744f01e1 | 1165 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1166 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "TCP don't drop mode off\n\r" ); |
klauss | 78:1353744f01e1 | 1167 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1168 | } |
klauss | 78:1353744f01e1 | 1169 | tcp_alive = false; |
klauss | 78:1353744f01e1 | 1170 | } |
klauss | 78:1353744f01e1 | 1171 | } |
klauss | 78:1353744f01e1 | 1172 | |
klauss | 78:1353744f01e1 | 1173 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "daging ",7 ) ){ |
klauss | 78:1353744f01e1 | 1174 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1175 | miss_match = false; |
klauss | 78:1353744f01e1 | 1176 | pc.printf( "\n\rAging Debug ON\n\r" ); |
klauss | 78:1353744f01e1 | 1177 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1178 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Aging Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1179 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1180 | } |
klauss | 78:1353744f01e1 | 1181 | debug_aging = true; |
klauss | 78:1353744f01e1 | 1182 | } |
klauss | 78:1353744f01e1 | 1183 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1184 | miss_match = false; |
klauss | 78:1353744f01e1 | 1185 | pc.printf( "\n\rAging Debug OFF\n\r" ); |
klauss | 78:1353744f01e1 | 1186 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1187 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Aging Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1188 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1189 | } |
klauss | 78:1353744f01e1 | 1190 | debug_aging = false; |
klauss | 78:1353744f01e1 | 1191 | } |
klauss | 78:1353744f01e1 | 1192 | } |
klauss | 78:1353744f01e1 | 1193 | |
klauss | 78:1353744f01e1 | 1194 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcpld ", 6 ) ){ |
klauss | 78:1353744f01e1 | 1195 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1196 | miss_match = false; |
klauss | 78:1353744f01e1 | 1197 | pc.printf( "\n\rDCPLD Debug ON\n\r" ); |
klauss | 78:1353744f01e1 | 1198 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1199 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "DCPLD Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1200 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1201 | } |
klauss | 78:1353744f01e1 | 1202 | debug_cpld = true; |
klauss | 78:1353744f01e1 | 1203 | } |
klauss | 78:1353744f01e1 | 1204 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 ) ){ |
klauss | 78:1353744f01e1 | 1205 | miss_match = false; |
klauss | 78:1353744f01e1 | 1206 | pc.printf( "\n\rDCPLD Debug OFF\n\r" ); |
klauss | 78:1353744f01e1 | 1207 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1208 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "DCPLD Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1209 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1210 | } |
klauss | 78:1353744f01e1 | 1211 | debug_cpld = false; |
klauss | 78:1353744f01e1 | 1212 | } |
klauss | 78:1353744f01e1 | 1213 | } |
klauss | 78:1353744f01e1 | 1214 | |
klauss | 78:1353744f01e1 | 1215 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcks_err ", 9 ) ){ |
klauss | 78:1353744f01e1 | 1216 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1217 | miss_match = false; |
klauss | 78:1353744f01e1 | 1218 | pc.printf( "\n\rCKS_ERR Debug ON\n\r" ); |
klauss | 78:1353744f01e1 | 1219 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1220 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS_ERR Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1221 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1222 | } |
klauss | 78:1353744f01e1 | 1223 | debug_cks_err = true; |
klauss | 78:1353744f01e1 | 1224 | } |
klauss | 78:1353744f01e1 | 1225 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "off", 3 ) ){ |
klauss | 78:1353744f01e1 | 1226 | miss_match = false; |
klauss | 78:1353744f01e1 | 1227 | pc.printf( "\n\rCKS_ERR Debug OFF\n\r" ); |
klauss | 78:1353744f01e1 | 1228 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1229 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS_ERR Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1230 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1231 | } |
klauss | 78:1353744f01e1 | 1232 | debug_cks_err = false; |
klauss | 78:1353744f01e1 | 1233 | } |
klauss | 78:1353744f01e1 | 1234 | } |
klauss | 78:1353744f01e1 | 1235 | |
klauss | 78:1353744f01e1 | 1236 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dinvite ", 8 ) ){ |
klauss | 78:1353744f01e1 | 1237 | if( xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1238 | miss_match = false; |
klauss | 78:1353744f01e1 | 1239 | pc.printf( "\n\rInvite Debug ON\n\r" ); |
klauss | 78:1353744f01e1 | 1240 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1241 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Invite Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1242 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1243 | } |
klauss | 81:3656f00ab3db | 1244 | debug_invite = true; |
klauss | 78:1353744f01e1 | 1245 | } |
klauss | 78:1353744f01e1 | 1246 | if( xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1247 | miss_match = false; |
klauss | 78:1353744f01e1 | 1248 | pc.printf( "\n\rInvite Debug OFF\n\r" ); |
klauss | 78:1353744f01e1 | 1249 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1250 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Invite Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1251 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1252 | } |
klauss | 78:1353744f01e1 | 1253 | debug_invite = 0; |
klauss | 45:c80574f24dc3 | 1254 | } |
klauss | 45:c80574f24dc3 | 1255 | } |
klauss | 45:c80574f24dc3 | 1256 | |
klauss | 72:895ca792c647 | 1257 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dparallel ", 10 ) ){ |
klauss | 72:895ca792c647 | 1258 | if( xmemmatch( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * )"on", 2 ) ){ |
klauss | 72:895ca792c647 | 1259 | miss_match = false; |
klauss | 72:895ca792c647 | 1260 | pc.printf( "\n\rParallel Write Debug ON\n\r" ); |
klauss | 72:895ca792c647 | 1261 | if( from_eth ){ |
klauss | 72:895ca792c647 | 1262 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rParallel Write Debug ON\n\r" ); |
klauss | 72:895ca792c647 | 1263 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 72:895ca792c647 | 1264 | } |
klauss | 72:895ca792c647 | 1265 | dparallel = true; |
klauss | 72:895ca792c647 | 1266 | } |
klauss | 72:895ca792c647 | 1267 | if( xmemmatch( ( uint8_t * )( debug_buf + 10 ), ( uint8_t *)"off", 3 )) { |
klauss | 72:895ca792c647 | 1268 | miss_match = false; |
klauss | 72:895ca792c647 | 1269 | pc.printf( "\n\rParallel Write Debug OFF\n\r" ); |
klauss | 72:895ca792c647 | 1270 | if( from_eth ){ |
klauss | 72:895ca792c647 | 1271 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rParallel Write Debug OFF\n\r" ); |
klauss | 72:895ca792c647 | 1272 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 72:895ca792c647 | 1273 | } |
klauss | 72:895ca792c647 | 1274 | dparallel = false; |
klauss | 72:895ca792c647 | 1275 | } |
klauss | 72:895ca792c647 | 1276 | } |
klauss | 72:895ca792c647 | 1277 | |
klauss | 78:1353744f01e1 | 1278 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dtelos ", 7 ) ){ |
klauss | 78:1353744f01e1 | 1279 | if (xmemmatch( (uint8_t*)( debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ |
klauss | 53:bb492a8f115a | 1280 | miss_match = false; |
klauss | 53:bb492a8f115a | 1281 | pc.printf( "\n\rTelemetry Debug ON\n\r" ); |
klauss | 53:bb492a8f115a | 1282 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1283 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\rTelemetry Debug On\n\r" ); |
klauss | 53:bb492a8f115a | 1284 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 53:bb492a8f115a | 1285 | } |
klauss | 53:bb492a8f115a | 1286 | debug_telemetry = true; |
klauss | 53:bb492a8f115a | 1287 | } |
klauss | 78:1353744f01e1 | 1288 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off", 3 )) { |
klauss | 53:bb492a8f115a | 1289 | miss_match = false; |
klauss | 78:1353744f01e1 | 1290 | pc.printf( "\n\rTelemetry Debug OFF\n\r" ); |
klauss | 53:bb492a8f115a | 1291 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1292 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\rTelemetry Debug Off\n\r" ); |
klauss | 53:bb492a8f115a | 1293 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 53:bb492a8f115a | 1294 | } |
klauss | 53:bb492a8f115a | 1295 | debug_telemetry = false; |
klauss | 53:bb492a8f115a | 1296 | } |
klauss | 53:bb492a8f115a | 1297 | } |
klauss | 53:bb492a8f115a | 1298 | |
klauss | 92:92df17f538a8 | 1299 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcks ", 5 ) ){ |
klauss | 92:92df17f538a8 | 1300 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on",2 ) ){ |
klauss | 45:c80574f24dc3 | 1301 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1302 | pc.printf( "\n\rCKS Debug ON\n\r" ); |
klauss | 45:c80574f24dc3 | 1303 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1304 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS Debug On\n\r" ); |
klauss | 45:c80574f24dc3 | 1305 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1306 | } |
klauss | 78:1353744f01e1 | 1307 | debug_cks = true; |
klauss | 45:c80574f24dc3 | 1308 | } |
klauss | 50:d9b6577a70f5 | 1309 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 1310 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1311 | pc.printf( "\n\rCKS Debug OFF\n\r" ); |
klauss | 45:c80574f24dc3 | 1312 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1313 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS Debug Off\n\r" ); |
klauss | 45:c80574f24dc3 | 1314 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1315 | } |
klauss | 78:1353744f01e1 | 1316 | debug_cks = false; |
klauss | 45:c80574f24dc3 | 1317 | } |
klauss | 45:c80574f24dc3 | 1318 | } |
klauss | 45:c80574f24dc3 | 1319 | |
klauss | 92:92df17f538a8 | 1320 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "promptcb ", 9 ) ){ |
klauss | 78:1353744f01e1 | 1321 | miss_match = false; |
klauss | 78:1353744f01e1 | 1322 | //static uint8_t id_msg = 0x10; |
klauss | 78:1353744f01e1 | 1323 | uint8_t write_buffer[ 300 ]; |
klauss | 78:1353744f01e1 | 1324 | int ext,port; |
klauss | 78:1353744f01e1 | 1325 | char *split, *ref, *cmd; |
klauss | 78:1353744f01e1 | 1326 | |
klauss | 78:1353744f01e1 | 1327 | ref = debug_buf; |
klauss | 78:1353744f01e1 | 1328 | |
klauss | 78:1353744f01e1 | 1329 | strcat( debug_buf, "\r" ); |
klauss | 78:1353744f01e1 | 1330 | |
klauss | 78:1353744f01e1 | 1331 | split = strtok( debug_buf + 9, " " ); |
klauss | 78:1353744f01e1 | 1332 | ext = atoi( split ); |
klauss | 78:1353744f01e1 | 1333 | split = strtok( NULL, " " ); |
klauss | 78:1353744f01e1 | 1334 | port = atoi( split ); |
klauss | 78:1353744f01e1 | 1335 | split += strlen( split ) + 1; |
klauss | 78:1353744f01e1 | 1336 | cmd = split; |
klauss | 78:1353744f01e1 | 1337 | |
klauss | 78:1353744f01e1 | 1338 | promptcb_last_ext = ext; |
klauss | 78:1353744f01e1 | 1339 | promptcb_last_port = port; |
klauss | 78:1353744f01e1 | 1340 | |
klauss | 78:1353744f01e1 | 1341 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 78:1353744f01e1 | 1342 | strcat( cmd, "\r\r\r\n" ); |
klauss | 78:1353744f01e1 | 1343 | |
klauss | 78:1353744f01e1 | 1344 | pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); |
klauss | 78:1353744f01e1 | 1345 | send2callboxes( __build_cb_package__( ext, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 78:1353744f01e1 | 1346 | pc.printf("\n\rComando enviado"); |
klauss | 78:1353744f01e1 | 1347 | |
klauss | 78:1353744f01e1 | 1348 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1349 | char eth_msg[ 512 ]; |
klauss | 78:1353744f01e1 | 1350 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd ); |
klauss | 78:1353744f01e1 | 1351 | if( tcp_session ){ |
klauss | 78:1353744f01e1 | 1352 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 78:1353744f01e1 | 1353 | }else if( udp_request ){ |
klauss | 78:1353744f01e1 | 1354 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 78:1353744f01e1 | 1355 | } |
klauss | 78:1353744f01e1 | 1356 | } |
klauss | 78:1353744f01e1 | 1357 | |
klauss | 78:1353744f01e1 | 1358 | debug_buf = ref; |
klauss | 78:1353744f01e1 | 1359 | bufptr = 0; |
klauss | 78:1353744f01e1 | 1360 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 78:1353744f01e1 | 1361 | } |
klauss | 78:1353744f01e1 | 1362 | |
klauss | 92:92df17f538a8 | 1363 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "bye ", 4 ) ){ |
klauss | 92:92df17f538a8 | 1364 | miss_match = false; |
klauss | 92:92df17f538a8 | 1365 | int ext,port; |
klauss | 92:92df17f538a8 | 1366 | char *split, *ref; |
klauss | 92:92df17f538a8 | 1367 | uint8_t write_buffer[ 300 ], data[ 300 ]; |
klauss | 92:92df17f538a8 | 1368 | |
klauss | 92:92df17f538a8 | 1369 | ref = debug_buf; |
klauss | 92:92df17f538a8 | 1370 | |
klauss | 92:92df17f538a8 | 1371 | strcat( debug_buf, "\r\r\r\n" ); |
klauss | 92:92df17f538a8 | 1372 | |
klauss | 92:92df17f538a8 | 1373 | split = strtok( debug_buf + 4, " " ); |
klauss | 92:92df17f538a8 | 1374 | ext = atoi( split ); |
klauss | 92:92df17f538a8 | 1375 | port = convert_ext_to_port( ext ); |
klauss | 92:92df17f538a8 | 1376 | |
klauss | 92:92df17f538a8 | 1377 | pc.printf("\r\next=%d port=%d request bye", ext, port ); |
klauss | 92:92df17f538a8 | 1378 | send2callboxes( __build_cb_package__( ext, port, __CB_BYE__, (char * )data, 0x20, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 92:92df17f538a8 | 1379 | pc.printf("\n\rBye enviado"); |
klauss | 92:92df17f538a8 | 1380 | |
klauss | 92:92df17f538a8 | 1381 | if( from_eth ){ |
klauss | 92:92df17f538a8 | 1382 | char eth_msg[ 512 ]; |
klauss | 92:92df17f538a8 | 1383 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d request bye\n\r", ext, port ); |
klauss | 92:92df17f538a8 | 1384 | if( tcp_session ){ |
klauss | 92:92df17f538a8 | 1385 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 92:92df17f538a8 | 1386 | }else if( udp_request ){ |
klauss | 92:92df17f538a8 | 1387 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 92:92df17f538a8 | 1388 | } |
klauss | 92:92df17f538a8 | 1389 | } |
klauss | 92:92df17f538a8 | 1390 | |
klauss | 92:92df17f538a8 | 1391 | debug_buf = ref; |
klauss | 92:92df17f538a8 | 1392 | bufptr = 0; |
klauss | 92:92df17f538a8 | 1393 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 92:92df17f538a8 | 1394 | } |
klauss | 92:92df17f538a8 | 1395 | |
klauss | 45:c80574f24dc3 | 1396 | //promptcb ramal porta comando |
klauss | 50:d9b6577a70f5 | 1397 | //FIXME colocar a parte eth de novo |
klauss | 59:e1e300880d2d | 1398 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "pcb ", 4 )) { |
klauss | 45:c80574f24dc3 | 1399 | miss_match = false; |
klauss | 48:195c97f12e8e | 1400 | int ext,port; |
klauss | 54:448d57291be6 | 1401 | char *split, *ref, *cmd; |
klauss | 48:195c97f12e8e | 1402 | |
klauss | 62:07e5bdc9f8f7 | 1403 | ref = debug_buf; |
klauss | 59:e1e300880d2d | 1404 | |
klauss | 74:81c47fff88a5 | 1405 | strcat( debug_buf, "\r" ); |
klauss | 48:195c97f12e8e | 1406 | |
klauss | 48:195c97f12e8e | 1407 | split = strtok( debug_buf + 4, " " ); |
klauss | 48:195c97f12e8e | 1408 | ext = atoi( split ); |
klauss | 50:d9b6577a70f5 | 1409 | |
klauss | 50:d9b6577a70f5 | 1410 | port = convert_ext_to_port( ext ); |
klauss | 48:195c97f12e8e | 1411 | split += strlen( split ) + 1; |
klauss | 54:448d57291be6 | 1412 | cmd = split; |
klauss | 48:195c97f12e8e | 1413 | |
klauss | 48:195c97f12e8e | 1414 | promptcb_last_ext = ext; |
klauss | 48:195c97f12e8e | 1415 | promptcb_last_port = port; |
klauss | 62:07e5bdc9f8f7 | 1416 | |
klauss | 55:2f5e7374af9d | 1417 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 78:1353744f01e1 | 1418 | strcat( cmd, "\r\r\r\n" ); |
klauss | 78:1353744f01e1 | 1419 | |
klauss | 78:1353744f01e1 | 1420 | //send_msg( "Tamanho do cmd == %d", strlen( cmd ) ); |
klauss | 48:195c97f12e8e | 1421 | |
klauss | 78:1353744f01e1 | 1422 | //for( register uint16_t i = strlen( cmd ); i < __CB_BUFFER_SIZE__; i++ ) cmd[ i ] = 0; |
klauss | 78:1353744f01e1 | 1423 | |
klauss | 78:1353744f01e1 | 1424 | pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); |
klauss | 74:81c47fff88a5 | 1425 | send2callboxes( __build_cb_package__( ext, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 78:1353744f01e1 | 1426 | pc.printf("\n\rComando enviado"); |
klauss | 48:195c97f12e8e | 1427 | |
klauss | 54:448d57291be6 | 1428 | if( from_eth ){ |
klauss | 62:07e5bdc9f8f7 | 1429 | char eth_msg[ 512 ]; |
klauss | 78:1353744f01e1 | 1430 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd ); |
klauss | 62:07e5bdc9f8f7 | 1431 | if( tcp_session ){ |
klauss | 62:07e5bdc9f8f7 | 1432 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 62:07e5bdc9f8f7 | 1433 | }else if( udp_request ){ |
klauss | 62:07e5bdc9f8f7 | 1434 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 62:07e5bdc9f8f7 | 1435 | } |
klauss | 54:448d57291be6 | 1436 | } |
klauss | 54:448d57291be6 | 1437 | |
klauss | 48:195c97f12e8e | 1438 | debug_buf = ref; |
klauss | 67:cdedc64d9921 | 1439 | //bufptr = 0; |
klauss | 67:cdedc64d9921 | 1440 | //debug_buf[ 0 ] = 0; |
klauss | 62:07e5bdc9f8f7 | 1441 | bufptr = 0; |
klauss | 67:cdedc64d9921 | 1442 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 45:c80574f24dc3 | 1443 | } |
klauss | 48:195c97f12e8e | 1444 | |
klauss | 59:e1e300880d2d | 1445 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "_pcb",4 )) { |
klauss | 45:c80574f24dc3 | 1446 | miss_match = false; |
klauss | 48:195c97f12e8e | 1447 | debug_buf[ bufptr++ ] = 0x0D; |
klauss | 48:195c97f12e8e | 1448 | debug_buf[ bufptr++ ] = 0x00; |
klauss | 45:c80574f24dc3 | 1449 | |
klauss | 48:195c97f12e8e | 1450 | pc.printf("\r\next=%d port=%d\r\ncmd=%s\r\n",promptcb_last_ext, promptcb_last_port, debug_buf + 4 ); |
klauss | 74:81c47fff88a5 | 1451 | 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 | 45:c80574f24dc3 | 1452 | pc.printf("\n\rComando enviado\n\r"); |
klauss | 45:c80574f24dc3 | 1453 | } |
klauss | 62:07e5bdc9f8f7 | 1454 | |
klauss | 58:af7e8788f106 | 1455 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "cks",3 )) { |
klauss | 45:c80574f24dc3 | 1456 | miss_match = false; |
klauss | 81:3656f00ab3db | 1457 | pcks_s = true; |
klauss | 45:c80574f24dc3 | 1458 | } |
klauss | 45:c80574f24dc3 | 1459 | |
klauss | 58:af7e8788f106 | 1460 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "showcb",6 )) { |
klauss | 45:c80574f24dc3 | 1461 | miss_match = false; |
klauss | 81:3656f00ab3db | 1462 | pshowcb = true; |
klauss | 45:c80574f24dc3 | 1463 | } |
klauss | 45:c80574f24dc3 | 1464 | |
klauss | 58:af7e8788f106 | 1465 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_main ", 11 )) { |
klauss | 81:3656f00ab3db | 1466 | if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "on", 2 )) { |
klauss | 45:c80574f24dc3 | 1467 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1468 | pc.printf("\r\nDebug Main ON"); |
klauss | 45:c80574f24dc3 | 1469 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1470 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Main On\n\r" ); |
klauss | 45:c80574f24dc3 | 1471 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1472 | } |
klauss | 81:3656f00ab3db | 1473 | debug_main = true; |
klauss | 45:c80574f24dc3 | 1474 | } |
klauss | 81:3656f00ab3db | 1475 | if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "off", 3 )) { |
klauss | 45:c80574f24dc3 | 1476 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1477 | pc.printf("\r\nDebug Main OFF"); |
klauss | 45:c80574f24dc3 | 1478 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1479 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Main Off\n\r" ); |
klauss | 45:c80574f24dc3 | 1480 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1481 | } |
klauss | 45:c80574f24dc3 | 1482 | debug_main = 0; |
klauss | 45:c80574f24dc3 | 1483 | } |
klauss | 45:c80574f24dc3 | 1484 | } |
klauss | 45:c80574f24dc3 | 1485 | |
klauss | 81:3656f00ab3db | 1486 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dout ", 5 ) ){ |
klauss | 81:3656f00ab3db | 1487 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "on", 2 ) ){ |
klauss | 81:3656f00ab3db | 1488 | miss_match = false; |
klauss | 81:3656f00ab3db | 1489 | pc.printf("\r\nOut Debug ON"); |
klauss | 81:3656f00ab3db | 1490 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1491 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Out Debug On\n\r" ); |
klauss | 81:3656f00ab3db | 1492 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1493 | } |
klauss | 81:3656f00ab3db | 1494 | debug_out_of_range = true; |
klauss | 81:3656f00ab3db | 1495 | } |
klauss | 81:3656f00ab3db | 1496 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "off", 3 ) ){ |
klauss | 81:3656f00ab3db | 1497 | miss_match = false; |
klauss | 81:3656f00ab3db | 1498 | pc.printf("\r\nOut Debug OFF"); |
klauss | 81:3656f00ab3db | 1499 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1500 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Out Debug Off\n\r" ); |
klauss | 81:3656f00ab3db | 1501 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1502 | } |
klauss | 81:3656f00ab3db | 1503 | debug_out_of_range = false; |
klauss | 81:3656f00ab3db | 1504 | } |
klauss | 81:3656f00ab3db | 1505 | } |
klauss | 81:3656f00ab3db | 1506 | |
klauss | 58:af7e8788f106 | 1507 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_cb_rx ", 12 )) { |
klauss | 45:c80574f24dc3 | 1508 | if (xmemmatch( (uint8_t*)( debug_buf + 12 ), (uint8_t*) "on",2 )) { |
klauss | 45:c80574f24dc3 | 1509 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1510 | pc.printf("\tDebug Cbx Rx ON"); |
klauss | 45:c80574f24dc3 | 1511 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1512 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Cbx On Rx on\n\r" ); |
klauss | 45:c80574f24dc3 | 1513 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1514 | } |
klauss | 81:3656f00ab3db | 1515 | debug_cb_rx = true; |
klauss | 45:c80574f24dc3 | 1516 | } |
klauss | 45:c80574f24dc3 | 1517 | if (xmemmatch( (uint8_t*)( debug_buf + 12 ), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 1518 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1519 | pc.printf("Debug Cbx Rx OFF"); |
klauss | 45:c80574f24dc3 | 1520 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1521 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Cbx Rx Off\n\r" ); |
klauss | 45:c80574f24dc3 | 1522 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1523 | } |
klauss | 45:c80574f24dc3 | 1524 | debug_cb_rx = 0; |
klauss | 45:c80574f24dc3 | 1525 | } |
klauss | 45:c80574f24dc3 | 1526 | } |
klauss | 45:c80574f24dc3 | 1527 | |
klauss | 58:af7e8788f106 | 1528 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_file ", 11 )) { |
klauss | 45:c80574f24dc3 | 1529 | if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "on",2 )) { |
klauss | 45:c80574f24dc3 | 1530 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1531 | pc.printf("\tDebug File ON"); |
klauss | 45:c80574f24dc3 | 1532 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1533 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug File On\n\r" ); |
klauss | 45:c80574f24dc3 | 1534 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1535 | } |
klauss | 81:3656f00ab3db | 1536 | debug_cb_rx = true; |
klauss | 45:c80574f24dc3 | 1537 | } |
klauss | 45:c80574f24dc3 | 1538 | if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 1539 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1540 | pc.printf("Debug File OFF"); |
klauss | 45:c80574f24dc3 | 1541 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1542 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug File Off\n\r" ); |
klauss | 45:c80574f24dc3 | 1543 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1544 | } |
klauss | 45:c80574f24dc3 | 1545 | debug_cb_rx = 0; |
klauss | 45:c80574f24dc3 | 1546 | } |
klauss | 45:c80574f24dc3 | 1547 | } |
klauss | 45:c80574f24dc3 | 1548 | |
klauss | 58:af7e8788f106 | 1549 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "help" )) { |
klauss | 45:c80574f24dc3 | 1550 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1551 | pc.printf("\n\r****************************PROMPT HELP******************\n\r"); |
klauss | 45:c80574f24dc3 | 1552 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1553 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "\n\r****************************PROMPT HELP******************\n\r" ); |
klauss | 78:1353744f01e1 | 1554 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1555 | |
klauss | 45:c80574f24dc3 | 1556 | else if( udp_request ){ |
klauss | 78:1353744f01e1 | 1557 | while( !( udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1558 | } |
klauss | 44:cc4996469404 | 1559 | } |
klauss | 52:12930cef17c4 | 1560 | |
klauss | 45:c80574f24dc3 | 1561 | pc.printf("ifconfig - mostra o arquivo de configuracao do sistema\n\r"); |
klauss | 45:c80574f24dc3 | 1562 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1563 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ifconfig - mostra o arquivo de configuracao do sistema\n\r" ); |
klauss | 78:1353744f01e1 | 1564 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1565 | |
klauss | 45:c80574f24dc3 | 1566 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1567 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1568 | } |
klauss | 45:c80574f24dc3 | 1569 | } |
klauss | 45:c80574f24dc3 | 1570 | pc.printf("dconfig - volta as configuracoes do sistema para o padrao de fabrica\n\r"); |
klauss | 45:c80574f24dc3 | 1571 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1572 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "dconfig - volta as configuracoes do sistema para o padrao de fabrica\n\r" ); |
klauss | 78:1353744f01e1 | 1573 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1574 | |
klauss | 45:c80574f24dc3 | 1575 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1576 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1577 | } |
klauss | 45:c80574f24dc3 | 1578 | } |
klauss | 45:c80574f24dc3 | 1579 | pc.printf("callme [ramal porta] - envia o pedido de ligacao para o callbox com o ramal e porta indicada\n\r"); |
klauss | 45:c80574f24dc3 | 1580 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1581 | 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 | 78:1353744f01e1 | 1582 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1583 | |
klauss | 45:c80574f24dc3 | 1584 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1585 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1586 | } |
klauss | 45:c80574f24dc3 | 1587 | } |
klauss | 48:195c97f12e8e | 1588 | pc.printf("pcb porta comando - envia o <comando> para o cbx <ramal> e <porta> executar\n\r"); |
klauss | 45:c80574f24dc3 | 1589 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1590 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "promptcb ramal porta comando - envia o <comando> para o cbx <ramal> e <porta> executar\n\r" ); |
klauss | 78:1353744f01e1 | 1591 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1592 | |
klauss | 45:c80574f24dc3 | 1593 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1594 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1595 | } |
klauss | 45:c80574f24dc3 | 1596 | } |
klauss | 45:c80574f24dc3 | 1597 | pc.printf("format - formata o sistema de arquivos\n\r"); |
klauss | 62:07e5bdc9f8f7 | 1598 | //desabilitado via eth |
klauss | 62:07e5bdc9f8f7 | 1599 | /* |
klauss | 45:c80574f24dc3 | 1600 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1601 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "format - formata o sistema de arquivos\n\r" ); |
klauss | 45:c80574f24dc3 | 1602 | if( tcp_session ) tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1603 | |
klauss | 45:c80574f24dc3 | 1604 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1605 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1606 | } |
klauss | 45:c80574f24dc3 | 1607 | } |
klauss | 62:07e5bdc9f8f7 | 1608 | */ |
klauss | 45:c80574f24dc3 | 1609 | pc.printf("reset - resta o sistema\n\r"); |
klauss | 45:c80574f24dc3 | 1610 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1611 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "reset - resta o sistema\n\r" ); |
klauss | 78:1353744f01e1 | 1612 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1613 | |
klauss | 45:c80574f24dc3 | 1614 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1615 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1616 | } |
klauss | 45:c80574f24dc3 | 1617 | } |
klauss | 45:c80574f24dc3 | 1618 | pc.printf("ipset [ip] - Configura o IP da cabeceira\n\r"); |
klauss | 45:c80574f24dc3 | 1619 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1620 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ipset [ip] - Configura o IP da cabeceira\n\r" ); |
klauss | 78:1353744f01e1 | 1621 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1622 | |
klauss | 45:c80574f24dc3 | 1623 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1624 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1625 | } |
klauss | 45:c80574f24dc3 | 1626 | } |
klauss | 45:c80574f24dc3 | 1627 | pc.printf("extset [ext] - Configura a ext da cabeceira\n\r"); |
klauss | 45:c80574f24dc3 | 1628 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1629 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "extset [ext] - Configura a ext da cabeceira\n\r" ); |
klauss | 78:1353744f01e1 | 1630 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1631 | |
klauss | 45:c80574f24dc3 | 1632 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1633 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1634 | } |
klauss | 45:c80574f24dc3 | 1635 | } |
klauss | 45:c80574f24dc3 | 1636 | pc.printf("msipport [port] - Configura a porta SIP da cabeceira\n\r"); |
klauss | 45:c80574f24dc3 | 1637 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1638 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "msipport [port] - Configura a porta SIP da cabeceira\n\r" ); |
klauss | 78:1353744f01e1 | 1639 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1640 | |
klauss | 45:c80574f24dc3 | 1641 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1642 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1643 | } |
klauss | 45:c80574f24dc3 | 1644 | } |
klauss | 45:c80574f24dc3 | 1645 | pc.printf("serverip [ip] - Configura o ip do servidor asterisk\n\r"); |
klauss | 45:c80574f24dc3 | 1646 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1647 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "serverip [ip] - Configura o ip do servidor asterisk\n\r" ); |
klauss | 78:1353744f01e1 | 1648 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1649 | |
klauss | 45:c80574f24dc3 | 1650 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1651 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1652 | } |
klauss | 45:c80574f24dc3 | 1653 | } |
klauss | 45:c80574f24dc3 | 1654 | pc.printf("serextset [ext] - Configura a server ext da cabeceira\n\r"); |
klauss | 45:c80574f24dc3 | 1655 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1656 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "serextset [ext] - Configura a server ext da cabeceira\n\r" ); |
klauss | 78:1353744f01e1 | 1657 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1658 | |
klauss | 45:c80574f24dc3 | 1659 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1660 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1661 | } |
klauss | 45:c80574f24dc3 | 1662 | } |
klauss | 45:c80574f24dc3 | 1663 | pc.printf("ssport [port] - Configura a porta SIP do servidor asterisk\n\r"); |
klauss | 45:c80574f24dc3 | 1664 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1665 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ssport [port] - Configura a porta SIP do servidor asterisk\n\r" ); |
klauss | 78:1353744f01e1 | 1666 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1667 | |
klauss | 45:c80574f24dc3 | 1668 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1669 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1670 | } |
klauss | 45:c80574f24dc3 | 1671 | } |
klauss | 45:c80574f24dc3 | 1672 | pc.printf("maskset [mask] - Configura a mascara da cabeceira\n\r"); |
klauss | 45:c80574f24dc3 | 1673 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1674 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "maskset [mask] - Configura a mascara da cabeceira\n\r" ); |
klauss | 78:1353744f01e1 | 1675 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1676 | |
klauss | 45:c80574f24dc3 | 1677 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1678 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1679 | } |
klauss | 45:c80574f24dc3 | 1680 | } |
klauss | 45:c80574f24dc3 | 1681 | pc.printf("gatewayset [gateway] - Configura o gateway da cabeceira\n\r"); |
klauss | 45:c80574f24dc3 | 1682 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1683 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "gatewayset [gateway] - Configura o gateway da cabeceira\n\r" ); |
klauss | 78:1353744f01e1 | 1684 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1685 | |
klauss | 45:c80574f24dc3 | 1686 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1687 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1688 | } |
klauss | 45:c80574f24dc3 | 1689 | } |
klauss | 56:c64bcbaa621a | 1690 | pc.printf("telemetry_ip - Configura o IP do servidor de telemetria\n\r"); |
klauss | 56:c64bcbaa621a | 1691 | if( from_eth ){ |
klauss | 56:c64bcbaa621a | 1692 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "telemetry_ip - Configura o IP do servidor de telemetria\n\r" ); |
klauss | 78:1353744f01e1 | 1693 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 56:c64bcbaa621a | 1694 | |
klauss | 56:c64bcbaa621a | 1695 | else if( udp_request ){ |
klauss | 56:c64bcbaa621a | 1696 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 56:c64bcbaa621a | 1697 | } |
klauss | 56:c64bcbaa621a | 1698 | } |
klauss | 62:07e5bdc9f8f7 | 1699 | pc.printf("telemetry_port - Configura a port do servidor de telemetria\n\r"); |
klauss | 56:c64bcbaa621a | 1700 | if( from_eth ){ |
klauss | 62:07e5bdc9f8f7 | 1701 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "telemetry_port - Configura a port do servidor de telemetria\n\r" ); |
klauss | 78:1353744f01e1 | 1702 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 56:c64bcbaa621a | 1703 | |
klauss | 56:c64bcbaa621a | 1704 | else if( udp_request ){ |
klauss | 56:c64bcbaa621a | 1705 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 56:c64bcbaa621a | 1706 | } |
klauss | 56:c64bcbaa621a | 1707 | } |
klauss | 56:c64bcbaa621a | 1708 | |
klauss | 81:3656f00ab3db | 1709 | pc.printf("maxext - Configura o maior ramal possivel de ser registrado nesse ramo\n\r"); |
klauss | 81:3656f00ab3db | 1710 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1711 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "maxext - Configura o maior ramal possivel de ser registrado nesse ramo\n\r" ); |
klauss | 81:3656f00ab3db | 1712 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 81:3656f00ab3db | 1713 | |
klauss | 81:3656f00ab3db | 1714 | else if( udp_request ){ |
klauss | 81:3656f00ab3db | 1715 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 81:3656f00ab3db | 1716 | } |
klauss | 81:3656f00ab3db | 1717 | } |
klauss | 81:3656f00ab3db | 1718 | |
klauss | 81:3656f00ab3db | 1719 | pc.printf("minext - Configura o menor ramal possivel de ser registrado nesse ramo\n\r"); |
klauss | 81:3656f00ab3db | 1720 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1721 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "minext - Configura o menor ramal possivel de ser registrado nesse ramo\n\r" ); |
klauss | 81:3656f00ab3db | 1722 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 81:3656f00ab3db | 1723 | |
klauss | 81:3656f00ab3db | 1724 | else if( udp_request ){ |
klauss | 81:3656f00ab3db | 1725 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 81:3656f00ab3db | 1726 | } |
klauss | 81:3656f00ab3db | 1727 | } |
klauss | 81:3656f00ab3db | 1728 | |
klauss | 45:c80574f24dc3 | 1729 | pc.printf("showcb - lista os Cbx registrados na header\n\r"); |
klauss | 45:c80574f24dc3 | 1730 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1731 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "showcb - lista os Cbx registrados na header\n\r" ); |
klauss | 78:1353744f01e1 | 1732 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1733 | |
klauss | 45:c80574f24dc3 | 1734 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1735 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1736 | } |
klauss | 45:c80574f24dc3 | 1737 | } |
klauss | 63:0d95da692bb4 | 1738 | /* |
klauss | 48:195c97f12e8e | 1739 | pc.printf("status - lista resumida de cbx registrados na header\n\r"); |
klauss | 48:195c97f12e8e | 1740 | if( from_eth ){ |
klauss | 48:195c97f12e8e | 1741 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "showcb - lista resumida de cbx registrados na header\n\r" ); |
klauss | 48:195c97f12e8e | 1742 | if( tcp_session ) tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 48:195c97f12e8e | 1743 | |
klauss | 48:195c97f12e8e | 1744 | else if( udp_request ){ |
klauss | 48:195c97f12e8e | 1745 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 48:195c97f12e8e | 1746 | } |
klauss | 48:195c97f12e8e | 1747 | } |
klauss | 63:0d95da692bb4 | 1748 | */ |
klauss | 45:c80574f24dc3 | 1749 | pc.printf("cks - exibe estatisticas de check sum\n\r"); |
klauss | 45:c80574f24dc3 | 1750 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1751 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "cks - exibe estatisticas de check sum\n\r" ); |
klauss | 78:1353744f01e1 | 1752 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1753 | |
klauss | 45:c80574f24dc3 | 1754 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1755 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1756 | } |
klauss | 45:c80574f24dc3 | 1757 | } |
klauss | 52:12930cef17c4 | 1758 | pc.printf("reset_cks - reseta estatisticas de check sum\n\r"); |
klauss | 52:12930cef17c4 | 1759 | if( from_eth ){ |
klauss | 52:12930cef17c4 | 1760 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "reset_cks - reseta estatisticas de check sum\n\r" ); |
klauss | 78:1353744f01e1 | 1761 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 52:12930cef17c4 | 1762 | |
klauss | 52:12930cef17c4 | 1763 | else if( udp_request ){ |
klauss | 52:12930cef17c4 | 1764 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 52:12930cef17c4 | 1765 | } |
klauss | 52:12930cef17c4 | 1766 | } |
klauss | 52:12930cef17c4 | 1767 | |
klauss | 45:c80574f24dc3 | 1768 | pc.printf(". - executa o comando anterior novamente\n\r"); |
klauss | 45:c80574f24dc3 | 1769 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1770 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, ". - executa o comando anterior novamente\n\r" ); |
klauss | 78:1353744f01e1 | 1771 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1772 | |
klauss | 45:c80574f24dc3 | 1773 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1774 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1775 | } |
klauss | 45:c80574f24dc3 | 1776 | } |
klauss | 45:c80574f24dc3 | 1777 | pc.printf("debug [on|off|show] - seleciona debugs gerais | lista de debugs \n\r"); |
klauss | 45:c80574f24dc3 | 1778 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1779 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "debug [on|off|show] - seleciona debugs gerais | lista de debugs \n\r" ); |
klauss | 78:1353744f01e1 | 1780 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1781 | |
klauss | 45:c80574f24dc3 | 1782 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1783 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1784 | } |
klauss | 45:c80574f24dc3 | 1785 | } |
klauss | 62:07e5bdc9f8f7 | 1786 | pc.printf("{ flood [ on | off ] | [+|-] } - simula envio de pacotes de audio\n\r"); |
klauss | 45:c80574f24dc3 | 1787 | if( from_eth ){ |
klauss | 62:07e5bdc9f8f7 | 1788 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "{ flood [ on | off ] | [+|-] } - simula envio de pacotes de audio\n\r"); |
klauss | 78:1353744f01e1 | 1789 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 62:07e5bdc9f8f7 | 1790 | |
klauss | 62:07e5bdc9f8f7 | 1791 | else if( udp_request ){ |
klauss | 62:07e5bdc9f8f7 | 1792 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 62:07e5bdc9f8f7 | 1793 | } |
klauss | 62:07e5bdc9f8f7 | 1794 | } |
klauss | 65:0b653cfe95db | 1795 | |
klauss | 65:0b653cfe95db | 1796 | pc.printf("silence <start_ext end_ext> - envia comando de flood off para os ramais no intervalo end_ext - start_ext\n\r"); |
klauss | 65:0b653cfe95db | 1797 | if( from_eth ){ |
klauss | 65:0b653cfe95db | 1798 | 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 | 78:1353744f01e1 | 1799 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 65:0b653cfe95db | 1800 | |
klauss | 65:0b653cfe95db | 1801 | else if( udp_request ){ |
klauss | 65:0b653cfe95db | 1802 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 65:0b653cfe95db | 1803 | } |
klauss | 65:0b653cfe95db | 1804 | } |
klauss | 65:0b653cfe95db | 1805 | |
klauss | 62:07e5bdc9f8f7 | 1806 | pc.printf("++ ext - Header flood on, ext flood on\n\r"); |
klauss | 62:07e5bdc9f8f7 | 1807 | if( from_eth ){ |
klauss | 62:07e5bdc9f8f7 | 1808 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "++ ext - Header flood on, ext flood on\n\r"); |
klauss | 78:1353744f01e1 | 1809 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1810 | |
klauss | 45:c80574f24dc3 | 1811 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1812 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1813 | } |
klauss | 45:c80574f24dc3 | 1814 | } |
klauss | 66:3f1d22e69e7b | 1815 | |
klauss | 66:3f1d22e69e7b | 1816 | pc.printf("-- ext - Header flood off, ext flood off\n\r"); |
klauss | 66:3f1d22e69e7b | 1817 | if( from_eth ){ |
klauss | 66:3f1d22e69e7b | 1818 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "++ ext - Header flood on, ext flood on\n\r"); |
klauss | 78:1353744f01e1 | 1819 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 66:3f1d22e69e7b | 1820 | |
klauss | 66:3f1d22e69e7b | 1821 | else if( udp_request ){ |
klauss | 66:3f1d22e69e7b | 1822 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 66:3f1d22e69e7b | 1823 | } |
klauss | 66:3f1d22e69e7b | 1824 | } |
klauss | 66:3f1d22e69e7b | 1825 | |
klauss | 64:5b011d5707d2 | 1826 | pc.printf("rx - Exibe ultimo pacote recebido dos CBx\n\r"); |
klauss | 64:5b011d5707d2 | 1827 | if( from_eth ){ |
klauss | 64:5b011d5707d2 | 1828 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "rx - Exibe ultimo pacote recebido dos CBx\n\r"); |
klauss | 78:1353744f01e1 | 1829 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 64:5b011d5707d2 | 1830 | |
klauss | 64:5b011d5707d2 | 1831 | else if( udp_request ){ |
klauss | 64:5b011d5707d2 | 1832 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 64:5b011d5707d2 | 1833 | } |
klauss | 64:5b011d5707d2 | 1834 | } |
klauss | 64:5b011d5707d2 | 1835 | pc.printf("tx - Exibe ultimo pacote enviado para os CBx\n\r"); |
klauss | 64:5b011d5707d2 | 1836 | if( from_eth ){ |
klauss | 64:5b011d5707d2 | 1837 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "tx - Exibe ultimo pacote enviado para os CBx\n\r"); |
klauss | 78:1353744f01e1 | 1838 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 64:5b011d5707d2 | 1839 | |
klauss | 64:5b011d5707d2 | 1840 | else if( udp_request ){ |
klauss | 64:5b011d5707d2 | 1841 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 64:5b011d5707d2 | 1842 | } |
klauss | 64:5b011d5707d2 | 1843 | } |
klauss | 64:5b011d5707d2 | 1844 | pc.printf("ls | status - Exibe uma lista ordenada por ext do CBx registrados na Header\n\r"); |
klauss | 64:5b011d5707d2 | 1845 | if( from_eth ){ |
klauss | 64:5b011d5707d2 | 1846 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ls | status - Exibe uma lista ordenada por ext do CBx registrados na Header\n\r"); |
klauss | 78:1353744f01e1 | 1847 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 64:5b011d5707d2 | 1848 | |
klauss | 64:5b011d5707d2 | 1849 | else if( udp_request ){ |
klauss | 64:5b011d5707d2 | 1850 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 64:5b011d5707d2 | 1851 | } |
klauss | 64:5b011d5707d2 | 1852 | } |
klauss | 64:5b011d5707d2 | 1853 | pc.printf("types - Lista os types usados no protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 64:5b011d5707d2 | 1854 | if( from_eth ){ |
klauss | 64:5b011d5707d2 | 1855 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "types - Lista os types usados no protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 78:1353744f01e1 | 1856 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 64:5b011d5707d2 | 1857 | |
klauss | 64:5b011d5707d2 | 1858 | else if( udp_request ){ |
klauss | 64:5b011d5707d2 | 1859 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 64:5b011d5707d2 | 1860 | } |
klauss | 64:5b011d5707d2 | 1861 | } |
klauss | 64:5b011d5707d2 | 1862 | pc.printf("protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 64:5b011d5707d2 | 1863 | if( from_eth ){ |
klauss | 64:5b011d5707d2 | 1864 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 78:1353744f01e1 | 1865 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 64:5b011d5707d2 | 1866 | |
klauss | 64:5b011d5707d2 | 1867 | else if( udp_request ){ |
klauss | 64:5b011d5707d2 | 1868 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 64:5b011d5707d2 | 1869 | } |
klauss | 64:5b011d5707d2 | 1870 | } |
klauss | 64:5b011d5707d2 | 1871 | |
klauss | 45:c80574f24dc3 | 1872 | pc.printf("PROMPT VERSION: V%d\n\r",PVERSION); |
klauss | 45:c80574f24dc3 | 1873 | //Obs :: a ultima linha nao mandamos direto pro tcp porque ela eh enviada fora desse escopo |
klauss | 45:c80574f24dc3 | 1874 | if( from_eth ) snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "PROMPT VERSION: V%d\n\r",PVERSION); |
klauss | 27:98f824719d1c | 1875 | } |
klauss | 54:448d57291be6 | 1876 | |
klauss | 58:af7e8788f106 | 1877 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "callme ", 7 )){ |
klauss | 54:448d57291be6 | 1878 | miss_match = false; |
klauss | 54:448d57291be6 | 1879 | int ext,port; |
klauss | 54:448d57291be6 | 1880 | char cmd[ 16 ]; |
klauss | 54:448d57291be6 | 1881 | |
klauss | 54:448d57291be6 | 1882 | ext = atoi( debug_buf + 7 ); |
klauss | 54:448d57291be6 | 1883 | port = convert_ext_to_port( ext ); |
klauss | 54:448d57291be6 | 1884 | |
klauss | 67:cdedc64d9921 | 1885 | strcpy( cmd, ( ext % 2 ) ? "call init B" : "call init A" ); |
klauss | 67:cdedc64d9921 | 1886 | |
klauss | 67:cdedc64d9921 | 1887 | if( ext % 2 ) ext--; |
klauss | 54:448d57291be6 | 1888 | |
klauss | 54:448d57291be6 | 1889 | promptcb_last_ext = ext; |
klauss | 54:448d57291be6 | 1890 | promptcb_last_port = port; |
klauss | 54:448d57291be6 | 1891 | |
klauss | 62:07e5bdc9f8f7 | 1892 | int tmp = strlen( cmd ); |
klauss | 62:07e5bdc9f8f7 | 1893 | cmd[ tmp ] = 0x0D; |
klauss | 62:07e5bdc9f8f7 | 1894 | cmd[ tmp + 1 ] = 0x00; |
klauss | 62:07e5bdc9f8f7 | 1895 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 62:07e5bdc9f8f7 | 1896 | |
klauss | 54:448d57291be6 | 1897 | pc.printf("\r\next=%d port=%d\r\ncmd=%s\r\n", ext, port, cmd ); |
klauss | 67:cdedc64d9921 | 1898 | |
klauss | 67:cdedc64d9921 | 1899 | pc.printf("\n\r--------------------------------------------------------\n\r"); |
klauss | 67:cdedc64d9921 | 1900 | for( uint16_t i = 0; i < strlen( cmd ) ; i++ ) pc.printf( "%02x ", cmd[ i ] ); |
klauss | 67:cdedc64d9921 | 1901 | |
klauss | 74:81c47fff88a5 | 1902 | send2callboxes( __build_cb_package__( ext, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 67:cdedc64d9921 | 1903 | pc.printf("\n\r--------------------------------------------------------\n\r"); |
klauss | 67:cdedc64d9921 | 1904 | for( uint16_t i = 0; i < 300 ; i++ ){ |
klauss | 67:cdedc64d9921 | 1905 | pc.printf( "%02x ", write_buffer[ i ] ); |
klauss | 67:cdedc64d9921 | 1906 | if( i != 0 && !( ( i + 1 ) % 30 ) ) pc.printf("\n\r"); |
klauss | 67:cdedc64d9921 | 1907 | } |
klauss | 67:cdedc64d9921 | 1908 | |
klauss | 67:cdedc64d9921 | 1909 | |
klauss | 62:07e5bdc9f8f7 | 1910 | pc.printf("\n\rComando enviado\n\r"); |
klauss | 54:448d57291be6 | 1911 | |
klauss | 54:448d57291be6 | 1912 | if( from_eth ){ |
klauss | 62:07e5bdc9f8f7 | 1913 | char eth_msg[ 512 ]; |
klauss | 62:07e5bdc9f8f7 | 1914 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d\r\ncmd=%s\r\n\n\rComando enviado\n\r", ext, port, cmd ); |
klauss | 62:07e5bdc9f8f7 | 1915 | if( tcp_session ){ |
klauss | 62:07e5bdc9f8f7 | 1916 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 62:07e5bdc9f8f7 | 1917 | }else if( udp_request ){ |
klauss | 62:07e5bdc9f8f7 | 1918 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 62:07e5bdc9f8f7 | 1919 | } |
klauss | 19:ab2088e0dec6 | 1920 | } |
klauss | 54:448d57291be6 | 1921 | |
klauss | 54:448d57291be6 | 1922 | bufptr = 0; |
klauss | 67:cdedc64d9921 | 1923 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 45:c80574f24dc3 | 1924 | } |
klauss | 45:c80574f24dc3 | 1925 | |
klauss | 45:c80574f24dc3 | 1926 | if( miss_match ){ |
klauss | 48:195c97f12e8e | 1927 | pc.printf("\n\r> %s: command not found\n\r", debug_buf ); |
klauss | 45:c80574f24dc3 | 1928 | if( from_eth ){ |
klauss | 48:195c97f12e8e | 1929 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "> %s: command not found\n ", debug_buf ); |
klauss | 58:af7e8788f106 | 1930 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1931 | } |
klauss | 45:c80574f24dc3 | 1932 | } |
klauss | 45:c80574f24dc3 | 1933 | else{ |
klauss | 58:af7e8788f106 | 1934 | if( from_eth && strlen( debug_buf ) > 2 ) strcpy( last_cmd, tmp_cmd ); |
klauss | 58:af7e8788f106 | 1935 | |
klauss | 58:af7e8788f106 | 1936 | else if( strlen( debug_buf ) > 2 ) strcpy( last_cmd, tmp_cmd ); |
klauss | 45:c80574f24dc3 | 1937 | } |
klauss | 48:195c97f12e8e | 1938 | } |
klauss | 45:c80574f24dc3 | 1939 | if( b == 0x0D || bufret == 1 || bufptr > DEBUGBUFSIZE ){ |
klauss | 45:c80574f24dc3 | 1940 | bufret = 0; |
klauss | 57:78f7191a8b69 | 1941 | if( from_eth ){ |
klauss | 57:78f7191a8b69 | 1942 | from_eth = false; |
klauss | 57:78f7191a8b69 | 1943 | |
klauss | 48:195c97f12e8e | 1944 | if( debug_buf[ strlen( debug_buf ) - 1 ] == '\r' || debug_buf[ strlen( debug_buf ) - 1 ] == '\n' ) strcat( debug_buf, "> " ); |
klauss | 48:195c97f12e8e | 1945 | |
klauss | 48:195c97f12e8e | 1946 | else strcat( debug_buf, "\n\r> " ); |
klauss | 48:195c97f12e8e | 1947 | |
klauss | 57:78f7191a8b69 | 1948 | if( tcp_session ){ |
klauss | 57:78f7191a8b69 | 1949 | |
klauss | 57:78f7191a8b69 | 1950 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 57:78f7191a8b69 | 1951 | |
klauss | 57:78f7191a8b69 | 1952 | }else if( udp_request ){ |
klauss | 48:195c97f12e8e | 1953 | |
klauss | 57:78f7191a8b69 | 1954 | int sent = udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 48:195c97f12e8e | 1955 | |
klauss | 57:78f7191a8b69 | 1956 | udp_request = false; |
klauss | 57:78f7191a8b69 | 1957 | } |
klauss | 57:78f7191a8b69 | 1958 | for( register uint16_t i = 0; i < __PROMPT_ETH_BUFFER_SIZE__; i++ ) eth_buffer[ i ] = 0; |
klauss | 57:78f7191a8b69 | 1959 | debug_buf = __debug_buf__; |
klauss | 57:78f7191a8b69 | 1960 | bufptr = last_bufptr; |
klauss | 45:c80574f24dc3 | 1961 | }else{ |
klauss | 42:480335bdde12 | 1962 | bufptr = 0; |
klauss | 58:af7e8788f106 | 1963 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 45:c80574f24dc3 | 1964 | } |
klauss | 45:c80574f24dc3 | 1965 | pc.putc(0x0A); |
klauss | 45:c80574f24dc3 | 1966 | pc.putc(0x0D); |
klauss | 45:c80574f24dc3 | 1967 | pc.printf("> "); |
klauss | 45:c80574f24dc3 | 1968 | } |
klauss | 36:728498a78e1e | 1969 | return( NULL ); |
klauss | 54:448d57291be6 | 1970 | } |