|
|
@ -14,6 +14,10 @@ Use [int()](https://www.arduino.cc/reference/en/language/variables/conversion/in |
|
|
|
AutoConnectInput& input = aux.getElement<AutoConnectInput>("INPUT"); |
|
|
|
AutoConnectInput& input = aux.getElement<AutoConnectInput>("INPUT"); |
|
|
|
int value = input.value.toInt(); |
|
|
|
int value = input.value.toInt(); |
|
|
|
``` |
|
|
|
``` |
|
|
|
|
|
|
|
You can shorten it and write as like: |
|
|
|
|
|
|
|
```cpp |
|
|
|
|
|
|
|
int value = aux["INPUT"].value.toInt(); |
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
### <i class="fa fa-exchange"></i> Float |
|
|
|
### <i class="fa fa-exchange"></i> Float |
|
|
|
|
|
|
|
|
|
|
@ -23,6 +27,10 @@ Use [float()](https://www.arduino.cc/reference/en/language/variables/conversion/ |
|
|
|
AutoConnectInput& input = aux.getElement<AutoConnectInput>("INPUT"); |
|
|
|
AutoConnectInput& input = aux.getElement<AutoConnectInput>("INPUT"); |
|
|
|
float value = input.value.toFloat(); |
|
|
|
float value = input.value.toFloat(); |
|
|
|
``` |
|
|
|
``` |
|
|
|
|
|
|
|
You can shorten it and write as like: |
|
|
|
|
|
|
|
```cpp |
|
|
|
|
|
|
|
float value = aux["INPUT"].value.toFloat(); |
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
### <i class="fa fa-exchange"></i> Date & Time |
|
|
|
### <i class="fa fa-exchange"></i> Date & Time |
|
|
|
|
|
|
|
|
|
|
@ -36,7 +44,7 @@ The easiest way is to use the [Arduino Time Library](https://www.pjrc.com/teensy |
|
|
|
time_t tm; |
|
|
|
time_t tm; |
|
|
|
int Year, Month, Day, Hour, Minute, Second; |
|
|
|
int Year, Month, Day, Hour, Minute, Second; |
|
|
|
|
|
|
|
|
|
|
|
AutoConnectInput& input = aux.getElement<AutoConnectInput>("INPUT"); |
|
|
|
AutoConnectInput& input = aux.["INPUT"].as<AutoConnectInput>(); |
|
|
|
sscanf(input.value.c_str(), "%d-%d-%d %d:%d:%d", &Year, &Month, &Day, &Hour, &Minute, &Second); |
|
|
|
sscanf(input.value.c_str(), "%d-%d-%d %d:%d:%d", &Year, &Month, &Day, &Hour, &Minute, &Second); |
|
|
|
tm.Year = CalendarYrToTm(Year); |
|
|
|
tm.Year = CalendarYrToTm(Year); |
|
|
|
tm.Month = Month; |
|
|
|
tm.Month = Month; |
|
|
@ -52,7 +60,7 @@ To convert a String to an IP address, use **IPAddress::fromString**. To stringiz |
|
|
|
|
|
|
|
|
|
|
|
```cpp |
|
|
|
```cpp |
|
|
|
IPAddress ip; |
|
|
|
IPAddress ip; |
|
|
|
AutoConnectInput& input aux.getElement<AutoConnectInput>("INPUT"); |
|
|
|
AutoConnectInput& input aux["INPUT"].as<AutoConnectInput>(); |
|
|
|
ip.fromString(input.value); |
|
|
|
ip.fromString(input.value); |
|
|
|
input.value = ip.toString(); |
|
|
|
input.value = ip.toString(); |
|
|
|
``` |
|
|
|
``` |
|
|
@ -108,9 +116,9 @@ static const char input_page[] PROGMEM = R"raw( |
|
|
|
AutoConnect portal; |
|
|
|
AutoConnect portal; |
|
|
|
|
|
|
|
|
|
|
|
String checkIPAddress(AutoConnectAux& aux, PageArgument& args) { |
|
|
|
String checkIPAddress(AutoConnectAux& aux, PageArgument& args) { |
|
|
|
AutoConnectAux* input_page = portal.aux("/"); |
|
|
|
AutoConnectAux& input_page = *portal.aux("/"); |
|
|
|
AutoConnectInput& ipaddress = input_page->getElement<AutoConnectInput>("ipaddress"); |
|
|
|
AutoConnectInput& ipaddress = input_page["ipaddress"].as<AutoConnectInput>(); |
|
|
|
AutoConnectText& result = aux.getElement<AutoConnectText>("result"); |
|
|
|
AutoConnectText& result = aux["result"].as<AutoConnectText>(); |
|
|
|
|
|
|
|
|
|
|
|
if (ipaddress.isValid()) { |
|
|
|
if (ipaddress.isValid()) { |
|
|
|
result.value = "IP Address " + ipaddress.value + " is OK."; |
|
|
|
result.value = "IP Address " + ipaddress.value + " is OK."; |
|
|
|