From: TrillGates Date: Sun, 25 Apr 2021 05:51:26 +0000 (+0800) Subject: add anan protocol cmd X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=9a5eb31e696cee4cd5001dd383387ce1b9f11b99;p=protocol_srv.git add anan protocol cmd --- diff --git a/app/src/main/java/com/enqualcomm/support/Config.java b/app/src/main/java/com/enqualcomm/support/Config.java index 490c0c27..2cd62254 100644 --- a/app/src/main/java/com/enqualcomm/support/Config.java +++ b/app/src/main/java/com/enqualcomm/support/Config.java @@ -2,7 +2,6 @@ package com.enqualcomm.support; import android.content.Context; import android.provider.Settings; -import android.text.TextUtils; import android.util.JsonReader; import com.enqualcomm.support.bean.ICLocation; @@ -16,19 +15,14 @@ import com.enqualcomm.support.utils.VibrateUtil; import com.ic.jni.ICJniUtils; import com.ic.protocols.protocolAPIHelper; -import org.json.JSONException; import org.json.JSONStringer; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; -import java.io.Reader; import java.io.StringReader; import java.util.HashMap; -import java.util.List; - -import chestnut.Interface.json.Json; import static com.enqualcomm.support.bean.ICLocation.CUSTOM_MOD8_GPS; import static com.enqualcomm.support.bean.ICLocation.NORMAL_MOD; @@ -158,15 +152,15 @@ public class Config { final static String KeyLastUnReadMessage = "UnreadMsg"; private static HashMap AlarmConfiglist; - static final boolean doJsonTest=false; //测试Jason文件标志 - static String JsonConfigFilePath="/system/etc/protocol_config.json"; // Config文件路径 + static final boolean doJsonTest = false; //测试Jason文件标志 + static String JsonConfigFilePath = "/system/etc/protocol_config.json"; // Config文件路径 - public static int DefaultLocationMode=CUSTOM_MOD8_GPS; - public static int DefaultLocationCycle=60*60; - public static int DefaultPPGTestCycle=60; - public static int DefaultTemperatureTestCycle=60*60; + public static int DefaultLocationMode = CUSTOM_MOD8_GPS; + public static int DefaultLocationCycle = 60 * 60; + public static int DefaultPPGTestCycle = 60; + public static int DefaultTemperatureTestCycle = 60 * 60; - public static int DefaultWifiStatus=0; //0 close , 1 open, 2 open and connect using default wifi + public static int DefaultWifiStatus = 0; //0 close , 1 open, 2 open and connect using default wifi static { AlarmConfiglist = new HashMap(); @@ -200,7 +194,7 @@ public class Config { sendSOSAtOnce = Util.getSystemProperties("persist.sys.sos_at_once", "false").equals("true"); - do_broadCast_message = Util.getSystemProperties("persist.sys.doBroadcastMSG","false").equals("true"); + do_broadCast_message = Util.getSystemProperties("persist.sys.doBroadcastMSG", "false").equals("true"); noPPGSensor = (ICJniUtils.isPPGavailable() == 0); noTempSensor = (ICJniUtils.isTemperatureDevAvailable() == 0); @@ -211,9 +205,9 @@ public class Config { c43_branch_name = Util.getSystemProperties("persist.sys.c43.branch"); try { - DefaultWifiStatus = Integer.valueOf(Util.getSystemProperties("persist.sys.DefaultWifiStatus","0")); - }catch (Exception e){ - ICLogger.e(e.getMessage(),e); + DefaultWifiStatus = Integer.valueOf(Util.getSystemProperties("persist.sys.DefaultWifiStatus", "0")); + } catch (Exception e) { + ICLogger.e(e.getMessage(), e); } if ((c43_branch_name.equals("l03")) || (c43_branch_name.equals("l05"))) { @@ -231,13 +225,13 @@ public class Config { custom_name = Util.getSystemProperties("persist.sys.customname"); ICLogger.i("get CUSTOMNAME " + custom_name); - if (custom_name.equals("H88") || custom_name.equals("H88A") ) { + if (custom_name.equals("H88") || custom_name.equals("H88A")) { ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true); ConfigAlarm(Runtime.AlarmType.ALARM_WEARED, true); - DefaultLocationMode=CUSTOM_MOD8_GPS; - DefaultLocationCycle=60*60; - DefaultPPGTestCycle=60; - DefaultTemperatureTestCycle=60*60; + DefaultLocationMode = CUSTOM_MOD8_GPS; + DefaultLocationCycle = 60 * 60; + DefaultPPGTestCycle = 60; + DefaultTemperatureTestCycle = 60 * 60; noPushTxtNotifyDialog = true; noSMSNotifyDialog = false; @@ -250,10 +244,10 @@ public class Config { ConfigAlarm(Runtime.AlarmType.ALARM_CUTOFF, true); ConfigAlarm(Runtime.AlarmType.ALARM_ILLEGAL_CUTOFF, true); ConfigAlarm(Runtime.AlarmType.ALARM_LOCK_WATCH, true); - DefaultLocationMode=CUSTOM_MOD8_GPS; - DefaultLocationCycle=10*60; - DefaultPPGTestCycle=0; - DefaultTemperatureTestCycle=0; + DefaultLocationMode = CUSTOM_MOD8_GPS; + DefaultLocationCycle = 10 * 60; + DefaultPPGTestCycle = 0; + DefaultTemperatureTestCycle = 0; noPushTxtNotifyDialog = true; noSMSNotifyDialog = true; @@ -275,10 +269,10 @@ public class Config { ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true); ConfigAlarm(Runtime.AlarmType.ALARM_UNREADMSG, true); ConfigAlarm(Runtime.AlarmType.ALARM_MSGREAD, true); - DefaultLocationMode=NORMAL_MOD; - DefaultLocationCycle=15*60; - DefaultPPGTestCycle=0; - DefaultTemperatureTestCycle=0; + DefaultLocationMode = NORMAL_MOD; + DefaultLocationCycle = 15 * 60; + DefaultPPGTestCycle = 0; + DefaultTemperatureTestCycle = 0; noPushTxtNotifyDialog = false; noSMSNotifyDialog = true; @@ -301,10 +295,10 @@ public class Config { ConfigAlarm(Runtime.AlarmType.ALARM_WEARED, true); ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true); enableSleep = true; - DefaultLocationMode=NORMAL_MOD; - DefaultLocationCycle=900; - DefaultPPGTestCycle=0; - DefaultTemperatureTestCycle=0; + DefaultLocationMode = NORMAL_MOD; + DefaultLocationCycle = 900; + DefaultPPGTestCycle = 0; + DefaultTemperatureTestCycle = 0; noPushTxtNotifyDialog = true; noSMSNotifyDialog = true; @@ -321,10 +315,10 @@ public class Config { ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true); enableSleep = true; - DefaultLocationMode=NORMAL_MOD; - DefaultLocationCycle=900; - DefaultPPGTestCycle=0; - DefaultTemperatureTestCycle=0; + DefaultLocationMode = NORMAL_MOD; + DefaultLocationCycle = 900; + DefaultPPGTestCycle = 0; + DefaultTemperatureTestCycle = 0; noPushTxtNotifyDialog = false; noSMSNotifyDialog = false; @@ -341,10 +335,10 @@ public class Config { ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true); forceMoveCheck = false; //对定位不进行运动检测。 - DefaultLocationMode=CUSTOM_MOD8_GPS; - DefaultLocationCycle=5 * 60; - DefaultPPGTestCycle=0; - DefaultTemperatureTestCycle=0; + DefaultLocationMode = CUSTOM_MOD8_GPS; + DefaultLocationCycle = 5 * 60; + DefaultPPGTestCycle = 0; + DefaultTemperatureTestCycle = 0; noPushTxtNotifyDialog = false; noSMSNotifyDialog = false; @@ -360,10 +354,10 @@ public class Config { } else if (Config.custom_name.equals("L02") || Config.custom_name.equals("L03") || Config.custom_name.equals("L05")) { //L02 Config.forceMoveCheck = false; //即爱对gps不进行运动检测,此变量专门为了给其他协议进行强制运动检测用的。 - DefaultLocationMode=NORMAL_MOD; - DefaultLocationCycle=900; - DefaultPPGTestCycle=0; - DefaultTemperatureTestCycle=0; + DefaultLocationMode = NORMAL_MOD; + DefaultLocationCycle = 900; + DefaultPPGTestCycle = 0; + DefaultTemperatureTestCycle = 0; noPushTxtReadReply = false;//即爱需要阅读反馈 noBroadCastPushTxtNotify = true; } else if (Config.custom_name.equals("VitracK") || Config.custom_name.equals("wtsrui")) { @@ -373,40 +367,40 @@ public class Config { Config.ConfigAlarm(Runtime.AlarmType.ALARM_WEARED, true); Config.ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true); enableSleep = false; - DefaultLocationMode=CUSTOM_MOD8_GPS; - DefaultLocationCycle=15 * 60; - DefaultPPGTestCycle=15; - DefaultTemperatureTestCycle=15 * 60; + DefaultLocationMode = CUSTOM_MOD8_GPS; + DefaultLocationCycle = 15 * 60; + DefaultPPGTestCycle = 15; + DefaultTemperatureTestCycle = 15 * 60; } else { - DefaultLocationMode=NORMAL_MOD; - DefaultLocationCycle=900; - DefaultPPGTestCycle=0; - DefaultTemperatureTestCycle=0; + DefaultLocationMode = NORMAL_MOD; + DefaultLocationCycle = 900; + DefaultPPGTestCycle = 0; + DefaultTemperatureTestCycle = 0; noBroadCastPushTxtNotify = true; } } - static void load_config_fromfile(){ + static void load_config_fromfile() { try { - JsonReader jsonReader=null; - if(doJsonTest) { + JsonReader jsonReader = null; + if (doJsonTest) { String jsonString = (new JSONStringer()) .object().key("pversion").value("V0.2.3").key("value").value("eiot_V1.0.0").key("protocol_version").value("2.0").key("product").value(String.valueOf(2L)).key("swReleaseNo").value(String.valueOf(sw_release_no)).endObject() .toString(); - ICLogger.d("json String "+jsonString); + ICLogger.d("json String " + jsonString); jsonReader = new JsonReader(new StringReader(jsonString)); - }else { - File jsonFile=new File(JsonConfigFilePath); - ICLogger.d("json file "+JsonConfigFilePath+(jsonFile.exists()?" exist":" not exist")); + } else { + File jsonFile = new File(JsonConfigFilePath); + ICLogger.d("json file " + JsonConfigFilePath + (jsonFile.exists() ? " exist" : " not exist")); jsonReader = new JsonReader(new FileReader(jsonFile)); } jsonReader.beginObject(); while (jsonReader.hasNext()) { String name = jsonReader.nextName(); String value = jsonReader.nextString(); - setConfigValue(name,value); + setConfigValue(name, value); } jsonReader.endObject(); @@ -718,7 +712,6 @@ public class Config { public static void LoadMessageConfigs() { - } public static void loadTemperatureSettings(Runtime runtime) { @@ -791,6 +784,7 @@ public class Config { public static final int PROTOCOL_IC = 2; public static final int PROTOCOL_FZD = 3; public static final int PROTOCOL_MQTT = 4; + public static final int PROTOCOL_ANAN = 5; public static int protocol_no = getProtocolNumber(); @@ -971,7 +965,6 @@ public class Config { } - public static boolean isAlarmTypeEnabled(Runtime.AlarmType alarmType) { boolean en = false; @@ -990,8 +983,8 @@ public class Config { } - public static void setConfigValue(String key,String value){ - ICLogger.d("( "+key+" , "+value+")"); + public static void setConfigValue(String key, String value) { + ICLogger.d("( " + key + " , " + value + ")"); try { if (key.trim().equals("AlarmConfig")) { @@ -1000,15 +993,15 @@ public class Config { try { AlarmConfiglist.put(Runtime.AlarmType.valueOf(al).ordinal(), Boolean.valueOf(value)); } catch (Exception e) { - ICLogger.e(e.getMessage(),e); + ICLogger.e(e.getMessage(), e); } } } else if (key.trim().equals("disableWiFiScan")) { - disableWiFiScan=Boolean.valueOf(value); + disableWiFiScan = Boolean.valueOf(value); } else if (key.trim().equals("disableWristTemp")) { - disableWristTemp=Boolean.valueOf(value); + disableWristTemp = Boolean.valueOf(value); } else if (key.trim().equals("BLEScanProtocol")) { - BLEScanProtocol=Integer.valueOf(value); + BLEScanProtocol = Integer.valueOf(value); } else if (key.trim().equals("UsePolingCheckWeared")) { /* @@ -1020,8 +1013,8 @@ public class Config { public static String DefaultWiFiEncryptType = "psk"; * */ } - }catch (Exception e){ - ICLogger.e(e.getMessage(),e); + } catch (Exception e) { + ICLogger.e(e.getMessage(), e); } } diff --git a/app/src/main/java/com/ic/protocols/protocolAPIHelper.java b/app/src/main/java/com/ic/protocols/protocolAPIHelper.java index ec5318a5..14e9c079 100644 --- a/app/src/main/java/com/ic/protocols/protocolAPIHelper.java +++ b/app/src/main/java/com/ic/protocols/protocolAPIHelper.java @@ -9,6 +9,8 @@ import com.enqualcomm.support.utils.Connection; import com.enqualcomm.support.utils.ICLogger; import com.enqualcomm.support.utils.TimeUtil; +import static com.enqualcomm.support.Config.PROTOCOL_ANAN; + public class protocolAPIHelper { @@ -17,6 +19,7 @@ public class protocolAPIHelper { private static protocol_ic protocolic_handler = null; private static protocol_fzd protocolfzd_handler = null; private static protocol_mqtt protocolmqtt_handler = null; + private static protocol_anan protocolanan_handler = null; public static protocol_fzd getProtocolfzd_handler() { return protocolfzd_handler; @@ -24,21 +27,32 @@ public class protocolAPIHelper { public protocolAPIHelper(Connection connect, Runtime runtime) { ICLogger.i("init Protocol " + Config.getProtocolNumber()); - if (protocolbeehome_handler == null) + if (protocolbeehome_handler == null) { protocolbeehome_handler = new protocol_beehome(connect, runtime); - if (protocoljiai_handler == null) + } + if (protocoljiai_handler == null) { protocoljiai_handler = new protocol_jiai(connect, runtime); - if (protocolic_handler == null) + } + if (protocolic_handler == null) { protocolic_handler = new protocol_ic(connect, runtime); - if (protocolfzd_handler == null) + } + if (protocolfzd_handler == null) { protocolfzd_handler = new protocol_fzd(connect, runtime); - if (protocolmqtt_handler == null) + } + if (protocolmqtt_handler == null) { protocolmqtt_handler = new protocol_mqtt(connect, runtime); + } + if (protocolanan_handler == null) { + protocolanan_handler = new protocol_anan(connect, runtime); + } } private static boolean is_protocol_not_Initialled() { - return (protocolbeehome_handler == null || protocoljiai_handler == null || protocolic_handler == null || protocolfzd_handler == null || protocolmqtt_handler == null); - + return (protocolbeehome_handler == null || protocoljiai_handler == null + || protocolic_handler == null || + protocolfzd_handler == null || + protocolmqtt_handler == null || + protocolanan_handler == null); } /* @@ -68,6 +82,10 @@ public class protocolAPIHelper { case Config.PROTOCOL_MQTT: protocolmqtt_handler.parserCmd(cmd_type, bytes); break; + case PROTOCOL_ANAN: + protocolanan_handler.parseCmd(cmd_type, bytes); + break; + } return true; } @@ -573,6 +591,9 @@ public class protocolAPIHelper { case Config.PROTOCOL_MQTT: ret = protocol_mqtt.defaultServerIP; break; + case PROTOCOL_ANAN: + ret = protocol_anan.defaultServerIp; + break; } ICLogger.d("ip ==> " + ret); return ret; @@ -597,6 +618,9 @@ public class protocolAPIHelper { case Config.PROTOCOL_MQTT: ret = protocol_mqtt.defaultServerPort; break; + case PROTOCOL_ANAN: + ret = protocol_anan.defaultServerPort; + break; } return ret; } @@ -721,6 +745,9 @@ public class protocolAPIHelper { case Config.PROTOCOL_MQTT: ret = null; break; + case PROTOCOL_ANAN: + ret = null; + break; } return ret; } diff --git a/app/src/main/java/com/ic/protocols/protocol_anan.java b/app/src/main/java/com/ic/protocols/protocol_anan.java new file mode 100644 index 00000000..65ed8a09 --- /dev/null +++ b/app/src/main/java/com/ic/protocols/protocol_anan.java @@ -0,0 +1,113 @@ +package com.ic.protocols; + +import com.enqualcomm.support.bean.Runtime; +import com.enqualcomm.support.utils.Connection; +import com.enqualcomm.support.utils.ICLogger; + +/** + * 安安康养的协议 + * 测试服务器域名:pay.yfanan.com:40009 + * 测试服务器IP地址:121.43.158.167:40009 + */ +public class protocol_anan { + + public static int defaultServerPort = 40009; + public static String defaultServerIp = "pay.yfanan.com"; + private final Connection mConnection; + private final Runtime mRuntime; + + public protocol_anan(Connection connect, Runtime runtime) { + mConnection = connect; + mRuntime = runtime; + } + + + public enum CMD_TYPE { + /*终端发起*/ + /*# 设备上传指令 + + AP00:登录包 + + APHT:上传心率与血压 + + AP01:定位数据包 + + AP03:心跳包,也包括步数数据 + + AP10:报警与地址回复包 + + APTQ:请求天气 + + APWA:手表佩戴与未佩戴提醒 + + APCH:充电状态 + + APFD:交好友 + +AP07:语音上行 + +AP95:语音上行给好友 + */ + AP00/*登录包*/, + APHT/*上传心率与血压*/, + AP01/*定位数据包*/, + AP03/*心跳包,也包括步数数据*/, + AP10/*报警与地址回复包*/, + APTQ/*请求天气*/, + APWA/*手表佩戴与未佩戴提醒*/, + APCH/*充电状态*/, + APFD/*交好友*/, + AP07/*语音上行*/, + AP95/*语音上行给好友*/, + + /** + * # 平台下发指令 + * BP16:立即定位 + * BP17:恢复出厂设置 + * BP18:重启手表手环 + * BP31:关机 + * BP32:打电话 + * BP75:设置闹钟 + * BP14: 下发电话本 + * BP44: 休眠时间段 + * BP45: 静音开关 + * BP26: 设置上课隐身时间段 + * BP12 设置紧急联系人 + * BPXL 测量心率 + * BPXY 测量血压响应APXL + * BP98 计步目标AP98 + * BP88 寻找设备 + * BP87: 请求设备二维码 + * BPNT 下发通知 + * BP99 监听 + * BPSW 切换定位数据开关 + * BP15 GPRS定位数据上传时间间隔 + * BP68 设置绑定状态 + * BP84 白名单开关 + * BPFD:交好友响应 + * BP07:语音上行响应 + * BP95:语音上行给好友响应 + */ + BP16/*立即定位*/, + BP17/*恢复出厂设置*/, + BP18/*重启手表手环*/, + BP31/*关机*/, + BP32/*打电话*/, + BP75/*设置闹钟*/, + BP14/* 下发电话本*/, + BP44/* 休眠时间段*/, + BP45/* 静音开关*/, + BP26/* 设置上课隐身时间段*/, + BP12/*设置紧急联系人*/, + BPXL/*测量心率*/, + BPXY/* 测量血压响应APXL*/, + BP98/*计步目标AP98*/, + BP88/*寻找设备*/, + BP87/* 请求设备二维码*/, + BPNT/*下发通知*/, + BP99/*监听*/, + BPSW/*切换定位数据开关*/, + BP15/*GPRS定位数据上传时间间隔*/, + BP68/*设置绑定状态*/, + BP84/* 白名单开关*/, + BPFD/*交好友响应*/, + BP07/*语音上行响应*/, + BP95/*语音上行给好友响应*/, + } + + + //指令解析 + public void parseCmd(String cmd_type, byte[] bytes) { + ICLogger.d("cmd_type == > " + cmd_type); + ICLogger.d("byte == > " + new String(bytes)); + } +}