From b1cee63ec338e663157f48004bac4616b0a543cb Mon Sep 17 00:00:00 2001 From: Ray Jones Date: Sun, 27 Oct 2019 16:37:12 +1100 Subject: [PATCH] Added ABTelnetSpy derived class modules --- src/Afterburner.cpp | 2 +- src/Utility/ABTelnetSpy.cpp | 43 +++++++++++++++++++++++++++++++++++++ src/Utility/ABTelnetSpy.h | 38 ++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 src/Utility/ABTelnetSpy.cpp create mode 100644 src/Utility/ABTelnetSpy.h diff --git a/src/Afterburner.cpp b/src/Afterburner.cpp index e7653b3..9727160 100644 --- a/src/Afterburner.cpp +++ b/src/Afterburner.cpp @@ -125,7 +125,7 @@ const int FirmwareRevision = 31; const int FirmwareSubRevision = 6; -const char* FirmwareDate = "18 Oct 2019"; +const char* FirmwareDate = "27 Oct 2019"; #ifdef ESP32 diff --git a/src/Utility/ABTelnetSpy.cpp b/src/Utility/ABTelnetSpy.cpp new file mode 100644 index 0000000..9ab2a9c --- /dev/null +++ b/src/Utility/ABTelnetSpy.cpp @@ -0,0 +1,43 @@ +/* + * This file is part of the "bluetoothheater" distribution + * (https://gitlab.com/mrjones.id.au/bluetoothheater) + * + * Copyright (C) 2018 Ray Jones + * Copyright (C) 2018 James Clark + * + * 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 "ABTelnetSpy.h" + +ABTelnetSpy::ABTelnetSpy() : TelnetSpy() { + _enabled = true; +} + +size_t +ABTelnetSpy::write(uint8_t val) { + if(_enabled) { + return TelnetSpy::write(val); + } + return 0; +} + +void +ABTelnetSpy::enable(bool state) +{ + _enabled = state; +} + + diff --git a/src/Utility/ABTelnetSpy.h b/src/Utility/ABTelnetSpy.h new file mode 100644 index 0000000..1eb5320 --- /dev/null +++ b/src/Utility/ABTelnetSpy.h @@ -0,0 +1,38 @@ +/* + * This file is part of the "bluetoothheater" distribution + * (https://gitlab.com/mrjones.id.au/bluetoothheater) + * + * Copyright (C) 2018 Ray Jones + * Copyright (C) 2018 James Clark + * + * 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 "../../lib/TelnetSpy/TelnetSpy.h" + +#ifndef __ABTELNETSPY_H__ +#define __ABTELNETSPY_H__ + +class ABTelnetSpy : public TelnetSpy { +public: + ABTelnetSpy(); + size_t write(uint8_t) override; + void enable(bool); +protected: + bool _enabled; +}; + + +#endif // __ABTELNETSPY_H__