From fd3b00ecd51e204870993eeba1bc6f153689e66d Mon Sep 17 00:00:00 2001 From: Gregg Date: Thu, 3 Sep 2020 07:07:07 -0500 Subject: [PATCH] created get wifi-status --- src/HAP.cpp | 32 ++++++++++++++++++++++++++++++-- src/HAP.h | 1 + 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/HAP.cpp b/src/HAP.cpp index 19ee483..321e126 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -176,6 +176,11 @@ void HAPClient::processRequest(){ return; } + if(!strncmp(body,"GET /wifi-status ",17)){ // GET WIFI-STATUS + getWiFiStatusURL(); + return; + } + captiveAccessURL(); // default action for all other URLs when in captive Access Point mode return; @@ -407,8 +412,9 @@ int HAPClient::postConfigureURL(char *formData){ LOG1("In Post Configure...\n"); - String s="HTTP/1.1 200 OK\r\nContent-type: text/html\r\nRefresh: 5\r\n\r\n"; - s+="OKAY"; + String s="HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n"; + s+="Initiating"; + s+="

Initiating WiFi Connection...

"; LOG2("\n>>>>>>>>>> "); LOG2(client.remoteIP()); @@ -423,6 +429,28 @@ int HAPClient::postConfigureURL(char *formData){ ////////////////////////////////////// +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+="Connection Status"; + 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 94f89e5..9716c4e 100644 --- a/src/HAP.h +++ b/src/HAP.h @@ -83,6 +83,7 @@ struct HAPClient { 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) int postPairSetupURL(); // POST /pair-setup (HAP Section 5.6) int postPairVerifyURL(); // POST /pair-verify (HAP Section 5.7)