diff --git a/src/Configure.cpp b/src/Configure.cpp index 5fa0375..118727b 100644 --- a/src/Configure.cpp +++ b/src/Configure.cpp @@ -1,10 +1,13 @@ #include "Configure.h" +#include "Settings.h" /////////////////////////////// void Configure::processRequest(WiFiClient &client, char *body, char *formData){ + String s; + if(!strncmp(body,"POST /configure ",16) && // POST CONFIGURE strstr(body,"Content-Type: application/x-www-form-urlencoded")){ // check that content is from a form @@ -13,8 +16,11 @@ void Configure::processRequest(WiFiClient &client, char *body, char *formData){ LOG1("In Post Configure...\n"); - String s="HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n"; - s+="
Initiating WiFi Connection...
"; } else @@ -23,7 +29,7 @@ void Configure::processRequest(WiFiClient &client, char *body, char *formData){ LOG1("In Get WiFi Status...\n"); - String s="HTTP/1.1 200 OK\r\nContent-type: text/html\r\nRefresh: 5\r\n\r\n"; + s+="HTTP/1.1 200 OK\r\nContent-type: text/html\r\nRefresh: 5\r\n\r\n"; s+="Trying to Connect ("; s+=String(millis()/1000) + "sec)...
"; @@ -34,7 +40,7 @@ void Configure::processRequest(WiFiClient &client, char *body, char *formData){ int n=WiFi.scanNetworks(); - String s="HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n"; + s+="HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n"; s+="HomeSpan_12_54_DD_E4_23_F5
Welcome to HomeSpan! This page allows you to configure the above HomeSpan device to connect to your WiFi network, and (if needed) to create a Setup Code for pairing this device to HomeKit.
"; diff --git a/src/Configure.h b/src/Configure.h index bf121b5..feb16df 100644 --- a/src/Configure.h +++ b/src/Configure.h @@ -1,5 +1,5 @@ -#includeHomeSpan_12_54_DD_E4_23_F5
Welcome to HomeSpan! This page allows you to configure the above HomeSpan device to connect to your WiFi network, and (if needed) to create a Setup Code for pairing this device to HomeKit.
"; - s+="The LED on this device should be double-blinking during this configuration.
"; - - s+="
"; - - LOG2("\n>>>>>>>>>> "); - LOG2(client.remoteIP()); - LOG2(" >>>>>>>>>>\n"); - LOG2(s); - LOG2("\n"); - client.print(s); - LOG2("------------ SENT! --------------\n"); - - return(1); -} - -////////////////////////////////////// - -int HAPClient::postConfigureURL(char *formData){ - - LOG1("In Post Configure...\n"); - - String s="HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n"; - s+="Initiating WiFi Connection...
"; - - LOG2("\n>>>>>>>>>> "); - LOG2(client.remoteIP()); - LOG2(" >>>>>>>>>>\n"); - LOG2(s); - LOG2("\n"); - client.print(s); - LOG2("------------ SENT! --------------\n"); - - return(1); -} - -////////////////////////////////////// - -int HAPClient::getWiFiStatusURL(){ - - LOG1("In Get WiFi Status...\n"); - - String s="HTTP/1.1 200 OK\r\nContent-type: text/html\r\nRefresh: 5\r\n\r\n"; - s+="Trying to Connect ("; - s+=String(millis()/1000) + "sec)...
"; - - LOG2("\n>>>>>>>>>> "); - LOG2(client.remoteIP()); - LOG2(" >>>>>>>>>>\n"); - LOG2(s); - LOG2("\n"); - client.print(s); - LOG2("------------ SENT! --------------\n"); - - return(1); -} - -////////////////////////////////////// - int HAPClient::postPairSetupURL(){ LOG1("In Pair Setup..."); diff --git a/src/HAP.h b/src/HAP.h index 1a0a8df..6c4aa2d 100644 --- a/src/HAP.h +++ b/src/HAP.h @@ -82,11 +82,7 @@ struct HAPClient { // define member methods - void processRequest(); // process HAP request - int captiveAccessURL(); // default process for requests made when in captive access point mode - int postConfigureURL(char *formData); // POST /configure (used to process captive access mode form) - int getWiFiStatusURL(); // GET /wifi-status (used to check status of connecting to WiFi network) - + void processRequest(); // process HAP request int postPairSetupURL(); // POST /pair-setup (HAP Section 5.6) int postPairVerifyURL(); // POST /pair-verify (HAP Section 5.7) int getAccessoriesURL(); // GET /accessories (HAP Section 6.6) diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 11431d0..8844f2f 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -387,78 +387,6 @@ void Span::configure(char *apName){ } while(1); - - - while(!needsConfiguration){ - dnsServer.processNextRequest(); - WiFiClient apClient=apServer.available(); - - if(apClient){ // found a new HTTP client - Serial.print("Client Found: "); - Serial.println(apClient.remoteIP()); - - while(apClient.available()){ // data is available - - int nBytes=apClient.read(HAPClient::httpBuf,HAPClient::MAX_HTTP); // read all available bytes up to maximum allowed - char *p=(char *)HAPClient::httpBuf; - p[nBytes]='\0'; - Serial.print(p); - Serial.print("\n"); - - if(!strncmp(p,"GET /",5)){ - apClient.println("HTTP/1.1 200 OK"); - apClient.println("Content-type:text/html"); - apClient.println(); - - apClient.print("HomeSpan_12_54_DD_E4_23_F5
Welcome to HomeSpan! This page allows you to configure the above HomeSpan device to connect to your WiFi network, and to create a Setup Code for pairing this device to HomeKit.
"); - apClient.print("WiFi Network is a required field. If your network name is broadcast you can select it from the dropdown list. If you don't see your network name in the dropdown list you may type it into the text box.
"); - apClient.print("WiFi Password is required only if your network is password-protected.
"); - apClient.print("Every HomeKit device requires an 8-digit Setup Code. If this device is being configured for the first time, or if the device has been factory reset, you must create a new Setup Code. "); - apClient.print("Otherwise, either leave this field blank to retain the current Setup Code, or type a new 8-digit Setup Code to replace the current one.
"); - apClient.print("Note that HomeSpan cannot display a previously saved Setup Code, so if you've forgotten what it is, this is the place to create a new one.
"); - apClient.print("The LED on this device should be double-blinking during this configuration.
"); - - apClient.print("
"); - } // GET - - if(!strncmp(p,"POST /",6)){ - apClient.println("HTTP/1.1 200 OK"); - apClient.println("Content-type:text/html"); - apClient.println(); - apClient.println("SUCCESS"); - } - - } // data available - - apClient.stop(); - } - - } }