diff --git a/ChangeLog.md b/ChangeLog.md index 5c33aca8..31668364 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,16 +7,19 @@ * fix some compiler warnings * fix non-unique message keys in HTTP JSON output with "full" query parameter * fix for message after debian install +* fix for replacing already existing message definitions +* fix missing length in CSV dump for some data types ## Features * added DTM and BDZ data types * added "-n" argument to "hex" and "direct" commands for automatically determining message length from input -* added level/pollprio/condition to HTTP JSON output +* added level/pollprio/condition/field flags and field result type as well as list of types to HTTP JSON output * added message dump from commandline in JSON format * added support for newer MQTT broker versions * added some PIC calibration data to "ebuspicloader" verbose output * added support for upcoming adapter 3 firmware enhancements * added config override path +* added support for adding message definition via HTTP port ## Breaking Changes * remove support for Debian 8 Jessie in docker diff --git a/src/ebusd/mainloop.cpp b/src/ebusd/mainloop.cpp index 4069f56b..70d74b16 100644 --- a/src/ebusd/mainloop.cpp +++ b/src/ebusd/mainloop.cpp @@ -2199,8 +2199,13 @@ result_t MainLoop::executeGet(const vector& args, bool* connected, ostri *ostream << ",\n \"reconnects\": " << m_reconnectCount << ",\n \"masters\": " << m_busHandler->getMasterCount() << ",\n \"messages\": " << m_messages->size() - << ",\n \"lastup\": " << static_cast(maxLastUp) - << "\n }" + << ",\n \"lastup\": " << static_cast(maxLastUp); + if (withDefinition) { + *ostream << ",\n \"types\": ["; + DataTypeList::getInstance()->dump(verbosity, true, ostream); + *ostream << "\n ]"; + } + *ostream << "\n }" << "\n}"; type = 6; } diff --git a/src/lib/ebus/datatype.cpp b/src/lib/ebus/datatype.cpp index 65cecad1..ea172563 100755 --- a/src/lib/ebus/datatype.cpp +++ b/src/lib/ebus/datatype.cpp @@ -1116,6 +1116,31 @@ DataTypeList* DataTypeList::getInstance() { return &s_instance; } +void DataTypeList::dump(OutputFormat outputFormat, bool appendDivisor, ostream* output) const { + bool json = outputFormat & OF_JSON; + string sep = "\n"; + for (int withLength=0; withLength<2; withLength++) { + const map* types = withLength==0 ? &m_typesById : &m_typesByIdLength; + for (const auto &it: *types) { + const DataType *dataType = it.second; + if (json) { + *output << sep << " {"; + } + if ((dataType->getBitCount() % 8) != 0) { + dataType->dump(outputFormat, dataType->getBitCount(), appendDivisor, output); + } else { + dataType->dump(outputFormat, dataType->getBitCount() / 8, appendDivisor, output); + } + if (json) { + *output << "}"; + sep = ",\n"; + } else { + *output << "\n"; + } + } + } +} + void DataTypeList::clear() { for (auto& it : m_cleanupTypes) { delete it; diff --git a/src/lib/ebus/datatype.h b/src/lib/ebus/datatype.h index 2945d51a..92c32b89 100755 --- a/src/lib/ebus/datatype.h +++ b/src/lib/ebus/datatype.h @@ -575,6 +575,14 @@ class DataTypeList { */ static DataTypeList* getInstance(); + /** + * Dump the type list optionally including the divisor to the output. + * @param outputFormat the @a OutputFormat options. + * @param appendDivisor whether to append the divisor (if available). + * @param output the @a ostream to dump to. + */ + void dump(OutputFormat outputFormat, bool appendDivisor, ostream* output) const; + /** * Removes all @a DataType instances. */