The access point section on the dashboard is now filled and corrected a typo. Finished the implementation of the apWifiInfoApi end point, disabled some traces, updated the dashboard's javascript code
This commit is contained in:
parent
ff37020638
commit
436e0d7336
@ -43,6 +43,16 @@
|
||||
{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.hide
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.show
|
||||
{
|
||||
display:block;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@ -154,26 +164,27 @@
|
||||
Enabled
|
||||
</label>
|
||||
</div>
|
||||
<div class="row white-text left-align" style="font-size:1.2em;margin-top: 20px;margin-bottom: -40px;">
|
||||
<div class="col m6">
|
||||
Connected devivces :
|
||||
</div>
|
||||
<div class="col m6">
|
||||
<span id="ap_connected_dev_count_id">0</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row white-text left-align" style="font-size:1.2em;margin-top: 20px;margin-bottom: -40px;">
|
||||
<div class="col m3">
|
||||
AP IP :
|
||||
</div>
|
||||
<div class="col m3">
|
||||
<span id="apIP"></span>
|
||||
</div>
|
||||
<div class="col m3">
|
||||
MAC :
|
||||
</div>
|
||||
<div class="col m3">
|
||||
<span id="ap_mac"></span>
|
||||
|
||||
<div class="white-text" style="font-size:1.2em;margin-top: 20px;margin-bottom: -40px;">
|
||||
<div class="row">
|
||||
<div class="col m6">
|
||||
Connected devices :
|
||||
</div>
|
||||
<div class="col m6">
|
||||
<span id="ap_connected_dev_count_id">0</span>
|
||||
</div>
|
||||
<div class="col m2">
|
||||
AP IP :
|
||||
</div>
|
||||
<div class="col m4">
|
||||
<span id="ap_IP"></span>
|
||||
</div>
|
||||
<div class="col m2">
|
||||
MAC :
|
||||
</div>
|
||||
<div class="col m4">
|
||||
<span id="ap_MAC"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -309,7 +320,8 @@
|
||||
Available OTA update :
|
||||
</div>
|
||||
<div class="col m6">
|
||||
<span id="otaUpdateInfo"></span>
|
||||
<button class="btn waves-effect waves-light lime darken-3" id="otaUpdateAction"><span id="ota_update_message">refresh</span></button>
|
||||
<button class="btn waves-effect waves-light green darken-3 hide" id="otaUpdateAction">update device to <span id="ota_update_version"></span> !</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -227,7 +227,7 @@ boolean staWifiInfoApi(WEBServer<WEBClient>::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<WEBClient>::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer));
|
||||
wc->print(buffer);
|
||||
@ -241,10 +241,15 @@ boolean apWifiInfoApi(WEBServer<WEBClient>::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<WEBClient>::HttpRequestData &HRD, WiFiClient *wc
|
||||
}
|
||||
|
||||
WEBServer<WEBClient>::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer));
|
||||
|
||||
wc->print(buffer);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user