Merge branch 'Enhance/v099' into master

pull/66/head
Hieromon Ikasamo 6 years ago committed by GitHub
commit 7f392c0657
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      mkdocs/faq.md
  2. 5
      src/AutoConnectElementBasis.h
  3. 81
      src/AutoConnectElementBasisImpl.h

@ -27,7 +27,7 @@ ESP32 hardware equips only one RF circuitry for WiFi signal. At the AP_STA mode,
## <i class="fa fa-question-circle"></i> Does not appear esp8266ap in smartphone.
Maybe it is successfully connected at the **first WiFi.begin**. ESP8266 remembers the last SSID successfully connected and will use at the next. It means SoftAP will only start up when the first *WiFi.begin()* fails.
Maybe it is successfully connected at the [**first WiFi.begin**](lsbegin.md#autoconnectbegin-logic-sequence). ESP8266 remembers the last SSID successfully connected and will use at the next. It means SoftAP will only start up when the first *WiFi.begin()* fails.
The saved SSID would be cleared by *WiFi.disconnect()* with WIFI_STA mode. If you do not want automatic reconnection, you can erase the memorized SSID with the following simple sketch.

@ -46,11 +46,11 @@ typedef enum {
*/
class AutoConnectElementBasis {
public:
explicit AutoConnectElementBasis(const char* name = "", const char* value = "") : name(String(name)), value(String(value)) {
explicit AutoConnectElementBasis(const char* name = "", const char* value = "") : name(String(name)), value(String(value)), enable(true) {
_type = AC_Element;
}
virtual ~AutoConnectElementBasis() {}
virtual const String toHTML(void) const { return value; }
virtual const String toHTML(void) const { return enable ? value : String(""); }
ACElement_t typeOf(void) const { return _type; }
#ifndef AUTOCONNECT_USE_JSON
template<typename T>
@ -59,6 +59,7 @@ class AutoConnectElementBasis {
String name; /**< Element name */
String value; /**< Element value */
bool enable; /**< Enabling the element */
protected:
ACElement_t _type; /**< Element type identifier */

@ -25,7 +25,7 @@
* @return An HTML string.
*/
const String AutoConnectButtonBasis::toHTML(void) const {
return String(F("<button type=\"button\" name=\"")) + name + String(F("\" value=\"")) + value + String(F("\" onclick=\"")) + action + String("\">") + value + String(F("</button>"));
return enable ? String(F("<button type=\"button\" name=\"")) + name + String(F("\" value=\"")) + value + String(F("\" onclick=\"")) + action + String("\">") + value + String(F("</button>")) : String("");
}
/**
@ -37,14 +37,16 @@ const String AutoConnectButtonBasis::toHTML(void) const {
* @return An HTML string.
*/
const String AutoConnectCheckboxBasis::toHTML(void) const {
String html;
String html = String("");
html = String(F("<input type=\"checkbox\" name=\"")) + name + String(F("\" value=\"")) + value + String("\"");
if (checked)
html += String(F(" checked"));
if (label.length())
html += String(F(" id=\"")) + name + String(F("\"><label for=\"")) + name + String("\">") + label + String(F("</label"));
html += String(F("><br>"));
if (enable) {
html = String(F("<input type=\"checkbox\" name=\"")) + name + String(F("\" value=\"")) + value + String("\"");
if (checked)
html += String(F(" checked"));
if (label.length())
html += String(F(" id=\"")) + name + String(F("\"><label for=\"")) + name + String("\">") + label + String(F("</label"));
html += String(F("><br>"));
}
return html;
}
@ -58,9 +60,11 @@ const String AutoConnectCheckboxBasis::toHTML(void) const {
const String AutoConnectFileBasis::toHTML(void) const {
String html = String("");
if (label.length())
html = String(F("<label for=\"")) + name + String(F("\">")) + label + String(F("</label>"));
html += String(F("<input type=\"file\" id=\"")) + name + String(F("\" name=\"")) + name + String(F("\"><br>"));
if (enable) {
if (label.length())
html = String(F("<label for=\"")) + name + String(F("\">")) + label + String(F("</label>"));
html += String(F("<input type=\"file\" id=\"")) + name + String(F("\" name=\"")) + name + String(F("\"><br>"));
}
return html;
}
@ -101,17 +105,18 @@ bool AutoConnectFileBasis::attach(const ACFile_t store) {
const String AutoConnectInputBasis::toHTML(void) const {
String html = String("");
if (label.length())
html = String(F("<label for=\"")) + name + String("\">") + label + String(F("</label>"));
html += String(F("<input type=\"text\" id=\"")) + name + String(F("\" name=\"")) + name + String("\"");
if (pattern.length())
html += String(F(" pattern=\"")) + pattern + String("\"");
if (placeholder.length())
html += String(F(" placeholder=\"")) + placeholder + String("\"");
if (value.length())
html += String(F(" value=\"")) + value + String("\"");
html += String(F("><br>"));
if (enable) {
if (label.length())
html = String(F("<label for=\"")) + name + String("\">") + label + String(F("</label>"));
html += String(F("<input type=\"text\" id=\"")) + name + String(F("\" name=\"")) + name + String("\"");
if (pattern.length())
html += String(F(" pattern=\"")) + pattern + String("\"");
if (placeholder.length())
html += String(F(" placeholder=\"")) + placeholder + String("\"");
if (value.length())
html += String(F(" value=\"")) + value + String("\"");
html += String(F("><br>"));
}
return html;
}
@ -269,7 +274,7 @@ const String& AutoConnectSelectBasis::value(void) const {
* @return String an HTML string.
*/
const String AutoConnectSubmitBasis::toHTML(void) const {
return String(F("<input type=\"button\" name=\"")) + name + String(F("\" value=\"")) + value + String(F("\" onclick=\"_sa('")) + uri + String("')\">");
return enable ? String(F("<input type=\"button\" name=\"")) + name + String(F("\" value=\"")) + value + String(F("\" onclick=\"_sa('")) + uri + String("')\">") : String("");
}
/**
@ -278,22 +283,26 @@ const String AutoConnectSubmitBasis::toHTML(void) const {
* @return String an HTML string.
*/
const String AutoConnectTextBasis::toHTML(void) const {
String html = String("<div");
String value_f = value;
String html = String("");
if (enable) {
html = String("<div");
String value_f = value;
if (style.length())
html += String(F(" style=\"")) + style + String("\"");
html += String(">");
if (format.length()) {
int buflen = (value.length() + format.length() + 16 + 1) & (~0xf);
char* buffer;
if ((buffer = (char*)malloc(buflen))) {
snprintf(buffer, buflen, format.c_str(), value.c_str());
value_f = String(buffer);
free(buffer);
if (style.length())
html += String(F(" style=\"")) + style + String("\"");
html += String(">");
if (format.length()) {
int buflen = (value.length() + format.length() + 16 + 1) & (~0xf);
char* buffer;
if ((buffer = (char*)malloc(buflen))) {
snprintf(buffer, buflen, format.c_str(), value.c_str());
value_f = String(buffer);
free(buffer);
}
}
html += value_f + String(F("</div>"));
}
html += value_f + String(F("</div>"));
return html;
}

Loading…
Cancel
Save