kopia lustrzana https://github.com/martin-ger/esp_mqtt
added serial config
rodzic
cf4eb6b718
commit
f1f3389bbc
|
@ -40,6 +40,8 @@ General commands:
|
|||
- set speed [80|160]: sets the CPU clock frequency (default 80 Mhz)
|
||||
- set config_port _portno_: sets the port number of the console login (default is 7777, 0 disables remote console config)
|
||||
- set config_access _mode_: controls the networks that allow config access (0: no access, 1: only internal, 2: only external, 3: both (default))
|
||||
- set bitrate [bps]: sets the serial bitrate (default 115200 bps)
|
||||
- set system_output [0|1]: enables/disables system info/warning output to serial port (default: on=1)
|
||||
- quit: terminates a remote session
|
||||
|
||||
WiFi and network related commands:
|
||||
|
|
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
|
@ -1,2 +1,2 @@
|
|||
dddf4cf10bd0ceea1a417ed44752dfa0c56b2b59 0x00000.bin
|
||||
68cfc30d818bd0a8ca7bb77b4065cb69f712f8ef 0x10000.bin
|
||||
2d114ceba82ee7e63b16726534888665fe1d7b22 0x00000.bin
|
||||
bdb01713a737a6f328b6a5953825758622e9e894 0x10000.bin
|
||||
|
|
|
@ -29,7 +29,10 @@ void config_load_default(sysconfig_p config) {
|
|||
config->dns_addr.addr = 0; // use DHCP
|
||||
config->my_addr.addr = 0; // use DHCP
|
||||
config->my_netmask.addr = 0; // use DHCP
|
||||
config->my_gw.addr = 0; // use DHCP
|
||||
config->my_gw.addr = 0; // use DHCP
|
||||
|
||||
config->system_output = 1;
|
||||
config->bit_rate = 115200;
|
||||
|
||||
config->mdns_mode = 0; // no mDNS
|
||||
|
||||
|
|
|
@ -49,6 +49,9 @@ typedef struct
|
|||
uint16_t config_port; // Port on which the concole listenes (0 if no access)
|
||||
uint8_t config_access; // Controls the interfaces that allow config access (default LOCAL_ACCESS | REMOTE_ACCESS)
|
||||
|
||||
uint8_t system_output; // Disable system info and warnings
|
||||
uint32_t bit_rate; // Bit rate of serial link
|
||||
|
||||
uint16_t max_subscriptions; // Upper limit on subscribed topics
|
||||
uint16_t max_retained_messages; // Upper limit on stored retained messages
|
||||
uint16_t max_clients; // Upper limit on concurrently connected clients (0: mem is the limit)
|
||||
|
|
|
@ -72,6 +72,7 @@ uint8_t remote_console_disconnect;
|
|||
struct espconn *console_conn;
|
||||
bool client_sent_pending;
|
||||
|
||||
LOCAL ICACHE_FLASH_ATTR void void_write_char(char c) {}
|
||||
|
||||
void ICACHE_FLASH_ATTR to_console(char *str) {
|
||||
ringbuf_memcpy_into(console_tx_buffer, str, os_strlen(str));
|
||||
|
@ -453,7 +454,9 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) {
|
|||
#endif
|
||||
os_sprintf(response, "set [ssid|password|auto_connect|ap_ssid|ap_password|ap_on|ap_open] <val>\r\n");
|
||||
to_console(response);
|
||||
os_sprintf(response, "set [network|dns|ip|netmask|gw|config_port|config_access] <val>\r\n");
|
||||
os_sprintf(response, "set [network|dns|ip|netmask|gw] <val>\r\n");
|
||||
to_console(response);
|
||||
os_sprintf(response, "set [config_port|config_access|bitrate|system_output] <val>\r\n");
|
||||
to_console(response);
|
||||
os_sprintf(response, "set [broker_user|broker_password|broker_access|broker_clients] <val>\r\n");
|
||||
to_console(response);
|
||||
|
@ -571,6 +574,12 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) {
|
|||
#endif
|
||||
os_sprintf(response, "Clock speed: %d\r\n", config.clock_speed);
|
||||
to_console(response);
|
||||
|
||||
os_sprintf(response, "Serial bitrate: %d\r\n", config.bit_rate);
|
||||
to_console(response);
|
||||
if (!config.system_output)
|
||||
to_console("System output: off\r\n");
|
||||
|
||||
goto command_handled_2;
|
||||
}
|
||||
|
||||
|
@ -1067,9 +1076,24 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) {
|
|||
goto command_handled;
|
||||
}
|
||||
|
||||
if (strcmp(tokens[1],"bitrate") == 0)
|
||||
{
|
||||
config.bit_rate = atoi(tokens[2]);
|
||||
os_sprintf(response, "Bitrate set to %d\r\n", config.bit_rate);
|
||||
goto command_handled;
|
||||
}
|
||||
|
||||
if (strcmp(tokens[1],"system_output") == 0)
|
||||
{
|
||||
config.system_output = atoi(tokens[2]);
|
||||
os_sprintf(response, "System output %s\r\n", config.system_output?"on":"off");
|
||||
goto command_handled;
|
||||
}
|
||||
|
||||
if (strcmp(tokens[1], "network") == 0) {
|
||||
config.network_addr.addr = ipaddr_addr(tokens[2]);
|
||||
ip4_addr4(&config.network_addr) = 0;
|
||||
os_sprintf(response, "Network set to %d.%d.%d.%d\r\n", IP2STR(&config.network_addr));
|
||||
goto command_handled;
|
||||
}
|
||||
|
||||
|
@ -1703,6 +1727,7 @@ void user_init() {
|
|||
#endif
|
||||
init_long_systime();
|
||||
|
||||
// Temporarily initialize the UART with 115200
|
||||
UART_init_console(BIT_RATE_115200, 0, console_rx_buffer, console_tx_buffer);
|
||||
|
||||
os_printf("\r\n\r\nWiFi Router/MQTT Broker V2.0 starting\r\n");
|
||||
|
@ -1736,6 +1761,15 @@ void user_init() {
|
|||
}
|
||||
#endif
|
||||
|
||||
// Set bit rate to config value
|
||||
uart_div_modify(0, UART_CLK_FREQ / config.bit_rate);
|
||||
|
||||
if (!config.system_output) {
|
||||
// all system output to /dev/null
|
||||
system_set_os_print(0);
|
||||
os_install_putc1(void_write_char);
|
||||
}
|
||||
|
||||
// Configure the AP and start it, if required
|
||||
|
||||
if (config.dns_addr.addr != 0)
|
||||
|
|
Ładowanie…
Reference in New Issue