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