From d613e8ff9c48c9e5c6eb8eafcc66aaa09e27b058 Mon Sep 17 00:00:00 2001 From: proddy Date: Sat, 17 Oct 2020 16:53:45 +0200 Subject: [PATCH] show unknown devices as generic --- src/devices/generic.cpp | 48 ++++++++++++++++++++++++++++++++++++++++ src/devices/generic.h | 49 +++++++++++++++++++++++++++++++++++++++++ src/locale_EN.h | 3 +++ src/test/test.cpp | 7 ++++-- src/version.h | 2 +- 5 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 src/devices/generic.cpp create mode 100644 src/devices/generic.h diff --git a/src/devices/generic.cpp b/src/devices/generic.cpp new file mode 100644 index 000000000..18c608d7e --- /dev/null +++ b/src/devices/generic.cpp @@ -0,0 +1,48 @@ +/* + * EMS-ESP - https://github.com/proddy/EMS-ESP + * Copyright 2019 Paul Derbyshire + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "generic.h" + +namespace emsesp { + +REGISTER_FACTORY(Generic, EMSdevice::DeviceType::GENERIC); + +uuid::log::Logger Generic::logger_{F_(generic), uuid::log::Facility::CONSOLE}; + +Generic::Generic(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand) + : EMSdevice(device_type, device_id, product_id, version, name, flags, brand) { +} + +void Generic::device_info_web(JsonArray & root) { +} + +// display all values into the shell console +void Generic::show_values(uuid::console::Shell & shell) { + // EMSdevice::show_values(shell); // always call this to show header +} + +// publish values via MQTT +void Generic::publish_values(JsonObject & data) { +} + +// check to see if values have been updated +bool Generic::updated_values() { + return false; +} + +} // namespace emsesp \ No newline at end of file diff --git a/src/devices/generic.h b/src/devices/generic.h new file mode 100644 index 000000000..4ee9fc113 --- /dev/null +++ b/src/devices/generic.h @@ -0,0 +1,49 @@ +/* + * EMS-ESP - https://github.com/proddy/EMS-ESP + * Copyright 2019 Paul Derbyshire + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef EMSESP_GENERIC_H +#define EMSESP_GENERIC_H + +#include +#include + +#include + +#include "emsdevice.h" +#include "telegram.h" +#include "helpers.h" +#include "mqtt.h" + +namespace emsesp { + +class Generic : public EMSdevice { + public: + Generic(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand); + + virtual void show_values(uuid::console::Shell & shell); + virtual void publish_values(JsonObject & data); + virtual void device_info_web(JsonArray & root); + virtual bool updated_values(); + + private: + static uuid::log::Logger logger_; +}; + +} // namespace emsesp + +#endif diff --git a/src/locale_EN.h b/src/locale_EN.h index 8345da681..6309690c2 100644 --- a/src/locale_EN.h +++ b/src/locale_EN.h @@ -90,10 +90,13 @@ MAKE_PSTR_WORD(gateway) MAKE_PSTR_WORD(controller) MAKE_PSTR_WORD(connect) MAKE_PSTR_WORD(heatpump) +MAKE_PSTR_WORD(generic) // dallas sensors MAKE_PSTR_WORD(sensor) +MAKE_PSTR(1space, " ") +MAKE_PSTR(2spaces, " ") MAKE_PSTR(kwh, "kWh") MAKE_PSTR(wh, "Wh") MAKE_PSTR(master_thermostat_fmt, "Master Thermostat Device ID = %s") diff --git a/src/test/test.cpp b/src/test/test.cpp index 5cafd69d1..e04a9561a 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -28,7 +28,7 @@ namespace emsesp { // used with the 'test' command, under su/admin void Test::run_test(uuid::console::Shell & shell, const std::string & command) { if (command == "default") { - run_test(shell, "mixing"); // add the default test case here + run_test(shell, "unknown"); // add the default test case here } if (command.empty()) { @@ -172,7 +172,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { // note there is no brand (byte 9) rx_telegram({0x09, 0x0B, 0x02, 0x00, 0x59, 0x09, 0x0a}); - EMSESP::show_device_values(shell); + shell.invoke_command("show devices"); + shell.invoke_command("call system report"); } if (command == "unknown2") { @@ -808,6 +809,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { uart_telegram({0xA0, 0x00, 0xFF, 0x00, 0x01, 0x55, 0x00, 0x1A}); shell.invoke_command("show"); + shell.invoke_command("call"); + shell.invoke_command("call system report"); } // finally dump to console diff --git a/src/version.h b/src/version.h index b8809fb9b..36b0b7a2b 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "2.1.0b7" +#define EMSESP_APP_VERSION "2.1.0b8"