master
martin-ger 2019-01-02 09:21:22 +01:00
rodzic 325923773f
commit 2d613c3f90
8 zmienionych plików z 27 dodań i 25 usunięć

2
.gitignore vendored
Wyświetl plik

@ -4,3 +4,5 @@ build/
.settings/
.DS_Store
include/user_config.local.h
scripts/script.demo
scripts/script.timers

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -1,2 +1,2 @@
7163ff45862ab01f061e256cd16ad1e083fe8df0 0x00000.bin
92fdb9a489a04461351fff59ac94adc618a3d17d 0x10000.bin
834399a6fc66a609ab06b6ac58e0e371d853d256 0x00000.bin
bad4fb09c6ac1b86e06de459e570fe3aee8186e0 0x10000.bin

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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

Wyświetl plik

@ -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"