Skip to content

Commit 1f397a7

Browse files
authored
Merge pull request #83 from espressif/master
Fixes softAPConfig() return
2 parents 62a732a + 7be846c commit 1f397a7

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

docs/source/installing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Installing using Boards Manager
1616
This is the preferred and easiest way to install Arduino-ESP32.
1717

1818
.. note::
19-
Currently, the support for new chips (ESP32-S2 and ESP32-C3) is in the development release. Consider installing the development release if you need to test the new supported SoC in beta.
19+
For overview of SoC's support, take a look on `Supported Soc's table <https://docs.espressif.com/projects/arduino-esp32/en/latest/getting_started.html#supported-soc-s>`_ where you can find if the particular chip is under stable or development release.
2020

2121
- Stable release link::
2222

libraries/HTTPClient/src/HTTPClient.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,10 @@ void HTTPClient::clearAllCookies()
15431543

15441544
void HTTPClient::setCookie(String date, String headerValue)
15451545
{
1546+
if (!_cookieJar)
1547+
{
1548+
return;
1549+
}
15461550
#define HTTP_TIME_PATTERN "%a, %d %b %Y %H:%M:%S"
15471551

15481552
Cookie cookie;
@@ -1574,7 +1578,7 @@ void HTTPClient::setCookie(String date, String headerValue)
15741578
value = headerValue.substring(pos1, pos2);
15751579
else
15761580
value = headerValue.substring(pos1);
1577-
1581+
15781582
strptime(value.c_str(), HTTP_TIME_PATTERN, &tm);
15791583
cookie.expires.date = mktime(&tm);
15801584
cookie.expires.valid = true;
@@ -1589,7 +1593,7 @@ void HTTPClient::setCookie(String date, String headerValue)
15891593
value = headerValue.substring(pos1, pos2);
15901594
else
15911595
value = headerValue.substring(pos1);
1592-
1596+
15931597
cookie.max_age.duration = value.toInt();
15941598
cookie.max_age.valid = true;
15951599
}
@@ -1639,10 +1643,10 @@ void HTTPClient::setCookie(String date, String headerValue)
16391643
// overwrite or delete cookie in/from cookie jar
16401644
time_t now_local = time(NULL);
16411645
time_t now_gmt = mktime(gmtime(&now_local));
1642-
1646+
16431647
bool found = false;
16441648

1645-
for (auto c = _cookieJar->begin(); c != _cookieJar->end(); ++c) {
1649+
for (auto c = _cookieJar->begin(); c != _cookieJar->end(); ++c) {
16461650
if (c->domain == cookie.domain && c->name == cookie.name) {
16471651
// when evaluating, max-age takes precedence over expires if both are defined
16481652
if ((cookie.max_age.valid && ((cookie.date + cookie.max_age.duration) < now_gmt)) || cookie.max_age.duration <= 0
@@ -1670,6 +1674,10 @@ bool HTTPClient::generateCookieString(String *cookieString)
16701674
*cookieString = "";
16711675
bool found = false;
16721676

1677+
if (!_cookieJar)
1678+
{
1679+
return false;
1680+
}
16731681
for (auto c = _cookieJar->begin(); c != _cookieJar->end(); ++c) {
16741682
if ((c->max_age.valid && ((c->date + c->max_age.duration) < now_gmt)) || (!c->max_age.valid && c->expires.valid && c->expires.date < now_gmt)) {
16751683
_cookieJar->erase(c);
@@ -1682,5 +1690,6 @@ bool HTTPClient::generateCookieString(String *cookieString)
16821690
found = true;
16831691
}
16841692
}
1693+
16851694
return found;
16861695
}

libraries/WiFi/src/WiFiAP.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,23 @@ bool WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress
205205
}
206206

207207
err = set_esp_interface_ip(ESP_IF_WIFI_AP, local_ip, gateway, subnet);
208-
return err == ESP_OK;
208+
209+
// testing effectiveness of the operation beyond internal DHCP Client process
210+
esp_netif_ip_info_t ip;
211+
if(esp_netif_get_ip_info(get_esp_interface_netif(ESP_IF_WIFI_AP), &ip) != ESP_OK){
212+
log_e("Netif Get IP Failed!");
213+
return false;
214+
}
215+
bool ip_ok = IPAddress(ip.ip.addr) == local_ip;
216+
bool gw_ok = IPAddress(ip.gw.addr) == gateway;
217+
bool mk_ok = IPAddress(ip.netmask.addr) == subnet;
218+
219+
if (ip_ok && gw_ok && mk_ok) {
220+
return true;
221+
} else {
222+
log_e("Failed setting: %s %s %s", ip_ok ? "" : "Static IP", gw_ok ? "" : "- Gateway", mk_ok ? "" : "- Netmask");
223+
return false;
224+
}
209225
}
210226

211227

0 commit comments

Comments
 (0)