From 3f02bcb49fca21a39d8c0d11c287addd9f7d7724 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 4 Jun 2013 11:28:30 +0200 Subject: Add SoftwareSerial::stopListening() This allows one to explicitly stop a SoftwareSerial instance from listening, without having to make another one listening. --- libraries/SoftwareSerial/SoftwareSerial.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libraries/SoftwareSerial/SoftwareSerial.cpp') diff --git a/libraries/SoftwareSerial/SoftwareSerial.cpp b/libraries/SoftwareSerial/SoftwareSerial.cpp index 8bf56e5..a429f7d 100644 --- a/libraries/SoftwareSerial/SoftwareSerial.cpp +++ b/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 // -- cgit v1.2.3-18-g5258