Code cleanup

This commit is contained in:
fvanroie 2020-11-22 16:59:35 +01:00
parent aa649e7c68
commit 8e150fca3a
23 changed files with 146 additions and 130 deletions

View File

@ -458,13 +458,6 @@ typedef void* lv_font_user_data_t;
#endif /*LV_SPRINTF_CUSTOM*/
//*********************** 7.0 BETA defines, Remove when final version is ready !!
#define LV_USE_TA 1 // TEMPORARY FIX for 7.0 beta
#define LV_USE_DDLIST 1 // TEMPORARY FIX for 7.0 beta
# define LV_DSLIST_DEF_ANIM_TIME 200
#define LV_USE_BTNM 1 // TEMPORARY FIX for 7.0 beta
/*===================
* LV_OBJ SETTINGS
*==================*/

View File

@ -49,6 +49,8 @@ enum hasp_event_t { // even = released, odd = pressed
*/
void haspSetup();
void haspLoop(void);
void haspReconnect(void);
void haspDisconnect(void);
lv_obj_t * get_page_obj(uint8_t pageid);
bool get_page_id(lv_obj_t * obj, uint8_t * pageid);
@ -63,10 +65,8 @@ void haspBackground(uint16_t pageid, uint16_t imageid);
void hasp_set_group_objects(uint8_t groupid, uint8_t eventid, lv_obj_t * src_obj);
void haspNewObject(const JsonObject & config, uint8_t & saved_page_id);
// void haspNewObject(const JsonObject & config, uint8_t & saved_page_id);
void haspReconnect(void);
void haspDisconnect(void);
void haspWakeUp(void);
void haspProgressVal(uint8_t val);

View File

@ -370,11 +370,11 @@ void configSetup()
}
//#if HASP_USE_SPIFFS > 0
Log.notice(TAG_DEBG, F("Loading debug settings"));
Log.trace(TAG_DEBG, F("Loading debug settings"));
debugSetConfig(settings[F("debug")]);
Log.notice(TAG_GPIO, F("Loading GUI settings"));
Log.trace(TAG_GPIO, F("Loading GUI settings"));
guiSetConfig(settings[F("gui")]);
Log.notice(TAG_HASP, F("Loading HASP settings"));
Log.trace(TAG_HASP, F("Loading HASP settings"));
haspSetConfig(settings[F("hasp")]);
// otaGetConfig(settings[F("ota")]);
@ -458,7 +458,7 @@ void configOutput(const JsonObject & settings, uint8_t tag)
Log.verbose(tag, output.c_str());
}
bool configClear()
bool configClearEeprom()
{
#if defined(STM32F4xx)
Log.notice(TAG_CONF, F("Clearing EEPROM"));

View File

@ -7,6 +7,27 @@
#include "ArduinoJson.h"
#include "hasp_debug.h" // for TAG_CONF
/* ===== Default Event Processors ===== */
void configSetup(void);
void configLoop(void);
void configEverySecond(void);
void configStart(void);
void configStop(void);
/* ===== Special Event Processors ===== */
void configWriteConfig(void);
void configOutput(const JsonObject & settings, uint8_t tag = TAG_CONF);
bool configClearEeprom(void);
/* ===== Getter and Setter Functions ===== */
bool configSet(int8_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name);
bool configSet(uint8_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name);
bool configSet(uint16_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name);
/* ===== Read/Write Configuration ===== */
void configSetConfig(JsonObject & settings);
void configGetConfig(JsonDocument & settings);
/* json keys used in the configfile */
const char F_CONFIG_STARTPAGE[] PROGMEM = "startpage";
const char F_CONFIG_STARTDIM[] PROGMEM = "startdim";
@ -37,17 +58,4 @@ const char F_GPIO_CONFIG[] PROGMEM = "config";
const char HASP_CONFIG_FILE[] PROGMEM = "/config.json";
void configSetup();
void configStop(void);
void configSetConfig(JsonObject & settings);
void configGetConfig(JsonDocument & settings);
void configWriteConfig();
void configOutput(const JsonObject & settings, uint8_t tag = TAG_CONF);
bool configSet(int8_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name);
bool configSet(uint8_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name);
bool configSet(uint16_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name);
bool configClear();
#endif

View File

@ -109,7 +109,7 @@ unsigned long debugLastMillis = 0;
uint16_t debugTelePeriod = 300;
// Send the HASP header and version to the output device specified
void debugHaspHeader(Print * output)
void debugPrintHaspHeader(Print * output)
{
if(debugAnsiCodes) output->println(TERM_COLOR_YELLOW);
output->print(F(""
@ -559,19 +559,19 @@ void debugPrintPrefix(uint8_t tag, int level, Print * _logOutput)
debugSendAnsiCode(F(TERM_CLEAR_LINE), _logOutput);
debugPrintTimestamp(level, _logOutput);
debugPrintHaspMemory(level, _logOutput);
#if LV_MEM_CUSTOM == 0
debugPrintLvglMemory(level, _logOutput);
#endif
switch(tag) {
case TAG_MQTT_PUB:
debugSendAnsiCode(F(TERM_COLOR_GREEN), _logOutput);
break;
case TAG_MQTT_RCV:
debugSendAnsiCode(F(TERM_COLOR_ORANGE), _logOutput);
break;
default:
debugPrintPriority(level, _logOutput);
if(tag == TAG_MQTT_PUB && level == LOG_LEVEL_NOTICE) {
debugSendAnsiCode(F(TERM_COLOR_GREEN), _logOutput);
} else if(tag == TAG_MQTT_RCV && level == LOG_LEVEL_NOTICE) {
debugSendAnsiCode(F(TERM_COLOR_ORANGE), _logOutput);
} else {
debugPrintPriority(level, _logOutput);
}
_logOutput->print(F(" "));
debugPrintTag(tag, _logOutput);
_logOutput->print(F(": "));
@ -627,7 +627,7 @@ void debugPreSetup(JsonObject settings)
// Print Header
Serial.println();
debugHaspHeader(&Serial);
debugPrintHaspHeader(&Serial);
// Serial.println(debugHaspHeader());
// Serial.println();
Serial.flush();
@ -637,15 +637,18 @@ void debugPreSetup(JsonObject settings)
}
#if LV_USE_LOG != 0
static uint32_t lastDbgLine;
static uint16_t lastDbgFree;
void debugLvgl(lv_log_level_t level, const char * file, uint32_t line, const char * funcname, const char * descr)
void debugLvglLogEvent(lv_log_level_t level, const char * file, uint32_t line, const char * funcname,
const char * descr)
{
/* used for duplicate detection */
static uint32_t lastDbgLine;
static uint16_t lastDbgFreeMem;
lv_mem_monitor_t mem_mon;
lv_mem_monitor(&mem_mon);
/* Reduce the number of reepeated debug message */
if(line != lastDbgLine || mem_mon.free_biggest_size != lastDbgFree) {
if(line != lastDbgLine || mem_mon.free_biggest_size != lastDbgFreeMem) {
switch(level) {
case LV_LOG_LEVEL_TRACE:
Log.verbose(TAG_LVGL, descr);
@ -659,8 +662,8 @@ void debugLvgl(lv_log_level_t level, const char * file, uint32_t line, const cha
default:
Log.notice(TAG_LVGL, descr);
}
lastDbgLine = line;
lastDbgFree = mem_mon.free_biggest_size;
lastDbgLine = line;
lastDbgFreeMem = mem_mon.free_biggest_size;
}
}
#endif

View File

@ -7,8 +7,7 @@
#include "ArduinoJson.h"
#include "lvgl.h"
void debugHaspHeader(Print * output);
/* ===== Default Event Processors ===== */
void debugPreSetup(JsonObject settings);
void debugSetup();
void debugLoop(void);
@ -16,21 +15,20 @@ void debugEverySecond(void);
void debugStart(void);
void debugStop(void);
/* ===== Special Event Processors ===== */
void debugLvglLogEvent(lv_log_level_t level, const char * file, uint32_t line, const char * funcname, const char * descr);
void debugPrintHaspHeader(Print * output);
void debugStartSyslog(void);
void debugStopSyslog(void);
// void syslogSend(uint8_t log, const char * debugText);
void serialPrintln(String & debugText, uint8_t level);
void serialPrintln(const char * debugText, uint8_t level);
void syslogSend(uint8_t log, const char * debugText);
/* ===== Read/Write Configuration ===== */
bool debugGetConfig(const JsonObject & settings);
bool debugSetConfig(const JsonObject & settings);
// void debugPrintPrefix(int level, Print * _logOutput);
// void debugPrintSuffix(int level, Print * _logOutput);
// void debugSendOuput(const char * buffer);
void debugLvgl(lv_log_level_t level, const char * file, uint32_t line, const char * funcname, const char * descr);
enum {
TAG_MAIN = 0,

View File

@ -8,31 +8,31 @@
#define LOG_CMND_CTR "CMND: "
bool is_true(const char * s);
/* ===== Default Event Processors ===== */
void dispatchSetup(void);
void dispatchLoop(void);
void dispatchEverySecond(void);
void dispatchStart(void);
void dispatchStop(void);
// void dispatchCommand(const char * topic, const char * payload); // intenal
/* ===== Special Event Processors ===== */
void dispatchConfig(const char * topic, const char * payload);
void dispatchTopicPayload(const char * topic, const char * payload);
void dispatchTextLine(const char * cmnd);
// void dispatchParseJson(char * strPayload);
// void dispatchParseJsonl(char * strPayload);
void dispatchParseJsonl(Stream & stream);
void dispatchClearPage(const char * page);
void dispatchPage(const char * page);
void dispatchPageNext();
void dispatchPagePrev();
void dispatchClearPage(const char * page);
void dispatchDim(const char * level);
void dispatchBacklight(const char * payload);
void dispatchWebUpdate(const char * espOtaUrl);
void dispatch_output_idle_state(const char * state);
void dispatchReboot(bool saveConfig);
void dispatch_output_idle_state(const char * state);
void dispatch_output_statusupdate(void);
void dispatch_button(uint8_t id, const char * event);
@ -41,9 +41,15 @@ void dispatch_send_object_event(uint8_t pageid, uint8_t objid, uint8_t eventid);
void dispatch_send_group_event(uint8_t groupid, uint8_t eventid, bool update_hasp);
bool dispatch_get_event_state(uint8_t eventid);
bool is_true(const char * s);
void IRAM_ATTR dispatch_send_obj_attribute_str(uint8_t pageid, uint8_t btnid, const char * attribute,
const char * data);
/* ===== Getter and Setter Functions ===== */
/* ===== Read/Write Configuration ===== */
/* ===== Structs and Constants ===== */
struct haspCommand_t
{
void (*func)(const char *);

View File

@ -95,9 +95,13 @@ void filesystemList()
#endif
}
bool filesystemSetup()
bool filesystemSetup(void)
{
// no SPIFFS settings, as settings depend on SPIFFS
// no Logging, because it depends on the configuration file
// Logging is defered until debugging has started
// FS success or failure is printed at that time !
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
#if defined(ARDUINO_ARCH_ESP8266)
@ -105,10 +109,10 @@ bool filesystemSetup()
#else
if(!HASP_FS.begin(true)) {
#endif
Log.error(TAG_FILE, F("SPI flash init failed. Unable to mount FS."));
// Log.error(TAG_FILE, F("SPI flash init failed. Unable to mount FS."));
return false;
} else {
Log.trace(TAG_FILE, F("SPI Flash FS mounted"));
// Log.trace(TAG_FILE, F("SPI Flash FS mounted"));
return true;
}
#endif

View File

@ -21,7 +21,7 @@ static AceButton * button[HASP_NUM_INPUTS];
// An array of button pins, led pins, and the led states. Cannot be const
// because ledState is mutable.
hasp_gpio_config_t gpioConfig[HASP_NUM_GPIO_CONFIG] = {
{2, 8, INPUT, LOW}, {3, 9, OUTPUT, LOW}, {4, 10, INPUT, HIGH}, {5, 11, OUTPUT, LOW}, {6, 12, INPUT, LOW},
// {2, 8, INPUT, LOW}, {3, 9, OUTPUT, LOW}, {4, 10, INPUT, HIGH}, {5, 11, OUTPUT, LOW}, {6, 12, INPUT, LOW},
};
#if defined(ARDUINO_ARCH_ESP32)

View File

@ -15,7 +15,7 @@
#include "tft_espi_drv.h"
#endif
// Touch Driver
// Select Touch Driver
//#include "indev/XPT2046_alt_drv.h"
#include "indev/XPT2046.h"
@ -69,13 +69,14 @@ static uint16_t guiSleepTime2 = 120; // 1 second resolution
static uint8_t guiSleeping = HASP_SLEEP_OFF;
static uint8_t guiTickPeriod = 20;
static uint8_t guiRotation = TFT_ROTATION;
#if ESP32 > 0 || ESP8266 > 0
// static TFT_eSPI tft; // = TFT_eSPI(); /* TFT instance */
static uint16_t calData[5] = {0, 65535, 0, 65535, 0};
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
static Ticker tick; /* timer for interrupt handler */
#else
static Ticker tick(lv_tick_handler, LVGL_TICK_PERIOD); // guiTickPeriod);
#endif
// static TFT_eSPI tft; // = TFT_eSPI(); /* TFT instance */
static uint16_t calData[5] = {0, 65535, 0, 65535, 0};
bool guiCheckSleep()
{
@ -136,7 +137,6 @@ static void IRAM_ATTR my_flush_cb(lv_disp_drv_t * disp, const lv_area_t * area,
/* Interrupt driven periodic handler */
static void ICACHE_RAM_ATTR lv_tick_handler(void)
{
// Serial.print(".");
lv_tick_inc(LVGL_TICK_PERIOD);
}
@ -562,7 +562,7 @@ void guiSetup()
#if LV_USE_LOG != 0
Log.notice(TAG_LVGL, F("Registering lvgl logging handler"));
lv_log_register_print_cb(debugLvgl); /* register print function for debugging */
lv_log_register_print_cb(debugLvglLogEvent); /* register print function for debugging */
#endif
/* Initialize the display driver */
@ -639,19 +639,23 @@ void guiSetup()
void IRAM_ATTR guiLoop()
{
lv_task_handler(); // process animations
#if defined(STM32F4xx)
tick.update();
#endif
lv_task_handler();
guiCheckSleep();
#if TOUCH_DRIVER == 1
touch.loop();
#endif
}
void guiEverySecond(void)
{
// check if we went to sleep, wake up is handled in the event handlers
guiCheckSleep();
}
void guiStart()
{
/*Initialize the graphics library's tick*/

View File

@ -4,41 +4,33 @@
#ifndef HASP_GUI_H
#define HASP_GUI_H
//#include "TFT_eSPI.h"
#include "ArduinoJson.h"
#include "lvgl.h"
#define HASP_SLEEP_OFF 0
#define HASP_SLEEP_SHORT 1
#define HASP_SLEEP_LONG 2
// #if defined(ARDUINO_ARCH_ESP8266)
// #include <ESP8266WebServer.h>
// void guiTakeScreenshot(ESP8266WebServer & client);
// #endif
// #if defined(ARDUINO_ARCH_ESP32)
// #include <WebServer.h>
// void guiTakeScreenshot(WebServer & client);
// #endif // ESP32
void guiTakeScreenshot();
/* ===== Default Event Processors ===== */
void guiSetup();
void guiStart(void);
void guiLoop(void);
void guiEverySecond(void);
void guiStart(void);
void guiStop(void);
/* ===== Special Event Processors ===== */
void guiCalibrate();
void guiTakeScreenshot(const char * pFileName);
void guiTakeScreenshot(const char * pFileName); // to file
void guiTakeScreenshot(); // webclient
/* ===== Getter and Setter Functions ===== */
void guiSetDim(int8_t level);
int8_t guiGetDim(void);
void guiSetBacklight(bool lighton);
bool guiGetBacklight();
bool guiCheckSleep();
/* ===== Read/Write Configuration ===== */
bool guiGetConfig(const JsonObject & settings);
bool guiSetConfig(const JsonObject & settings);

View File

@ -88,7 +88,7 @@ String esp32ResetReason(uint8_t cpuid)
}
#endif
void halRestart(void)
void halRestartMcu(void)
{
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
ESP.restart();

View File

@ -6,7 +6,7 @@
#include <Arduino.h>
void halRestart(void);
void halRestartMcu(void);
uint8_t halGetHeapFragmentation(void);
String halGetResetInfo(void);
size_t halGetMaxFreeBlock(void);

View File

@ -130,7 +130,7 @@ bool httpIsAuthenticated(const __FlashStringHelper * fstr_page)
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
Log.notice(TAG_HTTP, F("Sending %S page to client connected from: %s"), fstr_page,
webServer.client().remoteIP().toString().c_str());
webServer.client().remoteIP().toString().c_str());
#else
// Log.trace(TAG_HTTP,F("Sending %s page to client connected from: %s"), page,
// String(webServer.client().remoteIP()).c_str());
@ -1642,7 +1642,7 @@ void httpHandleResetConfig()
httpMessage += F("</h1><hr>");
if(resetConfirmed) { // User has confirmed, so reset everything
bool formatted = configClear();
bool formatted = configClearEeprom();
if(formatted) {
httpMessage += F("<b>Resetting all saved settings and restarting device</b>");
} else {
@ -1677,7 +1677,7 @@ void httpHandleResetConfig()
}
}
void webStart()
void httpStart()
{
webServer.begin();
webServerStarted = true;
@ -1688,7 +1688,7 @@ void webStart()
Log.trace(TAG_HTTP, F("Server started @ http://%d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
#else
Log.trace(TAG_HTTP, F("Server started @ http://%s"),
(WiFi.getMode() != WIFI_STA ? WiFi.softAPIP().toString().c_str() : WiFi.localIP().toString().c_str()));
(WiFi.getMode() != WIFI_STA ? WiFi.softAPIP().toString().c_str() : WiFi.localIP().toString().c_str()));
#endif
#else
IPAddress ip;
@ -1701,7 +1701,7 @@ void webStart()
#endif
}
void webStop()
void httpStop()
{
webServer.stop();
webServerStarted = false;
@ -1817,7 +1817,7 @@ void httpSetup()
webServer.collectHeaders(headerkeys, headerkeyssize);
Log.trace(TAG_HTTP, F("Setup Complete"));
webStart();
// webStart(); Wait for network connection
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@ -1826,13 +1826,13 @@ void httpReconnect()
if(!httpEnable) return;
if(webServerStarted) {
webStop();
httpStop();
} else
#if HASP_USE_WIFI > 0 && !defined(STM32F4xx)
if(WiFi.status() == WL_CONNECTED || WiFi.getMode() != WIFI_STA)
#endif
{
webStart();
httpStart();
}
}
@ -1845,7 +1845,7 @@ void httpLoop()
////////////////////////////////////////////////////////////////////////////////////////////////////
void httpEvery5Seconds()
{
if(httpEnable && !webServerStarted) httpReconnect();
// if(httpEnable && !webServerStarted) httpReconnect();
}
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -10,9 +10,11 @@
void httpSetup();
void httpLoop(void);
void httpEvery5Seconds(void);
void httpReconnect(void);
// void httpReconnect(void);
void httpStart(void);
void httpStop(void);
size_t httpClientWrite(const uint8_t *buf, size_t size); // Screenshot Write Data
size_t httpClientWrite(const uint8_t * buf, size_t size); // Screenshot Write Data
bool httpGetConfig(const JsonObject & settings);
bool httpSetConfig(const JsonObject & settings);

View File

@ -6,11 +6,13 @@
#include "ArduinoJson.h"
/* ===== Default Event Processors ===== */
void mdnsSetup();
void mdnsLoop(void);
void mdnsStart(void);
void mdnsStop(void);
/* ===== Read/Write Configuration ===== */
bool mdnsGetConfig(const JsonObject & settings);
bool mdnsSetConfig(const JsonObject & settings);

View File

@ -323,7 +323,7 @@ void mqttSubscribeTo(const char * format, const char * data)
}
}
void mqttReconnect()
void mqttStart()
{
char buffer[128];
char mqttClientId[64];
@ -342,7 +342,7 @@ void mqttReconnect()
// Attempt to connect and set LWT and Clean Session
snprintf_P(buffer, sizeof(buffer), PSTR("%sstatus"), mqttNodeTopic);
if(!mqttClient.connect(mqttClientId, mqttUser, mqttPassword, buffer, 0, false, "OFF", true)) {
if(!mqttClient.connect(mqttClientId, mqttUser, mqttPassword, buffer, 0, false, "OFF", true)) { // Literal String
// Retry until we give up and restart after connectTimeout seconds
mqttReconnectCount++;
@ -398,12 +398,10 @@ void mqttReconnect()
mqttCommandTopic = prefix + F("/page");
mqttGroupCommandTopic = "hasp/" + mqttGroupName + "/page";
mqttSensorTopic = prefix + F("/sensor");
mqttLightCommandTopic = prefix + F("/light/switch");
mqttLightStateTopic = prefix + F("/light/state");
mqttLightBrightCommandTopic = prefix + F("/brightness/set");
mqttLightBrightStateTopic = prefix + F("/brightness/state");
mqttMotionStateTopic = prefix + F("/motion/state");
*/
// Set keepAlive, cleanSession, timeout
@ -469,7 +467,7 @@ void mqttLoop()
void mqttEvery5Seconds(bool networkIsConnected)
{
if(mqttEnabled && networkIsConnected && !mqttClient.connected()) mqttReconnect();
if(mqttEnabled && networkIsConnected && !mqttClient.connected()) mqttStart();
}
String mqttGetNodename()

View File

@ -9,8 +9,8 @@
void mqttSetup();
void mqttLoop();
void mqttEvery5Seconds(bool wifiIsConnected);
void mqttStart();
void mqttStop();
void mqttReconnect();
void IRAM_ATTR mqtt_send_state(const __FlashStringHelper * subtopic, const char * payload);
void mqtt_send_input(uint8_t id, const char * payload);

View File

@ -32,13 +32,13 @@ std::string otaUrl = "http://ota.netwize.be";
int16_t otaPort = HASP_OTA_PORT;
int8_t otaPrecentageComplete = -1;
void otaProgress()
static inline void otaProgress(void)
{
Log.verbose(TAG_OTA, F("%s update in progress... %3u%"),
(ArduinoOTA.getCommand() == U_FLASH ? PSTR("Firmware") : PSTR("Filesystem")), otaPrecentageComplete);
}
void otaSetup()
void otaSetup(void)
{
if(strlen(otaUrl.c_str())) {
Log.trace(TAG_OTA, otaUrl.c_str());
@ -126,12 +126,12 @@ void otaSetup()
}
}
void otaLoop()
void otaLoop(void)
{
ArduinoOTA.handle();
}
void otaEverySecond()
void otaEverySecond(void)
{
if(otaPrecentageComplete >= 0) otaProgress();
}

View File

@ -8,9 +8,12 @@
#include "ArduinoJson.h"
void otaSetup();
/* ===== Default Event Processors ===== */
void otaSetup(void);
void otaLoop(void);
void otaEverySecond(void);
/* ===== Special Event Processors ===== */
void otaHttpUpdate(const char * espOtaUrl);
#endif

View File

@ -60,7 +60,7 @@ void telnetClientDisconnect()
void telnetClientLogon()
{
telnetClient.println();
debugHaspHeader(&telnetClient);
debugPrintHaspHeader(&telnetClient);
// telnetClient.println(debugHaspHeader().c_str()); // Send version header
telnetLoginState = TELNET_AUTHENTICATED; // User and Pass are correct
telnetLoginAttempt = 0; // Reset attempt counter

View File

@ -66,11 +66,11 @@ static void wifiConnected(IPAddress ipaddress)
Log.verbose(TAG_WIFI, F("Connected = %s"), WiFi.status() == WL_CONNECTED ? PSTR("yes") : PSTR("no"));
haspProgressVal(255);
debugStartSyslog();
// mqttReconnect();
// httpReconnect();
mdnsStart();
haspReconnect();
debugStartSyslog();
//mqttStart();
httpStart();
mdnsStart();
}
static void wifiDisconnected(const char * ssid, uint8_t reason)
@ -81,6 +81,8 @@ static void wifiDisconnected(const char * ssid, uint8_t reason)
haspProgressMsg(F("Wifi Disconnected"));
debugStopSyslog();
mqttStop();
httpStop();
mdnsStop();
if(wifiReconnectCounter > 33) {
@ -356,7 +358,7 @@ bool wifiShowAP(char * ssid, char * pass)
return true;
}
void wifiReconnect()
static void wifiReconnect(void)
{
WiFi.disconnect(true);
#if defined(ARDUINO_ARCH_ESP8266)

View File

@ -26,9 +26,9 @@ void setup()
eepromSetup(); // Don't start at boot, only at write
#endif
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
filesystemSetup();
#endif
// #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
// filesystemSetup(); // Done in configSetup()
// #endif
#if HASP_USE_SDCARD > 0
sdcardSetup();
@ -154,13 +154,14 @@ void loop()
/* Timer Loop */
if(millis() - mainLastLoopTime >= 1000) {
/* Run Every Second */
/* Runs Every Second */
#if HASP_USE_OTA > 0
otaEverySecond();
otaEverySecond(); // progressbar
#endif
debugEverySecond();
guiEverySecond(); // sleep timer
debugEverySecond(); // statusupdate
/* Run Every 5 Seconds */
/* Runs Every 5 Seconds */
if(mainLoopCounter == 0 || mainLoopCounter == 5) {
#if HASP_USE_WIFI > 0
isConnected = wifiEvery5Seconds();
@ -171,11 +172,11 @@ void loop()
#endif
#if HASP_USE_HTTP > 0
httpEvery5Seconds();
// httpEvery5Seconds();
#endif
#if HASP_USE_MQTT > 0
mqttEvery5Seconds(isConnected);
mqttEvery5Seconds(isConnected);
#endif
}
@ -188,5 +189,5 @@ void loop()
mainLastLoopTime += 1000;
}
delay(2);
delay(3);
}