mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-24 11:46:34 +00:00
Code cleanup
This commit is contained in:
parent
51423a9f83
commit
e07426a94c
@ -443,12 +443,6 @@ void mqttReconnect()
|
||||
mqtt_send_statusupdate();
|
||||
}
|
||||
|
||||
void mqttPreSetup()
|
||||
{
|
||||
// mqttClient.setCallback(mqtt_message_cb);
|
||||
// mqttClient.setBufferSize(1024);
|
||||
}
|
||||
|
||||
void mqttSetup()
|
||||
{
|
||||
mqttEnabled = strlen(mqttServer) > 0 && mqttPort > 0;
|
||||
|
@ -73,8 +73,9 @@ static void kb_event_cb(lv_obj_t * event_kb, lv_event_t event)
|
||||
}
|
||||
|
||||
if(strlen(ssid) > 0) {
|
||||
wifiSetConfig(settings.as<JsonObject>());
|
||||
if(wifiTestConnection()) {
|
||||
if(wifiValidateSsid(ssid, pass)) {
|
||||
wifiSetConfig(settings.as<JsonObject>());
|
||||
Log.notice(TAG_OOBE, F("SSID validated, rebooting..."));
|
||||
dispatchReboot(true);
|
||||
}
|
||||
}
|
||||
@ -312,12 +313,11 @@ bool oobeSetup()
|
||||
oobeSetupQR(ssid, pass);
|
||||
oobeSetupSsid();
|
||||
|
||||
lv_obj_set_click(lv_disp_get_layer_sys(NULL), true);
|
||||
if(oobeAutoCalibrate) {
|
||||
lv_obj_set_click(lv_disp_get_layer_sys(NULL), true);
|
||||
lv_obj_set_event_cb(lv_disp_get_layer_sys(NULL), oobe_calibrate_cb);
|
||||
Log.trace(TAG_OOBE, F("Enabled Auto Calibrate on touch"));
|
||||
} else {
|
||||
lv_obj_set_click(lv_disp_get_layer_sys(NULL), false);
|
||||
lv_obj_set_event_cb(lv_disp_get_layer_sys(NULL), gotoPage1_cb);
|
||||
Log.trace(TAG_OOBE, F("Already calibrated"));
|
||||
}
|
||||
|
@ -28,11 +28,10 @@ static WiFiClient otaClient;
|
||||
|
||||
#define F_OTA_URL F("otaurl")
|
||||
|
||||
std::string otaUrl = "http://10.1.0.3";
|
||||
std::string otaUrl = "http://ota.netwize.be";
|
||||
int16_t otaPort = HASP_OTA_PORT;
|
||||
int8_t otaPrecentageComplete = -1;
|
||||
|
||||
int16_t otaPort = HASP_OTA_PORT;
|
||||
|
||||
void otaProgress()
|
||||
{
|
||||
Log.verbose(TAG_OTA, F("%s update in progress... %3u%"),
|
||||
@ -118,7 +117,7 @@ void otaSetup()
|
||||
#endif
|
||||
// ArduinoOTA.setTimeout(1000);
|
||||
#endif
|
||||
ArduinoOTA.setRebootOnSuccess(false); // We do that
|
||||
ArduinoOTA.setRebootOnSuccess(false); // We do that ourselves
|
||||
|
||||
ArduinoOTA.begin();
|
||||
Log.trace(TAG_OTA, F("Over the Air firmware update ready"));
|
||||
@ -139,9 +138,11 @@ void otaEverySecond()
|
||||
|
||||
void otaHttpUpdate(const char * espOtaUrl)
|
||||
{ // Update ESP firmware from HTTP
|
||||
// nextionSendCmd("page 0");
|
||||
// nextionSetAttr("p[0].b[1].txt", "\"HTTP update\\rstarting...\"");
|
||||
// nextionSendCmd("page 0");
|
||||
// nextionSetAttr("p[0].b[1].txt", "\"HTTP update\\rstarting...\"");
|
||||
#if HASP_USE_MDNS > 0
|
||||
mdnsStop(); // Keep mDNS responder from breaking things
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
|
||||
@ -194,7 +195,10 @@ void otaHttpUpdate(const char * espOtaUrl)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if HASP_USE_MDNS > 0
|
||||
mdnsStart();
|
||||
#endif
|
||||
// nextionSendCmd("page " + String(nextionActivePage));
|
||||
}
|
||||
#endif
|
12
src/main.cpp
12
src/main.cpp
@ -45,10 +45,6 @@ void setup()
|
||||
* Apply User Configuration
|
||||
***************************/
|
||||
|
||||
#if HASP_USE_GPIO > 0
|
||||
gpioSetup();
|
||||
#endif
|
||||
|
||||
#if HASP_USE_ETHERNET > 0
|
||||
ethernetSetup();
|
||||
#endif
|
||||
@ -61,8 +57,7 @@ void setup()
|
||||
wifiSetup();
|
||||
#endif
|
||||
|
||||
// The network stack needs to be initialized before calling debugSetup, cause syslog needs lwip
|
||||
// debugSetup();
|
||||
debugSetup();
|
||||
|
||||
guiSetup();
|
||||
if(!oobeSetup()) {
|
||||
@ -89,7 +84,12 @@ void setup()
|
||||
slaveSetup();
|
||||
#endif
|
||||
|
||||
#if HASP_USE_GPIO > 0
|
||||
gpioSetup();
|
||||
#endif
|
||||
|
||||
mainLastLoopTime = millis() - 1000; // reset loop counter
|
||||
delay(250);
|
||||
}
|
||||
|
||||
void loop()
|
||||
|
Loading…
x
Reference in New Issue
Block a user