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