1、增加NMEA日志,可以支持回放路径
authorsnickersun <snickersun@qq.com>
Tue, 10 Mar 2020 17:59:46 +0000 (01:59 +0800)
committersnickersun <snickersun@qq.com>
Tue, 10 Mar 2020 17:59:46 +0000 (01:59 +0800)
2、upload,all日志增加Nmea.txt
3、优化nmea解析,修正上报数据。坐标小数点后6位压缩到4位。

app/src/main/java/com/enqualcomm/support/ICSmsManager.java
app/src/main/java/com/enqualcomm/support/LocationClient.java
app/src/main/java/com/enqualcomm/support/NMEAListener.java
app/src/main/java/com/enqualcomm/support/bean/ICLocation.java
app/src/main/java/com/enqualcomm/support/bean/Runtime.java
app/src/main/java/com/enqualcomm/support/utils/FileOutputUtil.java

index 307bcc4..246d93e 100644 (file)
@@ -396,13 +396,13 @@ public class ICSmsManager {
                             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
index d9c48f0..c7e5c1b 100644 (file)
@@ -445,7 +445,7 @@ public void updateCellInfo() {
 \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
index 4773563..a48517c 100644 (file)
@@ -80,9 +80,9 @@ public class NMEAListener implements NmeaListener, LocationListener {
 //    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
@@ -101,7 +101,7 @@ public class NMEAListener implements NmeaListener, LocationListener {
       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
@@ -127,23 +127,23 @@ public class NMEAListener implements NmeaListener, LocationListener {
       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
@@ -191,7 +191,7 @@ public class NMEAListener implements NmeaListener, LocationListener {
         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
@@ -653,7 +653,7 @@ public class NMEAListener implements NmeaListener, LocationListener {
       locationManager.addNmeaListener(this); //监听NMEA 协议数据。\r
 \r
       //做个热启动\r
-      return gpsHotStart();\r
+      return true;//gpsHotStart();\r
     }else{\r
       return true;\r
     }\r
@@ -661,7 +661,7 @@ public class NMEAListener implements NmeaListener, LocationListener {
   \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
index 05daadb..3aded22 100644 (file)
@@ -13,6 +13,8 @@ public class ICLocation {
         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
@@ -102,6 +104,17 @@ public class ICLocation {
         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
index dc8d7cf..4133d80 100644 (file)
@@ -467,11 +467,17 @@ public class Runtime {
     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
index a56aa2f..dad44ac 100644 (file)
@@ -118,7 +118,26 @@ public class FileOutputUtil {
         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