diff --git a/.gitignore b/.gitignore index 963f8cb..eceb219 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ build/ .settings/ .DS_Store include/user_config.local.h +scripts/script.demo +scripts/script.timers diff --git a/firmware/0x00000.bin b/firmware/0x00000.bin index 00f8ab9..a9fbf0a 100644 Binary files a/firmware/0x00000.bin and b/firmware/0x00000.bin differ diff --git a/firmware/0x10000.bin b/firmware/0x10000.bin index c033b91..788962f 100644 Binary files a/firmware/0x10000.bin and b/firmware/0x10000.bin differ diff --git a/firmware/sha1sums b/firmware/sha1sums index e58ff2f..b8881ee 100644 --- a/firmware/sha1sums +++ b/firmware/sha1sums @@ -1,2 +1,2 @@ -7163ff45862ab01f061e256cd16ad1e083fe8df0 0x00000.bin -92fdb9a489a04461351fff59ac94adc618a3d17d 0x10000.bin +834399a6fc66a609ab06b6ac58e0e371d853d256 0x00000.bin +bad4fb09c6ac1b86e06de459e570fe3aee8186e0 0x10000.bin diff --git a/user/cli.c b/user/cli.c index 2a9ab13..e25e2dd 100644 --- a/user/cli.c +++ b/user/cli.c @@ -909,8 +909,8 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) { } if (strcmp(tokens[1], "broker_user") == 0) { - os_strncpy(config.mqtt_broker_user, tokens[2], 32); - config.mqtt_broker_user[31] = '\0'; + os_strncpy(config.mqtt_broker_user, tokens[2], sizeof(config.mqtt_broker_user)); + config.mqtt_broker_user[sizeof(config.mqtt_broker_user)-1] = '\0'; os_sprintf_flash(response, "Broker username set\r\n"); goto command_handled; } @@ -919,8 +919,8 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) { if (os_strcmp(tokens[2], "none") == 0) { config.mqtt_broker_password[0] = '\0'; } else { - os_strncpy(config.mqtt_broker_password, tokens[2], 32); - config.mqtt_broker_password[31] = '\0'; + os_strncpy(config.mqtt_broker_password, tokens[2], sizeof(config.mqtt_broker_password)); + config.mqtt_broker_password[sizeof(config.mqtt_broker_password)-1] = '\0'; } os_sprintf_flash(response, "Broker password set\r\n"); goto command_handled; @@ -993,8 +993,8 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) { #endif #ifdef NTP if (strcmp(tokens[1], "ntp_server") == 0) { - os_strncpy(config.ntp_server, tokens[2], 32); - config.ntp_server[31] = 0; + os_strncpy(config.ntp_server, tokens[2], sizeof(config.ntp_server)); + config.ntp_server[sizeof(config.ntp_server)-1] = '\0'; ntp_set_server(config.ntp_server); os_sprintf(response, "NTP server set to %s\r\n", config.ntp_server); goto command_handled; @@ -1036,16 +1036,16 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) { #endif #ifdef DNS_RESP if (strcmp(tokens[1], "dns_name") == 0) { - os_strncpy(config.broker_dns_name, tokens[2], 32); - config.mqtt_host[31] = 0; + os_strncpy(config.broker_dns_name, tokens[2], sizeof(config.broker_dns_name)); + config.mqtt_host[sizeof(config.broker_dns_name)-1] = '\0'; os_sprintf_flash(response, "DNS name set\r\n"); goto command_handled; } #endif #ifdef MQTT_CLIENT if (strcmp(tokens[1], "mqtt_host") == 0) { - os_strncpy(config.mqtt_host, tokens[2], 32); - config.mqtt_host[31] = 0; + os_strncpy(config.mqtt_host, tokens[2], sizeof(config.mqtt_host)); + config.mqtt_host[sizeof(config.mqtt_host)-1] = '\0'; os_sprintf_flash(response, "MQTT host set\r\n"); goto command_handled; } @@ -1063,22 +1063,22 @@ void ICACHE_FLASH_ATTR console_handle_command(struct espconn *pespconn) { } if (strcmp(tokens[1], "mqtt_user") == 0) { - os_strncpy(config.mqtt_user, tokens[2], 32); - config.mqtt_user[31] = 0; + os_strncpy(config.mqtt_user, tokens[2], sizeof(config.mqtt_user)); + config.mqtt_user[sizeof(config.mqtt_user)-1] = '\0'; os_sprintf_flash(response, "MQTT user set\r\n"); goto command_handled; } if (strcmp(tokens[1], "mqtt_password") == 0) { - os_strncpy(config.mqtt_password, tokens[2], 32); - config.mqtt_password[31] = 0; + os_strncpy(config.mqtt_password, tokens[2], sizeof(config.mqtt_password)); + config.mqtt_password[sizeof(config.mqtt_password)-1] = '\0'; os_sprintf_flash(response, "MQTT password set\r\n"); goto command_handled; } if (strcmp(tokens[1], "mqtt_id") == 0) { - os_strncpy(config.mqtt_id, tokens[2], 32); - config.mqtt_id[31] = 0; + os_strncpy(config.mqtt_id, tokens[2], sizeof(config.mqtt_id)); + config.mqtt_id[sizeof(config.mqtt_id)-1] = '\0'; os_sprintf_flash(response, "MQTT id set\r\n"); goto command_handled; } diff --git a/user/config_flash.c b/user/config_flash.c index 191f22e..0c459f7 100644 --- a/user/config_flash.c +++ b/user/config_flash.c @@ -87,13 +87,13 @@ int ICACHE_FLASH_ATTR config_load(sysconfig_p config) { return -1; } - os_printf("\r\nConfig found and loaded\r\n"); + os_printf("\r\nConfig found and loaded\r\n"); spi_flash_read(base_address * SPI_FLASH_SEC_SIZE, (uint32 *) config, sizeof(sysconfig_t)); if (config->length != sizeof(sysconfig_t)) { - os_printf("Length Mismatch, probably old version of config, loading defaults\r\n"); - config_load_default(config); - config_save(config); - return -1; + os_printf("Length Mismatch, probably old version of config, loading defaults\r\n"); + config_load_default(config); + config_save(config); + return -1; } return 0; } diff --git a/user/config_flash.h b/user/config_flash.h index a39e0c4..ec793d1 100644 --- a/user/config_flash.h +++ b/user/config_flash.h @@ -74,7 +74,7 @@ typedef struct uint8_t mqtt_user[32]; // Username for broker login, "none" if empty uint8_t mqtt_password[32]; // Password for broker login - uint8_t mqtt_id[32]; // MQTT clientId + uint8_t mqtt_id[48]; // MQTT clientId #endif #ifdef NTP uint8_t ntp_server[32]; // IP or hostname of the MQTT broker, "none" if empty diff --git a/user/user_config.h b/user/user_config.h index 5057a72..171bbf5 100644 --- a/user/user_config.h +++ b/user/user_config.h @@ -1,7 +1,7 @@ #ifndef _USER_CONFIG_ #define _USER_CONFIG_ -#define ESP_UBROKER_VERSION "V2.0.7" +#define ESP_UBROKER_VERSION "V2.0.8" #define WIFI_SSID "ssid" #define WIFI_PASSWORD "password"