profile,//情景模式
SOSON,//w100SOS 报警开关
IP,//配置服务器地址
+ SOSREC,//服务器响应S0S消息
}
public static HashMap<CMD_TYPE, String> cmdMap = null;
public void handleHrtstart(Connection connection, Runtime runtime, String cmd, String data) {
//[IC*334588000000156*len*hrtstart,x]
- // x 为上传间隔时间,单位秒,连续上传时最小时间不小于 300 秒,最大不超过 65535.
+ // x 为上传间隔时间,单位秒,连续上传时最小时间不小于 300 秒,最大不超过 65535.
// 实例:[IC*334588000000156*len*hrtstart,300]
//终端会每隔 300 秒检测一次心率
//
//x 为 1 则代表终端心率单次上传,上传完后自动关闭。x 为 0 则代表终端心率上传关闭。
- int testcycle=0;
- try{
- testcycle=Integer.parseInt(data);
- }catch (Exception e){
+ int testcycle = 0;
+ try {
+ testcycle = Integer.parseInt(data);
+ } catch (Exception e) {
ICLogger.e(e.getMessage());
- testcycle=0;
+ testcycle = 0;
ICLogger.i("Hrtstart format error!");
return;
}
connection.send(hrtstart());
- if(testcycle>=0 && testcycle<65535) {
- ICLogger.i("收到服务器指令:设置心率周期 " + testcycle + "秒 相当于 "+testcycle/60 +"分钟" );
+ if (testcycle >= 0 && testcycle < 65535) {
+ ICLogger.i("收到服务器指令:设置心率周期 " + testcycle + "秒 相当于 " + testcycle / 60 + "分钟");
try {
//发送重置PPGCycle的广播,会在CoreServer里面执行
- CoreService.getInstance().setHeartRateDetectAlarm(testcycle/60);
+ CoreService.getInstance().setHeartRateDetectAlarm(testcycle / 60);
} catch (Exception e) {
ICLogger.e(e.getMessage(), e);
}
- }else{
- ICLogger.i("收到服务器指令:设置心率周期超限[0~65535] " + testcycle + "秒 相当于 "+testcycle/60 +"分钟" );
+ } else {
+ ICLogger.i("收到服务器指令:设置心率周期超限[0~65535] " + testcycle + "秒 相当于 " + testcycle / 60 + "分钟");
}
}
// 实例:[IC*334588000000156*0002*IP]
// 说明:设置服务器地址和端口
- String[] cmdlist=data.split(CMD_SPLIT);
- if(cmdlist.length==2) {
+ String[] cmdlist = data.split(CMD_SPLIT);
+ if (cmdlist.length == 2) {
connection.send(IP());
- try {
- String ip = cmdlist[0];
- int port = Integer.valueOf(cmdlist[1].replace("#", ""));
- Config.setCustomServer(runtime.getContextProxy().context, true, ip, port);
- Config.loadServerSettings(runtime);
- CoreService.getInstance().disconnect_server();
- CoreService.getInstance().ReConnectToServer();
- }catch (Exception e){
- ICLogger.e(e.getMessage(),e);
- }
- }else{
+ try {
+ String ip = cmdlist[0];
+ int port = Integer.valueOf(cmdlist[1].replace("#", ""));
+ Config.setCustomServer(runtime.getContextProxy().context, true, ip, port);
+ Config.loadServerSettings(runtime);
+ CoreService.getInstance().disconnect_server();
+ CoreService.getInstance().ReConnectToServer();
+ } catch (Exception e) {
+ ICLogger.e(e.getMessage(), e);
+ }
+ } else {
ICLogger.i("IP format error!");
}
case hrtstart:
ICLogger.i("收到服务器心率检测命令");
Config.testType = HeartRateOxygenTestType.JUST_HEART_RATE;
- handleHrtstart(mConnection,mRuntime,cmd,data);
+ handleHrtstart(mConnection, mRuntime, cmd, data);
break;
case bldstart:
handleBldstart(mConnection);
break;
case SOSON:
ICLogger.d("收到服务器设置的SOS开发消息..");
- handleSOSON(cmd,data,mRuntime,mConnection);
+ handleSOSON(cmd, data, mRuntime, mConnection);
break;
case IP:
//设置服务器IP
- ICLogger.d("设置服务器 IP 为 "+data);
- handleIP(mConnection, mRuntime, cmd,data);
+ ICLogger.d("设置服务器IP为 " + data);
+ handleIP(mConnection, mRuntime, cmd, data);
+ break;
+ case SOSREC:
+ ICLogger.d("服务器收到SOS消息...");
+ mConnection.DeliverCMDMessageToSystem("sosReceive", cmd);
break;
}
return ret;
private static final String BOOT_OFF_ACTION_OFF = "0";
private static final String BOOT_OFF_ACTION_ON = "1";
private static final long ONE_DAY = 86400000L;
+
public static StringMessage SOSON() {
return genFZDCMD(cmdMap.get(CMD_TYPE.SOSON));
}
- private void handleSOSON(String cmd, String data, Runtime mRuntime,Connection connection) {
+ private void handleSOSON(String cmd, String data, Runtime mRuntime, Connection connection) {
connection.send(SOSON());
handleSettings(CMD_TYPE.SOSON, data, mRuntime);
}
+
/**
* 设置开关机时间
* <p>
--- /dev/null
+package com.ic.view;
+
+import android.content.Context;
+import android.view.Gravity;
+import android.view.View;
+import android.view.WindowManager;
+
+import com.ic.protocolSrv.ICApplication;
+import com.ic.protocolSrv.R;
+import com.ic.protocolSrv.utils.ICLogger;
+
+public class SOSRecView {
+
+ private WindowManager windowManager;
+
+ private static SOSRecView sInstance;
+ private boolean isShow;
+ private View view;
+
+ public static SOSRecView getInstance() {
+ if (sInstance == null) {
+ sInstance = new SOSRecView();
+ }
+ return sInstance;
+ }
+
+ public void showMsgDialog() {
+ ICLogger.d("showMsgDialog..." + isShow);
+ if (isShow) {
+ return;
+ }
+ isShow = true;
+ Context context = ICApplication.sContext;
+ windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ //设置属性
+ WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
+ layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
+ //这个是针对S123的屏幕,如果要适配其他,可以动态获取屏幕宽度,高度,再以百分比的形式计算即可。
+ layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
+ layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
+ layoutParams.packageName = context.getPackageName();
+ layoutParams.gravity = Gravity.CENTER;
+ //加载布局
+ view = View.inflate(context, R.layout.find_device_layout, null);
+ windowManager.addView(view, layoutParams);
+ }
+
+ public void dismiss() {
+ windowManager.removeView(view);
+ sInstance = null;
+ windowManager = null;
+ }
+}