From 122e23fccda701bbfe40046fb8937ad9198c6d0e Mon Sep 17 00:00:00 2001 From: Erik Fleckstein Date: Thu, 31 Oct 2024 16:38:26 +0100 Subject: [PATCH] modbus_tcp: Use tftools/option. --- .../src/modules/modbus_tcp/modbus_tcp.cpp | 69 +------------------ 1 file changed, 2 insertions(+), 67 deletions(-) diff --git a/software/src/modules/modbus_tcp/modbus_tcp.cpp b/software/src/modules/modbus_tcp/modbus_tcp.cpp index cca114006..4bb113961 100644 --- a/software/src/modules/modbus_tcp/modbus_tcp.cpp +++ b/software/src/modules/modbus_tcp/modbus_tcp.cpp @@ -33,6 +33,8 @@ #include "modules/power_manager/power_manager.h" #endif +#include + extern uint32_t local_uid_num; // MODBUS TABLE CHANGELOG @@ -41,73 +43,6 @@ extern uint32_t local_uid_num; // 3 - Add phase switch #define MODBUS_TABLE_VERSION 3 - -template -struct Option { -public: - template, typename std::enable_if::type...> - Option(T t): val(t), have_val(true) {} - - // val has to be initialized if it is a primitive type. - Option() : val(), have_val(false) {} - - T &unwrap() { - return expect("unwrapped Option without value!"); - } - - const T &unwrap() const { - return expect("unwrapped Option without value!"); - } - - T &unwrap_or(T &default_value) { - if (!have_val) - return default_value; - return val; - } - - const T &unwrap_or(const T &default_value) const { - if (!have_val) - return default_value; - return val; - } - - T &expect(const char *message) { - if (!have_val) - esp_system_abort(message); - return val; - } - - const T &expect(const char *message) const { - if (!have_val) - esp_system_abort(message); - return val; - } - - T &insert(const T &default_value) { - val = default_value; - have_val = true; - return val; - } - - bool is_some() const { - return have_val; - } - - bool is_none() const { - return !have_val; - } - - void clear() { - have_val = false; - } - -private: - T val; - bool have_val; -}; - - - static uint8_t hextouint(const char c) { uint8_t i = 0;