diff --git a/docs/advancedusage/index.html b/docs/advancedusage/index.html index fe241d6..52f8df8 100644 --- a/docs/advancedusage/index.html +++ b/docs/advancedusage/index.html @@ -465,8 +465,8 @@
  • - - Static IP assignment + + Static IP assignment 1
  • @@ -678,8 +678,8 @@
  • - - Static IP assignment + + Static IP assignment 1
  • @@ -891,9 +891,17 @@
    #define AUTOCONNECT_URI         "/_ac"
     
    -

    Static IP assignment

    -

    It is also possible to assign static IP Address to ESP8266 in STA mode. By default DHCP is enabled and it becomes the IP address assigned by the DHCP server with WiFi.begin.1

    -

    To assign a static IP Address, specify it in the AutoConnectConfig parameter. In the case of assigning a static IP Address, specify the gateway, subnet mask, and DNS server is needed.

    +

    Static IP assignment 1

    +

    It is also possible to assign static IP Address to ESP8266 in STA mode. By default DHCP is enabled and it becomes the IP address assigned by the DHCP server with WiFi.begin.

    +

    To assign a static IP to ESP8266 with WIFI_MODE_STA, the following parameters are required:

    + +

    The above parameters must be executed before AutoConnect::begin as arguments of AutoConnectConfig.

    AutoConnect        portal;
     AutoConnectConfig  Config;
     Config.staip = IPAddress(192,168,1,10);
    diff --git a/docs/examples/index.html b/docs/examples/index.html
    index c626798..4320a09 100644
    --- a/docs/examples/index.html
    +++ b/docs/examples/index.html
    @@ -683,7 +683,7 @@
     

    Declare only AutoConnect, performs handleClient.

    Used with MQTT as a client application

    -

    The effect of AutoConnect is not only for ESP8266 as the Web server. It has a benefit for something WiFi client too. AutoConnect is effective too when publishing with MQTT from various measurement points. Even if the SSID is different for each measurement point, it is no need to modify the sketch.

    +

    The effect of AutoConnect is not only for ESP8266 as the Web server. It has advantages for something WiFi client as well. For example, AutoConnect is also effective for publishing MQTT messages from various measurement points. Even if the SSID is different for each measurement point, it is not necessary to modify the sketch.

    This example tries to publish the WiFi signal strength of ESP8266 with MQTT. It uses the ThingSpeak for MQTT broker. ESP8266 publishes the RSSI value to the channel created on ThingSpeak as MQTT client. This example is well suited to demonstrate the usefulness of AutoConnect, as RSSI values are measured at each access point usually. Just adding a few lines of code makes it unnecessary to upload sketches with the different SSIDs rewrite for each access point.

    Advance procedures

    @@ -726,22 +726,32 @@

    For the client sketches, the code required to connect to WiFi is the following four parts only.

    1. -

      #include directive3
      -

      +

      #include directive3

      +

      Include AutoConnect.h header file behind the include of ESP8266WiFi.h.

      +

    2. -

      Declare AutoConnect
      -

      +

      Declare AutoConnect

      +

      The declaration of the AutoConnect variable is not accompanied by ESP8266WebServer.

      +

    3. -

      Invokes "begin()"
      -

      +

      Invokes "begin()"

      +

      Call AutoConnec::begin. If you need to assign a static IP address, executes AutoConnectConfig before that.

      +

    4. -

      Performs "handleClent()" in "loop()"
      -

      +

      Performs "handleClent()" in "loop()"

      +

      Invokes AutoConnect::handleClient() at inside loop() to enable the AutoConnect menu.

      +

    + +

      @@ -752,12 +762,7 @@

      '454951' in the example above, but your channel ID should be different. 

    1. -

      #include <ESP8266WebServer.h> does not necessary for uses only client. - 

      +

      #include <ESP8266WebServer.h> does not necessary for uses only client. 

    diff --git a/docs/search/search_index.json b/docs/search/search_index.json index 186a9de..b68cbc3 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;\nf\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 function 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 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 area. \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 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 the first \nWiFi.begin\n. 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\n\nAutoConnect::config before AutoConnect::begin\n\n\nAutoConnect::config\n must be executed before \nAutoConnect::begin\n.\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\"\n\n\n\n\n\n Static IP assignment\n\u00b6\n\n\nIt is also possible to assign static IP Address to ESP8266 in STA mode. By default DHCP is enabled and it becomes the IP address assigned by the DHCP server with \nWiFi.begin\n.\n1\n\n\nTo assign a static IP Address, specify it in the \nAutoConnectConfig parameter\n. In the case of assigning a static IP Address, specify the gateway, subnet mask, and DNS server is needed.\n\n\nAutoConnect\n \nportal\n;\n\n\nAutoConnectConfig\n \nConfig\n;\n\n\nConfig\n.\nstaip\n \n=\n \nIPAddress\n(\n192\n,\n168\n,\n1\n,\n10\n);\n\n\nConfig\n.\nstaGateway\n \n=\n \nIPAddress\n(\n192\n,\n168\n,\n1\n,\n1\n);\n\n\nConfig\n.\nstaNetmask\n \n=\n \nIPAddress\n(\n255\n,\n255\n,\n255\n,\n0\n);\n\n\nConfig\n.\ndns1\n \n=\n \nIPAddress\n(\n192\n,\n168\n,\n1\n,\n1\n);\n\n\nportal\n.\nconfig\n(\nConfig\n);\n\n\nportal\n.\nbegin\n();\n\n\n\n\n\n\n\n\n\n\n\n\n\nStatic IP address assignment is available from version 0.9.3.\u00a0\n\u21a9", + "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;\nf\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 function 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 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 area. \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 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 the first \nWiFi.begin\n. 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\n\nAutoConnect::config before AutoConnect::begin\n\n\nAutoConnect::config\n must be executed before \nAutoConnect::begin\n.\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\"\n\n\n\n\n\n Static IP assignment \n1\n\u00b6\n\n\nIt is also possible to assign static IP Address to ESP8266 in STA mode. By default DHCP is enabled and it becomes the IP address assigned by the DHCP server with \nWiFi.begin\n.\n\n\nTo assign a static IP to ESP8266 with WIFI_MODE_STA, the following parameters are required:\n\n\n\n\nIP address.\n\n\nGateway address.\n\n\nSubnet mask.\n\n\nPrimary DNS server.\n\n\nSecondary DNS server. (optional)\n\n\n\n\nThe above parameters must be executed before \nAutoConnect::begin\n as \narguments of AutoConnectConfig\n.\n\n\nAutoConnect\n \nportal\n;\n\n\nAutoConnectConfig\n \nConfig\n;\n\n\nConfig\n.\nstaip\n \n=\n \nIPAddress\n(\n192\n,\n168\n,\n1\n,\n10\n);\n\n\nConfig\n.\nstaGateway\n \n=\n \nIPAddress\n(\n192\n,\n168\n,\n1\n,\n1\n);\n\n\nConfig\n.\nstaNetmask\n \n=\n \nIPAddress\n(\n255\n,\n255\n,\n255\n,\n0\n);\n\n\nConfig\n.\ndns1\n \n=\n \nIPAddress\n(\n192\n,\n168\n,\n1\n,\n1\n);\n\n\nportal\n.\nconfig\n(\nConfig\n);\n\n\nportal\n.\nbegin\n();\n\n\n\n\n\n\n\n\n\n\n\n\n\nStatic IP address assignment is available from version 0.9.3.\u00a0\n\u21a9", "title": "Advanced usage" }, { @@ -276,9 +276,9 @@ "title": " Relocate the AutoConnect home path" }, { - "location": "/advancedusage/index.html#static-ip-assignment", - "text": "It is also possible to assign static IP Address to ESP8266 in STA mode. By default DHCP is enabled and it becomes the IP address assigned by the DHCP server with WiFi.begin . 1 To assign a static IP Address, specify it in the AutoConnectConfig parameter . In the case of assigning a static IP Address, specify the gateway, subnet mask, and DNS server is needed. AutoConnect portal ; AutoConnectConfig Config ; Config . staip = IPAddress ( 192 , 168 , 1 , 10 ); Config . staGateway = IPAddress ( 192 , 168 , 1 , 1 ); Config . staNetmask = IPAddress ( 255 , 255 , 255 , 0 ); Config . dns1 = IPAddress ( 192 , 168 , 1 , 1 ); portal . config ( Config ); portal . begin (); Static IP address assignment is available from version 0.9.3.\u00a0 \u21a9", - "title": " Static IP assignment" + "location": "/advancedusage/index.html#static-ip-assignment-1", + "text": "It is also possible to assign static IP Address to ESP8266 in STA mode. By default DHCP is enabled and it becomes the IP address assigned by the DHCP server with WiFi.begin . To assign a static IP to ESP8266 with WIFI_MODE_STA, the following parameters are required: IP address. Gateway address. Subnet mask. Primary DNS server. Secondary DNS server. (optional) The above parameters must be executed before AutoConnect::begin as arguments of AutoConnectConfig . AutoConnect portal ; AutoConnectConfig Config ; Config . staip = IPAddress ( 192 , 168 , 1 , 10 ); Config . staGateway = IPAddress ( 192 , 168 , 1 , 1 ); Config . staNetmask = IPAddress ( 255 , 255 , 255 , 0 ); Config . dns1 = IPAddress ( 192 , 168 , 1 , 1 ); portal . config ( Config ); portal . begin (); Static IP address assignment is available from version 0.9.3.\u00a0 \u21a9", + "title": " Static IP assignment 1" }, { "location": "/api/index.html", @@ -482,7 +482,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 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\nUsed with MQTT as a client application\n\u00b6\n\n\nThe effect of AutoConnect is not only for ESP8266 as the Web server. It has a benefit for something WiFi client too. AutoConnect is effective too when publishing with MQTT from various measurement points. Even if the SSID is different for each measurement point, it is no need to modify the sketch.\n\n\nThis example tries to publish the WiFi signal strength of ESP8266 with MQTT. It uses the \nThingSpeak\n for MQTT broker. ESP8266 publishes the RSSI value to the channel created on ThingSpeak as \nMQTT client\n. This example is well suited to demonstrate the usefulness of AutoConnect, as RSSI values are measured at each access point usually. Just adding a few lines of code makes it unnecessary to upload sketches with the different SSIDs rewrite for each access point.\n\n\n\n\nAdvance procedures\n\u00b6\n\n\n\n\nArduino Client for MQTT - It's the \nPubSubClient\n, install it to Arduino IDE. If you have the latest version already, this step does not need.\n\n\nCreate a channel on ThingSpeak.\n\n\nGet the Channel API Keys from ThingSpeak, put its keys to the sketch.\n\n\n\n\nThe ThingSpeak is the open IoT platform. It is capable of sending data privately to the cloud and analyzing, visualizing its data. If you do not have an account of ThingSpeak, you need that account to proceed further. ThingSpeak has the free plan for the account which uses within the scope of this example.\n1\n You can sign up with the \nThingSpeak sign-up page\n.\n\n\n\n\nWhether you should do sign-up or not.\n\n\nYou are entrusted with the final judgment of account creation for ThingSpeak. Create an account at your own risk.\n\n\n\n\nCreate a channel on ThingSpeak\n\u00b6\n\n\nSign in ThingSpeak. Select \nChannels\n to show the \nMy Channels\n, then click \nNew Channel\n.\n\n\nAt the \nNew Channel\n screen, enter each field as a below. And click \nSave Channel\n at the bottom of the screen to save.\n\n\n\n\nName: \nESP8266 Signal Strength\n\n\nDescription: \nESP8266 RSSI publish\n\n\nField1: \nRSSI\n\n\n\n\n\n\nGet Channel ID and API Keys\n\u00b6\n\n\nThe channel successfully created, you can see the channel status screen as a below. \nChannel ID\n is displayed there.\n2\n\n\n\n\nHere, switch the channel status tab to \nAPI Keys\n. The API key required to publish the message is the \nWrite API Key\n.\n\n\n\n\nThe last key you need is the \nUser API Key\n and can be confirmed it in the user profile. Pull down \nAccount\n from the top menu, select \nMy profile\n. Then you can see the ThingSpeak settings and the \nUser API Key\n is displayed middle of this screen.\n\n\n\n\nThe sketch, Publishes messages\n\u00b6\n\n\nThe complete code of the sketch is \nmqttRSSI.ino\n in the \nAutoConnect repository\n. Replace the following #define in a sketch with \nUser API Key\n, \nWrite API Key\n and \nChannel ID\n. After Keys updated, compile the sketch and upload it.\n\n\n#define MQTT_USER_KEY \"****************\" \n// Replace to User API Key.\n\n\n#define CHANNEL_ID \"******\" \n// Replace to Channel ID.\n\n\n#define CHANNEL_API_KEY_WR \"****************\" \n// Replace to the write API Key.\n\n\n\n\n\nPublish messages\n\u00b6\n\n\nAfter upload and reboot complete, the message publishing will start via the access point now set. The message carries RSSI as the current WiFi signal strength. The signal strength variations in RSSI are displayed on ThingSpeak's Channel status screen.\n\n\nHow embed to your sketches\n\u00b6\n\n\nFor the client sketches, the code required to connect to WiFi is the following four parts only.\n\n\n\n\n\n\n#include directive\n3\n\n\n\n\n\n\n\n\nDeclare AutoConnect\n\n\n\n\n\n\n\n\nInvokes \"begin()\"\n\n\n\n\n\n\n\n\nPerforms \"handleClent()\" in \"loop()\"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nAs of March 21, 2018.\u00a0\n\u21a9\n\n\n\n\n\n\n'454951' in the example above, but your channel ID should be different.\u00a0\n\u21a9\n\n\n\n\n\n\n#include\n \n\n does not necessary for uses only client.\n\n\n window.onload = function() {\nGifffer();\n }\n\n\u00a0\n\u21a9", + "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\nUsed with MQTT as a client application\n\u00b6\n\n\nThe effect of AutoConnect is not only for ESP8266 as the Web server. It has advantages for something WiFi client as well. For example, AutoConnect is also effective for publishing MQTT messages from various measurement points. Even if the SSID is different for each measurement point, it is not necessary to modify the sketch.\n\n\nThis example tries to publish the WiFi signal strength of ESP8266 with MQTT. It uses the \nThingSpeak\n for MQTT broker. ESP8266 publishes the RSSI value to the channel created on ThingSpeak as \nMQTT client\n. This example is well suited to demonstrate the usefulness of AutoConnect, as RSSI values are measured at each access point usually. Just adding a few lines of code makes it unnecessary to upload sketches with the different SSIDs rewrite for each access point.\n\n\n\n\nAdvance procedures\n\u00b6\n\n\n\n\nArduino Client for MQTT - It's the \nPubSubClient\n, install it to Arduino IDE. If you have the latest version already, this step does not need.\n\n\nCreate a channel on ThingSpeak.\n\n\nGet the Channel API Keys from ThingSpeak, put its keys to the sketch.\n\n\n\n\nThe ThingSpeak is the open IoT platform. It is capable of sending data privately to the cloud and analyzing, visualizing its data. If you do not have an account of ThingSpeak, you need that account to proceed further. ThingSpeak has the free plan for the account which uses within the scope of this example.\n1\n You can sign up with the \nThingSpeak sign-up page\n.\n\n\n\n\nWhether you should do sign-up or not.\n\n\nYou are entrusted with the final judgment of account creation for ThingSpeak. Create an account at your own risk.\n\n\n\n\nCreate a channel on ThingSpeak\n\u00b6\n\n\nSign in ThingSpeak. Select \nChannels\n to show the \nMy Channels\n, then click \nNew Channel\n.\n\n\nAt the \nNew Channel\n screen, enter each field as a below. And click \nSave Channel\n at the bottom of the screen to save.\n\n\n\n\nName: \nESP8266 Signal Strength\n\n\nDescription: \nESP8266 RSSI publish\n\n\nField1: \nRSSI\n\n\n\n\n\n\nGet Channel ID and API Keys\n\u00b6\n\n\nThe channel successfully created, you can see the channel status screen as a below. \nChannel ID\n is displayed there.\n2\n\n\n\n\nHere, switch the channel status tab to \nAPI Keys\n. The API key required to publish the message is the \nWrite API Key\n.\n\n\n\n\nThe last key you need is the \nUser API Key\n and can be confirmed it in the user profile. Pull down \nAccount\n from the top menu, select \nMy profile\n. Then you can see the ThingSpeak settings and the \nUser API Key\n is displayed middle of this screen.\n\n\n\n\nThe sketch, Publishes messages\n\u00b6\n\n\nThe complete code of the sketch is \nmqttRSSI.ino\n in the \nAutoConnect repository\n. Replace the following #define in a sketch with \nUser API Key\n, \nWrite API Key\n and \nChannel ID\n. After Keys updated, compile the sketch and upload it.\n\n\n#define MQTT_USER_KEY \"****************\" \n// Replace to User API Key.\n\n\n#define CHANNEL_ID \"******\" \n// Replace to Channel ID.\n\n\n#define CHANNEL_API_KEY_WR \"****************\" \n// Replace to the write API Key.\n\n\n\n\n\nPublish messages\n\u00b6\n\n\nAfter upload and reboot complete, the message publishing will start via the access point now set. The message carries RSSI as the current WiFi signal strength. The signal strength variations in RSSI are displayed on ThingSpeak's Channel status screen.\n\n\nHow embed to your sketches\n\u00b6\n\n\nFor the client sketches, the code required to connect to WiFi is the following four parts only.\n\n\n\n\n\n\n#include directive\n3\n\n\nInclude \nAutoConnect.h\n header file behind the include of \nESP8266WiFi.h\n.\n\n\n\n\n\n\n\n\nDeclare AutoConnect\n\n\nThe declaration of the \nAutoConnect variable\n is not accompanied by ESP8266WebServer.\n\n\n\n\n\n\n\n\nInvokes \"begin()\"\n\n\nCall \nAutoConnec::begin\n. If you need to assign a static IP address, executes \nAutoConnectConfig\n before that. \n\n\n\n\n\n\n\n\nPerforms \"handleClent()\" in \"loop()\"\n\n\nInvokes \nAutoConnect::handleClient()\n at inside \nloop()\n to enable the AutoConnect menu.\n\n\n\n\n\n\n\n\n\n window.onload = function() {\n Gifffer();\n }\n\n\n\n\n\n\n\n\n\n\n\n\nAs of March 21, 2018.\u00a0\n\u21a9\n\n\n\n\n\n\n'454951' in the example above, but your channel ID should be different.\u00a0\n\u21a9\n\n\n\n\n\n\n#include\n \n\n does not necessary for uses only client.\u00a0\n\u21a9", "title": "Examples" }, { @@ -512,7 +512,7 @@ }, { "location": "/examples/index.html#used-with-mqtt-as-a-client-application", - "text": "The effect of AutoConnect is not only for ESP8266 as the Web server. It has a benefit for something WiFi client too. AutoConnect is effective too when publishing with MQTT from various measurement points. Even if the SSID is different for each measurement point, it is no need to modify the sketch. This example tries to publish the WiFi signal strength of ESP8266 with MQTT. It uses the ThingSpeak for MQTT broker. ESP8266 publishes the RSSI value to the channel created on ThingSpeak as MQTT client . This example is well suited to demonstrate the usefulness of AutoConnect, as RSSI values are measured at each access point usually. Just adding a few lines of code makes it unnecessary to upload sketches with the different SSIDs rewrite for each access point.", + "text": "The effect of AutoConnect is not only for ESP8266 as the Web server. It has advantages for something WiFi client as well. For example, AutoConnect is also effective for publishing MQTT messages from various measurement points. Even if the SSID is different for each measurement point, it is not necessary to modify the sketch. This example tries to publish the WiFi signal strength of ESP8266 with MQTT. It uses the ThingSpeak for MQTT broker. ESP8266 publishes the RSSI value to the channel created on ThingSpeak as MQTT client . This example is well suited to demonstrate the usefulness of AutoConnect, as RSSI values are measured at each access point usually. Just adding a few lines of code makes it unnecessary to upload sketches with the different SSIDs rewrite for each access point.", "title": "Used with MQTT as a client application" }, { @@ -542,17 +542,17 @@ }, { "location": "/examples/index.html#how-embed-to-your-sketches", - "text": "For the client sketches, the code required to connect to WiFi is the following four parts only. #include directive 3 Declare AutoConnect Invokes \"begin()\" Performs \"handleClent()\" in \"loop()\" As of March 21, 2018.\u00a0 \u21a9 '454951' in the example above, but your channel ID should be different.\u00a0 \u21a9 #include does not necessary for uses only client. \n window.onload = function() {\nGifffer();\n } \u00a0 \u21a9", + "text": "For the client sketches, the code required to connect to WiFi is the following four parts only. #include directive 3 Include AutoConnect.h header file behind the include of ESP8266WiFi.h . Declare AutoConnect The declaration of the AutoConnect variable is not accompanied by ESP8266WebServer. Invokes \"begin()\" Call AutoConnec::begin . If you need to assign a static IP address, executes AutoConnectConfig before that. Performs \"handleClent()\" in \"loop()\" Invokes AutoConnect::handleClient() at inside loop() to enable the AutoConnect menu. \n window.onload = function() {\n Gifffer();\n } As of March 21, 2018.\u00a0 \u21a9 '454951' in the example above, but your channel ID should be different.\u00a0 \u21a9 #include does not necessary for uses only client.\u00a0 \u21a9", "title": "How embed to your sketches" }, { "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\nSee also the explanation \nhere\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 last 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 \nesp8266ap\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 How change HTTP port?\n\u00b6\n\n\nHTTP port number is defined as a macro in \nAutoConnect.h\n header file. You can change it directly with several editors and must re-compile.\n\n\n#define AUTOCONNECT_HTTPPORT 80\n\n\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\n\nESP8266 Boot Messages\n\n\nIt is described by \nESP8266 Non-OS SDK API Reference\n, section A.5.\n\n\n\n\n\n\n\n\nMessages\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\nrst cause\n\n\n1: power on\n2: external reset\n4: hardware watchdog reset\n\n\n\n\n\n\nboot mode\n(the first parameter)\n\n\n1: ESP8266 is in UART-down mode (and downloads firmware into flash).\n3: ESP8266 is in Flash-boot mode (and boots up from flash).\n\n\n\n\n\n\n\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\n\n\n\n\n\n How much memory does AutoConnect consume?\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 in 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 combined \nAutoConnect::handleRequest()\n.\n\n\nSee also the explanation \nhere\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 last 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 \nesp8266ap\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 How change HTTP port?\n\u00b6\n\n\nHTTP port number is defined as a macro in \nAutoConnect.h\n header file. You can change it directly with several editors and must re-compile.\n\n\n#define AUTOCONNECT_HTTPPORT 80\n\n\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\n\nESP8266 Boot Messages\n\n\nIt is described by \nESP8266 Non-OS SDK API Reference\n, section A.5.\n\n\n\n\n\n\n\n\nMessages\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\nrst cause\n\n\n1: power on\n2: external reset\n4: hardware watchdog reset\n\n\n\n\n\n\nboot mode\n(the first parameter)\n\n\n1: ESP8266 is in UART-down mode (and downloads firmware into flash).\n3: ESP8266 is in Flash-boot mode (and boots up from flash).\n\n\n\n\n\n\n\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\n\n\n\n\n\n How much memory does AutoConnect consume?\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 in 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" }, { "location": "/faq/index.html#after-connected-autoconnect-menu-performs-but-no-happens", - "text": "If you can access the AutoConnect root path as http://ESP8266IPADDRESS/_ac from browser, probably the sketch uses ESP8266WebServer::handleClient() without AutoConnect::handleRequest() . \nFor AutoConnect menus to work properly, call AutoConnect::handleRequest() after ESP8266WebServer::handleClient() invoked, or use AutoConnect::handleClient() . AutoConnect::handleClient() is equivalent ESP8266WebServer::handleClient combinated AutoConnect::handleRequest() . See also the explanation here .", + "text": "If you can access the AutoConnect root path as http://ESP8266IPADDRESS/_ac from browser, probably the sketch uses ESP8266WebServer::handleClient() without AutoConnect::handleRequest() . \nFor AutoConnect menus to work properly, call AutoConnect::handleRequest() after ESP8266WebServer::handleClient() invoked, or use AutoConnect::handleClient() . AutoConnect::handleClient() is equivalent ESP8266WebServer::handleClient combined AutoConnect::handleRequest() . See also the explanation here .", "title": " After connected, AutoConnect menu performs but no happens." }, { diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 33b5fa2..fea710a 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -4,7 +4,7 @@ https://Hieromon.github.io/AutoConnect//index.html - 2018-03-23 + 2018-03-24 daily @@ -12,7 +12,7 @@ https://Hieromon.github.io/AutoConnect//gettingstarted/index.html - 2018-03-23 + 2018-03-24 daily @@ -20,7 +20,7 @@ https://Hieromon.github.io/AutoConnect//menu/index.html - 2018-03-23 + 2018-03-24 daily @@ -28,7 +28,7 @@ https://Hieromon.github.io/AutoConnect//basicusage/index.html - 2018-03-23 + 2018-03-24 daily @@ -36,7 +36,7 @@ https://Hieromon.github.io/AutoConnect//advancedusage/index.html - 2018-03-23 + 2018-03-24 daily @@ -44,7 +44,7 @@ https://Hieromon.github.io/AutoConnect//api/index.html - 2018-03-23 + 2018-03-24 daily @@ -52,7 +52,7 @@ https://Hieromon.github.io/AutoConnect//examples/index.html - 2018-03-23 + 2018-03-24 daily @@ -60,7 +60,7 @@ https://Hieromon.github.io/AutoConnect//faq/index.html - 2018-03-23 + 2018-03-24 daily @@ -68,7 +68,7 @@ https://Hieromon.github.io/AutoConnect//changelog/index.html - 2018-03-23 + 2018-03-24 daily @@ -76,7 +76,7 @@ https://Hieromon.github.io/AutoConnect//license/index.html - 2018-03-23 + 2018-03-24 daily diff --git a/mkdocs/advancedusage.md b/mkdocs/advancedusage.md index 1575de0..13af696 100644 --- a/mkdocs/advancedusage.md +++ b/mkdocs/advancedusage.md @@ -218,11 +218,19 @@ A home path of AutoConnect is **/\_ac** by default. You can access from the brow #define AUTOCONNECT_URI "/_ac" ``` -### Static IP assignment +### Static IP assignment [^1] -It is also possible to assign static IP Address to ESP8266 in STA mode. By default DHCP is enabled and it becomes the IP address assigned by the DHCP server with *WiFi.begin*.[^1] +It is also possible to assign static IP Address to ESP8266 in STA mode. By default DHCP is enabled and it becomes the IP address assigned by the DHCP server with *WiFi.begin*. -To assign a static IP Address, specify it in the [AutoConnectConfig parameter](api.md#staip). In the case of assigning a static IP Address, specify the gateway, subnet mask, and DNS server is needed. +To assign a static IP to ESP8266 with WIFI\_MODE\_STA, the following parameters are required: + +- IP address. +- Gateway address. +- Subnet mask. +- Primary DNS server. +- Secondary DNS server. (optional) + +The above parameters must be executed before *AutoConnect::begin* as [arguments of AutoConnectConfig](api.md#staip). ```arduino AutoConnect portal; diff --git a/mkdocs/examples.md b/mkdocs/examples.md index 3b1005f..c9d4165 100644 --- a/mkdocs/examples.md +++ b/mkdocs/examples.md @@ -31,7 +31,7 @@ Declare only AutoConnect, performs handleClient. ## Used with MQTT as a client application -The effect of AutoConnect is not only for ESP8266 as the Web server. It has a benefit for something WiFi client too. AutoConnect is effective too when publishing with MQTT from various measurement points. Even if the SSID is different for each measurement point, it is no need to modify the sketch. +The effect of AutoConnect is not only for ESP8266 as the Web server. It has advantages for something WiFi client as well. For example, AutoConnect is also effective for publishing MQTT messages from various measurement points. Even if the SSID is different for each measurement point, it is not necessary to modify the sketch. This example tries to publish the WiFi signal strength of ESP8266 with MQTT. It uses the [ThingSpeak](https://thingspeak.com/) for MQTT broker. ESP8266 publishes the RSSI value to the channel created on ThingSpeak as [MQTT client](https://github.com/knolleary/pubsubclient). This example is well suited to demonstrate the usefulness of AutoConnect, as RSSI values are measured at each access point usually. Just adding a few lines of code makes it unnecessary to upload sketches with the different SSIDs rewrite for each access point. @@ -96,19 +96,32 @@ After upload and reboot complete, the message publishing will start via the acce For the client sketches, the code required to connect to WiFi is the following four parts only. -1. \#include directive[^3] - +1. \#include directive[^3] + + Include ```AutoConnect.h``` header file behind the include of ```ESP8266WiFi.h```. -2. Declare AutoConnect - + -3. Invokes "begin()" - +2. Declare AutoConnect + + The declaration of the [**AutoConnect variable**](api.md#autoconnect) is not accompanied by ESP8266WebServer. -4. Performs "handleClent()" in "loop()" - + + +3. Invokes "begin()" + + Call [**AutoConnec::begin**](api.md#begin). If you need to assign a static IP address, executes [**AutoConnectConfig**](api.md#autoconnectconfig-api) before that. + + + +4. Performs "handleClent()" in "loop()" + + Invokes [**AutoConnect::handleClient()**](api.md#handleclient) at inside ```loop()``` to enable the AutoConnect menu. + + [^3]:```#include ``` does not necessary for uses only client. +