![](/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@82:f55d13babca0, 2014-12-30 (annotated)
- Committer:
- klauss
- Date:
- Tue Dec 30 21:00:00 2014 +0000
- Revision:
- 82:f55d13babca0
- Parent:
- 81:3656f00ab3db
- Child:
- 89:0fe315117b00
pequena correcao de bug relacionado ao tratamento de pacotes de bye do cbx.
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 | 45:c80574f24dc3 | 468 | tcp_server.set_blocking( false, 1 ); |
klauss | 45:c80574f24dc3 | 469 | udp_server.set_blocking( false, 2 ); |
klauss | 78:1353744f01e1 | 470 | udp_server.bind( UDP_PORT_LISTENER ); |
klauss | 81:3656f00ab3db | 471 | pc.printf("******* Prompt eth Ready *******\n\r"); |
klauss | 19:ab2088e0dec6 | 472 | } |
klauss | 19:ab2088e0dec6 | 473 | |
klauss | 28:94aec56c6329 | 474 | // main prompt process |
klauss | 48:195c97f12e8e | 475 | char * prompt_process( char * msg_from_cb ){ |
klauss | 28:94aec56c6329 | 476 | //FIXME dar flush na serial |
klauss | 19:ab2088e0dec6 | 477 | volatile char b = 0; |
klauss | 19:ab2088e0dec6 | 478 | static uint8_t bufret = 0; |
klauss | 30:8dfb6d8de53d | 479 | static Timer flood_timeout; |
klauss | 60:b4ec6beb3be3 | 480 | static Timer flood_silence_timer; |
klauss | 60:b4ec6beb3be3 | 481 | static uint8_t id_msg = 0x10; |
klauss | 60:b4ec6beb3be3 | 482 | static int start_ext, end_ext, ext_count; |
klauss | 36:728498a78e1e | 483 | bool miss_match = true; |
klauss | 57:78f7191a8b69 | 484 | char eth_buffer[ __PROMPT_ETH_BUFFER_SIZE__ ]; |
klauss | 60:b4ec6beb3be3 | 485 | uint8_t write_buffer[ __CB_BUFFER_SIZE__ ]; |
klauss | 57:78f7191a8b69 | 486 | |
klauss | 45:c80574f24dc3 | 487 | if( flood_timeout.read() > 60 ){ |
klauss | 45:c80574f24dc3 | 488 | pflood = 0; |
klauss | 45:c80574f24dc3 | 489 | flood_timeout.stop(); |
klauss | 45:c80574f24dc3 | 490 | flood_timeout.reset(); |
klauss | 45:c80574f24dc3 | 491 | } |
klauss | 78:1353744f01e1 | 492 | |
klauss | 53:bb492a8f115a | 493 | if( tcp_timer.read() >= TCP_IDLE_MAX_TIME ){ |
klauss | 78:1353744f01e1 | 494 | bool close_tcp = true; |
klauss | 78:1353744f01e1 | 495 | //if( tcp_alive && ( tcp_timer.read() < TCP_ALIVE_IDLE_MAX_TIME ) ){ |
klauss | 78:1353744f01e1 | 496 | // close_tcp = false; |
klauss | 78:1353744f01e1 | 497 | //} |
klauss | 78:1353744f01e1 | 498 | if( close_tcp ){ |
klauss | 78:1353744f01e1 | 499 | tcp_alive = false; |
klauss | 78:1353744f01e1 | 500 | tcp_timer.stop(); |
klauss | 78:1353744f01e1 | 501 | tcp_timer.reset(); |
klauss | 78:1353744f01e1 | 502 | tcp_session = false; |
klauss | 78:1353744f01e1 | 503 | debug_buf = __debug_buf__; |
klauss | 78:1353744f01e1 | 504 | bufptr = last_bufptr; |
klauss | 78:1353744f01e1 | 505 | bufret = 0; |
klauss | 78:1353744f01e1 | 506 | from_eth = false; |
klauss | 78:1353744f01e1 | 507 | tcp_client.close(); |
klauss | 78:1353744f01e1 | 508 | return( NULL ); |
klauss | 78:1353744f01e1 | 509 | } |
klauss | 53:bb492a8f115a | 510 | } |
klauss | 48:195c97f12e8e | 511 | if( !tcp_server.accept( tcp_client ) ){ |
klauss | 48:195c97f12e8e | 512 | tcp_session = true; |
klauss | 53:bb492a8f115a | 513 | tcp_timer.start(); |
klauss | 48:195c97f12e8e | 514 | last_bufptr = bufptr; |
klauss | 53:bb492a8f115a | 515 | eth_buffer[ 0 ] = 0; |
klauss | 48:195c97f12e8e | 516 | bufret = 0; |
klauss | 48:195c97f12e8e | 517 | } |
klauss | 53:bb492a8f115a | 518 | if( tcp_session ){ |
klauss | 57:78f7191a8b69 | 519 | //if( !( (int)tcp_timer.read_ms() % 100 ) ){ |
klauss | 53:bb492a8f115a | 520 | tcp_client.set_blocking( false, 1 ); |
klauss | 53:bb492a8f115a | 521 | int n = tcp_client.receive( eth_buffer, sizeof( eth_buffer ) - 1 ); |
klauss | 53:bb492a8f115a | 522 | if( n > 0 ){ |
klauss | 48:195c97f12e8e | 523 | tcp_timer.reset(); |
klauss | 53:bb492a8f115a | 524 | |
klauss | 53:bb492a8f115a | 525 | if( ( n > 2 ) && ( eth_buffer[ n - 2 ] == '\r' ) ) eth_buffer[ n - 2 ] = 0; |
klauss | 53:bb492a8f115a | 526 | |
klauss | 53:bb492a8f115a | 527 | if( ( n > 1 ) && ( eth_buffer[ n - 1 ] == '\n' ) ) eth_buffer[ n - 1 ] = 0; |
klauss | 53:bb492a8f115a | 528 | |
klauss | 53:bb492a8f115a | 529 | if( ( n == 1 ) && eth_buffer[ 0 ] == 0x0A ) strcpy( eth_buffer, "\r" ); |
klauss | 53:bb492a8f115a | 530 | |
klauss | 53:bb492a8f115a | 531 | //if( eth_buffer[ 0 ] == '\r' || eth_buffer[ 1 ] == '\n' || eth_buffer[ 2 ] == 'r' || eth_buffer[ 2 ] == '\n' ) strcpy( eth_buffer, "\r" ); |
klauss | 62:07e5bdc9f8f7 | 532 | |
klauss | 53:bb492a8f115a | 533 | bufptr = strlen( eth_buffer ); |
klauss | 53:bb492a8f115a | 534 | debug_buf = eth_buffer; |
klauss | 53:bb492a8f115a | 535 | from_eth = true; |
klauss | 53:bb492a8f115a | 536 | bufret = 1; |
klauss | 53:bb492a8f115a | 537 | |
klauss | 53:bb492a8f115a | 538 | if( !( strcmp( eth_buffer, "quit" ) ) ){ |
klauss | 53:bb492a8f115a | 539 | tcp_timer.reset(); |
klauss | 53:bb492a8f115a | 540 | debug_buf = __debug_buf__; |
klauss | 53:bb492a8f115a | 541 | bufptr = last_bufptr; |
klauss | 53:bb492a8f115a | 542 | from_eth = false; |
klauss | 53:bb492a8f115a | 543 | tcp_session = false; |
klauss | 53:bb492a8f115a | 544 | tcp_client.close(); |
klauss | 53:bb492a8f115a | 545 | bufret = 0; |
klauss | 53:bb492a8f115a | 546 | return( NULL ); |
klauss | 82:f55d13babca0 | 547 | } |
klauss | 82:f55d13babca0 | 548 | /*else if( !( strcmp( eth_buffer, "alive" ) ) ){ |
klauss | 79:9bc12aa305a9 | 549 | char wake_msg[ 8 ]; |
klauss | 81:3656f00ab3db | 550 | external_wdt = EXTERN_WDT_IDLE; |
klauss | 81:3656f00ab3db | 551 | strcpy( wake_msg, "wakeup\n" ); |
klauss | 81:3656f00ab3db | 552 | while( !( tcp_client.send_all( wake_msg, strlen( wake_msg ) ) ) ); |
klauss | 81:3656f00ab3db | 553 | strcpy( eth_buffer, "0" ); |
klauss | 81:3656f00ab3db | 554 | bufret = 0; |
klauss | 53:bb492a8f115a | 555 | } |
klauss | 82:f55d13babca0 | 556 | */ |
klauss | 53:bb492a8f115a | 557 | }else{ |
klauss | 48:195c97f12e8e | 558 | debug_buf = __debug_buf__; |
klauss | 48:195c97f12e8e | 559 | bufptr = last_bufptr; |
klauss | 57:78f7191a8b69 | 560 | from_eth = false; |
klauss | 45:c80574f24dc3 | 561 | } |
klauss | 57:78f7191a8b69 | 562 | //} |
klauss | 53:bb492a8f115a | 563 | } |
klauss | 57:78f7191a8b69 | 564 | |
klauss | 53:bb492a8f115a | 565 | if( !from_eth ){ |
klauss | 57:78f7191a8b69 | 566 | if( pc.readable() ){ |
klauss | 53:bb492a8f115a | 567 | // imput do teclado |
klauss | 53:bb492a8f115a | 568 | b = pc.getc(); |
klauss | 53:bb492a8f115a | 569 | if( b == 0x0D ){ // enter |
klauss | 53:bb492a8f115a | 570 | bufret = 1; |
klauss | 53:bb492a8f115a | 571 | }else{ |
klauss | 53:bb492a8f115a | 572 | pc.putc( b ); |
klauss | 53:bb492a8f115a | 573 | if( b == 0x08 || b == 0x7F ){ // BS | DEL |
klauss | 53:bb492a8f115a | 574 | if( bufptr > 0 ) debug_buf[ --bufptr ] = 0; |
klauss | 53:bb492a8f115a | 575 | }else if( b == 0x09 ){ |
klauss | 53:bb492a8f115a | 576 | // ignore tab |
klauss | 53:bb492a8f115a | 577 | }else{ |
klauss | 53:bb492a8f115a | 578 | debug_buf[bufptr] = b; |
klauss | 53:bb492a8f115a | 579 | bufptr++; |
klauss | 42:480335bdde12 | 580 | } |
klauss | 31:bb5fb28a77df | 581 | } |
klauss | 53:bb492a8f115a | 582 | } |
klauss | 48:195c97f12e8e | 583 | } |
klauss | 53:bb492a8f115a | 584 | |
klauss | 48:195c97f12e8e | 585 | if( msg_from_cb ){ |
klauss | 48:195c97f12e8e | 586 | if( tcp_session ){ |
klauss | 48:195c97f12e8e | 587 | tcp_client.send_all( msg_from_cb, strlen( msg_from_cb ) ); |
klauss | 48:195c97f12e8e | 588 | }else if( udp_request ){ |
klauss | 48:195c97f12e8e | 589 | udp_server.sendTo( udp_client, msg_from_cb, strlen( msg_from_cb ) ); |
klauss | 48:195c97f12e8e | 590 | } |
klauss | 48:195c97f12e8e | 591 | pc.printf( "\n\r%s\n\r", msg_from_cb ); |
klauss | 45:c80574f24dc3 | 592 | } |
klauss | 60:b4ec6beb3be3 | 593 | |
klauss | 60:b4ec6beb3be3 | 594 | if( flood_silence ){ |
klauss | 60:b4ec6beb3be3 | 595 | if( flood_silence_timer.read_ms() > 250 ){ |
klauss | 60:b4ec6beb3be3 | 596 | char cmd[ 16 ] = "flood off"; |
klauss | 60:b4ec6beb3be3 | 597 | int str_end = strlen( cmd ); |
klauss | 60:b4ec6beb3be3 | 598 | cmd[ str_end ] = 0x0D; |
klauss | 60:b4ec6beb3be3 | 599 | cmd[ str_end + 1 ] = 0x00; |
klauss | 60:b4ec6beb3be3 | 600 | |
klauss | 60:b4ec6beb3be3 | 601 | int port = convert_ext_to_port( ext_count ); |
klauss | 74:81c47fff88a5 | 602 | send2callboxes( __build_cb_package__( ext_count, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 60:b4ec6beb3be3 | 603 | pc.printf("\r\nSilence sent to ext=%d port=%d", ext_count, port ); |
klauss | 60:b4ec6beb3be3 | 604 | |
klauss | 60:b4ec6beb3be3 | 605 | if( tcp_session ){ |
klauss | 60:b4ec6beb3be3 | 606 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\nSilence sent to ext=%d port=%d", ext_count, port ); |
klauss | 60:b4ec6beb3be3 | 607 | //eth_buffer[ strlen( eth_buffer ) - 1 ] = '\0'; |
klauss | 60:b4ec6beb3be3 | 608 | |
klauss | 60:b4ec6beb3be3 | 609 | tcp_client.send_all( eth_buffer, strlen( eth_buffer ) ); |
klauss | 60:b4ec6beb3be3 | 610 | }else if( udp_request ){ |
klauss | 60:b4ec6beb3be3 | 611 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\nSilence sent to ext=%d port=%d", ext_count, port ); |
klauss | 60:b4ec6beb3be3 | 612 | //eth_buffer[ strlen( eth_buffer ) - 1 ] = '\0'; |
klauss | 60:b4ec6beb3be3 | 613 | |
klauss | 60:b4ec6beb3be3 | 614 | udp_server.sendTo( udp_client, eth_buffer, strlen( eth_buffer ) ); |
klauss | 60:b4ec6beb3be3 | 615 | } |
klauss | 60:b4ec6beb3be3 | 616 | flood_silence_timer.reset(); |
klauss | 60:b4ec6beb3be3 | 617 | |
klauss | 60:b4ec6beb3be3 | 618 | if( ++ext_count > end_ext ){ |
klauss | 60:b4ec6beb3be3 | 619 | flood_silence = false; |
klauss | 60:b4ec6beb3be3 | 620 | flood_silence_timer.stop(); |
klauss | 60:b4ec6beb3be3 | 621 | flood_silence_timer.reset(); |
klauss | 60:b4ec6beb3be3 | 622 | |
klauss | 60:b4ec6beb3be3 | 623 | pc.printf("\r\n> " ); |
klauss | 60:b4ec6beb3be3 | 624 | if( tcp_session ){ |
klauss | 60:b4ec6beb3be3 | 625 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\n> " ); |
klauss | 60:b4ec6beb3be3 | 626 | tcp_client.send_all( eth_buffer, strlen( eth_buffer ) ); |
klauss | 60:b4ec6beb3be3 | 627 | }else if( udp_request ){ |
klauss | 60:b4ec6beb3be3 | 628 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\n> " ); |
klauss | 60:b4ec6beb3be3 | 629 | udp_server.sendTo( udp_client, eth_buffer, strlen( eth_buffer ) ); |
klauss | 60:b4ec6beb3be3 | 630 | } |
klauss | 60:b4ec6beb3be3 | 631 | } |
klauss | 60:b4ec6beb3be3 | 632 | } |
klauss | 60:b4ec6beb3be3 | 633 | } |
klauss | 65:0b653cfe95db | 634 | |
klauss | 65:0b653cfe95db | 635 | if( delayed_flood ){ |
klauss | 65:0b653cfe95db | 636 | tflood.start(); |
klauss | 65:0b653cfe95db | 637 | tflood.reset(); |
klauss | 65:0b653cfe95db | 638 | floodcount =0; |
klauss | 65:0b653cfe95db | 639 | pflood = 1; |
klauss | 65:0b653cfe95db | 640 | flood_timeout.start(); |
klauss | 65:0b653cfe95db | 641 | delayed_flood = false; |
klauss | 65:0b653cfe95db | 642 | pc.printf("\n\rFlood ON\n\r"); |
klauss | 65:0b653cfe95db | 643 | if( from_eth ){ |
klauss | 65:0b653cfe95db | 644 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r" ); |
klauss | 65:0b653cfe95db | 645 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 65:0b653cfe95db | 646 | } |
klauss | 65:0b653cfe95db | 647 | } |
klauss | 45:c80574f24dc3 | 648 | |
klauss | 45:c80574f24dc3 | 649 | // Prompt commands here |
klauss | 58:af7e8788f106 | 650 | if ( bufret == 1 ) { |
klauss | 45:c80574f24dc3 | 651 | static unsigned int promptcb_last_ext = 0; |
klauss | 45:c80574f24dc3 | 652 | static unsigned int promptcb_last_port = 0; |
klauss | 55:2f5e7374af9d | 653 | static char promptcb_last_cmd[ 300 ]; |
klauss | 60:b4ec6beb3be3 | 654 | |
klauss | 58:af7e8788f106 | 655 | strcpy( tmp_cmd, debug_buf ); |
klauss | 59:e1e300880d2d | 656 | if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "." ) ){ |
klauss | 45:c80574f24dc3 | 657 | miss_match = false; |
klauss | 58:af7e8788f106 | 658 | strcpy( debug_buf, last_cmd ); |
klauss | 58:af7e8788f106 | 659 | strcpy( tmp_cmd, debug_buf ); |
klauss | 59:e1e300880d2d | 660 | }else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "+" ) ){ |
klauss | 59:e1e300880d2d | 661 | miss_match = false; |
klauss | 59:e1e300880d2d | 662 | strcpy( debug_buf, "flood on" ); |
klauss | 59:e1e300880d2d | 663 | strcpy( tmp_cmd, debug_buf ); |
klauss | 59:e1e300880d2d | 664 | }else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "-" ) ){ |
klauss | 59:e1e300880d2d | 665 | miss_match = false; |
klauss | 59:e1e300880d2d | 666 | strcpy( debug_buf, "flood off" ); |
klauss | 59:e1e300880d2d | 667 | strcpy( tmp_cmd, debug_buf ); |
klauss | 59:e1e300880d2d | 668 | }else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "++ ", 3 ) ){ |
klauss | 59:e1e300880d2d | 669 | miss_match = false; |
klauss | 65:0b653cfe95db | 670 | delayed_flood = true; |
klauss | 59:e1e300880d2d | 671 | int ext = atoi( debug_buf + 3 ); |
klauss | 59:e1e300880d2d | 672 | sprintf( debug_buf, "pcb %i flood on", ext ); |
klauss | 59:e1e300880d2d | 673 | }else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "-- ", 3 ) ){ |
klauss | 59:e1e300880d2d | 674 | miss_match = false; |
klauss | 59:e1e300880d2d | 675 | int ext = atoi( debug_buf + 3 ); |
klauss | 59:e1e300880d2d | 676 | pc.printf("\n\rFlood OFF\n\r"); |
klauss | 59:e1e300880d2d | 677 | if( from_eth ){ |
klauss | 59:e1e300880d2d | 678 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood OFF\n\r" ); |
klauss | 59:e1e300880d2d | 679 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 59:e1e300880d2d | 680 | } |
klauss | 59:e1e300880d2d | 681 | pflood = 0; |
klauss | 59:e1e300880d2d | 682 | tflood.stop(); |
klauss | 59:e1e300880d2d | 683 | flood_timeout.reset(); |
klauss | 60:b4ec6beb3be3 | 684 | sprintf( debug_buf, "pcb %i flood off", ext ); |
klauss | 45:c80574f24dc3 | 685 | } |
klauss | 45:c80574f24dc3 | 686 | |
klauss | 48:195c97f12e8e | 687 | //tratamento dos enters |
klauss | 45:c80574f24dc3 | 688 | if( !bufptr ){ |
klauss | 45:c80574f24dc3 | 689 | miss_match = false; |
klauss | 48:195c97f12e8e | 690 | }else if( bufptr == 1 ) { |
klauss | 48:195c97f12e8e | 691 | if( debug_buf[ 0 ] == 0x0D || debug_buf[ 0 ] == 0x0D ) miss_match = false; |
klauss | 48:195c97f12e8e | 692 | } |
klauss | 48:195c97f12e8e | 693 | |
klauss | 45:c80574f24dc3 | 694 | if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ifconfig" ) ){ |
klauss | 45:c80574f24dc3 | 695 | miss_match = false; |
klauss | 45:c80574f24dc3 | 696 | pc.printf("\n\r"); |
klauss | 45:c80574f24dc3 | 697 | files('s'); |
klauss | 45:c80574f24dc3 | 698 | } |
klauss | 62:07e5bdc9f8f7 | 699 | |
klauss | 63:0d95da692bb4 | 700 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "rx" ) ){ |
klauss | 62:07e5bdc9f8f7 | 701 | miss_match = false; |
klauss | 62:07e5bdc9f8f7 | 702 | rx = true; |
klauss | 62:07e5bdc9f8f7 | 703 | } |
klauss | 62:07e5bdc9f8f7 | 704 | |
klauss | 63:0d95da692bb4 | 705 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "tx" ) ){ |
klauss | 63:0d95da692bb4 | 706 | miss_match = false; |
klauss | 63:0d95da692bb4 | 707 | tx = true; |
klauss | 63:0d95da692bb4 | 708 | } |
klauss | 63:0d95da692bb4 | 709 | |
klauss | 63:0d95da692bb4 | 710 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "stats" ) ){ |
klauss | 63:0d95da692bb4 | 711 | miss_match = false; |
klauss | 63:0d95da692bb4 | 712 | stats = true; |
klauss | 63:0d95da692bb4 | 713 | } |
klauss | 63:0d95da692bb4 | 714 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_stats" ) ){ |
klauss | 63:0d95da692bb4 | 715 | miss_match = false; |
klauss | 63:0d95da692bb4 | 716 | r_stats = true; |
klauss | 63:0d95da692bb4 | 717 | } |
klauss | 63:0d95da692bb4 | 718 | |
klauss | 59:e1e300880d2d | 719 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "format" ) ){ |
klauss | 45:c80574f24dc3 | 720 | miss_match = false; |
klauss | 50:d9b6577a70f5 | 721 | pc.printf("\n\rFormatando o sistema de arquivos... espere o sistema reiniciar\n\r"); |
klauss | 62:07e5bdc9f8f7 | 722 | |
klauss | 45:c80574f24dc3 | 723 | if( from_eth ){ |
klauss | 62:07e5bdc9f8f7 | 724 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Not Allowed\n\r"); |
klauss | 62:07e5bdc9f8f7 | 725 | }else{ |
klauss | 62:07e5bdc9f8f7 | 726 | files('e'); |
klauss | 62:07e5bdc9f8f7 | 727 | files('w'); |
klauss | 62:07e5bdc9f8f7 | 728 | __disable_irq(); |
klauss | 62:07e5bdc9f8f7 | 729 | NVIC_SystemReset(); |
klauss | 42:480335bdde12 | 730 | } |
klauss | 45:c80574f24dc3 | 731 | } |
klauss | 45:c80574f24dc3 | 732 | |
klauss | 59:e1e300880d2d | 733 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ipset ", 6 )) { |
klauss | 45:c80574f24dc3 | 734 | miss_match = false; |
klauss | 54:448d57291be6 | 735 | set_ip( debug_buf + 6 ); |
klauss | 45:c80574f24dc3 | 736 | files('s'); |
klauss | 45:c80574f24dc3 | 737 | } |
klauss | 45:c80574f24dc3 | 738 | |
klauss | 59:e1e300880d2d | 739 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "extset ", 7 ) ){ |
klauss | 45:c80574f24dc3 | 740 | miss_match = false; |
klauss | 55:2f5e7374af9d | 741 | set_header_ext( atoi( debug_buf + 7 ) ); |
klauss | 45:c80574f24dc3 | 742 | files('s'); |
klauss | 45:c80574f24dc3 | 743 | } |
klauss | 45:c80574f24dc3 | 744 | |
klauss | 59:e1e300880d2d | 745 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serextset ", 10 ) ){ |
klauss | 45:c80574f24dc3 | 746 | miss_match = false; |
klauss | 55:2f5e7374af9d | 747 | set_server_ext( atoi( debug_buf + 10 ) ); |
klauss | 45:c80574f24dc3 | 748 | files('s'); |
klauss | 45:c80574f24dc3 | 749 | } |
klauss | 45:c80574f24dc3 | 750 | |
klauss | 59:e1e300880d2d | 751 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "maskset ",8 ) ){ |
klauss | 45:c80574f24dc3 | 752 | miss_match = false; |
klauss | 55:2f5e7374af9d | 753 | set_mask( debug_buf + 8 ); |
klauss | 45:c80574f24dc3 | 754 | files('s'); |
klauss | 45:c80574f24dc3 | 755 | } |
klauss | 45:c80574f24dc3 | 756 | |
klauss | 59:e1e300880d2d | 757 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "gatewayset ",11 ) ){ |
klauss | 45:c80574f24dc3 | 758 | miss_match = false; |
klauss | 55:2f5e7374af9d | 759 | set_gateway( debug_buf + 11 ); |
klauss | 45:c80574f24dc3 | 760 | files('s'); |
klauss | 45:c80574f24dc3 | 761 | } |
klauss | 45:c80574f24dc3 | 762 | |
klauss | 59:e1e300880d2d | 763 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "msipport ",9 ) ){ |
klauss | 45:c80574f24dc3 | 764 | miss_match = false; |
klauss | 55:2f5e7374af9d | 765 | set_header_sip_port( atoi( debug_buf + 9 ) ); |
klauss | 45:c80574f24dc3 | 766 | files('s'); |
klauss | 45:c80574f24dc3 | 767 | } |
klauss | 45:c80574f24dc3 | 768 | |
klauss | 59:e1e300880d2d | 769 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serverip ",9 ) ){ |
klauss | 45:c80574f24dc3 | 770 | miss_match = false; |
klauss | 55:2f5e7374af9d | 771 | set_server_ip( debug_buf + 9 ); |
klauss | 45:c80574f24dc3 | 772 | files('s'); |
klauss | 45:c80574f24dc3 | 773 | } |
klauss | 81:3656f00ab3db | 774 | |
klauss | 81:3656f00ab3db | 775 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "maxext ", 7 ) ){ |
klauss | 81:3656f00ab3db | 776 | miss_match = false; |
klauss | 81:3656f00ab3db | 777 | set_max_ext( atoi( debug_buf + 7 ) ); |
klauss | 81:3656f00ab3db | 778 | files('s'); |
klauss | 81:3656f00ab3db | 779 | } |
klauss | 81:3656f00ab3db | 780 | |
klauss | 81:3656f00ab3db | 781 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "minext ", 7 ) ){ |
klauss | 81:3656f00ab3db | 782 | miss_match = false; |
klauss | 81:3656f00ab3db | 783 | set_min_ext( atoi( debug_buf + 7 ) ); |
klauss | 81:3656f00ab3db | 784 | files('s'); |
klauss | 81:3656f00ab3db | 785 | } |
klauss | 45:c80574f24dc3 | 786 | |
klauss | 81:3656f00ab3db | 787 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ssport ", 7 ) ){ |
klauss | 45:c80574f24dc3 | 788 | miss_match = false; |
klauss | 55:2f5e7374af9d | 789 | set_server_port( atoi( debug_buf + 7 ) ); |
klauss | 45:c80574f24dc3 | 790 | files('s'); |
klauss | 45:c80574f24dc3 | 791 | } |
klauss | 45:c80574f24dc3 | 792 | |
klauss | 59:e1e300880d2d | 793 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "telemetry_ip ", 13 ) ){ |
klauss | 56:c64bcbaa621a | 794 | miss_match = false; |
klauss | 56:c64bcbaa621a | 795 | set_telemetry_ip( debug_buf + 13 ); |
klauss | 56:c64bcbaa621a | 796 | files('s'); |
klauss | 56:c64bcbaa621a | 797 | } |
klauss | 56:c64bcbaa621a | 798 | |
klauss | 59:e1e300880d2d | 799 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "telemetry_port ", 15 ) ){ |
klauss | 56:c64bcbaa621a | 800 | miss_match = false; |
klauss | 56:c64bcbaa621a | 801 | set_telemetry_port( atoi( debug_buf + 15 ) ); |
klauss | 56:c64bcbaa621a | 802 | files('s'); |
klauss | 56:c64bcbaa621a | 803 | } |
klauss | 45:c80574f24dc3 | 804 | |
klauss | 59:e1e300880d2d | 805 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dconfig" ) ){ |
klauss | 45:c80574f24dc3 | 806 | miss_match = false; |
klauss | 50:d9b6577a70f5 | 807 | files('e'); |
klauss | 45:c80574f24dc3 | 808 | files('w'); |
klauss | 45:c80574f24dc3 | 809 | files('s'); |
klauss | 45:c80574f24dc3 | 810 | } |
klauss | 45:c80574f24dc3 | 811 | |
klauss | 59:e1e300880d2d | 812 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset" ) ){ |
klauss | 45:c80574f24dc3 | 813 | miss_match = false; |
klauss | 45:c80574f24dc3 | 814 | pc.printf("\n\rJob is done\n\r"); |
klauss | 45:c80574f24dc3 | 815 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 816 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Job is done\n\r"); |
klauss | 45:c80574f24dc3 | 817 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 818 | if( tcp_session ){ |
klauss | 45:c80574f24dc3 | 819 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 820 | tcp_client.close(); |
klauss | 45:c80574f24dc3 | 821 | }else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 822 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 42:480335bdde12 | 823 | } |
klauss | 45:c80574f24dc3 | 824 | } |
klauss | 48:195c97f12e8e | 825 | __disable_irq(); |
klauss | 45:c80574f24dc3 | 826 | NVIC_SystemReset(); |
klauss | 45:c80574f24dc3 | 827 | } |
klauss | 45:c80574f24dc3 | 828 | |
klauss | 59:e1e300880d2d | 829 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dog" ) ){ |
klauss | 45:c80574f24dc3 | 830 | miss_match = false; |
klauss | 45:c80574f24dc3 | 831 | pc.printf("\n\r MUUUUUUUuuuuUUUUUU - I'm not a dog!!!! \n\r"); |
klauss | 45:c80574f24dc3 | 832 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 833 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "MUUUUUUUuuuuUUUUUU - I'm not a dog!!!!\n\r"); |
klauss | 67:cdedc64d9921 | 834 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 835 | } |
klauss | 45:c80574f24dc3 | 836 | } |
klauss | 48:195c97f12e8e | 837 | |
klauss | 62:07e5bdc9f8f7 | 838 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ls" ) ){ |
klauss | 62:07e5bdc9f8f7 | 839 | miss_match = false; |
klauss | 62:07e5bdc9f8f7 | 840 | list = true; |
klauss | 62:07e5bdc9f8f7 | 841 | } |
klauss | 62:07e5bdc9f8f7 | 842 | |
klauss | 81:3656f00ab3db | 843 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ls -l" ) ){ |
klauss | 81:3656f00ab3db | 844 | miss_match = false; |
klauss | 81:3656f00ab3db | 845 | long_list = true; |
klauss | 81:3656f00ab3db | 846 | } |
klauss | 81:3656f00ab3db | 847 | |
klauss | 59:e1e300880d2d | 848 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "tt" ) ){ |
klauss | 53:bb492a8f115a | 849 | miss_match = false; |
klauss | 62:07e5bdc9f8f7 | 850 | main_test = !main_test; |
klauss | 53:bb492a8f115a | 851 | } |
klauss | 53:bb492a8f115a | 852 | |
klauss | 59:e1e300880d2d | 853 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_cks" ) ){ |
klauss | 52:12930cef17c4 | 854 | miss_match = false; |
klauss | 52:12930cef17c4 | 855 | reset_cks = true; |
klauss | 52:12930cef17c4 | 856 | } |
klauss | 52:12930cef17c4 | 857 | |
klauss | 64:5b011d5707d2 | 858 | //replaced by ls |
klauss | 59:e1e300880d2d | 859 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "status" ) ){ |
klauss | 48:195c97f12e8e | 860 | miss_match = false; |
klauss | 64:5b011d5707d2 | 861 | list = true; |
klauss | 64:5b011d5707d2 | 862 | } |
klauss | 64:5b011d5707d2 | 863 | |
klauss | 81:3656f00ab3db | 864 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "wdt" ) ){ |
klauss | 81:3656f00ab3db | 865 | miss_match = false; |
klauss | 81:3656f00ab3db | 866 | debug_wdt = true; |
klauss | 81:3656f00ab3db | 867 | } |
klauss | 81:3656f00ab3db | 868 | |
klauss | 81:3656f00ab3db | 869 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "eth" ) ){ |
klauss | 81:3656f00ab3db | 870 | miss_match = false; |
klauss | 81:3656f00ab3db | 871 | debug_eth = true; |
klauss | 81:3656f00ab3db | 872 | } |
klauss | 81:3656f00ab3db | 873 | |
klauss | 64:5b011d5707d2 | 874 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "types" ) ){ |
klauss | 64:5b011d5707d2 | 875 | miss_match = false; |
klauss | 64:5b011d5707d2 | 876 | |
klauss | 64:5b011d5707d2 | 877 | 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 | 878 | |
klauss | 64:5b011d5707d2 | 879 | if( from_eth ){ |
klauss | 64:5b011d5707d2 | 880 | 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 | 881 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 64:5b011d5707d2 | 882 | } |
klauss | 48:195c97f12e8e | 883 | } |
klauss | 64:5b011d5707d2 | 884 | |
klauss | 64:5b011d5707d2 | 885 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "protocol" ) ){ |
klauss | 64:5b011d5707d2 | 886 | miss_match = false; |
klauss | 64:5b011d5707d2 | 887 | |
klauss | 64:5b011d5707d2 | 888 | 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 | 889 | |
klauss | 64:5b011d5707d2 | 890 | if( from_eth ){ |
klauss | 64:5b011d5707d2 | 891 | 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 | 892 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 64:5b011d5707d2 | 893 | } |
klauss | 64:5b011d5707d2 | 894 | } |
klauss | 64:5b011d5707d2 | 895 | |
klauss | 60:b4ec6beb3be3 | 896 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "flood ", 6 ) ){ |
klauss | 60:b4ec6beb3be3 | 897 | if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on", 2 ) ){ |
klauss | 45:c80574f24dc3 | 898 | miss_match = false; |
klauss | 46:a670f187a704 | 899 | pc.printf("\n\rFlood ON\n\r"); |
klauss | 42:480335bdde12 | 900 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 901 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r" ); |
klauss | 45:c80574f24dc3 | 902 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 42:480335bdde12 | 903 | } |
klauss | 45:c80574f24dc3 | 904 | tflood.start(); |
klauss | 45:c80574f24dc3 | 905 | tflood.reset(); |
klauss | 45:c80574f24dc3 | 906 | floodcount =0; |
klauss | 45:c80574f24dc3 | 907 | pflood = 1; |
klauss | 45:c80574f24dc3 | 908 | flood_timeout.start(); |
klauss | 45:c80574f24dc3 | 909 | } |
klauss | 61:06e77dff6f00 | 910 | |
klauss | 61:06e77dff6f00 | 911 | if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "more", 4 ) ){ |
klauss | 61:06e77dff6f00 | 912 | miss_match = false; |
klauss | 61:06e77dff6f00 | 913 | pc.printf("\n\rFlood ON\n\r"); |
klauss | 61:06e77dff6f00 | 914 | if( from_eth ){ |
klauss | 61:06e77dff6f00 | 915 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r" ); |
klauss | 61:06e77dff6f00 | 916 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 61:06e77dff6f00 | 917 | } |
klauss | 61:06e77dff6f00 | 918 | tflood.start(); |
klauss | 61:06e77dff6f00 | 919 | tflood.reset(); |
klauss | 61:06e77dff6f00 | 920 | floodcount = 0; |
klauss | 61:06e77dff6f00 | 921 | pflood = 1; |
klauss | 61:06e77dff6f00 | 922 | } |
klauss | 61:06e77dff6f00 | 923 | |
klauss | 60:b4ec6beb3be3 | 924 | if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "off", 3 )) { |
klauss | 45:c80574f24dc3 | 925 | miss_match = false; |
klauss | 46:a670f187a704 | 926 | pc.printf("\n\rFlood OFF\n\r"); |
klauss | 42:480335bdde12 | 927 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 928 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood Off\n\r" ); |
klauss | 45:c80574f24dc3 | 929 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 42:480335bdde12 | 930 | } |
klauss | 45:c80574f24dc3 | 931 | pflood = 0; |
klauss | 45:c80574f24dc3 | 932 | tflood.stop(); |
klauss | 45:c80574f24dc3 | 933 | flood_timeout.reset(); |
klauss | 31:bb5fb28a77df | 934 | } |
klauss | 60:b4ec6beb3be3 | 935 | }else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "silence ", 8 ) ){ |
klauss | 60:b4ec6beb3be3 | 936 | miss_match = false; |
klauss | 60:b4ec6beb3be3 | 937 | char *ref, *split; |
klauss | 60:b4ec6beb3be3 | 938 | |
klauss | 60:b4ec6beb3be3 | 939 | strcpy( promptcb_last_cmd, debug_buf ); |
klauss | 60:b4ec6beb3be3 | 940 | |
klauss | 65:0b653cfe95db | 941 | if( !( strcmp( debug_buf + 8, "-h" ) && strcmp( debug_buf + 8, "--help" ) ) ){ |
klauss | 65:0b653cfe95db | 942 | 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 | 943 | |
klauss | 65:0b653cfe95db | 944 | if( tcp_session ){ |
klauss | 65:0b653cfe95db | 945 | 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 | 946 | } |
klauss | 65:0b653cfe95db | 947 | }else{ |
klauss | 65:0b653cfe95db | 948 | ref = debug_buf; |
klauss | 65:0b653cfe95db | 949 | |
klauss | 65:0b653cfe95db | 950 | split = strtok( debug_buf + 8, " " ); |
klauss | 65:0b653cfe95db | 951 | |
klauss | 65:0b653cfe95db | 952 | start_ext = atoi( split ); |
klauss | 65:0b653cfe95db | 953 | |
klauss | 65:0b653cfe95db | 954 | split += strlen( split ) + 1; |
klauss | 65:0b653cfe95db | 955 | |
klauss | 65:0b653cfe95db | 956 | end_ext = atoi( split ); |
klauss | 60:b4ec6beb3be3 | 957 | |
klauss | 65:0b653cfe95db | 958 | debug_buf = ref; |
klauss | 65:0b653cfe95db | 959 | |
klauss | 65:0b653cfe95db | 960 | if( start_ext < end_ext && ( end_ext - start_ext ) < 50 ){ |
klauss | 65:0b653cfe95db | 961 | if( start_ext % 2 ) start_ext--; |
klauss | 65:0b653cfe95db | 962 | if( !( end_ext % 2 ) ) end_ext++; |
klauss | 65:0b653cfe95db | 963 | |
klauss | 65:0b653cfe95db | 964 | ext_count = start_ext; |
klauss | 65:0b653cfe95db | 965 | flood_silence_timer.start(); |
klauss | 65:0b653cfe95db | 966 | }else{ |
klauss | 65:0b653cfe95db | 967 | 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 | 968 | |
klauss | 65:0b653cfe95db | 969 | if( tcp_session ){ |
klauss | 65:0b653cfe95db | 970 | 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 | 971 | } |
klauss | 48:195c97f12e8e | 972 | } |
klauss | 65:0b653cfe95db | 973 | flood_silence = true; |
klauss | 48:195c97f12e8e | 974 | } |
klauss | 45:c80574f24dc3 | 975 | } |
klauss | 45:c80574f24dc3 | 976 | |
klauss | 60:b4ec6beb3be3 | 977 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug ",6 ) ){ |
klauss | 45:c80574f24dc3 | 978 | if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on",2 )) { |
klauss | 45:c80574f24dc3 | 979 | miss_match = false; |
klauss | 46:a670f187a704 | 980 | pc.printf("\n\rDebug ON\n\r"); |
klauss | 45:c80574f24dc3 | 981 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 982 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug On\n\r" ); |
klauss | 45:c80574f24dc3 | 983 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 984 | } |
klauss | 78:1353744f01e1 | 985 | debug_alive = true; |
klauss | 45:c80574f24dc3 | 986 | } |
klauss | 45:c80574f24dc3 | 987 | if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 988 | miss_match = false; |
klauss | 46:a670f187a704 | 989 | pc.printf("\n\rDebug OFF\n\r"); |
klauss | 45:c80574f24dc3 | 990 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 991 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Off\n\r" ); |
klauss | 45:c80574f24dc3 | 992 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 42:480335bdde12 | 993 | } |
klauss | 78:1353744f01e1 | 994 | debug_alive = false; |
klauss | 31:bb5fb28a77df | 995 | } |
klauss | 45:c80574f24dc3 | 996 | if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "show",4 ) ){ |
klauss | 45:c80574f24dc3 | 997 | miss_match = false; |
klauss | 50:d9b6577a70f5 | 998 | pc.printf("\n\rdsip"); |
klauss | 45:c80574f24dc3 | 999 | pc.printf("\n\rdebug_alive"); |
klauss | 45:c80574f24dc3 | 1000 | pc.printf("\n\rdebug_prompt"); |
klauss | 45:c80574f24dc3 | 1001 | pc.printf("\n\rdebug_vector"); |
klauss | 45:c80574f24dc3 | 1002 | pc.printf("\n\rdebug_cb"); |
klauss | 45:c80574f24dc3 | 1003 | pc.printf("\n\rdebug_main"); |
klauss | 78:1353744f01e1 | 1004 | pc.printf("\n\rdcks"); |
klauss | 45:c80574f24dc3 | 1005 | pc.printf("\n\rdebug_cb_rx"); |
klauss | 45:c80574f24dc3 | 1006 | pc.printf("\n\rdebug_cb_tx*"); |
klauss | 45:c80574f24dc3 | 1007 | pc.printf("\n\rdebug_eth_rx*"); |
klauss | 45:c80574f24dc3 | 1008 | pc.printf("\n\rdebug_eth_tx*"); |
klauss | 45:c80574f24dc3 | 1009 | pc.printf("\n\rdebug_file"); |
klauss | 45:c80574f24dc3 | 1010 | |
klauss | 42:480335bdde12 | 1011 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1012 | 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 | 1013 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 42:480335bdde12 | 1014 | } |
klauss | 42:480335bdde12 | 1015 | } |
klauss | 45:c80574f24dc3 | 1016 | } |
klauss | 45:c80574f24dc3 | 1017 | |
klauss | 78:1353744f01e1 | 1018 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dsip ", 5 ) ){ |
klauss | 78:1353744f01e1 | 1019 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ){ |
klauss | 45:c80574f24dc3 | 1020 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1021 | pc.printf( "\n\rSip Debug ON\n\r" ); |
klauss | 45:c80574f24dc3 | 1022 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1023 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Sip Debug On\n\r" ); |
klauss | 45:c80574f24dc3 | 1024 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1025 | } |
klauss | 78:1353744f01e1 | 1026 | debug_sip = true; |
klauss | 45:c80574f24dc3 | 1027 | } |
klauss | 50:d9b6577a70f5 | 1028 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 1029 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1030 | pc.printf( "\n\rSip Debug OFF\n\r" ); |
klauss | 45:c80574f24dc3 | 1031 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1032 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Sip Debug Off\n\r" ); |
klauss | 45:c80574f24dc3 | 1033 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1034 | } |
klauss | 78:1353744f01e1 | 1035 | debug_sip = false; |
klauss | 78:1353744f01e1 | 1036 | } |
klauss | 78:1353744f01e1 | 1037 | } |
klauss | 78:1353744f01e1 | 1038 | |
klauss | 81:3656f00ab3db | 1039 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dmuted ", 7 ) ){ |
klauss | 81:3656f00ab3db | 1040 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ |
klauss | 81:3656f00ab3db | 1041 | miss_match = false; |
klauss | 81:3656f00ab3db | 1042 | pc.printf( "\n\rMuted Debug ON\n\r" ); |
klauss | 81:3656f00ab3db | 1043 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1044 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Muted Debug On\n\r" ); |
klauss | 81:3656f00ab3db | 1045 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1046 | } |
klauss | 81:3656f00ab3db | 1047 | debug_muted = true; |
klauss | 81:3656f00ab3db | 1048 | } |
klauss | 81:3656f00ab3db | 1049 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { |
klauss | 81:3656f00ab3db | 1050 | miss_match = false; |
klauss | 81:3656f00ab3db | 1051 | pc.printf( "\n\rMuted Debug OFF\n\r" ); |
klauss | 81:3656f00ab3db | 1052 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1053 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Muted Debug Off\n\r" ); |
klauss | 81:3656f00ab3db | 1054 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1055 | } |
klauss | 81:3656f00ab3db | 1056 | debug_muted = false; |
klauss | 81:3656f00ab3db | 1057 | } |
klauss | 81:3656f00ab3db | 1058 | } |
klauss | 81:3656f00ab3db | 1059 | |
klauss | 81:3656f00ab3db | 1060 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dwdt ", 5 ) ){ |
klauss | 81:3656f00ab3db | 1061 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ){ |
klauss | 81:3656f00ab3db | 1062 | miss_match = false; |
klauss | 81:3656f00ab3db | 1063 | pc.printf( "\n\rWdt Debug ON\n\r" ); |
klauss | 81:3656f00ab3db | 1064 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1065 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wdt Debug On\n\r" ); |
klauss | 81:3656f00ab3db | 1066 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1067 | } |
klauss | 81:3656f00ab3db | 1068 | wdt_show = true; |
klauss | 81:3656f00ab3db | 1069 | } |
klauss | 81:3656f00ab3db | 1070 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) { |
klauss | 81:3656f00ab3db | 1071 | miss_match = false; |
klauss | 81:3656f00ab3db | 1072 | pc.printf( "\n\rWdt Debug OFF\n\r" ); |
klauss | 81:3656f00ab3db | 1073 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1074 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wdt Debug Off\n\r" ); |
klauss | 81:3656f00ab3db | 1075 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1076 | } |
klauss | 81:3656f00ab3db | 1077 | wdt_show = false; |
klauss | 81:3656f00ab3db | 1078 | } |
klauss | 81:3656f00ab3db | 1079 | } |
klauss | 81:3656f00ab3db | 1080 | |
klauss | 81:3656f00ab3db | 1081 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drefresh ", 9 ) ){ |
klauss | 81:3656f00ab3db | 1082 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "on", 2 ) ){ |
klauss | 81:3656f00ab3db | 1083 | miss_match = false; |
klauss | 81:3656f00ab3db | 1084 | pc.printf( "\n\rRefresh Debug ON\n\r" ); |
klauss | 81:3656f00ab3db | 1085 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1086 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Refresh Debug On\n\r" ); |
klauss | 81:3656f00ab3db | 1087 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1088 | } |
klauss | 81:3656f00ab3db | 1089 | debug_refresh= true; |
klauss | 81:3656f00ab3db | 1090 | } |
klauss | 81:3656f00ab3db | 1091 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "off",3 )) { |
klauss | 81:3656f00ab3db | 1092 | miss_match = false; |
klauss | 81:3656f00ab3db | 1093 | pc.printf( "\n\rRefresh Debug OFF\n\r" ); |
klauss | 81:3656f00ab3db | 1094 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1095 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Refresh Debug Off\n\r" ); |
klauss | 81:3656f00ab3db | 1096 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1097 | } |
klauss | 81:3656f00ab3db | 1098 | debug_refresh = false; |
klauss | 81:3656f00ab3db | 1099 | } |
klauss | 81:3656f00ab3db | 1100 | } |
klauss | 81:3656f00ab3db | 1101 | |
klauss | 78:1353744f01e1 | 1102 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dping ", 6 ) ){ |
klauss | 78:1353744f01e1 | 1103 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1104 | miss_match = false; |
klauss | 78:1353744f01e1 | 1105 | pc.printf( "\n\rPing Debug ON\n\r" ); |
klauss | 78:1353744f01e1 | 1106 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1107 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Ping Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1108 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1109 | } |
klauss | 78:1353744f01e1 | 1110 | debug_ping = true; |
klauss | 78:1353744f01e1 | 1111 | } |
klauss | 78:1353744f01e1 | 1112 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1113 | miss_match = false; |
klauss | 78:1353744f01e1 | 1114 | pc.printf( "\n\rPing Debug OFF\n\r" ); |
klauss | 78:1353744f01e1 | 1115 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1116 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Ping Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1117 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1118 | } |
klauss | 78:1353744f01e1 | 1119 | debug_ping= false; |
klauss | 78:1353744f01e1 | 1120 | } |
klauss | 78:1353744f01e1 | 1121 | } |
klauss | 78:1353744f01e1 | 1122 | |
klauss | 78:1353744f01e1 | 1123 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dwu ", 4 ) ){ |
klauss | 78:1353744f01e1 | 1124 | if (xmemmatch( (uint8_t*)(debug_buf + 4 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1125 | miss_match = false; |
klauss | 78:1353744f01e1 | 1126 | pc.printf( "\n\rWake Up Debug ON\n\r" ); |
klauss | 78:1353744f01e1 | 1127 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1128 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wake Up Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1129 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1130 | } |
klauss | 78:1353744f01e1 | 1131 | debug_wake = true; |
klauss | 78:1353744f01e1 | 1132 | } |
klauss | 78:1353744f01e1 | 1133 | if (xmemmatch( (uint8_t*)(debug_buf + 4 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1134 | miss_match = false; |
klauss | 78:1353744f01e1 | 1135 | pc.printf( "\n\rWake Up Debug OFF\n\r" ); |
klauss | 78:1353744f01e1 | 1136 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1137 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wake Up Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1138 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1139 | } |
klauss | 78:1353744f01e1 | 1140 | debug_wake = false; |
klauss | 78:1353744f01e1 | 1141 | } |
klauss | 78:1353744f01e1 | 1142 | } |
klauss | 78:1353744f01e1 | 1143 | |
klauss | 78:1353744f01e1 | 1144 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "tcp_alive ", 10 ) ){ |
klauss | 78:1353744f01e1 | 1145 | if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1146 | miss_match = false; |
klauss | 78:1353744f01e1 | 1147 | pc.printf( "\n\rTCP don't drop mode on\n\r" ); |
klauss | 78:1353744f01e1 | 1148 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1149 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "TCP don't drop mode on\n\r" ); |
klauss | 78:1353744f01e1 | 1150 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1151 | } |
klauss | 78:1353744f01e1 | 1152 | tcp_alive = true; |
klauss | 78:1353744f01e1 | 1153 | } |
klauss | 78:1353744f01e1 | 1154 | if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1155 | miss_match = false; |
klauss | 78:1353744f01e1 | 1156 | pc.printf( "\n\rTCP don't drop mode off\n\r" ); |
klauss | 78:1353744f01e1 | 1157 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1158 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "TCP don't drop mode off\n\r" ); |
klauss | 78:1353744f01e1 | 1159 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1160 | } |
klauss | 78:1353744f01e1 | 1161 | tcp_alive = false; |
klauss | 78:1353744f01e1 | 1162 | } |
klauss | 78:1353744f01e1 | 1163 | } |
klauss | 78:1353744f01e1 | 1164 | |
klauss | 78:1353744f01e1 | 1165 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "daging ",7 ) ){ |
klauss | 78:1353744f01e1 | 1166 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1167 | miss_match = false; |
klauss | 78:1353744f01e1 | 1168 | pc.printf( "\n\rAging Debug ON\n\r" ); |
klauss | 78:1353744f01e1 | 1169 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1170 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Aging Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1171 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1172 | } |
klauss | 78:1353744f01e1 | 1173 | debug_aging = true; |
klauss | 78:1353744f01e1 | 1174 | } |
klauss | 78:1353744f01e1 | 1175 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1176 | miss_match = false; |
klauss | 78:1353744f01e1 | 1177 | pc.printf( "\n\rAging Debug OFF\n\r" ); |
klauss | 78:1353744f01e1 | 1178 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1179 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Aging Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1180 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1181 | } |
klauss | 78:1353744f01e1 | 1182 | debug_aging = false; |
klauss | 78:1353744f01e1 | 1183 | } |
klauss | 78:1353744f01e1 | 1184 | } |
klauss | 78:1353744f01e1 | 1185 | |
klauss | 78:1353744f01e1 | 1186 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcpld ", 6 ) ){ |
klauss | 78:1353744f01e1 | 1187 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1188 | miss_match = false; |
klauss | 78:1353744f01e1 | 1189 | pc.printf( "\n\rDCPLD Debug ON\n\r" ); |
klauss | 78:1353744f01e1 | 1190 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1191 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "DCPLD Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1192 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1193 | } |
klauss | 78:1353744f01e1 | 1194 | debug_cpld = true; |
klauss | 78:1353744f01e1 | 1195 | } |
klauss | 78:1353744f01e1 | 1196 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 ) ){ |
klauss | 78:1353744f01e1 | 1197 | miss_match = false; |
klauss | 78:1353744f01e1 | 1198 | pc.printf( "\n\rDCPLD Debug OFF\n\r" ); |
klauss | 78:1353744f01e1 | 1199 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1200 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "DCPLD Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1201 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1202 | } |
klauss | 78:1353744f01e1 | 1203 | debug_cpld = false; |
klauss | 78:1353744f01e1 | 1204 | } |
klauss | 78:1353744f01e1 | 1205 | } |
klauss | 78:1353744f01e1 | 1206 | |
klauss | 78:1353744f01e1 | 1207 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcks_err ", 9 ) ){ |
klauss | 78:1353744f01e1 | 1208 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1209 | miss_match = false; |
klauss | 78:1353744f01e1 | 1210 | pc.printf( "\n\rCKS_ERR Debug ON\n\r" ); |
klauss | 78:1353744f01e1 | 1211 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1212 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS_ERR Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1213 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1214 | } |
klauss | 78:1353744f01e1 | 1215 | debug_cks_err = true; |
klauss | 78:1353744f01e1 | 1216 | } |
klauss | 78:1353744f01e1 | 1217 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "off", 3 ) ){ |
klauss | 78:1353744f01e1 | 1218 | miss_match = false; |
klauss | 78:1353744f01e1 | 1219 | pc.printf( "\n\rCKS_ERR Debug OFF\n\r" ); |
klauss | 78:1353744f01e1 | 1220 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1221 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS_ERR Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1222 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1223 | } |
klauss | 78:1353744f01e1 | 1224 | debug_cks_err = false; |
klauss | 78:1353744f01e1 | 1225 | } |
klauss | 78:1353744f01e1 | 1226 | } |
klauss | 78:1353744f01e1 | 1227 | |
klauss | 78:1353744f01e1 | 1228 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dinvite ", 8 ) ){ |
klauss | 78:1353744f01e1 | 1229 | if( xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "on", 2 ) ){ |
klauss | 78:1353744f01e1 | 1230 | miss_match = false; |
klauss | 78:1353744f01e1 | 1231 | pc.printf( "\n\rInvite Debug ON\n\r" ); |
klauss | 78:1353744f01e1 | 1232 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1233 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Invite Debug On\n\r" ); |
klauss | 78:1353744f01e1 | 1234 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1235 | } |
klauss | 81:3656f00ab3db | 1236 | debug_invite = true; |
klauss | 78:1353744f01e1 | 1237 | } |
klauss | 78:1353744f01e1 | 1238 | if( xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1239 | miss_match = false; |
klauss | 78:1353744f01e1 | 1240 | pc.printf( "\n\rInvite Debug OFF\n\r" ); |
klauss | 78:1353744f01e1 | 1241 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1242 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Invite Debug Off\n\r" ); |
klauss | 78:1353744f01e1 | 1243 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 78:1353744f01e1 | 1244 | } |
klauss | 78:1353744f01e1 | 1245 | debug_invite = 0; |
klauss | 45:c80574f24dc3 | 1246 | } |
klauss | 45:c80574f24dc3 | 1247 | } |
klauss | 45:c80574f24dc3 | 1248 | |
klauss | 72:895ca792c647 | 1249 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dparallel ", 10 ) ){ |
klauss | 72:895ca792c647 | 1250 | if( xmemmatch( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * )"on", 2 ) ){ |
klauss | 72:895ca792c647 | 1251 | miss_match = false; |
klauss | 72:895ca792c647 | 1252 | pc.printf( "\n\rParallel Write Debug ON\n\r" ); |
klauss | 72:895ca792c647 | 1253 | if( from_eth ){ |
klauss | 72:895ca792c647 | 1254 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rParallel Write Debug ON\n\r" ); |
klauss | 72:895ca792c647 | 1255 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 72:895ca792c647 | 1256 | } |
klauss | 72:895ca792c647 | 1257 | dparallel = true; |
klauss | 72:895ca792c647 | 1258 | } |
klauss | 72:895ca792c647 | 1259 | if( xmemmatch( ( uint8_t * )( debug_buf + 10 ), ( uint8_t *)"off", 3 )) { |
klauss | 72:895ca792c647 | 1260 | miss_match = false; |
klauss | 72:895ca792c647 | 1261 | pc.printf( "\n\rParallel Write Debug OFF\n\r" ); |
klauss | 72:895ca792c647 | 1262 | if( from_eth ){ |
klauss | 72:895ca792c647 | 1263 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rParallel Write Debug OFF\n\r" ); |
klauss | 72:895ca792c647 | 1264 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 72:895ca792c647 | 1265 | } |
klauss | 72:895ca792c647 | 1266 | dparallel = false; |
klauss | 72:895ca792c647 | 1267 | } |
klauss | 72:895ca792c647 | 1268 | } |
klauss | 72:895ca792c647 | 1269 | |
klauss | 78:1353744f01e1 | 1270 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dtelos ", 7 ) ){ |
klauss | 78:1353744f01e1 | 1271 | if (xmemmatch( (uint8_t*)( debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ |
klauss | 53:bb492a8f115a | 1272 | miss_match = false; |
klauss | 53:bb492a8f115a | 1273 | pc.printf( "\n\rTelemetry Debug ON\n\r" ); |
klauss | 53:bb492a8f115a | 1274 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1275 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\rTelemetry Debug On\n\r" ); |
klauss | 53:bb492a8f115a | 1276 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 53:bb492a8f115a | 1277 | } |
klauss | 53:bb492a8f115a | 1278 | debug_telemetry = true; |
klauss | 53:bb492a8f115a | 1279 | } |
klauss | 78:1353744f01e1 | 1280 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off", 3 )) { |
klauss | 53:bb492a8f115a | 1281 | miss_match = false; |
klauss | 78:1353744f01e1 | 1282 | pc.printf( "\n\rTelemetry Debug OFF\n\r" ); |
klauss | 53:bb492a8f115a | 1283 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1284 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\rTelemetry Debug Off\n\r" ); |
klauss | 53:bb492a8f115a | 1285 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 53:bb492a8f115a | 1286 | } |
klauss | 53:bb492a8f115a | 1287 | debug_telemetry = false; |
klauss | 53:bb492a8f115a | 1288 | } |
klauss | 53:bb492a8f115a | 1289 | } |
klauss | 53:bb492a8f115a | 1290 | |
klauss | 78:1353744f01e1 | 1291 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcks ", 5 )) { |
klauss | 50:d9b6577a70f5 | 1292 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on",2 )) { |
klauss | 45:c80574f24dc3 | 1293 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1294 | pc.printf( "\n\rCKS Debug ON\n\r" ); |
klauss | 45:c80574f24dc3 | 1295 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1296 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS Debug On\n\r" ); |
klauss | 45:c80574f24dc3 | 1297 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1298 | } |
klauss | 78:1353744f01e1 | 1299 | debug_cks = true; |
klauss | 45:c80574f24dc3 | 1300 | } |
klauss | 50:d9b6577a70f5 | 1301 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 1302 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1303 | pc.printf( "\n\rCKS Debug OFF\n\r" ); |
klauss | 45:c80574f24dc3 | 1304 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1305 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS Debug Off\n\r" ); |
klauss | 45:c80574f24dc3 | 1306 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1307 | } |
klauss | 78:1353744f01e1 | 1308 | debug_cks = false; |
klauss | 45:c80574f24dc3 | 1309 | } |
klauss | 45:c80574f24dc3 | 1310 | } |
klauss | 45:c80574f24dc3 | 1311 | |
klauss | 78:1353744f01e1 | 1312 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "promptcb ", 9 )) { |
klauss | 78:1353744f01e1 | 1313 | miss_match = false; |
klauss | 78:1353744f01e1 | 1314 | //static uint8_t id_msg = 0x10; |
klauss | 78:1353744f01e1 | 1315 | uint8_t write_buffer[ 300 ]; |
klauss | 78:1353744f01e1 | 1316 | int ext,port; |
klauss | 78:1353744f01e1 | 1317 | char *split, *ref, *cmd; |
klauss | 78:1353744f01e1 | 1318 | |
klauss | 78:1353744f01e1 | 1319 | ref = debug_buf; |
klauss | 78:1353744f01e1 | 1320 | |
klauss | 78:1353744f01e1 | 1321 | strcat( debug_buf, "\r" ); |
klauss | 78:1353744f01e1 | 1322 | |
klauss | 78:1353744f01e1 | 1323 | split = strtok( debug_buf + 9, " " ); |
klauss | 78:1353744f01e1 | 1324 | ext = atoi( split ); |
klauss | 78:1353744f01e1 | 1325 | split = strtok( NULL, " " ); |
klauss | 78:1353744f01e1 | 1326 | port = atoi( split ); |
klauss | 78:1353744f01e1 | 1327 | split += strlen( split ) + 1; |
klauss | 78:1353744f01e1 | 1328 | cmd = split; |
klauss | 78:1353744f01e1 | 1329 | |
klauss | 78:1353744f01e1 | 1330 | promptcb_last_ext = ext; |
klauss | 78:1353744f01e1 | 1331 | promptcb_last_port = port; |
klauss | 78:1353744f01e1 | 1332 | |
klauss | 78:1353744f01e1 | 1333 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 78:1353744f01e1 | 1334 | strcat( cmd, "\r\r\r\n" ); |
klauss | 78:1353744f01e1 | 1335 | |
klauss | 78:1353744f01e1 | 1336 | pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); |
klauss | 78:1353744f01e1 | 1337 | send2callboxes( __build_cb_package__( ext, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 78:1353744f01e1 | 1338 | pc.printf("\n\rComando enviado"); |
klauss | 78:1353744f01e1 | 1339 | |
klauss | 78:1353744f01e1 | 1340 | if( from_eth ){ |
klauss | 78:1353744f01e1 | 1341 | char eth_msg[ 512 ]; |
klauss | 78:1353744f01e1 | 1342 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd ); |
klauss | 78:1353744f01e1 | 1343 | if( tcp_session ){ |
klauss | 78:1353744f01e1 | 1344 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 78:1353744f01e1 | 1345 | }else if( udp_request ){ |
klauss | 78:1353744f01e1 | 1346 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 78:1353744f01e1 | 1347 | } |
klauss | 78:1353744f01e1 | 1348 | } |
klauss | 78:1353744f01e1 | 1349 | |
klauss | 78:1353744f01e1 | 1350 | debug_buf = ref; |
klauss | 78:1353744f01e1 | 1351 | bufptr = 0; |
klauss | 78:1353744f01e1 | 1352 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 78:1353744f01e1 | 1353 | } |
klauss | 78:1353744f01e1 | 1354 | |
klauss | 45:c80574f24dc3 | 1355 | //promptcb ramal porta comando |
klauss | 50:d9b6577a70f5 | 1356 | //FIXME colocar a parte eth de novo |
klauss | 59:e1e300880d2d | 1357 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "pcb ", 4 )) { |
klauss | 45:c80574f24dc3 | 1358 | miss_match = false; |
klauss | 48:195c97f12e8e | 1359 | int ext,port; |
klauss | 54:448d57291be6 | 1360 | char *split, *ref, *cmd; |
klauss | 48:195c97f12e8e | 1361 | |
klauss | 62:07e5bdc9f8f7 | 1362 | ref = debug_buf; |
klauss | 59:e1e300880d2d | 1363 | |
klauss | 74:81c47fff88a5 | 1364 | strcat( debug_buf, "\r" ); |
klauss | 48:195c97f12e8e | 1365 | |
klauss | 48:195c97f12e8e | 1366 | split = strtok( debug_buf + 4, " " ); |
klauss | 48:195c97f12e8e | 1367 | ext = atoi( split ); |
klauss | 50:d9b6577a70f5 | 1368 | |
klauss | 50:d9b6577a70f5 | 1369 | port = convert_ext_to_port( ext ); |
klauss | 48:195c97f12e8e | 1370 | split += strlen( split ) + 1; |
klauss | 54:448d57291be6 | 1371 | cmd = split; |
klauss | 48:195c97f12e8e | 1372 | |
klauss | 48:195c97f12e8e | 1373 | promptcb_last_ext = ext; |
klauss | 48:195c97f12e8e | 1374 | promptcb_last_port = port; |
klauss | 62:07e5bdc9f8f7 | 1375 | |
klauss | 55:2f5e7374af9d | 1376 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 78:1353744f01e1 | 1377 | strcat( cmd, "\r\r\r\n" ); |
klauss | 78:1353744f01e1 | 1378 | |
klauss | 78:1353744f01e1 | 1379 | //send_msg( "Tamanho do cmd == %d", strlen( cmd ) ); |
klauss | 48:195c97f12e8e | 1380 | |
klauss | 78:1353744f01e1 | 1381 | //for( register uint16_t i = strlen( cmd ); i < __CB_BUFFER_SIZE__; i++ ) cmd[ i ] = 0; |
klauss | 78:1353744f01e1 | 1382 | |
klauss | 78:1353744f01e1 | 1383 | pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); |
klauss | 74:81c47fff88a5 | 1384 | send2callboxes( __build_cb_package__( ext, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 78:1353744f01e1 | 1385 | pc.printf("\n\rComando enviado"); |
klauss | 48:195c97f12e8e | 1386 | |
klauss | 54:448d57291be6 | 1387 | if( from_eth ){ |
klauss | 62:07e5bdc9f8f7 | 1388 | char eth_msg[ 512 ]; |
klauss | 78:1353744f01e1 | 1389 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd ); |
klauss | 62:07e5bdc9f8f7 | 1390 | if( tcp_session ){ |
klauss | 62:07e5bdc9f8f7 | 1391 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 62:07e5bdc9f8f7 | 1392 | }else if( udp_request ){ |
klauss | 62:07e5bdc9f8f7 | 1393 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 62:07e5bdc9f8f7 | 1394 | } |
klauss | 54:448d57291be6 | 1395 | } |
klauss | 54:448d57291be6 | 1396 | |
klauss | 48:195c97f12e8e | 1397 | debug_buf = ref; |
klauss | 67:cdedc64d9921 | 1398 | //bufptr = 0; |
klauss | 67:cdedc64d9921 | 1399 | //debug_buf[ 0 ] = 0; |
klauss | 62:07e5bdc9f8f7 | 1400 | bufptr = 0; |
klauss | 67:cdedc64d9921 | 1401 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 45:c80574f24dc3 | 1402 | } |
klauss | 48:195c97f12e8e | 1403 | |
klauss | 59:e1e300880d2d | 1404 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "_pcb",4 )) { |
klauss | 45:c80574f24dc3 | 1405 | miss_match = false; |
klauss | 48:195c97f12e8e | 1406 | debug_buf[ bufptr++ ] = 0x0D; |
klauss | 48:195c97f12e8e | 1407 | debug_buf[ bufptr++ ] = 0x00; |
klauss | 45:c80574f24dc3 | 1408 | |
klauss | 48:195c97f12e8e | 1409 | pc.printf("\r\next=%d port=%d\r\ncmd=%s\r\n",promptcb_last_ext, promptcb_last_port, debug_buf + 4 ); |
klauss | 74:81c47fff88a5 | 1410 | 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 | 1411 | pc.printf("\n\rComando enviado\n\r"); |
klauss | 45:c80574f24dc3 | 1412 | } |
klauss | 62:07e5bdc9f8f7 | 1413 | |
klauss | 58:af7e8788f106 | 1414 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "cks",3 )) { |
klauss | 45:c80574f24dc3 | 1415 | miss_match = false; |
klauss | 81:3656f00ab3db | 1416 | pcks_s = true; |
klauss | 45:c80574f24dc3 | 1417 | } |
klauss | 45:c80574f24dc3 | 1418 | |
klauss | 58:af7e8788f106 | 1419 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "showcb",6 )) { |
klauss | 45:c80574f24dc3 | 1420 | miss_match = false; |
klauss | 81:3656f00ab3db | 1421 | pshowcb = true; |
klauss | 45:c80574f24dc3 | 1422 | } |
klauss | 45:c80574f24dc3 | 1423 | |
klauss | 58:af7e8788f106 | 1424 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_main ", 11 )) { |
klauss | 81:3656f00ab3db | 1425 | if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "on", 2 )) { |
klauss | 45:c80574f24dc3 | 1426 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1427 | pc.printf("\r\nDebug Main ON"); |
klauss | 45:c80574f24dc3 | 1428 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1429 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Main On\n\r" ); |
klauss | 45:c80574f24dc3 | 1430 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1431 | } |
klauss | 81:3656f00ab3db | 1432 | debug_main = true; |
klauss | 45:c80574f24dc3 | 1433 | } |
klauss | 81:3656f00ab3db | 1434 | if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "off", 3 )) { |
klauss | 45:c80574f24dc3 | 1435 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1436 | pc.printf("\r\nDebug Main OFF"); |
klauss | 45:c80574f24dc3 | 1437 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1438 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Main Off\n\r" ); |
klauss | 45:c80574f24dc3 | 1439 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1440 | } |
klauss | 45:c80574f24dc3 | 1441 | debug_main = 0; |
klauss | 45:c80574f24dc3 | 1442 | } |
klauss | 45:c80574f24dc3 | 1443 | } |
klauss | 45:c80574f24dc3 | 1444 | |
klauss | 81:3656f00ab3db | 1445 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dout ", 5 ) ){ |
klauss | 81:3656f00ab3db | 1446 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "on", 2 ) ){ |
klauss | 81:3656f00ab3db | 1447 | miss_match = false; |
klauss | 81:3656f00ab3db | 1448 | pc.printf("\r\nOut Debug ON"); |
klauss | 81:3656f00ab3db | 1449 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1450 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Out Debug On\n\r" ); |
klauss | 81:3656f00ab3db | 1451 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1452 | } |
klauss | 81:3656f00ab3db | 1453 | debug_out_of_range = true; |
klauss | 81:3656f00ab3db | 1454 | } |
klauss | 81:3656f00ab3db | 1455 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "off", 3 ) ){ |
klauss | 81:3656f00ab3db | 1456 | miss_match = false; |
klauss | 81:3656f00ab3db | 1457 | pc.printf("\r\nOut Debug OFF"); |
klauss | 81:3656f00ab3db | 1458 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1459 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Out Debug Off\n\r" ); |
klauss | 81:3656f00ab3db | 1460 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 81:3656f00ab3db | 1461 | } |
klauss | 81:3656f00ab3db | 1462 | debug_out_of_range = false; |
klauss | 81:3656f00ab3db | 1463 | } |
klauss | 81:3656f00ab3db | 1464 | } |
klauss | 81:3656f00ab3db | 1465 | |
klauss | 58:af7e8788f106 | 1466 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_cb_rx ", 12 )) { |
klauss | 45:c80574f24dc3 | 1467 | if (xmemmatch( (uint8_t*)( debug_buf + 12 ), (uint8_t*) "on",2 )) { |
klauss | 45:c80574f24dc3 | 1468 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1469 | pc.printf("\tDebug Cbx Rx ON"); |
klauss | 45:c80574f24dc3 | 1470 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1471 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Cbx On Rx on\n\r" ); |
klauss | 45:c80574f24dc3 | 1472 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1473 | } |
klauss | 81:3656f00ab3db | 1474 | debug_cb_rx = true; |
klauss | 45:c80574f24dc3 | 1475 | } |
klauss | 45:c80574f24dc3 | 1476 | if (xmemmatch( (uint8_t*)( debug_buf + 12 ), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 1477 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1478 | pc.printf("Debug Cbx Rx OFF"); |
klauss | 45:c80574f24dc3 | 1479 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1480 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Cbx Rx Off\n\r" ); |
klauss | 45:c80574f24dc3 | 1481 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1482 | } |
klauss | 45:c80574f24dc3 | 1483 | debug_cb_rx = 0; |
klauss | 45:c80574f24dc3 | 1484 | } |
klauss | 45:c80574f24dc3 | 1485 | } |
klauss | 45:c80574f24dc3 | 1486 | |
klauss | 58:af7e8788f106 | 1487 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_file ", 11 )) { |
klauss | 45:c80574f24dc3 | 1488 | if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "on",2 )) { |
klauss | 45:c80574f24dc3 | 1489 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1490 | pc.printf("\tDebug File ON"); |
klauss | 45:c80574f24dc3 | 1491 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1492 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug File On\n\r" ); |
klauss | 45:c80574f24dc3 | 1493 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1494 | } |
klauss | 81:3656f00ab3db | 1495 | debug_cb_rx = true; |
klauss | 45:c80574f24dc3 | 1496 | } |
klauss | 45:c80574f24dc3 | 1497 | if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 1498 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1499 | pc.printf("Debug File OFF"); |
klauss | 45:c80574f24dc3 | 1500 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1501 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug File Off\n\r" ); |
klauss | 45:c80574f24dc3 | 1502 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1503 | } |
klauss | 45:c80574f24dc3 | 1504 | debug_cb_rx = 0; |
klauss | 45:c80574f24dc3 | 1505 | } |
klauss | 45:c80574f24dc3 | 1506 | } |
klauss | 45:c80574f24dc3 | 1507 | |
klauss | 58:af7e8788f106 | 1508 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "help" )) { |
klauss | 45:c80574f24dc3 | 1509 | miss_match = false; |
klauss | 45:c80574f24dc3 | 1510 | pc.printf("\n\r****************************PROMPT HELP******************\n\r"); |
klauss | 45:c80574f24dc3 | 1511 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1512 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "\n\r****************************PROMPT HELP******************\n\r" ); |
klauss | 78:1353744f01e1 | 1513 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1514 | |
klauss | 45:c80574f24dc3 | 1515 | else if( udp_request ){ |
klauss | 78:1353744f01e1 | 1516 | while( !( udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1517 | } |
klauss | 44:cc4996469404 | 1518 | } |
klauss | 52:12930cef17c4 | 1519 | |
klauss | 45:c80574f24dc3 | 1520 | pc.printf("ifconfig - mostra o arquivo de configuracao do sistema\n\r"); |
klauss | 45:c80574f24dc3 | 1521 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1522 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ifconfig - mostra o arquivo de configuracao do sistema\n\r" ); |
klauss | 78:1353744f01e1 | 1523 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1524 | |
klauss | 45:c80574f24dc3 | 1525 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1526 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1527 | } |
klauss | 45:c80574f24dc3 | 1528 | } |
klauss | 45:c80574f24dc3 | 1529 | pc.printf("dconfig - volta as configuracoes do sistema para o padrao de fabrica\n\r"); |
klauss | 45:c80574f24dc3 | 1530 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1531 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "dconfig - volta as configuracoes do sistema para o padrao de fabrica\n\r" ); |
klauss | 78:1353744f01e1 | 1532 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1533 | |
klauss | 45:c80574f24dc3 | 1534 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1535 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1536 | } |
klauss | 45:c80574f24dc3 | 1537 | } |
klauss | 45:c80574f24dc3 | 1538 | pc.printf("callme [ramal porta] - envia o pedido de ligacao para o callbox com o ramal e porta indicada\n\r"); |
klauss | 45:c80574f24dc3 | 1539 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1540 | 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 | 1541 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1542 | |
klauss | 45:c80574f24dc3 | 1543 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1544 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1545 | } |
klauss | 45:c80574f24dc3 | 1546 | } |
klauss | 48:195c97f12e8e | 1547 | pc.printf("pcb porta comando - envia o <comando> para o cbx <ramal> e <porta> executar\n\r"); |
klauss | 45:c80574f24dc3 | 1548 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1549 | 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 | 1550 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1551 | |
klauss | 45:c80574f24dc3 | 1552 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1553 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1554 | } |
klauss | 45:c80574f24dc3 | 1555 | } |
klauss | 45:c80574f24dc3 | 1556 | pc.printf("format - formata o sistema de arquivos\n\r"); |
klauss | 62:07e5bdc9f8f7 | 1557 | //desabilitado via eth |
klauss | 62:07e5bdc9f8f7 | 1558 | /* |
klauss | 45:c80574f24dc3 | 1559 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1560 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "format - formata o sistema de arquivos\n\r" ); |
klauss | 45:c80574f24dc3 | 1561 | if( tcp_session ) tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1562 | |
klauss | 45:c80574f24dc3 | 1563 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1564 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1565 | } |
klauss | 45:c80574f24dc3 | 1566 | } |
klauss | 62:07e5bdc9f8f7 | 1567 | */ |
klauss | 45:c80574f24dc3 | 1568 | pc.printf("reset - resta o sistema\n\r"); |
klauss | 45:c80574f24dc3 | 1569 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1570 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "reset - resta o sistema\n\r" ); |
klauss | 78:1353744f01e1 | 1571 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1572 | |
klauss | 45:c80574f24dc3 | 1573 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1574 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1575 | } |
klauss | 45:c80574f24dc3 | 1576 | } |
klauss | 45:c80574f24dc3 | 1577 | pc.printf("ipset [ip] - Configura o IP da cabeceira\n\r"); |
klauss | 45:c80574f24dc3 | 1578 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1579 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ipset [ip] - Configura o IP da cabeceira\n\r" ); |
klauss | 78:1353744f01e1 | 1580 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1581 | |
klauss | 45:c80574f24dc3 | 1582 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1583 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1584 | } |
klauss | 45:c80574f24dc3 | 1585 | } |
klauss | 45:c80574f24dc3 | 1586 | pc.printf("extset [ext] - Configura a ext da cabeceira\n\r"); |
klauss | 45:c80574f24dc3 | 1587 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1588 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "extset [ext] - Configura a ext da cabeceira\n\r" ); |
klauss | 78:1353744f01e1 | 1589 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1590 | |
klauss | 45:c80574f24dc3 | 1591 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1592 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1593 | } |
klauss | 45:c80574f24dc3 | 1594 | } |
klauss | 45:c80574f24dc3 | 1595 | pc.printf("msipport [port] - Configura a porta SIP da cabeceira\n\r"); |
klauss | 45:c80574f24dc3 | 1596 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1597 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "msipport [port] - Configura a porta SIP da cabeceira\n\r" ); |
klauss | 78:1353744f01e1 | 1598 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1599 | |
klauss | 45:c80574f24dc3 | 1600 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1601 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1602 | } |
klauss | 45:c80574f24dc3 | 1603 | } |
klauss | 45:c80574f24dc3 | 1604 | pc.printf("serverip [ip] - Configura o ip do servidor asterisk\n\r"); |
klauss | 45:c80574f24dc3 | 1605 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1606 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "serverip [ip] - Configura o ip do servidor asterisk\n\r" ); |
klauss | 78:1353744f01e1 | 1607 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1608 | |
klauss | 45:c80574f24dc3 | 1609 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1610 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1611 | } |
klauss | 45:c80574f24dc3 | 1612 | } |
klauss | 45:c80574f24dc3 | 1613 | pc.printf("serextset [ext] - Configura a server ext da cabeceira\n\r"); |
klauss | 45:c80574f24dc3 | 1614 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1615 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "serextset [ext] - Configura a server ext da cabeceira\n\r" ); |
klauss | 78:1353744f01e1 | 1616 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1617 | |
klauss | 45:c80574f24dc3 | 1618 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1619 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1620 | } |
klauss | 45:c80574f24dc3 | 1621 | } |
klauss | 45:c80574f24dc3 | 1622 | pc.printf("ssport [port] - Configura a porta SIP do servidor asterisk\n\r"); |
klauss | 45:c80574f24dc3 | 1623 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1624 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ssport [port] - Configura a porta SIP do servidor asterisk\n\r" ); |
klauss | 78:1353744f01e1 | 1625 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1626 | |
klauss | 45:c80574f24dc3 | 1627 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1628 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1629 | } |
klauss | 45:c80574f24dc3 | 1630 | } |
klauss | 45:c80574f24dc3 | 1631 | pc.printf("maskset [mask] - Configura a mascara da cabeceira\n\r"); |
klauss | 45:c80574f24dc3 | 1632 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1633 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "maskset [mask] - Configura a mascara da cabeceira\n\r" ); |
klauss | 78:1353744f01e1 | 1634 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1635 | |
klauss | 45:c80574f24dc3 | 1636 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1637 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1638 | } |
klauss | 45:c80574f24dc3 | 1639 | } |
klauss | 45:c80574f24dc3 | 1640 | pc.printf("gatewayset [gateway] - Configura o gateway da cabeceira\n\r"); |
klauss | 45:c80574f24dc3 | 1641 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1642 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "gatewayset [gateway] - Configura o gateway da cabeceira\n\r" ); |
klauss | 78:1353744f01e1 | 1643 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1644 | |
klauss | 45:c80574f24dc3 | 1645 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1646 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1647 | } |
klauss | 45:c80574f24dc3 | 1648 | } |
klauss | 56:c64bcbaa621a | 1649 | pc.printf("telemetry_ip - Configura o IP do servidor de telemetria\n\r"); |
klauss | 56:c64bcbaa621a | 1650 | if( from_eth ){ |
klauss | 56:c64bcbaa621a | 1651 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "telemetry_ip - Configura o IP do servidor de telemetria\n\r" ); |
klauss | 78:1353744f01e1 | 1652 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 56:c64bcbaa621a | 1653 | |
klauss | 56:c64bcbaa621a | 1654 | else if( udp_request ){ |
klauss | 56:c64bcbaa621a | 1655 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 56:c64bcbaa621a | 1656 | } |
klauss | 56:c64bcbaa621a | 1657 | } |
klauss | 62:07e5bdc9f8f7 | 1658 | pc.printf("telemetry_port - Configura a port do servidor de telemetria\n\r"); |
klauss | 56:c64bcbaa621a | 1659 | if( from_eth ){ |
klauss | 62:07e5bdc9f8f7 | 1660 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "telemetry_port - Configura a port do servidor de telemetria\n\r" ); |
klauss | 78:1353744f01e1 | 1661 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 56:c64bcbaa621a | 1662 | |
klauss | 56:c64bcbaa621a | 1663 | else if( udp_request ){ |
klauss | 56:c64bcbaa621a | 1664 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 56:c64bcbaa621a | 1665 | } |
klauss | 56:c64bcbaa621a | 1666 | } |
klauss | 56:c64bcbaa621a | 1667 | |
klauss | 81:3656f00ab3db | 1668 | pc.printf("maxext - Configura o maior ramal possivel de ser registrado nesse ramo\n\r"); |
klauss | 81:3656f00ab3db | 1669 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1670 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "maxext - Configura o maior ramal possivel de ser registrado nesse ramo\n\r" ); |
klauss | 81:3656f00ab3db | 1671 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 81:3656f00ab3db | 1672 | |
klauss | 81:3656f00ab3db | 1673 | else if( udp_request ){ |
klauss | 81:3656f00ab3db | 1674 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 81:3656f00ab3db | 1675 | } |
klauss | 81:3656f00ab3db | 1676 | } |
klauss | 81:3656f00ab3db | 1677 | |
klauss | 81:3656f00ab3db | 1678 | pc.printf("minext - Configura o menor ramal possivel de ser registrado nesse ramo\n\r"); |
klauss | 81:3656f00ab3db | 1679 | if( from_eth ){ |
klauss | 81:3656f00ab3db | 1680 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "minext - Configura o menor ramal possivel de ser registrado nesse ramo\n\r" ); |
klauss | 81:3656f00ab3db | 1681 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 81:3656f00ab3db | 1682 | |
klauss | 81:3656f00ab3db | 1683 | else if( udp_request ){ |
klauss | 81:3656f00ab3db | 1684 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 81:3656f00ab3db | 1685 | } |
klauss | 81:3656f00ab3db | 1686 | } |
klauss | 81:3656f00ab3db | 1687 | |
klauss | 45:c80574f24dc3 | 1688 | pc.printf("showcb - lista os Cbx registrados na header\n\r"); |
klauss | 45:c80574f24dc3 | 1689 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1690 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "showcb - lista os Cbx registrados na header\n\r" ); |
klauss | 78:1353744f01e1 | 1691 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1692 | |
klauss | 45:c80574f24dc3 | 1693 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1694 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1695 | } |
klauss | 45:c80574f24dc3 | 1696 | } |
klauss | 63:0d95da692bb4 | 1697 | /* |
klauss | 48:195c97f12e8e | 1698 | pc.printf("status - lista resumida de cbx registrados na header\n\r"); |
klauss | 48:195c97f12e8e | 1699 | if( from_eth ){ |
klauss | 48:195c97f12e8e | 1700 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "showcb - lista resumida de cbx registrados na header\n\r" ); |
klauss | 48:195c97f12e8e | 1701 | if( tcp_session ) tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 48:195c97f12e8e | 1702 | |
klauss | 48:195c97f12e8e | 1703 | else if( udp_request ){ |
klauss | 48:195c97f12e8e | 1704 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 48:195c97f12e8e | 1705 | } |
klauss | 48:195c97f12e8e | 1706 | } |
klauss | 63:0d95da692bb4 | 1707 | */ |
klauss | 45:c80574f24dc3 | 1708 | pc.printf("cks - exibe estatisticas de check sum\n\r"); |
klauss | 45:c80574f24dc3 | 1709 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1710 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "cks - exibe estatisticas de check sum\n\r" ); |
klauss | 78:1353744f01e1 | 1711 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1712 | |
klauss | 45:c80574f24dc3 | 1713 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1714 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1715 | } |
klauss | 45:c80574f24dc3 | 1716 | } |
klauss | 52:12930cef17c4 | 1717 | pc.printf("reset_cks - reseta estatisticas de check sum\n\r"); |
klauss | 52:12930cef17c4 | 1718 | if( from_eth ){ |
klauss | 52:12930cef17c4 | 1719 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "reset_cks - reseta estatisticas de check sum\n\r" ); |
klauss | 78:1353744f01e1 | 1720 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 52:12930cef17c4 | 1721 | |
klauss | 52:12930cef17c4 | 1722 | else if( udp_request ){ |
klauss | 52:12930cef17c4 | 1723 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 52:12930cef17c4 | 1724 | } |
klauss | 52:12930cef17c4 | 1725 | } |
klauss | 52:12930cef17c4 | 1726 | |
klauss | 45:c80574f24dc3 | 1727 | pc.printf(". - executa o comando anterior novamente\n\r"); |
klauss | 45:c80574f24dc3 | 1728 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1729 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, ". - executa o comando anterior novamente\n\r" ); |
klauss | 78:1353744f01e1 | 1730 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1731 | |
klauss | 45:c80574f24dc3 | 1732 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1733 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1734 | } |
klauss | 45:c80574f24dc3 | 1735 | } |
klauss | 45:c80574f24dc3 | 1736 | pc.printf("debug [on|off|show] - seleciona debugs gerais | lista de debugs \n\r"); |
klauss | 45:c80574f24dc3 | 1737 | if( from_eth ){ |
klauss | 45:c80574f24dc3 | 1738 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "debug [on|off|show] - seleciona debugs gerais | lista de debugs \n\r" ); |
klauss | 78:1353744f01e1 | 1739 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1740 | |
klauss | 45:c80574f24dc3 | 1741 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1742 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1743 | } |
klauss | 45:c80574f24dc3 | 1744 | } |
klauss | 62:07e5bdc9f8f7 | 1745 | pc.printf("{ flood [ on | off ] | [+|-] } - simula envio de pacotes de audio\n\r"); |
klauss | 45:c80574f24dc3 | 1746 | if( from_eth ){ |
klauss | 62:07e5bdc9f8f7 | 1747 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "{ flood [ on | off ] | [+|-] } - simula envio de pacotes de audio\n\r"); |
klauss | 78:1353744f01e1 | 1748 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 62:07e5bdc9f8f7 | 1749 | |
klauss | 62:07e5bdc9f8f7 | 1750 | else if( udp_request ){ |
klauss | 62:07e5bdc9f8f7 | 1751 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 62:07e5bdc9f8f7 | 1752 | } |
klauss | 62:07e5bdc9f8f7 | 1753 | } |
klauss | 65:0b653cfe95db | 1754 | |
klauss | 65:0b653cfe95db | 1755 | 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 | 1756 | if( from_eth ){ |
klauss | 65:0b653cfe95db | 1757 | 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 | 1758 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 65:0b653cfe95db | 1759 | |
klauss | 65:0b653cfe95db | 1760 | else if( udp_request ){ |
klauss | 65:0b653cfe95db | 1761 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 65:0b653cfe95db | 1762 | } |
klauss | 65:0b653cfe95db | 1763 | } |
klauss | 65:0b653cfe95db | 1764 | |
klauss | 62:07e5bdc9f8f7 | 1765 | pc.printf("++ ext - Header flood on, ext flood on\n\r"); |
klauss | 62:07e5bdc9f8f7 | 1766 | if( from_eth ){ |
klauss | 62:07e5bdc9f8f7 | 1767 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "++ ext - Header flood on, ext flood on\n\r"); |
klauss | 78:1353744f01e1 | 1768 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 45:c80574f24dc3 | 1769 | |
klauss | 45:c80574f24dc3 | 1770 | else if( udp_request ){ |
klauss | 45:c80574f24dc3 | 1771 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 1772 | } |
klauss | 45:c80574f24dc3 | 1773 | } |
klauss | 66:3f1d22e69e7b | 1774 | |
klauss | 66:3f1d22e69e7b | 1775 | pc.printf("-- ext - Header flood off, ext flood off\n\r"); |
klauss | 66:3f1d22e69e7b | 1776 | if( from_eth ){ |
klauss | 66:3f1d22e69e7b | 1777 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "++ ext - Header flood on, ext flood on\n\r"); |
klauss | 78:1353744f01e1 | 1778 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 66:3f1d22e69e7b | 1779 | |
klauss | 66:3f1d22e69e7b | 1780 | else if( udp_request ){ |
klauss | 66:3f1d22e69e7b | 1781 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 66:3f1d22e69e7b | 1782 | } |
klauss | 66:3f1d22e69e7b | 1783 | } |
klauss | 66:3f1d22e69e7b | 1784 | |
klauss | 64:5b011d5707d2 | 1785 | pc.printf("rx - Exibe ultimo pacote recebido dos CBx\n\r"); |
klauss | 64:5b011d5707d2 | 1786 | if( from_eth ){ |
klauss | 64:5b011d5707d2 | 1787 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "rx - Exibe ultimo pacote recebido dos CBx\n\r"); |
klauss | 78:1353744f01e1 | 1788 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 64:5b011d5707d2 | 1789 | |
klauss | 64:5b011d5707d2 | 1790 | else if( udp_request ){ |
klauss | 64:5b011d5707d2 | 1791 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 64:5b011d5707d2 | 1792 | } |
klauss | 64:5b011d5707d2 | 1793 | } |
klauss | 64:5b011d5707d2 | 1794 | pc.printf("tx - Exibe ultimo pacote enviado para os CBx\n\r"); |
klauss | 64:5b011d5707d2 | 1795 | if( from_eth ){ |
klauss | 64:5b011d5707d2 | 1796 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "tx - Exibe ultimo pacote enviado para os CBx\n\r"); |
klauss | 78:1353744f01e1 | 1797 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 64:5b011d5707d2 | 1798 | |
klauss | 64:5b011d5707d2 | 1799 | else if( udp_request ){ |
klauss | 64:5b011d5707d2 | 1800 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 64:5b011d5707d2 | 1801 | } |
klauss | 64:5b011d5707d2 | 1802 | } |
klauss | 64:5b011d5707d2 | 1803 | pc.printf("ls | status - Exibe uma lista ordenada por ext do CBx registrados na Header\n\r"); |
klauss | 64:5b011d5707d2 | 1804 | if( from_eth ){ |
klauss | 64:5b011d5707d2 | 1805 | 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 | 1806 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 64:5b011d5707d2 | 1807 | |
klauss | 64:5b011d5707d2 | 1808 | else if( udp_request ){ |
klauss | 64:5b011d5707d2 | 1809 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 64:5b011d5707d2 | 1810 | } |
klauss | 64:5b011d5707d2 | 1811 | } |
klauss | 64:5b011d5707d2 | 1812 | pc.printf("types - Lista os types usados no protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 64:5b011d5707d2 | 1813 | if( from_eth ){ |
klauss | 64:5b011d5707d2 | 1814 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "types - Lista os types usados no protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 78:1353744f01e1 | 1815 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 64:5b011d5707d2 | 1816 | |
klauss | 64:5b011d5707d2 | 1817 | else if( udp_request ){ |
klauss | 64:5b011d5707d2 | 1818 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 64:5b011d5707d2 | 1819 | } |
klauss | 64:5b011d5707d2 | 1820 | } |
klauss | 64:5b011d5707d2 | 1821 | pc.printf("protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 64:5b011d5707d2 | 1822 | if( from_eth ){ |
klauss | 64:5b011d5707d2 | 1823 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 78:1353744f01e1 | 1824 | if( tcp_session ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 64:5b011d5707d2 | 1825 | |
klauss | 64:5b011d5707d2 | 1826 | else if( udp_request ){ |
klauss | 64:5b011d5707d2 | 1827 | udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 64:5b011d5707d2 | 1828 | } |
klauss | 64:5b011d5707d2 | 1829 | } |
klauss | 64:5b011d5707d2 | 1830 | |
klauss | 45:c80574f24dc3 | 1831 | pc.printf("PROMPT VERSION: V%d\n\r",PVERSION); |
klauss | 45:c80574f24dc3 | 1832 | //Obs :: a ultima linha nao mandamos direto pro tcp porque ela eh enviada fora desse escopo |
klauss | 45:c80574f24dc3 | 1833 | if( from_eth ) snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "PROMPT VERSION: V%d\n\r",PVERSION); |
klauss | 27:98f824719d1c | 1834 | } |
klauss | 54:448d57291be6 | 1835 | |
klauss | 58:af7e8788f106 | 1836 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "callme ", 7 )){ |
klauss | 54:448d57291be6 | 1837 | miss_match = false; |
klauss | 54:448d57291be6 | 1838 | int ext,port; |
klauss | 54:448d57291be6 | 1839 | char cmd[ 16 ]; |
klauss | 54:448d57291be6 | 1840 | |
klauss | 54:448d57291be6 | 1841 | ext = atoi( debug_buf + 7 ); |
klauss | 54:448d57291be6 | 1842 | port = convert_ext_to_port( ext ); |
klauss | 54:448d57291be6 | 1843 | |
klauss | 67:cdedc64d9921 | 1844 | strcpy( cmd, ( ext % 2 ) ? "call init B" : "call init A" ); |
klauss | 67:cdedc64d9921 | 1845 | |
klauss | 67:cdedc64d9921 | 1846 | if( ext % 2 ) ext--; |
klauss | 54:448d57291be6 | 1847 | |
klauss | 54:448d57291be6 | 1848 | promptcb_last_ext = ext; |
klauss | 54:448d57291be6 | 1849 | promptcb_last_port = port; |
klauss | 54:448d57291be6 | 1850 | |
klauss | 62:07e5bdc9f8f7 | 1851 | int tmp = strlen( cmd ); |
klauss | 62:07e5bdc9f8f7 | 1852 | cmd[ tmp ] = 0x0D; |
klauss | 62:07e5bdc9f8f7 | 1853 | cmd[ tmp + 1 ] = 0x00; |
klauss | 62:07e5bdc9f8f7 | 1854 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 62:07e5bdc9f8f7 | 1855 | |
klauss | 54:448d57291be6 | 1856 | pc.printf("\r\next=%d port=%d\r\ncmd=%s\r\n", ext, port, cmd ); |
klauss | 67:cdedc64d9921 | 1857 | |
klauss | 67:cdedc64d9921 | 1858 | pc.printf("\n\r--------------------------------------------------------\n\r"); |
klauss | 67:cdedc64d9921 | 1859 | for( uint16_t i = 0; i < strlen( cmd ) ; i++ ) pc.printf( "%02x ", cmd[ i ] ); |
klauss | 67:cdedc64d9921 | 1860 | |
klauss | 74:81c47fff88a5 | 1861 | send2callboxes( __build_cb_package__( ext, port, __PROMPT__, cmd, id_msg++, __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 67:cdedc64d9921 | 1862 | pc.printf("\n\r--------------------------------------------------------\n\r"); |
klauss | 67:cdedc64d9921 | 1863 | for( uint16_t i = 0; i < 300 ; i++ ){ |
klauss | 67:cdedc64d9921 | 1864 | pc.printf( "%02x ", write_buffer[ i ] ); |
klauss | 67:cdedc64d9921 | 1865 | if( i != 0 && !( ( i + 1 ) % 30 ) ) pc.printf("\n\r"); |
klauss | 67:cdedc64d9921 | 1866 | } |
klauss | 67:cdedc64d9921 | 1867 | |
klauss | 67:cdedc64d9921 | 1868 | |
klauss | 62:07e5bdc9f8f7 | 1869 | pc.printf("\n\rComando enviado\n\r"); |
klauss | 54:448d57291be6 | 1870 | |
klauss | 54:448d57291be6 | 1871 | if( from_eth ){ |
klauss | 62:07e5bdc9f8f7 | 1872 | char eth_msg[ 512 ]; |
klauss | 62:07e5bdc9f8f7 | 1873 | 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 | 1874 | if( tcp_session ){ |
klauss | 62:07e5bdc9f8f7 | 1875 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 62:07e5bdc9f8f7 | 1876 | }else if( udp_request ){ |
klauss | 62:07e5bdc9f8f7 | 1877 | udp_server.sendTo( udp_client, eth_msg, strlen( eth_msg ) ); |
klauss | 62:07e5bdc9f8f7 | 1878 | } |
klauss | 19:ab2088e0dec6 | 1879 | } |
klauss | 54:448d57291be6 | 1880 | |
klauss | 54:448d57291be6 | 1881 | bufptr = 0; |
klauss | 67:cdedc64d9921 | 1882 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 45:c80574f24dc3 | 1883 | } |
klauss | 45:c80574f24dc3 | 1884 | |
klauss | 45:c80574f24dc3 | 1885 | if( miss_match ){ |
klauss | 48:195c97f12e8e | 1886 | pc.printf("\n\r> %s: command not found\n\r", debug_buf ); |
klauss | 45:c80574f24dc3 | 1887 | if( from_eth ){ |
klauss | 48:195c97f12e8e | 1888 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "> %s: command not found\n ", debug_buf ); |
klauss | 58:af7e8788f106 | 1889 | //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 45:c80574f24dc3 | 1890 | } |
klauss | 45:c80574f24dc3 | 1891 | } |
klauss | 45:c80574f24dc3 | 1892 | else{ |
klauss | 58:af7e8788f106 | 1893 | if( from_eth && strlen( debug_buf ) > 2 ) strcpy( last_cmd, tmp_cmd ); |
klauss | 58:af7e8788f106 | 1894 | |
klauss | 58:af7e8788f106 | 1895 | else if( strlen( debug_buf ) > 2 ) strcpy( last_cmd, tmp_cmd ); |
klauss | 45:c80574f24dc3 | 1896 | } |
klauss | 48:195c97f12e8e | 1897 | } |
klauss | 45:c80574f24dc3 | 1898 | if( b == 0x0D || bufret == 1 || bufptr > DEBUGBUFSIZE ){ |
klauss | 45:c80574f24dc3 | 1899 | bufret = 0; |
klauss | 57:78f7191a8b69 | 1900 | if( from_eth ){ |
klauss | 57:78f7191a8b69 | 1901 | from_eth = false; |
klauss | 57:78f7191a8b69 | 1902 | |
klauss | 48:195c97f12e8e | 1903 | if( debug_buf[ strlen( debug_buf ) - 1 ] == '\r' || debug_buf[ strlen( debug_buf ) - 1 ] == '\n' ) strcat( debug_buf, "> " ); |
klauss | 48:195c97f12e8e | 1904 | |
klauss | 48:195c97f12e8e | 1905 | else strcat( debug_buf, "\n\r> " ); |
klauss | 48:195c97f12e8e | 1906 | |
klauss | 57:78f7191a8b69 | 1907 | if( tcp_session ){ |
klauss | 57:78f7191a8b69 | 1908 | |
klauss | 57:78f7191a8b69 | 1909 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 57:78f7191a8b69 | 1910 | |
klauss | 57:78f7191a8b69 | 1911 | }else if( udp_request ){ |
klauss | 48:195c97f12e8e | 1912 | |
klauss | 57:78f7191a8b69 | 1913 | int sent = udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); |
klauss | 48:195c97f12e8e | 1914 | |
klauss | 57:78f7191a8b69 | 1915 | udp_request = false; |
klauss | 57:78f7191a8b69 | 1916 | } |
klauss | 57:78f7191a8b69 | 1917 | for( register uint16_t i = 0; i < __PROMPT_ETH_BUFFER_SIZE__; i++ ) eth_buffer[ i ] = 0; |
klauss | 57:78f7191a8b69 | 1918 | debug_buf = __debug_buf__; |
klauss | 57:78f7191a8b69 | 1919 | bufptr = last_bufptr; |
klauss | 45:c80574f24dc3 | 1920 | }else{ |
klauss | 42:480335bdde12 | 1921 | bufptr = 0; |
klauss | 58:af7e8788f106 | 1922 | for( uint8_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 45:c80574f24dc3 | 1923 | } |
klauss | 45:c80574f24dc3 | 1924 | pc.putc(0x0A); |
klauss | 45:c80574f24dc3 | 1925 | pc.putc(0x0D); |
klauss | 45:c80574f24dc3 | 1926 | pc.printf("> "); |
klauss | 45:c80574f24dc3 | 1927 | } |
klauss | 36:728498a78e1e | 1928 | return( NULL ); |
klauss | 54:448d57291be6 | 1929 | } |