altosdroid: Check for closed before writing/reading bluetooth
[fw/altos] / altosdroid / src / org / altusmetrum / AltosDroid / AltosBluetooth.java
index 15efc0e2a72294765626ce97fa5ace879f4b8702..51937b7faa6999f7c125188aa7a5e1be35f4c861 100644 (file)
@@ -199,6 +199,8 @@ public class AltosBluetooth extends AltosDroidLink {
        }
 
        int write(byte[] buffer, int len) {
+               if (output == null)
+                       return -1;
                try {
                        output.write(buffer, 0, len);
                } catch (IOException ie) {
@@ -208,6 +210,8 @@ public class AltosBluetooth extends AltosDroidLink {
        }
 
        int read(byte[] buffer, int len) {
+               if (input == null)
+                       return -1;
                try {
                        return input.read(buffer, 0, len);
                } catch (IOException ie) {