Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ESP32 support, changed layout of inline HTML, small fixes #26

Merged
merged 13 commits into from
Mar 16, 2019

Conversation

Jeroen88
Copy link
Contributor

@Jeroen88 Jeroen88 commented Jan 30, 2019

Added ESP32 support for the main files PersWiFiManager.h and PersWiFiManager.cpp using #if defined(ESP8266) and defined(ESP32) to make the difference.

Added ESP32 support for the first example basic_rest_api.ino using the same #if defined's.
To make this example work you need to install the ESP32 port of the ESP8266SSDP library too. This port is called ESP32SSDP and can be found here.

The other two examples can be adapted easily, although spiffs_rest_api_nonblocking.ino requires adaptation of the EasySSDP and SPIFFSReadServer files too.

Other changes are, in basic_rest_api.ino:

  • moved SSDP.setDeviceType("upnp:rootdevice") to before SSDP.begin(), because it seems more logical to fully initialise SSDP before starting it

and in PersWiFiManager.cpp:

  • changed the layout of the inline HTML for const char wifi_htm[] to make it readable in the Arduino SDK
  • used the ESP32 equivalent for ENC_TYPE_NONE, i.e. WIFI_AUTH_OPEN
  • added HTTP headers Cache-Control and Expires for the route "/wifi.htm", both for the ESP32 and for the ESP8266, to avoid this page being loaded from the browser cache when a (next) connection to the ESP Access Point fails
  • added WiFi.mode(WIFI_STA) in PersWiFiManager::begin(), because otherwise my ESP32 crashed. Maybe it is a good idea to add this for the ESP8266 version too

@Jeroen88 Jeroen88 mentioned this pull request Jan 30, 2019
@Jeroen88
Copy link
Contributor Author

Changed Access Point IP address to 192.168.4.1 instead of 192.168.1.1, because that is what the ESP32 reported back even if I set it to 192.168.1.1.

@Jeroen88
Copy link
Contributor Author

Jeroen88 commented Jan 31, 2019

If no WiFi credentials are found (e.g. when the ESP has never connected to a WiFi network before or the credentials have been reset) do not wait for a timeout but start the AP inmediately

@Jeroen88
Copy link
Contributor Author

Fixed a bug in starting the AP inmediately if no WiFi credentials are found.

@Jeroen88
Copy link
Contributor Author

Jeroen88 commented Jan 31, 2019

On an ESP32 it was more difficult to detect if no WiFi credentials are present. This feature is not tested yet on an ESP32 completely fresh out of the box, neither is it tested yet on an ESP8266.

@Jeroen88
Copy link
Contributor Author

Changed the DNS server IP to 192.168.4.1 too, so all clients connecting in AP mode are redirected to the ESP webserver root.

@Jeroen88
Copy link
Contributor Author

Tested on a 'fresh out of the box' ESP32 and works like a charm!
Tested on a previously used before ESP8266 and, after the last commit, works like a charm too!

@Jeroen88
Copy link
Contributor Author

Jeroen88 commented Feb 1, 2019

Added a method ::resetSettings() to clear WiFi credentials, e.g. for testing purposes. If ::resetSettings() is called before ::begin(), the ESP should start in AP mode, because it has no more a known SSID to connect to.

@Jeroen88
Copy link
Contributor Author

Jeroen88 commented Feb 1, 2019

Some more changes:

  • It seems that the ESP8266 can be (rarely) bricked if connecting to a new SSID while it is already connected to another SSID. So calling the recently added ::resetSettings() to clear a previous SSID
  • The literal HTML string was wrong
  • Added ::getSsid() to get the last SSID the ESP connected to, or tried to connect to

@r-downing
Copy link
Owner

Very cool, thanks!

@r-downing r-downing merged commit f8486ec into r-downing:master Mar 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants