diff --git a/sdCard_content/WWW/indexV2.htm b/sdCard_content/WWW/indexV2.htm index 2a0b671..300cd35 100644 --- a/sdCard_content/WWW/indexV2.htm +++ b/sdCard_content/WWW/indexV2.htm @@ -43,6 +43,16 @@ { cursor: pointer; } + + .hide + { + display: none; + } + + .show + { + display:block; + } @@ -154,26 +164,27 @@ Enabled -
-
- Connected devivces : -
-
- 0 -
-
-
-
- AP IP : -
-
- -
-
- MAC : -
-
- + +
+
+
+ Connected devices : +
+
+ 0 +
+
+ AP IP : +
+
+ +
+
+ MAC : +
+
+ +
@@ -309,7 +320,8 @@ Available OTA update :
- + +
diff --git a/sdCard_content/WWW/rsrc/scriptV2.js b/sdCard_content/WWW/rsrc/scriptV2.js index 855ea66..2829495 100644 --- a/sdCard_content/WWW/rsrc/scriptV2.js +++ b/sdCard_content/WWW/rsrc/scriptV2.js @@ -18,6 +18,7 @@ var setFrequencyReq = null; var setRTCReq = null; var sdCardSizeReq = null; var sdCardActionReq = null; +var apStationReq = null; var setIoModeReq = null; var setIoLevelReq = null; @@ -111,6 +112,7 @@ function init() App.registerAutomatedRequest({timeout:5000, pollInterval: 5000, apiEndPoint:deviceIPAddr + '/sab/io/get/mode', gotResponse:(data) => {ioModeRefreshHandler(data, 'OK');}, gotError:(e) => {ioModeRefreshHandler(e, 'FAIL');}}); App.registerAutomatedRequest({timeout:5000, pollInterval: 1000, apiEndPoint:deviceIPAddr + '/sab/io/get/level', gotResponse:(data) => {ioLevelRefreshHandler(data, 'OK');}, gotError:(e) => {ioLevelRefreshHandler(e, 'FAIL');}}); App.registerAutomatedRequest({timeout:5000, pollInterval: 10000, apiEndPoint:deviceIPAddr + '/sab/power/info', gotResponse:(data) => {powerInfoRefreshHandler(data, 'OK');}, gotError:(e) => {powerInfoRefreshHandler(e, 'FAIL');}}); + App.registerAutomatedRequest({timeout:5000, pollInterval: 10000, apiEndPoint:deviceIPAddr + '/sab/power/info', gotResponse:(data) => {powerInfoRefreshHandler(data, 'OK');}, gotError:(e) => {powerInfoRefreshHandler(e, 'FAIL');}}); //All requests needing an UI action: setFrequencyReq = App.buildXMLHttpRequest({timeout:2000, gotResponse:(data) => {setFreqHandler(data, 'OK');}, gotError:(e) => {setFreqHandler(e, 'FAIL');}}); @@ -120,6 +122,7 @@ function init() setIoModeReq = App.buildXMLHttpRequest({timeout:2000, gotResponse:(data) => {setIoModeHandler(data, 'OK');}, gotError:(e) => {setIoModeHandler(e, 'FAIL');}}); setIoLevelReq = App.buildXMLHttpRequest({timeout:2000, gotResponse:(data) => {setIoLevelHandler(data, 'OK');}, gotError:(e) => {setIoLevelHandler(e, 'FAIL');}}); scanNetworkReq = App.buildXMLHttpRequest({timeout:2000, gotResponse:(data) => {scanAvailableNetworksHandler(data, 'OK');}, gotError:(e) => {scanAvailableNetworksHandler(data, 'FAIL');}}); + apStationReq = App.buildXMLHttpRequest({timeout:2000, gotResponse:(data) => {apStationHandler(data, 'OK');}, gotError:(e) => {apStationHandler(data, 'FAIL');}}); } //Callback functions @@ -193,6 +196,7 @@ function staInfoRefreshHandler(data,kind) elemById('sigStrength').innerHTML = wifiStaObj.RSSI; elemById('sigStrengthPercent').innerHTML = wifiStaObj.RSSI2; elemById('localIP').innerHTML = wifiStaObj['local IP']; + elemById('sta_mac').innerHTML = wifiStaObj.MAC; setSigStrenthPicture(wifiStaObj.RSSI2); } else @@ -375,6 +379,36 @@ function scanAvailableNetworksHandler(data, kind) } } +function apStationHandler(data, kind) +{ + if(kind === 'OK') + { + var apStationObj = JSON.parse(data); + var apEnabled = apStationObj.AP === 'enabled'; + elemById('ap_enabled_id').checked = apEnabled; + if(apEnabled) + { + elemById('ap_connected_dev_count_id').innerHTML = apStationObj['STA count']; + elemById('ap_IP').innerHTML = apStationObj['AP IP']; + elemById('ap_MAC').innerHTML = apStationObj.MAC; + elemById('ssid').value = apStationObj.SSID; + elemById('ap_password').value = apStationObj.Password; + } + else + { + elemById('ap_connected_dev_count_id').innerHTML = '0'; + elemById('ap_IP').innerHTML = 'Nan'; + elemById('ap_MAC').innerHTML = 'Nan'; + elemById('ssid').value = ''; + elemById('ap_password').value = ''; + } + } + else + { + elemById('ap_enabled_id').checked = false; + } +} + //All UI action functions are here function setCpuFrequ(freq) @@ -451,6 +485,12 @@ function scanAvailableNetworks() scanNetworkReq.send(); } +function apStation() +{ + apStationReq.open('GET', deviceIPAddr + "/sab/wifi/apinfo"); + apStationReq.send(); +} + App = { init:function() @@ -499,6 +539,7 @@ App = { /*We need to update everything when we connect*/ this.updateApp(); sdCardSize(); + apStation(); } }, registerAutomatedRequest:function(param) diff --git a/src/app/WEBServerManager.cpp b/src/app/WEBServerManager.cpp index 1b7faf9..21529db 100644 --- a/src/app/WEBServerManager.cpp +++ b/src/app/WEBServerManager.cpp @@ -1,8 +1,8 @@ #include "WEBServerManager.h" #include "definition.h" -//#define DEBUG_WEB_SERVER_MANAGER(...) do {} while(0) -#define DEBUG_WEB_SERVER_MANAGER(...) do { Serial.printf(__VA_ARGS__); Serial.println();} while(0) +#define DEBUG_WEB_SERVER_MANAGER(...) do {} while(0) +//#define DEBUG_WEB_SERVER_MANAGER(...) do { Serial.printf(__VA_ARGS__); Serial.println();} while(0) WEBServerManager::WEBServerManager(SDCardManager &sdCardManager) : _sdCardManager(&sdCardManager), _webServer(80, &sdCardManager, 10) { diff --git a/src/app/webApi.cpp b/src/app/webApi.cpp index 401022a..e59e7b0 100644 --- a/src/app/webApi.cpp +++ b/src/app/webApi.cpp @@ -227,7 +227,7 @@ boolean staWifiInfoApi(WEBServer::HttpRequestData &HRD, WiFiClient *w char buffer[300]; IPAddress IP = p->getConnectivityManager().localIP(); - sprintf(buffer,"{\"status\":\"ok\",\"RSSI\":%d,\"RSSI2\":%d,\"local IP\":\"%u.%u.%u.%u\",\"mac\":\"%s\"}", p->getConnectivityManager().RSSI(), p->getConnectivityManager().RSSIPercent(), IP[0], IP[1], IP[2], IP[3], p->getConnectivityManager().macAddress().c_str()); + sprintf(buffer,"{\"status\":\"ok\",\"RSSI\":%d,\"RSSI2\":%d,\"local IP\":\"%u.%u.%u.%u\",\"MAC\":\"%s\"}", p->getConnectivityManager().RSSI(), p->getConnectivityManager().RSSIPercent(), IP[0], IP[1], IP[2], IP[3], p->getConnectivityManager().macAddress().c_str()); WEBServer::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer)); wc->print(buffer); @@ -241,10 +241,15 @@ boolean apWifiInfoApi(WEBServer::HttpRequestData &HRD, WiFiClient *wc //We check if the AP is enabled boolean apEnabled = p->getConnectivityManager().getMode() == WIFI_AP || p->getConnectivityManager().getMode() == WIFI_AP_STA; - + if(apEnabled) { - sprintf(buffer, "{\"status\":\"ok\",\"AP\":\"enabled\",\"AP IP\":\"%u.%u.%u.%u\",\"STA count\":%u,\"SSID\":\"%s\",\"Password\":\"%s\"}", + IPAddress apIP = p->getConnectivityManager().softAPIP(); + + sprintf(buffer, "{\"status\":\"ok\",\"AP\":\"enabled\",\"AP IP\":\"%u.%u.%u.%u\",\"MAC\":\"%s\",\"STA count\":%u,\"SSID\":\"%s\",\"Password\":\"%s\"}", + apIP[0], apIP[1], apIP[2], apIP[3], + p->getConnectivityManager().softAPmacAddress().c_str(), + p->getConnectivityManager().softAPgetStationNum(), p->getConnectivityManager().softAPSSID().c_str(), p->getConnectivityManager().softAPPSK().c_str()); } @@ -256,7 +261,6 @@ boolean apWifiInfoApi(WEBServer::HttpRequestData &HRD, WiFiClient *wc } WEBServer::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer)); - wc->print(buffer); return true; }