From 02a065d62322cbef549358dd60eaec2e2be2ca93 Mon Sep 17 00:00:00 2001 From: TD-er Date: Sat, 31 Mar 2018 00:22:12 +0200 Subject: [PATCH] [Build ESP32] Fix for build issues between ESP32 and ESP8266 There is a problem with the PlatformIO builder since the last update of @mvdbro It's an issue with the parsing of `#ifdef ESP32`. It is very well explained here: [platformio/platformio-core#801 (comment)](https://github.com/platformio/platformio-core/issues/801#issuecomment-252447178) In short, the event handling functions for the wifi have been moved to a separate .h file, since those files will be parsed properly by the Library Dependency Finder (LDF) in PlatformIO 3.x --- lib/ESPEasySoftwareSerial/README.md | 4 +- lib/ESPEasySoftwareSerial/library.json | 2 +- platformio.ini | 57 +++++++++++++++++++-- src/ESPEasy-Globals.h | 16 ++++-- src/ESPEasy.ino | 2 +- src/ESPEasyTimeTypes.h | 1 + src/ESPEasyWiFiEvent.h | 68 ++++++++++++++++++++++++++ src/{Wifi.ino => ESPEasyWifi.ino} | 68 -------------------------- src/_N002_Buzzer.ino | 3 ++ src/define_plugin_sets.h | 15 ++++++ 10 files changed, 155 insertions(+), 81 deletions(-) create mode 100644 src/ESPEasyWiFiEvent.h rename src/{Wifi.ino => ESPEasyWifi.ino} (87%) diff --git a/lib/ESPEasySoftwareSerial/README.md b/lib/ESPEasySoftwareSerial/README.md index 23897a081..05de560b3 100644 --- a/lib/ESPEasySoftwareSerial/README.md +++ b/lib/ESPEasySoftwareSerial/README.md @@ -1,4 +1,4 @@ -# EspESPeasySoftwareSerial +# ESPeasySoftwareSerial Implementation of the Arduino software serial library for the ESP8266 @@ -7,5 +7,3 @@ Speed up to 115200 baud is supported. The constructor also has an optional input Please note that due to the fact that the ESP always have other activities ongoing, there will be some inexactness in interrupt timings. This may lead to bit errors when having heavy data traffic in high baud rates. - - diff --git a/lib/ESPEasySoftwareSerial/library.json b/lib/ESPEasySoftwareSerial/library.json index 82b826f0a..daa68ff76 100644 --- a/lib/ESPEasySoftwareSerial/library.json +++ b/lib/ESPEasySoftwareSerial/library.json @@ -1,5 +1,5 @@ { - "name": "EspESPeasySoftwareSerial", + "name": "ESPeasySoftwareSerial", "version": "3.3.1", "keywords": [ "serial", "io", "softwareserial" diff --git a/platformio.ini b/platformio.ini index 59751fe62..7b9a26395 100644 --- a/platformio.ini +++ b/platformio.ini @@ -39,10 +39,18 @@ platform = espressif8266@1.5.0 [core_2_4_0] platform = espressif8266@1.6.0 +[core_esp32] +#platform = espressif32@0.12.0 +platform = https://github.com/platformio/platform-espressif32.git#feature/stage +build_flags = -D BUILD_GIT='"${env.TRAVIS_TAG}"' +lib_ignore = ESPeasySoftwareSerial, EspESPeasySoftwareSerial, AS_BH1750, ESP8266WiFi, ESP8266Ping, ESP8266WebServer, ESP8266HTTPUpdateServer, ESP8266mDNS, IRremoteESP8266, ESPEasy_ESP8266Ping, SerialSensors +lib_deps = ESP32WebServer + [common] build_flags = -D BUILD_GIT='"${env.TRAVIS_TAG}"' ; ${compiler_warnings.build_flags} lib_deps = "" +lib_ignore = ESP32_ping, ESP32WebServer lib_ldf_mode = chain upload_speed = 460800 framework = arduino @@ -60,7 +68,7 @@ board_flash_mode = ${esp8266_1M.board_flash_mode} build_flags = ${esp8266_1M.build_flags} -DESP8285 [Sonoff] -board = esp01_1m +board = esp01_1m board_flash_mode = ${esp8266_1M.board_flash_mode} build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.1m128.ld @@ -73,8 +81,20 @@ build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.2m.ld board_flash_mode = dio build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.4m1m.ld - - +### ESP32 pre-alpha test build ########################################################### +# Very limited build for ESP32, to start testing regular building for ESP32. # +# Will probably not work, not tested and guaranteed to take a few hours time of some # +# still trying to build the version without reading this warning. # +########################################################################################## +[env:esp32dev] +platform = ${core_esp32.platform} +board = esp32dev +build_flags = ${core_esp32.build_flags} -DPLUGIN_SET_GENERIC_ESP32 +lib_deps = ${core_esp32.lib_deps} +lib_ignore = ${core_esp32.lib_ignore} +lib_ldf_mode = ${common.lib_ldf_mode} +framework = ${common.framework} +upload_speed = ${common.upload_speed} ### NORMAL (STABLE) ###################################################################### # normal version with stable plugins # @@ -84,6 +104,7 @@ build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.4m1m.ld [env:normal_ESP8266_1024] platform = ${common.platform} lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} lib_ldf_mode = ${common.lib_ldf_mode} framework = ${common.framework} upload_speed = ${common.upload_speed} @@ -95,6 +116,7 @@ build_flags = ${esp8266_1M.build_flags} [env:normal_ESP8285_1024] platform = ${common.platform} lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} lib_ldf_mode = ${common.lib_ldf_mode} framework = ${common.framework} upload_speed = ${common.upload_speed} @@ -106,6 +128,7 @@ build_flags = ${esp8285_1M.build_flags} [env:normal_WROOM02_2048] platform = ${common.platform} lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} lib_ldf_mode = ${common.lib_ldf_mode} framework = ${common.framework} upload_speed = ${common.upload_speed} @@ -117,6 +140,7 @@ build_flags = ${espWroom2M.build_flags} [env:normal_ESP8266_4096] platform = ${common.platform} lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} lib_ldf_mode = ${common.lib_ldf_mode} framework = ${common.framework} upload_speed = ${common.upload_speed} @@ -134,6 +158,7 @@ build_flags = ${esp8266_4M.build_flags} [env:test_ESP8266_1024] platform = ${common.platform} lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} lib_ldf_mode = ${common.lib_ldf_mode} framework = ${common.framework} upload_speed = ${common.upload_speed} @@ -145,6 +170,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_TESTING [env:test_ESP8285_1024] platform = ${common.platform} lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} lib_ldf_mode = ${common.lib_ldf_mode} framework = ${common.framework} upload_speed = ${common.upload_speed} @@ -156,6 +182,7 @@ build_flags = ${esp8285_1M.build_flags} -D PLUGIN_BUILD_TESTING [env:test_WROOM02_2048] platform = ${common.platform} lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} lib_ldf_mode = ${common.lib_ldf_mode} framework = ${common.framework} upload_speed = ${common.upload_speed} @@ -167,6 +194,7 @@ build_flags = ${espWroom2M.build_flags} -D PLUGIN_BUILD_TESTING [env:test_ESP8266_4096] platform = ${common.platform} lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} lib_ldf_mode = ${common.lib_ldf_mode} framework = ${common.framework} board = ${common.board} @@ -178,6 +206,7 @@ build_flags = ${esp8266_4M.build_flags} -D PLUGIN_BUILD_TESTING [env:test_ESP8266_4096_VCC] platform = ${common.platform} lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} lib_ldf_mode = ${common.lib_ldf_mode} framework = ${common.framework} board = ${common.board} @@ -195,6 +224,7 @@ build_flags = ${esp8266_4M.build_flags} -D PLUGIN_BUILD_TESTING -D FEATURE_ [env:dev_ESP8266_1024] platform = ${common.platform} lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} lib_ldf_mode = ${common.lib_ldf_mode} framework = ${common.framework} upload_speed = ${common.upload_speed} @@ -206,6 +236,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV [env:dev_ESP8285_1024] platform = ${common.platform} lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} lib_ldf_mode = ${common.lib_ldf_mode} framework = ${common.framework} upload_speed = ${common.upload_speed} @@ -217,6 +248,7 @@ build_flags = ${esp8285_1M.build_flags} -D PLUGIN_BUILD_DEV [env:dev_WROOM02_2048] platform = ${common.platform} lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} lib_ldf_mode = ${common.lib_ldf_mode} framework = ${common.framework} upload_speed = ${common.upload_speed} @@ -228,6 +260,7 @@ build_flags = ${espWroom2M.build_flags} -D PLUGIN_BUILD_DEV [env:dev_ESP8266_4096] platform = ${common.platform} lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} lib_ldf_mode = ${common.lib_ldf_mode} framework = ${common.framework} board = ${common.board} @@ -245,6 +278,7 @@ build_flags = ${esp8266_4M.build_flags} -D PLUGIN_BUILD_DEV [env:dev_ESP8266PUYA_1024] platform = ${common.platform} lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} lib_ldf_mode = ${common.lib_ldf_mode} framework = ${common.framework} board = ${common.board} @@ -256,6 +290,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ [env:dev_ESP8266PUYA_1024_VCC] platform = ${common.platform} lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} lib_ldf_mode = ${common.lib_ldf_mode} framework = ${common.framework} board = ${common.board} @@ -278,6 +313,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ #framework = ${common.framework} #platform = ${common.platform} #lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} #lib_ldf_mode = ${common.lib_ldf_mode} #board_flash_mode = ${Sonoff.board_flash_mode} #board = ${Sonoff.board} @@ -289,6 +325,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ #framework = ${common.framework} #platform = ${common.platform} #lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} #lib_ldf_mode = ${common.lib_ldf_mode} #board_flash_mode = ${Sonoff.board_flash_mode} #board = ${Sonoff.board} @@ -300,6 +337,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ #framework = ${common.framework} #platform = ${common.platform} #lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} #lib_ldf_mode = ${common.lib_ldf_mode} #board_flash_mode = ${Sonoff.board_flash_mode} #board = ${Sonoff.board} @@ -311,6 +349,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ #framework = ${common.framework} #platform = ${common.platform} #lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} #lib_ldf_mode = ${common.lib_ldf_mode} #board_flash_mode = ${Sonoff.board_flash_mode} #board = ${Sonoff.board} @@ -322,6 +361,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ #framework = ${common.framework} #platform = ${common.platform} #lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} #lib_ldf_mode = ${common.lib_ldf_mode} #board_flash_mode = ${Sonoff.board_flash_mode} #board = ${Sonoff.board} @@ -333,6 +373,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ #framework = ${common.framework} #platform = ${common.platform} #lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} #lib_ldf_mode = ${common.lib_ldf_mode} #board_flash_mode = ${Sonoff.board_flash_mode} #board = ${Sonoff.board} @@ -344,6 +385,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ #framework = ${common.framework} #platform = ${common.platform} #lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} #lib_ldf_mode = ${common.lib_ldf_mode} #board_flash_mode = ${Sonoff.board_flash_mode} #board = ${Sonoff.board} @@ -359,6 +401,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ #framework = ${common.framework} #platform = ${common.platform} #lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} #lib_ldf_mode = ${common.lib_ldf_mode} #board_flash_mode = ${esp8266_1M.board_flash_mode} #board = esp01_1m @@ -371,6 +414,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ #framework = ${common.framework} #platform = ${common.platform} #lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} #lib_ldf_mode = ${common.lib_ldf_mode} #board_flash_mode = ${esp8266_1M.board_flash_mode} #board = esp01_1m @@ -382,6 +426,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ #framework = ${common.framework} #platform = ${common.platform} #lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} #lib_ldf_mode = ${common.lib_ldf_mode} #board_flash_mode = ${esp8266_1M.board_flash_mode} #board = esp01_1m @@ -400,6 +445,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ #framework = ${common.framework} #platform = ${common.platform} #lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} #lib_ldf_mode = ${common.lib_ldf_mode} #board_flash_mode = ${esp8266_1M.board_flash_mode} #board = esp01_1m @@ -412,6 +458,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ #framework = ${common.framework} #platform = ${common.platform} #lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} #lib_ldf_mode = ${common.lib_ldf_mode} #board_flash_mode = ${esp8266_1M.board_flash_mode} #board = esp01_1m @@ -426,6 +473,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ #framework = ${common.framework} #platform = ${common.platform} #lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} #lib_ldf_mode = ${common.lib_ldf_mode} #board_flash_mode = ${esp8266_1M.board_flash_mode} #board = esp01_1m @@ -437,6 +485,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ #framework = ${common.framework} #platform = ${common.platform} #lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} #lib_ldf_mode = ${common.lib_ldf_mode} #board_flash_mode = ${esp8266_1M.board_flash_mode} #board = esp01_1m @@ -448,6 +497,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ #framework = ${common.framework} #platform = ${common.platform} #lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} #lib_ldf_mode = ${common.lib_ldf_mode} #board_flash_mode = ${esp8266_1M.board_flash_mode} #board = esp01_1m @@ -459,6 +509,7 @@ build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_ #framework = ${common.framework} #platform = ${common.platform} #lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} #lib_ldf_mode = ${common.lib_ldf_mode} #board_flash_mode = ${esp8266_1M.board_flash_mode} #board = esp01_1m diff --git a/src/ESPEasy-Globals.h b/src/ESPEasy-Globals.h index 9e3ca87c3..fef54c87f 100644 --- a/src/ESPEasy-Globals.h +++ b/src/ESPEasy-Globals.h @@ -439,8 +439,8 @@ ADC_MODE(ADC_VCC); #define ESPEASY_WIFI_GOT_IP 2 #define ESPEASY_WIFI_SERVICES_INITIALIZED 3 -#ifdef ESP32 -void WiFiEvent(WiFiEvent_t event); +#if defined(ESP32) +void WiFiEvent(system_event_id_t event, system_event_info_t info); #else WiFiEventHandler stationConnectedHandler; WiFiEventHandler stationDisconnectedHandler; @@ -1118,8 +1118,8 @@ String dummyString = ""; byte lastBootCause = BOOT_CAUSE_MANUAL_REBOOT; -#ifdef ESP32 -enum WiFiDisconnectReason +#if defined(ESP32) +enum WiFiDisconnectReason { WIFI_DISCONNECT_REASON_UNSPECIFIED = 1, WIFI_DISCONNECT_REASON_AUTH_EXPIRE = 2, @@ -1149,7 +1149,7 @@ enum WiFiDisconnectReason 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, + WIFI_DISCONNECT_REASON_HANDSHAKE_TIMEOUT = 204 }; #endif @@ -1195,4 +1195,10 @@ bool firstLoop=true; boolean activeRuleSets[RULESETS_MAX]; + +// These wifi event functions must be in a .h-file because otherwise the preprocessor +// may not filter the ifdef checks properly. +// Also the functions use a lot of global defined variables, so include at the end of this file. +#include "ESPEasyWiFiEvent.h" + #endif /* ESPEASY_GLOBALS_H_ */ diff --git a/src/ESPEasy.ino b/src/ESPEasy.ino index 4e6a2a4cb..0dfbda6c4 100644 --- a/src/ESPEasy.ino +++ b/src/ESPEasy.ino @@ -111,7 +111,7 @@ void setup() initLog(); -#ifdef ESP32 +#if defined(ESP32) WiFi.onEvent((WiFiEventFullCb)WiFiEvent); #else // WiFi event handlers diff --git a/src/ESPEasyTimeTypes.h b/src/ESPEasyTimeTypes.h index 0f4ffadd3..c366854e0 100644 --- a/src/ESPEasyTimeTypes.h +++ b/src/ESPEasyTimeTypes.h @@ -64,6 +64,7 @@ void setTimeZone(const TimeChangeRule& dstStart, const TimeChangeRule& stdStart, uint32_t calcTimeChangeForRule(const TimeChangeRule& r, int yr); String getTimeString(char delimiter, bool show_seconds=true); String getTimeString_ampm(char delimiter, bool show_seconds=true); +long timeDiff(unsigned long prev, unsigned long next); #endif /* ESPEASY_TIMETYPES_H_ */ diff --git a/src/ESPEasyWiFiEvent.h b/src/ESPEasyWiFiEvent.h new file mode 100644 index 000000000..59aaa245c --- /dev/null +++ b/src/ESPEasyWiFiEvent.h @@ -0,0 +1,68 @@ +//******************************************************************************** +// 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(info.disconnected.reason); + wifiStatus = ESPEASY_WIFI_DISCONNECTED; + break; + case SYSTEM_EVENT_STA_GOT_IP: + lastGetIPmoment = millis(); + wifiStatus = ESPEASY_WIFI_GOT_IP; + processedGetIP = false; + break; + default: + break; + } +} +#else + +void onConnected(const WiFiEventStationModeConnected& event){ + lastConnectMoment = millis(); + processedConnect = false; + wifiStatus = ESPEASY_WIFI_CONNECTED; + 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); + processedDisconnect = false; + lastDisconnectReason = event.reason; + wifiStatus = ESPEASY_WIFI_DISCONNECTED; +} + +void onGotIP(const WiFiEventStationModeGotIP& event){ + lastGetIPmoment = millis(); + wifiStatus = ESPEASY_WIFI_GOT_IP; + processedGetIP = false; +} +#endif diff --git a/src/Wifi.ino b/src/ESPEasyWifi.ino similarity index 87% rename from src/Wifi.ino rename to src/ESPEasyWifi.ino index 6bcfb3f25..a7543d065 100644 --- a/src/Wifi.ino +++ b/src/ESPEasyWifi.ino @@ -1,72 +1,4 @@ -//******************************************************************************** -// 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(info.disconnected.reason); - wifiStatus = ESPEASY_WIFI_DISCONNECTED; - break; - case SYSTEM_EVENT_STA_GOT_IP: - lastGetIPmoment = millis(); - wifiStatus = ESPEASY_WIFI_GOT_IP; - processedGetIP = false; - break; - default: - break; - } -} - -#else - -void onConnected(const WiFiEventStationModeConnected& event){ - lastConnectMoment = millis(); - processedConnect = false; - wifiStatus = ESPEASY_WIFI_CONNECTED; - 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); - processedDisconnect = false; - lastDisconnectReason = event.reason; - wifiStatus = ESPEASY_WIFI_DISCONNECTED; -} - -void onGotIP(const WiFiEventStationModeGotIP& event){ - lastGetIPmoment = millis(); - wifiStatus = ESPEASY_WIFI_GOT_IP; - processedGetIP = false; -} -#endif //******************************************************************************** // Functions to process the data gathered from the events. diff --git a/src/_N002_Buzzer.ino b/src/_N002_Buzzer.ino index acbc4534d..0f4593fa4 100644 --- a/src/_N002_Buzzer.ino +++ b/src/_N002_Buzzer.ino @@ -46,7 +46,10 @@ boolean NPlugin_002(byte function, struct EventStruct *event, String& string) NotificationSettingsStruct NotificationSettings; LoadNotificationSettings(event->NotificationIndex, (byte*)&NotificationSettings, sizeof(NotificationSettings)); //this reserves IRAM and uninitialized RAM + #ifndef ESP32 + // Buzzer not compatible with ESP32 due to lack of tone command. tone(NotificationSettings.Pin1, 500, 500); + #endif success = true; } diff --git a/src/define_plugin_sets.h b/src/define_plugin_sets.h index 0048ed5c8..f49be4136 100644 --- a/src/define_plugin_sets.h +++ b/src/define_plugin_sets.h @@ -134,6 +134,21 @@ To create/register a plugin, you have to : #endif +// Generic ESP32 ----------------------------- +#ifdef PLUGIN_SET_GENERIC_ESP32 + #ifndef ESP32 + #define ESP32 + #endif + #ifdef ESP8266 + #undef ESP8266 + #endif + #define PLUGIN_SET_ONLY_SWITCH + #define USES_P036 // FrameOLED + // TODO : Add list of compatible plugins for ESP32 board. +#endif + + + // Generic ------------------------------------ #ifdef PLUGIN_SET_GENERIC_1M #define PLUGIN_SET_NONE