![](/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
config_manager.h@132:05cd37f7e007, 2015-09-01 (annotated)
- Committer:
- klauss
- Date:
- Tue Sep 01 17:21:11 2015 +0000
- Revision:
- 132:05cd37f7e007
- Child:
- 133:3d136f5ffd66
Substitui??o de; send_msg -> vz_printf; debug_msg -> vz_debug
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 132:05cd37f7e007 | 1 | %: ifndef __CONFIG_MANAGER_H__ |
klauss | 132:05cd37f7e007 | 2 | %: define __CONFIG_MANAGER_H__ |
klauss | 132:05cd37f7e007 | 3 | |
klauss | 132:05cd37f7e007 | 4 | %: include <stdint.h> |
klauss | 132:05cd37f7e007 | 5 | %: include <string.h> |
klauss | 132:05cd37f7e007 | 6 | %: include "file_system_manager.h" |
klauss | 132:05cd37f7e007 | 7 | |
klauss | 132:05cd37f7e007 | 8 | /** |
klauss | 132:05cd37f7e007 | 9 | * Classe que representa lógicamente os valores das variáveis de |
klauss | 132:05cd37f7e007 | 10 | * ambiente usadas pela Cabeceira, estas variáveis são arquivadas |
klauss | 132:05cd37f7e007 | 11 | * em arquivos e carregadas durante o boot. |
klauss | 132:05cd37f7e007 | 12 | * |
klauss | 132:05cd37f7e007 | 13 | * Header IP 192.168.120.171 |
klauss | 132:05cd37f7e007 | 14 | * Header ext 820 |
klauss | 132:05cd37f7e007 | 15 | * Header port 5062 |
klauss | 132:05cd37f7e007 | 16 | * Server IP 192.168.120.120 |
klauss | 132:05cd37f7e007 | 17 | * Server ext 723 |
klauss | 132:05cd37f7e007 | 18 | * Server port 5075 |
klauss | 132:05cd37f7e007 | 19 | * Mascara de rede 255.255.255.0 |
klauss | 132:05cd37f7e007 | 20 | * Gateway IP 192.168.120.1 |
klauss | 132:05cd37f7e007 | 21 | * FW Server IP 192.168.120.120 |
klauss | 132:05cd37f7e007 | 22 | * FW Server Port 6667 |
klauss | 132:05cd37f7e007 | 23 | * Max Ext 6000 |
klauss | 132:05cd37f7e007 | 24 | * Min Ext 5000 |
klauss | 132:05cd37f7e007 | 25 | * Shift Port 3000 |
klauss | 132:05cd37f7e007 | 26 | */ |
klauss | 132:05cd37f7e007 | 27 | |
klauss | 132:05cd37f7e007 | 28 | const uint16_t u16_SHIFT_PORT = 3000; |
klauss | 132:05cd37f7e007 | 29 | ///< Deslocamento padrão de porta, usado na forma <ext recebido + SHIFT_PORT> |
klauss | 132:05cd37f7e007 | 30 | |
klauss | 132:05cd37f7e007 | 31 | const char MY_IP[] = "192.168.120.171"; |
klauss | 132:05cd37f7e007 | 32 | ///< Representa o IP default da Header. |
klauss | 132:05cd37f7e007 | 33 | //#define __MY_IP__ "192.168.2.20?" // Colinas |
klauss | 132:05cd37f7e007 | 34 | //#define __MY_IP__ "192.168.1.200" // Colinas |
klauss | 132:05cd37f7e007 | 35 | |
klauss | 132:05cd37f7e007 | 36 | const char SERVER_IP[] = "192.168.120.120"; |
klauss | 132:05cd37f7e007 | 37 | ///< Indica o IP defaut do servidor para onde a Header ira encaminhar pedidos de ligação. |
klauss | 132:05cd37f7e007 | 38 | //#define __SERVER_IP__ "192.168.30.25" // Colinas |
klauss | 132:05cd37f7e007 | 39 | |
klauss | 132:05cd37f7e007 | 40 | const uint16_t u16_MIN_EXT = 1; |
klauss | 132:05cd37f7e007 | 41 | ///< Define o valor minimo de ramal que sera processado. |
klauss | 132:05cd37f7e007 | 42 | |
klauss | 132:05cd37f7e007 | 43 | const uint16_t u16_MAX_EXT = 5999; |
klauss | 132:05cd37f7e007 | 44 | ///< Define o valor máximo de ramal que sera processado. |
klauss | 132:05cd37f7e007 | 45 | |
klauss | 132:05cd37f7e007 | 46 | const uint16_t u16_MY_EXT = 820; |
klauss | 132:05cd37f7e007 | 47 | ///< Indica o ramal default da Header. |
klauss | 132:05cd37f7e007 | 48 | |
klauss | 132:05cd37f7e007 | 49 | const uint16_t u16_MY_PORT = 5062; |
klauss | 132:05cd37f7e007 | 50 | ///< Representa a porta default da Header. |
klauss | 132:05cd37f7e007 | 51 | |
klauss | 132:05cd37f7e007 | 52 | const uint16_t u16_PEER_EXT = 913; |
klauss | 132:05cd37f7e007 | 53 | ///< Estabelece o ramal default para onde a Header ira direcionar os pedidos de ligações. |
klauss | 132:05cd37f7e007 | 54 | //#define __PEER_EXT__ 812 // VZ Producao |
klauss | 132:05cd37f7e007 | 55 | //#define __PEER_EXT__ 813 // VZ Desenvolvimento |
klauss | 132:05cd37f7e007 | 56 | |
klauss | 132:05cd37f7e007 | 57 | const uint16_t u16_SERVER_PORT = 5075; |
klauss | 132:05cd37f7e007 | 58 | ///< Indica a porta default do server para onde os pacotes eth serão enviados na negociação SIP. |
klauss | 132:05cd37f7e007 | 59 | //#define __SERVER_PORT__ 5060 // Colinas |
klauss | 132:05cd37f7e007 | 60 | |
klauss | 132:05cd37f7e007 | 61 | const char MY_MSK[] = "255.255.255.0"; |
klauss | 132:05cd37f7e007 | 62 | ///< Indica a mascara de rede onde a Header se encontra. |
klauss | 132:05cd37f7e007 | 63 | //#define __MY_GTW__ "192.168.2.254" // Colinas |
klauss | 132:05cd37f7e007 | 64 | |
klauss | 132:05cd37f7e007 | 65 | const char MY_GTW[] = "192.168.120.1"; // vz |
klauss | 132:05cd37f7e007 | 66 | ///< Indica o IP do Gateway de rede |
klauss | 132:05cd37f7e007 | 67 | |
klauss | 132:05cd37f7e007 | 68 | const uint16_t u16_UDP_PORT_LISTENER = 11406; |
klauss | 132:05cd37f7e007 | 69 | ///< Porta UDP na qual a Header espera por eventuais mensagens. |
klauss | 132:05cd37f7e007 | 70 | |
klauss | 132:05cd37f7e007 | 71 | const uint16_t u16_TCP_PORT_LISTENER = 7879; |
klauss | 132:05cd37f7e007 | 72 | ///< Porta TCP na qual a Header espera por eventuais mensagens. |
klauss | 132:05cd37f7e007 | 73 | |
klauss | 132:05cd37f7e007 | 74 | const uint16_t u16_UDP_BOOTLOADER_PORT = 9891; |
klauss | 132:05cd37f7e007 | 75 | ///< Porta UDP para tratativas do procedimento de gravação dos CBx. |
klauss | 132:05cd37f7e007 | 76 | |
klauss | 132:05cd37f7e007 | 77 | const char FW_SERVER_IP[] = "192.168.120.144"; |
klauss | 132:05cd37f7e007 | 78 | ///< Estabelece o IP default para onde os dados de telemetria são enviados. |
klauss | 132:05cd37f7e007 | 79 | const uint16_t u16_FW_SERVER_PORT = 9192; |
klauss | 132:05cd37f7e007 | 80 | ///< Estabelece a porta default do servidor para onde os dados de telemetria são enviados |
klauss | 132:05cd37f7e007 | 81 | |
klauss | 132:05cd37f7e007 | 82 | const uint8_t u8_IP_LENGTH = 46; |
klauss | 132:05cd37f7e007 | 83 | |
klauss | 132:05cd37f7e007 | 84 | class ConfigManager |
klauss | 132:05cd37f7e007 | 85 | { |
klauss | 132:05cd37f7e007 | 86 | private : |
klauss | 132:05cd37f7e007 | 87 | char chHeader_ip[ u8_IP_LENGTH ]; |
klauss | 132:05cd37f7e007 | 88 | uint16_t u16Ext; |
klauss | 132:05cd37f7e007 | 89 | uint16_t u16Port; |
klauss | 132:05cd37f7e007 | 90 | char chServer_ip[ u8_IP_LENGTH ]; |
klauss | 132:05cd37f7e007 | 91 | uint16_t u16Server_ext; |
klauss | 132:05cd37f7e007 | 92 | uint16_t u16Server_port; |
klauss | 132:05cd37f7e007 | 93 | char chNet_mask[ u8_IP_LENGTH ]; |
klauss | 132:05cd37f7e007 | 94 | char chGateway[ u8_IP_LENGTH ]; |
klauss | 132:05cd37f7e007 | 95 | char chFw_server_ip[ u8_IP_LENGTH ]; |
klauss | 132:05cd37f7e007 | 96 | uint16_t u16Fw_server_port; |
klauss | 132:05cd37f7e007 | 97 | uint16_t u16Max_ext; |
klauss | 132:05cd37f7e007 | 98 | uint16_t u16Min_ext; |
klauss | 132:05cd37f7e007 | 99 | uint16_t u16Shift_port; |
klauss | 132:05cd37f7e007 | 100 | uint16_t u16Udp_port_listener; |
klauss | 132:05cd37f7e007 | 101 | uint16_t u16Tcp_port_listener; |
klauss | 132:05cd37f7e007 | 102 | bool boolModified; |
klauss | 132:05cd37f7e007 | 103 | bool boolHeader_ip_was_modified; |
klauss | 132:05cd37f7e007 | 104 | bool boolServer_ip_was_modified; |
klauss | 132:05cd37f7e007 | 105 | bool boolNet_mask_was_modified; |
klauss | 132:05cd37f7e007 | 106 | bool boolGateway_was_modified; |
klauss | 132:05cd37f7e007 | 107 | bool boolFw_server_ip_was_modified; |
klauss | 132:05cd37f7e007 | 108 | bool boolHeader_ext_was_modified; |
klauss | 132:05cd37f7e007 | 109 | bool boolHeader_sip_port_was_modified; |
klauss | 132:05cd37f7e007 | 110 | bool boolServer_ext_was_modified; |
klauss | 132:05cd37f7e007 | 111 | bool boolServer_port_was_modified; |
klauss | 132:05cd37f7e007 | 112 | bool boolFw_server_port_was_modified; |
klauss | 132:05cd37f7e007 | 113 | bool boolMax_ext_was_modified; |
klauss | 132:05cd37f7e007 | 114 | bool boolMin_ext_was_modified; |
klauss | 132:05cd37f7e007 | 115 | bool boolShift_port_was_modified; |
klauss | 132:05cd37f7e007 | 116 | char chClock_erver_ip [ u8_IP_LENGTH ]; |
klauss | 132:05cd37f7e007 | 117 | |
klauss | 132:05cd37f7e007 | 118 | |
klauss | 132:05cd37f7e007 | 119 | public : |
klauss | 132:05cd37f7e007 | 120 | ConfigManager ( void ); |
klauss | 132:05cd37f7e007 | 121 | ~ConfigManager ( void ); |
klauss | 132:05cd37f7e007 | 122 | |
klauss | 132:05cd37f7e007 | 123 | char * get_header_ip ( char * buffer ); |
klauss | 132:05cd37f7e007 | 124 | char * get_server_ip ( char * buffer ); |
klauss | 132:05cd37f7e007 | 125 | char * get_net_mask ( char * buffer ); |
klauss | 132:05cd37f7e007 | 126 | char * get_gateway ( char * buffer ); |
klauss | 132:05cd37f7e007 | 127 | char * get_fw_server_ip ( char * buffer ); |
klauss | 132:05cd37f7e007 | 128 | char * get_clock_server_ip ( char * buffer ); |
klauss | 132:05cd37f7e007 | 129 | |
klauss | 132:05cd37f7e007 | 130 | uint16_t get_ext ( void ); |
klauss | 132:05cd37f7e007 | 131 | uint16_t get_port ( void ); |
klauss | 132:05cd37f7e007 | 132 | uint16_t get_server_ext ( void ); |
klauss | 132:05cd37f7e007 | 133 | uint16_t get_server_port ( void ); |
klauss | 132:05cd37f7e007 | 134 | uint16_t get_fw_server_port ( void ); |
klauss | 132:05cd37f7e007 | 135 | uint16_t get_max_ext ( void ); |
klauss | 132:05cd37f7e007 | 136 | uint16_t get_min_ext ( void ); |
klauss | 132:05cd37f7e007 | 137 | uint16_t get_shift_port ( void ); |
klauss | 132:05cd37f7e007 | 138 | uint16_t get_udp_port_listener ( void ); |
klauss | 132:05cd37f7e007 | 139 | uint16_t get_tcp_port_listener ( void ); |
klauss | 132:05cd37f7e007 | 140 | bool was_modified ( void ); |
klauss | 132:05cd37f7e007 | 141 | |
klauss | 132:05cd37f7e007 | 142 | bool header_ip_was_modified ( void ); |
klauss | 132:05cd37f7e007 | 143 | bool server_ip_was_modified ( void ); |
klauss | 132:05cd37f7e007 | 144 | bool net_mask_was_modified ( void ); |
klauss | 132:05cd37f7e007 | 145 | bool gateway_was_modified ( void ); |
klauss | 132:05cd37f7e007 | 146 | bool fw_server_ip_was_modified ( void ); |
klauss | 132:05cd37f7e007 | 147 | bool header_ext_was_modified ( void ); |
klauss | 132:05cd37f7e007 | 148 | bool header_sip_port_was_modified ( void ); |
klauss | 132:05cd37f7e007 | 149 | bool server_ext_was_modified ( void ); |
klauss | 132:05cd37f7e007 | 150 | bool server_port_was_modified ( void ); |
klauss | 132:05cd37f7e007 | 151 | bool fw_server_port_was_modified ( void ); |
klauss | 132:05cd37f7e007 | 152 | bool max_ext_was_modified ( void ); |
klauss | 132:05cd37f7e007 | 153 | bool min_ext_was_modified ( void ); |
klauss | 132:05cd37f7e007 | 154 | bool shift_port_was_modified ( void ); |
klauss | 132:05cd37f7e007 | 155 | |
klauss | 132:05cd37f7e007 | 156 | void set_header_ip ( const char * new_header_ip ); |
klauss | 132:05cd37f7e007 | 157 | void set_server_ip ( const char * new_server_ip ); |
klauss | 132:05cd37f7e007 | 158 | void set_net_mask ( const char * new_net_mask ); |
klauss | 132:05cd37f7e007 | 159 | void set_gateway ( const char * new_gateway ); |
klauss | 132:05cd37f7e007 | 160 | void set_fw_server_ip ( const char * new_fw_server_ip ); |
klauss | 132:05cd37f7e007 | 161 | void set_header_ext ( const uint16_t new_ext ); |
klauss | 132:05cd37f7e007 | 162 | void set_header_sip_port ( const uint16_t new_port ); |
klauss | 132:05cd37f7e007 | 163 | void set_server_ext ( const uint16_t new_server_ext ); |
klauss | 132:05cd37f7e007 | 164 | void set_server_port ( const uint16_t new_server_port ); |
klauss | 132:05cd37f7e007 | 165 | void set_fw_server_port ( const uint16_t new_fw_server_port ); |
klauss | 132:05cd37f7e007 | 166 | void set_max_ext ( const uint16_t new_max_ext ); |
klauss | 132:05cd37f7e007 | 167 | void set_min_ext ( const uint16_t new_min_ext ); |
klauss | 132:05cd37f7e007 | 168 | void set_shift_port ( const uint16_t new_shift_port ); |
klauss | 132:05cd37f7e007 | 169 | void set_udp_port_listener ( const uint16_t new_udp_port_listener ); |
klauss | 132:05cd37f7e007 | 170 | void set_tcp_port_listener ( const uint16_t new_tcp_port_listener ); |
klauss | 132:05cd37f7e007 | 171 | void set_modified_true ( void ); |
klauss | 132:05cd37f7e007 | 172 | void set_modified_false ( void ); |
klauss | 132:05cd37f7e007 | 173 | |
klauss | 132:05cd37f7e007 | 174 | void restore_defaults_settings ( void ); |
klauss | 132:05cd37f7e007 | 175 | }; |
klauss | 132:05cd37f7e007 | 176 | |
klauss | 132:05cd37f7e007 | 177 | %: endif |