From 047dee5244ae5dd2e45141a75023622b1ac5a8bb Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 5 Jul 2020 10:02:38 +0200 Subject: [PATCH] Moved SoftwareSerial only methods to macro guards --- src/ISerial.cpp | 50 +++++++++++++++++++------------------------------ src/ISerial.h | 12 ++++++++---- 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/src/ISerial.cpp b/src/ISerial.cpp index 8cd4c65a..dbfa6a30 100644 --- a/src/ISerial.cpp +++ b/src/ISerial.cpp @@ -8,41 +8,10 @@ void ISerial::begin(long speed) { _mod->ModuleSerial->begin(speed); } -bool ISerial::listen() { -#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - return true; -#else - return(_mod->ModuleSerial->listen()); -#endif -} - void ISerial::end() { _mod->ModuleSerial->end(); } -bool ISerial::isListening() { -#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - return true; -#else - return(_mod->ModuleSerial->isListening()); -#endif -} - -bool ISerial::stopListening() { -#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - return true; -#else - return(_mod->ModuleSerial->stopListening()); -#endif -} - -bool ISerial::overflow() { -#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED - return false; -#else - return(_mod->ModuleSerial->overflow()); -#endif -} int ISerial::peek() { return(_mod->ModuleSerial->peek()); @@ -64,6 +33,25 @@ void ISerial::flush() { _mod->ModuleSerial->flush(); } +// SoftwareSerial-only methods +#if !defined(RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED) +bool ISerial::listen() { + return(_mod->ModuleSerial->listen()); +} + +bool ISerial::isListening() { + return(_mod->ModuleSerial->isListening()); +} + +bool ISerial::stopListening() { + return(_mod->ModuleSerial->stopListening()); +} + +bool ISerial::overflow() { + return(_mod->ModuleSerial->overflow()); +} +#endif + size_t ISerial::print(const __FlashStringHelper *ifsh) { return(_mod->ModuleSerial->print(ifsh)); } diff --git a/src/ISerial.h b/src/ISerial.h index c8ecacbe..34064934 100644 --- a/src/ISerial.h +++ b/src/ISerial.h @@ -18,17 +18,21 @@ class ISerial { explicit ISerial(Module* mod); void begin(long); - bool listen(); void end(); - bool isListening(); - bool stopListening(); - bool overflow(); int peek(); size_t write(uint8_t); int read(); int available(); void flush(); + // SoftwareSerial-only methods + #if !defined(RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED) + bool listen(); + bool isListening(); + bool stopListening(); + bool overflow(); + #endif + size_t print(const __FlashStringHelper *); size_t print(const String &); size_t print(const char[]);