mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-03-07 15:57:51 +01:00
allow disabling Tasmota JSON API (#1236)
* allow disabling Tasmota JSON API * test enable
This commit is contained in:
@@ -2291,13 +2291,17 @@ int http_fn_cm(http_request_t* request) {
|
||||
http_getRawArg(request->bodystart, "cmnd", long_str_alloced, commandLen);
|
||||
}
|
||||
CMD_ExecuteCommand(long_str_alloced, COMMAND_FLAG_SOURCE_HTTP);
|
||||
#if ENABLE_TASMOTA_JSON
|
||||
JSON_ProcessCommandReply(long_str_alloced, skipToNextWord(long_str_alloced), request, (jsonCb_t)hprintf255, COMMAND_FLAG_SOURCE_HTTP);
|
||||
#endif
|
||||
free(long_str_alloced);
|
||||
}
|
||||
}
|
||||
else {
|
||||
CMD_ExecuteCommand(tmpA, COMMAND_FLAG_SOURCE_HTTP);
|
||||
#if ENABLE_TASMOTA_JSON
|
||||
JSON_ProcessCommandReply(tmpA, skipToNextWord(tmpA), request, (jsonCb_t)hprintf255, COMMAND_FLAG_SOURCE_HTTP);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "../driver/drv_local.h"
|
||||
#include "../driver/drv_bl_shared.h"
|
||||
|
||||
#if ENABLE_TASMOTA_JSON
|
||||
|
||||
void JSON_PrintKeyValue_String(void* request, jsonCb_t printer, const char* key, const char* value, bool bComma) {
|
||||
printer(request, "\"%s\":\"%s\"", key, value);
|
||||
if (bComma) {
|
||||
@@ -1049,6 +1051,8 @@ int JSON_ProcessCommandReply(const char* cmd, const char* arg, void* request, js
|
||||
|
||||
return 0;
|
||||
}
|
||||
// close for ENABLE_TASMOTA_JSON
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2062,7 +2062,9 @@ static int http_rest_post_cmd(http_request_t* request) {
|
||||
request->responseCode = code;
|
||||
http_setup(request, httpMimeTypeJson);
|
||||
hprintf255(request, "{\"%s\":%d, \"msg\":\"%s\", \"res\":", type, code, reply);
|
||||
#if ENABLE_TASMOTA_JSON
|
||||
JSON_ProcessCommandReply(cmd, skipToNextWord(cmd), request, (jsonCb_t)hprintf255, COMMAND_FLAG_SOURCE_HTTP);
|
||||
#endif
|
||||
hprintf255(request, "}", code, reply);
|
||||
poststr(request, NULL);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user