Skip to content

Commit e56d262

Browse files
authored
Merge branch 'espressif:master' into TwoWireInheritFromHardwareI2C
2 parents 3cf20e0 + 4766608 commit e56d262

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ You can use the [Arduino-ESP32 Online Documentation](https://docs.espressif.com/
3636

3737
---
3838

39+
**APIs compatibility with ESP8266 and Arduino-CORE (Arduino.cc) is explained [here](https://docs.espressif.com/projects/arduino-esp32/en/latest/libraries.html#apis).**
40+
41+
---
42+
3943
* [Getting Started](https://docs.espressif.com/projects/arduino-esp32/en/latest/getting_started.html)
4044
* [Installing (Windows, Linux and macOS)](https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html)
4145
* [Libraries](https://docs.espressif.com/projects/arduino-esp32/en/latest/libraries.html)

docs/en/libraries.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ APIs
7171

7272
The Arduino ESP32 offers some unique APIs, described in this section:
7373

74+
.. note::
75+
Please be advised that we cannot ensure continuous compatibility between the Arduino Core ESP32 APIs and ESP8266 APIs, as well as Arduino-Core APIs (Arduino.cc).
76+
While our aim is to maintain harmony, the addition of new features may result in occasional divergence. We strive to achieve the best possible integration but acknowledge
77+
that perfect compatibility might not always be feasible. Please refer to the documentation for any specific considerations.
78+
7479
.. toctree::
7580
:maxdepth: 1
7681
:glob:

libraries/WiFi/src/WiFiSTA.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ bool WiFiSTAClass::reconnect()
367367
* @param eraseap `true` to erase the AP configuration from the NVS memory.
368368
* @return `true` when successful.
369369
*/
370-
bool WiFiSTAClass::disconnect(bool wifioff, bool eraseap)
370+
bool WiFiSTAClass::disconnectAsync(bool wifioff, bool eraseap)
371371
{
372372
wifi_config_t conf;
373373
wifi_sta_config(&conf);
@@ -391,6 +391,31 @@ bool WiFiSTAClass::disconnect(bool wifioff, bool eraseap)
391391
return false;
392392
}
393393

394+
/**
395+
* Disconnect from the network.
396+
* @param wifioff `true` to turn the Wi-Fi radio off.
397+
* @param eraseap `true` to erase the AP configuration from the NVS memory.
398+
* @param timeoutLength timeout to wait for status change
399+
* @return `true` when successful.
400+
*/
401+
bool WiFiSTAClass::disconnect(bool wifioff, bool eraseap, unsigned long timeoutLength)
402+
{
403+
if (!disconnectAsync(wifioff, eraseap)) {
404+
return false;
405+
}
406+
if (!timeoutLength) {
407+
return true;
408+
}
409+
const unsigned long start = millis();
410+
while ((WiFiGenericClass::getStatusBits() & STA_CONNECTED_BIT) != 0) {
411+
if((millis() - start) >= timeoutLength){
412+
return false;
413+
}
414+
delay(2);
415+
}
416+
return true;
417+
}
418+
394419
/**
395420
* @brief Reset WiFi settings in NVS to default values.
396421
* @return true if erase succeeded

libraries/WiFi/src/WiFiSTA.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ class WiFiSTAClass
6161
bool bandwidth(wifi_bandwidth_t bandwidth);
6262

6363
bool reconnect();
64-
bool disconnect(bool wifioff = false, bool eraseap = false);
64+
bool disconnectAsync(bool wifioff = false, bool eraseap = false);
65+
bool disconnect(bool wifioff = false, bool eraseap = false, unsigned long timeoutLength = 100);
6566
bool eraseAP(void);
6667

6768
bool isConnected();

0 commit comments

Comments
 (0)