Logger.d(“mqtt 开启在线监控”);
subscribe = Observable.interval(5, TimeUnit.MINUTES).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer() {
public final void accept(Long code) {
long reboottime = SystemInfo.getSerial_port_temperaturetest(BaseApplication.getApplication());
Log.e("===","mqtt 在线监控 " + reboottime);
if(!MqttUtil.getInstance(BaseApplication.getApplication()).isConnect()&& Util.hasNetwork(MqttWrapService.this)){
isStart = true;
MqttWrapService.reStart(BaseApplication.getApplication());
}
if(System.currentTimeMillis() > reboottime && reboottime > 0){
mDeviceManager.reboot();
}
boolean isrunningReadCard = isServiceRunning(MqttWrapService.this, “net.bunnytouch.bunnydaemon.service.ReadCardService”);
DoorSetData doorSetData = getDoorSetData(BaseApplication.getApplication());
if (!isrunningReadCard && (doorSetData.getOneSort() != 0 || doorSetData.getTwoSort() != 0)) {
Intent startSrv = new Intent(MqttWrapService.this, ReadCardService.class);
try {
//MqttWrapService.this.stopService(startSrv);
MqttWrapService.this.startService(startSrv);
} catch (IllegalStateException e) {
}
}
//WindowTouchService.judgeNormallyOpenDoor(BaseApplication.getApplication());
//接收到消息记录一次时间复制全局
//datatime = System.currentTimeMillis();
//if(System.currentTimeMillis() - datatime > 20000){
//重启
//}
}
});
看门狗类似,喂狗
最新推荐文章于 2024-01-13 23:11:12 发布