Moved SoftwareSerial only methods to macro guards

This commit is contained in:
jgromes 2020-07-05 10:02:38 +02:00
parent 0ee58ff770
commit 047dee5244
2 changed files with 27 additions and 35 deletions

View file

@ -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));
}

View file

@ -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[]);