| | |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLCurtain.Parser.CurtainCtrlParser; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLFreshAir.FreshAirBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.GeothermalBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.CCTBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.LightCtrlBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.RGBBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLLogic.LogicCtrlBackInfo; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLLogic.LogicMode; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLSecurity.SecurityBackInfo; |
| | |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.EventCode; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.FreshAirFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.GeothermalFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LightCCTCtrlBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LightFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LightRGBCtrlBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.SecurityAlarmFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.SecurityArmingFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.WarningInfoEvent; |
| | |
| | | |
| | | /** |
| | | * 配置简易编程搜索返回的默认参数 |
| | | * @param mSDKLocalBigClass 大类ID |
| | | * |
| | | * @param mSDKLocalBigClass 大类ID |
| | | * @param mSDKLocalSmallClass 小类ID |
| | | * @param mSDKLocalRemark 备注 |
| | | * @param mSDKLocalRemark 备注 |
| | | */ |
| | | public static void setEasyProgrammingSearchLocalData(int mSDKLocalBigClass, int mSDKLocalSmallClass, String mSDKLocalRemark){ |
| | | public static void setEasyProgrammingSearchLocalData(int mSDKLocalBigClass, int mSDKLocalSmallClass, String mSDKLocalRemark) { |
| | | SDKLocalBigClass = mSDKLocalBigClass; |
| | | SDKLocalSmallClass = mSDKLocalSmallClass; |
| | | if(mSDKLocalRemark != null){ |
| | | if (mSDKLocalRemark != null) { |
| | | SDKLocalRemark = mSDKLocalRemark; |
| | | } |
| | | isAllowEasyProgrammingSearch = true; |
| | | } |
| | | |
| | | public static void setEasyProgrammingSearchLocalData(int mSDKLocalBigClass, int mSDKLocalSmallClass){ |
| | | setEasyProgrammingSearchLocalData(mSDKLocalBigClass, mSDKLocalSmallClass,null); |
| | | public static void setEasyProgrammingSearchLocalData(int mSDKLocalBigClass, int mSDKLocalSmallClass) { |
| | | setEasyProgrammingSearchLocalData(mSDKLocalBigClass, mSDKLocalSmallClass, null); |
| | | } |
| | | |
| | | /** |
| | | * 设置是否允许被简易编程搜索 |
| | | * |
| | | * @param isAllow |
| | | */ |
| | | public static void setIsAllowEasyProgrammingSearch(boolean isAllow){ |
| | | public static void setIsAllowEasyProgrammingSearch(boolean isAllow) { |
| | | isAllowEasyProgrammingSearch = isAllow; |
| | | } |
| | | |
| | |
| | | case Configuration.AIR_HVAC_CTRL_BACK_COMMAND: |
| | | case Configuration.FRESH_AIR_CTRL_BACK_COMMAND: //20190709新增 |
| | | handleCtrlData(getDatas); |
| | | break; |
| | | case Configuration.LIGHT_RGB_CTRL_BACK_COMMAND: //2020-10-19新增 |
| | | handleRGBCCTCtrlData(getDatas); |
| | | break; |
| | | case Configuration.LIGHT_RGB_STATE_BACK_COMMAND: //2020-10-19新增 |
| | | handleRGBCCTStateData(getDatas); |
| | | break; |
| | | case Configuration.GEOTHERMAL_MODULE_CTRL_BACK_COMMAND://20190709新增 |
| | | handleGeothermalCtrlData(getDatas); |
| | |
| | | * @param getDatas |
| | | */ |
| | | private static void sendDeviceSearchBackInfo(UdpDataBean getDatas) { |
| | | byte[] remarkByte = StringUtil.stringtoBytes(SDKLocalRemark); |
| | | byte[] remarkByte = StringUtil.stringtoBytes(SDKLocalRemark); |
| | | byte[] addBytes = new byte[25]; |
| | | addBytes[0] = getDatas.addBytes[0]; |
| | | addBytes[1] = getDatas.addBytes[1]; |
| | |
| | | |
| | | /** |
| | | * 收到简易编程搜索非网络设备 |
| | | * |
| | | * @param getDatas |
| | | */ |
| | | public static void handleDeviceSearchBackData(UdpDataBean getDatas){ |
| | | public static void handleDeviceSearchBackData(UdpDataBean getDatas) { |
| | | //判断是否允许被简易编程搜索和回复 |
| | | if(!isAllowEasyProgrammingSearch) return; |
| | | if (!isAllowEasyProgrammingSearch) return; |
| | | |
| | | if (getDatas.addBytes.length == 2) { |
| | | sendDeviceSearchBackInfo(getDatas); |
| | |
| | | for (int i = 2, len = getDatas.addBytes.length; i < len; i++) { |
| | | if (i % 2 == 0) { |
| | | if ((getDatas.addBytes[i] & 0xFF) == Crc.localSubnetID |
| | | && (getDatas.addBytes[i + 1] & 0xFF) == Crc.localDeviceID |
| | | && (getDatas.addBytes[i + 1] & 0xFF) == Crc.localDeviceID |
| | | ) { |
| | | isExit = true; |
| | | break; |
| | |
| | | } |
| | | } |
| | | |
| | | if(!isExit){ |
| | | if (!isExit) { |
| | | sendDeviceSearchBackInfo(getDatas); |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | * 处理灯光返回 |
| | | * 2020-1-18 |
| | | * 修复混合调光混合开关 类模块问题 |
| | | * |
| | | * @param getDatas |
| | | */ |
| | | private static void handleLightCtrlData(UdpDataBean getDatas){ |
| | | private static void handleLightCtrlData(UdpDataBean getDatas) { |
| | | |
| | | if (TextUtils.isEmpty(HandleSearch.rcuIp)) { |
| | | outter: |
| | |
| | | ) { |
| | | List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); |
| | | for (int j = 0, len2 = infos.size(); j < len2; j++) { |
| | | if(infos.get(j).getLittleType() == 9 || infos.get(j).getLittleType() == 10 ){ |
| | | if (infos.get(j).getLittleType() == 9 || infos.get(j).getLittleType() == 10) { |
| | | |
| | | if (infos.get(j).getPhysicsChannelNum() == (getDatas.addBytes[0] & 0xFF)) { |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | }else { |
| | | } else { |
| | | |
| | | |
| | | if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { |
| | |
| | | List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); |
| | | inner: |
| | | for (int j = 0, len2 = infos.size(); j < len2; j++) { |
| | | if(infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_GLYSTRO |
| | | if (infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_GLYSTRO |
| | | || infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_ROLLER |
| | | || infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE |
| | | ) { |
| | |
| | | hvacBytes[i - 23] = getDatas.addBytes[i]; |
| | | } |
| | | |
| | | HDLLog.info("获取备注Configuration.AIR_BIG_TYPE: "+ StringUtil.ByteArrToHex(hvacBytes,0, hvacBytes.length)); |
| | | HDLLog.info("获取备注Configuration.AIR_BIG_TYPE: " + StringUtil.ByteArrToHex(hvacBytes, 0, hvacBytes.length)); |
| | | |
| | | devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setArrCurState(hvacBytes); |
| | | // switch (devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getChannelNum()) { |
| | |
| | | devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes); |
| | | EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); |
| | | break outter; |
| | | }else { |
| | | } else { |
| | | HDLLog.info("handleFreshAirStateData 没有找到匹配类型"); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | break outter; |
| | | }else { |
| | | } else { |
| | | HDLLog.info("handleFreshAirStateData 没有找到匹配类型"); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * 设置控制是否成功状态 |
| | | * |
| | | * @param info |
| | | * @param success |
| | | */ |
| | | public static void setDeviceCtrlSuccessStateWithInfo(AppliancesInfo info, Boolean success){ |
| | | public static void setDeviceCtrlSuccessStateWithInfo(AppliancesInfo info, Boolean success) { |
| | | ctrlSuccessStateHashMap.put(info.getDeviceKey(), success); |
| | | } |
| | | |
| | | /** |
| | | * 获取是否控制成功 |
| | | * |
| | | * @param info |
| | | * @return 结果 |
| | | */ |
| | | public static Boolean getDeviceCtrlSuccessStateWithInfo(AppliancesInfo info){ |
| | | Boolean success = ctrlSuccessStateHashMap.get(info.getDeviceKey()); |
| | | if(success == null) success = false; |
| | | public static Boolean getDeviceCtrlSuccessStateWithInfo(AppliancesInfo info) { |
| | | Boolean success = ctrlSuccessStateHashMap.get(info.getDeviceKey()); |
| | | if (success == null) success = false; |
| | | return success; |
| | | } |
| | | |
| | |
| | | * 保存设备数据列表 |
| | | * 根据需要,实时保存当前数据 |
| | | * 2019-10-14 |
| | | * |
| | | * @return boolean |
| | | */ |
| | | public static boolean saveDevicesDataList() { |
| | |
| | | HandleSearch.curSearchMode = HandleSearch.GET_RCU_DEVICES; |
| | | HDLUdpCore.closeSocket6000(); |
| | | HDLUdpCore.init6008(); |
| | | }else { |
| | | } else { |
| | | HandleSearch.curSearchMode = HandleSearch.GET_BUS_DEVICES; |
| | | HDLUdpCore.closeSocket6008(); |
| | | HDLUdpCore.init6000(); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | private static void setRemarkList(){ |
| | | private static void setRemarkList() { |
| | | listRemarks.clear(); |
| | | for (int j = 0; j < devicesDataList.size(); j++) { |
| | | if (devicesDataList.get(j).getAppliancesInfoList().get(0).getBigType() != Configuration.AUDIO_BIG_TYPE) { |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * RGB CCT设备控制数据 |
| | | * 2020-10-20 新增 |
| | | * |
| | | * @param getDatas |
| | | */ |
| | | private static void handleRGBCCTCtrlData(UdpDataBean getDatas) { |
| | | if (getDatas.addBytes.length >= 9) { |
| | | //1-5//1单路 2CCT 3RGB 4RGBW 5RGBWY |
| | | if (getDatas.addBytes[5] == 3) {//RGB |
| | | outter: |
| | | for (int i = 0, len = devicesDataList.size(); i < len; i++) { |
| | | if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID |
| | | && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID) { |
| | | |
| | | List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); |
| | | for (int j = 0, len2 = infos.size(); j < len2; j++) { |
| | | if (infos.get(j).getBigType() == Configuration.LIGTH_BIG_TYPE |
| | | && infos.get(j).getDeviceType() == HDLApConfig.TYPE_LIGHT_RGB |
| | | && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF) |
| | | ) { |
| | | devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes); |
| | | AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); |
| | | RGBBackInfo info = new RGBBackInfo(mInfo); |
| | | setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); |
| | | EventBus.getDefault().post(new LightRGBCtrlBackEvent(info, true)); |
| | | } |
| | | } |
| | | break outter;//跳出循环 |
| | | } |
| | | } |
| | | } else if (getDatas.addBytes[5] == 2) {//CCT |
| | | outter: |
| | | for (int i = 0, len = devicesDataList.size(); i < len; i++) { |
| | | if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID |
| | | && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID) { |
| | | |
| | | List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); |
| | | for (int j = 0, len2 = infos.size(); j < len2; j++) { |
| | | if (infos.get(j).getBigType() == Configuration.LIGTH_BIG_TYPE |
| | | && infos.get(j).getDeviceType() == HDLApConfig.TYPE_LIGHT_CCT |
| | | && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF) |
| | | ) { |
| | | devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes); |
| | | AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); |
| | | CCTBackInfo info = new CCTBackInfo(mInfo); |
| | | setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); |
| | | EventBus.getDefault().post(new LightCCTCtrlBackEvent(info, true)); |
| | | } |
| | | } |
| | | break outter;//跳出循环 |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * RGB CCT 状态读取回复数据 |
| | | * 2020-10-20 新增 |
| | | * |
| | | * @param getDatas |
| | | */ |
| | | private static void handleRGBCCTStateData(UdpDataBean getDatas) { |
| | | outter: |
| | | for (int i = 0, len = devicesDataList.size(); i < len; i++) { |
| | | if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID |
| | | && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID |
| | | ) { |
| | | List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); |
| | | for (int j = 0, len2 = infos.size(); j < len2; j++) { |
| | | if (infos.get(j).getBigType() == Configuration.LIGTH_BIG_TYPE |
| | | && (infos.get(j).getDeviceType() == HDLApConfig.TYPE_LIGHT_RGB || infos.get(j).getDeviceType() == HDLApConfig.TYPE_LIGHT_CCT) |
| | | && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { |
| | | if (getDatas.addBytes.length >= 9) { |
| | | byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getFeedbackState(); |
| | | if (getBytes == null || getBytes.length < 9) {//标准协议长度是11,但是抓包发现有的设备会少于11 |
| | | getBytes = new byte[11]; |
| | | } |
| | | System.arraycopy(getDatas.addBytes, 0, getBytes, 0, Math.min(getDatas.addBytes.length, 11)); |
| | | devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getBytes); |
| | | isGetDeviceStateSuccess = true; |
| | | EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); |
| | | } else { |
| | | HDLLog.E("RGB CCT状态反馈数据异常"); |
| | | } |
| | | |
| | | break outter; |
| | | } else { |
| | | // HDLLog.info("handleFreshAirStateData 没有找到匹配类型"); |
| | | } |
| | | } |
| | | break outter; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |