projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altosdroid: Move pause before reopening bluetooth into connec thread
[fw/altos]
/
altosdroid
/
src
/
org
/
altusmetrum
/
AltosDroid
/
AltosBluetooth.java
diff --git
a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java
b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java
index e68b1885175c6bcb76641437359025c3196c6ea4..d506ff59cc4702e2d2fa8561330af5289edb2b8e 100644
(file)
--- a/
altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java
+++ b/
altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java
@@
-41,19
+41,19
@@
public class AltosBluetooth extends AltosDroidLink {
private ConnectThread connect_thread = null;
private ConnectThread connect_thread = null;
- private Bluetooth
Adapter adapter
;
+ private Bluetooth
Device device
;
private BluetoothSocket socket;
private InputStream input;
private OutputStream output;
private BluetoothSocket socket;
private InputStream input;
private OutputStream output;
+ private boolean pause;
// Constructor
// Constructor
- public AltosBluetooth(BluetoothDevice device, Handler handler) {
+ public AltosBluetooth(BluetoothDevice device, Handler handler
, boolean pause
) {
super(handler);
super(handler);
-// set_debug(D);
- adapter = BluetoothAdapter.getDefaultAdapter();
+ this.device = device;
this.handler = handler;
this.handler = handler;
+ this.pause = pause;
- create_socket(device);
connect_thread = new ConnectThread();
connect_thread.start();
}
connect_thread = new ConnectThread();
connect_thread.start();
}
@@
-64,6
+64,7
@@
public class AltosBluetooth extends AltosDroidLink {
return;
}
return;
}
+ AltosDebug.check_ui("connected\n");
try {
synchronized(this) {
if (socket != null) {
try {
synchronized(this) {
if (socket != null) {
@@
-141,9
+142,17
@@
public class AltosBluetooth extends AltosDroidLink {
if (D) Log.d(TAG, "ConnectThread: BEGIN");
setName("ConnectThread");
if (D) Log.d(TAG, "ConnectThread: BEGIN");
setName("ConnectThread");
+ if (pause) {
+ try {
+ Thread.sleep(4000);
+ } catch (InterruptedException e) {
+ }
+ }
+
+ create_socket(device);
// Always cancel discovery because it will slow down a connection
try {
// Always cancel discovery because it will slow down a connection
try {
-
adapter
.cancelDiscovery();
+
BluetoothAdapter.getDefaultAdapter()
.cancelDiscovery();
} catch (Exception e) {
if (D) Log.d(TAG, String.format("cancelDiscovery exception %s", e.toString()));
}
} catch (Exception e) {
if (D) Log.d(TAG, String.format("cancelDiscovery exception %s", e.toString()));
}