String logfile=cmdl[1];\r
\r
if (logfile.isEmpty()|| logfile.equals("all")) {\r
- String filelist[] = {"crashlog", "APILog", "GPS", "LocationAlarm", "Battery", "log"};\r
+ String filelist[] = {"crashlog", "Nmea","APILog", "GPS", "LocationAlarm", "Battery", "log"};\r
// String filelist[]={"APILog","LocationAlarm","Battery"};\r
String time = TimeUtil.getSystemTime3();\r
StringBuilder sb = new StringBuilder();\r
Observable.timer(500L, TimeUnit.MILLISECONDS).subscribe(new Action1<Long>() {\r
public void call(Long param1Long) {\r
- sendSMS(phonenumber, "start Upload allLogfile [crashlog APILog log GPS LocationAlarm Battery] to " + Config.getFtpServer(mContext));\r
+ sendSMS(phonenumber, "start Upload allLogfile [crashlog Nmea APILog log GPS LocationAlarm Battery] to " + Config.getFtpServer(mContext));\r
String logtime = TimeUtil.getSystemTime3();\r
for (String file : filelist) {\r
\r
\r
updateStepCount();//update StepCount,保证每次定位前,计步数据是最新的。防止丢数据。\r
ICLogger.i("forceLocation="+forceLocation+", WorkingMod="+mod+", isLocating="+isLocating+", lastStep="+runtime.getLastStepCount()+", currentStep="+ runtime.getTotalStepCount());\r
- if (isLocating ) {\r
+ if (isLocating && 1!=forceLocation) {\r
ICLogger.i("locating ,skip location!");\r
return;\r
}\r
// EqcAlgorithmNative.native_EqcAlgorithmMethod5(paramString);\r
// ICLogger.i("Nmea :"+nmeastr+" "+paramLong);\r
\r
- if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"Nmea","Nmea :"+nmeastr+" "+paramLong);\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutputRaw(this.runtime.getCacheDir(),"Nmea",nmeastr);\r
\r
- searchCout++;\r
+ if(nmeastr.startsWith("$RD_RSSI")) searchCout++;\r
\r
\r
if (nmeastr.startsWith("$GPGLL,")){\r
String Lat=tmplist[1];\r
String lon=tmplist[3];\r
String fixed=tmplist[6];\r
- ICLogger.i("GPGLL Lat="+Lat+",Lon="+lon+",fixed="+fixed);\r
+// ICLogger.i("GPGLL Lat="+Lat+",Lon="+lon+",fixed="+fixed);\r
\r
}else if (nmeastr.startsWith("$GPRMC,")) {\r
// GPRMC编辑\r
String lon=tmplist[5];\r
String fixed=tmplist[2];\r
String speed=tmplist[7];\r
- ICLogger.i("GPRMC GPSTime="+utctime+",Lat="+Lat+",Lon="+lon+",fixed="+fixed+",speed="+speed);\r
- if (Config.LOG_TOFILE)\r
- FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "GPRMC GPSTime="+utctime+",Lat="+Lat+",Lon="+lon+",fixed="+fixed+",speed="+speed);\r
+// ICLogger.i("GPRMC GPSTime="+utctime+",Lat="+Lat+",Lon="+lon+",fixed="+fixed+",speed="+speed);\r
+// if (Config.LOG_TOFILE)\r
+// FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "GPRMC GPSTime="+utctime+",Lat="+Lat+",Lon="+lon+",fixed="+fixed+",speed="+speed);\r
\r
StringBuilder sb=new StringBuilder();\r
-\r
+ sb.append("GPRMC, location time= " + TimeUtil.getLocalTime() + " ,lon= " + lon + ", lat= " + Lat + ","+fixed+" FixedCount=" + locationFixedCount + ", speed=" + speed);\r
+ ICLogger.i(sb.toString());\r
+ if (Config.LOG_TOFILE)\r
+ FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb.toString());\r
//定位了,\r
if (fixed.equals("A")) {\r
locationFixedCount++;\r
\r
- sb.append(", location time= " + TimeUtil.getLocalTime() + " ,lon= " + lon + ", lat= " + Lat + " FixedCount=" + locationFixedCount + ", speed=" + speed);\r
- ICLogger.i(sb.toString());\r
- if (Config.LOG_TOFILE)\r
- FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb.toString());\r
+\r
\r
if (speed.trim().isEmpty())speed="0.0";\r
- runtime.getLocationInstance().setLocation(latitude, longitude,Double.valueOf(speed), 0, numSatelliteList.size());\r
+ runtime.getLocationInstance().setLocation(Lat, lon,Double.valueOf(speed), 0, numSatelliteList.size());\r
if (locationFixedCount > MaxFixedTimes) {\r
/*\r
只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。\r
max3Satellite.clear(); //清除 最大3个星值\r
}\r
int satcount=(tmplist.length-4)/4;\r
- ICLogger.i("Nmea :"+nmeastr+" "+satcount);\r
+// ICLogger.i("Nmea :"+nmeastr+" "+satcount);\r
for (int i=0;i<satcount;i++){\r
satindex++;\r
String prn=tmplist[i*4+4];\r
locationManager.addNmeaListener(this); //监听NMEA 协议数据。\r
\r
//做个热启动\r
- return gpsHotStart();\r
+ return true;//gpsHotStart();\r
}else{\r
return true;\r
}\r
\r
\r
public void stopListen() {\r
-// this.locationManager.removeNmeaListener(this);\r
+ this.locationManager.removeNmeaListener(this);\r
this.locationManager.removeUpdates(this);\r
this.listening = false;\r
}\r
public double speed;\r
public double heading;\r
public int used_gps_numbs;\r
+ public String latStr;\r
+ public String lonStr;\r
}\r
public class LBS_Data{\r
HashMap<String ,Integer> wifi_aps=null;\r
currentLP.speed=speed;\r
currentLP.heading=heading;\r
currentLP.used_gps_numbs = userdgpsnumbers;\r
+ currentLP.latStr="";\r
+ currentLP.lonStr="";\r
+ }\r
+ public void setLocation(String lat,String lon,double speed,double heading,int userdgpsnumbers){\r
+ currentLP.lat=0;\r
+ currentLP.lon=0;\r
+ currentLP.speed=speed;\r
+ currentLP.heading=heading;\r
+ currentLP.used_gps_numbs = userdgpsnumbers;\r
+ currentLP.latStr=lat;\r
+ currentLP.lonStr=lon;\r
}\r
\r
public void clearLBSdata(){\r
int lonl=(int) ((gpsp.getLocation().lon - loni)*10000);\r
int speedi=(int)gpsp.getLocation().speed;\r
int speedl=(int) ((gpsp.getLocation().speed - speedi)*10);\r
-\r
+ String latStr=gpsp.getLocation().latStr;\r
+ String lonStr=gpsp.getLocation().lonStr;\r
if (isGPSFixed())\r
{\r
- String gpsStr=String.format("%04d.%04dN%05d.%04dE%03d.%01d",lati,latl,loni,lonl,speedi,speedl);\r
- sb.append("A").append(gpsStr);\r
+ if (gpsp.getLocation().lonStr.isEmpty()) {\r
+ String gpsStr = String.format("%04d.%04dN%05d.%04dE%03d.%01d", lati, latl, loni, lonl, speedi, speedl);\r
+ sb.append("A").append(gpsStr);\r
+ }else{\r
+ String gpsStr = String.format("%sN%sE%03d.%01d", latStr.substring(0,9), lonStr.substring(0,10), speedi, speedl);\r
+ sb.append("A").append(gpsStr);\r
+ }\r
}else{\r
String gpsStr=String.format("%04d.%04dN%05d.%04dE%03d.%01d",0,0,0,0,0,0);\r
sb.append("V").append(gpsStr);\r
return;\r
} \r
}\r
- \r
+ public static void fileOutputRaw(File dir, String filename, String msg) {\r
+// String str = TimeUtil.getSystemTime();\r
+\r
+ StringBuilder stringBuilder = new StringBuilder();\r
+ stringBuilder.append(filename);\r
+ stringBuilder.append(".txt");\r
+ File file = new File(dir, stringBuilder.toString());\r
+ try {\r
+ PrintStream printStream = new PrintStream(new FileOutputStream(file, true));\r
+ StringBuilder stringBuilder1 = new StringBuilder();\r
+ stringBuilder1.append(msg);\r
+ printStream.println(stringBuilder1.toString());\r
+ printStream.close();\r
+\r
+ } catch (FileNotFoundException e) {\r
+ e.printStackTrace();\r
+\r
+ }\r
+\r
+ }\r
public static void fileOutput(File dir, String filename, String msg) {\r
String str = TimeUtil.getSystemTime();\r
\r