diff --git a/README.md b/README.md index 44493de..3d4e6b3 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/firmware/0x00000.bin b/firmware/0x00000.bin index 29002e8..6c15bd2 100644 Binary files a/firmware/0x00000.bin and b/firmware/0x00000.bin differ diff --git a/firmware/0x10000.bin b/firmware/0x10000.bin index a27acdb..2f92aaf 100644 Binary files a/firmware/0x10000.bin and b/firmware/0x10000.bin differ diff --git a/firmware/sha1sums b/firmware/sha1sums index 5e703cd..690205d 100644 --- a/firmware/sha1sums +++ b/firmware/sha1sums @@ -1,2 +1,2 @@ -dddf4cf10bd0ceea1a417ed44752dfa0c56b2b59 0x00000.bin -68cfc30d818bd0a8ca7bb77b4065cb69f712f8ef 0x10000.bin +2d114ceba82ee7e63b16726534888665fe1d7b22 0x00000.bin +bdb01713a737a6f328b6a5953825758622e9e894 0x10000.bin diff --git a/user/config_flash.c b/user/config_flash.c index f6a5e2a..8ca08ae 100644 --- a/user/config_flash.c +++ b/user/config_flash.c @@ -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 diff --git a/user/config_flash.h b/user/config_flash.h index 6abb008..0ec743b 100644 --- a/user/config_flash.h +++ b/user/config_flash.h @@ -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) diff --git a/user/user_main.c b/user/user_main.c index 88d39f1..d069538 100644 --- a/user/user_main.c +++ b/user/user_main.c @@ -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] \r\n"); to_console(response); - os_sprintf(response, "set [network|dns|ip|netmask|gw|config_port|config_access] \r\n"); + os_sprintf(response, "set [network|dns|ip|netmask|gw] \r\n"); + to_console(response); + os_sprintf(response, "set [config_port|config_access|bitrate|system_output] \r\n"); to_console(response); os_sprintf(response, "set [broker_user|broker_password|broker_access|broker_clients] \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)