Merge branch 'dev' of https://github.com/emsesp/EMS-ESP32 into dev_no_master_thermostat

This commit is contained in:
MichaelDvP
2022-03-11 11:51:12 +01:00
30 changed files with 855 additions and 892 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -7,15 +7,15 @@
"@emotion/react": "^11.8.1", "@emotion/react": "^11.8.1",
"@emotion/styled": "^11.8.1", "@emotion/styled": "^11.8.1",
"@msgpack/msgpack": "^2.7.2", "@msgpack/msgpack": "^2.7.2",
"@mui/icons-material": "^5.4.4", "@mui/icons-material": "^5.5.0",
"@mui/material": "^5.4.4", "@mui/material": "^5.5.0",
"@types/lodash": "^4.14.179", "@types/lodash": "^4.14.179",
"@types/node": "^17.0.21", "@types/node": "^17.0.21",
"@types/react": "^17.0.39", "@types/react": "^17.0.40",
"@types/react-dom": "^17.0.13", "@types/react-dom": "^17.0.13",
"@types/react-router-dom": "^5.3.3", "@types/react-router-dom": "^5.3.3",
"async-validator": "^4.0.7", "async-validator": "^4.0.7",
"axios": "^0.26.0", "axios": "^0.26.1",
"http-proxy-middleware": "^2.0.3", "http-proxy-middleware": "^2.0.3",
"jwt-decode": "^3.1.2", "jwt-decode": "^3.1.2",
"lodash": "^4.17.21", "lodash": "^4.17.21",

View File

@@ -1,6 +1,19 @@
ArduinoJson: change log ArduinoJson: change log
======================= =======================
v6.19.3 (2022-03-08)
-------
* Fix `call of overloaded 'String(const char*, int)' is ambiguous`
* Fix `JsonString` operator `==` and `!=` for non-zero-terminated string
* Fix `-Wsign-conversion` on GCC 8 (issue #1715)
* MessagePack: serialize round floats as integers (issue #1718)
v6.19.2 (2022-02-14)
-------
* Fix `cannot convert 'pgm_p' to 'const void*'` (issue #1707)
v6.19.1 (2022-01-14) v6.19.1 (2022-01-14)
------- -------

View File

@@ -7,8 +7,8 @@
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/arduinojson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/arduinojson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson)
[![LGTM Grade](https://img.shields.io/lgtm/grade/cpp/github/bblanchon/ArduinoJson?label=quality&logo=lgtm)](https://lgtm.com/projects/g/bblanchon/ArduinoJson/) [![LGTM Grade](https://img.shields.io/lgtm/grade/cpp/github/bblanchon/ArduinoJson?label=quality&logo=lgtm)](https://lgtm.com/projects/g/bblanchon/ArduinoJson/)
[![Coveralls branch](https://img.shields.io/coveralls/github/bblanchon/ArduinoJson/6.x?logo=coveralls)](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x) [![Coveralls branch](https://img.shields.io/coveralls/github/bblanchon/ArduinoJson/6.x?logo=coveralls)](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x)
[![Arduino Library Manager](https://img.shields.io/static/v1?label=Arduino&message=v6.19.1&logo=arduino&logoColor=white&color=blue)](https://www.ardu-badge.com/ArduinoJson/6.19.1) [![Arduino Library Manager](https://img.shields.io/static/v1?label=Arduino&message=v6.19.3&logo=arduino&logoColor=white&color=blue)](https://www.ardu-badge.com/ArduinoJson/6.19.3)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/bblanchon/library/ArduinoJson.svg?version=6.19.1)](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.19.1) [![PlatformIO Registry](https://badges.registry.platformio.org/packages/bblanchon/library/ArduinoJson.svg?version=6.19.3)](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.19.3)
[![GitHub stars](https://img.shields.io/github/stars/bblanchon/ArduinoJson?style=flat&logo=github)](https://github.com/bblanchon/ArduinoJson/stargazers) [![GitHub stars](https://img.shields.io/github/stars/bblanchon/ArduinoJson?style=flat&logo=github)](https://github.com/bblanchon/ArduinoJson/stargazers)
[![GitHub Sponsors](https://img.shields.io/github/sponsors/bblanchon?logo=github)](https://github.com/sponsors/bblanchon) [![GitHub Sponsors](https://img.shields.io/github/sponsors/bblanchon?logo=github)](https://github.com/sponsors/bblanchon)

View File

@@ -64,7 +64,7 @@ inline bool CollectionData::copyFrom(const CollectionData& src,
for (VariantSlot* s = src._head; s; s = s->next()) { for (VariantSlot* s = src._head; s; s = s->next()) {
VariantData* var; VariantData* var;
if (s->key() != 0) { if (s->key() != 0) {
String key(s->key(), !s->ownsKey()); String key(s->key(), s->ownsKey() ? String::Copied : String::Linked);
var = addMember(adaptString(key), pool, getStringStoragePolicy(key)); var = addMember(adaptString(key), pool, getStringStoragePolicy(key));
} else { } else {
var = addElement(pool); var = addElement(pool);

View File

@@ -40,7 +40,7 @@ class MsgPackDeserializer {
template <typename TFilter> template <typename TFilter>
bool parseVariant(VariantData *variant, TFilter filter, bool parseVariant(VariantData *variant, TFilter filter,
NestingLimit nestingLimit) { NestingLimit nestingLimit) {
uint8_t code = 0; uint8_t code = 0; // TODO: why do we need to initialize this variable?
if (!readByte(code)) if (!readByte(code))
return false; return false;
@@ -481,7 +481,7 @@ class MsgPackDeserializer {
T size; T size;
if (!readInteger(size)) if (!readInteger(size))
return false; return false;
return skipBytes(size + 1); return skipBytes(size + 1U);
} }
MemoryPool *_pool; MemoryPool *_pool;

View File

@@ -23,6 +23,11 @@ class MsgPackSerializer : public Visitor<size_t> {
template <typename T> template <typename T>
typename enable_if<sizeof(T) == 4, size_t>::type visitFloat(T value32) { typename enable_if<sizeof(T) == 4, size_t>::type visitFloat(T value32) {
if (canConvertNumber<Integer>(value32)) {
Integer truncatedValue = Integer(value32);
if (value32 == T(truncatedValue))
return visitSignedInteger(truncatedValue);
}
writeByte(0xCA); writeByte(0xCA);
writeInteger(value32); writeInteger(value32);
return bytesWritten(); return bytesWritten();
@@ -32,13 +37,10 @@ class MsgPackSerializer : public Visitor<size_t> {
ARDUINOJSON_NO_SANITIZE("float-cast-overflow") ARDUINOJSON_NO_SANITIZE("float-cast-overflow")
typename enable_if<sizeof(T) == 8, size_t>::type visitFloat(T value64) { typename enable_if<sizeof(T) == 8, size_t>::type visitFloat(T value64) {
float value32 = float(value64); float value32 = float(value64);
if (value32 == value64) { if (value32 == value64)
writeByte(0xCA); return visitFloat(value32);
writeInteger(value32); writeByte(0xCB);
} else { writeInteger(value64);
writeByte(0xCB);
writeInteger(value64);
}
return bytesWritten(); return bytesWritten();
} }

View File

@@ -13,7 +13,8 @@ class Pair {
public: public:
Pair(MemoryPool* pool, VariantSlot* slot) { Pair(MemoryPool* pool, VariantSlot* slot) {
if (slot) { if (slot) {
_key = String(slot->key(), !slot->ownsKey()); _key = String(slot->key(),
slot->ownsKey() ? String::Copied : String::Linked);
_value = VariantRef(pool, slot->data()); _value = VariantRef(pool, slot->data());
} }
} }
@@ -35,7 +36,8 @@ class PairConst {
public: public:
PairConst(const VariantSlot* slot) { PairConst(const VariantSlot* slot) {
if (slot) { if (slot) {
_key = String(slot->key(), !slot->ownsKey()); _key = String(slot->key(),
slot->ownsKey() ? String::Copied : String::Linked);
_value = VariantConstRef(slot->data()); _value = VariantConstRef(slot->data());
} }
} }

View File

@@ -99,7 +99,7 @@ inline void* memcpy_P(void* dst, ARDUINOJSON_NAMESPACE::pgm_p src, size_t n) {
#ifndef pgm_read_dword #ifndef pgm_read_dword
inline uint32_t pgm_read_dword(ARDUINOJSON_NAMESPACE::pgm_p p) { inline uint32_t pgm_read_dword(ARDUINOJSON_NAMESPACE::pgm_p p) {
uint32_t result; uint32_t result;
memcpy_P(&result, p, 4); memcpy_P(&result, p.address, 4);
return result; return result;
} }
#endif #endif
@@ -107,7 +107,7 @@ inline uint32_t pgm_read_dword(ARDUINOJSON_NAMESPACE::pgm_p p) {
#ifndef pgm_read_ptr #ifndef pgm_read_ptr
inline void* pgm_read_ptr(ARDUINOJSON_NAMESPACE::pgm_p p) { inline void* pgm_read_ptr(ARDUINOJSON_NAMESPACE::pgm_p p) {
void* result; void* result;
memcpy_P(&result, p, sizeof(result)); memcpy_P(&result, p.address, sizeof(result));
return result; return result;
} }
#endif #endif

View File

@@ -22,7 +22,7 @@ class StringCopier {
String save() { String save() {
ARDUINOJSON_ASSERT(_ptr); ARDUINOJSON_ASSERT(_ptr);
ARDUINOJSON_ASSERT(_size < _capacity); // needs room for the terminator ARDUINOJSON_ASSERT(_size < _capacity); // needs room for the terminator
return String(_pool->saveStringFromFreeZone(_size), _size, false); return String(_pool->saveStringFromFreeZone(_size), _size, String::Copied);
} }
void append(const char* s) { void append(const char* s) {
@@ -52,7 +52,7 @@ class StringCopier {
ARDUINOJSON_ASSERT(_ptr); ARDUINOJSON_ASSERT(_ptr);
ARDUINOJSON_ASSERT(_size < _capacity); ARDUINOJSON_ASSERT(_size < _capacity);
_ptr[_size] = 0; _ptr[_size] = 0;
return String(_ptr, _size, false); return String(_ptr, _size, String::Copied);
} }
private: private:

View File

@@ -33,7 +33,7 @@ class StringMover {
String str() const { String str() const {
_writePtr[0] = 0; // terminator _writePtr[0] = 0; // terminator
return String(_startPtr, size(), true); return String(_startPtr, size(), String::Linked);
} }
size_t size() const { size_t size() const {

View File

@@ -106,13 +106,13 @@ inline SizedRamString adaptString(const char* s, size_t n) {
return SizedRamString(s, n); return SizedRamString(s, n);
} }
template <int N> template <size_t N>
struct IsString<char[N]> : true_type {}; struct IsString<char[N]> : true_type {};
template <int N> template <size_t N>
struct IsString<const char[N]> : true_type {}; struct IsString<const char[N]> : true_type {};
template <int N> template <size_t N>
inline SizedRamString adaptString(char s[N]) { inline SizedRamString adaptString(char s[N]) {
return SizedRamString(s, strlen(s)); return SizedRamString(s, strlen(s));
} }

View File

@@ -12,7 +12,7 @@ namespace ARDUINOJSON_NAMESPACE {
struct LinkStringStoragePolicy { struct LinkStringStoragePolicy {
template <typename TAdaptedString, typename TCallback> template <typename TAdaptedString, typename TCallback>
bool store(TAdaptedString str, MemoryPool *, TCallback callback) { bool store(TAdaptedString str, MemoryPool *, TCallback callback) {
String storedString(str.data(), str.size(), true); String storedString(str.data(), str.size(), String::Linked);
callback(storedString); callback(storedString);
return !str.isNull(); return !str.isNull();
} }
@@ -50,7 +50,7 @@ inline LinkStringStoragePolicy getStringStoragePolicy(const char *) {
} }
inline LinkOrCopyStringStoragePolicy getStringStoragePolicy(const String &s) { inline LinkOrCopyStringStoragePolicy getStringStoragePolicy(const String &s) {
return LinkOrCopyStringStoragePolicy(s.isStatic()); return LinkOrCopyStringStoragePolicy(s.isLinked());
} }
} // namespace ARDUINOJSON_NAMESPACE } // namespace ARDUINOJSON_NAMESPACE

View File

@@ -1,35 +0,0 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// MIT License
#pragma once
namespace ARDUINOJSON_NAMESPACE {
template <bool linked>
class StoredString {
public:
StoredString() : _data(0), _size(0) {}
StoredString(const char* p, size_t n) : _data(p), _size(n) {}
operator const char*() const {
return _data;
}
const char* c_str() const {
return _data;
}
size_t size() const {
return _size;
}
private:
const char* _data;
size_t _size;
};
typedef StoredString<true> LinkedString;
typedef StoredString<false> CopiedString;
} // namespace ARDUINOJSON_NAMESPACE

View File

@@ -14,15 +14,15 @@ namespace ARDUINOJSON_NAMESPACE {
class String : public SafeBoolIdom<String> { class String : public SafeBoolIdom<String> {
public: public:
String() : _data(0), _size(0), _isStatic(true) {} enum Ownership { Copied, Linked };
String(const char* data, bool isStaticData = true) String() : _data(0), _size(0), _ownership(Linked) {}
: _data(data),
_size(data ? ::strlen(data) : 0),
_isStatic(isStaticData) {}
String(const char* data, size_t sz, bool isStaticData = true) String(const char* data, Ownership ownership = Linked)
: _data(data), _size(sz), _isStatic(isStaticData) {} : _data(data), _size(data ? ::strlen(data) : 0), _ownership(ownership) {}
String(const char* data, size_t sz, Ownership ownership = Linked)
: _data(data), _size(sz), _ownership(ownership) {}
const char* c_str() const { const char* c_str() const {
return _data; return _data;
@@ -32,8 +32,8 @@ class String : public SafeBoolIdom<String> {
return !_data; return !_data;
} }
bool isStatic() const { bool isLinked() const {
return _isStatic; return _ownership == Linked;
} }
size_t size() const { size_t size() const {
@@ -46,23 +46,19 @@ class String : public SafeBoolIdom<String> {
} }
friend bool operator==(String lhs, String rhs) { friend bool operator==(String lhs, String rhs) {
if (lhs._size != rhs._size)
return false;
if (lhs._data == rhs._data) if (lhs._data == rhs._data)
return true; return true;
if (!lhs._data) if (!lhs._data)
return false; return false;
if (!rhs._data) if (!rhs._data)
return false; return false;
return strcmp(lhs._data, rhs._data) == 0; return memcmp(lhs._data, rhs._data, lhs._size) == 0;
} }
friend bool operator!=(String lhs, String rhs) { friend bool operator!=(String lhs, String rhs) {
if (lhs._data == rhs._data) return !(lhs == rhs);
return false;
if (!lhs._data)
return true;
if (!rhs._data)
return true;
return strcmp(lhs._data, rhs._data) != 0;
} }
#if ARDUINOJSON_ENABLE_STD_STREAM #if ARDUINOJSON_ENABLE_STD_STREAM
@@ -75,7 +71,7 @@ class String : public SafeBoolIdom<String> {
private: private:
const char* _data; const char* _data;
size_t _size; size_t _size;
bool _isStatic; Ownership _ownership;
}; };
} // namespace ARDUINOJSON_NAMESPACE } // namespace ARDUINOJSON_NAMESPACE

View File

@@ -208,7 +208,7 @@ class MemoryPoolPrint : public Print {
String str() { String str() {
ARDUINOJSON_ASSERT(_size < _capacity); ARDUINOJSON_ASSERT(_size < _capacity);
return String(_pool->saveStringFromFreeZone(_size), _size, false); return String(_pool->saveStringFromFreeZone(_size), _size, String::Copied);
} }
size_t write(uint8_t c) { size_t write(uint8_t c) {

View File

@@ -23,7 +23,7 @@ struct Comparer;
template <typename T> template <typename T>
struct Comparer<T, typename enable_if<IsString<T>::value>::type> struct Comparer<T, typename enable_if<IsString<T>::value>::type>
: ComparerBase { : ComparerBase {
T rhs; T rhs; // TODO: store adapted string?
explicit Comparer(T value) : rhs(value) {} explicit Comparer(T value) : rhs(value) {}

View File

@@ -210,7 +210,7 @@ class VariantData {
void setString(String s) { void setString(String s) {
ARDUINOJSON_ASSERT(s); ARDUINOJSON_ASSERT(s);
if (s.isStatic()) if (s.isLinked())
setType(VALUE_IS_LINKED_STRING); setType(VALUE_IS_LINKED_STRING);
else else
setType(VALUE_IS_OWNED_STRING); setType(VALUE_IS_OWNED_STRING);

View File

@@ -73,9 +73,11 @@ inline T VariantData::asFloat() const {
inline String VariantData::asString() const { inline String VariantData::asString() const {
switch (type()) { switch (type()) {
case VALUE_IS_LINKED_STRING: case VALUE_IS_LINKED_STRING:
return String(_content.asString.data, _content.asString.size, true); return String(_content.asString.data, _content.asString.size,
String::Linked);
case VALUE_IS_OWNED_STRING: case VALUE_IS_OWNED_STRING:
return String(_content.asString.data, _content.asString.size, false); return String(_content.asString.data, _content.asString.size,
String::Copied);
default: default:
return String(); return String();
} }
@@ -166,14 +168,15 @@ inline VariantConstRef operator|(VariantConstRef preferedValue,
// Out of class definition to avoid #1560 // Out of class definition to avoid #1560
inline bool VariantRef::set(char value) const { inline bool VariantRef::set(char value) const {
return set<signed char>(value); return set(static_cast<signed char>(value));
} }
// TODO: move somewhere else
template <typename TAdaptedString, typename TCallback> template <typename TAdaptedString, typename TCallback>
bool CopyStringStoragePolicy::store(TAdaptedString str, MemoryPool *pool, bool CopyStringStoragePolicy::store(TAdaptedString str, MemoryPool *pool,
TCallback callback) { TCallback callback) {
const char *copy = pool->saveString(str); const char *copy = pool->saveString(str);
String storedString(copy, str.size(), false); String storedString(copy, str.size(), String::Copied);
callback(storedString); callback(storedString);
return copy != 0; return copy != 0;
} }

View File

@@ -119,7 +119,7 @@ class VariantRef : public VariantRefBase<VariantData>,
ARDUINOJSON_DEPRECATED( ARDUINOJSON_DEPRECATED(
"Support for char is deprecated, use int8_t or uint8_t instead") "Support for char is deprecated, use int8_t or uint8_t instead")
as() const { as() const {
return as<signed char>(); return static_cast<char>(as<signed char>());
} }
template <typename T> template <typename T>
@@ -265,7 +265,7 @@ class VariantConstRef : public VariantRefBase<const VariantData>,
ARDUINOJSON_DEPRECATED( ARDUINOJSON_DEPRECATED(
"Support for char is deprecated, use int8_t or uint8_t instead") "Support for char is deprecated, use int8_t or uint8_t instead")
as() const { as() const {
return as<signed char>(); return static_cast<char>(as<signed char>());
} }
template <typename T> template <typename T>

View File

@@ -78,7 +78,7 @@ class VariantSlot {
void setKey(String k) { void setKey(String k) {
ARDUINOJSON_ASSERT(k); ARDUINOJSON_ASSERT(k);
if (k.isStatic()) if (k.isLinked())
_flags &= VALUE_MASK; _flags &= VALUE_MASK;
else else
_flags |= OWNED_KEY_BIT; _flags |= OWNED_KEY_BIT;

View File

@@ -4,7 +4,7 @@
#pragma once #pragma once
#define ARDUINOJSON_VERSION "6.19.1" #define ARDUINOJSON_VERSION "6.19.3"
#define ARDUINOJSON_VERSION_MAJOR 6 #define ARDUINOJSON_VERSION_MAJOR 6
#define ARDUINOJSON_VERSION_MINOR 19 #define ARDUINOJSON_VERSION_MINOR 19
#define ARDUINOJSON_VERSION_REVISION 1 #define ARDUINOJSON_VERSION_REVISION 3

View File

@@ -535,7 +535,7 @@ std::string DallasSensor::Sensor::name() const {
bool DallasSensor::Sensor::apply_customization() { bool DallasSensor::Sensor::apply_customization() {
EMSESP::webCustomizationService.read([&](WebCustomization & settings) { EMSESP::webCustomizationService.read([&](WebCustomization & settings) {
auto sensors = settings.sensorCustomizations; auto sensors = settings.sensorCustomizations;
if (sensors.empty()) { if (!sensors.empty()) {
for (const auto & sensor : sensors) { for (const auto & sensor : sensors) {
#if defined(EMSESP_DEBUG) #if defined(EMSESP_DEBUG)
LOG_DEBUG(F("Loading customization for dallas sensor %s"), sensor.id_str.c_str()); LOG_DEBUG(F("Loading customization for dallas sensor %s"), sensor.id_str.c_str());

View File

@@ -117,7 +117,7 @@ Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_i
register_telegram_type(set_typeids[i], F("RC300Set"), false, MAKE_PF_CB(process_RC300Set)); register_telegram_type(set_typeids[i], F("RC300Set"), false, MAKE_PF_CB(process_RC300Set));
register_telegram_type(summer_typeids[i], F("RC300Summer"), false, MAKE_PF_CB(process_RC300Summer)); register_telegram_type(summer_typeids[i], F("RC300Summer"), false, MAKE_PF_CB(process_RC300Summer));
register_telegram_type(curve_typeids[i], F("RC300Curves"), false, MAKE_PF_CB(process_RC300Curve)); register_telegram_type(curve_typeids[i], F("RC300Curves"), false, MAKE_PF_CB(process_RC300Curve));
register_telegram_type(summer2_typeids[i], F("RC300Summer2"), true, MAKE_PF_CB(process_RC300Summer2)); register_telegram_type(summer2_typeids[i], F("RC300Summer2"), false, MAKE_PF_CB(process_RC300Summer2));
} }
register_telegram_type(0x2F5, F("RC300WWmode"), true, MAKE_PF_CB(process_RC300WWmode)); register_telegram_type(0x2F5, F("RC300WWmode"), true, MAKE_PF_CB(process_RC300WWmode));
register_telegram_type(0x31B, F("RC300WWtemp"), true, MAKE_PF_CB(process_RC300WWtemp)); register_telegram_type(0x31B, F("RC300WWtemp"), true, MAKE_PF_CB(process_RC300WWtemp));
@@ -328,6 +328,9 @@ std::shared_ptr<Thermostat::HeatingCircuit> Thermostat::heating_circuit(std::sha
if (timer2_typeids.size()) { if (timer2_typeids.size()) {
toggle_fetch(timer2_typeids[hc_num - 1], toggle_); toggle_fetch(timer2_typeids[hc_num - 1], toggle_);
} }
if (summer2_typeids.size()) {
toggle_fetch(summer2_typeids[hc_num - 1], toggle_);
}
return new_hc; // return back point to new HC object return new_hc; // return back point to new HC object
} }

View File

@@ -324,10 +324,10 @@ void EMSdevice::show_telegram_handlers(uuid::console::Shell & shell) const {
} }
// list all the telegram type IDs for this device, outputting to a string (max size 200) // list all the telegram type IDs for this device, outputting to a string (max size 200)
char * EMSdevice::show_telegram_handlers(char * result, uint8_t handlers) { char * EMSdevice::show_telegram_handlers(char * result, const size_t len, const uint8_t handlers) {
uint8_t size = telegram_functions_.size(); uint8_t size = telegram_functions_.size();
strlcpy(result, "", 200); strlcpy(result, "", len);
if (!size) { if (!size) {
return result; return result;
@@ -338,9 +338,9 @@ char * EMSdevice::show_telegram_handlers(char * result, uint8_t handlers) {
if (handlers == Handlers::ALL || (handlers == Handlers::RECEIVED && tf.received_ && !tf.fetch_) if (handlers == Handlers::ALL || (handlers == Handlers::RECEIVED && tf.received_ && !tf.fetch_)
|| (handlers == Handlers::FETCHED && tf.received_ && tf.fetch_) || (handlers == Handlers::PENDING && !tf.received_ && !tf.fetch_)) { || (handlers == Handlers::FETCHED && tf.received_ && tf.fetch_) || (handlers == Handlers::PENDING && !tf.received_ && !tf.fetch_)) {
if (i++ > 0) { if (i++ > 0) {
strlcat(result, " ", 200); strlcat(result, " ", len);
} }
strlcat(result, Helpers::hextoa(tf.telegram_type_id_, true).c_str(), 200); strlcat(result, Helpers::hextoa(tf.telegram_type_id_, true).c_str(), len);
} }
} }

View File

@@ -182,7 +182,7 @@ class EMSdevice {
enum Handlers : uint8_t { ALL, RECEIVED, FETCHED, PENDING }; enum Handlers : uint8_t { ALL, RECEIVED, FETCHED, PENDING };
void show_telegram_handlers(uuid::console::Shell & shell) const; void show_telegram_handlers(uuid::console::Shell & shell) const;
char * show_telegram_handlers(char * result, uint8_t handlers); char * show_telegram_handlers(char * result, const size_t len, const uint8_t handlers);
void show_mqtt_handlers(uuid::console::Shell & shell) const; void show_mqtt_handlers(uuid::console::Shell & shell) const;
void list_device_entries(JsonObject & output) const; void list_device_entries(JsonObject & output) const;
void exclude_entity(uint8_t entity_id); void exclude_entity(uint8_t entity_id);

View File

@@ -1281,7 +1281,6 @@ void EMSESP::start() {
esp8266React.begin(); // loads core system services settings (network, mqtt, ap, ntp etc) esp8266React.begin(); // loads core system services settings (network, mqtt, ap, ntp etc)
webLogService.begin(); // start web log service. now we can start capturing logs to the web log webLogService.begin(); // start web log service. now we can start capturing logs to the web log
LOG_INFO(F("Starting EMS-ESP version %s (hostname: %s)"), EMSESP_APP_VERSION, system_.hostname().c_str()); // welcome message
LOG_INFO(F("Last system reset reason Core0: %s, Core1: %s"), system_.reset_reason(0).c_str(), system_.reset_reason(1).c_str()); LOG_INFO(F("Last system reset reason Core0: %s, Core1: %s"), system_.reset_reason(0).c_str(), system_.reset_reason(1).c_str());
webSettingsService.begin(); // load EMS-ESP Application settings... webSettingsService.begin(); // load EMS-ESP Application settings...
@@ -1296,8 +1295,10 @@ void EMSESP::start() {
system_.check_upgrade(); // do any system upgrades system_.check_upgrade(); // do any system upgrades
// start all the EMS-ESP services // start all the EMS-ESP services
mqtt_.start(); // mqtt init mqtt_.start(); // mqtt init
system_.start(); // starts commands, led, adc, button, network, syslog & uart system_.start(); // starts commands, led, adc, button, network, syslog & uart
LOG_INFO(F("Starting EMS-ESP version %s (hostname: %s)"), EMSESP_APP_VERSION, system_.hostname().c_str()); // welcome message
shower_.start(); // initialize shower timer and shower alert shower_.start(); // initialize shower timer and shower alert
dallassensor_.start(); // Dallas external sensors dallassensor_.start(); // Dallas external sensors
analogsensor_.start(); // Analog external sensors analogsensor_.start(); // Analog external sensors

View File

@@ -189,11 +189,11 @@ char * Helpers::render_boolean(char * result, bool value) {
return result; return result;
} }
// render for native char strings // // render for native char strings
char * Helpers::render_value(char * result, const char * value, const int8_t format __attribute__((unused))) { // char * Helpers::render_value(char * result, const char * value, const int8_t format __attribute__((unused))) {
strcpy(result, value); // un-safe but we don't care // strcpy(result, value); // un-safe but we don't care
return result; // return result;
} // }
// convert unsigned int (single byte) to text value and returns it // convert unsigned int (single byte) to text value and returns it
// format: 255(0xFF)=boolean, 0=no formatting, otherwise divide by format // format: 255(0xFF)=boolean, 0=no formatting, otherwise divide by format

View File

@@ -37,7 +37,7 @@ class Helpers {
static char * render_value(char * result, const uint32_t value, const int8_t format, const uint8_t fahrenheit = 0); static char * render_value(char * result, const uint32_t value, const int8_t format, const uint8_t fahrenheit = 0);
static char * render_value(char * result, const int16_t value, const int8_t format, const uint8_t fahrenheit = 0); static char * render_value(char * result, const int16_t value, const int8_t format, const uint8_t fahrenheit = 0);
static char * render_value(char * result, const int32_t value, const int8_t format, const uint8_t fahrenheit = 0); static char * render_value(char * result, const int32_t value, const int8_t format, const uint8_t fahrenheit = 0);
static char * render_value(char * result, const char * value, const int8_t format); // static char * render_value(char * result, const char * value, const int8_t format);
static char * render_boolean(char * result, bool value); static char * render_boolean(char * result, bool value);
static char * hextoa(char * result, const uint8_t value); static char * hextoa(char * result, const uint8_t value);

View File

@@ -1191,16 +1191,16 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
obj["product id"] = emsdevice->product_id(); obj["product id"] = emsdevice->product_id();
obj["version"] = emsdevice->version(); obj["version"] = emsdevice->version();
obj["entities"] = emsdevice->count_entities(); obj["entities"] = emsdevice->count_entities();
char result[200]; char result[250];
(void)emsdevice->show_telegram_handlers(result, EMSdevice::Handlers::RECEIVED); (void)emsdevice->show_telegram_handlers(result, sizeof(result), EMSdevice::Handlers::RECEIVED);
if (result[0] != '\0') { if (result[0] != '\0') {
obj["handlers received"] = result; // don't show handlers if there aren't any obj["handlers received"] = result; // don't show handlers if there aren't any
} }
(void)emsdevice->show_telegram_handlers(result, EMSdevice::Handlers::FETCHED); (void)emsdevice->show_telegram_handlers(result, sizeof(result), EMSdevice::Handlers::FETCHED);
if (result[0] != '\0') { if (result[0] != '\0') {
obj["handlers fetched"] = result; obj["handlers fetched"] = result;
} }
(void)emsdevice->show_telegram_handlers(result, EMSdevice::Handlers::PENDING); (void)emsdevice->show_telegram_handlers(result, sizeof(result), EMSdevice::Handlers::PENDING);
if (result[0] != '\0') { if (result[0] != '\0') {
obj["handlers pending"] = result; obj["handlers pending"] = result;
} }