![](/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.h@78:1353744f01e1, 2014-12-16 (annotated)
- Committer:
- klauss
- Date:
- Tue Dec 16 12:13:01 2014 +0000
- Revision:
- 78:1353744f01e1
- Parent:
- 74:81c47fff88a5
- Child:
- 79:9bc12aa305a9
before meeting
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 69:65665afbad5d | 1 | /** |
klauss | 69:65665afbad5d | 2 | * @file prompt.h |
klauss | 69:65665afbad5d | 3 | * @Synopsis Implementa as funcionalidades de prompt/prompt-eth da Header. |
klauss | 69:65665afbad5d | 4 | * @author Fernando Cola / Jhontan Casale |
klauss | 69:65665afbad5d | 5 | * @version 1 |
klauss | 69:65665afbad5d | 6 | * @date 2014-11-05 |
klauss | 69:65665afbad5d | 7 | */ |
klauss | 69:65665afbad5d | 8 | |
klauss | 17:67a6b557eda5 | 9 | #ifndef _PROMPT_H |
klauss | 17:67a6b557eda5 | 10 | #define _PROMPT_H |
klauss | 17:67a6b557eda5 | 11 | |
klauss | 74:81c47fff88a5 | 12 | #include <stdint.h> |
klauss | 44:cc4996469404 | 13 | #include "mbed.h" |
klauss | 74:81c47fff88a5 | 14 | #include "EthernetInterface.h" |
klauss | 74:81c47fff88a5 | 15 | #include "telemetry.h" // used for __TELEMETRY_SERVER_IP__ and __TELEMETRY_SERVER_PORT__ |
klauss | 74:81c47fff88a5 | 16 | #include "utils.h" // need for convert_ext_to_port() |
klauss | 44:cc4996469404 | 17 | #include "flood.h" |
klauss | 74:81c47fff88a5 | 18 | #include "shared_variables.h" |
klauss | 74:81c47fff88a5 | 19 | #include "debug.h" |
klauss | 74:81c47fff88a5 | 20 | #include "wdt_manager.h" |
klauss | 74:81c47fff88a5 | 21 | #include "file_system_manager.h" |
klauss | 44:cc4996469404 | 22 | |
klauss | 78:1353744f01e1 | 23 | #define TCP_IDLE_MAX_TIME 360//90 |
klauss | 78:1353744f01e1 | 24 | ///< Define o tempo maximo de espera por um novo comando via eth, dado que já estamos em uma sessão TCP. |
klauss | 78:1353744f01e1 | 25 | |
klauss | 78:1353744f01e1 | 26 | #define TCP_ALIVE_IDLE_MAX_TIME 360 |
klauss | 78:1353744f01e1 | 27 | ///< Define o tempo maximo de espera por um novo comando via eth dado que já estamos em uma sessão TCP e a flag tcp_alive esta on. |
klauss | 69:65665afbad5d | 28 | |
klauss | 58:af7e8788f106 | 29 | #define DEBUGBUFSIZE 50 |
klauss | 69:65665afbad5d | 30 | ///< Define o tamanho do buffer de entrada de dados. |
klauss | 44:cc4996469404 | 31 | |
klauss | 17:67a6b557eda5 | 32 | extern uint8_t dog; |
klauss | 69:65665afbad5d | 33 | ///< Variável de controle que ativa a mensagem de boas vindas. |
klauss | 69:65665afbad5d | 34 | |
klauss | 69:65665afbad5d | 35 | extern FILE *fmask; ///< arquivo de mascara de rede |
klauss | 69:65665afbad5d | 36 | extern FILE *fgate; ///< arquivo de gateway ip |
klauss | 69:65665afbad5d | 37 | |
klauss | 69:65665afbad5d | 38 | extern FILE *fip; ///< arquivo de header ip |
klauss | 69:65665afbad5d | 39 | extern FILE *fext; ///< arquivo de header ext |
klauss | 69:65665afbad5d | 40 | extern FILE *fport; ///< arquivo de header sip port |
klauss | 69:65665afbad5d | 41 | |
klauss | 69:65665afbad5d | 42 | extern FILE *fsip; ///< arquivo de server sip ip |
klauss | 69:65665afbad5d | 43 | extern FILE *fserext; ///< arquivo de server sip ext |
klauss | 69:65665afbad5d | 44 | extern FILE *fsport; ///< arquivo de server sip port |
klauss | 69:65665afbad5d | 45 | |
klauss | 69:65665afbad5d | 46 | extern FILE *fudpport; ///< arquivo de porta udp que a header escuta |
klauss | 69:65665afbad5d | 47 | extern FILE *ftcpport; ///< arquivo de porta tcp que a header escuta |
klauss | 69:65665afbad5d | 48 | extern FILE *ftip; ///< arquivo de IP do servidor para envio de telemetria |
klauss | 69:65665afbad5d | 49 | extern FILE *ftport; ///< arquivo de Porta UDP do servidor para envio de telemetria |
klauss | 17:67a6b557eda5 | 50 | |
klauss | 74:81c47fff88a5 | 51 | extern bool flood_silence; |
klauss | 74:81c47fff88a5 | 52 | extern bool delayed_flood; |
klauss | 74:81c47fff88a5 | 53 | ///< Variável de controle do envio de pacotes de flood off |
klauss | 74:81c47fff88a5 | 54 | |
klauss | 78:1353744f01e1 | 55 | extern bool tcp_alive; |
klauss | 78:1353744f01e1 | 56 | ///< Flag que indica para não dar timeout na conexão tcp |
klauss | 78:1353744f01e1 | 57 | |
klauss | 78:1353744f01e1 | 58 | extern Timer tcp_timer; |
klauss | 78:1353744f01e1 | 59 | ///< Timer responsavel por dar timeout por não utilização de recurso. |
klauss | 78:1353744f01e1 | 60 | |
klauss | 69:65665afbad5d | 61 | /** |
klauss | 69:65665afbad5d | 62 | * @Synopsis Principal função de processamento de comandos. |
klauss | 69:65665afbad5d | 63 | * |
klauss | 69:65665afbad5d | 64 | * \note Apesar de formalmente receber apenas um parâmetro, esta função verifica uma porta TCP para verificar eventual |
klauss | 69:65665afbad5d | 65 | * envio de comandos, processando qualquer comando enviado por um usuário ligado na rede. |
klauss | 69:65665afbad5d | 66 | * |
klauss | 69:65665afbad5d | 67 | * @param ethernet_pkg Uma string de comando que será analisada, caso seja um comando válido, executa-o. |
klauss | 69:65665afbad5d | 68 | * |
klauss | 69:65665afbad5d | 69 | * @return NULL, sempre retorna NULL. |
klauss | 69:65665afbad5d | 70 | * |
klauss | 69:65665afbad5d | 71 | * Exemplo: |
klauss | 69:65665afbad5d | 72 | * @code |
klauss | 69:65665afbad5d | 73 | * ... |
klauss | 69:65665afbad5d | 74 | * char * returned_prompt = prompt_process( NULL ); |
klauss | 69:65665afbad5d | 75 | * ... |
klauss | 69:65665afbad5d | 76 | * @endcode |
klauss | 69:65665afbad5d | 77 | */ |
klauss | 69:65665afbad5d | 78 | char * prompt_process( char * ethernet_pkg ); |
klauss | 69:65665afbad5d | 79 | |
klauss | 69:65665afbad5d | 80 | /** |
klauss | 69:65665afbad5d | 81 | * @Synopsis Init file system and check if files exist |
klauss | 69:65665afbad5d | 82 | * |
klauss | 69:65665afbad5d | 83 | * Exemplo: |
klauss | 69:65665afbad5d | 84 | * @code |
klauss | 69:65665afbad5d | 85 | * ... |
klauss | 69:65665afbad5d | 86 | * init_fsystem(); |
klauss | 69:65665afbad5d | 87 | * ... |
klauss | 69:65665afbad5d | 88 | * @endcode |
klauss | 69:65665afbad5d | 89 | */ |
klauss | 69:65665afbad5d | 90 | void init_fsystem(); |
klauss | 28:94aec56c6329 | 91 | |
klauss | 69:65665afbad5d | 92 | /** |
klauss | 69:65665afbad5d | 93 | * @Synopsis Inicializa o prompt e os sockets de conexão eth |
klauss | 69:65665afbad5d | 94 | * |
klauss | 69:65665afbad5d | 95 | * Exemplo: |
klauss | 69:65665afbad5d | 96 | * @code |
klauss | 69:65665afbad5d | 97 | * ... |
klauss | 69:65665afbad5d | 98 | * init_prompt(); |
klauss | 69:65665afbad5d | 99 | * ... |
klauss | 69:65665afbad5d | 100 | * @endcode |
klauss | 69:65665afbad5d | 101 | */ |
klauss | 78:1353744f01e1 | 102 | void init_prompt_eth(); |
klauss | 69:65665afbad5d | 103 | |
klauss | 69:65665afbad5d | 104 | /** |
klauss | 69:65665afbad5d | 105 | * @Synopsis Altera o valor default contido no arquivo /qspi/myip.txt |
klauss | 69:65665afbad5d | 106 | * |
klauss | 69:65665afbad5d | 107 | * @param new_header_ip Atualiza o valor de /qspi/myip.txt sobrescrevendo-o com o valor de new_header_ip |
klauss | 69:65665afbad5d | 108 | * |
klauss | 69:65665afbad5d | 109 | * Exemplo: |
klauss | 69:65665afbad5d | 110 | * @code |
klauss | 69:65665afbad5d | 111 | * ... |
klauss | 69:65665afbad5d | 112 | * set_ip( "192.168.120.2" ); |
klauss | 69:65665afbad5d | 113 | * ... |
klauss | 69:65665afbad5d | 114 | * @endcode |
klauss | 69:65665afbad5d | 115 | */ |
klauss | 69:65665afbad5d | 116 | void set_ip( char * new_header_ip ); |
klauss | 28:94aec56c6329 | 117 | |
klauss | 69:65665afbad5d | 118 | /** |
klauss | 69:65665afbad5d | 119 | * @Synopsis Altera o valor default contido no arquivo /qspi/myext.txt |
klauss | 69:65665afbad5d | 120 | * |
klauss | 69:65665afbad5d | 121 | * @param new_header_ext Atualiza o valor de /qspi/myext.txt sobrescrevendo-o com o valor de new_header_ext |
klauss | 69:65665afbad5d | 122 | * |
klauss | 69:65665afbad5d | 123 | * Exemplo: |
klauss | 69:65665afbad5d | 124 | * @code |
klauss | 69:65665afbad5d | 125 | * ... |
klauss | 69:65665afbad5d | 126 | * set_header_ext( 912 ); |
klauss | 69:65665afbad5d | 127 | * ... |
klauss | 69:65665afbad5d | 128 | * @endcode |
klauss | 69:65665afbad5d | 129 | */ |
klauss | 69:65665afbad5d | 130 | void set_header_ext( int new_header_ext ); |
klauss | 69:65665afbad5d | 131 | |
klauss | 69:65665afbad5d | 132 | /** |
klauss | 69:65665afbad5d | 133 | * @Synopsis Altera o valor default contido no arquivo /qspi/mysipport.txt |
klauss | 69:65665afbad5d | 134 | * |
klauss | 69:65665afbad5d | 135 | * @param new_header_sip_port Atualiza o valor de /qspi/mysipport.txt sobrescrevendo-o com o valor de new_header_sip_port |
klauss | 69:65665afbad5d | 136 | * |
klauss | 69:65665afbad5d | 137 | * Exemplo: |
klauss | 69:65665afbad5d | 138 | * @code |
klauss | 69:65665afbad5d | 139 | * ... |
klauss | 69:65665afbad5d | 140 | * set_header_sip_port( 820 ); |
klauss | 69:65665afbad5d | 141 | * ... |
klauss | 69:65665afbad5d | 142 | * @endcode |
klauss | 69:65665afbad5d | 143 | */ |
klauss | 69:65665afbad5d | 144 | void set_header_sip_port( int new_header_sip_port ); |
klauss | 28:94aec56c6329 | 145 | |
klauss | 69:65665afbad5d | 146 | /** |
klauss | 69:65665afbad5d | 147 | * @Synopsis Altera o valor default contido no arquivo /qspi/serverip.txt |
klauss | 69:65665afbad5d | 148 | * |
klauss | 69:65665afbad5d | 149 | * @param new_server_ip Atualiza o valor de /qspi/serverip.txt sobrescrevendo-o com o valor de new_server_ip |
klauss | 69:65665afbad5d | 150 | * |
klauss | 69:65665afbad5d | 151 | * Exemplo: |
klauss | 69:65665afbad5d | 152 | * @code |
klauss | 69:65665afbad5d | 153 | * ... |
klauss | 69:65665afbad5d | 154 | * set_header_sip_port( "192.168.120.231" ); |
klauss | 69:65665afbad5d | 155 | * ... |
klauss | 69:65665afbad5d | 156 | * @endcode |
klauss | 69:65665afbad5d | 157 | */ |
klauss | 69:65665afbad5d | 158 | void set_server_ip( char * new_server_ip ); |
klauss | 69:65665afbad5d | 159 | |
klauss | 69:65665afbad5d | 160 | /** |
klauss | 69:65665afbad5d | 161 | * @Synopsis Altera o valor default contido no arquivo /qspi/peerext.txt |
klauss | 69:65665afbad5d | 162 | * |
klauss | 69:65665afbad5d | 163 | * @param new_server_ext Atualiza o valor de /qspi/peerext.txt sobrescrevendo-o com o valor de new_server_ext |
klauss | 69:65665afbad5d | 164 | * |
klauss | 69:65665afbad5d | 165 | * Exemplo: |
klauss | 69:65665afbad5d | 166 | * @code |
klauss | 69:65665afbad5d | 167 | * ... |
klauss | 69:65665afbad5d | 168 | * set_header_sip_port( 1011 ); |
klauss | 69:65665afbad5d | 169 | * ... |
klauss | 69:65665afbad5d | 170 | * @endcode |
klauss | 69:65665afbad5d | 171 | */ |
klauss | 69:65665afbad5d | 172 | void set_server_ext( int new_server_ext ); |
klauss | 69:65665afbad5d | 173 | |
klauss | 69:65665afbad5d | 174 | /** |
klauss | 69:65665afbad5d | 175 | * @Synopsis Altera o valor default contido no arquivo /qspi/serverport.txt |
klauss | 69:65665afbad5d | 176 | * |
klauss | 69:65665afbad5d | 177 | * @param new_server_port Atualiza o valor de /qspi/serverport.txt sobrescrevendo-o com o valor de new_server_port |
klauss | 69:65665afbad5d | 178 | * |
klauss | 69:65665afbad5d | 179 | * Exemplo: |
klauss | 69:65665afbad5d | 180 | * @code |
klauss | 69:65665afbad5d | 181 | * ... |
klauss | 69:65665afbad5d | 182 | * set_header_sip_port( 1562 ); |
klauss | 69:65665afbad5d | 183 | * ... |
klauss | 69:65665afbad5d | 184 | * @endcode |
klauss | 69:65665afbad5d | 185 | */ |
klauss | 69:65665afbad5d | 186 | void set_server_port( int new_server_port ); |
klauss | 69:65665afbad5d | 187 | |
klauss | 69:65665afbad5d | 188 | /** |
klauss | 69:65665afbad5d | 189 | * @Synopsis Altera o valor default contido no arquivo /qspi/udpport.txt |
klauss | 69:65665afbad5d | 190 | * |
klauss | 69:65665afbad5d | 191 | * @param new_udp_port_listener Atualiza o valor de /qspi/udpport.txt sobrescrevendo-o com o valor de new_udp_port_listener |
klauss | 69:65665afbad5d | 192 | * |
klauss | 69:65665afbad5d | 193 | * Exemplo: |
klauss | 69:65665afbad5d | 194 | * @code |
klauss | 69:65665afbad5d | 195 | * ... |
klauss | 69:65665afbad5d | 196 | * set_udp_port_listener( 11147 ); |
klauss | 69:65665afbad5d | 197 | * ... |
klauss | 69:65665afbad5d | 198 | * @endcode |
klauss | 69:65665afbad5d | 199 | */ |
klauss | 69:65665afbad5d | 200 | void set_udp_port_listener( int new_udp_port_listener ); |
klauss | 45:c80574f24dc3 | 201 | |
klauss | 69:65665afbad5d | 202 | /** |
klauss | 69:65665afbad5d | 203 | * @Synopsis Altera o valor default contido no arquivo /qspi/tcpport.txt |
klauss | 69:65665afbad5d | 204 | * |
klauss | 69:65665afbad5d | 205 | * @param new_tcp_port_listener Atualiza o valor de /qspi/tcpport.txt sobrescrevendo-o com o valor de new_tcp_port_listener |
klauss | 69:65665afbad5d | 206 | * |
klauss | 69:65665afbad5d | 207 | * Exemplo: |
klauss | 69:65665afbad5d | 208 | * @code |
klauss | 69:65665afbad5d | 209 | * ... |
klauss | 69:65665afbad5d | 210 | * set_tcp_port_listener( 7178 ); |
klauss | 69:65665afbad5d | 211 | * ... |
klauss | 69:65665afbad5d | 212 | * @endcode |
klauss | 69:65665afbad5d | 213 | */ |
klauss | 56:c64bcbaa621a | 214 | void set_tcp_port_listener( int new_tcp_port_listener ); |
klauss | 69:65665afbad5d | 215 | |
klauss | 69:65665afbad5d | 216 | /** |
klauss | 69:65665afbad5d | 217 | * @Synopsis Altera o valor default contido no arquivo /qspi/telemetry_ip.txt |
klauss | 69:65665afbad5d | 218 | * |
klauss | 69:65665afbad5d | 219 | * @param new_telemetry_ip Atualiza o valor de /qspi/telemetry_ip.txt sobrescrevendo-o com o valor de new_telemetry_ip |
klauss | 69:65665afbad5d | 220 | * |
klauss | 69:65665afbad5d | 221 | * Exemplo: |
klauss | 69:65665afbad5d | 222 | * @code |
klauss | 69:65665afbad5d | 223 | * ... |
klauss | 69:65665afbad5d | 224 | * set_telemetry_ip( "192.154.123.7" ) |
klauss | 69:65665afbad5d | 225 | * ... |
klauss | 69:65665afbad5d | 226 | * @endcode |
klauss | 69:65665afbad5d | 227 | */ |
klauss | 56:c64bcbaa621a | 228 | void set_telemetry_ip( char * new_telemetry_ip ); |
klauss | 69:65665afbad5d | 229 | |
klauss | 69:65665afbad5d | 230 | /** |
klauss | 69:65665afbad5d | 231 | * @Synopsis Altera o valor default contido no arquivo /qspi/telemetry_port.txt |
klauss | 69:65665afbad5d | 232 | * |
klauss | 69:65665afbad5d | 233 | * @param new_telemetry_port Atualiza o valor de /qspi/telemetry_port.txt sobrescrevendo-o com o valor de new_telemetry_port |
klauss | 69:65665afbad5d | 234 | * |
klauss | 69:65665afbad5d | 235 | * Exemplo: |
klauss | 69:65665afbad5d | 236 | * @code |
klauss | 69:65665afbad5d | 237 | * ... |
klauss | 69:65665afbad5d | 238 | * set_telemetry_port( 9193 ); |
klauss | 69:65665afbad5d | 239 | * ... |
klauss | 69:65665afbad5d | 240 | * @endcode |
klauss | 69:65665afbad5d | 241 | */ |
klauss | 56:c64bcbaa621a | 242 | void set_telemetry_port( int new_telemetry_port ); |
klauss | 69:65665afbad5d | 243 | |
klauss | 69:65665afbad5d | 244 | /** |
klauss | 69:65665afbad5d | 245 | * @Synopsis Altera o valor default contido no arquivo /qspi/mymask.txt |
klauss | 69:65665afbad5d | 246 | * |
klauss | 69:65665afbad5d | 247 | * @param new_mask Atualiza o valor de /qspi/mymask.txt sobrescrevendo-o com o valor de new_mask |
klauss | 69:65665afbad5d | 248 | * |
klauss | 69:65665afbad5d | 249 | * Exemplo: |
klauss | 69:65665afbad5d | 250 | * @code |
klauss | 69:65665afbad5d | 251 | * ... |
klauss | 69:65665afbad5d | 252 | * set_mask( "255.255.0.0" ); |
klauss | 69:65665afbad5d | 253 | * ... |
klauss | 69:65665afbad5d | 254 | * @endcode |
klauss | 69:65665afbad5d | 255 | */ |
klauss | 55:2f5e7374af9d | 256 | void set_mask( char * new_mask ); |
klauss | 69:65665afbad5d | 257 | |
klauss | 69:65665afbad5d | 258 | /** |
klauss | 78:1353744f01e1 | 259 | * @Synopsis Altera o valor default contido no arquivo /qspi/mygateway.txt |
klauss | 69:65665afbad5d | 260 | * |
klauss | 78:1353744f01e1 | 261 | * @param new_gateway Atualiza o valor de /qspi/mygateway.txt sobrescrevendo-o com o valor de new_gateway |
klauss | 69:65665afbad5d | 262 | * |
klauss | 69:65665afbad5d | 263 | * Exemplo: |
klauss | 69:65665afbad5d | 264 | * @code |
klauss | 69:65665afbad5d | 265 | * ... |
klauss | 69:65665afbad5d | 266 | * set_gateway( "192.168.118.2" ); |
klauss | 69:65665afbad5d | 267 | * ... |
klauss | 69:65665afbad5d | 268 | * @endcode |
klauss | 69:65665afbad5d | 269 | */ |
klauss | 55:2f5e7374af9d | 270 | void set_gateway( char * new_gateway ); |
klauss | 17:67a6b557eda5 | 271 | |
klauss | 44:cc4996469404 | 272 | extern char * debug_buf; |
klauss | 69:65665afbad5d | 273 | ///< Buffer de entrada dos dados via serial. |
klauss | 17:67a6b557eda5 | 274 | |
klauss | 50:d9b6577a70f5 | 275 | |
klauss | 17:67a6b557eda5 | 276 | #endif |