aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/broeuschmeul/android/gps/nmea
diff options
context:
space:
mode:
authorHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-11-07 20:14:05 +0100
committerHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-11-07 20:14:05 +0100
commit209c8bd571998d3d1639c56c5ad02fba0b6f9fe5 (patch)
tree68656bc69c8360c4f0c126b89663f74a5f73b992 /src/org/broeuschmeul/android/gps/nmea
parent8f50ddb2550152d86fc500cf55e4ce4a488c3ed7 (diff)
parent17f8164913422da101be1c667207608c5c6c1003 (diff)
downloadBlueGPS-209c8bd571998d3d1639c56c5ad02fba0b6f9fe5.zip
BlueGPS-209c8bd571998d3d1639c56c5ad02fba0b6f9fe5.tar.gz
BlueGPS-209c8bd571998d3d1639c56c5ad02fba0b6f9fe5.tar.bz2
Merge log rewrite from 1.1.x into branch 1.2.x
Diffstat (limited to 'src/org/broeuschmeul/android/gps/nmea')
-rw-r--r--src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java52
1 files changed, 27 insertions, 25 deletions
diff --git a/src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java b/src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java
index dbfae17..3d89efc 100644
--- a/src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java
+++ b/src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java
@@ -36,6 +36,9 @@ import android.text.TextUtils.SimpleStringSplitter;
import android.util.Log;
public class NmeaParser {
+ private static final String LOG_TAG = "BlueGPS";
+// private static final String LOG_TAG = NmeaParser.class.getSimpleName();
+
private String fixTime = null;
private long fixTimestamp;
@@ -73,27 +76,27 @@ public class NmeaParser {
if (! mockGpsEnabled){
prov = lm.getProvider(mockLocationProvider);
if (prov != null){
- Log.e("BT test", "Mock provider: "+prov.getName()+" "+prov.getPowerRequirement()+" "+prov.getAccuracy()+" "+lm.isProviderEnabled(mockLocationProvider));
+ Log.v(LOG_TAG, "Mock provider: "+prov.getName()+" "+prov.getPowerRequirement()+" "+prov.getAccuracy()+" "+lm.isProviderEnabled(mockLocationProvider));
}
lm.addTestProvider(mockLocationProvider, false, true,false, false, true, true, true, Criteria.POWER_HIGH, Criteria.ACCURACY_FINE);
if ((prov == null)
// || (! LocationManager.GPS_PROVIDER.equals(mockLocationProvider))
){
- Log.e("BT test", "enabling Mock provider: "+mockLocationProvider);
+ Log.d(LOG_TAG, "enabling Mock provider: "+mockLocationProvider);
lm.setTestProviderEnabled(mockLocationProvider, true);
mockGpsAutoEnabled = true;
}
mockGpsEnabled = true;
} else {
- Log.e("BT test", "Mock provider already enabled: "+mockLocationProvider);
+ Log.d(LOG_TAG, "Mock provider already enabled: "+mockLocationProvider);
}
prov = lm.getProvider(mockLocationProvider);
if (prov != null){
- Log.e("BT test", "Mock provider: "+prov.getName()+" "+prov.getPowerRequirement()+" "+prov.getAccuracy()+" "+lm.isProviderEnabled(mockLocationProvider));
+ Log.e(LOG_TAG, "Mock provider: "+prov.getName()+" "+prov.getPowerRequirement()+" "+prov.getAccuracy()+" "+lm.isProviderEnabled(mockLocationProvider));
}
}
} catch (SecurityException e){
- Log.e("BT test", "Error while enabling Mock Mocations Provider", e);
+ Log.e(LOG_TAG, "Error while enabling Mock Mocations Provider", e);
disableMockLocationProvider();
}
}
@@ -104,34 +107,34 @@ public class NmeaParser {
if (mockLocationProvider != null && mockLocationProvider != "" && mockGpsEnabled){
prov = lm.getProvider(mockLocationProvider);
if (prov != null){
- Log.e("BT test", "Mock provider: "+prov.getName()+" "+prov.getPowerRequirement()+" "+prov.getAccuracy()+" "+lm.isProviderEnabled(mockLocationProvider));
+ Log.v(LOG_TAG, "Mock provider: "+prov.getName()+" "+prov.getPowerRequirement()+" "+prov.getAccuracy()+" "+lm.isProviderEnabled(mockLocationProvider));
}
mockGpsEnabled = false;
if ( mockGpsAutoEnabled ) {
- Log.e("BT test", "disabling Mock provider: "+mockLocationProvider);
+ Log.d(LOG_TAG, "disabling Mock provider: "+mockLocationProvider);
lm.setTestProviderEnabled(mockLocationProvider, false);
}
prov = lm.getProvider(mockLocationProvider);
if (prov != null){
- Log.e("BT test", "Mock provider: "+prov.getName()+" "+prov.getPowerRequirement()+" "+prov.getAccuracy()+" "+lm.isProviderEnabled(mockLocationProvider));
+ Log.v(LOG_TAG, "Mock provider: "+prov.getName()+" "+prov.getPowerRequirement()+" "+prov.getAccuracy()+" "+lm.isProviderEnabled(mockLocationProvider));
}
lm.clearTestProviderEnabled(mockLocationProvider);
prov = lm.getProvider(mockLocationProvider);
if (prov != null){
- Log.e("BT test", "Mock provider: "+prov.getName()+" "+prov.getPowerRequirement()+" "+prov.getAccuracy()+" "+lm.isProviderEnabled(mockLocationProvider));
+ Log.v(LOG_TAG, "Mock provider: "+prov.getName()+" "+prov.getPowerRequirement()+" "+prov.getAccuracy()+" "+lm.isProviderEnabled(mockLocationProvider));
}
lm.clearTestProviderStatus(mockLocationProvider);
lm.removeTestProvider(mockLocationProvider);
prov = lm.getProvider(mockLocationProvider);
if (prov != null){
- Log.e("BT test", "Mock provider: "+prov.getName()+" "+prov.getPowerRequirement()+" "+prov.getAccuracy()+" "+lm.isProviderEnabled(mockLocationProvider));
+ Log.v(LOG_TAG, "Mock provider: "+prov.getName()+" "+prov.getPowerRequirement()+" "+prov.getAccuracy()+" "+lm.isProviderEnabled(mockLocationProvider));
}
- Log.e("BT test", "removed mock GPS");
+ Log.d(LOG_TAG, "removed mock GPS");
} else {
- Log.e("BT test", "Mock provider already disabled: "+mockLocationProvider);
+ Log.d(LOG_TAG, "Mock provider already disabled: "+mockLocationProvider);
}
} catch (SecurityException e){
- Log.e("BT test", "Error while enabling Mock Mocations Provider", e);
+ Log.e(LOG_TAG, "Error while enabling Mock Mocations Provider", e);
} finally {
mockLocationProvider = null;
mockGpsEnabled = false;
@@ -163,10 +166,10 @@ public class NmeaParser {
hasGGA = false;
hasRMC=false;
if (fix != null){
- Log.e(this.getClass().getSimpleName(), "New Fix: "+System.currentTimeMillis()+" "+fix);
+ Log.v(LOG_TAG, "New Fix: "+System.currentTimeMillis()+" "+fix);
if (lm != null && mockGpsEnabled){
lm.setTestProviderLocation(mockLocationProvider, fix);
- Log.e(this.getClass().getSimpleName(), "New Fix notified to Location Manager: "+mockLocationProvider);
+ Log.v(LOG_TAG, "New Fix notified to Location Manager: "+mockLocationProvider);
}
this.fix = null;
}
@@ -177,12 +180,12 @@ public class NmeaParser {
hasGGA = false;
hasRMC=false;
if (this.mockStatus != status){
- Log.e(this.getClass().getSimpleName(), "New mockStatus: "+System.currentTimeMillis()+" "+status);
+ Log.d(LOG_TAG, "New mockStatus: "+System.currentTimeMillis()+" "+status);
if (lm != null && mockGpsEnabled){
lm.setTestProviderStatus(mockLocationProvider, status, extras, updateTime);
// lm.setTestProviderStatus(mockLocationProvider, status, extras, SystemClock.elapsedRealtime());
// lm.setTestProviderStatus(mockLocationProvider, status, extras, 50);
- Log.e(this.getClass().getSimpleName(), "New mockStatus notified to Location Manager: " + status + " "+mockLocationProvider);
+ Log.v(LOG_TAG, "New mockStatus notified to Location Manager: " + status + " "+mockLocationProvider);
}
this.fix = null;
this.mockStatus = status;
@@ -192,14 +195,14 @@ public class NmeaParser {
// parse NMEA Sentence
public String parseNmeaSentence(String gpsSentence) throws SecurityException {
String nmeaSentence = null;
- Log.e("BT test", "data: "+System.currentTimeMillis()+" "+gpsSentence);
+ Log.v(LOG_TAG, "data: "+System.currentTimeMillis()+" "+gpsSentence);
Pattern xx = Pattern.compile("\\$([^*$]*)\\*([0-9A-F][0-9A-F])?\r\n");
Matcher m = xx.matcher(gpsSentence);
if (m.matches()){
nmeaSentence = m.group(0);
String sentence = m.group(1);
String checkSum = m.group(2);
- Log.e("BT test", "data: "+System.currentTimeMillis()+" "+sentence+" cheksum; "+checkSum +" control: "+String.format("%X",computeChecksum(sentence)));
+ Log.v(LOG_TAG, "data: "+System.currentTimeMillis()+" "+sentence+" cheksum; "+checkSum +" control: "+String.format("%X",computeChecksum(sentence)));
SimpleStringSplitter splitter = new TextUtils.SimpleStringSplitter(',');
splitter.setString(sentence);
String command = splitter.next();
@@ -272,7 +275,7 @@ public class NmeaParser {
fixTime = time;
fixTimestamp = parseNmeaTime(time);
fix.setTime(fixTimestamp);
- Log.e(this.getClass().getSimpleName(), "Fix: "+fix);
+ Log.v(LOG_TAG, "Fix: "+fix);
}
if (lat != null && !lat.equals("")){
fix.setLatitude(parseNmeaLatitude(lat,latDir));
@@ -291,7 +294,7 @@ public class NmeaParser {
extras.putInt("satellites", Integer.parseInt(nbSat));
fix.setExtras(extras);
}
- Log.e(this.getClass().getSimpleName(), "Fix: "+System.currentTimeMillis()+" "+fix);
+ Log.v(LOG_TAG, "Fix: "+System.currentTimeMillis()+" "+fix);
hasGGA = true;
if (hasGGA && hasRMC){
notifyFix(fix);
@@ -352,7 +355,7 @@ public class NmeaParser {
fixTime = time;
fixTimestamp = parseNmeaTime(time);
fix.setTime(fixTimestamp);
- Log.e(this.getClass().getSimpleName(), "Fix: "+fix);
+ Log.v(LOG_TAG, "Fix: "+fix);
}
if (lat != null && !lat.equals("")){
fix.setLatitude(parseNmeaLatitude(lat,latDir));
@@ -366,7 +369,7 @@ public class NmeaParser {
if (bearing != null && !bearing.equals("")){
fix.setBearing(Float.parseFloat(bearing));
}
- Log.e(this.getClass().getSimpleName(), "Fix: "+System.currentTimeMillis()+" "+fix);
+ Log.v(LOG_TAG, "Fix: "+System.currentTimeMillis()+" "+fix);
hasRMC = true;
if (hasGGA && hasRMC){
notifyFix(fix);
@@ -526,8 +529,7 @@ public class NmeaParser {
}
}
} catch (ParseException e) {
- // TODO Auto-generated catch block
- Log.e(this.getClass().getSimpleName(), "Error while parsing NMEA time", e);
+ Log.e(LOG_TAG, "Error while parsing NMEA time", e);
}
return timestamp;
}