Prep for release with fix some warnings

Prep for release with fix some warnings
This commit is contained in:
Theo Arends 2019-03-14 16:50:56 +01:00
parent 71279f6353
commit 2959ec9341
5 changed files with 38 additions and 53 deletions

View File

@ -200,8 +200,8 @@ struct SYSCFG {
uint8_t seriallog_level; // 09E
uint8_t sta_config; // 09F
uint8_t sta_active; // 0A0
char sta_ssid[2][33]; // 0A1 - Keep together with sta_pwd as being copied as one chunck with reset 4/5
char sta_pwd[2][65]; // 0E3 - Keep together with sta_ssid as being copied as one chunck with reset 4/5
char sta_ssid[2][33]; // 0A1 - Keep together with sta_pwd as being copied as one chunck with reset 5
char sta_pwd[2][65]; // 0E3 - Keep together with sta_ssid as being copied as one chunck with reset 5
char hostname[33]; // 165
char syslog_host[33]; // 186
uint8_t rule_stop; // 1A7
@ -213,12 +213,12 @@ struct SYSCFG {
uint8_t free_1D5[20]; // 1D5 Free since 5.12.0e
char mqtt_host[33]; // 1E9
uint16_t mqtt_port; // 20A
char mqtt_client[33]; // 20C
char mqtt_user[33]; // 22D
char mqtt_pwd[33]; // 24E
char mqtt_topic[33]; // 26F
char mqtt_host[33]; // 1E9 - Keep together with below as being copied as one chunck with reset 6
uint16_t mqtt_port; // 20A - Keep together
char mqtt_client[33]; // 20C - Keep together
char mqtt_user[33]; // 22D - Keep together
char mqtt_pwd[33]; // 24E - Keep together
char mqtt_topic[33]; // 26F - Keep together with above items as being copied as one chunck with reset 6
char button_topic[33]; // 290
char mqtt_grptopic[33]; // 2B1
uint8_t display_model; // 2D2

View File

@ -2082,31 +2082,26 @@ void Every250mSeconds(void)
}
if (restart_flag && (backlog_pointer == backlog_index)) {
if ((214 == restart_flag) || (215 == restart_flag) || (216 == restart_flag)) {
char storage[sizeof(Settings.sta_ssid) + sizeof(Settings.sta_pwd)];
char storage_mqtt_host[sizeof(Settings.mqtt_host)];
uint16_t storage_mqtt_port;
char storage_mqtt_user[sizeof(Settings.mqtt_user)];
char storage_mqtt_pwd[sizeof(Settings.mqtt_pwd)];
char storage_mqtt_topic[sizeof(Settings.mqtt_topic)];
memcpy(storage, Settings.sta_ssid, sizeof(storage)); // Backup current SSIDs and Passwords
char storage_wifi[sizeof(Settings.sta_ssid) +
sizeof(Settings.sta_pwd)];
char storage_mqtt[sizeof(Settings.mqtt_host) +
sizeof(Settings.mqtt_port) +
sizeof(Settings.mqtt_client) +
sizeof(Settings.mqtt_user) +
sizeof(Settings.mqtt_pwd) +
sizeof(Settings.mqtt_topic)];
memcpy(storage_wifi, Settings.sta_ssid, sizeof(storage_wifi)); // Backup current SSIDs and Passwords
if (216 == restart_flag) {
memcpy(storage_mqtt_host, Settings.mqtt_host, sizeof(Settings.mqtt_host));
storage_mqtt_port = Settings.mqtt_port;
memcpy(storage_mqtt_user, Settings.mqtt_user, sizeof(Settings.mqtt_user));
memcpy(storage_mqtt_pwd, Settings.mqtt_pwd, sizeof(Settings.mqtt_pwd));
memcpy(storage_mqtt_topic, Settings.mqtt_topic, sizeof(Settings.mqtt_topic));
memcpy(storage_mqtt, Settings.mqtt_host, sizeof(storage_mqtt)); // Backup mqtt host, port, client, username and password
}
if ((215 == restart_flag) || (216 == restart_flag)) {
SettingsErase(0); // Erase all flash from program end to end of physical flash
}
SettingsDefault();
memcpy(Settings.sta_ssid, storage, sizeof(storage)); // Restore current SSIDs and Passwords
if (216 == restart_flag) { // Restore the mqtt host, port, username and password
memcpy(Settings.mqtt_host, storage_mqtt_host, sizeof(Settings.mqtt_host));
Settings.mqtt_port = storage_mqtt_port;
memcpy(Settings.mqtt_user, storage_mqtt_user, sizeof(Settings.mqtt_user));
memcpy(Settings.mqtt_pwd, storage_mqtt_pwd, sizeof(Settings.mqtt_pwd));
memcpy(Settings.mqtt_topic, storage_mqtt_topic, sizeof(Settings.mqtt_topic));
memcpy(Settings.sta_ssid, storage_wifi, sizeof(storage_wifi)); // Restore current SSIDs and Passwords
if (216 == restart_flag) {
memcpy(Settings.mqtt_host, storage_mqtt, sizeof(storage_mqtt)); // Restore the mqtt host, port, client, username and password
strlcpy(Settings.mqtt_client, MQTT_CLIENT_ID, sizeof(Settings.mqtt_client)); // Set client to default
}
restart_flag = 2;
}

View File

@ -1278,7 +1278,7 @@ void AddLog_P2(uint8_t loglevel, PGM_P formatP, ...)
{
va_list arg;
va_start(arg, formatP);
int len = vsnprintf_P(log_data, sizeof(log_data), formatP, arg);
vsnprintf_P(log_data, sizeof(log_data), formatP, arg);
va_end(arg);
AddLog(loglevel);

View File

@ -272,7 +272,7 @@ const char HTTP_HEAD_STYLE3[] PROGMEM =
#else
"<h3>%s " D_MODULE "</h3>"
#endif
"<h2>%s</h2>%s</div>";
"<h2>%s</h2>";
const char HTTP_MSG_SLIDER1[] PROGMEM =
"<div><span class='p'>" D_COLDLIGHT "</span><span class='q'>" D_WARMLIGHT "</span></div>"
@ -566,27 +566,6 @@ bool HttpCheckPriviledgedAccess(bool autorequestauth = true)
return true;
}
String WSNetworkInfo(void)
{
String info = "";
if (Settings.flag3.gui_hostname_ip) {
uint8_t more_ips = 0;
info += F("<h3>"); info += my_hostname;
if (mdns_begun) { info += F(".local"); }
info += F(" (");
if (static_cast<uint32_t>(WiFi.localIP()) != 0) {
info += WiFi.localIP().toString();
more_ips++;
}
if (static_cast<uint32_t>(WiFi.softAPIP()) != 0) {
if (more_ips) { info += F(", "); }
info += WiFi.softAPIP().toString();
}
info += F(")</h3>");
}
return info;
}
void WSHeaderSend(void)
{
WebServer->sendHeader(F("Cache-Control"), F("no-cache, no-store, must-revalidate"));
@ -701,7 +680,18 @@ void WSContentSendStyle_P(const char* style)
WSContentSend_P(HTTP_HEAD_STYLE1);
WSContentSend_P(HTTP_HEAD_STYLE2);
WSContentSend_P(style);
WSContentSend_P(HTTP_HEAD_STYLE3, ModuleName().c_str(), Settings.friendlyname[0], WSNetworkInfo().c_str());
WSContentSend_P(HTTP_HEAD_STYLE3, ModuleName().c_str(), Settings.friendlyname[0]);
if (Settings.flag3.gui_hostname_ip) {
bool lip = (static_cast<uint32_t>(WiFi.localIP()) != 0);
bool sip = (static_cast<uint32_t>(WiFi.softAPIP()) != 0);
WSContentSend_P(PSTR("<h4>%s%s (%s%s%s)</h4>"), // sonoff.local (192.168.2.12,192.168.4.1)
my_hostname,
(mdns_begun) ? ".local" : "",
(lip) ? WiFi.localIP().toString().c_str() : "",
(lip && sip) ? "," : "",
(sip) ? WiFi.softAPIP().toString().c_str() : "");
}
WSContentSend_P(PSTR("</div>"));
}
void WSContentSendStyle(void)
@ -812,7 +802,7 @@ void HandleRoot(void)
if ((Settings.web_password[0] != 0) && !(WebServer->hasArg("USER1")) && !(WebServer->hasArg("PASS1")) && HTTP_MANAGER_RESET_ONLY != webserver_state) {
HandleWifiLogin();
} else {
if (!(Settings.web_password[0] != 0) || ((WebServer->arg("USER1") == WEB_USERNAME ) && (WebServer->arg("PASS1") == Settings.web_password ) || HTTP_MANAGER_RESET_ONLY == webserver_state)) {
if (!(Settings.web_password[0] != 0) || (((WebServer->arg("USER1") == WEB_USERNAME ) && (WebServer->arg("PASS1") == Settings.web_password )) || HTTP_MANAGER_RESET_ONLY == webserver_state)) {
HandleWifiConfiguration();
} else {
// wrong user and pass

View File

@ -166,7 +166,7 @@ static void Shorten(char** s, char *prefix)
}
}
int try_snprintf_P(char *s, size_t n, const char *format, ... )
void try_snprintf_P(char *s, int n, const char *format, ... )
{
va_list args;
va_start(args, format);