Browse Source

Fix telnet & web debug responsiveness (#896)

fastled^2
Xose Pérez 6 years ago
parent
commit
9f817ae2d0
2 changed files with 19 additions and 4 deletions
  1. +7
    -0
      code/espurna/debug.ino
  2. +12
    -4
      code/espurna/web.ino

+ 7
- 0
code/espurna/debug.ino View File

@ -26,6 +26,8 @@ char _udp_syslog_header[40] = {0};
void _debugSend(char * message) { void _debugSend(char * message) {
bool pause = false;
#if DEBUG_ADD_TIMESTAMP #if DEBUG_ADD_TIMESTAMP
static bool add_timestamp = true; static bool add_timestamp = true;
char timestamp[10] = {0}; char timestamp[10] = {0};
@ -50,6 +52,7 @@ void _debugSend(char * message) {
#endif #endif
_udp_debug.write(message); _udp_debug.write(message);
_udp_debug.endPacket(); _udp_debug.endPacket();
pause = true;
#if SYSTEM_CHECK_ENABLED #if SYSTEM_CHECK_ENABLED
} }
#endif #endif
@ -60,6 +63,7 @@ void _debugSend(char * message) {
_telnetWrite(timestamp, strlen(timestamp)); _telnetWrite(timestamp, strlen(timestamp));
#endif #endif
_telnetWrite(message, strlen(message)); _telnetWrite(message, strlen(message));
pause = true;
#endif #endif
#if DEBUG_WEB_SUPPORT #if DEBUG_WEB_SUPPORT
@ -75,9 +79,12 @@ void _debugSend(char * message) {
snprintf_P(buffer, sizeof(buffer), PSTR("{\"weblog\": \"%s\"}"), m.c_str()); snprintf_P(buffer, sizeof(buffer), PSTR("{\"weblog\": \"%s\"}"), m.c_str());
#endif #endif
wsSend(buffer); wsSend(buffer);
pause = true;
} }
#endif #endif
if (pause) optimistic_yield(100);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------


+ 12
- 4
code/espurna/web.ino View File

@ -43,7 +43,9 @@ void _onReset(AsyncWebServerRequest *request) {
void _onGetConfig(AsyncWebServerRequest *request) { void _onGetConfig(AsyncWebServerRequest *request) {
webLog(request); webLog(request);
if (!webAuthenticate(request)) return request->requestAuthentication(getSetting("hostname").c_str());
if (!webAuthenticate(request)) {
return request->requestAuthentication(getSetting("hostname").c_str());
}
AsyncResponseStream *response = request->beginResponseStream("text/json"); AsyncResponseStream *response = request->beginResponseStream("text/json");
@ -64,7 +66,9 @@ void _onGetConfig(AsyncWebServerRequest *request) {
void _onPostConfig(AsyncWebServerRequest *request) { void _onPostConfig(AsyncWebServerRequest *request) {
webLog(request); webLog(request);
if (!webAuthenticate(request)) return request->requestAuthentication(getSetting("hostname").c_str());
if (!webAuthenticate(request)) {
return request->requestAuthentication(getSetting("hostname").c_str());
}
request->send(_webConfigSuccess ? 200 : 400); request->send(_webConfigSuccess ? 200 : 400);
} }
@ -112,7 +116,9 @@ void _onPostConfigData(AsyncWebServerRequest *request, String filename, size_t i
void _onHome(AsyncWebServerRequest *request) { void _onHome(AsyncWebServerRequest *request) {
webLog(request); webLog(request);
if (!webAuthenticate(request)) return request->requestAuthentication(getSetting("hostname").c_str());
if (!webAuthenticate(request)) {
return request->requestAuthentication(getSetting("hostname").c_str());
}
if (request->header("If-Modified-Since").equals(_last_modified)) { if (request->header("If-Modified-Since").equals(_last_modified)) {
@ -212,7 +218,9 @@ int _onCertificate(void * arg, const char *filename, uint8_t **buf) {
void _onUpgrade(AsyncWebServerRequest *request) { void _onUpgrade(AsyncWebServerRequest *request) {
webLog(request); webLog(request);
if (!webAuthenticate(request)) return request->requestAuthentication(getSetting("hostname").c_str());
if (!webAuthenticate(request)) {
return request->requestAuthentication(getSetting("hostname").c_str());
}
char buffer[10]; char buffer[10];
if (!Update.hasError()) { if (!Update.hasError()) {


Loading…
Cancel
Save