mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-10-27 06:21:26 +00:00
[JSON] Also update OLED display preview in JSON
This commit is contained in:
1 parent
69f04fe375
commit
775f69dcec
17 files changed
+209
-189
No files matched your search
+1
-1
@@ -249,7 +249,7 @@ boolean Plugin_023(uint8_t function, struct EventStruct *event, String& string)
|
||||
P023_data_struct *P023_data =
|
||||
static_cast<P023_data_struct *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
success = nullptr != P023_data && P023_data->web_show_values();
|
||||
success = nullptr != P023_data && P023_data->web_show_values(event);
|
||||
break;
|
||||
}
|
||||
# endif // if P023_FEATURE_DISPLAY_PREVIEW
|
||||
|
||||
@@ -1078,7 +1078,7 @@ boolean Plugin_036(uint8_t function, struct EventStruct *event, String& string)
|
||||
static_cast<P036_data_struct *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
if (nullptr != P036_data) {
|
||||
success = P036_data->web_show_values();
|
||||
success = P036_data->web_show_values(event);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -267,7 +267,10 @@ boolean Plugin_077(uint8_t function, struct EventStruct *event, String& string)
|
||||
const float pulsesPerKwh = P077_data->cf_frequency * 3600;
|
||||
const float kWh = P077_data->cf_pulses / pulsesPerKwh;
|
||||
TaskValuesWriterHelper data(event);
|
||||
data.writeCustom(varNr++, F("kWh"), toString(kWh, 3), true);
|
||||
|
||||
data.setWriteRegularTaskValuesFirst();
|
||||
data.writeCustom(varNr++, F("kWh"), toString(kWh, 3));
|
||||
success = true; // Do not write other taskvalues
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+3
-2
@@ -89,12 +89,13 @@ boolean Plugin_082(uint8_t function, struct EventStruct *event, String& string)
|
||||
if ((nullptr != P082_data) && P082_data->isInitialized()) {
|
||||
uint8_t varNr = VARS_PER_TASK;
|
||||
TaskValuesWriterHelper data(event);
|
||||
data.setWriteRegularTaskValuesFirst();
|
||||
data.writeCustom(varNr++, F("Fix"), String(P082_data->hasFix(P082_TIMEOUT) ? 1 : 0));
|
||||
data.writeCustom(varNr++, F("Tracked"),
|
||||
String(P082_data->gps->satellitesStats.nrSatsTracked()));
|
||||
data.writeCustom(varNr++, F("Best SNR"), String(P082_data->gps->satellitesStats.getBestSNR()), true);
|
||||
data.writeCustom(varNr++, F("Best SNR"), String(P082_data->gps->satellitesStats.getBestSNR()));
|
||||
|
||||
// success = true;
|
||||
success = true; // Do not write other taskvalues
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -114,15 +114,15 @@ boolean Plugin_087(uint8_t function, struct EventStruct *event, String& string)
|
||||
static_cast<P087_data_struct *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
if ((nullptr != P087_data) && P087_data->isInitialized()) {
|
||||
uint32_t success, error, length_last;
|
||||
P087_data->getSentencesReceived(success, error, length_last);
|
||||
uint32_t success_count, error, length_last;
|
||||
P087_data->getSentencesReceived(success_count, error, length_last);
|
||||
uint8_t varNr = VARS_PER_TASK;
|
||||
TaskValuesWriterHelper data(event);
|
||||
data.writeCustom(varNr++, F("Success"), String(success));
|
||||
data.setWriteRegularTaskValuesFirst();
|
||||
data.writeCustom(varNr++, F("Success"), String(success_count));
|
||||
data.writeCustom(varNr++, F("Error"), String(error));
|
||||
data.writeCustom(varNr++, F("Length Last"), String(length_last), true);
|
||||
|
||||
// success = true;
|
||||
data.writeCustom(varNr++, F("Length Last"), String(length_last));
|
||||
success = true; // Do not write other taskvalues
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -112,15 +112,16 @@ boolean Plugin_094(uint8_t function, struct EventStruct *event, String& string)
|
||||
static_cast<P094_data_struct *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
if ((nullptr != P094_data) && P094_data->isInitialized()) {
|
||||
uint32_t success, error, length_last;
|
||||
P094_data->getSentencesReceived(success, error, length_last);
|
||||
uint32_t success_count, error, length_last;
|
||||
P094_data->getSentencesReceived(success_count, error, length_last);
|
||||
uint8_t varNr = VARS_PER_TASK;
|
||||
TaskValuesWriterHelper data(event);
|
||||
data.writeCustom(varNr++, F("Success"), String(success));
|
||||
data.setWriteRegularTaskValuesFirst();
|
||||
data.writeCustom(varNr++, F("Success"), String(success_count));
|
||||
data.writeCustom(varNr++, F("Error"), String(error));
|
||||
data.writeCustom(varNr++, F("Length Last"), String(length_last), true);
|
||||
data.writeCustom(varNr++, F("Length Last"), String(length_last));
|
||||
|
||||
// success = true;
|
||||
success = true; // Do not write other taskvalues
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -282,9 +282,9 @@ boolean Plugin_124(uint8_t function, struct EventStruct *event, String& string)
|
||||
state += ull2String(val, 2);
|
||||
state.remove(3, 1); // Delete leading 1 we added
|
||||
TaskValuesWriterHelper data(event);
|
||||
data.writeCustom(varNr++, label, state, true);
|
||||
|
||||
// success = true;
|
||||
data.setWriteRegularTaskValuesFirst();
|
||||
data.writeCustom(varNr++, label, state);
|
||||
success = true; // Do not write other taskvalues
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -384,7 +384,8 @@ boolean Plugin_126(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
string += value;
|
||||
TaskValuesWriterHelper data(event);
|
||||
data.writeCustom(varNr, label, value, true);
|
||||
data.writeCustom(varNr, label, value);
|
||||
success = true; // Do not write other taskvalues
|
||||
}
|
||||
}
|
||||
success = true; // Don't show the default value data
|
||||
|
||||
@@ -477,7 +477,8 @@ boolean Plugin_129(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
string += value;
|
||||
TaskValuesWriterHelper data(event);
|
||||
data.writeCustom(varNr, label, value, true);
|
||||
data.writeCustom(varNr, label, value);
|
||||
success = true; // Do not write other taskvalues
|
||||
}
|
||||
}
|
||||
success = true; // Don't show the default value data
|
||||
|
||||
@@ -30,6 +30,7 @@ void TaskValuesWriterHelper::clear()
|
||||
valName_id.clear();
|
||||
value.clear();
|
||||
value_id.clear();
|
||||
attribute.clear();
|
||||
#if FEATURE_TASKVALUE_UNIT_OF_MEASURE
|
||||
uom.clear();
|
||||
#endif
|
||||
@@ -37,8 +38,9 @@ void TaskValuesWriterHelper::clear()
|
||||
hasPresentation = false;
|
||||
presentation.clear();
|
||||
#endif // if FEATURE_STRING_VARIABLES
|
||||
nrDecimals = 0;
|
||||
addTrailingBreak = false;
|
||||
nrDecimals = 0;
|
||||
_writeRegularTaskValuesFirst = false;
|
||||
_isLast = false;
|
||||
}
|
||||
|
||||
void TaskValuesWriterHelper::setID(uint8_t varNr)
|
||||
@@ -62,12 +64,17 @@ void TaskValuesWriterHelper::setID(uint8_t varNr)
|
||||
#endif // if FEATURE_STRING_VARIABLES
|
||||
}
|
||||
|
||||
void TaskValuesWriterHelper::setAttribute(const __FlashStringHelper *attr) { attribute = attr; }
|
||||
|
||||
void TaskValuesWriterHelper::write()
|
||||
{
|
||||
if (!validDeviceIndex(deviceIndex)) { return; }
|
||||
|
||||
if (event->kvWriter) { handle_json_stream_task_value_data(this); }
|
||||
else { pluginWebformShowValue(); }
|
||||
if (event->kvWriter) {
|
||||
handle_json_stream_task_value_data(this);
|
||||
} else {
|
||||
pluginWebformShowValue();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskValuesWriterHelper::writeTaskValues()
|
||||
@@ -85,18 +92,25 @@ void TaskValuesWriterHelper::writeTaskValues()
|
||||
#endif
|
||||
}
|
||||
|
||||
void TaskValuesWriterHelper::writeCustom(uint8_t varNr, const __FlashStringHelper * label, const String& val, bool addTrailing_Break)
|
||||
void TaskValuesWriterHelper::writeCustom(uint8_t varNr, const __FlashStringHelper *label, const String& val, bool isLast)
|
||||
{
|
||||
writeCustom(varNr, String(label), val, addTrailing_Break);
|
||||
writeCustom(varNr, String(label), val, isLast);
|
||||
}
|
||||
|
||||
void TaskValuesWriterHelper::writeCustom(uint8_t varNr, const String& label, const String& val, bool addTrailing_Break)
|
||||
void TaskValuesWriterHelper::writeCustom(uint8_t varNr, const String& label, const String& val, bool isLast)
|
||||
{
|
||||
if (!validDeviceIndex(deviceIndex)) { return; }
|
||||
|
||||
if (_writeRegularTaskValuesFirst) {
|
||||
writeRegularTaskValues();
|
||||
#if FEATURE_STRING_VARIABLES
|
||||
writeDerivedTaskValues();
|
||||
#endif
|
||||
}
|
||||
clear();
|
||||
_isLast = isLast;
|
||||
valName = label;
|
||||
value = val;
|
||||
addTrailingBreak = addTrailing_Break;
|
||||
value = val;
|
||||
setID(varNr);
|
||||
write();
|
||||
}
|
||||
@@ -191,28 +205,37 @@ void TaskValuesWriterHelper::writeDerivedTaskValues()
|
||||
|
||||
void TaskValuesWriterHelper::pluginWebformShowValue()
|
||||
{
|
||||
if (!validDeviceIndex(deviceIndex)) return;
|
||||
if (!validDeviceIndex(deviceIndex)) { return; }
|
||||
|
||||
if ((valueNumber == 0) && _monoSpaced) { addHtml(F("<pre>")); } // To keep spaces etc. in the shown
|
||||
// output
|
||||
|
||||
if (valueNumber > 0) {
|
||||
addHtmlDiv(F("div_br"));
|
||||
}
|
||||
if (hasPresentation) value = presentation;
|
||||
else if (!uom.isEmpty())
|
||||
value += concat(' ', uom);
|
||||
|
||||
if (hasPresentation) { value = presentation; }
|
||||
else if (!uom.isEmpty()) {
|
||||
value += concat(' ', uom);
|
||||
}
|
||||
|
||||
String valName_tmp(valName);
|
||||
|
||||
if (!valName_tmp.endsWith(F(":"))) {
|
||||
if (!_monoSpaced && !valName_tmp.endsWith(F(":"))) {
|
||||
valName_tmp += ':';
|
||||
}
|
||||
addHtmlDiv(F("div_l"), valName_tmp, valName_id);
|
||||
addHtmlDiv(F("div_r"), value, value_id);
|
||||
addHtmlDiv(F("div_l"), valName_tmp, valName_id, attribute);
|
||||
|
||||
if (addTrailingBreak) {
|
||||
addHtmlDiv(F("div_br"));
|
||||
if (!value.isEmpty()) {
|
||||
addHtmlDiv(F("div_r"), value, value_id);
|
||||
}
|
||||
|
||||
if (_isLast && _monoSpaced) {
|
||||
addHtml(F("</pre>")); // To keep spaces etc. in the shown output
|
||||
_monoSpaced = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool TaskValuesWriterHelper::initRegularTaskValue(uint8_t varNr)
|
||||
{
|
||||
if (!validDeviceIndex(deviceIndex)) { return false; }
|
||||
@@ -253,4 +276,3 @@ bool TaskValuesWriterHelper::initRegularTaskValue(uint8_t varNr)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -16,12 +16,27 @@ struct TaskValuesWriterHelper {
|
||||
|
||||
void setID(uint8_t varNr);
|
||||
|
||||
void setAttribute(const __FlashStringHelper *attr);
|
||||
|
||||
void setAttribute(const String& attr) { attribute = attr; }
|
||||
|
||||
void setWriteRegularTaskValuesFirst() { _writeRegularTaskValuesFirst = true; }
|
||||
|
||||
void setMonoSpaced() { _monoSpaced = true; }
|
||||
|
||||
|
||||
void write();
|
||||
|
||||
void writeTaskValues();
|
||||
|
||||
void writeCustom(uint8_t varNr, const __FlashStringHelper * label, const String& val, bool addTrailing_Break = false);
|
||||
void writeCustom(uint8_t varNr, const String& label, const String& val, bool addTrailing_Break = false);
|
||||
void writeCustom(uint8_t varNr,
|
||||
const __FlashStringHelper *label,
|
||||
const String & val,
|
||||
bool isLast = false);
|
||||
void writeCustom(uint8_t varNr,
|
||||
const String& label,
|
||||
const String& val,
|
||||
bool isLast = false);
|
||||
|
||||
private:
|
||||
|
||||
@@ -30,14 +45,14 @@ private:
|
||||
void writeDerivedTaskValues();
|
||||
#endif
|
||||
|
||||
void pluginWebformShowValue();
|
||||
void pluginWebformShowValue();
|
||||
|
||||
bool initRegularTaskValue(uint8_t varNr);
|
||||
|
||||
public:
|
||||
|
||||
EventStruct * const event = nullptr;
|
||||
String valName, valName_id, value, value_id;
|
||||
String valName, valName_id, value, value_id, attribute;
|
||||
#if FEATURE_TASKVALUE_UNIT_OF_MEASURE
|
||||
String uom, uom_id;
|
||||
#endif
|
||||
@@ -49,7 +64,10 @@ public:
|
||||
uint8_t nrDecimals{};
|
||||
uint8_t valueCount{};
|
||||
uint8_t valueNumber{};
|
||||
deviceIndex_t deviceIndex = INVALID_DEVICE_INDEX;
|
||||
bool addTrailingBreak = false;
|
||||
deviceIndex_t deviceIndex = INVALID_DEVICE_INDEX;
|
||||
|
||||
bool _writeRegularTaskValuesFirst{};
|
||||
bool _monoSpaced{};
|
||||
bool _isLast{};
|
||||
|
||||
};
|
||||
@@ -330,8 +330,7 @@ void P023_data_struct::setCurrentText(const String& string, int X, int Y) {
|
||||
}
|
||||
}
|
||||
|
||||
bool P023_data_struct::web_show_values() {
|
||||
bool result = true;
|
||||
bool P023_data_struct::web_show_values(struct EventStruct *event) {
|
||||
uint8_t maxLine = P23_Nlines;
|
||||
|
||||
for (; maxLine > 0; --maxLine) { // Don't show trailing empty lines
|
||||
@@ -341,17 +340,15 @@ bool P023_data_struct::web_show_values() {
|
||||
if (!tmp.isEmpty()) { break; }
|
||||
}
|
||||
|
||||
addHtml(F("<pre>")); // To keep spaces etc. in the shown output
|
||||
TaskValuesWriterHelper data(event);
|
||||
|
||||
for (uint8_t i = 0; i < maxLine; ++i) {
|
||||
addHtmlDiv(F("div_l"), currentLines[i], EMPTY_STRING, F("style='font-size:75%;'"));
|
||||
|
||||
if (i != maxLine - 1) {
|
||||
addHtmlDiv(F("div_br"));
|
||||
}
|
||||
const bool isLast = i == (maxLine - 1);
|
||||
data.setMonoSpaced();
|
||||
data.setAttribute(F("style='font-size:75%;'"));
|
||||
data.writeCustom(i, currentLines[i], EMPTY_STRING, isLast);
|
||||
}
|
||||
addHtml(F("</pre>"));
|
||||
return result;
|
||||
return true; // Don't show anything else
|
||||
}
|
||||
|
||||
#endif // if P023_FEATURE_DISPLAY_PREVIEW
|
||||
|
||||
@@ -53,7 +53,7 @@ struct P023_data_struct : public PluginTaskData_base {
|
||||
String & string);
|
||||
|
||||
# if P023_FEATURE_DISPLAY_PREVIEW
|
||||
bool web_show_values();
|
||||
bool web_show_values(struct EventStruct *event);
|
||||
|
||||
void setCurrentText(const String& string,
|
||||
int X,
|
||||
|
||||
@@ -2548,18 +2548,15 @@ void P036_data_struct::CreateScrollingPageLine(tScrollingPageLines *ScrollingPag
|
||||
}
|
||||
|
||||
# if P036_FEATURE_DISPLAY_PREVIEW
|
||||
bool P036_data_struct::web_show_values() {
|
||||
addHtml(F("<pre>")); // To keep spaces etc. in the shown output
|
||||
|
||||
bool P036_data_struct::web_show_values(struct EventStruct *event) {
|
||||
TaskValuesWriterHelper data(event);
|
||||
for (uint8_t i = 0; i < ScrollingPages.linesPerFrameDef; ++i) {
|
||||
addHtmlDiv(F("div_l"), currentLines[i], EMPTY_STRING, F("style='font-size:75%;'"));
|
||||
|
||||
if (i != ScrollingPages.linesPerFrameDef - 1) {
|
||||
addHtmlDiv(F("div_br"));
|
||||
}
|
||||
const bool isLast = i == (ScrollingPages.linesPerFrameDef - 1);
|
||||
data.setMonoSpaced();
|
||||
data.setAttribute(F("style='font-size:75%;'"));
|
||||
data.writeCustom(i, currentLines[i], EMPTY_STRING, isLast);
|
||||
}
|
||||
addHtml(F("</pre>"));
|
||||
return true;
|
||||
return true; // Don't show anything else
|
||||
}
|
||||
|
||||
# endif // if P036_FEATURE_DISPLAY_PREVIEW
|
||||
|
||||
@@ -492,7 +492,7 @@ public:
|
||||
# endif // ifdef P036_ENABLE_LEFT_ALIGN
|
||||
|
||||
# if P036_FEATURE_DISPLAY_PREVIEW
|
||||
bool web_show_values();
|
||||
bool web_show_values(struct EventStruct *event);
|
||||
# endif // if P036_FEATURE_DISPLAY_PREVIEW
|
||||
|
||||
// Instantiate display here - does not work to do this within the INIT call
|
||||
|
||||
+99
-113
@@ -13,7 +13,7 @@
|
||||
|
||||
#include "../Helpers/_Plugin_init.h"
|
||||
#if FEATURE_TASKVALUE_UNIT_OF_MEASURE
|
||||
#include "../Helpers/ESPEasy_UnitOfMeasure.h"
|
||||
# include "../Helpers/ESPEasy_UnitOfMeasure.h"
|
||||
#endif
|
||||
#include "../Helpers/KeyValueWriter_JSON.h"
|
||||
#include "../Helpers/Numerical.h"
|
||||
@@ -113,6 +113,7 @@ void handle_csvval()
|
||||
#endif // ifdef WEBSERVER_CSVVAL
|
||||
|
||||
#ifdef WEBSERVER_JSON
|
||||
|
||||
// ********************************************************************************
|
||||
// Web Interface JSON page (no password!)
|
||||
// ********************************************************************************
|
||||
@@ -124,32 +125,32 @@ void handle_json()
|
||||
bool showSystem = true;
|
||||
bool showWifi = true;
|
||||
|
||||
#if FEATURE_ETHERNET
|
||||
# if FEATURE_ETHERNET
|
||||
bool showEthernet = true;
|
||||
#endif // if FEATURE_ETHERNET
|
||||
# endif // if FEATURE_ETHERNET
|
||||
bool showDataAcquisition = true;
|
||||
bool showTaskDetails = true;
|
||||
#if FEATURE_ESPEASY_P2P
|
||||
# if FEATURE_ESPEASY_P2P
|
||||
bool showNodes = true;
|
||||
#endif
|
||||
#if FEATURE_PLUGIN_STATS && FEATURE_CHART_JS
|
||||
# endif
|
||||
# if FEATURE_PLUGIN_STATS && FEATURE_CHART_JS
|
||||
bool showPluginStats = getFormItemInt(F("showpluginstats"), 0) != 0;
|
||||
#endif
|
||||
# endif
|
||||
|
||||
if (equals(webArg(F("view")), F("sensorupdate"))) {
|
||||
showSystem = false;
|
||||
showWifi = false;
|
||||
#if FEATURE_ETHERNET
|
||||
# if FEATURE_ETHERNET
|
||||
showEthernet = false;
|
||||
#endif // if FEATURE_ETHERNET
|
||||
# endif // if FEATURE_ETHERNET
|
||||
showDataAcquisition = false;
|
||||
showTaskDetails = false;
|
||||
#if FEATURE_ESPEASY_P2P
|
||||
# if FEATURE_ESPEASY_P2P
|
||||
showNodes = false;
|
||||
#endif
|
||||
#if FEATURE_PLUGIN_STATS && FEATURE_CHART_JS
|
||||
# endif
|
||||
# if FEATURE_PLUGIN_STATS && FEATURE_CHART_JS
|
||||
showPluginStats = hasArg(F("showpluginstats"));
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
TXBuffer.startJsonStream();
|
||||
@@ -168,7 +169,7 @@ void handle_json()
|
||||
{
|
||||
static const LabelType::Enum wdlabels[] PROGMEM =
|
||||
{
|
||||
LabelType::LOAD_PCT,
|
||||
LabelType::LOAD_PCT,
|
||||
LabelType::LOOP_COUNT,
|
||||
|
||||
LabelType::MAX_LABEL
|
||||
@@ -183,17 +184,17 @@ void handle_json()
|
||||
LabelType::BUILD_DESC,
|
||||
LabelType::GIT_BUILD,
|
||||
LabelType::SYSTEM_LIBRARIES,
|
||||
#ifdef ESP32
|
||||
# ifdef ESP32
|
||||
LabelType::ESP_IDF_SDK_VERSION,
|
||||
#endif
|
||||
# endif
|
||||
LabelType::PLUGIN_COUNT,
|
||||
LabelType::PLUGIN_DESCRIPTION,
|
||||
LabelType::BUILD_TIME,
|
||||
LabelType::BINARY_FILENAME,
|
||||
LabelType::LOCAL_TIME,
|
||||
#if FEATURE_EXT_RTC
|
||||
# if FEATURE_EXT_RTC
|
||||
LabelType::EXT_RTC_UTC_TIME,
|
||||
#endif
|
||||
# endif
|
||||
LabelType::TIME_SOURCE,
|
||||
LabelType::TIME_WANDER,
|
||||
LabelType::ISNTP,
|
||||
@@ -201,43 +202,43 @@ void handle_json()
|
||||
LabelType::UNIT_NAME,
|
||||
LabelType::UPTIME,
|
||||
LabelType::UPTIME_MS,
|
||||
#if FEATURE_INTERNAL_TEMPERATURE
|
||||
# if FEATURE_INTERNAL_TEMPERATURE
|
||||
LabelType::INTERNAL_TEMPERATURE,
|
||||
#endif
|
||||
# endif
|
||||
LabelType::BOOT_TYPE,
|
||||
LabelType::RESET_REASON,
|
||||
LabelType::CPU_ECO_MODE,
|
||||
|
||||
#if defined(CORE_POST_2_5_0) || defined(ESP32)
|
||||
# ifndef LIMIT_BUILD_SIZE
|
||||
# if defined(CORE_POST_2_5_0) || defined(ESP32)
|
||||
# ifndef LIMIT_BUILD_SIZE
|
||||
LabelType::HEAP_MAX_FREE_BLOCK, // 7654
|
||||
# endif
|
||||
#endif // if defined(CORE_POST_2_5_0) || defined(ESP32)
|
||||
#if defined(CORE_POST_2_5_0)
|
||||
# ifndef LIMIT_BUILD_SIZE
|
||||
# endif
|
||||
# endif // if defined(CORE_POST_2_5_0) || defined(ESP32)
|
||||
# if defined(CORE_POST_2_5_0)
|
||||
# ifndef LIMIT_BUILD_SIZE
|
||||
LabelType::HEAP_FRAGMENTATION, // 12
|
||||
# endif
|
||||
#endif // if defined(CORE_POST_2_5_0)
|
||||
# endif
|
||||
# endif // if defined(CORE_POST_2_5_0)
|
||||
LabelType::FREE_MEM,
|
||||
#ifdef USE_SECOND_HEAP
|
||||
# ifdef USE_SECOND_HEAP
|
||||
LabelType::FREE_HEAP_IRAM,
|
||||
#endif
|
||||
# endif
|
||||
LabelType::FREE_STACK,
|
||||
|
||||
#ifdef ESP32
|
||||
# ifdef ESP32
|
||||
LabelType::HEAP_SIZE,
|
||||
LabelType::HEAP_MIN_FREE,
|
||||
# ifdef BOARD_HAS_PSRAM
|
||||
# ifdef BOARD_HAS_PSRAM
|
||||
LabelType::PSRAM_SIZE,
|
||||
LabelType::PSRAM_FREE,
|
||||
LabelType::PSRAM_MIN_FREE,
|
||||
LabelType::PSRAM_MAX_FREE_BLOCK,
|
||||
# endif // BOARD_HAS_PSRAM
|
||||
#endif // ifdef ESP32
|
||||
# endif // BOARD_HAS_PSRAM
|
||||
# endif // ifdef ESP32
|
||||
LabelType::ESP_CHIP_MODEL,
|
||||
#ifdef ESP32
|
||||
# ifdef ESP32
|
||||
LabelType::ESP_CHIP_REVISION,
|
||||
#endif // ifdef ESP32
|
||||
# endif // ifdef ESP32
|
||||
LabelType::FLASH_CHIP_ID,
|
||||
LabelType::FLASH_CHIP_VENDOR,
|
||||
LabelType::FLASH_CHIP_MODEL,
|
||||
@@ -252,16 +253,16 @@ void handle_json()
|
||||
LabelType::TIMEZONE_OFFSET,
|
||||
LabelType::LATITUDE,
|
||||
LabelType::LONGITUDE,
|
||||
#if FEATURE_SYSLOG
|
||||
# if FEATURE_SYSLOG
|
||||
LabelType::SYSLOG_LOG_LEVEL,
|
||||
#endif
|
||||
# endif
|
||||
LabelType::SERIAL_LOG_LEVEL,
|
||||
# ifdef WEBSERVER_LOG
|
||||
LabelType::WEB_LOG_LEVEL,
|
||||
#endif
|
||||
#if FEATURE_SD
|
||||
# endif
|
||||
# if FEATURE_SD
|
||||
LabelType::SD_LOG_LEVEL,
|
||||
#endif // if FEATURE_SD
|
||||
# endif // if FEATURE_SD
|
||||
|
||||
|
||||
LabelType::MAX_LABEL
|
||||
@@ -281,15 +282,15 @@ void handle_json()
|
||||
|
||||
if (writer) {
|
||||
writer->write({ F("Network Index"), x + 1 });
|
||||
#ifdef WEBSERVER_NETWORK
|
||||
# ifdef ESP32
|
||||
# ifdef WEBSERVER_NETWORK
|
||||
# ifdef ESP32
|
||||
ESPEasy::net::write_NetworkAdapterFlags(x, writer->createChild(F("Interface")).get());
|
||||
#ifndef LIMIT_BUILD_SIZE
|
||||
# ifndef LIMIT_BUILD_SIZE
|
||||
ESPEasy::net::write_NetworkAdapterPort(x, writer->createChild(F("Port")).get());
|
||||
#endif
|
||||
# endif
|
||||
ESPEasy::net::write_IP_config(x, writer->createChild(F("IP")).get());
|
||||
# endif // ifdef ESP32
|
||||
#endif // ifdef WEBSERVER_NETWORK
|
||||
# endif // ifdef ESP32
|
||||
# endif // ifdef WEBSERVER_NETWORK
|
||||
ESPEasy::net::write_NetworkConnectionInfo(x, writer->createChild(F("Connection")).get());
|
||||
}
|
||||
|
||||
@@ -297,24 +298,24 @@ void handle_json()
|
||||
static const LabelType::Enum labels[] PROGMEM =
|
||||
{
|
||||
LabelType::HOST_NAME,
|
||||
#if FEATURE_MDNS
|
||||
# if FEATURE_MDNS
|
||||
LabelType::USE_MDNS,
|
||||
LabelType::M_DNS,
|
||||
#endif // if FEATURE_MDNS
|
||||
# endif // if FEATURE_MDNS
|
||||
// LabelType::IP_CONFIG,
|
||||
#ifdef ESP8266
|
||||
# ifdef ESP8266
|
||||
LabelType::IP_ADDRESS,
|
||||
# if FEATURE_USE_IPV6
|
||||
# if FEATURE_USE_IPV6
|
||||
LabelType::IP6_LOCAL,
|
||||
LabelType::IP6_GLOBAL,
|
||||
LabelType::ENABLE_IPV6,
|
||||
# endif // if FEATURE_USE_IPV6
|
||||
# endif // if FEATURE_USE_IPV6
|
||||
LabelType::IP_SUBNET,
|
||||
LabelType::GATEWAY,
|
||||
LabelType::STA_MAC,
|
||||
LabelType::DNS_1,
|
||||
LabelType::DNS_2,
|
||||
#endif // ifdef ESP8266
|
||||
# endif // ifdef ESP8266
|
||||
LabelType::SSID,
|
||||
LabelType::BSSID,
|
||||
LabelType::CHANNEL,
|
||||
@@ -328,31 +329,31 @@ void handle_json()
|
||||
LabelType::FORCE_WIFI_BG,
|
||||
LabelType::RESTART_WIFI_LOST_CONN,
|
||||
LabelType::FORCE_WIFI_NOSLEEP,
|
||||
#ifdef SUPPORT_ARP
|
||||
# ifdef SUPPORT_ARP
|
||||
LabelType::PERIODICAL_GRAT_ARP,
|
||||
#endif // ifdef SUPPORT_ARP
|
||||
#ifdef USES_ESPEASY_NOW
|
||||
# endif // ifdef SUPPORT_ARP
|
||||
# ifdef USES_ESPEASY_NOW
|
||||
LabelType::USE_ESPEASY_NOW,
|
||||
LabelType::FORCE_ESPEASY_NOW_CHANNEL,
|
||||
#endif // ifdef USES_ESPEASY_NOW
|
||||
# endif // ifdef USES_ESPEASY_NOW
|
||||
LabelType::CONNECTION_FAIL_THRESH,
|
||||
#if FEATURE_SET_WIFI_TX_PWR
|
||||
# if FEATURE_SET_WIFI_TX_PWR
|
||||
LabelType::WIFI_TX_MAX_PWR,
|
||||
LabelType::WIFI_CUR_TX_PWR,
|
||||
LabelType::WIFI_SENS_MARGIN,
|
||||
LabelType::WIFI_SEND_AT_MAX_TX_PWR,
|
||||
#endif // if FEATURE_SET_WIFI_TX_PWR
|
||||
# endif // if FEATURE_SET_WIFI_TX_PWR
|
||||
LabelType::WIFI_NR_RECONNECT_ATTEMPTS,
|
||||
LabelType::WIFI_MAX_UPTIME_AUTO_START_AP,
|
||||
LabelType::WIFI_AP_MINIMAL_ON_TIME,
|
||||
#ifdef ESP32
|
||||
# ifdef ESP32
|
||||
LabelType::WIFI_PASSIVE_SCAN,
|
||||
#endif
|
||||
# endif
|
||||
LabelType::WIFI_USE_LAST_CONN_FROM_RTC,
|
||||
LabelType::WIFI_RSSI,
|
||||
#ifndef ESP32
|
||||
# ifndef ESP32
|
||||
LabelType::WAIT_WIFI_CONNECT,
|
||||
#endif
|
||||
# endif
|
||||
LabelType::HIDDEN_SSID_SLOW_CONNECT,
|
||||
LabelType::CONNECT_HIDDEN_SSID,
|
||||
LabelType::SDK_WIFI_AUTORECONNECT,
|
||||
@@ -368,7 +369,7 @@ void handle_json()
|
||||
}
|
||||
}
|
||||
|
||||
#if FEATURE_ESPEASY_P2P
|
||||
# if FEATURE_ESPEASY_P2P
|
||||
|
||||
if (showNodes) {
|
||||
auto nodesWriter = mainLevelWriter.createChildArray(F("nodes"));
|
||||
@@ -406,7 +407,7 @@ void handle_json()
|
||||
}
|
||||
}
|
||||
writer->write({ F("ip"), formatIP(it->second.IP()) });
|
||||
# if FEATURE_USE_IPV6
|
||||
# if FEATURE_USE_IPV6
|
||||
|
||||
if (it->second.hasIPv6_mac_based_link_local) {
|
||||
writer->write({ F("ipv6local"), formatIP(it->second.IPv6_link_local(true), true) });
|
||||
@@ -415,14 +416,14 @@ void handle_json()
|
||||
if (it->second.hasIPv6_mac_based_link_global) {
|
||||
writer->write({ F("ipv6global"), formatIP(it->second.IPv6_global()) });
|
||||
}
|
||||
# endif // if FEATURE_USE_IPV6
|
||||
# endif // if FEATURE_USE_IPV6
|
||||
writer->write({ F("age"), it->second.getAge() });
|
||||
} // if node info exists
|
||||
} // for loop
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // if FEATURE_ESPEASY_P2P
|
||||
# endif // if FEATURE_ESPEASY_P2P
|
||||
}
|
||||
|
||||
taskIndex_t firstTaskIndex = 0;
|
||||
@@ -450,6 +451,7 @@ void handle_json()
|
||||
|
||||
if (sensorsWriter) {
|
||||
sensorsWriter->setWriteWhenEmpty();
|
||||
|
||||
for (taskIndex_t TaskIndex = firstTaskIndex; TaskIndex <= lastActiveTaskIndex && validTaskIndex(TaskIndex); TaskIndex++)
|
||||
{
|
||||
const deviceIndex_t DeviceIndex = getDeviceIndex_from_TaskIndex(TaskIndex);
|
||||
@@ -489,12 +491,13 @@ void handle_json()
|
||||
struct EventStruct TempEvent(TaskIndex);
|
||||
TempEvent.kvWriter = taskValueWriter.get();
|
||||
TaskValuesWriterHelper data(&TempEvent);
|
||||
|
||||
// FIXME tonhuisman: HasFormatUserVar is not really compatible with Derived Values...
|
||||
data.writeTaskValues();
|
||||
}
|
||||
}
|
||||
|
||||
#if FEATURE_PLUGIN_STATS && FEATURE_CHART_JS
|
||||
# if FEATURE_PLUGIN_STATS && FEATURE_CHART_JS
|
||||
|
||||
if (showPluginStats && Device[DeviceIndex].PluginStats) {
|
||||
PluginTaskData_base *taskData = getPluginTaskDataBaseClassOnly(TaskIndex);
|
||||
@@ -505,7 +508,7 @@ void handle_json()
|
||||
taskData->plot_ChartJS(true);
|
||||
}
|
||||
}
|
||||
#endif // if FEATURE_PLUGIN_STATS && FEATURE_CHART_JS
|
||||
# endif // if FEATURE_PLUGIN_STATS && FEATURE_CHART_JS
|
||||
|
||||
|
||||
if (showDataAcquisition) {
|
||||
@@ -537,16 +540,16 @@ void handle_json()
|
||||
}
|
||||
}
|
||||
|
||||
#if FEATURE_I2CMULTIPLEXER
|
||||
# if FEATURE_I2CMULTIPLEXER
|
||||
uint8_t i2cBus = 0;
|
||||
# if FEATURE_I2C_MULTIPLE
|
||||
# if FEATURE_I2C_MULTIPLE
|
||||
i2cBus = Settings.getI2CInterface(TaskIndex);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
if ((Device[DeviceIndex].Type == DEVICE_TYPE_I2C) && isI2CMultiplexerEnabled(i2cBus)) {
|
||||
# if FEATURE_I2C_MULTIPLE
|
||||
# if FEATURE_I2C_MULTIPLE
|
||||
taskWriter->write({ F("I2C_Interface"), static_cast<int>(i2cBus + 1) });
|
||||
# endif
|
||||
# endif
|
||||
int8_t channel = Settings.I2C_Multiplexer_Channel[TaskIndex];
|
||||
|
||||
if (bitRead(Settings.I2C_SPI_bus_Flags[TaskIndex], I2C_FLAGS_MUX_MULTICHANNEL)) {
|
||||
@@ -569,7 +572,7 @@ void handle_json()
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // if FEATURE_I2CMULTIPLEXER
|
||||
# endif // if FEATURE_I2CMULTIPLEXER
|
||||
}
|
||||
|
||||
taskWriter->write({ F("TaskEnabled"),
|
||||
@@ -577,9 +580,9 @@ void handle_json()
|
||||
taskWriter->write({ F("TaskNumber"), TaskIndex + 1 });
|
||||
|
||||
if (showSpecificTask) {
|
||||
#if FEATURE_TASKVALUE_UNIT_OF_MEASURE
|
||||
# if FEATURE_TASKVALUE_UNIT_OF_MEASURE
|
||||
taskWriter->write({ F("ShowUoM"), Settings.ShowUnitOfMeasureOnDevicesPage() });
|
||||
#endif // if FEATURE_TASKVALUE_UNIT_OF_MEASURE
|
||||
# endif // if FEATURE_TASKVALUE_UNIT_OF_MEASURE
|
||||
taskWriter->write({ F("TTL"), ttl_json * 1000 });
|
||||
}
|
||||
}
|
||||
@@ -589,9 +592,9 @@ void handle_json()
|
||||
}
|
||||
|
||||
if (!showSpecificTask) {
|
||||
#if FEATURE_TASKVALUE_UNIT_OF_MEASURE
|
||||
# if FEATURE_TASKVALUE_UNIT_OF_MEASURE
|
||||
mainLevelWriter.write({ F("ShowUoM"), Settings.ShowUnitOfMeasureOnDevicesPage() });
|
||||
#endif // if FEATURE_TASKVALUE_UNIT_OF_MEASURE
|
||||
# endif // if FEATURE_TASKVALUE_UNIT_OF_MEASURE
|
||||
mainLevelWriter.write({ F("TTL"), lowest_ttl_json * 1000 });
|
||||
}
|
||||
}
|
||||
@@ -600,9 +603,9 @@ void handle_json()
|
||||
STOP_TIMER(HANDLE_SERVING_WEBPAGE_JSON);
|
||||
}
|
||||
|
||||
void handle_json_stream_task_value_data(TaskValuesWriterHelper* data)
|
||||
void handle_json_stream_task_value_data(TaskValuesWriterHelper*data)
|
||||
{
|
||||
if (!data || !data->event || !data->event->kvWriter) return;
|
||||
if (!data || !data->event || !data->event->kvWriter) { return; }
|
||||
|
||||
auto writer = data->event->kvWriter->createChild();
|
||||
|
||||
@@ -615,26 +618,36 @@ void handle_json_stream_task_value_data(TaskValuesWriterHelper* data)
|
||||
}
|
||||
|
||||
{
|
||||
KeyValueStruct kv(F("Name"), data->valName);
|
||||
String tmp = data->valName;
|
||||
|
||||
if (tmp.indexOf('"') != -1) {
|
||||
tmp.replace(F("\""), F("\\\""));
|
||||
}
|
||||
KeyValueStruct kv(F("Name"), tmp);
|
||||
kv.setID(data->valName_id);
|
||||
writer->write(kv);
|
||||
}
|
||||
{
|
||||
KeyValueStruct kv(F("Value"), data->value);
|
||||
String tmp = data->value;
|
||||
|
||||
if (tmp.indexOf('"') != -1) {
|
||||
tmp.replace(F("\""), F("\\\""));
|
||||
}
|
||||
KeyValueStruct kv(F("Value"), tmp);
|
||||
kv.setID(data->value_id);
|
||||
writer->write(kv);
|
||||
}
|
||||
|
||||
writer->write({ F("ValueNumber"), data->valueNumber + 1 });
|
||||
writer->write({ F("NrDecimals"), nrDecimals });
|
||||
#if FEATURE_STRING_VARIABLES
|
||||
# if FEATURE_STRING_VARIABLES
|
||||
|
||||
if (!data->presentation.isEmpty()) {
|
||||
KeyValueStruct kv(F("Presentation"), data->presentation);
|
||||
kv.setID(data->presentation_id);
|
||||
writer->write(kv);
|
||||
}
|
||||
#endif // if FEATURE_STRING_VARIABLES
|
||||
# endif // if FEATURE_STRING_VARIABLES
|
||||
|
||||
if (!data->uom.isEmpty()) {
|
||||
KeyValueStruct kv(F("UoM"), data->uom);
|
||||
@@ -644,34 +657,7 @@ void handle_json_stream_task_value_data(TaskValuesWriterHelper* data)
|
||||
}
|
||||
}
|
||||
|
||||
void handle_json_stream_task_value_data(KeyValueWriter*parent,
|
||||
uint16_t valueNumber,
|
||||
const String & valueName,
|
||||
uint8_t nrDecimals,
|
||||
const String & value,
|
||||
const String & presentation,
|
||||
const String & uom)
|
||||
{
|
||||
auto writer = parent->createChild();
|
||||
|
||||
if (writer) {
|
||||
writer->write({ F("ValueNumber"), valueNumber });
|
||||
writer->write({ F("Name"), valueName });
|
||||
writer->write({ F("NrDecimals"), nrDecimals });
|
||||
#if FEATURE_STRING_VARIABLES
|
||||
|
||||
if (!presentation.isEmpty()) {
|
||||
writer->write({ F("Presentation"), presentation });
|
||||
}
|
||||
#endif // if FEATURE_STRING_VARIABLES
|
||||
|
||||
if (!uom.isEmpty()) {
|
||||
writer->write({ F("UoM"), uom });
|
||||
}
|
||||
writer->write({ F("Value"), value });
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // ifdef WEBSERVER_JSON
|
||||
|
||||
// ********************************************************************************
|
||||
// JSON formatted timing statistics
|
||||
|
||||
@@ -22,13 +22,6 @@ void handle_json();
|
||||
|
||||
void handle_json_stream_task_value_data(TaskValuesWriterHelper* data);
|
||||
|
||||
void handle_json_stream_task_value_data(KeyValueWriter* parent,
|
||||
uint16_t valueNumber,
|
||||
const String & valueName,
|
||||
uint8_t nrDecimals,
|
||||
const String & value,
|
||||
const String & presentation,
|
||||
const String & uom);
|
||||
#endif
|
||||
// ********************************************************************************
|
||||
// JSON formatted timing statistics
|
||||
|
||||
Reference in new issue
Block a user