From: snickersun Date: Mon, 12 Oct 2020 06:21:48 +0000 (+0800) Subject: release V640 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=25e8eac2f81055c0ddb8836ee3db83f5f0c3573f;p=protocol_srv.git release V640 1、优化电量报警检测,在亮屏,心跳中增加了电量检测,防止漏报 2、温度测量结果 广播给launcher作为提示保存 3、服务器链接状态保存到persist.sys.server_connected中,给launcher显示使用 4、给protocol_ic添加BP87 二维码更新,APTQ 天气更新命令。 5、优化蓝牙搜索判定,解决重复记录问题。 6、蓝牙搜索后强制关闭蓝牙,解决功耗问题。 --- diff --git a/app/app.iml b/app/app.iml index 10a51020..e442bebb 100644 --- a/app/app.iml +++ b/app/app.iml @@ -29,15 +29,15 @@ - - + + - + diff --git a/app/release/ICSer_V638_2009281042_release.apk b/app/release/ICSer_V642_2010121415_release.apk similarity index 78% rename from app/release/ICSer_V638_2009281042_release.apk rename to app/release/ICSer_V642_2010121415_release.apk index 216e34bf..c5477838 100644 Binary files a/app/release/ICSer_V638_2009281042_release.apk and b/app/release/ICSer_V642_2010121415_release.apk differ diff --git a/app/release/output.json b/app/release/output.json index 20e02ad2..36e24eaa 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":638,"versionName":"2009281042","enabled":true,"outputFile":"ICSer_V638_2009281042_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V638_2009281042_release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":642,"versionName":"2010121415","enabled":true,"outputFile":"ICSer_V642_2010121415_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V642_2010121415_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/enqualcomm/support/Config.java b/app/src/main/java/com/enqualcomm/support/Config.java index a4045492..4867d9e8 100644 --- a/app/src/main/java/com/enqualcomm/support/Config.java +++ b/app/src/main/java/com/enqualcomm/support/Config.java @@ -1,7 +1,6 @@ package com.enqualcomm.support; import android.content.Context; -import android.content.SharedPreferences; import android.provider.Settings; import android.text.TextUtils; @@ -13,18 +12,12 @@ import com.enqualcomm.support.utils.TimeUtil; import com.enqualcomm.support.utils.Util; import com.ic.jni.ICJniUtils; import com.ic.protocols.protocolAPIHelper; -import com.sina.util.dnscache.log.FileUtil; import org.json.JSONException; import org.json.JSONStringer; -import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import static com.enqualcomm.support.utils.Util.connectWifiByReflectMethod; import static com.enqualcomm.support.utils.Util.getSystemProperties; public class Config { @@ -36,12 +29,8 @@ public class Config { public static int sw_release_no = -1; public static int bleScanTimeout=10; public static boolean forceMoveCheck=true; - public static String work_mode = "2@1"; + public static boolean forceWearCheck=true; - public static final String JiAiHost="watch.jiai.pro"; - public static final int JiAiPort=8090; - public static final String BeehomeHost="device.beehome360.com"; - public static final int BeehomePort=5111; public static final String DefaultLogFtpServer="icfota.snicker.com.cn"; public static final String DefaultLogFtpUser="ftpuser"; @@ -111,6 +100,8 @@ public class Config { final static String KeySOSNumbersList="SOSNumbersList"; final static String KeyIMEI = "persist.sys.protocol_IMEI"; + public final static String KeyQRURIFILE = "persist.sys.qrUriFile"; + final static String KeyPractiseState = "persist.sys.practising"; final static String KeyHeartBeatCycle="ServerHeartBeatCycle"; diff --git a/app/src/main/java/com/enqualcomm/support/Constants.java b/app/src/main/java/com/enqualcomm/support/Constants.java index 72862202..78422134 100644 --- a/app/src/main/java/com/enqualcomm/support/Constants.java +++ b/app/src/main/java/com/enqualcomm/support/Constants.java @@ -287,6 +287,10 @@ public interface Constants { public static final String WEATHER_ALARM = "com.ic.alarm.ACTION_WEATHER_ALARM"; public static final String WEATHER_ACTION = "com.ic.action.ACTION_GET_WEATHER"; + public static final String ACTION_QUERY_WEATHER = "com.ic.action_query_weather"; + public static final String ACTION_WEATHER_RECEIVED = "com.ic.action_weather_recveived"; + public static final String KEY_Weather = "weather"; + public static final int WIFI_SET_RESULT = 217; diff --git a/app/src/main/java/com/enqualcomm/support/CoreService.java b/app/src/main/java/com/enqualcomm/support/CoreService.java index 53ab5a2d..1a327e4b 100644 --- a/app/src/main/java/com/enqualcomm/support/CoreService.java +++ b/app/src/main/java/com/enqualcomm/support/CoreService.java @@ -352,6 +352,8 @@ public class CoreService extends Service { var3.append("screen on wake is_wifi_network_ok="); var3.append(CoreService.is_wifi_network_ok); ICLogger.i(var3.toString()); + //检测电池电量 并上报低电报警 + batteryUtil.getBatteryLevel(param1Context); if (CoreService.is_in_sleep_mode) { /*屏幕亮起时,如果在sleep模式(夜晚的那个睡眠模式,非系统休眠,暂时没实现,还不会跑到这里),则唤醒各个进程*/ @@ -1137,6 +1139,8 @@ public class CoreService extends Service { // ICLogger.i(""); // } } + //检测电池电量 并上报低电报警 + batteryUtil.getBatteryLevel(this); setHeartAlarm(); if (Config.LOG_TOFILE) ICLogger.logToFile("alarmCycle", "HEART_ALARM alarmCycle "); @@ -1173,7 +1177,6 @@ public class CoreService extends Service { } } - this.invokeHandlerServiceChain.processUserRequest(paramIntent, this.connection, this.runtime); } diff --git a/app/src/main/java/com/enqualcomm/support/adapter/BTHelper.java b/app/src/main/java/com/enqualcomm/support/adapter/BTHelper.java index 19c96d9c..931ee116 100644 --- a/app/src/main/java/com/enqualcomm/support/adapter/BTHelper.java +++ b/app/src/main/java/com/enqualcomm/support/adapter/BTHelper.java @@ -18,8 +18,8 @@ import java.util.Set; public class BTHelper { private BluetoothAdapter mBtAdapter; - private ArrayList mPairedDevicesArray=new ArrayList<>(); - private ArrayList mNewDevicesArray=new ArrayList<>(); + private static ArrayList mPairedDevicesArray=new ArrayList<>(); + private static ArrayList mNewDevicesArray=new ArrayList<>(); private Context mContext=null; private BTScanCallback mCallback=null; private static BTHelper mBThelper=null; @@ -191,7 +191,14 @@ public class BTHelper { public void onLeScan(BluetoothDevice bluetoothDevice, int rssi, byte[] scanRecode) { // ICLogger.i( "BT onLeScan "+bluetoothDevice.getName()+" "+bluetoothDevice.getAddress()+" rssi "+rssi); // ICLogger.logToFile("LBS","BT onLeScan "+bluetoothDevice.getName()+" "+bluetoothDevice.getAddress()+" rssi "+rssi ); - if(!mNewDevicesArray.contains(bluetoothDevice.getAddress())) + boolean found=false; + for (String dev: mNewDevicesArray){ + if (dev.contains(bluetoothDevice.getAddress())) { + found = true; + break; + } + } + if(!found) mNewDevicesArray.add(bluetoothDevice.getAddress()+","+rssi); } }; @@ -203,11 +210,11 @@ public class BTHelper { new Handler().postDelayed(new Runnable() { @Override public void run() { - mBtAdapter.stopLeScan(lecallback); ICLogger.i("BT stopLeScan"); + mBtAdapter.stopLeScan(lecallback); //开始扫描前是关闭的,就关闭它 - if(!enabledBeforScan) +// if(!enabledBeforScan) disableBT(); if (mCallback!=null) diff --git a/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java b/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java index 16c4f622..d74bc21d 100644 --- a/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java +++ b/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java @@ -98,6 +98,8 @@ public class KeepAlive extends AbstractConnectionService { ICLogger.i("checkSrvResponse 成功,停止检测!"); stopResponseCheckTimer(); }else{ + //心跳发送失败,则认为已经和服务器断开 + mRuntime.setServerProtocolConnected(false); //如果重试次数大于等于 最大重试次数,则停止重试,等下次心跳时间再行尝试。 if (hearBeatResendCount >= MaxHeartbeatResendTime){ ICLogger.i("checkSrvResponse "+hearBeatResendCount+"次 >= "+MaxHeartbeatResendTime+" , 则停止重试,等下次心跳时间再行尝试!"); diff --git a/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java b/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java index c49776e6..6c03f9b2 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java @@ -93,14 +93,7 @@ public class BatteryUtil { if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","BatteryLow less than 15%!"); - //没有充电,上次电池level > 15% , 上次电池并且不是 低电状态,则报警 - if (mRuntime.isPowerConnected()==false && mRuntime.getBatterylevel()<15 && mRuntime.getBatteryLow()==false) { - send_batterylow_event_broadcast(param1Context, 1); - play_waning_notify(param1Context); - mRuntime.setAlarmType(Runtime.AlarmType.ALARM_LOWBATTERY); - //trigger AP10 报警定位 - Deliver.sendLocationMSG(protocolAPIHelper.getWarningMSG(mRuntime)); - } + checkAndSendBatteryEvent(param1Context,mRuntime); mRuntime.setBattery(String.format("%03d",batLevel)); mRuntime.setBattery(batLevel); mRuntime.setHaveBatteryChange(true); @@ -108,16 +101,7 @@ public class BatteryUtil { } else { if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","BatteryLow less than 5% !"); - //没有充电,上次电池level > 15% , 上次电池并且不是 电池低电状态,则报警 - if (mRuntime.isPowerConnected()==false && mRuntime.getBatterylevel()< 5 ) { - send_batterylow_event_broadcast(param1Context, 1); - - play_waning_notify(param1Context); - mRuntime.setAlarmType(Runtime.AlarmType.ALARM_LOWBATTERY); - //trigger AP10 报警定位 - Deliver.sendLocationMSG( protocolAPIHelper.getWarningMSG(mRuntime)); - - } + checkAndSendBatteryEvent(param1Context,mRuntime); mRuntime.setBattery(String.format("%03d",batLevel)); mRuntime.setBattery(batLevel); mRuntime.setHaveBatteryChange(true); @@ -157,9 +141,34 @@ public class BatteryUtil { private Handler mHandler=null; PowerManager.WakeLock mWakeLock = null; - private void play_waning_notify(Context context){ + private static void play_waning_notify(Context context){ AudioService.getInstance().play(context.getAssets(), "warning.mp3"); } + + public static void checkAndSendBatteryEvent(Context context, Runtime runtime){ + + //没有充电,上次电池level > 15% , 上次电池并且不是 低电状态,则报警 + if (runtime.isPowerConnected()==false && runtime.getBatterylevel()<15 && runtime.getBatteryLow()==false) { + Intent intent=new Intent(); + intent.setAction(ACTION_BATTERYLOW); + intent.putExtra(KEY_BATTERY_EVENT,1); + context.sendBroadcast(intent); + play_waning_notify(context); + runtime.setAlarmType(Runtime.AlarmType.ALARM_LOWBATTERY); + //trigger AP10 报警定位 + Deliver.sendLocationMSG(protocolAPIHelper.getWarningMSG(runtime)); + }else if (runtime.isPowerConnected()==false && runtime.getBatterylevel()< 5 ) { + //没有充电,上次电池level > 15% , 上次电池并且不是 电池低电状态,则报警 + Intent intent=new Intent(); + intent.setAction(ACTION_BATTERYLOW); + intent.putExtra(KEY_BATTERY_EVENT,1); + context.sendBroadcast(intent); + play_waning_notify(context); + runtime.setAlarmType(Runtime.AlarmType.ALARM_LOWBATTERY); + //trigger AP10 报警定位 + Deliver.sendLocationMSG( protocolAPIHelper.getWarningMSG(runtime)); + } + } private void send_batterylow_event_broadcast(Context context,int batlow){ mHandler.post(new Runnable() { @Override @@ -210,15 +219,34 @@ public class BatteryUtil { (this.mRuntime.getContextProxy()).context.registerReceiver(this.batteryChangedReceiver, intentFilter); } - public int getBatteryLevel(Context context){ + public int getBatteryLevel(Context context) { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // BatteryManager batteryManager = (BatteryManager)context.getSystemService(BATTERY_SERVICE); // return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY); // } else { - Intent intent = new ContextWrapper(context.getApplicationContext()).registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); - return (intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) * 100) / - intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); -// } + Intent intent = new ContextWrapper(context.getApplicationContext()).registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); + int batLevel = (intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) * 100) / + intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); + + if( batLevel>=15) { + + + }else if (batLevel<15 && batLevel >= 5) { + if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","BatteryLow less than 15%!"); + checkAndSendBatteryEvent(context,mRuntime); + mRuntime.setBattery(String.format("%03d",batLevel)); + mRuntime.setBattery(batLevel); + mRuntime.setHaveBatteryChange(true); + mRuntime.setBatteryLow(true); + } else { + if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","BatteryLow less than 5% !"); + checkAndSendBatteryEvent(context,mRuntime); + mRuntime.setBattery(String.format("%03d",batLevel)); + mRuntime.setBattery(batLevel); + mRuntime.setHaveBatteryChange(true); + mRuntime.setBatteryLow(true); + } + return batLevel; } diff --git a/app/src/main/java/com/enqualcomm/support/utils/ContextProxy.java b/app/src/main/java/com/enqualcomm/support/utils/ContextProxy.java index 215dab07..c279b074 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/ContextProxy.java +++ b/app/src/main/java/com/enqualcomm/support/utils/ContextProxy.java @@ -346,6 +346,7 @@ public class ContextProxy { Intent intent = new Intent(); intent.setAction(ACTION_ISCONNECTED); intent.putExtra("isConnected", paramBoolean); + Util.setSystemProperties("persist.sys.server_connected",paramBoolean?"true":"false"); this.context.sendBroadcast(intent); } diff --git a/app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java b/app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java index d812954b..2f253a41 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java @@ -231,7 +231,7 @@ public class DeviceInfoUtil { SimSignalUtil sim=SimSignalUtil.getInstance(runtime.getContextProxy().context); double wrist_temp; - wrist_temp=TemperatureUtil.get_temp_value_adjusted(); +// wrist_temp=TemperatureUtil.get_temp_value_adjusted(); return new StringBuilder() .append(TimeUtil.getLocalTime2()).append(" ").append(DeviceInfoUtil.getSWVersionDisplayName()).append("\n") .append(DeviceInfoUtil.getVersionCode(runtime.getContextProxy().context)) @@ -241,7 +241,7 @@ public class DeviceInfoUtil { .append(runtime.IMEI()) .append("\n Srv [P").append(Config.protocol_no).append(" ").append(runtime.getHost()).append(":").append(runtime.getPort()).append("]").append(KeepAlive.isConnected).append(" , HBcycle ").append(runtime.getHeartBeatCycle()) .append("\n ServerConnected is ").append(runtime.isServerProtocolConnected()) - .append(",Temp ").append(String.format("%1$.2f",wrist_temp)).append(",Body ").append(String.format("%1$.2f",TemperatureUtil.getBodyTemp(wrist_temp,26.0f))) +// .append(",Temp ").append(String.format("%1$.2f",wrist_temp)).append(",Body ").append(String.format("%1$.2f",TemperatureUtil.getBodyTemp(wrist_temp,26.0f))) .append(" \n Bat ").append(runtime.getBattery()).append(",").append(runtime.getBatteryVotage()) .append(" charged ").append(runtime.isPowerConnected()) .append(" StepCount ").append(runtime.getTotalStepCount()) @@ -262,7 +262,7 @@ public class DeviceInfoUtil { public static String getShortDeviceInfo(Runtime runtime){ SimSignalUtil sim=SimSignalUtil.getInstance(runtime.getContextProxy().context); - double wrist_temp=TemperatureUtil.get_temp_value_adjusted(); +// double wrist_temp=TemperatureUtil.get_temp_value_adjusted(); return new StringBuilder("Firmware ") .append(DeviceInfoUtil.getSWVersionDisplayName()).append("\nProtocol ") .append(DeviceInfoUtil.getVersionCode(runtime.getContextProxy().context)) @@ -280,12 +280,12 @@ public class DeviceInfoUtil { .append(",T").append(runtime.getLocationInstance().getLocationType()) .append(",").append(runtime.getLocationInstance().getLocationTime()) .append("]\nPPG[C").append(runtime.getPpgTestCycle()) - .append(",P").append(runtime.getHRS().getPPG()) - .append(",H").append(runtime.getHRS().getBPH()) - .append(",L").append(runtime.getHRS().getBPL()) - .append(",T").append(String.format("%1$.2f",wrist_temp)) - .append(",TA").append(String.format("%1$.2f",TemperatureUtil.getBodyTemp(wrist_temp,26.0f))) - .append(",").append(runtime.getHRS().getTestTime()).append("]") +// .append(",P").append(runtime.getHRS().getPPG()) +// .append(",H").append(runtime.getHRS().getBPH()) +// .append(",L").append(runtime.getHRS().getBPL()) +// .append(",T").append(String.format("%1$.2f",wrist_temp)) +// .append(",TA").append(String.format("%1$.2f",TemperatureUtil.getBodyTemp(wrist_temp,26.0f))) +// .append(",").append(runtime.getHRS().getTestTime()).append("]") .toString(); } diff --git a/app/src/main/java/com/enqualcomm/support/utils/TemperatureUtil.java b/app/src/main/java/com/enqualcomm/support/utils/TemperatureUtil.java index 42e743d9..d2be579a 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/TemperatureUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/TemperatureUtil.java @@ -59,6 +59,17 @@ public class TemperatureUtil { },500); } + public static final String ACTION_TEMP_RESULT = "com.ic.action.temp_result"; + public static final String KEY_TEMP_BODY = "body"; // double 体温 + public static final String KEY_TEMP_WRIST = "wrist"; // double 腕温 + private static void sendTempBroadcast(double value, double animal) { + Intent pedIntent = new Intent(); + pedIntent.setAction(ACTION_TEMP_RESULT); + pedIntent.putExtra(KEY_TEMP_WRIST, value); + pedIntent.putExtra(KEY_TEMP_BODY, animal); + if(CoreService.getInstance()!=null) + CoreService.getInstance().sendBroadcast(pedIntent); + } public static void DoTempTest(){ if (ICJniUtils.isTemperatureDevAvailable() >ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal()) { @@ -99,6 +110,10 @@ public class TemperatureUtil { Runtime runtime = CoreService.getInstance().getRuntime(); runtime.tempInfo.setTemp(body_temp, wrist_temp); + + //发送消息给launcher显示 + sendTempBroadcast(wrist_temp,body_temp); + ICJniUtils.disableTemperature(); //体温异常报警检测开启的会进行异常报警 diff --git a/app/src/main/java/com/enqualcomm/support/utils/mqttConnection.java b/app/src/main/java/com/enqualcomm/support/utils/mqttConnection.java index 84fbbc8b..b8d4d781 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/mqttConnection.java +++ b/app/src/main/java/com/enqualcomm/support/utils/mqttConnection.java @@ -19,7 +19,7 @@ public class mqttConnection implements Connection { mqtt_client.setSubscriptTopicHeader(topic_header); mqtt_client.attemptSubscribeToTopic(topic_header+"+"); isServerconnected=true; - mRuntime.setServerProtocolConnected(true); +// mRuntime.setServerProtocolConnected(true); if (listener!=null) listener.onConnectionOpen(); diff --git a/app/src/main/java/com/ic/protocols/protocol_ic.java b/app/src/main/java/com/ic/protocols/protocol_ic.java index fca7a5c1..677e3571 100644 --- a/app/src/main/java/com/ic/protocols/protocol_ic.java +++ b/app/src/main/java/com/ic/protocols/protocol_ic.java @@ -8,6 +8,7 @@ import android.os.Environment; import android.os.Handler; import com.enqualcomm.support.Config; +import com.enqualcomm.support.Constants; import com.enqualcomm.support.CoreService; import com.enqualcomm.support.R; import com.enqualcomm.support.bean.Alarm; @@ -28,9 +29,11 @@ import com.enqualcomm.support.utils.Util; import com.enqualcomm.support.utils.WakeLockUtil; import java.io.File; +import java.io.FileOutputStream; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.Locale; import static com.enqualcomm.support.Constants.ACTION_HEATR_RATE_START; import static com.enqualcomm.support.Constants.ACTION_REMOTE_CAMERA; @@ -111,6 +114,8 @@ public class protocol_ic { BP85,//设置闹钟 AP86, BP86,//绑定解绑 + AP87, + BP87,//二维码更新 AP88, BP88,//查找手表 AP89, @@ -139,6 +144,8 @@ public class protocol_ic { BPDH, AP99,//监听电话 BP99, + APTQ,//天气 + BPTQ, UNKNOWN_CMD, } @@ -209,6 +216,8 @@ public class protocol_ic { cmdMap.put(CMD_TYPE.BP85, "BP85"); cmdMap.put(CMD_TYPE.AP86, "AP86"); cmdMap.put(CMD_TYPE.BP86, "BP86"); + cmdMap.put(CMD_TYPE.AP87, "AP87"); + cmdMap.put(CMD_TYPE.BP87, "BP87"); cmdMap.put(CMD_TYPE.AP88, "AP88"); cmdMap.put(CMD_TYPE.BP88, "BP88"); cmdMap.put(CMD_TYPE.AP89, "AP89"); @@ -237,6 +246,8 @@ public class protocol_ic { cmdMap.put(CMD_TYPE.BPDH, "BPDH"); cmdMap.put(CMD_TYPE.AP99, "AP99"); cmdMap.put(CMD_TYPE.BP99, "BP99"); + cmdMap.put(CMD_TYPE.APTQ, "APTQ"); + cmdMap.put(CMD_TYPE.BPTQ, "BPTQ"); } @@ -1367,7 +1378,7 @@ public class protocol_ic { try { Config.setLocationMode(runtime.getContextProxy().context, ICLocation.CUSTOM_MOD8_GPS); - Config.setLocationCycle(runtime.getContextProxy().context, Integer.parseInt(time) * 60); + Config.setLocationCycle(runtime.getContextProxy().context, Integer.parseInt(time) ); runtime.getLocationInstance().setWorkingMod(Config.getLocationMode(runtime.getContextProxy().context)); runtime.getLocationInstance().setLocation_cycle(Config.getLocationCycle(runtime.getContextProxy().context)); //set AlarmCycle and trigger Location @@ -1599,6 +1610,9 @@ public class protocol_ic { } } + + + //17.设置心率/血压测量周期(下行协议号:BP86,响应:AP86) public static StringMessage AP86(String index){ @@ -1642,6 +1656,40 @@ public class protocol_ic { ICLogger.i("BP86 format error!"); } + } + + //IWBP87,http://cn.map20000.com/physicalReport.html?lang=zh-CN&imeis=866671044898063# + public static StringMessage AP87(){ + + //设备响应: IWAP86, 080835# + //080835:指令流水号 + return genStringMessage("AP87",new StringBuffer(CMDHEADER).append(cmdMap.get(CMD_TYPE.AP87)) + .append(CMDEND).toString()); + } + + public void handleBP87(String cmd,Connection connection,Runtime runtime){ + + //IWBP87,http://cn.map20000.com/physicalReport.html?lang=zh-CN&imeis=866671044898063# + + String[] list=cmd.split(CMDSPLIT); + + if (list.length==2){ + String furl=list[1];//.replace("#",""); + ICLogger.i("收到服务器指令 BP87:Qrcode url "+furl); +// connection.send(AP87()); + try { + String qrfilepath=Util.getLogfilePath(runtime,TimeUtil.getSystemDateYYMMDD()); + Util.setSystemProperties(Config.KeyQRURIFILE,qrfilepath); + FileOutputStream fos=new FileOutputStream(new File(qrfilepath)); + fos.write(furl.getBytes()); + fos.close(); + }catch (Exception e){ + ICLogger.e(e.getMessage(),e); + } + }else{ + ICLogger.i("BP87 format error!"); + } + } public static StringMessage AP88(String index){ //设备响应: IWAP88, 080835# @@ -2295,6 +2343,140 @@ public class protocol_ic { } } + public static StringMessage APTQ(Runtime runtime) + { + /** + * IWAPTQ,460,0,9520,3671,0# + * APTQ : 命令字符 + * 460,0,9520,3671基站信息 + * 0:语言标志位 0 默认为中文,1为英文 + */ + //或者仅仅使用 locale = Locale.getDefault(); 不需要考虑接口 deprecated(弃用)问题 + Locale locale = Locale.getDefault(); + String lang = locale.getLanguage() + "-" + locale.getCountry(); + int language=0; + if(!lang.contains("zh")) + { + language=1; + } + return genStringMessage("APTQ",new StringBuffer(CMDHEADER).append(cmdMap.get(CMD_TYPE.APTQ)) + .append(CMDSPLIT).append(runtime.getLocationInstance().getMCC()) + .append(CMDSPLIT).append(runtime.getLocationInstance().getMNC()) + .append(CMDSPLIT).append(runtime.getLocationInstance().getLAC()) + .append(CMDSPLIT).append(runtime.getLocationInstance().getGSMStationCID()) + .append(CMDSPLIT).append(language) + .append(CMDEND).toString()); + } + + + public void handleBPTQ( Connection connection,Runtime runtime,String cmd) { + /*** + * + * IWBPTQ,20-10-11,19:32:02,6674,32,27,22,30,20-10-12,19:32:02,6674,32,27,22,30,20-10-13,19:32:02,6674,32,27,22,30,53575C71533A + * IWBPTQ, 16-09-24,11:00:00,b6e0d4c6,2,-5,-12,22,16-09-25,11:00:00,b6e0d4c6,2,-5,-12,22,16-09-26,11:00:00,b6e0d4c6,2,-5,-12,22,316df15733# + * å¹´-月-日,时:分:秒,天气描述,天气编号,当前温度,最低温,最高温,å¹´-月-日,时:分:秒,天气描述,天气编号,当前温度,最低温,最高温,å¹´-月-日,时:分:秒,天气描述,天气编号,当前温度,最低温,最高温,城市名 + * 注:天气描述用Unicode编码,城市名使用Unicode编码, 第一组为当天,后2组依次为后续2天天气 + * 如天气编号及描述对应如下(天气描述不需要发送括号内的白天晚上) + * 0:龙卷风 + * 1:热带风暴 + * 2:飓风 + * 3:严重的雷暴 + * 4:雷暴 + * 5:混合雨雪 + * 6:混合降雨和冰雹 + * 7:混合雪和雨夹雪 + * 8:冻结小雨 + * 9:小雨 + * 10:冻雨 + * 11:阵雨 + * 12:阵雨 + * 13:雪飘雪 + * 14:小雪阵雨 + * 15:吹雪 + * 16:雪 + * 17:冰雹 + * 18:雨夹雪 + * 19:尘埃 + * 20:雾 + * 21:霾 + * 22:黑烟 + * 23:大风 + * 24:风 + * 25:低温 + * 26:多云 + * 27:多云(晚上) + * 28:多云(白天) + * 29:局部多云(晚上) + * 30:局部多云(天) + * 31:清爽(晚) + * 32:晴天 + * 33:晴朗(晚) + * 34:晴朗(天) + * 35:混合雨和冰雹 + * 36:热 + * 37:局部地区性雷暴 + * 38:零星雷暴 + * 39:零星雷暴 + * 40:零星阵雨 + * 41:大雪 + * 42:零星阵雪 + * 43:大雪 + * 44:多云 + * 45:雷阵雨 + * 46:阵雪 + * 47:局部雷阵雨 + */ + + log("BPTQ "+cmd); + String[] cmdlist=cmd.split(CMDSPLIT); + if (cmdlist.length==23){ + + StringBuilder sb=new StringBuilder(); + StringBuilder msg=new StringBuilder(); + for(int i=0;i<3;i++) { + String DayTime = cmdlist[1+i*7] + " " + cmdlist[2+i*7]; + String date= "20"+cmdlist[1+i*7].trim(); + String weather_name = Util.decodeUnicode2Utf8(cmdlist[3+i*7].trim()); + String weather_id = cmdlist[4+i*7]; + String temp_current = cmdlist[5+i*7]; + String temp_high = cmdlist[6+i*7]; + String temp_low = cmdlist[7+i*7]; + + sb.append(" "+DayTime); + sb.append(",天气:"+weather_name); + sb.append(",ID "+weather_id); + sb.append(",当前温度 "+temp_current); + sb.append(",最高温度 "+temp_high); + sb.append(",最低温度 "+temp_low); + sb.append("\n"); + + msg.append(date); + msg.append(","+weather_name); + msg.append(","+weather_id); + msg.append(","+temp_current); + msg.append(","+temp_high); + msg.append(","+temp_low); + msg.append(";"); + } + String City=Util.decodeUnicode2Utf8(cmdlist[22]); + + ICLogger.i(City+" \n"+sb.toString()); + + msg.insert(0,City+";"); + String weatherstr=msg.toString(); + if (weatherstr.endsWith(";")) + { + weatherstr=weatherstr.substring(0,weatherstr.lastIndexOf(";")); + } + Intent intent=new Intent(Constants.ACTION_WEATHER_RECEIVED); + intent.putExtra(Constants.KEY_Weather,weatherstr); + ICLogger.i("send Broadcast "+ Constants.ACTION_WEATHER_RECEIVED +"\n"+weatherstr+"\n"); + CoreService.getInstance().sendBroadcast(intent); + + }else{ + ICLogger.i(" BPTQ Format error!"); + } + } @@ -2372,6 +2554,11 @@ public class protocol_ic { ICLogger.i("收到服务器设置闹钟命令BP85"); mConnection.DeliverCMDMessageToSystem("AP85",cmd);//通知下面线程状态变化 break; + + case BP87: + handleBP87(cmd,mConnection,mRuntime); + ICLogger.i("收到服务器 QRCode uri BP87"); + break; case BP33: //设置工作模式 handleBP33(mConnection,mRuntime,cmd); @@ -2527,6 +2714,10 @@ public class protocol_ic { ICLogger.i("聆听"); handleBPDH(mConnection,mRuntime,cmd); break; + + case BPTQ: + handleBPTQ(mConnection,mRuntime,cmd); + break; } return ret; diff --git a/app/src/main/java/com/ic/protocols/protocol_mqtt.java b/app/src/main/java/com/ic/protocols/protocol_mqtt.java index f2dfeb77..190abd58 100644 --- a/app/src/main/java/com/ic/protocols/protocol_mqtt.java +++ b/app/src/main/java/com/ic/protocols/protocol_mqtt.java @@ -303,6 +303,7 @@ public class protocol_mqtt { */ if(runtime.bleInfo.ble_area_id.isEmpty()){ + ICLogger.i("not Bind, skip send Location!"); return null; } StringBuilder sb = new StringBuilder(); diff --git a/app/version_code.properties b/app/version_code.properties index bdc78628..bac1906a 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Mon Sep 28 10:42:38 CST 2020 -VERSION_CODE=638 +#Mon Oct 12 14:15:33 CST 2020 +VERSION_CODE=642