Skip to content

Commit d459e5b

Browse files
authored
Merge branch 'master' into pgmspace_to_libc
2 parents 5beb1a3 + 41de43a commit d459e5b

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

doc/esp8266wifi/generic-class.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ onEvent
1212
1313
void onEvent (WiFiEventCb cb, WiFiEvent_t event=WIFI_EVENT_ANY) __attribute__((deprecated))
1414
15-
To see how to use ``onEvent`` please check example sketch `WiFiClientEvents.ino <https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino>`__ available inside examples folder of the ESP8266WiFi library.
1615
1716
WiFiEventHandler
1817
~~~~~~~~~~~~~~~~
@@ -27,7 +26,14 @@ WiFiEventHandler
2726
WiFiEventHandler onSoftAPModeStationConnected (std::function< void(const WiFiEventSoftAPModeStationConnected &)>)
2827
WiFiEventHandler onSoftAPModeStationDisconnected (std::function< void(const WiFiEventSoftAPModeStationDisconnected &)>)
2928
30-
To see a sample application with ``WiFiEventHandler``, please check separate section with `examples :arrow\_right: <generic-examples.rst>`__ dedicated specifically to the Generic Class..
29+
It should be noted that when an WiFi interface goes down, all WiFiClients are stopped, and all WiFiServers stop serving. When the interface comes up, it is up to the user to reconnect the relevant WiFiClients and bring the WiFiServers back up.
30+
For the WiFi station interface, it is suggested to set a callback for onStationModeDisconnected() that shuts down the user app's WiFiClients and WiFiServers (resource cleanup), and another callback for onStationModeGotIP() that brings them back up.
31+
For the SoftAP interface, when the interface is brought up, any servers should be brought up as well.
32+
33+
A detailed explanation of ``WiFiEventHandler`` can be found in the section with `examples :arrow\_right: <generic-examples.rst>`__ dedicated specifically to the Generic Class..
34+
35+
Alternatively, check the example sketch `WiFiEvents.ino <https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/examples/WiFiEvents/WiFiEvents.ino>`__ available inside examples folder of the ESP8266WiFi library.
36+
3137

3238
persistent
3339
~~~~~~~~~~

libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,26 @@ ESP8266HTTPUpdateServer::ESP8266HTTPUpdateServer(bool serial_debug)
2020
{
2121
_serial_output = serial_debug;
2222
_server = NULL;
23-
_username = NULL;
24-
_password = NULL;
23+
_username = emptyString;
24+
_password = emptyString;
2525
_authenticated = false;
2626
}
2727

28-
void ESP8266HTTPUpdateServer::setup(ESP8266WebServer *server, const char * path, const char * username, const char * password)
28+
void ESP8266HTTPUpdateServer::setup(ESP8266WebServer *server, const String& path, const String& username, const String& password)
2929
{
3030
_server = server;
31-
_username = (char *)username;
32-
_password = (char *)password;
31+
_username = username;
32+
_password = password;
3333

3434
// handler for the /update form page
35-
_server->on(path, HTTP_GET, [&](){
36-
if(_username != NULL && _password != NULL && !_server->authenticate(_username, _password))
35+
_server->on(path.c_str(), HTTP_GET, [&](){
36+
if(_username != emptyString && _password != emptyString && !_server->authenticate(_username.c_str(), _password.c_str()))
3737
return _server->requestAuthentication();
3838
_server->send_P(200, PSTR("text/html"), serverIndex);
3939
});
4040

4141
// handler for the /update form POST (once file upload finishes)
42-
_server->on(path, HTTP_POST, [&](){
42+
_server->on(path.c_str(), HTTP_POST, [&](){
4343
if(!_authenticated)
4444
return _server->requestAuthentication();
4545
if (Update.hasError()) {
@@ -61,7 +61,7 @@ void ESP8266HTTPUpdateServer::setup(ESP8266WebServer *server, const char * path,
6161
if (_serial_output)
6262
Serial.setDebugOutput(true);
6363

64-
_authenticated = (_username == NULL || _password == NULL || _server->authenticate(_username, _password));
64+
_authenticated = (_username == emptyString || _password == emptyString || _server->authenticate(_username.c_str(), _password.c_str()));
6565
if(!_authenticated){
6666
if (_serial_output)
6767
Serial.printf("Unauthenticated Update\n");

libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ class ESP8266HTTPUpdateServer
1010

1111
void setup(ESP8266WebServer *server)
1212
{
13-
setup(server, NULL, NULL);
13+
setup(server, emptyString, emptyString);
1414
}
1515

16-
void setup(ESP8266WebServer *server, const char * path)
16+
void setup(ESP8266WebServer *server, const String& path)
1717
{
18-
setup(server, path, NULL, NULL);
18+
setup(server, path, emptyString, emptyString);
1919
}
2020

21-
void setup(ESP8266WebServer *server, const char * username, const char * password)
21+
void setup(ESP8266WebServer *server, const String& username, const String& password)
2222
{
2323
setup(server, "/update", username, password);
2424
}
2525

26-
void setup(ESP8266WebServer *server, const char * path, const char * username, const char * password);
26+
void setup(ESP8266WebServer *server, const String& path, const String& username, const String& password);
2727

28-
void updateCredentials(const char * username, const char * password)
28+
void updateCredentials(const String& username, const String& password)
2929
{
30-
_username = (char *)username;
31-
_password = (char *)password;
30+
_username = username;
31+
_password = password;
3232
}
3333

3434
protected:
@@ -37,8 +37,8 @@ class ESP8266HTTPUpdateServer
3737
private:
3838
bool _serial_output;
3939
ESP8266WebServer *_server;
40-
char * _username;
41-
char * _password;
40+
String _username;
41+
String _password;
4242
bool _authenticated;
4343
String _updaterError;
4444
};

0 commit comments

Comments
 (0)