|
@@ -32,6 +32,7 @@ import com.wdkl.callingbed2.util.DownloadUtil;
|
|
import com.wdkl.callingbed2.util.LogUtil;
|
|
import com.wdkl.callingbed2.util.LogUtil;
|
|
import com.wdkl.callingbed2.util.NetUtil;
|
|
import com.wdkl.callingbed2.util.NetUtil;
|
|
import com.wdkl.callingbed2.util.ScreenManagerUtil;
|
|
import com.wdkl.callingbed2.util.ScreenManagerUtil;
|
|
|
|
+import com.wdkl.callingbed2.util.SharedPreferencesUtil;
|
|
import com.wdkl.callingbed2.util.StringUtils;
|
|
import com.wdkl.callingbed2.util.StringUtils;
|
|
import com.wdkl.callingbed2.util.ToastUtil;
|
|
import com.wdkl.callingbed2.util.ToastUtil;
|
|
import com.wdkl.callingbed2.util.UdpSendUtil;
|
|
import com.wdkl.callingbed2.util.UdpSendUtil;
|
|
@@ -196,6 +197,7 @@ public class InitActivity extends BaseActivity implements SerialPortUtil.ISerial
|
|
CallingBedSendCommand.setSipStatus(serialPortUtil, "0");
|
|
CallingBedSendCommand.setSipStatus(serialPortUtil, "0");
|
|
showNetErrorView("MAC地址: " + macAddress + " IP地址: " + ipStr + "\nError:无网络连接;以太网是否连接正常?");//网络信息初始化错误
|
|
showNetErrorView("MAC地址: " + macAddress + " IP地址: " + ipStr + "\nError:无网络连接;以太网是否连接正常?");//网络信息初始化错误
|
|
ToastUtil.showToast("无网络连接;以太网是否连接正常?");//网络信息初始化错误
|
|
ToastUtil.showToast("无网络连接;以太网是否连接正常?");//网络信息初始化错误
|
|
|
|
+
|
|
resetEthernet();
|
|
resetEthernet();
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -273,6 +275,10 @@ public class InitActivity extends BaseActivity implements SerialPortUtil.ISerial
|
|
private void getInitData() {
|
|
private void getInitData() {
|
|
LogUtil.d("getInitData", "URL==" + Constants.URL + Constants.URL_END + Constants.CALLINGBED_INIT);
|
|
LogUtil.d("getInitData", "URL==" + Constants.URL + Constants.URL_END + Constants.CALLINGBED_INIT);
|
|
final String ipStr = NetUtil.getLocalIP();
|
|
final String ipStr = NetUtil.getLocalIP();
|
|
|
|
+ //网络恢复正常,重置重启计数
|
|
|
|
+ if (!TextUtils.isEmpty(ipStr)) {
|
|
|
|
+ SharedPreferencesUtil.putIntSp(context, Constants.REBOOT_COUNT, Constants.REBOOT_COUNT, 0);
|
|
|
|
+ }
|
|
if (Constants.URL.length() > 7) {
|
|
if (Constants.URL.length() > 7) {
|
|
OkHttpUtils
|
|
OkHttpUtils
|
|
.post()
|
|
.post()
|
|
@@ -588,11 +594,22 @@ public class InitActivity extends BaseActivity implements SerialPortUtil.ISerial
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case 222:
|
|
case 222:
|
|
- if (TextUtils.isEmpty(NetUtil.getLocalIP())) {
|
|
|
|
- ToastUtil.showToast("网络异常,设备即将重启!!!");
|
|
|
|
- CallingBedSendCommand.setNetStatus(serialPortUtil, "1");
|
|
|
|
|
|
+ int count = SharedPreferencesUtil.getIntSp(context, Constants.REBOOT_COUNT, Constants.REBOOT_COUNT);
|
|
|
|
+ LogUtil.d("wzlll", "NetReset reboot count: " + count);
|
|
|
|
+ if (count >= 10) {
|
|
|
|
+ ToastUtil.showToast("设备出现异常,请确保网络连接正常或重启设备");
|
|
|
|
+ } else {
|
|
|
|
+ count++;
|
|
|
|
+ SharedPreferencesUtil.putIntSp(context, Constants.REBOOT_COUNT, Constants.REBOOT_COUNT, count);
|
|
|
|
+ ToastUtil.showToast("网络异常,即将重启");
|
|
|
|
+ updateHandler.sendEmptyMessageDelayed(333, 5000);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+ case 333:
|
|
|
|
+ LogUtil.d("wzlll", "NetReset reboot...");
|
|
|
|
+ AutoRebootUtil.reboot(MyApplication.getAppContext());
|
|
|
|
+ CallingBedSendCommand.setNetStatus(serialPortUtil, "1");
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|