//心跳指令默认设置为3分钟\r
AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context,cycle, HEART_ALARM);\r
sb.append(" setHeartAlarm "+HEART_ALARM+", cycle "+cycle);\r
-\r
// locationClient.triggerLocationProcess();\r
ICLogger.i(sb.toString());\r
FileOutputUtil.fileOutput(runtime.getCacheDir(),"HeartAlarm",sb.toString());\r
public void run() {\r
ReConnectToServer();\r
}\r
- }, 0, 20000); //每20秒重试一次\r
+ }, 0, 20000); //每次都是断网才需要重连,所以不需要delay,并且每20秒重试一次\r
}\r
}\r
}\r
\r
private static NettyConnection connection;\r
\r
-\r
- \r
private static boolean isLocationCallBack = false;\r
\r
private static boolean linkOK = false;\r
timeout=false;\r
//延时2秒执行发送“读取定位”消息\r
if (mTimer==null) mTimer=new Timer();\r
- mTimer.schedule(new MyTimerTask(), 0,1000L);\r
+ mTimer.schedule(new MyTimerTask(), 1000L,1000L);\r
}\r
class MyTimerTask extends TimerTask {\r
public void run() {\r
int numberOfSatellites;\r
Runtime runtime;\r
\r
+ private static int MaxFixedTimes=5;\r
+\r
+ private static int locationFixedCount=0;\r
+\r
+\r
\r
public void setNoStop(boolean nostop){\r
noStop=nostop;\r
gpsMode = GPS_CURRENT_STATUS.GPS_FIXED;\r
\r
\r
- delaystop();\r
+ // delaystop();\r
\r
break;\r
case GpsStatus.GPS_EVENT_STARTED:\r
//no start\r
//do nothing\r
\r
- }else if (message.what==MSG_WHAT_GPS_FIXED){\r
+ }\r
+ else if (message.what==MSG_WHAT_GPS_FIXED){\r
//fixed\r
/*\r
只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。\r
只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。\r
延迟三秒后才设置runtime的定位标志,以便稳定坐标值。\r
*/\r
- if (location != null && gpsMode == GPS_CURRENT_STATUS.GPS_FIXED ) {\r
+// if (location != null && gpsMode == GPS_CURRENT_STATUS.GPS_FIXED ) {\r
+ if (location != null ) {\r
longitude = location.getLongitude();\r
latitude = location.getLatitude();\r
\r
strLatitude = df.format(latitude);\r
strLongitude = df.format(longitude);\r
\r
+ locationFixedCount++;\r
\r
- sb.append(", gps time "+TimeUtil.getLocalTime(gpsTime)+" lon " + strLongitude + " lat " + strLatitude +" TimeToFirstFix "+status.getTimeToFirstFix());\r
-\r
+ sb.append(", gps time= "+TimeUtil.getLocalTime(gpsTime)+" ,lon= " + strLongitude + ", lat= " + strLatitude +" FixedCount="+locationFixedCount+", TimeToFirstFix="+status.getTimeToFirstFix());\r
ICLogger.i( sb.toString());\r
-\r
if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS",sb.toString());\r
runtime.getLocationInstance().setLocation(latitude,longitude,speed,0,status.getMaxSatellites());\r
- if (noStop){//如果是不停止gps,那么每次确认定位的数据都设置标志位,以便其他线程能及时更新数据\r
+ if (locationFixedCount > MaxFixedTimes ){\r
+ /*\r
+ 只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。\r
+ 延迟MaxFixedTimes秒后才设置runtime的定位标志,以便稳定坐标值。\r
+ */\r
runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_FIXED);\r
+ if(!noStop){\r
+ stopListen();\r
+ }\r
}\r
}\r
\r
longitude = 0;\r
latitude = 0;\r
searchCout = 0;\r
+ locationFixedCount=0;\r
gpsMode = GPS_CURRENT_STATUS.GPS_LISTENING;\r
locationManager.addGpsStatusListener(statusListener);//监听搜星状态\r
// this.locationManager.addNmeaListener(this);\r
@Override\r
public boolean handleMessage(Message message) {\r
\r
- switch (message.what){\r
- case 1:\r
- mSendMSGHandler.post(delaySendMSG);\r
- break;\r
- default:\r
- break;\r
- }\r
+// switch (message.what){\r
+// case 1:\r
+// mSendMSGHandler.post(delaySendMSG);\r
+// break;\r
+// default:\r
+// break;\r
+// }\r
return false;\r
}\r
});\r
// }\r
// }\r
if (getAndSendMsgFromQueue()==true){\r
- mSendMSGHandler.postDelayed(delaySendMSG,5000);\r
+ mSendMSGHandler.postDelayed(delaySendMSG,5000L);\r
}\r
// sendingMsg=false;\r
// ICLogger.i("exit delaySendMSG!");\r
return ret;\r
}\r
public static void triggerSendThread() {\r
-\r
- mSendMSGHandler.sendEmptyMessage(1);\r
+ mSendMSGHandler.post(delaySendMSG);\r
+// mSendMSGHandler.sendEmptyMessage(1);\r
}\r
\r
public static boolean getAndSendMsgFromQueue(){\r
str = "no message!\n";\r
}\r
ICLogger.i("send cached cmd : \n"+str);\r
- ICLogger.i("\n"+queue.size()+" in Queue!");\r
+ ICLogger.i("\n"+queue.size()+" left in Queue!");\r
}finally {\r
if(mLock!=null && mLock.isLocked())\r
mLock.unlock();\r
if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(), "APILog", " queueFullskip " + Msg);\r
\r
}\r
- triggerSendThread();\r
+\r
+// if(queue.size()>5) //测试queue 发送逻辑用\r
+ triggerSendThread();\r
\r
}else {\r
if (checkNetwork()) {\r
public void run() {\r
checkSrvResponse();\r
}\r
- }, 0, heartBeatRetryTimeout*1000); //每5秒重试一次\r
+ }, 3*1000, heartBeatRetryTimeout*1000); //delay 3秒先检查一次,然后每5秒重试一次\r
}\r
}\r
}\r
.append(DeviceInfoUtil.getVersionCode(runtime.getContextProxy().context))\r
.append(SimSignalUtil.hasSimCard(runtime.getContextProxy().context)?" SIM ":" NoSIM ")\r
.append(sim.getNetworkType()==SimSignalUtil.IS_2G?"2G":(sim.getNetworkType()==SimSignalUtil.IS_3G)?"3G":(sim.getNetworkType()==SimSignalUtil.IS_4G?"4G":"unknown"))\r
- .append(" [").append(runtime.getSignalStrength()).append(",Mini:").append(SimSignalUtil.getMinSignalStrength(sim.getNetworkType())).append("]")\r
+ .append(" [").append(runtime.getSignalStrength()).append(",Mini:").append(SimSignalUtil.getMinSignalStrength(sim.getNetworkType())).append("] ")\r
+ .append(runtime.IMEI())\r
.append("\n SocketConnection ").append(KeepAlive.isConnected).append(" , HBcycle ").append(runtime.getHeartBeatCycle())\r
.append("\n ServerConnected is ").append(runtime.isServerProtocolConnected())\r
.append(" \n Bat ").append(runtime.getBattery()).append(",").append(runtime.getBatteryVotage())\r
-#Fri Mar 06 15:30:32 CST 2020\r
-VERSION_CODE=371\r
+#Mon Mar 09 17:32:36 CST 2020\r
+VERSION_CODE=372\r