mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 12:46:34 +00:00
Add webquery message when empty response
This commit is contained in:
parent
07031d5ebf
commit
62afe918f0
@ -3356,39 +3356,43 @@ int WebQuery(char *buffer) {
|
|||||||
#ifdef USE_WEBSEND_RESPONSE
|
#ifdef USE_WEBSEND_RESPONSE
|
||||||
if (http_code == HTTP_CODE_OK || http_code == HTTP_CODE_MOVED_PERMANENTLY) {
|
if (http_code == HTTP_CODE_OK || http_code == HTTP_CODE_MOVED_PERMANENTLY) {
|
||||||
// Return received data to the user - Adds 900+ bytes to the code
|
// Return received data to the user - Adds 900+ bytes to the code
|
||||||
String response = http.getString(); // File found at server - may need lot of ram or trigger out of memory!
|
String response = http.getString(); // File found at server - may need lot of ram or trigger out of memory!
|
||||||
const char* read = response.c_str();
|
const char* read = response.c_str();
|
||||||
|
|
||||||
// uint32_t len = response.length() + 1;
|
// uint32_t len = response.length() + 1;
|
||||||
// AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Response '%*_H' = %s"), len, (uint8_t*)read, read);
|
// AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Response '%*_H' = %s"), len, (uint8_t*)read, read);
|
||||||
|
|
||||||
Response_P(PSTR("{\"" D_CMND_WEBQUERY "\":"));
|
|
||||||
char text[3] = { 0 }; // Make room foor double %
|
char text[3] = { 0 }; // Make room foor double %
|
||||||
text[0] = *read++;
|
text[0] = *read++;
|
||||||
bool assume_json = (text[0] == '{') || (text[0] == '[');
|
if (text[0] != '\0') {
|
||||||
if (!assume_json) { ResponseAppend_P(PSTR("\"")); }
|
Response_P(PSTR("{\"" D_CMND_WEBQUERY "\":"));
|
||||||
while (text[0] != '\0') {
|
bool assume_json = (text[0] == '{') || (text[0] == '[');
|
||||||
if (text[0] > 31) { // Remove control characters like linefeed
|
if (!assume_json) { ResponseAppend_P(PSTR("\"")); }
|
||||||
if ('%' == text[0]) { // Fix char string expansion for %
|
while (text[0] != '\0') {
|
||||||
text[1] = '%';
|
if (text[0] > 31) { // Remove control characters like linefeed
|
||||||
}
|
if ('%' == text[0]) { // Fix char string formatting for %
|
||||||
if (assume_json) {
|
text[1] = '%';
|
||||||
if (ResponseAppend_P(text) == ResponseSize()) { break; };
|
}
|
||||||
} else {
|
if (assume_json) {
|
||||||
if (ResponseAppend_P(EscapeJSONString(text).c_str()) == ResponseSize()) { break; };
|
if (ResponseAppend_P(text) == ResponseSize()) { break; };
|
||||||
|
} else {
|
||||||
|
if (ResponseAppend_P(EscapeJSONString(text).c_str()) == ResponseSize()) { break; };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
text[0] = *read++;
|
||||||
|
text[1] = '\0';
|
||||||
}
|
}
|
||||||
text[0] = *read++;
|
if (!assume_json) { ResponseAppend_P(PSTR("\"")); }
|
||||||
text[1] = '\0';
|
ResponseJsonEnd();
|
||||||
}
|
|
||||||
if (!assume_json) { ResponseAppend_P(PSTR("\"")); }
|
|
||||||
ResponseJsonEnd();
|
|
||||||
#ifdef USE_SCRIPT
|
#ifdef USE_SCRIPT
|
||||||
extern uint8_t tasm_cmd_activ;
|
extern uint8_t tasm_cmd_activ;
|
||||||
// recursive call must be possible in this case
|
// recursive call must be possible in this case
|
||||||
tasm_cmd_activ = 0;
|
tasm_cmd_activ = 0;
|
||||||
#endif // USE_SCRIPT
|
#endif // USE_SCRIPT
|
||||||
status = WEBCMND_VALID_RESPONSE;
|
status = WEBCMND_VALID_RESPONSE;
|
||||||
|
} else {
|
||||||
|
status = WEBCMND_DONE;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
#endif // USE_WEBSEND_RESPONSE
|
#endif // USE_WEBSEND_RESPONSE
|
||||||
status = WEBCMND_DONE;
|
status = WEBCMND_DONE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user