mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-09-11 17:14:27 +00:00
Split Diagnostic.h & ESPEasyWiFiEvent.h into .h/.cpp
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#include "NewPingESP8266.h"
|
||||
//#include "ESPEasy-Globals.h"
|
||||
// ---------------------------------------------------------------------------
|
||||
// NewPingESP8266 constructor
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
+4
-1
@@ -188,11 +188,14 @@ platform = espressif32@1.8.0
|
||||
[core_esp32_1_9_0]
|
||||
platform = espressif32@1.9.0
|
||||
|
||||
[core_esp32_1_10_0]
|
||||
platform = espressif32@1.10.0
|
||||
|
||||
[core_esp32_stage]
|
||||
platform = https://github.com/platformio/platform-espressif32.git#feature/stage
|
||||
|
||||
[core_esp32]
|
||||
platform = ${core_esp32_1_9_0.platform}
|
||||
platform = ${core_esp32_1_10_0.platform}
|
||||
build_unflags = -Wall
|
||||
build_flags = -D BUILD_GIT='"${sysenv.TRAVIS_TAG}"'
|
||||
-DCONFIG_FREERTOS_ASSERT_DISABLE
|
||||
|
||||
+80
-19
@@ -1,31 +1,92 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
/*#include "ESPEasy-Globals.h"
|
||||
#include "ESPEasy-Globals.h"
|
||||
|
||||
NotificationStruct Notification[NPLUGIN_MAX];
|
||||
|
||||
#if defined(ESP32)
|
||||
int8_t ledChannelPin[16];
|
||||
#endif
|
||||
|
||||
|
||||
#include "src/DataStructs/ControllerSettingsStruct.h"
|
||||
#include "src/DataStructs/DeviceModel.h"
|
||||
|
||||
#include "src/DataStructs/ESPEasy_EventStruct.h"
|
||||
#include "src/DataStructs/FactoryDefaultPref.h"
|
||||
#include "src/DataStructs/NodeStruct.h"
|
||||
#include "src/DataStructs/NotificationSettingsStruct.h"
|
||||
#include "src/DataStructs/NotificationStruct.h"
|
||||
#include "src/DataStructs/PortStatusStruct.h"
|
||||
#include "src/DataStructs/ProtocolStruct.h"
|
||||
#include "src/DataStructs/SettingsStruct.h"
|
||||
#include "src/DataStructs/SettingsType.h"
|
||||
#include "src/DataStructs/SystemTimerStruct.h"
|
||||
#include "src/DataStructs/TimingStats.h"
|
||||
I2Cdev i2cdev;
|
||||
|
||||
|
||||
|
||||
|
||||
SettingsStruct Settings;
|
||||
//NotificationStruct Notification[NPLUGIN_MAX];
|
||||
// Setup DNS, only used if the ESP has no valid WiFi config
|
||||
const byte DNS_PORT = 53;
|
||||
IPAddress apIP(DEFAULT_AP_IP);
|
||||
DNSServer dnsServer;
|
||||
bool dnsServerActive = false;
|
||||
|
||||
*/
|
||||
//NTP status
|
||||
bool statusNTPInitialized = false;
|
||||
|
||||
unsigned long connectionFailures(0);
|
||||
// udp protocol stuff (syslog, global sync, node info list, ntp time)
|
||||
WiFiUDP portUDP;
|
||||
|
||||
float customFloatVar[CUSTOM_VARS_MAX];
|
||||
|
||||
float UserVar[VARS_PER_TASK * TASKS_MAX];
|
||||
|
||||
|
||||
|
||||
int deviceCount = -1;
|
||||
int protocolCount = -1;
|
||||
int notificationCount = -1;
|
||||
|
||||
boolean printToWeb = false;
|
||||
String printWebString;
|
||||
boolean printToWebJSON = false;
|
||||
|
||||
rulesTimerStatus RulesTimer[RULES_TIMER_MAX];
|
||||
|
||||
msecTimerHandlerStruct msecTimerHandler;
|
||||
|
||||
unsigned long timer_gratuitous_arp_interval = 5000;
|
||||
unsigned long timermqtt_interval = 250;
|
||||
unsigned long lastSend = 0;
|
||||
unsigned long lastWeb = 0;
|
||||
byte cmd_within_mainloop = 0;
|
||||
unsigned long wdcounter = 0;
|
||||
unsigned long timerAPoff = 0; // Timer to check whether the AP mode should be disabled (0 = disabled)
|
||||
unsigned long timerAPstart = 0; // Timer to start AP mode, started when no valid network is detected.
|
||||
unsigned long timerAwakeFromDeepSleep = 0;
|
||||
unsigned long last_system_event_run = 0;
|
||||
|
||||
#if FEATURE_ADC_VCC
|
||||
float vcc = -1.0;
|
||||
#endif
|
||||
|
||||
boolean WebLoggedIn = false;
|
||||
int WebLoggedInTimer = 300;
|
||||
|
||||
|
||||
bool (*CPlugin_ptr[CPLUGIN_MAX])(byte, struct EventStruct*, String&);
|
||||
byte CPlugin_id[CPLUGIN_MAX];
|
||||
|
||||
boolean (*NPlugin_ptr[NPLUGIN_MAX])(byte, struct EventStruct*, String&);
|
||||
byte NPlugin_id[NPLUGIN_MAX];
|
||||
|
||||
String dummyString = ""; // FIXME @TD-er This may take a lot of memory over time, since long-lived Strings only tend to grow.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool webserverRunning(false);
|
||||
bool webserver_init(false);
|
||||
|
||||
|
||||
String eventBuffer;
|
||||
|
||||
|
||||
|
||||
|
||||
bool shouldReboot(false);
|
||||
bool firstLoop(true);
|
||||
|
||||
boolean activeRuleSets[RULESETS_MAX];
|
||||
|
||||
boolean UseRTOSMultitasking(false);
|
||||
|
||||
+51
-206
@@ -92,10 +92,6 @@
|
||||
|
||||
|
||||
|
||||
#define BOOT_CAUSE_MANUAL_REBOOT 0
|
||||
#define BOOT_CAUSE_COLD_BOOT 1
|
||||
#define BOOT_CAUSE_DEEP_SLEEP 2
|
||||
#define BOOT_CAUSE_EXT_WD 10
|
||||
|
||||
|
||||
#include <map>
|
||||
@@ -117,7 +113,7 @@
|
||||
#include "src/DataStructs/NotificationSettingsStruct.h"
|
||||
#include "src/DataStructs/NotificationStruct.h"
|
||||
|
||||
NotificationStruct Notification[NPLUGIN_MAX];
|
||||
extern NotificationStruct Notification[NPLUGIN_MAX];
|
||||
|
||||
|
||||
|
||||
@@ -126,17 +122,7 @@ NotificationStruct Notification[NPLUGIN_MAX];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern unsigned long connectionFailures;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "ESPEasy_Log.h"
|
||||
#include "WebStaticData.h"
|
||||
#include "ESPEasyTimeTypes.h"
|
||||
#include "StringProviderTypes.h"
|
||||
#include "ESPeasySerial.h"
|
||||
@@ -149,7 +135,7 @@ extern unsigned long connectionFailures;
|
||||
#define FS_NO_GLOBALS
|
||||
#if defined(ESP8266)
|
||||
#include "core_version.h"
|
||||
#define NODE_TYPE_ID NODE_TYPE_ID_ESP_EASYM_STD
|
||||
#define NODE_TYPE_ID NODE_TYPE_ID_ESP_EASYM_STD
|
||||
#define FILE_CONFIG "config.dat"
|
||||
#define FILE_SECURITY "security.dat"
|
||||
#define FILE_NOTIFICATION "notification.dat"
|
||||
@@ -165,12 +151,8 @@ extern unsigned long connectionFailures;
|
||||
#endif
|
||||
#include <ESP8266WiFi.h>
|
||||
//#include <ESP8266Ping.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
ESP8266WebServer WebServer(80);
|
||||
#include <DNSServer.h>
|
||||
#include <Servo.h>
|
||||
#include <ESP8266HTTPUpdateServer.h>
|
||||
ESP8266HTTPUpdateServer httpUpdater(true);
|
||||
#ifndef LWIP_OPEN_SRC
|
||||
#define LWIP_OPEN_SRC
|
||||
#endif
|
||||
@@ -202,11 +184,6 @@ extern unsigned long connectionFailures;
|
||||
#endif
|
||||
#define SMALLEST_OTA_IMAGE 276848 // smallest known 2-step OTA image
|
||||
#define MAX_SKETCH_SIZE 1044464
|
||||
#ifdef FEATURE_ARDUINO_OTA
|
||||
#include <ArduinoOTA.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
bool ArduinoOTAtriggered=false;
|
||||
#endif
|
||||
#define PIN_D_MAX 16
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
@@ -222,21 +199,14 @@ extern unsigned long connectionFailures;
|
||||
#define FILE_RULES "/rules1.txt"
|
||||
#include <WiFi.h>
|
||||
// #include "esp32_ping.h"
|
||||
#include <WebServer.h>
|
||||
#include "SPIFFS.h"
|
||||
#include <rom/rtc.h>
|
||||
#include "esp_wifi.h" // Needed to call ESP-IDF functions like esp_wifi_....
|
||||
WebServer WebServer(80);
|
||||
#ifdef FEATURE_MDNS
|
||||
#include <ESPmDNS.h>
|
||||
#endif
|
||||
#ifdef FEATURE_ARDUINO_OTA
|
||||
#include <ArduinoOTA.h>
|
||||
#include <ESPmDNS.h>
|
||||
bool ArduinoOTAtriggered=false;
|
||||
#endif
|
||||
#define PIN_D_MAX 39
|
||||
int8_t ledChannelPin[16];
|
||||
extern int8_t ledChannelPin[16];
|
||||
#endif
|
||||
|
||||
#include <WiFiUdp.h>
|
||||
@@ -250,55 +220,25 @@ extern unsigned long connectionFailures;
|
||||
using namespace fs;
|
||||
#endif
|
||||
#include <base64.h>
|
||||
#if FEATURE_ADC_VCC
|
||||
ADC_MODE(ADC_VCC);
|
||||
#endif
|
||||
|
||||
|
||||
I2Cdev i2cdev;
|
||||
extern I2Cdev i2cdev;
|
||||
|
||||
#ifdef USES_MQTT
|
||||
#include <PubSubClient.h>
|
||||
// MQTT client
|
||||
WiFiClient mqtt;
|
||||
PubSubClient MQTTclient(mqtt);
|
||||
bool MQTTclient_should_reconnect = true;
|
||||
bool MQTTclient_connected = false;
|
||||
int mqtt_reconnect_count = 0;
|
||||
#endif //USES_MQTT
|
||||
|
||||
#ifdef USES_P037
|
||||
// mqtt import status
|
||||
bool P037_MQTTImport_connected = false;
|
||||
#endif
|
||||
|
||||
#define ESPEASY_WIFI_DISCONNECTED 0
|
||||
#define ESPEASY_WIFI_CONNECTED 1
|
||||
#define ESPEASY_WIFI_GOT_IP 2
|
||||
#define ESPEASY_WIFI_SERVICES_INITIALIZED 4
|
||||
|
||||
#if defined(ESP32)
|
||||
void WiFiEvent(system_event_id_t event, system_event_info_t info);
|
||||
#else
|
||||
WiFiEventHandler stationConnectedHandler;
|
||||
WiFiEventHandler stationDisconnectedHandler;
|
||||
WiFiEventHandler stationGotIpHandler;
|
||||
WiFiEventHandler stationModeDHCPTimeoutHandler;
|
||||
WiFiEventHandler APModeStationConnectedHandler;
|
||||
WiFiEventHandler APModeStationDisconnectedHandler;
|
||||
#endif
|
||||
|
||||
// Setup DNS, only used if the ESP has no valid WiFi config
|
||||
const byte DNS_PORT = 53;
|
||||
IPAddress apIP(DEFAULT_AP_IP);
|
||||
DNSServer dnsServer;
|
||||
bool dnsServerActive = false;
|
||||
extern const byte DNS_PORT;
|
||||
extern IPAddress apIP;
|
||||
extern DNSServer dnsServer;
|
||||
extern bool dnsServerActive;
|
||||
|
||||
//NTP status
|
||||
bool statusNTPInitialized = false;
|
||||
extern bool statusNTPInitialized;
|
||||
|
||||
// udp protocol stuff (syslog, global sync, node info list, ntp time)
|
||||
WiFiUDP portUDP;
|
||||
extern WiFiUDP portUDP;
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
@@ -308,9 +248,10 @@ WiFiUDP portUDP;
|
||||
* let,1,10
|
||||
* if %v1%=10 do ...
|
||||
\*********************************************************************************************/
|
||||
float customFloatVar[CUSTOM_VARS_MAX];
|
||||
extern float customFloatVar[CUSTOM_VARS_MAX];
|
||||
|
||||
extern float UserVar[VARS_PER_TASK * TASKS_MAX];
|
||||
|
||||
float UserVar[VARS_PER_TASK * TASKS_MAX];
|
||||
|
||||
|
||||
|
||||
@@ -321,10 +262,6 @@ float UserVar[VARS_PER_TASK * TASKS_MAX];
|
||||
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Buffer for outputting logs via serial port.
|
||||
\*********************************************************************************************/
|
||||
std::deque<char> serialWriteBuffer;
|
||||
|
||||
|
||||
|
||||
@@ -351,13 +288,13 @@ struct pinStatesStruct
|
||||
*/
|
||||
|
||||
|
||||
int deviceCount = -1;
|
||||
int protocolCount = -1;
|
||||
int notificationCount = -1;
|
||||
extern int deviceCount;
|
||||
extern int protocolCount;
|
||||
extern int notificationCount;
|
||||
|
||||
boolean printToWeb = false;
|
||||
String printWebString = "";
|
||||
boolean printToWebJSON = false;
|
||||
extern boolean printToWeb;
|
||||
extern String printWebString;
|
||||
extern boolean printToWebJSON;
|
||||
|
||||
/********************************************************************************************\
|
||||
RTC_cache_struct
|
||||
@@ -385,36 +322,38 @@ struct rulesTimerStatus
|
||||
unsigned long timestamp;
|
||||
unsigned int interval; //interval in milliseconds
|
||||
boolean paused;
|
||||
} RulesTimer[RULES_TIMER_MAX];
|
||||
};
|
||||
|
||||
msecTimerHandlerStruct msecTimerHandler;
|
||||
extern rulesTimerStatus RulesTimer[RULES_TIMER_MAX];
|
||||
|
||||
unsigned long timer_gratuitous_arp_interval = 5000;
|
||||
unsigned long timermqtt_interval = 250;
|
||||
unsigned long lastSend = 0;
|
||||
unsigned long lastWeb = 0;
|
||||
byte cmd_within_mainloop = 0;
|
||||
unsigned long wdcounter = 0;
|
||||
unsigned long timerAPoff = 0; // Timer to check whether the AP mode should be disabled (0 = disabled)
|
||||
unsigned long timerAPstart = 0; // Timer to start AP mode, started when no valid network is detected.
|
||||
unsigned long timerAwakeFromDeepSleep = 0;
|
||||
unsigned long last_system_event_run = 0;
|
||||
extern msecTimerHandlerStruct msecTimerHandler;
|
||||
|
||||
extern unsigned long timer_gratuitous_arp_interval;
|
||||
extern unsigned long timermqtt_interval;
|
||||
extern unsigned long lastSend;
|
||||
extern unsigned long lastWeb;
|
||||
extern byte cmd_within_mainloop;
|
||||
extern unsigned long wdcounter;
|
||||
extern unsigned long timerAPoff; // Timer to check whether the AP mode should be disabled (0 = disabled)
|
||||
extern unsigned long timerAPstart; // Timer to start AP mode, started when no valid network is detected.
|
||||
extern unsigned long timerAwakeFromDeepSleep;
|
||||
extern unsigned long last_system_event_run;
|
||||
|
||||
#if FEATURE_ADC_VCC
|
||||
float vcc = -1.0;
|
||||
extern float vcc;
|
||||
#endif
|
||||
|
||||
boolean WebLoggedIn = false;
|
||||
int WebLoggedInTimer = 300;
|
||||
extern boolean WebLoggedIn;
|
||||
extern int WebLoggedInTimer;
|
||||
|
||||
|
||||
bool (*CPlugin_ptr[CPLUGIN_MAX])(byte, struct EventStruct*, String&);
|
||||
byte CPlugin_id[CPLUGIN_MAX];
|
||||
extern bool (*CPlugin_ptr[CPLUGIN_MAX])(byte, struct EventStruct*, String&);
|
||||
extern byte CPlugin_id[CPLUGIN_MAX];
|
||||
|
||||
boolean (*NPlugin_ptr[NPLUGIN_MAX])(byte, struct EventStruct*, String&);
|
||||
byte NPlugin_id[NPLUGIN_MAX];
|
||||
extern boolean (*NPlugin_ptr[NPLUGIN_MAX])(byte, struct EventStruct*, String&);
|
||||
extern byte NPlugin_id[NPLUGIN_MAX];
|
||||
|
||||
String dummyString = ""; // FIXME @TD-er This may take a lot of memory over time, since long-lived Strings only tend to grow.
|
||||
extern String dummyString; // FIXME @TD-er This may take a lot of memory over time, since long-lived Strings only tend to grow.
|
||||
|
||||
enum PluginPtrType {
|
||||
TaskPluginEnum,
|
||||
@@ -427,119 +366,25 @@ unsigned long createSystemEventMixedId(PluginPtrType ptr_type, byte Index, byte
|
||||
unsigned long createSystemEventMixedId(PluginPtrType ptr_type, uint16_t crc16);
|
||||
|
||||
|
||||
byte lastBootCause = BOOT_CAUSE_MANUAL_REBOOT;
|
||||
unsigned long lastMixedSchedulerId_beforereboot = 0;
|
||||
|
||||
#if defined(ESP32)
|
||||
enum WiFiDisconnectReason
|
||||
{
|
||||
WIFI_DISCONNECT_REASON_UNSPECIFIED = 1,
|
||||
WIFI_DISCONNECT_REASON_AUTH_EXPIRE = 2,
|
||||
WIFI_DISCONNECT_REASON_AUTH_LEAVE = 3,
|
||||
WIFI_DISCONNECT_REASON_ASSOC_EXPIRE = 4,
|
||||
WIFI_DISCONNECT_REASON_ASSOC_TOOMANY = 5,
|
||||
WIFI_DISCONNECT_REASON_NOT_AUTHED = 6,
|
||||
WIFI_DISCONNECT_REASON_NOT_ASSOCED = 7,
|
||||
WIFI_DISCONNECT_REASON_ASSOC_LEAVE = 8,
|
||||
WIFI_DISCONNECT_REASON_ASSOC_NOT_AUTHED = 9,
|
||||
WIFI_DISCONNECT_REASON_DISASSOC_PWRCAP_BAD = 10, /* 11h */
|
||||
WIFI_DISCONNECT_REASON_DISASSOC_SUPCHAN_BAD = 11, /* 11h */
|
||||
WIFI_DISCONNECT_REASON_IE_INVALID = 13, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_MIC_FAILURE = 14, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_GROUP_KEY_UPDATE_TIMEOUT = 16, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_IE_IN_4WAY_DIFFERS = 17, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_GROUP_CIPHER_INVALID = 18, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_PAIRWISE_CIPHER_INVALID = 19, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_AKMP_INVALID = 20, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_UNSUPP_RSN_IE_VERSION = 21, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_INVALID_RSN_IE_CAP = 22, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_802_1X_AUTH_FAILED = 23, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_CIPHER_SUITE_REJECTED = 24, /* 11i */
|
||||
|
||||
WIFI_DISCONNECT_REASON_BEACON_TIMEOUT = 200,
|
||||
WIFI_DISCONNECT_REASON_NO_AP_FOUND = 201,
|
||||
WIFI_DISCONNECT_REASON_AUTH_FAIL = 202,
|
||||
WIFI_DISCONNECT_REASON_ASSOC_FAIL = 203,
|
||||
WIFI_DISCONNECT_REASON_HANDSHAKE_TIMEOUT = 204
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
bool useStaticIP();
|
||||
|
||||
// WiFi related data
|
||||
boolean wifiSetup = false;
|
||||
boolean wifiSetupConnect = false;
|
||||
uint8_t lastBSSID[6] = {0};
|
||||
uint8_t wifiStatus = ESPEASY_WIFI_DISCONNECTED;
|
||||
unsigned long last_wifi_connect_attempt_moment = 0;
|
||||
unsigned int wifi_connect_attempt = 0;
|
||||
int wifi_reconnects = -1; // First connection attempt is not a reconnect.
|
||||
uint8_t lastWiFiSettings = 0;
|
||||
String last_ssid;
|
||||
bool bssid_changed = false;
|
||||
bool channel_changed = false;
|
||||
uint8_t last_channel = 0;
|
||||
WiFiDisconnectReason lastDisconnectReason = WIFI_DISCONNECT_REASON_UNSPECIFIED;
|
||||
unsigned long lastConnectMoment = 0;
|
||||
unsigned long lastDisconnectMoment = 0;
|
||||
unsigned long lastGetIPmoment = 0;
|
||||
unsigned long lastGetScanMoment = 0;
|
||||
unsigned long lastConnectedDuration = 0;
|
||||
bool intent_to_reboot = false;
|
||||
uint8_t lastMacConnectedAPmode[6] = {0};
|
||||
uint8_t lastMacDisconnectedAPmode[6] = {0};
|
||||
|
||||
//uint32_t scan_done_status = 0;
|
||||
uint8_t scan_done_number = 0;
|
||||
//uint8_t scan_done_scan_id = 0;
|
||||
|
||||
// Semaphore like booleans for processing data gathered from WiFi events.
|
||||
volatile bool processedConnect = true;
|
||||
volatile bool processedDisconnect = true;
|
||||
volatile bool processedGotIP = true;
|
||||
volatile bool processedDHCPTimeout = true;
|
||||
volatile bool processedConnectAPmode = true;
|
||||
volatile bool processedDisconnectAPmode = true;
|
||||
volatile bool processedScanDone = true;
|
||||
bool wifiConnectAttemptNeeded = true;
|
||||
bool wifiConnectInProgress = false;
|
||||
|
||||
bool webserverRunning = false;
|
||||
bool webserver_init = false;
|
||||
|
||||
unsigned long idle_msec_per_sec = 0;
|
||||
unsigned long elapsed10ps = 0;
|
||||
unsigned long elapsed10psU = 0;
|
||||
unsigned long elapsed50ps = 0;
|
||||
unsigned long loopCounter = 0;
|
||||
unsigned long loopCounterLast = 0;
|
||||
unsigned long loopCounterMax = 1;
|
||||
unsigned long lastLoopStart = 0;
|
||||
unsigned long shortestLoop = 10000000;
|
||||
unsigned long longestLoop = 0;
|
||||
unsigned long loopCounter_full = 1;
|
||||
float loop_usec_duration_total = 0.0;
|
||||
|
||||
|
||||
unsigned long dailyResetCounter = 0;
|
||||
volatile unsigned long sw_watchdog_callback_count = 0;
|
||||
|
||||
String eventBuffer = "";
|
||||
|
||||
uint32_t lowestRAM = 0;
|
||||
String lowestRAMfunction = "";
|
||||
uint32_t lowestFreeStack = 0;
|
||||
String lowestFreeStackfunction = "";
|
||||
extern bool webserverRunning;
|
||||
extern bool webserver_init;
|
||||
|
||||
|
||||
bool shouldReboot=false;
|
||||
bool firstLoop=true;
|
||||
extern String eventBuffer;
|
||||
|
||||
boolean activeRuleSets[RULESETS_MAX];
|
||||
|
||||
boolean UseRTOSMultitasking = false;
|
||||
extern bool shouldReboot;
|
||||
extern bool firstLoop;
|
||||
|
||||
extern boolean activeRuleSets[RULESETS_MAX];
|
||||
|
||||
extern boolean UseRTOSMultitasking;
|
||||
|
||||
|
||||
// void (*MainLoopCall_ptr)(void); //FIXME TD-er: No idea what this does.
|
||||
|
||||
|
||||
+21
-27
@@ -91,35 +91,46 @@
|
||||
#include "_CPlugin_Helper.h"
|
||||
#include "src/ControllerQueue/DelayQueueElements.h"
|
||||
|
||||
|
||||
#include "src/DataStructs/ControllerSettingsStruct.h"
|
||||
#include "src/DataStructs/DeviceModel.h"
|
||||
#include "src/DataStructs/ESPEasy_EventStruct.h"
|
||||
#include "src/DataStructs/PortStatusStruct.h"
|
||||
#include "src/DataStructs/ProtocolStruct.h"
|
||||
#include "src/DataStructs/RTCStruct.h"
|
||||
#include "src/DataStructs/SchedulerTimers.h"
|
||||
#include "src/DataStructs/SettingsType.h"
|
||||
#include "src/DataStructs/SystemTimerStruct.h"
|
||||
#include "src/DataStructs/TimingStats.h"
|
||||
|
||||
#include "src/Globals/Device.h"
|
||||
#include "src/Globals/ESPEasyWiFiEvent.h"
|
||||
#include "src/Globals/ExtraTaskSettings.h"
|
||||
#include "src/Globals/GlobalMapPortStatus.h"
|
||||
#include "src/Globals/MQTT.h"
|
||||
#include "src/Globals/Plugins.h"
|
||||
#include "src/Globals/RTC.h"
|
||||
#include "src/DataStructs/RTCStruct.h"
|
||||
#include "src/Globals/Device.h"
|
||||
#include "src/Globals/Settings.h"
|
||||
#include "src/Globals/SecuritySettings.h"
|
||||
#include "src/Globals/ExtraTaskSettings.h"
|
||||
#include "src/Globals/Services.h"
|
||||
#include "src/Globals/Settings.h"
|
||||
#include "src/Globals/Statistics.h"
|
||||
|
||||
#if FEATURE_ADC_VCC
|
||||
ADC_MODE(ADC_VCC);
|
||||
#endif
|
||||
|
||||
|
||||
// FIXME TD-er: This must be moves to src/Globals/Services
|
||||
// But right now, it seems hard to define WevServer in a .h/.cpp file
|
||||
// error: 'WebServer' does not name a type
|
||||
#ifdef ESP32
|
||||
#include <WiFi.h>
|
||||
#include <WebServer.h>
|
||||
WebServer WebServer(80);
|
||||
#endif
|
||||
|
||||
// Get functions to give access to global defined variables.
|
||||
// These are needed to get direct access to global defined variables, since they cannot be defined in .h files and included more than once.
|
||||
|
||||
|
||||
unsigned long& getConnectionFailures() { return connectionFailures; }
|
||||
|
||||
|
||||
|
||||
float& getUserVar(unsigned int varIndex) {return UserVar[varIndex]; }
|
||||
|
||||
|
||||
@@ -809,23 +820,6 @@ void runOncePerSecond()
|
||||
Wire.endTransmission();
|
||||
}
|
||||
|
||||
/*
|
||||
if (Settings.SerialLogLevel == LOG_LEVEL_DEBUG_DEV)
|
||||
{
|
||||
serialPrint(F("Plugin calls: 50 ps:"));
|
||||
serialPrint(elapsed50ps);
|
||||
serialPrint(F(" uS, 10 ps:"));
|
||||
serialPrint(elapsed10ps);
|
||||
serialPrint(F(" uS, 10 psU:"));
|
||||
serialPrint(elapsed10psU);
|
||||
serialPrint(F(" uS, 1 ps:"));
|
||||
serialPrint(elapsed);
|
||||
serialPrintln(F(" uS"));
|
||||
elapsed50ps=0;
|
||||
elapsed10ps=0;
|
||||
elapsed10psU=0;
|
||||
}
|
||||
*/
|
||||
checkResetFactoryPin();
|
||||
STOP_TIMER(PLUGIN_CALL_1PS);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
#include "ESPEasyWiFiEvent.h"
|
||||
#include "src/Globals/ESPEasyWiFiEvent.h"
|
||||
#include "ESPEasyTimeTypes.h"
|
||||
|
||||
#ifdef ESP32
|
||||
void WiFi_Access_Static_IP::set_use_static_ip(bool enabled) {
|
||||
_useStaticIp = enabled;
|
||||
}
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
void WiFi_Access_Static_IP::set_use_static_ip(bool enabled) {
|
||||
_useStaticIp = enabled;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void setUseStaticIP(bool enabled) {
|
||||
WiFi_Access_Static_IP tmp_wifi;
|
||||
|
||||
tmp_wifi.set_use_static_ip(enabled);
|
||||
}
|
||||
|
||||
void markGotIP() {
|
||||
lastGetIPmoment = millis();
|
||||
wifiStatus = ESPEASY_WIFI_GOT_IP;
|
||||
processedGotIP = false;
|
||||
}
|
||||
|
||||
// ********************************************************************************
|
||||
// Functions called on events.
|
||||
// Make sure not to call anything in these functions that result in delay() or yield()
|
||||
// ********************************************************************************
|
||||
#ifdef ESP32
|
||||
void WiFiEvent(system_event_id_t event, system_event_info_t info) {
|
||||
switch (event) {
|
||||
case SYSTEM_EVENT_STA_CONNECTED:
|
||||
lastConnectMoment = millis();
|
||||
processedConnect = false;
|
||||
wifiStatus = ESPEASY_WIFI_CONNECTED;
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_DISCONNECTED:
|
||||
lastDisconnectMoment = millis();
|
||||
|
||||
if (timeDiff(lastConnectMoment, last_wifi_connect_attempt_moment) > 0) {
|
||||
// There was an unsuccessful connection attempt
|
||||
lastConnectedDuration = timeDiff(last_wifi_connect_attempt_moment, lastDisconnectMoment);
|
||||
} else {
|
||||
lastConnectedDuration = timeDiff(lastConnectMoment, lastDisconnectMoment);
|
||||
}
|
||||
processedDisconnect = false;
|
||||
lastDisconnectReason = static_cast<WiFiDisconnectReason>(info.disconnected.reason);
|
||||
wifiStatus = ESPEASY_WIFI_DISCONNECTED;
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_GOT_IP:
|
||||
markGotIP();
|
||||
break;
|
||||
case SYSTEM_EVENT_AP_STACONNECTED:
|
||||
|
||||
for (byte i = 0; i < 6; ++i) {
|
||||
lastMacConnectedAPmode[i] = info.sta_connected.mac[i];
|
||||
}
|
||||
processedConnectAPmode = false;
|
||||
break;
|
||||
case SYSTEM_EVENT_AP_STADISCONNECTED:
|
||||
|
||||
for (byte i = 0; i < 6; ++i) {
|
||||
lastMacConnectedAPmode[i] = info.sta_disconnected.mac[i];
|
||||
}
|
||||
processedDisconnectAPmode = false;
|
||||
break;
|
||||
case SYSTEM_EVENT_SCAN_DONE:
|
||||
lastGetScanMoment = millis();
|
||||
|
||||
// scan_done_status = info.scan_done.status;
|
||||
scan_done_number = info.scan_done.number;
|
||||
|
||||
// scan_done_scan_id = info.scan_done.scan_id;
|
||||
processedScanDone = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ESP8266
|
||||
|
||||
void onConnected(const WiFiEventStationModeConnected& event) {
|
||||
lastConnectMoment = millis();
|
||||
processedConnect = false;
|
||||
wifiStatus = ESPEASY_WIFI_CONNECTED;
|
||||
channel_changed = last_channel != event.channel;
|
||||
last_channel = event.channel;
|
||||
last_ssid = event.ssid;
|
||||
bssid_changed = false;
|
||||
|
||||
for (byte i = 0; i < 6; ++i) {
|
||||
if (lastBSSID[i] != event.bssid[i]) {
|
||||
bssid_changed = true;
|
||||
lastBSSID[i] = event.bssid[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onDisconnect(const WiFiEventStationModeDisconnected& event) {
|
||||
lastDisconnectMoment = millis();
|
||||
|
||||
if (timeDiff(lastConnectMoment, last_wifi_connect_attempt_moment) > 0) {
|
||||
// There was an unsuccessful connection attempt
|
||||
lastConnectedDuration = timeDiff(last_wifi_connect_attempt_moment, lastDisconnectMoment);
|
||||
} else {
|
||||
lastConnectedDuration = timeDiff(lastConnectMoment, lastDisconnectMoment);
|
||||
}
|
||||
lastDisconnectReason = event.reason;
|
||||
wifiStatus = ESPEASY_WIFI_DISCONNECTED;
|
||||
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
// See https://github.com/esp8266/Arduino/issues/5912
|
||||
WiFi.disconnect();
|
||||
}
|
||||
processedDisconnect = false;
|
||||
}
|
||||
|
||||
void onGotIP(const WiFiEventStationModeGotIP& event) {
|
||||
markGotIP();
|
||||
}
|
||||
|
||||
void ICACHE_RAM_ATTR onDHCPTimeout() {
|
||||
processedDHCPTimeout = false;
|
||||
}
|
||||
|
||||
void onConnectedAPmode(const WiFiEventSoftAPModeStationConnected& event) {
|
||||
for (byte i = 0; i < 6; ++i) {
|
||||
lastMacConnectedAPmode[i] = event.mac[i];
|
||||
}
|
||||
processedConnectAPmode = false;
|
||||
}
|
||||
|
||||
void onDisonnectedAPmode(const WiFiEventSoftAPModeStationDisconnected& event) {
|
||||
for (byte i = 0; i < 6; ++i) {
|
||||
lastMacDisconnectedAPmode[i] = event.mac[i];
|
||||
}
|
||||
processedDisconnectAPmode = false;
|
||||
}
|
||||
|
||||
void onScanFinished(int networksFound) {
|
||||
lastGetScanMoment = millis();
|
||||
scan_done_number = networksFound;
|
||||
processedScanDone = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
+24
-125
@@ -1,161 +1,60 @@
|
||||
#include "ESPEasy_common.h"
|
||||
|
||||
#include <IPAddress.h>
|
||||
|
||||
// ********************************************************************************
|
||||
|
||||
// Work-around for setting _useStaticIP
|
||||
// See reported issue: https://github.com/esp8266/Arduino/issues/4114
|
||||
// ********************************************************************************
|
||||
#ifdef ESP32
|
||||
#include <IPv6Address.h>
|
||||
#include <WiFiSTA.h>
|
||||
class WiFi_Access_Static_IP : public WiFiSTAClass {
|
||||
public:
|
||||
|
||||
void set_use_static_ip(bool enabled) {
|
||||
_useStaticIp = enabled;
|
||||
}
|
||||
void set_use_static_ip(bool enabled);
|
||||
};
|
||||
#else // ifdef ESP32
|
||||
#endif
|
||||
|
||||
#ifdef ESP8266
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266WiFiSTA.h>
|
||||
class WiFi_Access_Static_IP : public ESP8266WiFiSTAClass {
|
||||
public:
|
||||
|
||||
void set_use_static_ip(bool enabled) {
|
||||
_useStaticIp = enabled;
|
||||
}
|
||||
void set_use_static_ip(bool enabled);
|
||||
};
|
||||
#endif // ifdef ESP32
|
||||
#endif
|
||||
|
||||
|
||||
void setUseStaticIP(bool enabled) {
|
||||
WiFi_Access_Static_IP tmp_wifi;
|
||||
void setUseStaticIP(bool enabled);
|
||||
|
||||
tmp_wifi.set_use_static_ip(enabled);
|
||||
}
|
||||
|
||||
void markGotIP() {
|
||||
lastGetIPmoment = millis();
|
||||
wifiStatus = ESPEASY_WIFI_GOT_IP;
|
||||
processedGotIP = false;
|
||||
}
|
||||
void markGotIP();
|
||||
|
||||
// ********************************************************************************
|
||||
// Functions called on events.
|
||||
// Make sure not to call anything in these functions that result in delay() or yield()
|
||||
// ********************************************************************************
|
||||
#ifdef ESP32
|
||||
void WiFiEvent(system_event_id_t event, system_event_info_t info) {
|
||||
switch (event) {
|
||||
case SYSTEM_EVENT_STA_CONNECTED:
|
||||
lastConnectMoment = millis();
|
||||
processedConnect = false;
|
||||
wifiStatus = ESPEASY_WIFI_CONNECTED;
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_DISCONNECTED:
|
||||
lastDisconnectMoment = millis();
|
||||
void WiFiEvent(system_event_id_t event, system_event_info_t info);
|
||||
|
||||
if (timeDiff(lastConnectMoment, last_wifi_connect_attempt_moment) > 0) {
|
||||
// There was an unsuccessful connection attempt
|
||||
lastConnectedDuration = timeDiff(last_wifi_connect_attempt_moment, lastDisconnectMoment);
|
||||
} else {
|
||||
lastConnectedDuration = timeDiff(lastConnectMoment, lastDisconnectMoment);
|
||||
}
|
||||
processedDisconnect = false;
|
||||
lastDisconnectReason = static_cast<WiFiDisconnectReason>(info.disconnected.reason);
|
||||
wifiStatus = ESPEASY_WIFI_DISCONNECTED;
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_GOT_IP:
|
||||
markGotIP();
|
||||
break;
|
||||
case SYSTEM_EVENT_AP_STACONNECTED:
|
||||
#endif
|
||||
|
||||
for (byte i = 0; i < 6; ++i) {
|
||||
lastMacConnectedAPmode[i] = info.sta_connected.mac[i];
|
||||
}
|
||||
processedConnectAPmode = false;
|
||||
break;
|
||||
case SYSTEM_EVENT_AP_STADISCONNECTED:
|
||||
#ifdef ESP8266
|
||||
|
||||
for (byte i = 0; i < 6; ++i) {
|
||||
lastMacConnectedAPmode[i] = info.sta_disconnected.mac[i];
|
||||
}
|
||||
processedDisconnectAPmode = false;
|
||||
break;
|
||||
case SYSTEM_EVENT_SCAN_DONE:
|
||||
lastGetScanMoment = millis();
|
||||
void onConnected(const WiFiEventStationModeConnected& event);
|
||||
|
||||
// scan_done_status = info.scan_done.status;
|
||||
scan_done_number = info.scan_done.number;
|
||||
void onDisconnect(const WiFiEventStationModeDisconnected& event);
|
||||
|
||||
// scan_done_scan_id = info.scan_done.scan_id;
|
||||
processedScanDone = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
void onGotIP(const WiFiEventStationModeGotIP& event);
|
||||
|
||||
#else // ifdef ESP32
|
||||
void ICACHE_RAM_ATTR onDHCPTimeout();
|
||||
|
||||
void onConnected(const WiFiEventStationModeConnected& event) {
|
||||
lastConnectMoment = millis();
|
||||
processedConnect = false;
|
||||
wifiStatus = ESPEASY_WIFI_CONNECTED;
|
||||
channel_changed = last_channel != event.channel;
|
||||
last_channel = event.channel;
|
||||
last_ssid = event.ssid;
|
||||
bssid_changed = false;
|
||||
void onConnectedAPmode(const WiFiEventSoftAPModeStationConnected& event);
|
||||
|
||||
for (byte i = 0; i < 6; ++i) {
|
||||
if (lastBSSID[i] != event.bssid[i]) {
|
||||
bssid_changed = true;
|
||||
lastBSSID[i] = event.bssid[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
void onDisonnectedAPmode(const WiFiEventSoftAPModeStationDisconnected& event);
|
||||
|
||||
void onDisconnect(const WiFiEventStationModeDisconnected& event) {
|
||||
lastDisconnectMoment = millis();
|
||||
|
||||
if (timeDiff(lastConnectMoment, last_wifi_connect_attempt_moment) > 0) {
|
||||
// There was an unsuccessful connection attempt
|
||||
lastConnectedDuration = timeDiff(last_wifi_connect_attempt_moment, lastDisconnectMoment);
|
||||
} else {
|
||||
lastConnectedDuration = timeDiff(lastConnectMoment, lastDisconnectMoment);
|
||||
}
|
||||
lastDisconnectReason = event.reason;
|
||||
wifiStatus = ESPEASY_WIFI_DISCONNECTED;
|
||||
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
// See https://github.com/esp8266/Arduino/issues/5912
|
||||
WiFi.disconnect();
|
||||
}
|
||||
processedDisconnect = false;
|
||||
}
|
||||
|
||||
void onGotIP(const WiFiEventStationModeGotIP& event) {
|
||||
markGotIP();
|
||||
}
|
||||
|
||||
void ICACHE_RAM_ATTR onDHCPTimeout() {
|
||||
processedDHCPTimeout = false;
|
||||
}
|
||||
|
||||
void onConnectedAPmode(const WiFiEventSoftAPModeStationConnected& event) {
|
||||
for (byte i = 0; i < 6; ++i) {
|
||||
lastMacConnectedAPmode[i] = event.mac[i];
|
||||
}
|
||||
processedConnectAPmode = false;
|
||||
}
|
||||
|
||||
void onDisonnectedAPmode(const WiFiEventSoftAPModeStationDisconnected& event) {
|
||||
for (byte i = 0; i < 6; ++i) {
|
||||
lastMacDisconnectedAPmode[i] = event.mac[i];
|
||||
}
|
||||
processedDisconnectAPmode = false;
|
||||
}
|
||||
|
||||
void onScanFinished(int networksFound) {
|
||||
lastGetScanMoment = millis();
|
||||
scan_done_number = networksFound;
|
||||
processedScanDone = false;
|
||||
}
|
||||
void onScanFinished(int networksFound);
|
||||
|
||||
#endif // ifdef ESP32
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#define WIFI_RECONNECT_WAIT 20000 // in milliSeconds
|
||||
#define WIFI_AP_OFF_TIMER_DURATION 60000 // in milliSeconds
|
||||
|
||||
#include "src/Globals/ESPEasyWiFiEvent.h"
|
||||
|
||||
// ********************************************************************************
|
||||
// WiFi state
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "src/Globals/ESPEasyWiFiEvent.h"
|
||||
|
||||
bool unprocessedWifiEvents() {
|
||||
if (processedConnect && processedDisconnect && processedGotIP && processedDHCPTimeout)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "ESPEasy_Log.h"
|
||||
#include "src/Globals/Logging.h"
|
||||
#include "src/Globals/ESPEasyWiFiEvent.h"
|
||||
#include "src/DataStructs/LogStruct.h"
|
||||
|
||||
/********************************************************************************************\
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
|
||||
// Forward declaration to give access to global member variables
|
||||
unsigned long & getConnectionFailures();
|
||||
float & getUserVar(unsigned int varIndex);
|
||||
|
||||
|
||||
@@ -70,6 +69,7 @@ bool connectClient(WiFiClient& client,
|
||||
|
||||
bool WiFiConnected(uint32_t timeout_ms);
|
||||
bool WiFiConnected();
|
||||
bool useStaticIP();
|
||||
bool hostReachable(const IPAddress& ip);
|
||||
bool hostReachable(const String& hostname);
|
||||
void formatMAC(const uint8_t * mac, char (& strMAC)[20]);
|
||||
|
||||
+8
-6
@@ -1,18 +1,20 @@
|
||||
#include "src/Globals/RTC.h"
|
||||
#include "src/DataStructs/Caches.h"
|
||||
#include "src/DataStructs/NodeStruct.h"
|
||||
#include "src/DataStructs/PinMode.h"
|
||||
#include "src/DataStructs/RTCStruct.h"
|
||||
#include "src/Globals/ResetFactoryDefaultPref.h"
|
||||
|
||||
#include "src/Globals/CRCValues.h"
|
||||
#include "src/Globals/Cache.h"
|
||||
#include "src/Globals/Device.h"
|
||||
#include "src/Globals/RTC.h"
|
||||
#include "src/Globals/ResetFactoryDefaultPref.h"
|
||||
#include "src/Globals/Services.h"
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
ESPEasy specific strings
|
||||
\*********************************************************************************************/
|
||||
|
||||
#include "src/DataStructs/NodeStruct.h"
|
||||
#include "src/DataStructs/PinMode.h"
|
||||
#include "src/DataStructs/Caches.h"
|
||||
#include "src/Globals/Cache.h"
|
||||
|
||||
String getNodeTypeDisplayString(byte nodeType) {
|
||||
switch (nodeType)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "src/Globals/Nodes.h"
|
||||
#include "src/Globals/ESPEasyWiFiEvent.h"
|
||||
|
||||
// Generic Networking routines
|
||||
|
||||
|
||||
+1
-1
@@ -391,7 +391,7 @@ void process_plugin_task_timer(unsigned long id) {
|
||||
|
||||
// TD-er: Not sure if we have to keep original source for notifications.
|
||||
TempEvent.Source = VALUE_SOURCE_SYSTEM;
|
||||
const int y = getPluginId(timer_data.TaskIndex);
|
||||
const int y = getPluginId_from_TaskIndex(timer_data.TaskIndex);
|
||||
|
||||
/*
|
||||
String log = F("proc_system_timer: Pluginid: ");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "src/Globals/CRCValues.h"
|
||||
#include "src/Globals/Device.h"
|
||||
#include "src/Globals/ESPEasyWiFiEvent.h"
|
||||
|
||||
/********************************************************************************************\
|
||||
Convert a char string to integer
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
|
||||
#include "src/Globals/Device.h"
|
||||
#include "src/Static/WebStaticData.h"
|
||||
|
||||
// ********************************************************************************
|
||||
// Core part of WebServer, the chunked streaming buffer
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "src/Globals/Nodes.h"
|
||||
#include "src/Globals/Device.h"
|
||||
#include "src/Static/WebStaticData.h"
|
||||
|
||||
|
||||
void handle_devices() {
|
||||
checkRAM(F("handle_devices"));
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
#include "src/Static/WebStaticData.h"
|
||||
|
||||
void handle_favicon() {
|
||||
checkRAM(F("handle_favicon"));
|
||||
WebServer.send_P(200, PSTR("image/x-icon"), favicon_8b_ico, favicon_8b_ico_len);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "src/Static/WebStaticData.h"
|
||||
|
||||
|
||||
// ********************************************************************************
|
||||
// HTML string re-use to keep the executable smaller
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "src/Globals/Logging.h"
|
||||
#include "src/Static/WebStaticData.h"
|
||||
|
||||
// ********************************************************************************
|
||||
// Web Interface log page
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "src/Globals/RTC.h"
|
||||
#include "src/DataStructs/RTCStruct.h"
|
||||
#include "src/Globals/CRCValues.h"
|
||||
#include "src/Static/WebStaticData.h"
|
||||
|
||||
#ifdef WEBSERVER_NEW_UI
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -15,6 +15,7 @@
|
||||
#include "src/Globals/CRCValues.h"
|
||||
#include "src/Globals/Settings.h"
|
||||
#include "src/Globals/SecuritySettings.h"
|
||||
#include "src/Globals/ESPEasyWiFiEvent.h"
|
||||
|
||||
#include <WiFiClient.h>
|
||||
#include <WiFiUdp.h>
|
||||
@@ -250,7 +251,7 @@ void log_connecting_fail(const String& prefix, int controller_number, Controller
|
||||
String log = prefix;
|
||||
log += get_formatted_Controller_number(controller_number);
|
||||
log += F(" connection failed (");
|
||||
log += getConnectionFailures();
|
||||
log += connectionFailures;
|
||||
log += F("/");
|
||||
log += Settings.ConnectionFailuresThreshold;
|
||||
log += F(")");
|
||||
@@ -261,14 +262,14 @@ void log_connecting_fail(const String& prefix, int controller_number, Controller
|
||||
bool count_connection_results(bool success, const String& prefix, int controller_number, ControllerSettingsStruct& ControllerSettings) {
|
||||
if (!success)
|
||||
{
|
||||
getConnectionFailures()++;
|
||||
connectionFailures++;
|
||||
log_connecting_fail(prefix, controller_number, ControllerSettings);
|
||||
return false;
|
||||
}
|
||||
statusLED(true);
|
||||
|
||||
if (getConnectionFailures()) {
|
||||
getConnectionFailures()--;
|
||||
if (connectionFailures) {
|
||||
connectionFailures--;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -800,4 +800,10 @@ boolean Plugin_004_DS_crc8(uint8_t *addr)
|
||||
return crc == *addr; // addr 8
|
||||
}
|
||||
|
||||
|
||||
#if defined(ESP32)
|
||||
#undef ESP32noInterrupts
|
||||
#undef ESP32interrupts
|
||||
#endif
|
||||
|
||||
#endif // USES_P004
|
||||
|
||||
@@ -545,4 +545,11 @@ boolean Plugin_080_DS_crc8(uint8_t * addr)
|
||||
}
|
||||
return crc == *addr; // addr 8
|
||||
}
|
||||
|
||||
#if defined(ESP32)
|
||||
#undef ESP32noInterrupts
|
||||
#undef ESP32interrupts
|
||||
#endif
|
||||
|
||||
|
||||
#endif // USES_P080
|
||||
|
||||
+4
-36
@@ -1065,38 +1065,6 @@ void PluginInit(void)
|
||||
}
|
||||
|
||||
|
||||
// TODO TD-er: Move to Plugins.cpp
|
||||
int getPluginId(byte taskId) {
|
||||
if (taskId < TASKS_MAX) {
|
||||
int retry = 1;
|
||||
while (retry >= 0) {
|
||||
int plugin = Task_id_to_Plugin_id[taskId];
|
||||
if (plugin >= 0 && plugin < PLUGIN_MAX) {
|
||||
if (Plugin_id[plugin] == Settings.TaskDeviceNumber[taskId])
|
||||
return plugin;
|
||||
}
|
||||
updateTaskPluginCache();
|
||||
--retry;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// TODO TD-er: Move to Plugins.cpp
|
||||
void updateTaskPluginCache() {
|
||||
++countFindPluginId; // Used for statistics.
|
||||
Task_id_to_Plugin_id.resize(TASKS_MAX);
|
||||
for (byte y = 0; y < TASKS_MAX; ++y) {
|
||||
Task_id_to_Plugin_id[y] = -1;
|
||||
bool foundPlugin = false;
|
||||
for (byte x = 0; x < PLUGIN_MAX && !foundPlugin; ++x) {
|
||||
if (Plugin_id[x] != 0 && Plugin_id[x] == Settings.TaskDeviceNumber[y]) {
|
||||
foundPlugin = true;
|
||||
Task_id_to_Plugin_id[y] = x;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int8_t getXFromPluginId(byte pluginID) {
|
||||
std::vector<byte>::iterator it;
|
||||
@@ -1177,7 +1145,7 @@ byte PluginCall(byte Function, struct EventStruct *event, String& str)
|
||||
{
|
||||
if (Settings.TaskDeviceDataFeed[y] == 0) // these calls only to tasks with local feed
|
||||
{
|
||||
const int x = getPluginId(y);
|
||||
const int x = getPluginId_from_TaskIndex(y);
|
||||
if (x >= 0) {
|
||||
byte DeviceIndex = getDeviceIndex(Settings.TaskDeviceNumber[y]);
|
||||
TempEvent.TaskIndex = y;
|
||||
@@ -1217,7 +1185,7 @@ byte PluginCall(byte Function, struct EventStruct *event, String& str)
|
||||
{
|
||||
if (Settings.TaskDeviceEnabled[y] && Settings.TaskDeviceNumber[y] != 0)
|
||||
{
|
||||
const int x = getPluginId(y);
|
||||
const int x = getPluginId_from_TaskIndex(y);
|
||||
if (x >= 0) {
|
||||
byte DeviceIndex = getDeviceIndex(Settings.TaskDeviceNumber[y]);
|
||||
TempEvent.TaskIndex = y;
|
||||
@@ -1256,7 +1224,7 @@ byte PluginCall(byte Function, struct EventStruct *event, String& str)
|
||||
{
|
||||
if (Settings.TaskDeviceDataFeed[y] == 0) // these calls only to tasks with local feed
|
||||
{
|
||||
const int x = getPluginId(y);
|
||||
const int x = getPluginId_from_TaskIndex(y);
|
||||
if (x >= 0) {
|
||||
byte DeviceIndex = getDeviceIndex(Settings.TaskDeviceNumber[y]);
|
||||
TempEvent.TaskIndex = y;
|
||||
@@ -1296,7 +1264,7 @@ byte PluginCall(byte Function, struct EventStruct *event, String& str)
|
||||
case PLUGIN_GET_PACKED_RAW_DATA:
|
||||
case PLUGIN_SET_DEFAULTS:
|
||||
{
|
||||
const int x = getPluginId(event->TaskIndex);
|
||||
const int x = getPluginId_from_TaskIndex(event->TaskIndex);
|
||||
if (x >= 0) {
|
||||
if (Plugin_id[x] != 0 ) {
|
||||
if (Function == PLUGIN_INIT) {
|
||||
|
||||
@@ -1,19 +1,35 @@
|
||||
|
||||
// FIXME TD-er Must make global variables available to complete this transition to .cpp file.
|
||||
/*
|
||||
#include "Diagnostic.h"
|
||||
|
||||
/*
|
||||
#include "Common.h"
|
||||
#include "../../ESPEasy_common.h"
|
||||
#include "../../ESPEasy_fdwdecl.h"
|
||||
#include "../DataStructs/ESPEasy_EventStruct.h"
|
||||
#include "../DataStructs/SettingsType.h"
|
||||
#include "../DataStructs/PortStatusStruct.h"
|
||||
#include "../../ESPEasy_Log.h"
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../../ESPEasy_common.h"
|
||||
#include "src/Commands/Common.h"
|
||||
#include "src/Globals/Settings.h"
|
||||
#include "src/Globals/SecuritySettings.h"
|
||||
#include "src/Globals/ExtraTaskSettings.h"
|
||||
#include "src/Globals/Device.h"
|
||||
#include "src/DataStructs/SettingsType.h"
|
||||
#include "src/DataStructs/PortStatusStruct.h"
|
||||
#include "src/Globals/GlobalMapPortStatus.h"
|
||||
#include "../../ESPEasy_Log.h"
|
||||
#include "../Globals/Statistics.h"
|
||||
|
||||
|
||||
#include "ESPEasy_fdwdecl.h"
|
||||
|
||||
|
||||
#ifndef BUILD_MINIMAL_OTA
|
||||
bool showSettingsFileLayout = false;
|
||||
#endif
|
||||
|
||||
String Command_Lowmem(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
String result;
|
||||
@@ -175,5 +191,3 @@ String Command_logPortStatus(struct EventStruct *event, const char* Line)
|
||||
logPortStatus("Rules");
|
||||
return return_command_success();
|
||||
}
|
||||
|
||||
*/
|
||||
+21
-164
@@ -1,177 +1,34 @@
|
||||
#ifndef COMMAND_DIAGNOSTIC_H
|
||||
#define COMMAND_DIAGNOSTIC_H
|
||||
|
||||
// FIXME TD-er Must complete moving these to the .cpp file
|
||||
#include <stdint.h>
|
||||
#include <map>
|
||||
|
||||
#include "../../ESPEasy_common.h"
|
||||
#include "src/Globals/Settings.h"
|
||||
#include "src/Globals/SecuritySettings.h"
|
||||
#include "src/Globals/ExtraTaskSettings.h"
|
||||
#include "src/Globals/Device.h"
|
||||
#include "src/DataStructs/SettingsType.h"
|
||||
class String;
|
||||
struct portStatusStruct;
|
||||
|
||||
#include "ESPEasy_fdwdecl.h"
|
||||
|
||||
String Command_Lowmem(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
String result;
|
||||
result += lowestRAM;
|
||||
result += F(" : ");
|
||||
result += lowestRAMfunction;
|
||||
return return_result(event, result);
|
||||
}
|
||||
String Command_Lowmem(struct EventStruct *event, const char* Line);
|
||||
String Command_Malloc(struct EventStruct *event, const char* Line);
|
||||
String Command_SysLoad(struct EventStruct *event, const char* Line);
|
||||
String Command_SerialFloat(struct EventStruct *event, const char* Line);
|
||||
String Command_MemInfo(struct EventStruct *event, const char* Line);
|
||||
String Command_MemInfo_detail(struct EventStruct *event, const char* Line);
|
||||
String Command_Background(struct EventStruct *event, const char* Line);
|
||||
String Command_Debug(struct EventStruct *event, const char* Line);
|
||||
String Command_logentry(struct EventStruct *event, const char* Line);
|
||||
String Command_JSONPortStatus(struct EventStruct *event, const char* Line);
|
||||
void createLogPortStatus(std::map< uint32_t, portStatusStruct >::iterator it);
|
||||
void debugPortStatus(std::map< uint32_t, portStatusStruct >::iterator it);
|
||||
void logPortStatus(String from);
|
||||
String Command_logPortStatus(struct EventStruct *event, const char* Line);
|
||||
|
||||
String Command_Malloc(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
char* ramtest;
|
||||
ramtest = (char*)malloc(event->Par1);
|
||||
if (ramtest == NULL) return F("failed");
|
||||
free(ramtest);
|
||||
return return_command_success();
|
||||
}
|
||||
|
||||
String Command_SysLoad(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
String result = toString(getCPUload());
|
||||
result += F("% (LC=");
|
||||
result += getLoopCountPerSec();
|
||||
result += ')';
|
||||
return return_result(event, result);
|
||||
}
|
||||
|
||||
String Command_SerialFloat(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
pinMode(1, INPUT);
|
||||
pinMode(3, INPUT);
|
||||
delay(60000);
|
||||
return return_command_success();
|
||||
}
|
||||
|
||||
String Command_MemInfo(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
serialPrint(F("SecurityStruct | "));
|
||||
serialPrintln(String(sizeof(SecuritySettings)));
|
||||
serialPrint(F("SettingsStruct | "));
|
||||
serialPrintln(String(sizeof(Settings)));
|
||||
serialPrint(F("ExtraTaskSettingsStruct| "));
|
||||
serialPrintln(String(sizeof(ExtraTaskSettings)));
|
||||
serialPrint(F("DeviceStruct | "));
|
||||
serialPrintln(String(sizeof(Device)));
|
||||
return return_see_serial(event);
|
||||
}
|
||||
|
||||
String Command_MemInfo_detail(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
#ifndef BUILD_MINIMAL_OTA
|
||||
showSettingsFileLayout = true;
|
||||
// Show settings file layout in charts on sysinfo page.
|
||||
// Will be enabled after running command "meminfodetail"
|
||||
extern bool showSettingsFileLayout;
|
||||
#endif
|
||||
Command_MemInfo(event, Line);
|
||||
for (int st = 0; st < SettingsType_MAX; ++st) {
|
||||
SettingsType settingsType = static_cast<SettingsType>(st);
|
||||
int max_index, offset, max_size;
|
||||
int struct_size = 0;
|
||||
serialPrintln();
|
||||
serialPrint(getSettingsTypeString(settingsType));
|
||||
serialPrintln(F(" | start | end | max_size | struct_size"));
|
||||
serialPrintln(F("--- | --- | --- | --- | ---"));
|
||||
getSettingsParameters(settingsType, 0, max_index, offset, max_size, struct_size);
|
||||
for (int i = 0; i < max_index; ++i) {
|
||||
getSettingsParameters(settingsType, i, offset, max_size);
|
||||
serialPrint(String(i));
|
||||
serialPrint("|");
|
||||
serialPrint(String(offset));
|
||||
serialPrint("|");
|
||||
serialPrint(String(offset + max_size - 1));
|
||||
serialPrint("|");
|
||||
serialPrint(String(max_size));
|
||||
serialPrint("|");
|
||||
serialPrintln(String(struct_size));
|
||||
}
|
||||
}
|
||||
return return_see_serial(event);
|
||||
}
|
||||
|
||||
String Command_Background(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
unsigned long timer = millis() + event->Par1;
|
||||
serialPrintln(F("start"));
|
||||
while (!timeOutReached(timer))
|
||||
backgroundtasks();
|
||||
serialPrintln(F("end"));
|
||||
return return_see_serial(event);
|
||||
}
|
||||
|
||||
String Command_Debug(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
if (HasArgv(Line, 2)) {
|
||||
setLogLevelFor(LOG_TO_SERIAL, event->Par1);
|
||||
}else {
|
||||
serialPrintln();
|
||||
serialPrint(F("Serial debug level: "));
|
||||
serialPrintln(String(Settings.SerialLogLevel));
|
||||
}
|
||||
return return_see_serial(event);
|
||||
}
|
||||
|
||||
String Command_logentry(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
addLog(LOG_LEVEL_INFO,Line);
|
||||
return return_command_success();
|
||||
}
|
||||
|
||||
|
||||
String Command_JSONPortStatus(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
addLog(LOG_LEVEL_INFO,F("JSON Port Status: Command not implemented yet."));
|
||||
return return_command_success();
|
||||
}
|
||||
|
||||
void createLogPortStatus(std::map<uint32_t,portStatusStruct>::iterator it)
|
||||
{
|
||||
String log = F("PortStatus detail: ");
|
||||
log += F("Port=");
|
||||
log += getPortFromKey(it->first);
|
||||
log += F(" State=");
|
||||
log += it->second.state;
|
||||
log += F(" Output=");
|
||||
log += it->second.output;
|
||||
log += F(" Mode=");
|
||||
log += it->second.mode;
|
||||
log += F(" Task=");
|
||||
log += it->second.task;
|
||||
log += F(" Monitor=");
|
||||
log += it->second.monitor;
|
||||
log += F(" Command=");
|
||||
log += it->second.command;
|
||||
log += F(" Init=");
|
||||
log += it->second.init;
|
||||
log += F(" PreviousTask=");
|
||||
log += it->second.previousTask;
|
||||
addLog(LOG_LEVEL_INFO,log);
|
||||
}
|
||||
|
||||
void debugPortStatus(std::map<uint32_t,portStatusStruct>::iterator it)
|
||||
{
|
||||
createLogPortStatus(it);
|
||||
}
|
||||
|
||||
void logPortStatus(String from) {
|
||||
String log;
|
||||
log=F("PortStatus structure: Called from=");
|
||||
log+=from;
|
||||
log+=F(" Count=");
|
||||
log+=globalMapPortStatus.size();
|
||||
addLog(LOG_LEVEL_INFO,log);
|
||||
|
||||
for (std::map<uint32_t,portStatusStruct>::iterator it=globalMapPortStatus.begin(); it!=globalMapPortStatus.end(); ++it) {
|
||||
debugPortStatus(it);
|
||||
}
|
||||
}
|
||||
|
||||
String Command_logPortStatus(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
logPortStatus("Rules");
|
||||
return return_command_success();
|
||||
}
|
||||
|
||||
#endif // COMMAND_DIAGNOSTIC_H
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define COMMAND_NETWORKS_H
|
||||
|
||||
|
||||
//#include "../ESPEasy-Globals.h"
|
||||
|
||||
|
||||
String Command_AccessInfo_Ls(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define COMMAND_RULES_H
|
||||
|
||||
|
||||
// #include "../ESPEasy-Globals.h"
|
||||
|
||||
String Command_Rules_Execute(struct EventStruct *event, const char *Line)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ struct portStatusStruct {
|
||||
int8_t x; // used to synchronize the Plugin_prt vector index (x) with the PLUGIN_ID
|
||||
};
|
||||
|
||||
std::map<uint32_t, portStatusStruct> globalMapPortStatus;
|
||||
typedef std::map<uint32_t, portStatusStruct> MapPortStatus;
|
||||
|
||||
|
||||
#endif // DATASTRUCTS_PORTSTATUSSTRUCT_H
|
||||
|
||||
@@ -18,9 +18,5 @@ String getSettingsTypeString(SettingsType settingsType);
|
||||
bool getSettingsParameters(SettingsType settingsType, int index, int& offset, int& max_size);
|
||||
bool getSettingsParameters(SettingsType settingsType, int index, int& max_index, int& offset, int& max_size, int& struct_size);
|
||||
|
||||
#ifndef BUILD_MINIMAL_OTA
|
||||
bool showSettingsFileLayout = false;
|
||||
#endif
|
||||
|
||||
|
||||
#endif // DATASTRUCTS_SETTINGSTYPE_H
|
||||
@@ -0,0 +1,54 @@
|
||||
#include "../Globals/ESPEasyWiFiEvent.h"
|
||||
|
||||
#include "../../ESPEasy_common.h"
|
||||
|
||||
|
||||
unsigned long connectionFailures = 0;
|
||||
|
||||
#ifdef ESP8266
|
||||
WiFiEventHandler stationConnectedHandler;
|
||||
WiFiEventHandler stationDisconnectedHandler;
|
||||
WiFiEventHandler stationGotIpHandler;
|
||||
WiFiEventHandler stationModeDHCPTimeoutHandler;
|
||||
WiFiEventHandler APModeStationConnectedHandler;
|
||||
WiFiEventHandler APModeStationDisconnectedHandler;
|
||||
#endif // ifdef ESP8266
|
||||
|
||||
|
||||
// WiFi related data
|
||||
bool wifiSetup = false;
|
||||
bool wifiSetupConnect = false;
|
||||
uint8_t lastBSSID[6] = { 0 };
|
||||
uint8_t wifiStatus = ESPEASY_WIFI_DISCONNECTED;
|
||||
unsigned long last_wifi_connect_attempt_moment = 0;
|
||||
unsigned int wifi_connect_attempt = 0;
|
||||
int wifi_reconnects = -1; // First connection attempt is not a reconnect.
|
||||
uint8_t lastWiFiSettings = 0;
|
||||
String last_ssid;
|
||||
bool bssid_changed = false;
|
||||
bool channel_changed = false;
|
||||
uint8_t last_channel = 0;
|
||||
WiFiDisconnectReason lastDisconnectReason = WIFI_DISCONNECT_REASON_UNSPECIFIED;
|
||||
unsigned long lastConnectMoment = 0;
|
||||
unsigned long lastDisconnectMoment = 0;
|
||||
unsigned long lastGetIPmoment = 0;
|
||||
unsigned long lastGetScanMoment = 0;
|
||||
unsigned long lastConnectedDuration = 0;
|
||||
bool intent_to_reboot = false;
|
||||
uint8_t lastMacConnectedAPmode[6] = { 0 };
|
||||
uint8_t lastMacDisconnectedAPmode[6] = { 0 };
|
||||
|
||||
// uint32_t scan_done_status = 0;
|
||||
// uint8_t scan_done_scan_id = 0;
|
||||
uint8_t scan_done_number = 0;
|
||||
|
||||
// Semaphore like bools for processing data gathered from WiFi events.
|
||||
volatile bool processedConnect = true;
|
||||
volatile bool processedDisconnect = true;
|
||||
volatile bool processedGotIP = true;
|
||||
volatile bool processedDHCPTimeout = true;
|
||||
volatile bool processedConnectAPmode = true;
|
||||
volatile bool processedDisconnectAPmode = true;
|
||||
volatile bool processedScanDone = true;
|
||||
bool wifiConnectAttemptNeeded = true;
|
||||
bool wifiConnectInProgress = false;
|
||||
@@ -0,0 +1,112 @@
|
||||
#ifndef GLOBALS_ESPEASYWIFIEVENT_H
|
||||
#define GLOBALS_ESPEASYWIFIEVENT_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <IPAddress.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// WifiStatus
|
||||
#define ESPEASY_WIFI_DISCONNECTED 0
|
||||
#define ESPEASY_WIFI_CONNECTED 1
|
||||
#define ESPEASY_WIFI_GOT_IP 2
|
||||
#define ESPEASY_WIFI_SERVICES_INITIALIZED 4
|
||||
|
||||
|
||||
extern unsigned long connectionFailures;
|
||||
|
||||
|
||||
#ifdef ESP32
|
||||
# include <esp_event.h>
|
||||
|
||||
|
||||
enum WiFiDisconnectReason
|
||||
{
|
||||
WIFI_DISCONNECT_REASON_UNSPECIFIED = 1,
|
||||
WIFI_DISCONNECT_REASON_AUTH_EXPIRE = 2,
|
||||
WIFI_DISCONNECT_REASON_AUTH_LEAVE = 3,
|
||||
WIFI_DISCONNECT_REASON_ASSOC_EXPIRE = 4,
|
||||
WIFI_DISCONNECT_REASON_ASSOC_TOOMANY = 5,
|
||||
WIFI_DISCONNECT_REASON_NOT_AUTHED = 6,
|
||||
WIFI_DISCONNECT_REASON_NOT_ASSOCED = 7,
|
||||
WIFI_DISCONNECT_REASON_ASSOC_LEAVE = 8,
|
||||
WIFI_DISCONNECT_REASON_ASSOC_NOT_AUTHED = 9,
|
||||
WIFI_DISCONNECT_REASON_DISASSOC_PWRCAP_BAD = 10, /* 11h */
|
||||
WIFI_DISCONNECT_REASON_DISASSOC_SUPCHAN_BAD = 11, /* 11h */
|
||||
WIFI_DISCONNECT_REASON_IE_INVALID = 13, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_MIC_FAILURE = 14, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_GROUP_KEY_UPDATE_TIMEOUT = 16, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_IE_IN_4WAY_DIFFERS = 17, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_GROUP_CIPHER_INVALID = 18, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_PAIRWISE_CIPHER_INVALID = 19, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_AKMP_INVALID = 20, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_UNSUPP_RSN_IE_VERSION = 21, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_INVALID_RSN_IE_CAP = 22, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_802_1X_AUTH_FAILED = 23, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_CIPHER_SUITE_REJECTED = 24, /* 11i */
|
||||
|
||||
WIFI_DISCONNECT_REASON_BEACON_TIMEOUT = 200,
|
||||
WIFI_DISCONNECT_REASON_NO_AP_FOUND = 201,
|
||||
WIFI_DISCONNECT_REASON_AUTH_FAIL = 202,
|
||||
WIFI_DISCONNECT_REASON_ASSOC_FAIL = 203,
|
||||
WIFI_DISCONNECT_REASON_HANDSHAKE_TIMEOUT = 204
|
||||
};
|
||||
|
||||
void WiFiEvent(system_event_id_t event,
|
||||
system_event_info_t info);
|
||||
#endif // ifdef ESP32
|
||||
|
||||
#ifdef ESP8266
|
||||
# include <ESP8266WiFiGeneric.h>
|
||||
# include <ESP8266WiFiType.h>
|
||||
class IPAddress;
|
||||
|
||||
extern WiFiEventHandler stationConnectedHandler;
|
||||
extern WiFiEventHandler stationDisconnectedHandler;
|
||||
extern WiFiEventHandler stationGotIpHandler;
|
||||
extern WiFiEventHandler stationModeDHCPTimeoutHandler;
|
||||
extern WiFiEventHandler APModeStationConnectedHandler;
|
||||
extern WiFiEventHandler APModeStationDisconnectedHandler;
|
||||
#endif // ifdef ESP8266
|
||||
|
||||
|
||||
// WiFi related data
|
||||
extern bool wifiSetup;
|
||||
extern bool wifiSetupConnect;
|
||||
extern uint8_t lastBSSID[6];
|
||||
extern uint8_t wifiStatus;
|
||||
extern unsigned long last_wifi_connect_attempt_moment;
|
||||
extern unsigned int wifi_connect_attempt;
|
||||
extern int wifi_reconnects; // First connection attempt is not a reconnect.
|
||||
extern uint8_t lastWiFiSettings;
|
||||
extern String last_ssid;
|
||||
extern bool bssid_changed;
|
||||
extern bool channel_changed;
|
||||
extern uint8_t last_channel;
|
||||
extern WiFiDisconnectReason lastDisconnectReason;
|
||||
extern unsigned long lastConnectMoment;
|
||||
extern unsigned long lastDisconnectMoment;
|
||||
extern unsigned long lastGetIPmoment;
|
||||
extern unsigned long lastGetScanMoment;
|
||||
extern unsigned long lastConnectedDuration;
|
||||
extern bool intent_to_reboot;
|
||||
extern uint8_t lastMacConnectedAPmode[6];
|
||||
extern uint8_t lastMacDisconnectedAPmode[6];
|
||||
|
||||
// uint32_t scan_done_status = 0;
|
||||
extern uint8_t scan_done_number;
|
||||
|
||||
// uint8_t scan_done_scan_id = 0;
|
||||
|
||||
// Semaphore like bools for processing data gathered from WiFi events.
|
||||
extern volatile bool processedConnect;
|
||||
extern volatile bool processedDisconnect;
|
||||
extern volatile bool processedGotIP;
|
||||
extern volatile bool processedDHCPTimeout;
|
||||
extern volatile bool processedConnectAPmode;
|
||||
extern volatile bool processedDisconnectAPmode;
|
||||
extern volatile bool processedScanDone;
|
||||
extern bool wifiConnectAttemptNeeded;
|
||||
extern bool wifiConnectInProgress;
|
||||
|
||||
#endif // GLOBALS_ESPEASYWIFIEVENT_H
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "src/Globals/GlobalMapPortStatus.h"
|
||||
|
||||
MapPortStatus globalMapPortStatus;
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef GLOBALS_GLOBAL_MAP_PORT_STATUS_H
|
||||
#define GLOBALS_GLOBAL_MAP_PORT_STATUS_H
|
||||
|
||||
#include "src/DataStructs/PortStatusStruct.h"
|
||||
|
||||
extern MapPortStatus globalMapPortStatus;
|
||||
|
||||
|
||||
#endif // GLOBALS_GLOBAL_MAP_PORT_STATUS_H
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
LogStruct Logging;
|
||||
|
||||
uint8_t highest_active_log_level = 0;
|
||||
bool log_to_serial_disabled = false;
|
||||
|
||||
uint8_t highest_active_log_level(0);
|
||||
bool log_to_serial_disabled(false);
|
||||
std::deque<char> serialWriteBuffer;
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <deque>
|
||||
|
||||
extern uint8_t highest_active_log_level;
|
||||
extern bool log_to_serial_disabled;
|
||||
@@ -10,4 +11,9 @@ extern bool log_to_serial_disabled;
|
||||
struct LogStruct;
|
||||
extern LogStruct Logging;
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Buffer for outputting logs via serial port.
|
||||
\*********************************************************************************************/
|
||||
extern std::deque<char> serialWriteBuffer;
|
||||
|
||||
#endif // GLOBALS_LOGGING_H
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "../Globals/MQTT.h"
|
||||
|
||||
#ifdef USES_MQTT
|
||||
|
||||
// MQTT client
|
||||
WiFiClient mqtt;
|
||||
PubSubClient MQTTclient(mqtt);
|
||||
bool MQTTclient_should_reconnect = true;
|
||||
bool MQTTclient_connected = false;
|
||||
int mqtt_reconnect_count = 0;
|
||||
#endif // USES_MQTT
|
||||
|
||||
#ifdef USES_P037
|
||||
|
||||
// mqtt import status
|
||||
bool P037_MQTTImport_connected = false;
|
||||
#endif // ifdef USES_P037
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef GLOBALS_MQTT_H
|
||||
#define GLOBALS_MQTT_H
|
||||
|
||||
#include "define_plugin_sets.h"
|
||||
|
||||
|
||||
#ifdef USES_MQTT
|
||||
|
||||
# include <WiFiClient.h>
|
||||
# include <PubSubClient.h>
|
||||
|
||||
// MQTT client
|
||||
extern WiFiClient mqtt;
|
||||
extern PubSubClient MQTTclient;
|
||||
extern bool MQTTclient_should_reconnect;
|
||||
extern bool MQTTclient_connected;
|
||||
extern int mqtt_reconnect_count;
|
||||
#endif // USES_MQTT
|
||||
|
||||
#ifdef USES_P037
|
||||
|
||||
// mqtt import status
|
||||
extern bool P037_MQTTImport_connected;
|
||||
#endif // ifdef USES_P037
|
||||
|
||||
|
||||
#endif // GLOBALS_MQTT_H
|
||||
+18
-26
@@ -1,32 +1,8 @@
|
||||
#include "Plugins.h"
|
||||
#include "src/DataStructs/ESPEasy_EventStruct.h"
|
||||
#include "ESPEasy_plugindefs.h"
|
||||
#include "src/Globals/Settings.h"
|
||||
|
||||
int getPluginId_from_TaskIndex(byte taskIndex) {
|
||||
if (taskIndex >= Task_id_to_Plugin_id.size())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return Task_id_to_Plugin_id[taskIndex];
|
||||
}
|
||||
|
||||
/*
|
||||
// TODO TD-er: Move from _Plugin.ino as soon as Settings is global defined.
|
||||
int getPluginId(byte taskId) {
|
||||
if (taskId < TASKS_MAX) {
|
||||
int retry = 1;
|
||||
while (retry >= 0) {
|
||||
int plugin = Task_id_to_Plugin_id[taskId];
|
||||
if (plugin >= 0 && plugin < PLUGIN_MAX) {
|
||||
if (Plugin_id[plugin] == Settings.TaskDeviceNumber[taskId])
|
||||
return plugin;
|
||||
}
|
||||
updateTaskPluginCache();
|
||||
--retry;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void updateTaskPluginCache() {
|
||||
++countFindPluginId; // Used for statistics.
|
||||
@@ -42,7 +18,23 @@ void updateTaskPluginCache() {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
int getPluginId_from_TaskIndex(byte taskIndex) {
|
||||
if (taskIndex < TASKS_MAX) {
|
||||
int retry = 1;
|
||||
while (retry >= 0) {
|
||||
int plugin = Task_id_to_Plugin_id[taskIndex];
|
||||
if (plugin >= 0 && plugin < PLUGIN_MAX) {
|
||||
if (Plugin_id[plugin] == Settings.TaskDeviceNumber[taskIndex])
|
||||
return plugin;
|
||||
}
|
||||
updateTaskPluginCache();
|
||||
--retry;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "src/DataStructs/ESPEasyLimits.h"
|
||||
|
||||
|
||||
//int getPluginId(byte taskId);
|
||||
int getPluginId_from_TaskIndex(byte taskIndex);
|
||||
|
||||
String getPluginNameFromDeviceIndex(byte deviceIndex);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "../Globals/Services.h"
|
||||
|
||||
#ifdef FEATURE_ARDUINO_OTA
|
||||
bool ArduinoOTAtriggered=false;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ESP8266
|
||||
ESP8266WebServer WebServer(80);
|
||||
ESP8266HTTPUpdateServer httpUpdater(true);
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifdef ESP32
|
||||
WebServer WebServer(80);
|
||||
#endif
|
||||
*/
|
||||
@@ -0,0 +1,43 @@
|
||||
#ifndef GLOBALS_SERVICES_H
|
||||
#define GLOBALS_SERVICES_H
|
||||
|
||||
#include "ESPEasy_common.h"
|
||||
|
||||
#ifdef FEATURE_ARDUINO_OTA
|
||||
#include <ArduinoOTA.h>
|
||||
#ifdef ESP8266
|
||||
#include <ESP8266mDNS.h>
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
#include <ESPmDNS.h>
|
||||
#endif
|
||||
|
||||
extern bool ArduinoOTAtriggered;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ESP8266
|
||||
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <ESP8266HTTPUpdateServer.h>
|
||||
|
||||
extern ESP8266WebServer WebServer;
|
||||
extern ESP8266HTTPUpdateServer httpUpdater;
|
||||
|
||||
#endif
|
||||
|
||||
// FIXME TD-er: For now declared in ESPEasy.ino
|
||||
/*
|
||||
#ifdef ESP32
|
||||
|
||||
#include <WiFi.h>
|
||||
#include <WebServer.h>
|
||||
|
||||
extern WebServer WebServer;
|
||||
|
||||
#endif
|
||||
*/
|
||||
|
||||
|
||||
#endif // GLOBALS_SERVICES_H
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "../Globals/Statistics.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
uint32_t lowestRAM = 0;
|
||||
String lowestRAMfunction;
|
||||
uint32_t lowestFreeStack = 0;
|
||||
String lowestFreeStackfunction;
|
||||
|
||||
uint8_t lastBootCause = BOOT_CAUSE_MANUAL_REBOOT;
|
||||
unsigned long lastMixedSchedulerId_beforereboot = 0;
|
||||
|
||||
unsigned long idle_msec_per_sec = 0;
|
||||
unsigned long elapsed10ps = 0;
|
||||
unsigned long elapsed10psU = 0;
|
||||
unsigned long elapsed50ps = 0;
|
||||
unsigned long loopCounter = 0;
|
||||
unsigned long loopCounterLast = 0;
|
||||
unsigned long loopCounterMax = 1;
|
||||
unsigned long lastLoopStart = 0;
|
||||
unsigned long shortestLoop = 10000000;
|
||||
unsigned long longestLoop = 0;
|
||||
unsigned long loopCounter_full = 1;
|
||||
float loop_usec_duration_total = 0.0;
|
||||
|
||||
|
||||
unsigned long dailyResetCounter = 0;
|
||||
volatile unsigned long sw_watchdog_callback_count = 0;
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef GLOBALS_STATISTICS_H
|
||||
#define GLOBALS_STATISTICS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
class String;
|
||||
|
||||
#define BOOT_CAUSE_MANUAL_REBOOT 0
|
||||
#define BOOT_CAUSE_COLD_BOOT 1
|
||||
#define BOOT_CAUSE_DEEP_SLEEP 2
|
||||
#define BOOT_CAUSE_EXT_WD 10
|
||||
|
||||
extern uint32_t lowestRAM;
|
||||
extern String lowestRAMfunction;
|
||||
extern uint32_t lowestFreeStack;
|
||||
extern String lowestFreeStackfunction;
|
||||
|
||||
extern uint8_t lastBootCause;
|
||||
extern unsigned long lastMixedSchedulerId_beforereboot;
|
||||
|
||||
extern unsigned long loopCounter;
|
||||
extern unsigned long loopCounterLast;
|
||||
extern unsigned long loopCounterMax;
|
||||
extern unsigned long lastLoopStart;
|
||||
extern unsigned long shortestLoop;
|
||||
extern unsigned long longestLoop;
|
||||
extern unsigned long loopCounter_full;
|
||||
extern float loop_usec_duration_total;
|
||||
|
||||
extern unsigned long dailyResetCounter;
|
||||
extern volatile unsigned long sw_watchdog_callback_count;
|
||||
|
||||
|
||||
#endif // GLOBALS_STATISTICS_H
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user