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