| | |
| | | package com.hdl.sdk.ttl.HDLDeviceManger.Core; |
| | | |
| | | import android.content.Context; |
| | | import android.util.Log; |
| | | |
| | | import com.hdl.sdk.ttl.Config.Configuration; |
| | | import com.hdl.sdk.ttl.Config.MCUConstants; |
| | |
| | | import com.hdl.sdk.ttl.HDLAppliances.HDLCommonSwitch.CommonSwitchBackInfo; |
| | | import com.hdl.sdk.ttl.HDLAppliances.HDLCurtain.CurtainCtrlBackInfo; |
| | | import com.hdl.sdk.ttl.HDLAppliances.HDLCurtain.Parser.CurtainCtrlParser; |
| | | import com.hdl.sdk.ttl.HDLAppliances.HDLDoorMachine.DoorMachineBackInfo; |
| | | import com.hdl.sdk.ttl.HDLAppliances.HDLDoorMachine.Parser.DoorMachineParser; |
| | | import com.hdl.sdk.ttl.HDLAppliances.HDLFreshAir.FreshAirBackInfo; |
| | | import com.hdl.sdk.ttl.HDLAppliances.HDLFreshAir.FreshAirJinMaoBackInfo; |
| | | import com.hdl.sdk.ttl.HDLAppliances.HDLFreshAir.Parser.FreshAirJinMaoParser; |
| | | import com.hdl.sdk.ttl.HDLAppliances.HDLFreshAir.Parser.FreshAirParser; |
| | | import com.hdl.sdk.ttl.HDLAppliances.HDLGeothermal.GeothermalBackInfo; |
| | | import com.hdl.sdk.ttl.HDLAppliances.HDLGeothermal.Parser.GeothermalParser; |
| | | import com.hdl.sdk.ttl.HDLAppliances.HDLLight.ColourLightCtrlBackInfo; |
| | | import com.hdl.sdk.ttl.HDLAppliances.HDLLight.LightCtrlBackInfo; |
| | | import com.hdl.sdk.ttl.HDLAppliances.HDLLight.Parser.LightCtrlParser; |
| | | import com.hdl.sdk.ttl.HDLAppliances.HDLLogic.LogicCtrlBackInfo; |
| | | import com.hdl.sdk.ttl.HDLAppliances.HDLSecurity.Parser.SecurityParser; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.Bean.DeviceStateBean; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.Bean.MCUDataBean; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.AirFeedBackEvent; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.ColourLightFeedBackEvent; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.CommonSwitchCtrlBackEvent; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.CurtainFeedBackEvent; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DeviceStateEvent; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DoorMachineFeedBackEvent; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.EventCode; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.FreshAirFeedBackEvent; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.FreshAirJinMaoFeedBackEvent; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.GeothermalFeedBackEvent; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.LightFeedBackEvent; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent; |
| | | import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.MCUFeedBackEvent; |
| | |
| | | private static Timer securityCtrlFailTimer = null;//安防模块操作失败Timer |
| | | private static Timer commonSwitchCtrlFailTimer = null;//通用开关失败Timer |
| | | |
| | | private static Timer freshAirCtrlFailTimer = null;//控制新风失败Timer |
| | | private static Timer geothermalCtrlFailTimer = null;//控制地热失败Timer 2020-07-20 |
| | | private static Timer doorMachineCtrlFailTimer = null;//控制门锁失败Timer |
| | | |
| | | // /** |
| | | // * 初始化 SDK |
| | |
| | | */ |
| | | public static void getHomeDevices() { |
| | | HandleSearch.getHomeDevices(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取家居设备备注 |
| | | */ |
| | | public static void getDevRemarks() { |
| | | HandleSearch.getDevRemarks(); |
| | | } |
| | | |
| | | /** |
| | |
| | | }, mRequestTimeout); |
| | | } |
| | | |
| | | /** |
| | | * 控制CCT OR RGB |
| | | * |
| | | * @param info |
| | | * @param brightness 亮度 |
| | | * @param color |
| | | */ |
| | | public static void colourLightCtrl(final AppliancesInfo info, int brightness, int color) { |
| | | HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); |
| | | if (lightCtrlFailTimer != null) { |
| | | lightCtrlFailTimer.cancel(); |
| | | lightCtrlFailTimer = null; |
| | | } |
| | | if (info.getBigType() == Configuration.LIGTH_BIG_TYPE) { |
| | | addSendData(info, LightCtrlParser.getColourLightAddByte(info, brightness, color), Configuration.CONTROL); |
| | | |
| | | lightCtrlFailTimer = new Timer(); |
| | | lightCtrlFailTimer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { |
| | | ColourLightCtrlBackInfo colourLightCtrlBackInfo = new ColourLightCtrlBackInfo(info); |
| | | EventBus.getDefault().post(new ColourLightFeedBackEvent(colourLightCtrlBackInfo, false)); |
| | | } |
| | | } |
| | | }, mRequestTimeout); |
| | | |
| | | } else { |
| | | HDLLog.I("灯光设备控制不在范围内" |
| | | + " LittleType = " + info.getLittleType() |
| | | + " BigType = " + info.getBigType() |
| | | ); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 控制窗帘 |
| | |
| | | if (info.getBigType() == Configuration.AIR_BIG_TYPE) { |
| | | if (info.getDeviceType() == HDLApConfig.TYPE_AC_PANEL) { |
| | | addSendData(info, AirCtrlParser.getAirPanelAddByte(type, state), Configuration.CONTROL); |
| | | } else if (info.getDeviceType() == HDLApConfig.TYPE_AC_TECHSYS) { |
| | | byte[] airbytes = AirCtrlParser.getAirTechAddByte(info, type, state); |
| | | if (airbytes != null) { |
| | | addSendData(info, airbytes, Configuration.CONTROL); |
| | | } |
| | | } else { |
| | | byte[] airbytes = AirCtrlParser.getAcAddByte(info, type, state); |
| | | if (airbytes != null) { |
| | |
| | | |
| | | /** |
| | | * 获取通用开关状态 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void getCommonSwitchStateFromNetwork(final AppliancesInfo info) { |
| | |
| | | /** |
| | | * 安防模块 布防设置 |
| | | * 2019-7-29 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void securityArmingCtrl(final AppliancesInfo info, int state) { |
| | |
| | | @Override |
| | | public void run() { |
| | | if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { |
| | | EventBus.getDefault().post(new SecurityArmingFeedBackEvent(info,0, false)); |
| | | EventBus.getDefault().post(new SecurityArmingFeedBackEvent(info, 0, false)); |
| | | } |
| | | } |
| | | }, 5000); |
| | |
| | | /** |
| | | * 安防模块 报警设置 |
| | | * 2019-7-29 |
| | | * |
| | | * @param info |
| | | * @param state 发送的报警内容,只报警一种 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 获取窗帘设备状态 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void getCurtainDeviceStateFromNetwork(final AppliancesInfo info) { |
| | |
| | | |
| | | /** |
| | | * 获取灯光设备状态 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void getLightDeviceStateFromNetwork(final AppliancesInfo info) { |
| | |
| | | case HDLApConfig.TYPE_LIGHT_RELAY: |
| | | case HDLApConfig.TYPE_LIGHT_MIX_DIMMER: |
| | | case HDLApConfig.TYPE_LIGHT_MIX_RELAY: |
| | | //发送获灯光状态数据 |
| | | //发送获取灯光状态数据 |
| | | addSendData(info, new byte[0], Configuration.STATE); |
| | | break; |
| | | default: |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取CTT or RGB灯设备状态 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void getColourLightDeviceStateFromNetwork(final AppliancesInfo info) { |
| | | if (info == null) { |
| | | return; |
| | | } |
| | | HDLDeviceManager.isGetDeviceStateSuccess = false; |
| | | switch (info.getDeviceType()) { |
| | | case HDLApConfig.TYPE_LIGHT_CCT: |
| | | case HDLApConfig.TYPE_LIGHT_RGB: |
| | | case HDLApConfig.TYPE_LIGHT_DALI: |
| | | case HDLApConfig.TYPE_LIGHT_DMX: |
| | | //发送获取灯光状态数据 |
| | | byte[] sendbytes = new byte[]{(byte) info.getChannelNum()}; |
| | | addSendData(info, sendbytes, Configuration.STATE); |
| | | break; |
| | | default: |
| | | HDLLog.I("不是CTT or RGB灯光设备"); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取逻辑 场景号 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void getLogicDeviceStateFromNetwork(final AppliancesInfo info) { |
| | |
| | | |
| | | /** |
| | | * 获取安防模块状态 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void getSecurityStateFromNetwork(final AppliancesInfo info) { |
| | |
| | | |
| | | /** |
| | | * 获取传感器模块状态 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void getSensorStateFromNetwork(final AppliancesInfo info) { |
| | |
| | | |
| | | /** |
| | | * 获取干接点传感器模块状态 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void getDryContactSensorStateFromNetwork(final AppliancesInfo info) { |
| | |
| | | |
| | | /** |
| | | * 获取HVAC空调设备状态 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void getHVACDeviceStateFromNetwork(final AppliancesInfo info) { |
| | |
| | | case HDLApConfig.TYPE_AC_HVAC: |
| | | // case HDLApConfig.TYPE_AC_PANEL: |
| | | //发送HVAC状态数据 |
| | | addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); |
| | | addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); |
| | | break; |
| | | default: |
| | | HDLLog.I("不是HVAC空调设备"); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取科技系统状态 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void getTechSysDeviceStateFromNetwork(final AppliancesInfo info) { |
| | | if (info == null) { |
| | | return; |
| | | } |
| | | HDLDeviceManager.isGetDeviceStateSuccess = false; |
| | | switch (info.getDeviceType()) { |
| | | case HDLApConfig.TYPE_AC_TECHSYS: |
| | | //发送科技系统状态数据 |
| | | addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); |
| | | break; |
| | | default: |
| | | HDLLog.I("不是科技系统设备"); |
| | | break; |
| | | } |
| | | } |
| | |
| | | case HDLApConfig.TYPE_AC_COOLMASTER: |
| | | case HDLApConfig.TYPE_AC_INFRARED: |
| | | case HDLApConfig.TYPE_AC_PANEL: |
| | | case HDLApConfig.TYPE_AC_TECHSYS: |
| | | //2019-8-21 增加判空 |
| | | byte[] acState = getACState(info); |
| | | if (acState != null && acState.length >= 4) { |
| | |
| | | switch (info.getDeviceType()) { |
| | | case HDLApConfig.TYPE_AC_HVAC: |
| | | case HDLApConfig.TYPE_AC_PANEL: |
| | | case HDLApConfig.TYPE_AC_TECHSYS: |
| | | curState = infos.get(j).getArrCurState(); |
| | | break; |
| | | default: |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取新风 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void getFreshAirDeviceStateFromNetwork(final AppliancesInfo info) { |
| | | if (info == null) { |
| | | return; |
| | | } |
| | | HDLDeviceManager.isGetDeviceStateSuccess = false; |
| | | switch (info.getDeviceType()) { |
| | | case HDLApConfig.TYPE_FRESH_AIR: |
| | | case HDLApConfig.TYPE_FRESH_AIR_JINMAO: |
| | | //发送获取新风系统所有数据 |
| | | addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); |
| | | break; |
| | | default: |
| | | HDLLog.I("不是新风系统设备"); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 控制新风系统 |
| | | * |
| | | * @param info |
| | | * @param type |
| | | * @param state 2020-07-20 |
| | | */ |
| | | public static void freshAirCtrl(final AppliancesInfo info, int type, int state) { |
| | | // HDLDeviceManager.isFreshAirCtrlSuccess = false; |
| | | HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); |
| | | if (freshAirCtrlFailTimer != null) { |
| | | freshAirCtrlFailTimer.cancel(); |
| | | freshAirCtrlFailTimer = null; |
| | | } |
| | | if (info.getBigType() == Configuration.FRESH_AIR_BIG_TYPE) { |
| | | byte[] freshAirbytes = FreshAirParser.getFreshAirAddByte(info, type, state); |
| | | addSendData(info, freshAirbytes, Configuration.CONTROL); |
| | | freshAirCtrlFailTimer = new Timer(); |
| | | freshAirCtrlFailTimer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { |
| | | FreshAirBackInfo mFreshAirBackInfo = new FreshAirBackInfo(); |
| | | mFreshAirBackInfo.setAppliancesInfo(info); |
| | | EventBus.getDefault().post(new FreshAirFeedBackEvent(mFreshAirBackInfo, false)); |
| | | } |
| | | } |
| | | }, mRequestTimeout); |
| | | |
| | | |
| | | } else { |
| | | HDLLog.I("新风设备控制不在范围内" |
| | | + " LittleType = " + info.getLittleType() |
| | | + " BigType = " + info.getBigType() |
| | | ); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取金茂新风状态 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void getFreshAirJinMaoDeviceStateFromNetwork(final AppliancesInfo info) { |
| | | if (info == null) { |
| | | return; |
| | | } |
| | | HDLDeviceManager.isGetDeviceStateSuccess = false; |
| | | switch (info.getDeviceType()) { |
| | | case HDLApConfig.TYPE_FRESH_AIR_JINMAO: |
| | | //发送获取新风系统所有数据 |
| | | addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); |
| | | break; |
| | | default: |
| | | HDLLog.I("不是金茂新风系统设备"); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 控制金茂新风 |
| | | * |
| | | * @param info |
| | | * @param type |
| | | * @param state 2020-07-20 |
| | | */ |
| | | public static void freshAirJinMaoCtrl(final AppliancesInfo info, int type, int state) { |
| | | // HDLDeviceManager.isFreshAirCtrlSuccess = false; |
| | | HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); |
| | | if (freshAirCtrlFailTimer != null) { |
| | | freshAirCtrlFailTimer.cancel(); |
| | | freshAirCtrlFailTimer = null; |
| | | } |
| | | if (info.getDeviceType() == HDLApConfig.TYPE_FRESH_AIR_JINMAO) { |
| | | byte[] sendBytes = FreshAirJinMaoParser.getFreshAirAddByte(info, type, state); |
| | | addSendData(info, sendBytes, Configuration.CONTROL); |
| | | freshAirCtrlFailTimer = new Timer(); |
| | | freshAirCtrlFailTimer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { |
| | | FreshAirJinMaoBackInfo mFreshAirJinMaoBackInfo = new FreshAirJinMaoBackInfo(); |
| | | mFreshAirJinMaoBackInfo.setAppliancesInfo(info); |
| | | EventBus.getDefault().post(new FreshAirJinMaoFeedBackEvent(mFreshAirJinMaoBackInfo, false)); |
| | | } |
| | | } |
| | | }, mRequestTimeout); |
| | | |
| | | |
| | | } else { |
| | | HDLLog.I("不是金茂新风系统设备"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取地热状态 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void getGeothermalStateFromNetwork(final AppliancesInfo info) { |
| | | if (info == null) { |
| | | return; |
| | | } |
| | | HDLDeviceManager.isGetDeviceStateSuccess = false; |
| | | switch (info.getDeviceType()) { |
| | | case HDLApConfig.TYPE_GEOTHERMAL_JINMAO: |
| | | case HDLApConfig.TYPE_GEOTHERMAL_MODULE: |
| | | //发送获取地热系统所有数据 |
| | | addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); |
| | | break; |
| | | default: |
| | | HDLLog.I("不是地热设备"); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 控制地热模块温度 |
| | | * |
| | | * @param info |
| | | * @param tempInt 2020-03-15 |
| | | */ |
| | | public static void geothermalCtrlTemp(final AppliancesInfo info, int tempInt) { |
| | | // HDLDeviceManager.isGeothermalCtrlSuccess = false; |
| | | HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); |
| | | if (geothermalCtrlFailTimer != null) { |
| | | geothermalCtrlFailTimer.cancel(); |
| | | geothermalCtrlFailTimer = null; |
| | | } |
| | | if (info.getBigType() == Configuration.GEOTHERMAL_BIG_TYPE) { |
| | | byte[] sendbytes = GeothermalParser.getGeothermalAddByteTemp(info, tempInt); |
| | | addSendData(info, sendbytes, Configuration.CONTROL); |
| | | |
| | | geothermalCtrlFailTimer = new Timer(); |
| | | geothermalCtrlFailTimer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { |
| | | GeothermalBackInfo mGeothermalBackInfo = new GeothermalBackInfo(); |
| | | mGeothermalBackInfo.setAppliancesInfo(info); |
| | | EventBus.getDefault().post(new GeothermalFeedBackEvent(mGeothermalBackInfo, EventCode.FAILURE_TIMEOUT)); |
| | | } |
| | | } |
| | | }, mRequestTimeout); |
| | | |
| | | |
| | | } else { |
| | | HDLLog.I("地热模块控制不在范围内" |
| | | + " LittleType = " + info.getLittleType() |
| | | + " BigType = " + info.getBigType() |
| | | ); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 控制地热模块 |
| | | * |
| | | * @param info |
| | | * @param type |
| | | * @param state 2019-07-10 |
| | | */ |
| | | public static void geothermalCtrl(final AppliancesInfo info, int type, int state) { |
| | | // HDLDeviceManager.isGeothermalCtrlSuccess = false; |
| | | HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); |
| | | if (geothermalCtrlFailTimer != null) { |
| | | geothermalCtrlFailTimer.cancel(); |
| | | geothermalCtrlFailTimer = null; |
| | | } |
| | | if (info.getBigType() == Configuration.GEOTHERMAL_BIG_TYPE) { |
| | | byte[] sendbytes = GeothermalParser.getGeothermalAddByte(info, type, state); |
| | | addSendData(info, sendbytes, Configuration.CONTROL); |
| | | |
| | | geothermalCtrlFailTimer = new Timer(); |
| | | geothermalCtrlFailTimer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { |
| | | GeothermalBackInfo mGeothermalBackInfo = new GeothermalBackInfo(); |
| | | mGeothermalBackInfo.setAppliancesInfo(info); |
| | | EventBus.getDefault().post(new GeothermalFeedBackEvent(mGeothermalBackInfo, EventCode.FAILURE_TIMEOUT)); |
| | | } |
| | | } |
| | | }, 5000); |
| | | |
| | | |
| | | } else { |
| | | HDLLog.I("地热模块控制不在范围内" |
| | | + " LittleType = " + info.getLittleType() |
| | | + " BigType = " + info.getBigType() |
| | | ); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取门锁状态 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void getDoorMachineDeviceStateFromNetwork(final AppliancesInfo info) { |
| | | if (info == null) { |
| | | return; |
| | | } |
| | | HDLDeviceManager.isGetDeviceStateSuccess = false; |
| | | switch (info.getDeviceType()) { |
| | | case HDLApConfig.TYPE_DOOR_MACHINE: |
| | | //发送获取门锁所有数据 |
| | | addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); |
| | | break; |
| | | default: |
| | | HDLLog.I("不是门锁设备"); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 门锁模块 远程开锁获取密钥 |
| | | * 2023-8-25 |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void doorMachineGetSecret(final AppliancesInfo info) { |
| | | if (info.getBigType() == Configuration.DOOR_MACHINE_BIG_TYPE) { |
| | | byte[] sendbytes = new byte[]{(byte) info.getChannelNum()}; |
| | | cusSendCommand(Configuration.DOOR_MACHINE_MODULE_CTRL_FRIST_COMMAND, info.getDeviceSubnetID(), info.getDeviceDeviceID(), sendbytes); |
| | | } else { |
| | | HDLLog.I("不是门锁模块" |
| | | + " LittleType = " + info.getLittleType() |
| | | + " BigType = " + info.getBigType() |
| | | ); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 控制门锁远程开锁 |
| | | * |
| | | * @param info |
| | | * @param secretBytes 密钥 |
| | | * @param password 开锁密码 2023-08-22 |
| | | */ |
| | | public static void doorMachineCtrl(final AppliancesInfo info, byte[] secretBytes, String password, int doorStatus) { |
| | | HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); |
| | | if (doorMachineCtrlFailTimer != null) { |
| | | doorMachineCtrlFailTimer.cancel(); |
| | | doorMachineCtrlFailTimer = null; |
| | | } |
| | | if (info.getBigType() == Configuration.DOOR_MACHINE_BIG_TYPE) { |
| | | byte[] doorMachinebytes = DoorMachineParser.getDoorMachineAddByte(info, secretBytes, password, doorStatus); |
| | | addSendData(info, doorMachinebytes, Configuration.CONTROL); |
| | | doorMachineCtrlFailTimer = new Timer(); |
| | | doorMachineCtrlFailTimer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { |
| | | DoorMachineBackInfo mDoorMachineBackInfo = new DoorMachineBackInfo(); |
| | | mDoorMachineBackInfo.setAppliancesInfo(info); |
| | | EventBus.getDefault().post(new DoorMachineFeedBackEvent(mDoorMachineBackInfo, false)); |
| | | } |
| | | } |
| | | }, mRequestTimeout); |
| | | |
| | | |
| | | } else { |
| | | HDLLog.I("门锁控制不在范围内" |
| | | + " LittleType = " + info.getLittleType() |
| | | + " BigType = " + info.getBigType() |
| | | ); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 门锁模块 设置临时密码 |
| | | * 2023-8-25 |
| | | * |
| | | * @param info |
| | | * @param tempPassword 临时密码 |
| | | * @param startTime 开始时间戳 |
| | | * @param endTime 结束时间戳 |
| | | */ |
| | | public static void doorMachineSettingPwd(final AppliancesInfo info, String tempPassword, String startTime, String endTime) { |
| | | if (info.getBigType() == Configuration.DOOR_MACHINE_BIG_TYPE) { |
| | | byte[] sendbytes = DoorMachineParser.getDoorMachineSettingPwdByte(info, tempPassword, startTime, endTime); |
| | | cusSendCommand(Configuration.DOOR_MACHINE_MODULE_SETTING_PASSWORD_COMMAND, info.getDeviceSubnetID(), info.getDeviceDeviceID(), sendbytes); |
| | | } else { |
| | | HDLLog.I("不是门锁模块" |
| | | + " LittleType = " + info.getLittleType() |
| | | + " BigType = " + info.getBigType() |
| | | ); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 背景音乐控制 |
| | |
| | | sendDatas.count++; |
| | | if (type == Configuration.STATE) { |
| | | sendDatas.command = info.getStateCommand(); |
| | | HDLLog.I("---getDevice: " + info.getDeviceKey() + " ---getStateCommand: " + Integer.toHexString(info.getStateCommand()));//2019-8-2 |
| | | sendDatas.isCtrlSuccess = HDLDeviceManager.isGetDeviceStateSuccess; |
| | | } else if (type == Configuration.CONTROL) { |
| | | sendDatas.command = info.getCtrlCommand(); |
| | | HDLLog.I("getDeviceKey: " + info.getDeviceKey());//2019-8-2 |
| | | HDLLog.I("---getDevice: " + info.getDeviceKey() + " ---getCtrlCommand: " + Integer.toHexString(info.getCtrlCommand()));//2019-8-2 |
| | | sendDatas.isCtrlSuccess = HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info); |
| | | |
| | | // switch (info.getBigType()) { |
| | | // case Configuration.LIGTH_BIG_TYPE: |
| | | // sendDatas.isCtrlSuccess = HDLDeviceManager.isLightCtrlSuccess; |
| | | // break; |
| | | // case Configuration.CURTAIN_BIG_TYPE: |
| | | // sendDatas.isCtrlSuccess = HDLDeviceManager.isCurtainCtrlSuccess; |
| | | // break; |
| | | // case Configuration.AIR_BIG_TYPE: |
| | | // sendDatas.isCtrlSuccess = HDLDeviceManager.isACCtrlSuccess; |
| | | // break; |
| | | // case Configuration.LOGIC_BIG_TYPE: |
| | | // sendDatas.isCtrlSuccess = HDLDeviceManager.isSceneCtrlSuccess; |
| | | // break; |
| | | // case Configuration.SECURITY_BIG_TYPE: |
| | | // sendDatas.isCtrlSuccess = HDLDeviceManager.isSecurityCtrlSuccess; |
| | | // break; |
| | | // default: |
| | | // sendDatas.isCtrlSuccess = false; |
| | | // } |
| | | } |
| | | if (!sendDatas.isCtrlSuccess) { |
| | | HDLLog.I("控制发送第" + sendDatas.count + "次"); |
| | | if (type == Configuration.STATE) { |
| | | HDLLog.I("读取发送第" + sendDatas.count + "次"); |
| | | } else if (type == Configuration.CONTROL) { |
| | | HDLLog.I("控制发送第" + sendDatas.count + "次"); |
| | | } |
| | | cusSendCommand(sendDatas.command, info.getDeviceSubnetID(), info.getDeviceDeviceID(), sendDatas.addBytes); |
| | | } else { |
| | | sendCycleTimer.cancel(); |