Constructor
@@ -758,12 +772,19 @@ wdt reset
How erase the credentials saved in EEPROM?
Make some sketches for erasing the EEPROM area, or some erasing utility is needed. You can prepare the sketch to erase the saved credential with AutoConnectCredential. The AutoConnectCrendential class provides the access method to the saved credential in EEPROM and library source file is including it.
A class description of AutoConnectCredential is follows.
-Constructor
+
#include <AutoConnectCredential.h>
+
+
+Constructor
+AutoConnectCredential();
+
-AutoConnectCredential();
+AutoConnectCredential default constructor. The default offset value is 0. If the offset value is 0, the credential storage area starts from the top of the EEPROM. AutoConnect sometimes overwrites data when using this area with user sketch.
+AutoConnectCredential(uint16_t offset);
+Specify offset from the top of the EEPROM for the credential storage area together. The offset value is from 0 to the flash sector size.
Public member functions
-
diff --git a/docs/search/search_index.json b/docs/search/search_index.json
index 6f779f1..4c64f86 100644
--- a/docs/search/search_index.json
+++ b/docs/search/search_index.json
@@ -197,7 +197,7 @@
},
{
"location": "/advancedusage/index.html",
- "text": "Advanced usage\n\u00b6\n\n\n 404 handler\n\u00b6\n\n\nRegistering the \"not found\" handler is a different way than ESP8266WebServer. The \nonNotFound\n of ESP8266WebServer does not work with AutoConnect. AutoConnect overrides \nESP8266WebServer::onNotFound\n to handle a captive portal. To register \"not found\" handler, use \nAutoConnect::onNotFound\n.\n\n\n Auto save Credential\n\u00b6\n\n\nBy default, AutoConnect saves the credentials of the established connection in EEPROM. You can disable it with the \nautoSave\n parameter specified by \nAutoConnectConfig\n.\n\n\nAutoConnect\n \nPortal\n;\n\n\nAutoConnectConfig\n \nConfig\n;\n\n\nConfig\n.\nautoSave\n \n=\n \nAC_SAVECREDENTIAL_NEVER\n;\n\n\nPortal\n.\nconfig\n(\nConfig\n);\n\n\nPortal\n.\nbegin\n();\n\n\n\n\n\n Captive portal start detection\n\u00b6\n\n\nThe captive portal will only be activated if the first \nWiFi::begin\n fails. Sketch can detect with the \nAutoConnect::onDetect\n funciton that the captive portal has started. For example, the sketch can be written like as follows that turns on the LED at the start captive portal.\n\n\nAutoConnect\n \nPortal\n;\n\n\n\nbool\n \nstartCP\n(\nIPAddress\n \nip\n)\n \n{\n\n\n \ndigitalWrite\n(\nBUILTIN_LED\n,\n \nHIGH\n);\n\n \nSerial\n.\nprintln\n(\n\"C.P. started, IP:\"\n \n+\n \nWiFi\n.\nlocalIP\n().\ntoString\n());\n\n \nreturn\n \ntrue\n;\n\n\n}\n\n\n\nvoid\n \nsetup\n()\n \n{\n\n \nSerial\n.\nbegin\n(\n115200\n);\n\n \npinMode\n(\nBUILTIN_LED\n,\n \noutput\n);\n\n \ndigitalWrite\n(\nBUILTIN_LED\n,\n \nLOW\n);\n\n\n \nPortal\n.\nonDetect\n(\nstartCP\n);\n\n\n \nif\n \n(\nPortal\n.\nbegin\n())\n \n{\n\n \ndigitalWrite\n(\nBUILTIN_LED\n,\n \nLOW\n);\n\n \n}\n\n\n}\n\n\n\nvoid\n \nloop\n()\n \n{\n\n \nPortal\n.\nhandleClient\n();\n\n\n}\n\n\n\n\n\n Combination with mDNS\n\u00b6\n\n\nWith \nmDNS library\n, you can access to ESP8266 by name instead of IP address after connection. The sketch can start the MDNS responder after \nAutoConnect::begin\n.\n\n\n#include\n \n\n\n\n#include\n \n\n\n\n#include\n \n\n\n\nAutoConnect\n \nPortal\n;\n\n\n\nvoid\n \nsetup\n()\n \n{\n\n \nif\n \n(\nPortal\n.\nbegin\n())\n \n{\n\n\n \nif\n \n(\nMDNS\n.\nbegin\n(\n\"esp8266\"\n))\n \n{\n\n\n \nMDNS\n.\naddService\n(\n\"http\"\n,\n \n\"tcp\"\n,\n \n80\n);\n\n\n \n}\n\n \n}\n\n\n}\n\n\n\nvoid\n \nloop\n()\n \n{\n\n \nPortal\n.\nhandleClient\n();\n\n\n}\n\n\n\n\n\n\n\nAutoConnect::config before AutoConnect::begin\n\n\nAutoConnect::config\n must be executed before \nAutoConnect::begin\n.\n\n\n\n\n Debug print\n\u00b6\n\n\nYou can output AutoConnect monitor messages to the \nSerial\n. A monitor message activation switch is in an include header file \nAutoConnect.h\n of library source. Define \nAC_DEBUG\n macro to output monitor messages.\n\n\n#define AC_DEBUG\n\n\n\n\n\n Disable the captive portal\n\u00b6\n\n\nIt can also prevent the captive portal from starting even if the connection at the first \nWiFi.begin\n fails. In this case, the behavior of \nAutoConnect::begin\n is the same as \nWiFi.begin\n.\n\n\nFor disabling the captive portal, \nautoRise\n sets to false with \nAutoConnectConfig\n.\n\n\nAutoConnect\n \nportal\n;\n\n\nAutoConnectConfig\n \nacConfig\n;\n\n\n\nacConfig\n.\nautoRaise\n \n=\n \nfalse\n;\n\n\nportal\n.\nconfig\n(\nacConfig\n);\n\n\nportal\n.\nbegin\n();\n\n\n\n\n\n Move the saving area of EEPROM for the credentials\n\u00b6\n\n\nBy default, the credentials saving area is occupied from the beginning of EEPROM. \nESP8266 Arduino core document\n says that:\n\n\n\n\nThe following diagram illustrates flash layout used in Arduino environment:\n\n\n\n\n\n\n\n \n|--------------|-------|---------------|--|--|--|--|--|\n\n \n^\n \n^\n \n^\n \n^\n \n^\n\n \nSketch\n \nOTA\n \nupdate\n \nFile\n \nsystem\n \nEEPROM\n \nWiFi\n \nconfig\n \n(\nSDK\n)\n\n\n\n\n\n\n\nand\n\n\n\n\nEEPROM library uses one sector of flash located \njust after the SPIFFS\n.\n\n\n\n\nSo in the default state, the credential storage area used by AutoConnect conflicts with data area owned by the user sketch. It will be destroyed together saved data in EEPROM by user sketch and AutoConnect each other. But you can move the storage area to avoid this.\n\n\nThe \nsaveOffset\n in \nAutoConnectConfig\n specifies the start offset of the credentials storage area. The default value is 0.\n\n\n Refers the hosted ESP8266WebServer\n\u00b6\n\n\nConstructing an AutoConnect object variable without parameters then creates and starts an ESP8266WebServer inside the AutoConnect. This object variable could be referred by \nAutoConnect::host()\n function to access ESP8266WebServer instance as like below.\n\n\nAutoConnect\n \nPortal\n;\n\n\n\nPortal\n.\nbegin\n();\n\n\nESP8266WebServer\n&\n \nserver\n \n=\n \nPortal\n.\nhost\n();\n\n\nserver\n.\nsend\n(\n200\n,\n \n\"text/plain\"\n,\n \n\"Hello, world\"\n);\n\n\n\n\n\n\n\nWhen host() is valid\n\n\nThe host() can be referred at after \nAutoConnect::begin\n.\n\n\n\n\n Usage for automatically instantiated ESP8266WebServer\n\u00b6\n\n\nThe sketch can handle URL requests using ESP8266WebServer that AutoConnect started internally. ESP8266WebServer instantiated dynamically by AutoConnect can be referred to by \nAutoConnect::host\n function. The sketch can use the '\non\n' function, '\nsend\n' function, '\nclient\n' function and others by ESP8266WebServer reference of its return value.\n\n\n#include\n \n\n\n\n#include\n \n\n\n\n#include\n \n\n\n\n\nAutoConnect\n \nPortal\n;\n\n\n\nvoid\n \nhandleRoot\n()\n \n{\n\n\n \nESP8266WebServer\n&\n \nIntServer\n \n=\n \nPortal\n.\nhost\n();\n\n\n \nIntServer\n.\nsend\n(\n200\n,\n \n\"text/html\"\n,\n \n\"Hello, world\"\n);\n\n\n}\n\n\n\nvoid\n \nhandleNotFound\n()\n \n{\n\n\n \nESP8266WebServer\n&\n \nIntServer\n \n=\n \nPortal\n.\nhost\n();\n\n\n \nIntServer\n.\nsend\n(\n404\n,\n \n\"text/html\"\n,\n \n\"Unknown.\"\n);\n\n\n}\n\n\n\nvoid\n \nsetup\n()\n \n{\n\n \nbool\n \nr\n \n=\n \nPortal\n.\nbegin\n();\n\n \nif\n \n(\nr\n)\n \n{\n\n\n \nESP8266WebServer\n&\n \nIntServer\n \n=\n \nPortal\n.\nhost\n();\n\n\n \nIntServer\n.\non\n(\n\"/\"\n,\n \nhandleRoot\n);\n\n\n \nPortal\n.\nonNotFound\n(\nhandleNotFound\n);\n \n// For only onNotFound.\n\n \n}\n\n\n}\n\n\n\nvoid\n \nloop\n()\n \n{\n\n\n \nPortal\n.\nhost\n().\nhandleClient\n();\n\n\n \nPortal\n.\nhandleRequest\n();\n\n \n/* or following one line code is equ.\n\n\n Portal.handleClient();\n\n\n */\n\n\n}\n\n\n\n\n\n\n\nESP8266WebServer function should be called after AutoConnect::begin\n\n\nThe sketch cannot refer to an instance of ESP8266WebServer until AutoConnect::begin completes successfully.\n\n\n\n\n\n\nDo not use with ESP8266WebServer::begin\n\n\nESP8266WebServer is already running inside the AutoConnect.\n\n\n\n\n Use with the \nPageBuilder\n library\n\u00b6\n\n\nIn ordinary, the URL handler will respond the request by sending some HTML. \nPageBuilder\n library is HTML assembly aid. it can handle predefined HTML as like a template and simplify an HTML string assemble logic, and also the generated HTML send automatically.\n\n\nAn example sketch used with the PageBuilder as follows and it explains how it aids for the HTML generating. Details for \nGithub repository\n.\n\n\n\n\nConfiguration functions\n\u00b6\n\n\n Configuration for Soft AP\n\u00b6\n\n\nAutoConnect will activate SoftAP at failed initial WiFi.Begin. It SoftAP settings are stored in \nAutoConnectConfig\n as the following parameters. The sketch could be configured SoftAP using these parameters, refer the \nAutoConnectConfig API\n for details.\n\n\n\n\nIP address of SoftAP activated.\n\n\nGateway IP address.\n\n\nSubnet mask.\n\n\nSSID for SoftAP.\n\n\nPassword for SoftAP.\n\n\nChannel.\n\n\nHidden attribute.\n\n\nAuto save credential.\n\n\nOffset address of the credentials storage area in EEPROM.\n\n\nLength of start up time after reset.\n\n\nAutomatic starting the captive portal.\n\n\nAuto reset after connection establishment.\n\n\nHome URL of the user sketch application.\n\n\n\n\n Assign user sketch's home path\n\u00b6\n\n\n\"\nHOME\n\" for returning to the user's sketch homepage is displayed at the bottom of the AutoConnect menu. It could be set using the \nAutoConnect::home\n function.\n\n\n\n\n Relocate the AutoConnect home path\n\u00b6\n\n\nA home path of AutoConnect is \n_ac\n by default. You can access from the browser with http://IPADDRESS/_ac. You can change the home path by revising \nAUTOCONNECT_URI\n macro in the include header file as \nAutoConnect.h\n.\n\n\n#define AUTOCONNECT_URI \"/_ac\"",
+ "text": "Advanced usage\n\u00b6\n\n\n 404 handler\n\u00b6\n\n\nRegistering the \"not found\" handler is a different way than ESP8266WebServer. The \nonNotFound\n of ESP8266WebServer does not work with AutoConnect. AutoConnect overrides \nESP8266WebServer::onNotFound\n to handle a captive portal. To register \"not found\" handler, use \nAutoConnect::onNotFound\n.\n\n\n Auto save Credential\n\u00b6\n\n\nBy default, AutoConnect saves the credentials of the established connection in EEPROM. You can disable it with the \nautoSave\n parameter specified by \nAutoConnectConfig\n.\n\n\nAutoConnect\n \nPortal\n;\n\n\nAutoConnectConfig\n \nConfig\n;\n\n\nConfig\n.\nautoSave\n \n=\n \nAC_SAVECREDENTIAL_NEVER\n;\n\n\nPortal\n.\nconfig\n(\nConfig\n);\n\n\nPortal\n.\nbegin\n();\n\n\n\n\n\n Captive portal start detection\n\u00b6\n\n\nThe captive portal will only be activated if the first \nWiFi::begin\n fails. Sketch can detect with the \nAutoConnect::onDetect\n funciton that the captive portal has started. For example, the sketch can be written like as follows that turns on the LED at the start captive portal.\n\n\nAutoConnect\n \nPortal\n;\n\n\n\nbool\n \nstartCP\n(\nIPAddress\n \nip\n)\n \n{\n\n\n \ndigitalWrite\n(\nBUILTIN_LED\n,\n \nHIGH\n);\n\n \nSerial\n.\nprintln\n(\n\"C.P. started, IP:\"\n \n+\n \nWiFi\n.\nlocalIP\n().\ntoString\n());\n\n \nreturn\n \ntrue\n;\n\n\n}\n\n\n\nvoid\n \nsetup\n()\n \n{\n\n \nSerial\n.\nbegin\n(\n115200\n);\n\n \npinMode\n(\nBUILTIN_LED\n,\n \noutput\n);\n\n \ndigitalWrite\n(\nBUILTIN_LED\n,\n \nLOW\n);\n\n\n \nPortal\n.\nonDetect\n(\nstartCP\n);\n\n\n \nif\n \n(\nPortal\n.\nbegin\n())\n \n{\n\n \ndigitalWrite\n(\nBUILTIN_LED\n,\n \nLOW\n);\n\n \n}\n\n\n}\n\n\n\nvoid\n \nloop\n()\n \n{\n\n \nPortal\n.\nhandleClient\n();\n\n\n}\n\n\n\n\n\n Combination with mDNS\n\u00b6\n\n\nWith \nmDNS library\n, you can access to ESP8266 by name instead of IP address after connection. The sketch can start the MDNS responder after \nAutoConnect::begin\n.\n\n\n#include\n \n\n\n\n#include\n \n\n\n\n#include\n \n\n\n\nAutoConnect\n \nPortal\n;\n\n\n\nvoid\n \nsetup\n()\n \n{\n\n \nif\n \n(\nPortal\n.\nbegin\n())\n \n{\n\n\n \nif\n \n(\nMDNS\n.\nbegin\n(\n\"esp8266\"\n))\n \n{\n\n\n \nMDNS\n.\naddService\n(\n\"http\"\n,\n \n\"tcp\"\n,\n \n80\n);\n\n\n \n}\n\n \n}\n\n\n}\n\n\n\nvoid\n \nloop\n()\n \n{\n\n \nPortal\n.\nhandleClient\n();\n\n\n}\n\n\n\n\n\n\n\nAutoConnect::config before AutoConnect::begin\n\n\nAutoConnect::config\n must be executed before \nAutoConnect::begin\n.\n\n\n\n\n Debug print\n\u00b6\n\n\nYou can output AutoConnect monitor messages to the \nSerial\n. A monitor message activation switch is in an include header file \nAutoConnect.h\n of library source. Define \nAC_DEBUG\n macro to output monitor messages.\n\n\n#define AC_DEBUG\n\n\n\n\n\n Disable the captive portal\n\u00b6\n\n\nIt can also prevent the captive portal from starting even if the connection at the first \nWiFi.begin\n fails. In this case, the behavior of \nAutoConnect::begin\n is the same as \nWiFi.begin\n.\n\n\nFor disabling the captive portal, \nautoRise\n sets to false with \nAutoConnectConfig\n.\n\n\nAutoConnect\n \nportal\n;\n\n\nAutoConnectConfig\n \nacConfig\n;\n\n\n\nacConfig\n.\nautoRaise\n \n=\n \nfalse\n;\n\n\nportal\n.\nconfig\n(\nacConfig\n);\n\n\nportal\n.\nbegin\n();\n\n\n\n\n\n Move the saving area of EEPROM for the credentials\n\u00b6\n\n\nBy default, the credentials saving area is occupied from the beginning of EEPROM. \nESP8266 Arduino core document\n says that:\n\n\n\n\nThe following diagram illustrates flash layout used in Arduino environment:\n\n\n\n\n\n\n\n \n|--------------|-------|---------------|--|--|--|--|--|\n\n \n^\n \n^\n \n^\n \n^\n \n^\n\n \nSketch\n \nOTA\n \nupdate\n \nFile\n \nsystem\n \nEEPROM\n \nWiFi\n \nconfig\n \n(\nSDK\n)\n\n\n\n\n\n\n\nand\n\n\n\n\nEEPROM library uses one sector of flash located \njust after the SPIFFS\n.\n\n\n\n\nSo in the default state, the credential storage area used by AutoConnect conflicts with data area owned by the user sketch. It will be destroyed together saved data in EEPROM by user sketch and AutoConnect each other. But you can move the storage area to avoid this.\n\n\nThe \nboundaryOffset\n in \nAutoConnectConfig\n specifies the start offset of the credentials storage area. The default value is 0.\n\n\n Refers the hosted ESP8266WebServer\n\u00b6\n\n\nConstructing an AutoConnect object variable without parameters then creates and starts an ESP8266WebServer inside the AutoConnect. This object variable could be referred by \nAutoConnect::host()\n function to access ESP8266WebServer instance as like below.\n\n\nAutoConnect\n \nPortal\n;\n\n\n\nPortal\n.\nbegin\n();\n\n\nESP8266WebServer\n&\n \nserver\n \n=\n \nPortal\n.\nhost\n();\n\n\nserver\n.\nsend\n(\n200\n,\n \n\"text/plain\"\n,\n \n\"Hello, world\"\n);\n\n\n\n\n\n\n\nWhen host() is valid\n\n\nThe host() can be referred at after \nAutoConnect::begin\n.\n\n\n\n\n Usage for automatically instantiated ESP8266WebServer\n\u00b6\n\n\nThe sketch can handle URL requests using ESP8266WebServer that AutoConnect started internally. ESP8266WebServer instantiated dynamically by AutoConnect can be referred to by \nAutoConnect::host\n function. The sketch can use the '\non\n' function, '\nsend\n' function, '\nclient\n' function and others by ESP8266WebServer reference of its return value.\n\n\n#include\n \n\n\n\n#include\n \n\n\n\n#include\n \n\n\n\n\nAutoConnect\n \nPortal\n;\n\n\n\nvoid\n \nhandleRoot\n()\n \n{\n\n\n \nESP8266WebServer\n&\n \nIntServer\n \n=\n \nPortal\n.\nhost\n();\n\n\n \nIntServer\n.\nsend\n(\n200\n,\n \n\"text/html\"\n,\n \n\"Hello, world\"\n);\n\n\n}\n\n\n\nvoid\n \nhandleNotFound\n()\n \n{\n\n\n \nESP8266WebServer\n&\n \nIntServer\n \n=\n \nPortal\n.\nhost\n();\n\n\n \nIntServer\n.\nsend\n(\n404\n,\n \n\"text/html\"\n,\n \n\"Unknown.\"\n);\n\n\n}\n\n\n\nvoid\n \nsetup\n()\n \n{\n\n \nbool\n \nr\n \n=\n \nPortal\n.\nbegin\n();\n\n \nif\n \n(\nr\n)\n \n{\n\n\n \nESP8266WebServer\n&\n \nIntServer\n \n=\n \nPortal\n.\nhost\n();\n\n\n \nIntServer\n.\non\n(\n\"/\"\n,\n \nhandleRoot\n);\n\n\n \nPortal\n.\nonNotFound\n(\nhandleNotFound\n);\n \n// For only onNotFound.\n\n \n}\n\n\n}\n\n\n\nvoid\n \nloop\n()\n \n{\n\n\n \nPortal\n.\nhost\n().\nhandleClient\n();\n\n\n \nPortal\n.\nhandleRequest\n();\n\n \n/* or following one line code is equ.\n\n\n Portal.handleClient();\n\n\n */\n\n\n}\n\n\n\n\n\n\n\nESP8266WebServer function should be called after AutoConnect::begin\n\n\nThe sketch cannot refer to an instance of ESP8266WebServer until AutoConnect::begin completes successfully.\n\n\n\n\n\n\nDo not use with ESP8266WebServer::begin\n\n\nESP8266WebServer is already running inside the AutoConnect.\n\n\n\n\n Use with the \nPageBuilder\n library\n\u00b6\n\n\nIn ordinary, the URL handler will respond the request by sending some HTML. \nPageBuilder\n library is HTML assembly aid. it can handle predefined HTML as like a template and simplify an HTML string assemble logic, and also the generated HTML send automatically.\n\n\nAn example sketch used with the PageBuilder as follows and it explains how it aids for the HTML generating. Details for \nGithub repository\n.\n\n\n\n\nConfiguration functions\n\u00b6\n\n\n Configuration for Soft AP\n\u00b6\n\n\nAutoConnect will activate SoftAP at failed initial WiFi.Begin. It SoftAP settings are stored in \nAutoConnectConfig\n as the following parameters. The sketch could be configured SoftAP using these parameters, refer the \nAutoConnectConfig API\n for details.\n\n\n\n\nIP address of SoftAP activated.\n\n\nGateway IP address.\n\n\nSubnet mask.\n\n\nSSID for SoftAP.\n\n\nPassword for SoftAP.\n\n\nChannel.\n\n\nHidden attribute.\n\n\nAuto save credential.\n\n\nOffset address of the credentials storage area in EEPROM.\n\n\nLength of start up time after reset.\n\n\nAutomatic starting the captive portal.\n\n\nAuto reset after connection establishment.\n\n\nHome URL of the user sketch application.\n\n\n\n\n Assign user sketch's home path\n\u00b6\n\n\n\"\nHOME\n\" for returning to the user's sketch homepage is displayed at the bottom of the AutoConnect menu. It could be set using the \nAutoConnect::home\n function.\n\n\n\n\n Relocate the AutoConnect home path\n\u00b6\n\n\nA home path of AutoConnect is \n_ac\n by default. You can access from the browser with http://IPADDRESS/_ac. You can change the home path by revising \nAUTOCONNECT_URI\n macro in the include header file as \nAutoConnect.h\n.\n\n\n#define AUTOCONNECT_URI \"/_ac\"",
"title": "Advanced usage"
},
{
@@ -237,7 +237,7 @@
},
{
"location": "/advancedusage/index.html#move-the-saving-area-of-eeprom-for-the-credentials",
- "text": "By default, the credentials saving area is occupied from the beginning of EEPROM. ESP8266 Arduino core document says that: The following diagram illustrates flash layout used in Arduino environment: \n |--------------|-------|---------------|--|--|--|--|--| \n ^ ^ ^ ^ ^ \n Sketch OTA update File system EEPROM WiFi config ( SDK ) and EEPROM library uses one sector of flash located just after the SPIFFS . So in the default state, the credential storage area used by AutoConnect conflicts with data area owned by the user sketch. It will be destroyed together saved data in EEPROM by user sketch and AutoConnect each other. But you can move the storage area to avoid this. The saveOffset in AutoConnectConfig specifies the start offset of the credentials storage area. The default value is 0.",
+ "text": "By default, the credentials saving area is occupied from the beginning of EEPROM. ESP8266 Arduino core document says that: The following diagram illustrates flash layout used in Arduino environment: \n |--------------|-------|---------------|--|--|--|--|--| \n ^ ^ ^ ^ ^ \n Sketch OTA update File system EEPROM WiFi config ( SDK ) and EEPROM library uses one sector of flash located just after the SPIFFS . So in the default state, the credential storage area used by AutoConnect conflicts with data area owned by the user sketch. It will be destroyed together saved data in EEPROM by user sketch and AutoConnect each other. But you can move the storage area to avoid this. The boundaryOffset in AutoConnectConfig specifies the start offset of the credentials storage area. The default value is 0.",
"title": " Move the saving area of EEPROM for the credentials"
},
{
@@ -277,7 +277,7 @@
},
{
"location": "/api/index.html",
- "text": "Include headers\n\u00b6\n\n\n AutoConnect.h\n\u00b6\n\n\n#include\n \n\n\n\n\n\n\nDefine macros\n\u00b6\n\n\n#define AC_DEBUG \n// Monitor message output activation\n\n\n#define AC_DEBUG_PORT Serial \n// Default message output device\n\n\n#define AUTOCONNECT_AP_IP 0x01F4A8C0 \n// Default SoftAP IP\n\n\n#define AUTOCONNECT_AP_GW 0x01F4A8C0 \n// Default SoftAP Gateway IP\n\n\n#define AUTOCONNECT_AP_NM 0x00FFFFFF \n// Default subnet mask\n\n\n#define AUTOCONNECT_DNSPORT 53 \n// Default DNS port at captive portal\n\n\n#define AUTOCONNECT_HTTPPORT 80 \n// Default HTTP\n\n\n#define AUTOCONNECT_MENU_TITLE \"AutoConnect\" \n// Default AutoConnect menu title\n\n\n#define AUTOCONNECT_STARTUPTIME 10 \n// Default waiting time[s] for after reset\n\n\n#define AUTOCONNECT_URI \"/_ac\" \n// Default AutoConnect root path\n\n\n#define AUTOCONNECT_TIMEOUT 30000 \n// Default connection timeout[ms]\n\n\n\n\n\nAutoConnect API\n\u00b6\n\n\n Constructors\n\u00b6\n\n\nAutoConnect\n\u00b6\n\n\nAutoConnect\n()\n\n\n\n\n\nAutoConnect default constructor. This entry activates WebServer internally and the web server is allocated internal.\n\n\nAutoConnect\n(\nESP8266WebServer\n&\n \nwebServer\n)\n\n\n\n\n\nRun the AutoConnect site using the externally ensured ESP 8266 WebServer. User's added URI handler response can be included in handleClient method.\n\n\n \nParameters\n\n \nwebServer\nA reference of ESP8266WebServer instance.\n\n\n\n\n Public member functions\n\u00b6\n\n\nbegin\n\u00b6\n\n\nbool\n \nbegin\n()\n\n\n\n\nbool\n \nbegin\n(\nconst\n \nchar\n*\n \nssid\n,\n \nconst\n \nchar\n*\n \npassphraase\n)\n\n\n\n\nbool\n \nbegin\n(\nconst\n \nchar\n*\n \nssid\n,\n \nconst\n \nchar\n*\n \npassphraase\n,\n \nunsinged\n \nlong\n \ntimeout\n)\n\n\n\n\nStarts establishing WiFi connection. Before establishing, start the Web server and DNS server for the captive portal. Then begins connection establishment in WIFI_STA mode. If connection can not established with the specified SSID and password, switch to WIFI_AP_STA mode and activate SoftAP.\n\n\n \nParameters\n\n \nssid\nSSID to be connected.\n\n \npassphrase\nPassword for connection.\n\n \ntimeout\nA time out value in milliseconds for waiting connection.\n\n \nReturn value\n\n \ntrue\nConnection established, AutoConnect service started with WIFI_STA mode.\n\n \nfalse\nCould not connected, Captive portal started with WIFI_AP_STA mode.\n\n\n\n\nconfig\n\u00b6\n\n\nbool\n \nconfig\n(\nAutoConnectConfig\n&\n \nconfig\n)\n\n\n\n\nbool\n \nconfig\n(\nconst\n \nchar\n*\n \nap\n,\n \nconst\n \nchar\n*\n \npassword\n \n=\n \nnullptr\n)\n\n\n\n\nSets SoftAP's WiFi configuration. \n\n\n \nParameters\n\n \nconfig\nReference to AutoConnectConfig containing SoftAP's parameters.\n\n \nap\nSSID for SoftAP. The default value is \nesp8266ap\n.\n\n \npassword\nPassword for SodtAP. The default value is \n12345678\n.\n\n \nReturn value\n\n \ntrue\nSuccessfully configured.\n\n \nfalse\nConfiguration parameter is invalid, some values out of range.\n\n\n\n\nend\n\u00b6\n\n\nvoid\n \nend\n()\n\n\n\n\n\nStops AutoConnect captive portal service. Release ESP8266WebServer and DNSServer. \n\n\n\n\nAttention to end\n\n\nThe end function releases the instance of ESP8266WebServer and DNSServer. It can not process them after the end function.\n\n\n\n\nhandleClient\n\u00b6\n\n\nvoid\n \nhandleClient\n()\n\n\n\n\n\nHandling for the AutoConnect web interface. Invoke the handleClient of the parent web server to process client request of the AutoConnect WEB interface. No effects when the web server is not available.\n\n\nhandleRequest\n\u00b6\n\n\nvoid\n \nhandleRequest\n()\n\n\n\n\n\nHandling for the AutoConnect menu request.\n\n\n\n\nAbout used in combination with handleClient\n\n\nThe handleRequest function is not supposed to use with AutoConnect::handleClient. It should be used with ESP8266::handleClient.\n\n\n\n\nhome\n\u00b6\n\n\nvoid\n \nhome\n(\nString\n \nuri\n)\n\n\n\n\n\nPut a user site's home URI. The URI specified by home is linked from \"HOME\" in the AutoConnect portal menu.\n\n\n \nParameters\n\n \nuri\n A URI string of user site's home path.\n\n\n\n\nhost\n\u00b6\n\n\nReturns the reference of the ESP8266WebServer which is allocated in AutoConnect automatically.\n\n\nESP8266WebServer\n&\n \nhost\n()\n\n\n\n\n\n \nReturn value\n\n \nA reference of the ESP8266WebServer.\n\n\n\n\n\n\n&reference is not a pointer\n\n\nA reference cannot be re-assigned, and must be assigned at initialization. It's like as bind as alias. \n\n\nESP8266WebServer\n&\n \nserver\n \n=\n \nportal\n.\nhost\n();\n\n\nserver\n.\nhandleClient\n();\n\n\n\nor\n\n\nportal\n.\nhost\n().\nhandleClient\n();\n\n\n\n\n\n\nonDetect\n\u00b6\n\n\nvoid\n \nonDetect\n(\nDetectExit_ft\n \nfn\n)\n\n\n\nRegister the function which will call from AutoConnect at the start of the captive portal.\n\n\n \nParameters\n\n \nfn\nFunction called at the captive portal start.\n\n\n\n\n\nAn \nfn\n specifies the function called when the captive portal starts. Its prototype declaration is defined as \"\nDetectFunc_ft\n\".\n\n\ntypedef\n \nstd\n::\nfunction\n<\nbool\n(\nIPAddress\n \nsoftapIP\n)\n>\n \nDetectExit_ft\n\n\n\n\n\n \nParameters\n\n \nsoftapIP\nAn IP address of SoftAP for the captive portal.\n\n \nRetuen value\n\n \ntrue\nContinues captive portal handling.\n\n \nfalse\nCancel the captive portal. AutoConnect::begin function will return with a false.\n\n\n\n\nonNotFound\n\u00b6\n\n\nvoid\n \nonNotFound\n(\nESP8266WebServer\n::\nTHandlerFunction\n \nfn\n)\n\n\n\nRegister the handler function for undefined URL request detected.\n\n\n \nParameters\n\n \nfn\nA function of the \"not found\" handler.\n\n\n\n\nAutoConnectConfig API\n\u00b6\n\n\n Constructor\n\u00b6\n\n\nAutoConnectConfig\n\u00b6\n\n\nAutoConnectConfig\n();\n\n\n\n\nAutoConnectConfig\n(\nconst\n \nchar\n*\n \nap\n,\n \nconst\n \nchar\n*\n \npassword\n);\n\n\n\n\n\n \nParameters\n\n \nap\nSSID for SoftAP. The length should be up to 31. The default value is \nesp8266ap\n.\n\n \npassword\nPassword for SodtAP. The length should be from 8 to up to 63. The default value is \n12345678\n.\n\n\n\n\n Public member variables\n\u00b6\n\n\napid\n\u00b6\n\n\nSoftAP's SSID.\n\n\n \nType\n\n \nString\n\n\n\n\napip\n\u00b6\n\n\nSets IP address for Soft AP in captive portal. When AutoConnect fails the initial WiFi.begin, it starts the captive portal with the IP address specified this.\n\n\n \nType\n\n \nIPAddress\n\n\n\n\nautoReset\n\u00b6\n\n\nReset ESP8266 module automatically when WLAN disconnected.\n\n\n \nType\n\n \nbool\n\n \nValue\n\n \ntrue\nReset after WiFi disconnected automatically.\n\n \nfalse\nNo reset.\n\n\n\n\nautoRise\n\u00b6\n\n\nCaptive portal activation switch. False for disabling the captive portal. It prevents starting the captive portal even if the connection at the first \nWiFi.begin\n fails.\n\n\n \nType\n\n \nbool\n\n \nValue\n\n \ntrue\nEnable the captive portal. This is a default.\n\n \nfalse\nDisable the captive portal.\n\n\n\n\nautoSave\n\u00b6\n\n\nThe credential saved automatically at the connection establishment.\n\n\n \nType\n\n \nAC_SAVECREDENTIAL_t\n\n \nValue\n\n \nAC_SAVECREDENTIAL_AUTO\nThe credential saved automatically.\n\n \nAC_SAVECREDENTIAL_NEVER\nThe credential no saved.\n\n\n\n\nchannel\n\u00b6\n\n\nThe channel number of WIFi when SoftAP starts.\n\n\n \nType\n\n \nuint8_t\n\n \nValue\n\n \n1 ~ 14. The default value is 1.\n\n\n\n\n\n\nSee Application note\n\n\nEspressif Systems had announced the \napplication note\n about Wi-Fi channel selection.\n\n\n\n\ngateway\n\u00b6\n\n\nSets gateway address for Soft AP in captive portal. When AutoConnect fails the initial WiFi.begin, it starts the captive portal with the IP address specified this.\n\n\n \nType\n\n \nIPAddress\n\n\n\n\nhidden\n\u00b6\n\n\nSets SoftAP to hidden SSID.\n\n\n \nType\n\n \nuint8_t\n\n \nValue\n\n \n0\nSSID will be appeared. This is the default.\n\n \n1\nSSID will be hidden.\n\n\n\n\nhomeUri\n\u00b6\n\n\nSets the home path of user sketch. This path would be linked from 'HOME' in the AutoConnect menu.\n\n\n \nType\n\n \nString\n\n\n\n\nnetmask\n\u00b6\n\n\nSets subnet mask for Soft AP in captive portal. When AutoConnect fails the initial WiFi.begin, it starts the captive portal with the IP address specified this.\n\n\n \nType\n\n \nIPAddress\n\n\n\n\npsk\n\u00b6\n\n\nSets password for SoftAP. The length should be from 8 to up to 63. The default value is \n12345678\n.\n\n\n \nType\n\n \nString\n\n\n\n\nsaveOffset\n\u00b6\n\n\nSets the offset address of the credential storage area for EEPROM. This value must be between greater than 4 and less than flash sector size. (4096 by SDK)\n\nThe default value is 0.\n\n\n \nType\n\n \nuint16_t\n\n\n\n\n\n\nIt will conflict with user data.\n\n\nIf the sketch leaves this offset at zero, it will conflict the storage area of credentials with the user sketch owned data. It needs to use the behind of credential area.\n\n\n\n\n AutoConnectConfig example\n\u00b6\n\n\nAutoConenct\n \nPortal\n;\n\n\nAutoConenctConfig\n \nConfig\n(\n\"\"\n,\n \n\"passpass\"\n);\n \n// SoftAp name is determined at runtime\n\n\nConfig\n.\napid\n \n=\n \nESP\n.\nhostname\n();\n \n// Retrieve host name to SotAp identification\n\n\nConfig\n.\napip\n \n=\n \nIPAddress\n(\n192\n,\n168\n,\n10\n,\n101\n);\n \n// Sets SoftAP IP address\n\n\nConfig\n.\ngateway\n \n=\n \nIPAddress\n(\n192\n,\n168\n,\n10\n,\n1\n);\n \n// Sets WLAN router IP address\n\n\nConfig\n.\nnetmask\n \n=\n \nIPAddress\n(\n255\n,\n255\n,\n255\n,\n0\n);\n \n// Sets WLAN scope\n\n\nConfig\n.\nautoSave\n \n=\n \nAC_SAVECREDENTIAL_NEVER\n;\n \n// No save credential\n\n\nConfig\n.\nhomeUri\n \n=\n \n\"/index.html\"\n \n// Sets home path of the sketch application\n\n\nPortal\n.\nconfig\n(\nConfig\n);\n \n// Configure AutoConnect\n\n\nPortal\n.\nbegin\n();\n \n// Starts and behaves captive portal\n\n\n\n\n\n Something extra\n\u00b6\n\n\nThe library presents two PNG icons which can be used to embed a hyperlink to the AutoConnect menu.\n\n\n\n\nBar type \n\n\nCog type \n\n\n\n\nTo reference the icon, use the \nAUTOCONNECT_LINK\n macro in the sketch. It expands into the string literal as an HTML \n\n tag with PNG embedded of the AutoConnect menu hyperlinks. Icon type is specified by the parameter of the macro.\n\n\n\n \nBAR_32\nBars icon, 32x32.\n\n \nBAR_48\nBars icon, 48x48.\n\n \nCOG_24\nCog icon, 24x24.\n\n \nCOG_32\nCog icon, 32x32.\n\n\n\n\n\n\n\nUsage\n\n\nString\n \nhtml\n \n=\n \n\"\"\n;\n\n\nhtml\n \n+=\n \nAUTOCONNECT_LINK\n(\nBAR_32\n);\n\n\nhtml\n \n+=\n \n\"\"\n;\n\n\nserver\n.\nsend\n(\n200\n,\n \n\"text/html\"\n,\n \nhtml\n);",
+ "text": "Include headers\n\u00b6\n\n\n AutoConnect.h\n\u00b6\n\n\n#include\n \n\n\n\n\n\n\nDefine macros\n\u00b6\n\n\n#define AC_DEBUG \n// Monitor message output activation\n\n\n#define AC_DEBUG_PORT Serial \n// Default message output device\n\n\n#define AUTOCONNECT_AP_IP 0x01F4A8C0 \n// Default SoftAP IP\n\n\n#define AUTOCONNECT_AP_GW 0x01F4A8C0 \n// Default SoftAP Gateway IP\n\n\n#define AUTOCONNECT_AP_NM 0x00FFFFFF \n// Default subnet mask\n\n\n#define AUTOCONNECT_DNSPORT 53 \n// Default DNS port at captive portal\n\n\n#define AUTOCONNECT_HTTPPORT 80 \n// Default HTTP\n\n\n#define AUTOCONNECT_MENU_TITLE \"AutoConnect\" \n// Default AutoConnect menu title\n\n\n#define AUTOCONNECT_STARTUPTIME 10 \n// Default waiting time[s] for after reset\n\n\n#define AUTOCONNECT_URI \"/_ac\" \n// Default AutoConnect root path\n\n\n#define AUTOCONNECT_TIMEOUT 30000 \n// Default connection timeout[ms]\n\n\n\n\n\nAutoConnect API\n\u00b6\n\n\n Constructors\n\u00b6\n\n\nAutoConnect\n\u00b6\n\n\nAutoConnect\n()\n\n\n\n\n\nAutoConnect default constructor. This entry activates WebServer internally and the web server is allocated internal.\n\n\nAutoConnect\n(\nESP8266WebServer\n&\n \nwebServer\n)\n\n\n\n\n\nRun the AutoConnect site using the externally ensured ESP 8266 WebServer. User's added URI handler response can be included in handleClient method.\n\n\n \nParameters\n\n \nwebServer\nA reference of ESP8266WebServer instance.\n\n\n\n\n Public member functions\n\u00b6\n\n\nbegin\n\u00b6\n\n\nbool\n \nbegin\n()\n\n\n\n\nbool\n \nbegin\n(\nconst\n \nchar\n*\n \nssid\n,\n \nconst\n \nchar\n*\n \npassphraase\n)\n\n\n\n\nbool\n \nbegin\n(\nconst\n \nchar\n*\n \nssid\n,\n \nconst\n \nchar\n*\n \npassphraase\n,\n \nunsinged\n \nlong\n \ntimeout\n)\n\n\n\n\nStarts establishing WiFi connection. Before establishing, start the Web server and DNS server for the captive portal. Then begins connection establishment in WIFI_STA mode. If connection can not established with the specified SSID and password, switch to WIFI_AP_STA mode and activate SoftAP.\n\n\n \nParameters\n\n \nssid\nSSID to be connected.\n\n \npassphrase\nPassword for connection.\n\n \ntimeout\nA time out value in milliseconds for waiting connection.\n\n \nReturn value\n\n \ntrue\nConnection established, AutoConnect service started with WIFI_STA mode.\n\n \nfalse\nCould not connected, Captive portal started with WIFI_AP_STA mode.\n\n\n\n\nconfig\n\u00b6\n\n\nbool\n \nconfig\n(\nAutoConnectConfig\n&\n \nconfig\n)\n\n\n\n\nbool\n \nconfig\n(\nconst\n \nchar\n*\n \nap\n,\n \nconst\n \nchar\n*\n \npassword\n \n=\n \nnullptr\n)\n\n\n\n\nSets SoftAP's WiFi configuration. \n\n\n \nParameters\n\n \nconfig\nReference to AutoConnectConfig containing SoftAP's parameters.\n\n \nap\nSSID for SoftAP. The default value is \nesp8266ap\n.\n\n \npassword\nPassword for SodtAP. The default value is \n12345678\n.\n\n \nReturn value\n\n \ntrue\nSuccessfully configured.\n\n \nfalse\nConfiguration parameter is invalid, some values out of range.\n\n\n\n\nend\n\u00b6\n\n\nvoid\n \nend\n()\n\n\n\n\n\nStops AutoConnect captive portal service. Release ESP8266WebServer and DNSServer. \n\n\n\n\nAttention to end\n\n\nThe end function releases the instance of ESP8266WebServer and DNSServer. It can not process them after the end function.\n\n\n\n\nhandleClient\n\u00b6\n\n\nvoid\n \nhandleClient\n()\n\n\n\n\n\nHandling for the AutoConnect web interface. Invoke the handleClient of the parent web server to process client request of the AutoConnect WEB interface. No effects when the web server is not available.\n\n\nhandleRequest\n\u00b6\n\n\nvoid\n \nhandleRequest\n()\n\n\n\n\n\nHandling for the AutoConnect menu request.\n\n\n\n\nAbout used in combination with handleClient\n\n\nThe handleRequest function is not supposed to use with AutoConnect::handleClient. It should be used with ESP8266::handleClient.\n\n\n\n\nhome\n\u00b6\n\n\nvoid\n \nhome\n(\nString\n \nuri\n)\n\n\n\n\n\nPut a user site's home URI. The URI specified by home is linked from \"HOME\" in the AutoConnect portal menu.\n\n\n \nParameters\n\n \nuri\n A URI string of user site's home path.\n\n\n\n\nhost\n\u00b6\n\n\nReturns the reference of the ESP8266WebServer which is allocated in AutoConnect automatically.\n\n\nESP8266WebServer\n&\n \nhost\n()\n\n\n\n\n\n \nReturn value\n\n \nA reference of the ESP8266WebServer.\n\n\n\n\n\n\n&reference is not a pointer\n\n\nA reference cannot be re-assigned, and must be assigned at initialization. It's like as bind as alias. \n\n\nESP8266WebServer\n&\n \nserver\n \n=\n \nportal\n.\nhost\n();\n\n\nserver\n.\nhandleClient\n();\n\n\n\nor\n\n\nportal\n.\nhost\n().\nhandleClient\n();\n\n\n\n\n\n\nonDetect\n\u00b6\n\n\nvoid\n \nonDetect\n(\nDetectExit_ft\n \nfn\n)\n\n\n\nRegister the function which will call from AutoConnect at the start of the captive portal.\n\n\n \nParameters\n\n \nfn\nFunction called at the captive portal start.\n\n\n\n\n\nAn \nfn\n specifies the function called when the captive portal starts. Its prototype declaration is defined as \"\nDetectFunc_ft\n\".\n\n\ntypedef\n \nstd\n::\nfunction\n<\nbool\n(\nIPAddress\n \nsoftapIP\n)\n>\n \nDetectExit_ft\n\n\n\n\n\n \nParameters\n\n \nsoftapIP\nAn IP address of SoftAP for the captive portal.\n\n \nRetuen value\n\n \ntrue\nContinues captive portal handling.\n\n \nfalse\nCancel the captive portal. AutoConnect::begin function will return with a false.\n\n\n\n\nonNotFound\n\u00b6\n\n\nvoid\n \nonNotFound\n(\nESP8266WebServer\n::\nTHandlerFunction\n \nfn\n)\n\n\n\nRegister the handler function for undefined URL request detected.\n\n\n \nParameters\n\n \nfn\nA function of the \"not found\" handler.\n\n\n\n\nAutoConnectConfig API\n\u00b6\n\n\n Constructor\n\u00b6\n\n\nAutoConnectConfig\n\u00b6\n\n\nAutoConnectConfig\n();\n\n\n\n\nAutoConnectConfig\n(\nconst\n \nchar\n*\n \nap\n,\n \nconst\n \nchar\n*\n \npassword\n);\n\n\n\n\n\n \nParameters\n\n \nap\nSSID for SoftAP. The length should be up to 31. The default value is \nesp8266ap\n.\n\n \npassword\nPassword for SodtAP. The length should be from 8 to up to 63. The default value is \n12345678\n.\n\n\n\n\n Public member variables\n\u00b6\n\n\napid\n\u00b6\n\n\nSoftAP's SSID.\n\n\n \nType\n\n \nString\n\n\n\n\napip\n\u00b6\n\n\nSets IP address for Soft AP in captive portal. When AutoConnect fails the initial WiFi.begin, it starts the captive portal with the IP address specified this.\n\n\n \nType\n\n \nIPAddress\n\n\n\n\nautoReset\n\u00b6\n\n\nReset ESP8266 module automatically when WLAN disconnected.\n\n\n \nType\n\n \nbool\n\n \nValue\n\n \ntrue\nReset after WiFi disconnected automatically.\n\n \nfalse\nNo reset.\n\n\n\n\nautoRise\n\u00b6\n\n\nCaptive portal activation switch. False for disabling the captive portal. It prevents starting the captive portal even if the connection at the first \nWiFi.begin\n fails.\n\n\n \nType\n\n \nbool\n\n \nValue\n\n \ntrue\nEnable the captive portal. This is the default.\n\n \nfalse\nDisable the captive portal.\n\n\n\n\nautoSave\n\u00b6\n\n\nThe credential saved automatically at the connection establishment.\n\n\n \nType\n\n \nAC_SAVECREDENTIAL_t\n\n \nValue\n\n \nAC_SAVECREDENTIAL_AUTO\nThe credential saved automatically.\n\n \nAC_SAVECREDENTIAL_NEVER\nThe credential no saved.\n\n\n\n\nboundaryOffset\n\u00b6\n\n\nSets the offset address of the credential storage area for EEPROM. This value must be between greater than 4 and less than flash sector size. (4096 by SDK)\n\nThe default value is 0.\n\n\n \nType\n\n \nuint16_t\n\n\n\n\n\n\nIt will conflict with user data.\n\n\nIf the sketch leaves this offset at zero, it will conflict the storage area of credentials with the user sketch owned data. It needs to use the behind of credential area.\n\n\n\n\nchannel\n\u00b6\n\n\nThe channel number of WIFi when SoftAP starts.\n\n\n \nType\n\n \nuint8_t\n\n \nValue\n\n \n1 ~ 14. The default value is 1.\n\n\n\n\n\n\nSee Application note\n\n\nEspressif Systems had announced the \napplication note\n about Wi-Fi channel selection.\n\n\n\n\ngateway\n\u00b6\n\n\nSets gateway address for Soft AP in captive portal. When AutoConnect fails the initial WiFi.begin, it starts the captive portal with the IP address specified this.\n\n\n \nType\n\n \nIPAddress\n\n\n\n\nhidden\n\u00b6\n\n\nSets SoftAP to hidden SSID.\n\n\n \nType\n\n \nuint8_t\n\n \nValue\n\n \n0\nSSID will be appeared. This is the default.\n\n \n1\nSSID will be hidden.\n\n\n\n\nhomeUri\n\u00b6\n\n\nSets the home path of user sketch. This path would be linked from 'HOME' in the AutoConnect menu.\n\n\n \nType\n\n \nString\n\n\n\n\nnetmask\n\u00b6\n\n\nSets subnet mask for Soft AP in captive portal. When AutoConnect fails the initial WiFi.begin, it starts the captive portal with the IP address specified this.\n\n\n \nType\n\n \nIPAddress\n\n\n\n\npsk\n\u00b6\n\n\nSets password for SoftAP. The length should be from 8 to up to 63. The default value is \n12345678\n.\n\n\n \nType\n\n \nString\n\n\n\n\n AutoConnectConfig example\n\u00b6\n\n\nAutoConenct\n \nPortal\n;\n\n\nAutoConenctConfig\n \nConfig\n(\n\"\"\n,\n \n\"passpass\"\n);\n \n// SoftAp name is determined at runtime\n\n\nConfig\n.\napid\n \n=\n \nESP\n.\nhostname\n();\n \n// Retrieve host name to SotAp identification\n\n\nConfig\n.\napip\n \n=\n \nIPAddress\n(\n192\n,\n168\n,\n10\n,\n101\n);\n \n// Sets SoftAP IP address\n\n\nConfig\n.\ngateway\n \n=\n \nIPAddress\n(\n192\n,\n168\n,\n10\n,\n1\n);\n \n// Sets WLAN router IP address\n\n\nConfig\n.\nnetmask\n \n=\n \nIPAddress\n(\n255\n,\n255\n,\n255\n,\n0\n);\n \n// Sets WLAN scope\n\n\nConfig\n.\nautoSave\n \n=\n \nAC_SAVECREDENTIAL_NEVER\n;\n \n// No save credential\n\n\nCOnfig\n.\nboundaryOffet\n \n=\n \n64\n;\n \n// Reserve 64 bytes for the user data in EEPROM. \n\n\nConfig\n.\nhomeUri\n \n=\n \n\"/index.html\"\n \n// Sets home path of the sketch application\n\n\nPortal\n.\nconfig\n(\nConfig\n);\n \n// Configure AutoConnect\n\n\nPortal\n.\nbegin\n();\n \n// Starts and behaves captive portal\n\n\n\n\n\n Something extra\n\u00b6\n\n\nThe library presents two PNG icons which can be used to embed a hyperlink to the AutoConnect menu.\n\n\n\n\nBar type \n\n\nCog type \n\n\n\n\nTo reference the icon, use the \nAUTOCONNECT_LINK\n macro in the sketch. It expands into the string literal as an HTML \n\n tag with PNG embedded of the AutoConnect menu hyperlinks. Icon type is specified by the parameter of the macro.\n\n\n\n \nBAR_32\nBars icon, 32x32.\n\n \nBAR_48\nBars icon, 48x48.\n\n \nCOG_24\nCog icon, 24x24.\n\n \nCOG_32\nCog icon, 32x32.\n\n\n\n\n\n\n\nUsage\n\n\nString\n \nhtml\n \n=\n \n\"\"\n;\n\n\nhtml\n \n+=\n \nAUTOCONNECT_LINK\n(\nBAR_32\n);\n\n\nhtml\n \n+=\n \n\"\"\n;\n\n\nserver\n.\nsend\n(\n200\n,\n \n\"text/html\"\n,\n \nhtml\n);",
"title": "Library APIs"
},
{
@@ -397,7 +397,7 @@
},
{
"location": "/api/index.html#autorise",
- "text": "Captive portal activation switch. False for disabling the captive portal. It prevents starting the captive portal even if the connection at the first WiFi.begin fails. \n Type \n bool \n Value \n true Enable the captive portal. This is a default. \n false Disable the captive portal.",
+ "text": "Captive portal activation switch. False for disabling the captive portal. It prevents starting the captive portal even if the connection at the first WiFi.begin fails. \n Type \n bool \n Value \n true Enable the captive portal. This is the default. \n false Disable the captive portal.",
"title": "autoRise"
},
{
@@ -405,6 +405,11 @@
"text": "The credential saved automatically at the connection establishment. \n Type \n AC_SAVECREDENTIAL_t \n Value \n AC_SAVECREDENTIAL_AUTO The credential saved automatically. \n AC_SAVECREDENTIAL_NEVER The credential no saved.",
"title": "autoSave"
},
+ {
+ "location": "/api/index.html#boundaryoffset",
+ "text": "Sets the offset address of the credential storage area for EEPROM. This value must be between greater than 4 and less than flash sector size. (4096 by SDK) \nThe default value is 0. \n Type \n uint16_t It will conflict with user data. If the sketch leaves this offset at zero, it will conflict the storage area of credentials with the user sketch owned data. It needs to use the behind of credential area.",
+ "title": "boundaryOffset"
+ },
{
"location": "/api/index.html#channel",
"text": "The channel number of WIFi when SoftAP starts. \n Type \n uint8_t \n Value \n 1 ~ 14. The default value is 1. See Application note Espressif Systems had announced the application note about Wi-Fi channel selection.",
@@ -435,14 +440,9 @@
"text": "Sets password for SoftAP. The length should be from 8 to up to 63. The default value is 12345678 . \n Type \n String",
"title": "psk"
},
- {
- "location": "/api/index.html#saveoffset",
- "text": "Sets the offset address of the credential storage area for EEPROM. This value must be between greater than 4 and less than flash sector size. (4096 by SDK) \nThe default value is 0. \n Type \n uint16_t It will conflict with user data. If the sketch leaves this offset at zero, it will conflict the storage area of credentials with the user sketch owned data. It needs to use the behind of credential area.",
- "title": "saveOffset"
- },
{
"location": "/api/index.html#autoconnectconfig-example",
- "text": "AutoConenct Portal ; AutoConenctConfig Config ( \"\" , \"passpass\" ); // SoftAp name is determined at runtime Config . apid = ESP . hostname (); // Retrieve host name to SotAp identification Config . apip = IPAddress ( 192 , 168 , 10 , 101 ); // Sets SoftAP IP address Config . gateway = IPAddress ( 192 , 168 , 10 , 1 ); // Sets WLAN router IP address Config . netmask = IPAddress ( 255 , 255 , 255 , 0 ); // Sets WLAN scope Config . autoSave = AC_SAVECREDENTIAL_NEVER ; // No save credential Config . homeUri = \"/index.html\" // Sets home path of the sketch application Portal . config ( Config ); // Configure AutoConnect Portal . begin (); // Starts and behaves captive portal",
+ "text": "AutoConenct Portal ; AutoConenctConfig Config ( \"\" , \"passpass\" ); // SoftAp name is determined at runtime Config . apid = ESP . hostname (); // Retrieve host name to SotAp identification Config . apip = IPAddress ( 192 , 168 , 10 , 101 ); // Sets SoftAP IP address Config . gateway = IPAddress ( 192 , 168 , 10 , 1 ); // Sets WLAN router IP address Config . netmask = IPAddress ( 255 , 255 , 255 , 0 ); // Sets WLAN scope Config . autoSave = AC_SAVECREDENTIAL_NEVER ; // No save credential COnfig . boundaryOffet = 64 ; // Reserve 64 bytes for the user data in EEPROM. Config . homeUri = \"/index.html\" // Sets home path of the sketch application Portal . config ( Config ); // Configure AutoConnect Portal . begin (); // Starts and behaves captive portal",
"title": " AutoConnectConfig example"
},
{
@@ -452,7 +452,7 @@
},
{
"location": "/examples/index.html",
- "text": "How to embed the AutoConnect\n\u00b6\n\n\nHere holds two case examples. Both examples perform the same function. Only how to incorporate the \nAutoConnect\n into the sketch differs. Also included in the sample folder, HandlePortal.ino also shows how to use the \nPageBuilder\n library for HTML assemblies.\n\n\nWhat does this example do?\n\u00b6\n\n\nUses the web interface to light the LED connected to the \nNodeMCU\n module D0 port (which could be referred to as \nBUILTIN_LED\n), the following animation is it.\n\n\nAccess to the ESP8266 module connected WiFi from the browser then the page contains the current value of the D0 port would be displayed. The page has the buttons to switch the port value. The LED blinks according to the value of the button that was clicked. This example is a typical sketch of manipulating ESP8266's GPIO via WLN.\n\n\n\n\nEmbed AutoConnect library into this sketch. There are few places to be changed. And you can use AutoConnect's captive portal function to establish a connection freely to other WiFi spots.\n\n\nEmbed AutoConnect\n\u00b6\n\n\n Pattern A.\n\u00b6\n\n\nBind to ESP8266WebServer, performs handleClient with handleRequest.\n\n\n\n\n\n\nIn what situations should the handleRequest be used.\n\n\nIt is something needs to be done immediately after the handle client. It is better to call only AutoConnect::handleClient whenever possible.\n\n\n\n\n Pattern B.\n\u00b6\n\n\nDeclare only AutoConnect, performs handleClient.\n\n\n\n\n\n window.onload = function() {\n Gifffer();\n }",
+ "text": "How to embed the AutoConnect\n\u00b6\n\n\nHere holds two case examples. Both examples perform the same function. Only how to incorporate the \nAutoConnect\n into the sketch differs. Also included in the sample folder, HandlePortal.ino also shows how to use the \nPageBuilder\n library for HTML assemblies.\n\n\nWhat does this example do?\n\u00b6\n\n\nUses the web interface to light the LED connected to the \nNodeMCU\n module D0 port (which could be referred to as \nBUILTIN_LED\n), the following animation is it.\n\n\nAccess to the ESP8266 module connected WiFi from the browser then the page contains the current value of the D0 port would be displayed. The page has the buttons to switch the port value. The LED blinks according to the value of the button that was clicked. This example is a typical sketch of manipulating ESP8266's GPIO via WLAN.\n\n\n\n\nEmbed AutoConnect library into this sketch. There are few places to be changed. And you can use AutoConnect's captive portal function to establish a connection freely to other WiFi spots.\n\n\nEmbed AutoConnect\n\u00b6\n\n\n Pattern A.\n\u00b6\n\n\nBind to ESP8266WebServer, performs handleClient with handleRequest.\n\n\n\n\n\n\nIn what situations should the handleRequest be used.\n\n\nIt is something needs to be done immediately after the handle client. It is better to call only AutoConnect::handleClient whenever possible.\n\n\n\n\n Pattern B.\n\u00b6\n\n\nDeclare only AutoConnect, performs handleClient.\n\n\n\n\n\n window.onload = function() {\n Gifffer();\n }",
"title": "Examples"
},
{
@@ -462,7 +462,7 @@
},
{
"location": "/examples/index.html#what-does-this-example-do",
- "text": "Uses the web interface to light the LED connected to the NodeMCU module D0 port (which could be referred to as BUILTIN_LED ), the following animation is it. Access to the ESP8266 module connected WiFi from the browser then the page contains the current value of the D0 port would be displayed. The page has the buttons to switch the port value. The LED blinks according to the value of the button that was clicked. This example is a typical sketch of manipulating ESP8266's GPIO via WLN. Embed AutoConnect library into this sketch. There are few places to be changed. And you can use AutoConnect's captive portal function to establish a connection freely to other WiFi spots.",
+ "text": "Uses the web interface to light the LED connected to the NodeMCU module D0 port (which could be referred to as BUILTIN_LED ), the following animation is it. Access to the ESP8266 module connected WiFi from the browser then the page contains the current value of the D0 port would be displayed. The page has the buttons to switch the port value. The LED blinks according to the value of the button that was clicked. This example is a typical sketch of manipulating ESP8266's GPIO via WLAN. Embed AutoConnect library into this sketch. There are few places to be changed. And you can use AutoConnect's captive portal function to establish a connection freely to other WiFi spots.",
"title": "What does this example do?"
},
{
@@ -482,7 +482,7 @@
},
{
"location": "/faq/index.html",
- "text": "After connected, AutoConnect menu performs but no happens.\n\u00b6\n\n\nIf you can access the \nAutoConnect root path\n as http://ESP8266IPADDRESS/_ac from browser, probably the sketch uses \nESP8266WebServer::handleClient()\n without \nAutoConnect::handleRequest()\n.\n\nFor AutoConnect menus to work properly, call \nAutoConnect::handleRequest()\n after \nESP8266WebServer::handleClient()\n invoked, or use \nAutoConnect::handleClient()\n. \nAutoConnect::handleClient()\n is equivalent \nESP8266WebServer::handleClient\n combinated \nAutoConnect::handleRequest()\n.\n\n\n An esp8266ap as SoftAP was connected but Captive portal does not start.\n\u00b6\n\n\nCaptive portal detection could not be trapped. It is necessary to disconnect and reset ESP8266 to clear memorized connection data in ESP8266. Also, It may be displayed on the smartphone if the connection information of esp8266ap is wrong. In that case, delete the connection information of esp8266ap memorized by the smartphone once.\n\n\n Does not appear esp8266ap in smartphone.\n\u00b6\n\n\nMaybe it is successfully connected at the \nfirst WiFi.begin\n. ESP8266 remembers the SSID successfully connected and will use at the next. It means SoftAP will only start up when the first \nWiFi.begin()\n fails.\n\n\nThe saved SSID would be cleared by \nWiFi.disconnect()\n with WIFI_STA mode. If you do not want automatic reconnection, you can erase the memorized SSID with the following simple sketch.\n\n\n#include\n \n\n\n\n\nvoid\n \nsetup\n()\n \n{\n\n \ndelay\n(\n1000\n);\n\n \nSerial\n.\nbegin\n(\n115200\n);\n\n \nWiFi\n.\nmode\n(\nWIFI_STA\n);\n\n \ndelay\n(\n100\n);\n\n \nWiFi\n.\nbegin\n();\n\n \nif\n \n(\nWiFi\n.\nwaitForConnectResult\n()\n \n==\n \nWL_CONNECTED\n)\n \n{\n\n \nWiFi\n.\ndisconnect\n();\n\n \nwhile\n \n(\nWiFi\n.\nstatus\n()\n \n==\n \nWL_CONNECTED\n)\n\n \ndelay\n(\n100\n);\n\n \n}\n\n \nSerial\n.\nprintln\n(\n\"WiFi disconnected.\"\n);\n\n\n}\n\n\n\nvoid\n \nloop\n()\n \n{\n\n \ndelay\n(\n1000\n);\n\n\n}\n\n\n\n\n\nYou can interactively check the WiFi state of ESP8266.\nPlease try \nESPShaker\n. It is ESP8266 interactive serial command processor.\n Does not response from _ac.\n\u00b6\n\n\nProbably \nWiFi.begin\n failed with the specified SSID. Activating the \ndebug printing\n will help you to track down the cause.\n\n\n How change esp8266ap for SSID name in Captive portal?\n\u00b6\n\n\nAn \nesp8266\n is default SSID name for SoftAP of captive portal and password is \n12345678\n. You can change both by using \nAutoConnectConfig\n.\n\n\n Hang up after Reset?\n\u00b6\n\n\nIf ESP8266 hang up after reset by AutoConnect menu, perhaps manual reset is not yet. Especially if it is not manual reset yet after uploading the sketch, the boot mode will stay 'Uart Download'. There is some discussion about this on the Github's ESP8266 core: \nhttps://github.com/esp8266/Arduino/issues/1017\n\n\nIf you received the following message, the boot mode is still sketch uploaded. It needs to the manual reset once.\n\n\nets Jan 8 2013,rst cause:2, boot mode:(1,6) or (1,7)\nets Jan 8 2013,rst cause:4, boot mode:(1,6) or (1,7)\nwdt reset\n\n\n\n\nThe correct boot mode for starting the sketch is \n(3, x)\n.\n\n\n How erase the credentials saved in EEPROM?\n\u00b6\n\n\nMake some sketches for erasing the EEPROM area, or some erasing utility is needed. You can prepare the sketch to erase the saved credential with \nAutoConnectCredential\n. The \nAutoConnectCrendential\n class provides the access method to the saved credential in EEPROM and library source file is including it.\n\n\nA class description of AutoConnectCredential is follows.\n\n\nConstructor\n\u00b6\n\n\n#include\n \n\n\n\n\nAutoConnectCredential\n();\n\n\n\n\n\nPublic member functions\n\u00b6\n\n\n\n\n\n\nuint8_t \nentries()\n\n Returns number of entries as contained credentials.\n\n\n\n\n\n\nint8_t \nload(const char* \nssid\n, struct station_config* \nconfig\n)\n\n Load a credential entry specified \nssid\n to \nconfig\n. Returns -1 as unsuccessfully loaded.\n\n\n\n\n\n\nbool \nload(int8_t \nentry\n, struct station_config* \nconfig\n)\n\n Load a credential entry to \nconfig\n. The \nentry\n parameter specify to index of the entry.\n\n\n\n\n\n\nbool \nsave(const struct station_config* \nconfig\n)\n\n Save a credential entry stored in \nconfig\n to EEPROM. Returns the true as succeeded.\n\n\n\n\n\n\nbool \ndel(const char* \nssid\n)\n\n Delete a credential entry specified \nssid\n. Returns the true as successfully deleted.\n\n\n\n\n\n\nData structures\n\u00b6\n\n\n\n\nstation_config\n\n A structure is included in the ESP8266 SDK. You can use it in the sketch like as follows.\n\n\n\n\nextern\n \n\"C\"\n \n{\n\n\n#include\n \n\n\n\n}\n\n\n\n\n\nstruct\n \nstation_config\n \n{\n\n \nuint8\n \nssid\n[\n32\n];\n\n \nuint8\n \npassword\n[\n64\n];\n\n \nuint8\n \nbssid_set\n;\n\n \nuint8\n \nbssid\n[\n6\n];\n\n\n};\n\n\n\n\n\n\n\nEEPROM data structure\n\n A data structure of the credential saving area in EEPROM as the below. \n1\n\n\n\n\n\n\n\n\n\n\nByte offset\n\n\nLength\n\n\nValue\n\n\n\n\n\n\n\n\n\n\n0\n\n\n8\n\n\nAC_CREDT\n\n\n\n\n\n\n8\n\n\n1\n\n\nNumber of contained entries (uint8_t)\n\n\n\n\n\n\n9\n\n\n2\n\n\nContainer size, excluding size of AC_CREDT and size of the number of entries(width for uint16_t type).\n\n\n\n\n\n\n11\n\n\nvariable\n\n\nSSID terminated by 0x00. Max length is 32 bytes.\n\n\n\n\n\n\nvariable\n\n\nvariable\n\n\nPassword plain text terminated by 0x00. Max length is 64 bytes.\n\n\n\n\n\n\nvariable\n\n\n6\n\n\nBSSID\n\n\n\n\n\n\nvariable\n\n\n\n\nContained the next entries. (Continuation SSID+Password+BSSID)\n\n\n\n\n\n\nvariable\n\n\n1\n\n\n0x00. End of container.\n\n\n\n\n\n\n\n\n\n\nHint\n\n\nWith the \nESPShaker\n, you can access EEPROM interactively from the serial monitor, and of course you can erase saved credentials.\n\n\n\n\n How locate the link button to the AutoConnect menu?\n\u00b6\n\n\nLink button to AutoConnect menu can be embedded into Sketch's web page. The root path of the menu is \n/_ac\n by default and embed the following \n\n tag in the generating HTML.\n\n\n<\na\n \nstyle\n=\n\"background-color:SteelBlue; display:inline-block; padding:7px 13px; text-decoration:none;\"\n \nhref\n=\n\"/_ac\"\n>\nMENU\n\na\n>\n\n\n\n\n\n How much memory consumption is AutoConnect?\n\u00b6\n\n\nSketch size\n\u00b6\n\n\nIt increases about 53K bytes compared to the case without AutoConnect. A sketch size of the most simple example introduced at the Getting started is about 330K bytes. (270K byte without AutoConnect)\n\n\nHeap size\n\u00b6\n\n\nIt consumes about 2K bytes in the static and about 12K bytes are consumed at the moment when menu executed.\n\n\n I cannot complete to Wi-Fi login from smartphone.\n\u00b6\n\n\nBecause AutoConnect does not send a login success response to the captive portal requests from the smartphone. The login success response varies iOS, Android and Windows. By analyzing the request URL of different login success inquiries for each OS, the correct behavior can be implemented, but not yet. Please resets ESP8266 from the AutoConnect menu.\n\n\n\n\n\n\n\n\n\n\nThere may be 0xff as an invalid data in the credential saving area. The 0xff area would be reused.\u00a0\n\u21a9",
+ "text": "After connected, AutoConnect menu performs but no happens.\n\u00b6\n\n\nIf you can access the \nAutoConnect root path\n as http://ESP8266IPADDRESS/_ac from browser, probably the sketch uses \nESP8266WebServer::handleClient()\n without \nAutoConnect::handleRequest()\n.\n\nFor AutoConnect menus to work properly, call \nAutoConnect::handleRequest()\n after \nESP8266WebServer::handleClient()\n invoked, or use \nAutoConnect::handleClient()\n. \nAutoConnect::handleClient()\n is equivalent \nESP8266WebServer::handleClient\n combinated \nAutoConnect::handleRequest()\n.\n\n\n An esp8266ap as SoftAP was connected but Captive portal does not start.\n\u00b6\n\n\nCaptive portal detection could not be trapped. It is necessary to disconnect and reset ESP8266 to clear memorized connection data in ESP8266. Also, It may be displayed on the smartphone if the connection information of esp8266ap is wrong. In that case, delete the connection information of esp8266ap memorized by the smartphone once.\n\n\n Does not appear esp8266ap in smartphone.\n\u00b6\n\n\nMaybe it is successfully connected at the \nfirst WiFi.begin\n. ESP8266 remembers the SSID successfully connected and will use at the next. It means SoftAP will only start up when the first \nWiFi.begin()\n fails.\n\n\nThe saved SSID would be cleared by \nWiFi.disconnect()\n with WIFI_STA mode. If you do not want automatic reconnection, you can erase the memorized SSID with the following simple sketch.\n\n\n#include\n \n\n\n\n\nvoid\n \nsetup\n()\n \n{\n\n \ndelay\n(\n1000\n);\n\n \nSerial\n.\nbegin\n(\n115200\n);\n\n \nWiFi\n.\nmode\n(\nWIFI_STA\n);\n\n \ndelay\n(\n100\n);\n\n \nWiFi\n.\nbegin\n();\n\n \nif\n \n(\nWiFi\n.\nwaitForConnectResult\n()\n \n==\n \nWL_CONNECTED\n)\n \n{\n\n \nWiFi\n.\ndisconnect\n();\n\n \nwhile\n \n(\nWiFi\n.\nstatus\n()\n \n==\n \nWL_CONNECTED\n)\n\n \ndelay\n(\n100\n);\n\n \n}\n\n \nSerial\n.\nprintln\n(\n\"WiFi disconnected.\"\n);\n\n\n}\n\n\n\nvoid\n \nloop\n()\n \n{\n\n \ndelay\n(\n1000\n);\n\n\n}\n\n\n\n\n\nYou can interactively check the WiFi state of ESP8266.\nPlease try \nESPShaker\n. It is ESP8266 interactive serial command processor.\n Does not response from _ac.\n\u00b6\n\n\nProbably \nWiFi.begin\n failed with the specified SSID. Activating the \ndebug printing\n will help you to track down the cause.\n\n\n How change esp8266ap for SSID name in Captive portal?\n\u00b6\n\n\nAn \nesp8266\n is default SSID name for SoftAP of captive portal and password is \n12345678\n. You can change both by using \nAutoConnectConfig\n.\n\n\n Hang up after Reset?\n\u00b6\n\n\nIf ESP8266 hang up after reset by AutoConnect menu, perhaps manual reset is not yet. Especially if it is not manual reset yet after uploading the sketch, the boot mode will stay 'Uart Download'. There is some discussion about this on the Github's ESP8266 core: \nhttps://github.com/esp8266/Arduino/issues/1017\n\n\nIf you received the following message, the boot mode is still sketch uploaded. It needs to the manual reset once.\n\n\nets Jan 8 2013,rst cause:2, boot mode:(1,6) or (1,7)\nets Jan 8 2013,rst cause:4, boot mode:(1,6) or (1,7)\nwdt reset\n\n\n\n\nThe correct boot mode for starting the sketch is \n(3, x)\n.\n\n\n How erase the credentials saved in EEPROM?\n\u00b6\n\n\nMake some sketches for erasing the EEPROM area, or some erasing utility is needed. You can prepare the sketch to erase the saved credential with \nAutoConnectCredential\n. The \nAutoConnectCrendential\n class provides the access method to the saved credential in EEPROM and library source file is including it.\n\n\nA class description of AutoConnectCredential is follows.\n\n\nInclude header\n\u00b6\n\n\n#include\n \n\n\n\n\n\n\nConstructor\n\u00b6\n\n\nAutoConnectCredential\n();\n\n\n\n\n\nAutoConnectCredential default constructor. The default offset value is 0. If the offset value is 0, the credential storage area starts from the top of the EEPROM. AutoConnect sometimes overwrites data when using this area with user sketch.\n\n\nAutoConnectCredential\n(\nuint16_t\n \noffset\n);\n\n\n\n\n\nSpecify offset from the top of the EEPROM for the credential storage area together. The offset value is from 0 to the flash sector size.\n\n\nPublic member functions\n\u00b6\n\n\n\n\n\n\nuint8_t \nentries()\n\n Returns number of entries as contained credentials.\n\n\n\n\n\n\nint8_t \nload(const char* \nssid\n, struct station_config* \nconfig\n)\n\n Load a credential entry specified \nssid\n to \nconfig\n. Returns -1 as unsuccessfully loaded.\n\n\n\n\n\n\nbool \nload(int8_t \nentry\n, struct station_config* \nconfig\n)\n\n Load a credential entry to \nconfig\n. The \nentry\n parameter specify to index of the entry.\n\n\n\n\n\n\nbool \nsave(const struct station_config* \nconfig\n)\n\n Save a credential entry stored in \nconfig\n to EEPROM. Returns the true as succeeded.\n\n\n\n\n\n\nbool \ndel(const char* \nssid\n)\n\n Delete a credential entry specified \nssid\n. Returns the true as successfully deleted.\n\n\n\n\n\n\nData structures\n\u00b6\n\n\n\n\nstation_config\n\n A structure is included in the ESP8266 SDK. You can use it in the sketch like as follows.\n\n\n\n\nextern\n \n\"C\"\n \n{\n\n\n#include\n \n\n\n\n}\n\n\n\n\n\nstruct\n \nstation_config\n \n{\n\n \nuint8\n \nssid\n[\n32\n];\n\n \nuint8\n \npassword\n[\n64\n];\n\n \nuint8\n \nbssid_set\n;\n\n \nuint8\n \nbssid\n[\n6\n];\n\n\n};\n\n\n\n\n\n\n\nEEPROM data structure\n\n A data structure of the credential saving area in EEPROM as the below. \n1\n\n\n\n\n\n\n\n\n\n\nByte offset\n\n\nLength\n\n\nValue\n\n\n\n\n\n\n\n\n\n\n0\n\n\n8\n\n\nAC_CREDT\n\n\n\n\n\n\n8\n\n\n1\n\n\nNumber of contained entries (uint8_t)\n\n\n\n\n\n\n9\n\n\n2\n\n\nContainer size, excluding size of AC_CREDT and size of the number of entries(width for uint16_t type).\n\n\n\n\n\n\n11\n\n\nvariable\n\n\nSSID terminated by 0x00. Max length is 32 bytes.\n\n\n\n\n\n\nvariable\n\n\nvariable\n\n\nPassword plain text terminated by 0x00. Max length is 64 bytes.\n\n\n\n\n\n\nvariable\n\n\n6\n\n\nBSSID\n\n\n\n\n\n\nvariable\n\n\n\n\nContained the next entries. (Continuation SSID+Password+BSSID)\n\n\n\n\n\n\nvariable\n\n\n1\n\n\n0x00. End of container.\n\n\n\n\n\n\n\n\n\n\nHint\n\n\nWith the \nESPShaker\n, you can access EEPROM interactively from the serial monitor, and of course you can erase saved credentials.\n\n\n\n\n How locate the link button to the AutoConnect menu?\n\u00b6\n\n\nLink button to AutoConnect menu can be embedded into Sketch's web page. The root path of the menu is \n/_ac\n by default and embed the following \n\n tag in the generating HTML.\n\n\n<\na\n \nstyle\n=\n\"background-color:SteelBlue; display:inline-block; padding:7px 13px; text-decoration:none;\"\n \nhref\n=\n\"/_ac\"\n>\nMENU\n\na\n>\n\n\n\n\n\n How much memory consumption is AutoConnect?\n\u00b6\n\n\nSketch size\n\u00b6\n\n\nIt increases about 53K bytes compared to the case without AutoConnect. A sketch size of the most simple example introduced at the Getting started is about 330K bytes. (270K byte without AutoConnect)\n\n\nHeap size\n\u00b6\n\n\nIt consumes about 2K bytes in the static and about 12K bytes are consumed at the moment when menu executed.\n\n\n I cannot complete to Wi-Fi login from smartphone.\n\u00b6\n\n\nBecause AutoConnect does not send a login success response to the captive portal requests from the smartphone. The login success response varies iOS, Android and Windows. By analyzing the request URL of different login success inquiries for each OS, the correct behavior can be implemented, but not yet. Please resets ESP8266 from the AutoConnect menu.\n\n\n\n\n\n\n\n\n\n\nThere may be 0xff as an invalid data in the credential saving area. The 0xff area would be reused.\u00a0\n\u21a9",
"title": "FAQ"
},
{
@@ -520,9 +520,14 @@
"text": "Make some sketches for erasing the EEPROM area, or some erasing utility is needed. You can prepare the sketch to erase the saved credential with AutoConnectCredential . The AutoConnectCrendential class provides the access method to the saved credential in EEPROM and library source file is including it. A class description of AutoConnectCredential is follows.",
"title": " How erase the credentials saved in EEPROM?"
},
+ {
+ "location": "/faq/index.html#include-header",
+ "text": "#include ",
+ "title": "Include header"
+ },
{
"location": "/faq/index.html#constructor",
- "text": "#include AutoConnectCredential ();",
+ "text": "AutoConnectCredential (); AutoConnectCredential default constructor. The default offset value is 0. If the offset value is 0, the credential storage area starts from the top of the EEPROM. AutoConnect sometimes overwrites data when using this area with user sketch. AutoConnectCredential ( uint16_t offset ); Specify offset from the top of the EEPROM for the credential storage area together. The offset value is from 0 to the flash sector size.",
"title": "Constructor"
},
{
diff --git a/examples/Credential/Credential.ino b/examples/Credential/Credential.ino
index 7b5b6ae..347e300 100644
--- a/examples/Credential/Credential.ino
+++ b/examples/Credential/Credential.ino
@@ -23,6 +23,10 @@ AutoConnect Portal(Server);
String viewCredential(PageArgument&);
String delCredential(PageArgument&);
+// Specified the offset if the user data exists.
+//#define CREDENTIAL_OFFSET 0
+#define CREDENTIAL_OFFSET 64
+
/**
* An HTML for the operation page.
* In PageBuilder, the token {{SSID}} contained in an HTML template below is
@@ -81,7 +85,7 @@ PageBuilder delPage("/del", { elmDel });
// Retrieve the credential entries from EEPROM, Build the SSID line
// with the
- tag.
String viewCredential(PageArgument& args) {
- AutoConnectCredential ac;
+ AutoConnectCredential ac(CREDENTIAL_OFFSET);
struct station_config entry;
String content = "";
uint8_t count = ac.entries(); // Get number of entries.
@@ -99,14 +103,14 @@ String viewCredential(PageArgument& args) {
// Delete a credential entry, the entry to be deleted is passed in the
// request parameter 'num'.
String delCredential(PageArgument& args) {
- AutoConnectCredential ac;
+ AutoConnectCredential ac(CREDENTIAL_OFFSET);
if (args.hasArg("num")) {
int8_t e = args.arg("num").toInt();
if (e > 0) {
struct station_config entry;
// If the input number is valid, delete that entry.
- int8_t de = ac.load(e, &entry);
+ int8_t de = ac.load(e - 1, &entry); // A base of entry num is 0.
if (de > 0) {
ac.del((char *)entry.ssid);
@@ -134,6 +138,12 @@ void setup() {
rootPage.insert(Server); // Instead of Server.on("/", ...);
delPage.insert(Server); // Instead of Server.on("/del", ...);
+ // Set an address of the credential area.
+ AutoConnectConfig Config;
+ Config.boundaryOffset = CREDENTIAL_OFFSET;
+ Portal.config(Config);
+
+ // Start
if (Portal.begin()) {
Serial.println("WiFi connected: " + WiFi.localIP().toString());
}
diff --git a/mkdocs/advancedusage.md b/mkdocs/advancedusage.md
index 1e31549..2ad364a 100644
--- a/mkdocs/advancedusage.md
+++ b/mkdocs/advancedusage.md
@@ -114,7 +114,7 @@ and
So in the default state, the credential storage area used by AutoConnect conflicts with data area owned by the user sketch. It will be destroyed together saved data in EEPROM by user sketch and AutoConnect each other. But you can move the storage area to avoid this.
-The [**saveOffset**](api.md#saveoffset) in [**AutoConnectConfig**](api.md#autoconnectconfig-api) specifies the start offset of the credentials storage area. The default value is 0.
+The [**boundaryOffset**](api.md#boundaryoffset) in [**AutoConnectConfig**](api.md#autoconnectconfig-api) specifies the start offset of the credentials storage area. The default value is 0.
### Refers the hosted ESP8266WebServer
diff --git a/mkdocs/api.md b/mkdocs/api.md
index 22b5fe0..361868e 100644
--- a/mkdocs/api.md
+++ b/mkdocs/api.md
@@ -243,7 +243,7 @@ Captive portal activation switch. False for disabling the captive portal. It pre
- **Type**
- bool
- **Value**
- - trueEnable the captive portal. This is a default.
+ - trueEnable the captive portal. This is the default.
- falseDisable the captive portal.
@@ -258,6 +258,18 @@ The credential saved automatically at the connection establishment.
- AC_SAVECREDENTIAL_NEVERThe credential no saved.
+#### boundaryOffset
+
+Sets the offset address of the credential storage area for EEPROM. This value must be between greater than 4 and less than flash sector size. (4096 by SDK)
+The default value is 0.
+
+ - **Type**
+ - uint16_t
+
+
+!!! warning "It will conflict with user data."
+ If the sketch leaves this offset at zero, it will conflict the storage area of credentials with the user sketch owned data. It needs to use the behind of credential area.
+
#### channel
The channel number of WIFi when SoftAP starts.
@@ -314,18 +326,6 @@ Sets password for SoftAP. The length should be from 8 to up to 63. The default v
- String
-#### saveOffset
-
-Sets the offset address of the credential storage area for EEPROM. This value must be between greater than 4 and less than flash sector size. (4096 by SDK)
-The default value is 0.
-
- - **Type**
- - uint16_t
-
-
-!!! warning "It will conflict with user data."
- If the sketch leaves this offset at zero, it will conflict the storage area of credentials with the user sketch owned data. It needs to use the behind of credential area.
-
### AutoConnectConfig example
```arduino
@@ -336,6 +336,7 @@ Config.apip = IPAddress(192,168,10,101); // Sets SoftAP IP address
Config.gateway = IPAddress(192,168,10,1); // Sets WLAN router IP address
Config.netmask = IPAddress(255,255,255,0); // Sets WLAN scope
Config.autoSave = AC_SAVECREDENTIAL_NEVER; // No save credential
+COnfig.boundaryOffet = 64; // Reserve 64 bytes for the user data in EEPROM.
Config.homeUri = "/index.html" // Sets home path of the sketch application
Portal.config(Config); // Configure AutoConnect
Portal.begin(); // Starts and behaves captive portal
diff --git a/mkdocs/examples.md b/mkdocs/examples.md
index 9c470dc..2b424af 100644
--- a/mkdocs/examples.md
+++ b/mkdocs/examples.md
@@ -6,7 +6,7 @@ Here holds two case examples. Both examples perform the same function. Only how
Uses the web interface to light the LED connected to the **[NodeMCU](https://github.com/nodemcu/nodemcu-devkit-v1.0)** module D0 port (which could be referred to as *BUILTIN_LED*), the following animation is it.
-Access to the ESP8266 module connected WiFi from the browser then the page contains the current value of the D0 port would be displayed. The page has the buttons to switch the port value. The LED blinks according to the value of the button that was clicked. This example is a typical sketch of manipulating ESP8266's GPIO via WLN.
+Access to the ESP8266 module connected WiFi from the browser then the page contains the current value of the D0 port would be displayed. The page has the buttons to switch the port value. The LED blinks according to the value of the button that was clicked. This example is a typical sketch of manipulating ESP8266's GPIO via WLAN.
diff --git a/mkdocs/faq.md b/mkdocs/faq.md
index 0455035..76435bd 100644
--- a/mkdocs/faq.md
+++ b/mkdocs/faq.md
@@ -68,14 +68,26 @@ Make some sketches for erasing the EEPROM area, or some erasing utility is neede
A class description of AutoConnectCredential is follows.
-### Constructor
+### Include header
```cpp
#include
+```
+### Constructor
+
+```cpp
AutoConnectCredential();
```
+AutoConnectCredential default constructor. The default offset value is 0. If the offset value is 0, the credential storage area starts from the top of the EEPROM. AutoConnect sometimes overwrites data when using this area with user sketch.
+
+```cpp
+AutoConnectCredential(uint16_t offset);
+```
+
+Specify offset from the top of the EEPROM for the credential storage area together. The offset value is from 0 to the flash sector size.
+
### Public member functions
- uint8_t **entries()**
diff --git a/src/AutoConnect.cpp b/src/AutoConnect.cpp
index e98f353..0037861 100644
--- a/src/AutoConnect.cpp
+++ b/src/AutoConnect.cpp
@@ -298,7 +298,7 @@ void AutoConnect::handleRequest() {
// Save current credential
if (_apConfig.autoSave == AC_SAVECREDENTIAL_AUTO) {
- AutoConnectCredential credit(_apConfig.saveOffset);
+ AutoConnectCredential credit(_apConfig.boundaryOffset);
credit.save(&_credential);
AC_DBG("%s credential saved\n", _credential.ssid);
}
@@ -443,7 +443,7 @@ String AutoConnect::_induceConnect(PageArgument& args) {
// Retrieve credential from the post method content.
if (args.hasArg(AUTOCONNECT_PARAMID_CRED)) {
// Read from EEPROM
- AutoConnectCredential credential(_apConfig.saveOffset);
+ AutoConnectCredential credential(_apConfig.boundaryOffset);
struct station_config entry;
AC_DBG("Load credential:%s\n", args.arg(AUTOCONNECT_PARAMID_CRED).c_str());
credential.load(args.arg(AUTOCONNECT_PARAMID_CRED).c_str(), &entry);
diff --git a/src/AutoConnect.h b/src/AutoConnect.h
index 053fbf7..42e708d 100644
--- a/src/AutoConnect.h
+++ b/src/AutoConnect.h
@@ -25,7 +25,7 @@ extern "C" {
#include "AutoConnectCredential.h"
// Uncomment the following AC_DEBUG to enable debug output.
-#define AC_DEBUG
+//#define AC_DEBUG
// Debug output destination can be defined externally with AC_DEBUG_PORT
#ifndef AC_DEBUG_PORT
@@ -115,7 +115,7 @@ class AutoConnectConfig {
channel(1),
hidden(0),
autoSave(AC_SAVECREDENTIAL_AUTO),
- saveOffset(AC_IDENTIFIER_OFFSET),
+ boundaryOffset(AC_IDENTIFIER_OFFSET),
uptime(AUTOCONNECT_STARTUPTIME),
autoRise(true),
autoReset(true),
@@ -132,7 +132,7 @@ class AutoConnectConfig {
channel(1),
hidden(0),
autoSave(AC_SAVECREDENTIAL_AUTO),
- saveOffset(AC_IDENTIFIER_OFFSET),
+ boundaryOffset(AC_IDENTIFIER_OFFSET),
uptime(AUTOCONNECT_STARTUPTIME),
autoRise(true),
autoReset(true),
@@ -149,7 +149,7 @@ class AutoConnectConfig {
channel = o.channel;
hidden = o.hidden;
autoSave = o.autoSave;
- saveOffset = o.saveOffset;
+ boundaryOffset = o.boundaryOffset;
uptime = o.uptime;
autoRise = o.autoRise;
autoReset = o.autoReset;
@@ -165,7 +165,7 @@ class AutoConnectConfig {
uint8_t channel; /**< SoftAP used wifi channel */
uint8_t hidden; /**< SoftAP SSID hidden */
AC_SAVECREDENTIAL_t autoSave; /**< Auto save credential */
- uint16_t saveOffset; /**< The save storage offset of EEPROM */
+ uint16_t boundaryOffset; /**< The save storage offset of EEPROM */
int uptime; /**< Length of start up time */
bool autoRise; /**< Automatic starting the captive portal */
bool autoReset; /**< Reset ESP8266 module automatically when WLAN disconnected. */
diff --git a/src/AutoConnectCredential.cpp b/src/AutoConnectCredential.cpp
index 40b45d5..1ed56c8 100644
--- a/src/AutoConnectCredential.cpp
+++ b/src/AutoConnectCredential.cpp
@@ -52,13 +52,14 @@ void AutoConnectCredential::_allocateEntry() {
// Validate the save area of the EEPROM.
// If it is a valid area, retrieve the stored number of entries,
// if the identifier is not saved, initialize the EEPROM area.
- for (c = _offset; c < _offset + sizeof(id_c); c++) {
- id_c[c] = static_cast(EEPROM.read(c));
+ _dp = _offset;
+ for (c = 0; c < sizeof(id_c); c++) {
+ id_c[c] = static_cast(EEPROM.read(_dp++));
}
if (!strncmp(id_c, AC_IDENTIFIER, sizeof(id_c))) {
- _entries = EEPROM.read(static_cast(c++));
- _containSize = EEPROM.read(static_cast(c++));
- _containSize += EEPROM.read(static_cast(c)) << 8;
+ _entries = EEPROM.read(static_cast(_dp++));
+ _containSize = EEPROM.read(static_cast(_dp++));
+ _containSize += EEPROM.read(static_cast(_dp)) << 8;
}
else {
_entries = 0;
@@ -106,7 +107,7 @@ bool AutoConnectCredential::del(const char* ssid) {
// End 0xff writing, update headers.
_entries--;
- EEPROM.write(static_cast(sizeof(AC_IDENTIFIER)) - 1, _entries);
+ EEPROM.write(_offset + static_cast(sizeof(AC_IDENTIFIER)) - 1, _entries);
// commit it.
rc = EEPROM.commit();
@@ -203,9 +204,9 @@ bool AutoConnectCredential::save(const struct station_config* config) {
// Same entry not found. increase the entry.
_entries++;
int i;
- for (i = AC_IDENTIFIER_OFFSET; i < static_cast(sizeof(_id)) - 1; i++)
- EEPROM.write(i, (uint8_t)_id[i]);
- EEPROM.write(i, _entries);
+ for (i = 0; i < static_cast(sizeof(_id)) - 1; i++)
+ EEPROM.write(i + _offset, (uint8_t)_id[i]);
+ EEPROM.write(i + _offset, _entries);
}
// Seek insertion point, evaluate capacity to insert the new entry.
@@ -245,8 +246,8 @@ bool AutoConnectCredential::save(const struct station_config* config) {
// Update container size
_containSize = _dp - AC_HEADERSIZE;
- EEPROM.write(sizeof(AC_IDENTIFIER) - 1 + sizeof(uint8_t), (uint8_t)_containSize);
- EEPROM.write(sizeof(AC_IDENTIFIER) - 1 + sizeof(uint8_t) + 1, (uint8_t)(_containSize >> 8));
+ EEPROM.write(_offset + sizeof(AC_IDENTIFIER) - 1 + sizeof(uint8_t), (uint8_t)_containSize);
+ EEPROM.write(_offset + sizeof(AC_IDENTIFIER) - 1 + sizeof(uint8_t) + 1, (uint8_t)(_containSize >> 8));
}
bool rc = EEPROM.commit();
diff --git a/src/AutoConnectPage.cpp b/src/AutoConnectPage.cpp
index f94e892..b97aa2f 100644
--- a/src/AutoConnectPage.cpp
+++ b/src/AutoConnectPage.cpp
@@ -899,7 +899,7 @@ String AutoConnect::_token_HIDDEN_COUNT(PageArgument& args) {
}
String AutoConnect::_token_OPEN_SSID(PageArgument& args) {
- AutoConnectCredential credit;
+ AutoConnectCredential credit(_apConfig.boundaryOffset);
struct station_config entry;
String ssidList = "";