import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
+import android.os.Handler;
import android.util.Log;
import org.altusmetrum.AltosLib.*;
private ConnectThread connect_thread = null;
private Thread input_thread = null;
+ private Handler handler;
+
private BluetoothAdapter adapter;
private BluetoothDevice device;
private BluetoothSocket socket;
private OutputStream output;
// Constructor
- public AltosBluetooth(BluetoothDevice in_device) {
+ public AltosBluetooth(BluetoothDevice in_device, Handler in_handler) {
adapter = BluetoothAdapter.getDefaultAdapter();
-
+ device = in_device;
+ handler = in_handler;
connect_thread = new ConnectThread(device);
connect_thread.start();
input = socket.getInputStream();
output = socket.getOutputStream();
+ // Configure the newly connected device for telemetry
+ print("~\nE 0\n");
+ set_monitor(false);
+
// Reset the ConnectThread because we're done
AltosBluetooth.this.notify();
connect_thread = null;
}
private void connection_failed() {
+ if (D) Log.i(TAG, "Bluetooth Connection failed!");
}
public void print(String data) {
byte[] bytes = data.getBytes();
try {
+ if (D) Log.i(TAG, "Entering print();");
wait_connected();
output.write(bytes);
+ if (D) Log.i(TAG, "Writing bytes: '" + data + "'");
} catch (IOException e) {
connection_failed();
} catch (InterruptedException e) {