diff --git a/hardware/arduino/avr/libraries/SoftwareSerial/SoftwareSerial.cpp b/hardware/arduino/avr/libraries/SoftwareSerial/SoftwareSerial.cpp index 8bf56e5d4..a429f7d2d 100644 --- a/hardware/arduino/avr/libraries/SoftwareSerial/SoftwareSerial.cpp +++ b/hardware/arduino/avr/libraries/SoftwareSerial/SoftwareSerial.cpp @@ -195,6 +195,17 @@ bool SoftwareSerial::listen() return false; } +// Stop listening. Returns true if we were actually listening. +bool SoftwareSerial::stopListening() +{ + if (active_object == this) + { + active_object = NULL; + return true; + } + return false; +} + // // The receive routine called by the interrupt handler // diff --git a/hardware/arduino/avr/libraries/SoftwareSerial/SoftwareSerial.h b/hardware/arduino/avr/libraries/SoftwareSerial/SoftwareSerial.h index 31bd229ef..e0e4746cd 100644 --- a/hardware/arduino/avr/libraries/SoftwareSerial/SoftwareSerial.h +++ b/hardware/arduino/avr/libraries/SoftwareSerial/SoftwareSerial.h @@ -87,6 +87,7 @@ public: bool listen(); void end(); bool isListening() { return this == active_object; } + bool stopListening(); bool overflow() { bool ret = _buffer_overflow; _buffer_overflow = false; return ret; } int peek();