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