Skip to content

Commit 872edde

Browse files
committed
Removed mutex
1 parent dec8fe8 commit 872edde

File tree

4 files changed

+9
-26
lines changed

4 files changed

+9
-26
lines changed

examples/NonBlockingCaptivePortal/NonBlockingCaptivePortal.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ void setup() {
5959
}
6060
});
6161

62-
espConnect.setConnectTimeout(20); // 20 seconds
63-
espConnect.setCaptivePortalTimeout(40); // 30 seconds
62+
espConnect.setConnectTimeout(20);
63+
espConnect.setCaptivePortalTimeout(40);
6464
espConnect.setAutoRestart(true);
6565
espConnect.setBlocking(false);
6666

platformio.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ build_flags =
2222
; -D ESPCONNECT_NO_STD_STRING
2323
; -D ESPCONNECT_NO_LOGGING
2424
; -D ESPCONNECT_ETH_SUPPORT
25-
; -D ESPCONNECT_NO_MUTEX
2625
lib_compat_mode = strict
2726
lib_ldf_mode = chain
2827
lib_deps =

src/MycilaESPConnect.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,6 @@ void Mycila::ESPConnect::loop() {
365365
if (_dnsServer != nullptr)
366366
_dnsServer->processNextRequest();
367367

368-
#ifndef ESPCONNECT_NO_MUTEX
369-
std::lock_guard<std::mutex> lock(_mutex);
370-
#endif
371-
372368
// first check if we have to enter AP mode
373369
if (_state == Mycila::ESPConnect::State::NETWORK_ENABLED && _config.apMode) {
374370
_startAP();
@@ -849,10 +845,6 @@ void Mycila::ESPConnect::_onWiFiEvent(WiFiEvent_t event) {
849845
if (_state == Mycila::ESPConnect::State::NETWORK_DISABLED)
850846
return;
851847

852-
#ifndef ESPCONNECT_NO_MUTEX
853-
std::lock_guard<std::mutex> lock(_mutex);
854-
#endif
855-
856848
switch (event) {
857849
#ifdef ESPCONNECT_ETH_SUPPORT
858850
case ARDUINO_EVENT_ETH_START:

src/MycilaESPConnect.h

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <DNSServer.h>
88

99
#ifdef ESP8266
10-
#define ESPCONNECT_NO_MUTEX 1
1110
#include <ESP8266WiFi.h>
1211
#else
1312
#include <WiFi.h>
@@ -27,10 +26,6 @@
2726
#define ESPCONNECT_STRING std::string
2827
#endif
2928

30-
#ifndef ESPCONNECT_NO_MUTEX
31-
#include <mutex>
32-
#endif
33-
3429
#define ESPCONNECT_VERSION "10.2.1"
3530
#define ESPCONNECT_VERSION_MAJOR 10
3631
#define ESPCONNECT_VERSION_MINOR 2
@@ -218,6 +213,11 @@ namespace Mycila {
218213
// Whether ESPConnect will restart the ESP if the captive portal times out or once it has completed (old behaviour)
219214
void setAutoRestart(bool autoRestart) { _autoRestart = autoRestart; }
220215

216+
// Get the delay before a restart occurs
217+
uint32_t getRestartDelay() const { return _restartDelay; }
218+
// Set the delay before a restart occurs in ms
219+
void setRestartDelay(uint32_t delay) { _restartDelay = delay; }
220+
221221
// load configuration from NVS
222222
void loadConfiguration() { loadConfiguration(_config); }
223223
// load configuration from NVS
@@ -231,11 +231,6 @@ namespace Mycila {
231231
// when using auto-load and save of configuration, this method can clear saved states.
232232
void clearConfiguration();
233233

234-
// Get the delay before a restart occurs
235-
uint32_t getRestartDelay() const { return _restartDelay; }
236-
// Set the delay before a restart occurs in ms
237-
void setRestartDelay(uint32_t delay) { _restartDelay = delay; }
238-
239234
#ifndef ESPCONNECT_NO_CAPTIVE_PORTAL
240235
void toJson(const JsonObject& root) const;
241236
#endif
@@ -259,6 +254,8 @@ namespace Mycila {
259254
bool _blocking = true;
260255
bool _autoRestart = true;
261256
bool _autoSave = false;
257+
uint32_t _restartRequestTime = 0;
258+
uint32_t _restartDelay = 1000;
262259
#ifdef ESP8266
263260
WiFiEventHandler onStationModeGotIP;
264261
WiFiEventHandler onStationModeDHCPTimeout;
@@ -283,10 +280,5 @@ namespace Mycila {
283280

284281
private:
285282
static int8_t _wifiSignalQuality(int32_t rssi);
286-
uint32_t _restartRequestTime = 0;
287-
uint32_t _restartDelay = 1000;
288-
#ifndef ESPCONNECT_NO_MUTEX
289-
std::mutex _mutex;
290-
#endif
291283
};
292284
} // namespace Mycila

0 commit comments

Comments
 (0)