|
|
@@ -17,18 +17,18 @@ ESP8266WebServer server(80); //creating the server at port 80 |
|
|
|
IPAddress apIP(192, 168, 4, 1); |
|
|
|
IPAddress netMsk(255, 255, 255, 0); |
|
|
|
|
|
|
|
volatile bool cts = true; |
|
|
|
|
|
|
|
void setup() { |
|
|
|
Serial.begin(19200); |
|
|
|
// put your setup code here, to run once: |
|
|
|
|
|
|
|
Serial.print("Configuring access point..."); |
|
|
|
//Serial.print("Configuring access point..."); |
|
|
|
/* You can remove the password parameter if you want the AP to be open. */ |
|
|
|
WiFi.mode(WIFI_AP); |
|
|
|
WiFi.softAPConfig(apIP, apIP, netMsk); |
|
|
|
WiFi.softAP(ssid); /*, password*/ |
|
|
|
delay(500); // Without delay I've seen the IP address blank |
|
|
|
//Serial.print("AP IP address: "); |
|
|
|
//Serial.println(WiFi.softAPIP()); |
|
|
|
|
|
|
|
/* Setup the DNS server redirecting all the domains to the apIP */ |
|
|
|
dnsServer.setErrorReplyCode(DNSReplyCode::NoError); |
|
|
@@ -46,56 +46,60 @@ void handleroot() { |
|
|
|
} |
|
|
|
|
|
|
|
void formdata() { |
|
|
|
char op='+'; |
|
|
|
char sw1='0',sw2='0',sw3='0',sw4='0',sw5='0',sw6='0',sw7='0',sw8='0',sw9='0',sw10='0'; |
|
|
|
if(server.hasArg("op")) { |
|
|
|
if(server.arg("op").equals("m")) { |
|
|
|
op = '-'; |
|
|
|
if(cts) { |
|
|
|
cts = false; |
|
|
|
char op='+'; |
|
|
|
char sw1='0',sw2='0',sw3='0',sw4='0',sw5='0',sw6='0',sw7='0',sw8='0',sw9='0',sw10='0'; |
|
|
|
if(server.hasArg("op")) { |
|
|
|
if(server.arg("op").equals("m")) { |
|
|
|
op = '-'; |
|
|
|
} |
|
|
|
} |
|
|
|
if(server.hasArg("switch1")) { |
|
|
|
sw1 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch2")) { |
|
|
|
sw2 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch3")) { |
|
|
|
sw3 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch4")) { |
|
|
|
sw4 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch5")) { |
|
|
|
sw5 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch6")) { |
|
|
|
sw6 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch7")) { |
|
|
|
sw7 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch8")) { |
|
|
|
sw8 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch9")) { |
|
|
|
sw9 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch10")) { |
|
|
|
sw10 = '1'; |
|
|
|
} |
|
|
|
Serial.print('A'); |
|
|
|
Serial.print(op); |
|
|
|
Serial.print(sw1); |
|
|
|
Serial.print(sw2); |
|
|
|
Serial.print(sw3); |
|
|
|
Serial.print(sw4); |
|
|
|
Serial.print(sw5); |
|
|
|
Serial.print(sw6); |
|
|
|
Serial.print(sw7); |
|
|
|
Serial.print(sw8); |
|
|
|
Serial.print(sw9); |
|
|
|
Serial.print(sw10); |
|
|
|
Serial.print('E'); |
|
|
|
cts = true; |
|
|
|
} |
|
|
|
if(server.hasArg("switch1")) { |
|
|
|
sw1 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch2")) { |
|
|
|
sw2 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch3")) { |
|
|
|
sw3 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch4")) { |
|
|
|
sw4 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch5")) { |
|
|
|
sw5 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch6")) { |
|
|
|
sw6 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch7")) { |
|
|
|
sw7 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch8")) { |
|
|
|
sw8 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch9")) { |
|
|
|
sw9 = '1'; |
|
|
|
} |
|
|
|
if(server.hasArg("switch10")) { |
|
|
|
sw10 = '1'; |
|
|
|
} |
|
|
|
Serial.print('A'); |
|
|
|
Serial.print(op); |
|
|
|
Serial.print(sw1); |
|
|
|
Serial.print(sw2); |
|
|
|
Serial.print(sw3); |
|
|
|
Serial.print(sw4); |
|
|
|
Serial.print(sw5); |
|
|
|
Serial.print(sw6); |
|
|
|
Serial.print(sw7); |
|
|
|
Serial.print(sw8); |
|
|
|
Serial.print(sw9); |
|
|
|
Serial.print(sw10); |
|
|
|
Serial.print('E'); |
|
|
|
server.sendHeader("Location", String("/"), true); |
|
|
|
server.send ( 302, "text/plain", ""); |
|
|
|
} |
|
|
|