}\r
}\r
\r
+ private static int no_network_Heartbeats_Count=0;\r
\r
public void ReConnectToServer(){\r
\r
// isServerConnected 成功则停止重试, KeepAlive会检测AP03心跳包的成功与否。此处只管socket连接是否成功\r
if (connection.isServerConnected()) {\r
ICLogger.i("retry 如果连接成功则停止重试!");\r
+ no_network_Heartbeats_Count=0;\r
stopConnectionRetryTimer();\r
}else {\r
if (retry_connect_count >= retry_connect_max_times) {\r
\r
ICLogger.i("retry " + retry_connect_count + " 次 >= " + retry_connect_max_times + " ,停止重试!等待下一次心跳再重试!");\r
+ no_network_Heartbeats_Count++;\r
stopConnectionRetryTimer();\r
\r
} else {\r
}else{\r
//没有网络就不用重新尝试连接网络了。网络连接后再重新尝试联网\r
ICLogger.i("retry 没有网络就不用重新尝试连接网络了。网络连接后再重新尝试联网!");\r
+ no_network_Heartbeats_Count++;\r
stopConnectionRetryTimer();\r
}\r
+ if( no_network_Heartbeats_Count >10){\r
+ ICLogger.i("当前第"+no_network_Heartbeats_Count+"次心跳都没有连接服务器成功 > 10 ,重置SIM卡尝试重新注册网络!");\r
+ SimSignalUtil.send_at_to_onoff_simcard(runtime);\r
+ }\r
}\r
\r
public void stopConnectionRetryTimer(){\r
\r
public void setNoStop(boolean nostop){\r
noStop=nostop;\r
- ICLogger.i("setNoStop"+nostop);\r
- if (noStop==false){\r
- stopListen();\r
+ ICLogger.i("setNoStop "+nostop);\r
+ if (noStop==false ){\r
+ switch (runtime.getLocationInstance().getWorkingMod()){\r
+ case ICLocation.CUSTOM_MOD:\r
+ case ICLocation.EMERGNECY_MOD:\r
+ case ICLocation.REALTIME_MOD:\r
+ //GPS 定位模式不关闭GPS,防止 1分钟定位超时后,重新关闭开启GPS。\r
+ //不给GPS继续定位的机会,造成第一次定位困难!\r
+ break;\r
+ case ICLocation.LOWPOWER_MOD:\r
+ case ICLocation.NORMAL_MOD:\r
+ default:\r
+ ICLogger.i("非GPS定位模式,关闭GPS");\r
+ //非GPS定位模式的话,需要关闭GPS。\r
+ stopListen();\r
+ break;\r
+ }\r
+\r
}\r
}\r
public NMEAListener(LocationManager paramLocationManager, Runtime paramRuntime) {\r
String usedStarts=tmplist[7];\r
String hdop=tmplist[8];\r
if ( (fixed.trim().equals("1"))||(fixed.trim().equals("2"))||(fixed.trim().equals("6"))){\r
+\r
+\r
+ // 转换GPS坐标为度,以便在各种应用中可以方便查找。\r
+ latitude=Double.valueOf(Lat);\r
+ longitude=Double.valueOf(lon);\r
+ // 转换单位,从分转换到度\r
+\r
+ double intdu= (int)(longitude /100f); //小数转换到分为单位\r
+ double du=(longitude - intdu*100)/60f;\r
+ double last= intdu+du;\r
+ longitude =last;\r
+ intdu= (int)(latitude /100f); //小数转换到分为单位\r
+ du=(latitude - intdu*100)/60f;\r
+ last= intdu+du;\r
+ latitude=last;\r
+\r
+ // 经纬度 保留4位小数点\r
+ DecimalFormat df = new DecimalFormat("#.000000");\r
+ String strLatitude = df.format(latitude);\r
+ String strLongitude = df.format(longitude);\r
+\r
//定位\r
StringBuilder sb=new StringBuilder();\r
- sb.append("GPGGA, location time= " + TimeUtil.getLocalTime() + ", FixedCount=" + locationFixedCount + ", GPSTime="+utctime+", Lat="+Lat+", Lon="+lon+", fixed="+fixed+", hdop="+hdop+", usedStarts="+usedStarts);\r
+ sb.append("GPGGA, location time= " + TimeUtil.getLocalTime() + ", FixedCount=" + locationFixedCount + ", GPSTime="+utctime+", Lat="+Lat+" ("+strLatitude+"), Lon="+lon+" ("+strLongitude+"), fixed="+fixed+", hdop="+hdop+", usedStarts="+usedStarts);\r
ICLogger.i(sb.toString());\r
if (Config.LOG_TOFILE)\r
FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb.toString());\r
只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。\r
延迟MaxFixedTimes秒后才设置runtime的定位标志,以便稳定坐标值。\r
*/\r
-\r
- //log msg变量\r
- StringBuffer sb2 = new StringBuffer();\r
- sb2.append(" gps lat=").append(Lat).append(", gps lon=").append(lon);\r
-\r
- latitude=Double.valueOf(Lat);\r
- longitude=Double.valueOf(lon);\r
- // 转换单位,从分转换到度\r
-\r
- double intdu= (int)(longitude /100f); //小数转换到分为单位\r
- double du=(longitude - intdu*100)/60f;\r
- double last= intdu+du;\r
- longitude =last;\r
- intdu= (int)(latitude /100f); //小数转换到分为单位\r
- du=(latitude - intdu*100)/60f;\r
- last= intdu+du;\r
- latitude=last;\r
-\r
- // 经纬度 保留4位小数点\r
- DecimalFormat df = new DecimalFormat("#.000000");\r
- String strLatitude = df.format(latitude);\r
- String strLongitude = df.format(longitude);\r
- sb2.append(" real lat=").append(strLatitude).append(" lon=").append(strLongitude);\r
- ICLogger.i(sb2.toString());\r
-\r
runtime.getLocationInstance().setLocation(Lat,lon);\r
runtime.getLocationInstance().setUsedStarts(Integer.valueOf(usedStarts.trim()));\r
runtime.getLocationInstance().setHod(Float.valueOf(hdop.trim()));\r