altoslib: Support binary reading/writing in AltosLink
[fw/altos] / altosdroid / src / org / altusmetrum / AltosDroid / AltosBluetooth.java
index 0aea06f1cf22a242cf89489768070522caafdf15..643e94f5fa3f8802fef2b7985c058d4dd2deec0c 100644 (file)
@@ -31,7 +31,7 @@ import android.os.Handler;
 //import android.os.Message;
 import android.util.Log;
 
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
 
 public class AltosBluetooth extends AltosLink {
 
@@ -162,6 +162,20 @@ public class AltosBluetooth extends AltosLink {
                }
        }
 
+       public void putchar(byte c) {
+               byte[] bytes = { c };
+               if (D) Log.d(TAG, "print(): begin");
+               try {
+                       wait_connected();
+                       output.write(bytes);
+                       if (D) Log.d(TAG, "print(): Wrote byte: '" + c + "'");
+               } catch (IOException e) {
+                       connection_lost();
+               } catch (InterruptedException e) {
+                       connection_lost();
+               }
+       }               
+
        public int getchar() {
                try {
                        wait_connected();