aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-10-01 07:18:26 +0200
committerHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-10-11 23:41:16 +0200
commit2358dc14d7cffac55ec297f335a433f9a73df146 (patch)
treeba41ade62a99e19d0d2f05db3b2a41c0c2564671 /src
parentfad5688f698bd10d91e730e4c5ee284e238d2faa (diff)
downloadBlueGPS-2358dc14d7cffac55ec297f335a433f9a73df146.zip
BlueGPS-2358dc14d7cffac55ec297f335a433f9a73df146.tar.gz
BlueGPS-2358dc14d7cffac55ec297f335a433f9a73df146.tar.bz2
verify we are ready to write, before really writing
Diffstat (limited to 'src')
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
index 4db6d65..c1ad6bc 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java
@@ -78,7 +78,11 @@ public class BlueetoothGpsManager {
out = tmpOut;
out2 = tmpOut2;
}
-
+
+ public boolean isReady(){
+ return ready;
+ }
+
public void run() {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(in,"US-ASCII"));
@@ -102,6 +106,7 @@ public class BlueetoothGpsManager {
Log.e("BT test", "error while getting data", e);
setMockLocationProviderOutOfService();
} finally {
+ ready = false;
disableIfNeeded();
}
}
@@ -396,6 +401,10 @@ public class BlueetoothGpsManager {
notificationPool.execute( new Runnable() {
@Override
public void run() {
+ while ((!enabled) || (!connected) || (connectedGps == null) || (!connectedGps.isReady())){
+ Log.e("BT test", "writing thread is not ready");
+ SystemClock.sleep(500);
+ }
if (isEnabled() && (connectedGps != null)){
connectedGps.write(command);
Log.e("BT test", "sent NMEA sentence: "+command);
@@ -412,6 +421,10 @@ public class BlueetoothGpsManager {
notificationPool.execute( new Runnable() {
@Override
public void run() {
+ while ((!enabled) || (!connected) || (connectedGps == null) || (!connectedGps.isReady())){
+ Log.e("BT test", "writing thread is not ready");
+ SystemClock.sleep(500);
+ }
if (isEnabled() && (connectedGps != null)){
connectedGps.write(command);
Log.e("BT test", "sent SIRF sentence: "+commandHexa);