Fix for SoftAP bugs

This commit is contained in:
Jm Casler
2021-12-23 18:18:07 -08:00
parent a192da5cd0
commit 2d8bf4d684
7 changed files with 52 additions and 87 deletions

View File

@@ -105,8 +105,6 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
secureServer->registerNode(nodeJsonReport);
secureServer->registerNode(nodeRoot);
secureServer->addMiddleware(&middlewareSpeedUp240);
// Insecure nodes
insecureServer->registerNode(nodeAPIv1ToRadioOptions);
insecureServer->registerNode(nodeAPIv1ToRadio);
@@ -122,42 +120,6 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
insecureServer->registerNode(nodeJsonReport);
insecureServer->registerNode(nodeRoot);
insecureServer->addMiddleware(&middlewareSpeedUp160);
}
void middlewareSpeedUp240(HTTPRequest *req, HTTPResponse *res, std::function<void()> next)
{
// We want to print the response status, so we need to call next() first.
next();
// Phone (or other device) has contacted us over WiFi. Keep the radio turned on.
// TODO: This should go into its own middleware layer separate from the speedup.
powerFSM.trigger(EVENT_CONTACT_FROM_PHONE);
setCpuFrequencyMhz(240);
setTimeSpeedUp();
numberOfRequests++;
}
void middlewareSpeedUp160(HTTPRequest *req, HTTPResponse *res, std::function<void()> next)
{
// We want to print the response status, so we need to call next() first.
next();
// Phone (or other device) has contacted us over WiFi. Keep the radio turned on.
// TODO: This should go into its own middleware layer separate from the speedup.
powerFSM.trigger(EVENT_CONTACT_FROM_PHONE);
// If the frequency is 240mhz, we have recently gotten a HTTPS request.
// In that case, leave the frequency where it is and just update the
// countdown timer (timeSpeedUp).
if (getCpuFrequencyMhz() != 240) {
setCpuFrequencyMhz(160);
}
setTimeSpeedUp();
numberOfRequests++;
}
void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res)
@@ -403,10 +365,6 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
DEBUG_MSG("Form Upload - Disabling keep-alive\n");
res->setHeader("Connection", "close");
DEBUG_MSG("Form Upload - Set frequency to 240mhz\n");
// The upload process is very CPU intensive. Let's speed things up a bit.
setCpuFrequencyMhz(240);
// First, we need to check the encoding of the form that we have received.
// The browser will set the Content-Type request header, so we can use it for that purpose.
// Then we select the body parser based on the encoding.
@@ -736,15 +694,11 @@ void handleScanNetworks(HTTPRequest *req, HTTPResponse *res)
for (int i = 0; i < n; ++i) {
char ssidArray[50];
String ssidString = String(WiFi.SSID(i));
// String ssidString = String(WiFi.SSID(i)).toCharArray(ssidArray, WiFi.SSID(i).length());
ssidString.replace("\"", "\\\"");
ssidString.toCharArray(ssidArray, 50);
if (WiFi.encryptionType(i) != WIFI_AUTH_OPEN) {
// res->println("{\"ssid\": \"%s\",\"rssi\": -75}, ", String(WiFi.SSID(i).c_str() );
res->printf("{\"ssid\": \"%s\",\"rssi\": %d}", ssidArray, WiFi.RSSI(i));
// WiFi.RSSI(i)
if (i != n - 1) {
res->printf(",");
}