18#ifdef USE_WIFI_AP_MODULE
23#include <ArduinoJson.h>
27#include <WiFiClient.h>
29#include <Preferences.h>
49const char*
_apSSID =
"PetTutorSetup_192_168_4_1";
61#define AP_EPROM_NAME "ap_wifi"
62#define WIFI_SSID "1ws"
63#define WIFI_PASSWORD "2wp"
66#define WIFI_SSID_LAST "3sl"
70#define MQTT_PORT "4pt"
71#define MQTT_SERVER "5sv"
72#define MQTT_USER "6mu"
73#define MQTT_PASSWORD "7mp"
74#define MQTT_GUEST_PASSWORD "8mg"
76#define MQTT_TOPIC "9mt"
77#define MQTT_DEVICE_NAME "10md"
78#define MQTT_LOCATION_NAME "11ml"
105 for (
int i=0; i< input.length(); i++)
165 SerialDebug.print(
"WIFI ssid = ");
181 SerialDebug.println(
"cleaned EPROM WIFI ssid ** REBOOTING");
191 SerialDebug.println(
"cleanEPROM_WIFI_APModule");
198void WIFI_APModule_updateMQTTInfo(
char *ssid,
char *ssid_password,
char *username,
char *password,
char *guestPassword,
char *deviceName,
char *host,
char *port,
char *locationString)
200 SerialDebug.printf(
"wifi_apModule.updateMQTTInfo(%s, %s, %s,%s, %s, %s, %s)\n", ssid?ssid:
"NULL", ssid_password?ssid_password:
"NULL", username?username:
"NULL", password?password:
"NULL", guestPassword?guestPassword:
"NULL", locationString?locationString:
"NULL", deviceName?deviceName:
"NULL");
217 SerialDebug.println(
"done wifi_apModule.updateMQTTInfo");
268 SerialDebug.println(
"wifi_apModule.WIFI_startWebServer");
291 SerialDebug.print(
"Visit Web Server: \n");
294 SerialDebug.print(WiFi.softAPIP());
298#ifdef DONT_USE_BASE_ADDRESS
301 String s =
"<h1>ESP is now in Access Point mode</h1><p><a href=\"/settings\">Click to update WiFi Credentials</a></p>";
318 SerialDebug.println(
"settings touched, ssid_last = ");
332 s +=
"<h1>Wi-Fi Settings for ESP-M5 Device</h1>";
335 s +=
"<h1>Wi-Fi Settings for ESP-32 Device</h1>";
338 s +=
"<p>Enter your password after selecting the visible SSID names";
343s +=
" (or type missing WIFI). <i>*older web browsers may not show list, and only 2.4gHz WIFI supported</i></p>";
344 s +=
"<button onClick=\"window.location.reload();\">Refresh to re-discover WIFI list</button> </p>";
347s +=
"<button onClick=\"window.location.reload();\">Refresh to re-discover WIFI list</button></p>";
350 s +=
"<form method=\"get\" action=\"setap\" onsubmit=\"return validateForm()\">\n";
351 s +=
"<label>SSID: </label>\n";
354 s +=
"<input list=\"ssid\" class=\"form-control\" name=\"ssid\" id=\"ssid_val\" style=\"width:300px;\">";
356 s +=
"<datalist id=\"ssid\" >";
360 s +=
"<select name=\"ssid\" id=\"ssid_val\" length=\"64\" \">";
365 s +=
"<br>Password: <input name=\"pass\" id=\"pass\" length=64 type=\"text\" value=\"" +
_WIFI_password +
"\">";
372 s +=
"<h2>MQTT User Settings</h2>";
373 s +=
"MQTT user : <input name=\"mqtt_user\" id=\"mqtt_user\" length=\"64\" size=\"64\" type=\"text\" style=\"text-transform: lowercase\" value=\"" +
_WIFI_mqttUser +
"\">";
374 s +=
"<br>MQTT pass : <input name=\"mqtt_password\" id=\"mqtt_password\" length=\"64\" size=\"64\" type=\"text\" style=\"text-transform: lowercase\" value=\"" +
_WIFI_mqttPassword +
"\">";
375 s +=
"<br>MQTT guestpass: <input name=\"mqtt_guestPassword\" id=\"mqtt_guestPassword\" length=\"64\" size=\"64\" type=\"text\" style=\"text-transform: lowercase\" value=\"" +
_WIFI_mqttGuestPassword +
"\">";
386 s +=
"<br>DeviceName : <input name=\"deviceName\" id=\"deviceName\" length=\"64\" size=\"64\" type=\"text\" value=\"" +
_WIFI_deviceName +
"\">";
387 s +=
"<br>Location in World : <input name=\"locationString\" length=\"64\" size=\"64\" type=\"text\" value=\"" +
_WIFI_locationString +
"\">";
388 s +=
"<h2>MQTT Server Settings</h2>";
390 s +=
"<br>MQTT Server: <input name=\"mqtt_server\" id=\"mqtt_server\" length=\"64\" size=\"64\" type=\"text\" value=\"" +
_WIFI_mqttServer +
"\">";
391 s +=
"<br>MQTT Port : <input name=\"mqtt_port\" id=\"mqtt_port\" length=\"10\" size=\"10\" type=\"text\" value=\"" +
_WIFI_mqttPort +
"\">";
395 s +=
"<br><input type=\"submit\"></form>";
399#ifdef M5_CAPTURE_SCREEN
401 s +=
"<a href=\"capture\">capture</a>";
409 SerialDebug.println(
"setAP touched");
415 SerialDebug.print(
"SSID: ");
416 SerialDebug.println(ssid);
470 DynamicJsonDocument myObject(1024);
471 myObject[
"ssid"] = ssid;
472 myObject[
"ssidPassword"] = pass;
485 SerialDebug.print(
"JSON = ");
488 SerialDebug.println(
"Write to WIFI_AP_Module.eprom done!");
494 s +=
"<h1>Credential Setup Complete.</h1><ol><li>Reconnect to your favorite WIFI\n<li>Then to access device commands, click: ";
496 s +=
"<br><a href=\"http://192.168.4.1\">Restart Credentials (after connecting to PetTutorSetup_192_168_4_1)</a>";
502#ifdef M5_CAPTURE_SCREEN
506 SerialDebug.println(
"capture touched");
529 int n = WiFi.scanNetworks();
531 SerialTemp.println(
" *** WIFI LIST: ");
534 for (
int i = 0; i < n; i++) {
535 SerialTemp.print(
"SSID: ");
536 SerialTemp.print(WiFi.SSID(i));
537 SerialTemp.print(
" Signal: ");
538 SerialTemp.print(WiFi.RSSI(i));
539 SerialTemp.print(
" dBm, channel: ");
540 SerialTemp.println(WiFi.channel(i));
559 SerialDebug.println(
"wifi_apModule.WIFI_setupMode");
562 WiFi.mode(WIFI_MODE_STA);
576 WiFi.mode(WIFI_MODE_AP);
583 SerialDebug.printf(
"\nStarting Access Point at \n\"%s\"\n",
_apSSID);
590 SerialDebug.print(
"WIFI_makePage:");
591 SerialDebug.println(title);
593 String s =
"<!DOCTYPE html><html><head>";
594 s +=
"<meta name=\"viewport\" content=\"width=device-width,user-scalable=0\">";
597 s +=
"</title></head><body>";
599 s +=
"</body></html>";
606 s.replace(
"%20",
" ");
608 s.replace(
"%21",
"!");
609 s.replace(
"%22",
"\"");
610 s.replace(
"%23",
"#");
611 s.replace(
"%24",
"$");
612 s.replace(
"%25",
"%");
613 s.replace(
"%26",
"&");
614 s.replace(
"%27",
"\'");
615 s.replace(
"%28",
"(");
616 s.replace(
"%29",
")");
617 s.replace(
"%30",
"*");
618 s.replace(
"%31",
"+");
619 s.replace(
"%2C",
",");
620 s.replace(
"%2E",
".");
621 s.replace(
"%2F",
"/");
622 s.replace(
"%2C",
",");
623 s.replace(
"%3A",
":");
624 s.replace(
"%3A",
";");
625 s.replace(
"%3C",
"<");
626 s.replace(
"%3D",
"=");
627 s.replace(
"%3E",
">");
628 s.replace(
"%3F",
"?");
629 s.replace(
"%40",
"@");
630 s.replace(
"%5B",
"[");
631 s.replace(
"%5C",
"\\");
632 s.replace(
"%5D",
"]");
633 s.replace(
"%5E",
"^");
634 s.replace(
"%5F",
"-");
635 s.replace(
"%60",
"`");
644 String imageString =
"<img width=\"200\" src=\"data:image/png;base64,";
646 "iVBORw0KGgoAAAANSUhEUgAAAGQAAAAgCAYAAADkK90uAAAMbmlDQ1BJQ0MgUHJvZmlsZQAASImVVwdYU8kWnluSkJAQIHQpoTdBpAaQEkILIL0INkISSCgxJgQVO7qo4NpFFCu6KqLYVkDs2JVFsffFgoqyLupiQ+VNSEDXfeV75/vm3j9nzvyn3JncewCgf+BJpfmoNgAFkkJZYkQIc1R6BpP0FGDAANCBNjDk8eVSdnx8DIAycP+7vLsBEOX9qouS65/z/1V0BUI5HwBkDMRZAjm/AOLjAOBr+VJZIQBEpd56UqFUiWdBrCeDAUK8QolzVHi7Emep8OF+m+REDsSXAdCg8niyHAC07kE9s4ifA3m0PkPsJhGIJQDQh0IcyBfxBBArYx9aUDBBiSshdoD2UohhPICV9R1nzt/4swb5ebycQazKq180QsVyaT5vyv9Zmv8tBfmKAR92cFBFsshEZf6whrfyJkQrMRXiLklWbJyy1hB/EAtUdQcApYgUkSkqe9SUL+fA+sGnDlA3AS80GmJTiMMl+bExan1WtjicCzHcLehkcSE3GWIjiOcL5WFJapuNsgmJal9ofbaMw1brz/Fk/X6Vvh4o8lLYav43IiFXzY9pFYuS0yCm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Li7FarTgcDvwSj6i/YTnviMpZh6+0lFKfj7GxMW3A8vJyrd7f38/mzZvFDTTQ0dFBUVGRxAiTOCVmGZdAUm2kTjwzNaaqvxVRtYFn/+VyT+7zd2p9zu0dlQg8LMbN5yvl0KFDeDxuAoGgRuCCggKNqGH5PMhulzP2o0dxy3uz2JUpObq1WCza50PNzc2ivvQaeAMDA8zMzBAMSrJPgjsFqs1mY+HChX8WIFlRfqcCcPq+5lRWQL4cmZ6e1giruH5EDoKUlOzcuZMNGzZoHK++2VJFEVdxvnICYpJaMYtLa5f8VkhOCI2StldAuOTLEzWeuqrPhNRhl0kMvQLlz5GQ0xf8Tr+fA+TNNqpAUET+/yrvgvHWlPw/p9HXMyEUsSMAAAAASUVORK5CYII=";
648 imageString +=
"\">";
651 imageString +=
"<br>";
663 s +=
"<script type=\"text/javascript\">\n";
665 s +=
"var _validatedForm = true;\n";
667 s +=
"//!convert to lower case and strip spaces, using the valId, and setting valId if valid\n";
668 s +=
"function checkAndConvertText(valId, msg, toLower)\n";
670 s +=
"var val = document.getElementById(valId).value;\n";
673 s +=
"alert(msg + \" required\");\n";
674 s +=
" _validatedForm = false;\n";
678 s +=
"//!strip all spaces\n";
680 s +=
"var str = val.replace(/\\s+/g, '');\n";
682 s +=
"if (toLower)\n";
684 s +=
"//!convert to lower case\n";
685 s +=
"str = str.toLowerCase();\n";
688 s +=
"document.getElementById(valId).value = str;\n";
689 s +=
"return true;\n";
692 s +=
"//!checks a string to make sure a number..\n";
693 s +=
"function checkNumber(valId, msg)\n";
695 s +=
"var num = document.getElementById(valId).value;\n";
696 s +=
"if (isNaN(num) || num < 1)\n";
698 s +=
"alert(msg + \": \" + num + \" must be valid number\");\n";
699 s +=
"_validatedForm = false;\n";
708 s +=
"//!v8 confirms the values the user entered\n";
709 s +=
"//! set _validatedForm = false if not confirmed\n";
710 s +=
"function confirmValues()\n";
713 s +=
" var msg = \"Please confirm values\\n\";\n";
714 s +=
" val = document.getElementById(\"ssid_val\").value;\n";
715 s +=
" msg += \"WIFI SSID = '\" + val + \"'\\n\";\n";
716 s +=
" val = document.getElementById(\"pass\").value;\n";
717 s +=
" msg += \"WIFI PASS = '\" + val + \"'\\n\";\n";
718 s +=
" val = document.getElementById(\"mqtt_user\").value;\n";
719 s +=
" msg += \"MQTT USER = '\" + val + \"'\\n\";\n";
720 s +=
" val = document.getElementById(\"mqtt_password\").value;\n";
721 s +=
" msg += \"MQTT PASS = '\" + val + \"'\\n\";\n";
722 s +=
" val = document.getElementById(\"mqtt_guestPassword\").value;\n";
723 s +=
" msg += \"MQTT Guest PASS = '\" + val + \"'\\n\";\n";
724 s +=
" val = document.getElementById(\"deviceName\").value;\n";
725 s +=
" msg += \"Device Name = '\" + val + \"'\\n\";\n";
726 s +=
" _validatedForm = confirm(msg);\n";
732 s +=
"//! checks a few fields, and makes sure they are not null, and convert to lowerCase and strip spaces\n";
733 s +=
"function validateForm()\n";
735 s +=
"//! set default that alls good\n";
736 s +=
"_validatedForm = true;\n";
737 s +=
"var toLower = true;\n";
738 s +=
"var keepCase = false;\n";
740 s +=
"// These will set _validatedFrom to false if not bood\n";
741 s +=
"checkAndConvertText(\"ssid_val\",\"WIFI SSID\", keepCase);\n";
742 s +=
"checkAndConvertText(\"mqtt_user\",\"MQTT User Name\", toLower);\n";
743 s +=
"checkAndConvertText(\"mqtt_password\",\"MQTT Password\", toLower);\n";
744 s +=
"checkAndConvertText(\"mqtt_guestPassword\",\"MQTT Guest Password\", toLower);\n";
745 s +=
"checkAndConvertText(\"deviceName\",\"Device Name\", keepCase);\n";
747 s +=
"checkAndConvertText(\"mqtt_server\",\"MQTT Server Name\", toLower);\n";
748 s +=
"checkNumber(\"mqtt_port\",\"MQTT Port\");\n";
750 s +=
"if (_validatedForm) confirmValues();\n";
751 s +=
"return _validatedForm;\n";
void addToTextMessages_displayModule(String text)
#define MQTT_GUEST_PASSWORD
String WIFI_APModule_JsonOutputString()
retrieves the JSON string
WiFiClient _WIFIClient
client of the web server??
boolean _doneWIFI_APModuleFlag
String WIFI_urlDecode(String input)
Decode the URL.
String getJavascriptString()
create the javascript header to convert to lowercase, etc
WebServer WIFI_webServer(80)
DNSServer dnsServer;. webServer的类, port 80.
void loop_WIFI_APModule()
main loop
void setup_WIFI_APModule()
sets the config in the EPPROM called wifi-config. NOTE: the _done isn't valid until after this code....
const char * _WIFIWirelessAP
String _WIFI_mqttGuestPassword
const IPAddress _WIFIapIP(192, 168, 4, 1)
void clean_SSID_WIFICredentials()
returns true if the SSID is set, false otherwise. If set, then just exit..
void WIFI_APModule_ResetCredentials()
resets the credentials
Preferences _WIFIPreferences
wifi config store. wifi配置存储的类
void WIFI_APModule_updateMQTTInfo(char *ssid, char *ssid_password, char *username, char *password, char *guestPassword, char *deviceName, char *host, char *port, char *locationString)
sets the MQTT user/password. It's up to the code to decide who needs to know
boolean doneWIFI_APModule_Credentials()
called to see if the WIFIModule has finished bootstrapping..
void cleanEPROM_WIFI_APModule()
cleans the eprom info
String _WIFI_locationString
#define AP_EPROM_NAME
EPROM INFO .. might be a length issue of the attribute name.
void WIFI_startWebServer()
String _WIFI_mqttPassword
void preSetup_WIFI_APModule()
boolean _WIFI_SettingMode
String removeSpaces(String input)
remove spaces in a string
void setDoneWIFI_APModuleFlag(boolean flag)
called to set the done flag
boolean isSet_SSID_WIFICredentials()
returns true if the SSID is set, false otherwise. If set, then just exit..
String _jsonOutputString
the json output string that contain the credentials
String WIFI_makePage(String title, String contents)
makes a webpage with the title, and contents, already in HTML
void rediscoverWIFIList()
rediscover (and prints) the WIFIlist .. scanning each time.. so a page refresh will look again....
#define MQTT_LOCATION_NAME
void WIFI_setupMode()
Setup the WIFI access point.
String headerImageString()
WIFI_APModule
void on(const String &uri, THandlerFunction handler)
void send(int code, const char *content_type=NULL, const String &content=String(""))
void onNotFound(THandlerFunction fn)