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