| | |
| | | } |
| | | |
| | | |
| | | |
| | | // /** |
| | | // * 获取本地广播IP |
| | | // * @return |
| | |
| | | |
| | | /** |
| | | * 获取本地广播IP |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getLocalBroadCastIp(){ |
| | | public static String getLocalBroadCastIp() { |
| | | return NetWorkUtil.getLocalBroadCast(); |
| | | } |
| | | |
| | | /** |
| | | * 是否开启SDK日志打印 |
| | | * 2019-07-10新增 |
| | | * |
| | | * @param bOpen |
| | | */ |
| | | public static void setHDLLogOpen(boolean bOpen) { |
| | |
| | | // } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取RCU模块的设备 |
| | | * |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取家居设备 |
| | | * |
| | | * @param context |
| | | */ |
| | | public static void getHomeDevices(Context context ,Boolean isZigbee) { |
| | | HandleSearch.getHomeDevices(context,isZigbee); |
| | | public static void getHomeDevices(Context context, Boolean isZigbee) { |
| | | HandleSearch.getHomeDevices(context, isZigbee); |
| | | } |
| | | |
| | | // public static void cancelSearching(){ |
| | |
| | | * @param info |
| | | * @param state |
| | | */ |
| | | public static void lightCtrl(final AppliancesInfo info, int state,boolean isZigbee) { |
| | | if (isZigbee){ |
| | | if (statusReadBackBean != null){ |
| | | if (info.getBigType() == Configuration.LIGTH_BIG_TYPE && info.getLittleType() == 1){//继电器 开关 |
| | | if (statusReadBackBean.getValue() == Configuration.RELAY_ON){ |
| | | HDLCommandText.sendStatus(zigbeeDeviceBean, ZigbeeDeviceID.OnOffOutput,Configuration.RELAY_OFF); |
| | | }else { |
| | | HDLCommandText.sendStatus(zigbeeDeviceBean,ZigbeeDeviceID.OnOffOutput,Configuration.RELAY_ON); |
| | | public static void lightCtrl(final AppliancesInfo info, int state, boolean isZigbee) { |
| | | if (isZigbee) { |
| | | if (statusReadBackBean != null) { |
| | | if (info.getBigType() == Configuration.LIGTH_BIG_TYPE && info.getLittleType() == 1) {//继电器 开关 |
| | | if (statusReadBackBean.getValue() == Configuration.RELAY_ON) { |
| | | HDLCommandText.sendStatus(zigbeeDeviceBean, ZigbeeDeviceID.OnOffOutput, Configuration.RELAY_OFF); |
| | | } else { |
| | | HDLCommandText.sendStatus(zigbeeDeviceBean, ZigbeeDeviceID.OnOffOutput, Configuration.RELAY_ON); |
| | | } |
| | | } |
| | | if (info.getBigType() == Configuration.LIGTH_BIG_TYPE && info.getLittleType() == 0){//调光器 开到固定的值或者开到0 |
| | | if (info.getBigType() == Configuration.LIGTH_BIG_TYPE && info.getLittleType() == 0) {//调光器 开到固定的值或者开到0 |
| | | int value = (int) (state * 2.55); |
| | | if (statusReadBackBean.getValue()!=0){ |
| | | if (statusReadBackBean.getValue() != 0) { |
| | | //lightStatus = 0; |
| | | HDLCommandText.sendStatus(zigbeeDeviceBean,ZigbeeDeviceID.DimmableLight,0); |
| | | }else { |
| | | HDLCommandText.sendStatus(zigbeeDeviceBean, ZigbeeDeviceID.DimmableLight, 0); |
| | | } else { |
| | | //lightStatus = value; |
| | | HDLCommandText.sendStatus(zigbeeDeviceBean,ZigbeeDeviceID.DimmableLight,value); |
| | | HDLCommandText.sendStatus(zigbeeDeviceBean, ZigbeeDeviceID.DimmableLight, value); |
| | | } |
| | | } |
| | | }else { |
| | | } else { |
| | | HDLLog.info("为获取到设备状态"); |
| | | } |
| | | |
| | | }else { |
| | | } else { |
| | | // HDLDeviceManager.isLightCtrlSuccess = false; |
| | | HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); |
| | | if (lightCtrlFailTimer != null) { |
| | |
| | | * @param info |
| | | * @param state 调整的值 |
| | | */ |
| | | public static void curtainCtrl(final AppliancesInfo info, int state,boolean isZigbee) { |
| | | if (isZigbee){ |
| | | switch (state){ |
| | | case CurtainCtrlParser.curtainOn: |
| | | HDLCommandText.sendCurtainStatus(zigbeeDeviceBean,ZigbeeDeviceID.WindowCoveringDevice,0,0);//value = 0为开,tag = 0为标记控制 |
| | | public static void curtainCtrl(final AppliancesInfo info, int state, boolean isZigbee) { |
| | | if (isZigbee) { |
| | | switch (state) { |
| | | case CurtainCtrlParser.curtainOn: |
| | | HDLCommandText.sendCurtainStatus(zigbeeDeviceBean, ZigbeeDeviceID.WindowCoveringDevice, 0, 0);//value = 0为开,tag = 0为标记控制 |
| | | break; |
| | | case CurtainCtrlParser.curtainOff: |
| | | HDLCommandText.sendCurtainStatus(zigbeeDeviceBean,ZigbeeDeviceID.WindowCoveringDevice,1,0);//value = 1为关,tag = 0为标记控制 |
| | | case CurtainCtrlParser.curtainOff: |
| | | HDLCommandText.sendCurtainStatus(zigbeeDeviceBean, ZigbeeDeviceID.WindowCoveringDevice, 1, 0);//value = 1为关,tag = 0为标记控制 |
| | | break; |
| | | case CurtainCtrlParser.curtainPause: |
| | | HDLCommandText.sendCurtainStatus(zigbeeDeviceBean,ZigbeeDeviceID.WindowCoveringDevice,2,0);//value = 2为暂停,tag = 0为标记控制 |
| | | HDLCommandText.sendCurtainStatus(zigbeeDeviceBean, ZigbeeDeviceID.WindowCoveringDevice, 2, 0);//value = 2为暂停,tag = 0为标记控制 |
| | | break; |
| | | default: |
| | | HDLCommandText.sendCurtainStatus(zigbeeDeviceBean,ZigbeeDeviceID.WindowCoveringDevice,state,1);//value = state为调整数值,tag = 1为标记数值控制 |
| | | HDLCommandText.sendCurtainStatus(zigbeeDeviceBean, ZigbeeDeviceID.WindowCoveringDevice, state, 1);//value = state为调整数值,tag = 1为标记数值控制 |
| | | break; |
| | | } |
| | | }else { |
| | | } else { |
| | | HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); |
| | | if (curtainCtrlFailTimer != null) { |
| | | curtainCtrlFailTimer.cancel(); |
| | |
| | | * @param type |
| | | * @param state |
| | | */ |
| | | public static void airCtrl(final AppliancesInfo info, int type, int state , boolean isZigbee) { |
| | | if (isZigbee){ |
| | | switch (type){ |
| | | public static void airCtrl(final AppliancesInfo info, int type, int state, boolean isZigbee) { |
| | | if (isZigbee) { |
| | | switch (type) { |
| | | case AirCtrlParser.airSwich: |
| | | //开关选择 |
| | | switch (state){ |
| | | switch (state) { |
| | | case AirCtrlParser.airOn://空调开 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,1,0,0);//value = 1为空调开 tag = 0为标志为开关控制 mode忽略 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean, ZigbeeDeviceID.Thermostat, 1, 0, 0);//value = 1为空调开 tag = 0为标志为开关控制 mode忽略 |
| | | break; |
| | | case AirCtrlParser.airOff://空调关 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,0,0,0);//value = 0为空调开 tag = 0为标志为开关控制 mode忽略 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean, ZigbeeDeviceID.Thermostat, 0, 0, 0);//value = 0为空调开 tag = 0为标志为开关控制 mode忽略 |
| | | break; |
| | | } |
| | | break; |
| | | case AirCtrlParser.airMode: |
| | | //恒温器模式选择 |
| | | switch (state){ |
| | | switch (state) { |
| | | case AirCtrlParser.airModeHeatTem://空调模式制热 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,4,1,0);//value = 4为恒温器制热 tag = 1为标志为恒温器控制 mode忽略 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean, ZigbeeDeviceID.Thermostat, 4, 1, 0);//value = 4为恒温器制热 tag = 1为标志为恒温器控制 mode忽略 |
| | | break; |
| | | case AirCtrlParser.airModeVen://空调模式通风 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,7,1,0);//value = 7为恒温器通风 tag = 1为标志为恒温器控制 mode忽略 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean, ZigbeeDeviceID.Thermostat, 7, 1, 0);//value = 7为恒温器通风 tag = 1为标志为恒温器控制 mode忽略 |
| | | break; |
| | | case AirCtrlParser.airModeAuto://空调模式自动 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,1,1,0);//value = 1为恒温器自动 tag = 1为标志为恒温器控制 mode忽略 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean, ZigbeeDeviceID.Thermostat, 1, 1, 0);//value = 1为恒温器自动 tag = 1为标志为恒温器控制 mode忽略 |
| | | break; |
| | | case AirCtrlParser.airModeDehum://空调模式抽湿 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,8,1,0);//value = 8为恒温器抽湿 tag = 1为标志为恒温器控制 mode忽略 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean, ZigbeeDeviceID.Thermostat, 8, 1, 0);//value = 8为恒温器抽湿 tag = 1为标志为恒温器控制 mode忽略 |
| | | break; |
| | | case AirCtrlParser.airModeRefTem://空调模式制冷 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,3,1,0);//value = 3为恒温器制冷 tag = 1为标志为恒温器控制 mode忽略 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean, ZigbeeDeviceID.Thermostat, 3, 1, 0);//value = 3为恒温器制冷 tag = 1为标志为恒温器控制 mode忽略 |
| | | break; |
| | | } |
| | | break; |
| | | case AirCtrlParser.airSpeed: |
| | | //风速模式选择 |
| | | switch (state){ |
| | | switch (state) { |
| | | case AirCtrlParser.airSpeedHigh://风速高风 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,3,2,0);//value = 3为风速高风 tag = 2为标志为风速控制 mode忽略 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean, ZigbeeDeviceID.Thermostat, 3, 2, 0);//value = 3为风速高风 tag = 2为标志为风速控制 mode忽略 |
| | | break; |
| | | case AirCtrlParser.airSpeedMid://风速中风 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,2,2,0);//value = 2为风速中风 tag = 2为标志为风速控制 mode忽略 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean, ZigbeeDeviceID.Thermostat, 2, 2, 0);//value = 2为风速中风 tag = 2为标志为风速控制 mode忽略 |
| | | break; |
| | | case AirCtrlParser.airSpeedLow://风速低风 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,1,2,0);//value = 1为风速低风 tag = 2为标志为风速控制 mode忽略 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean, ZigbeeDeviceID.Thermostat, 1, 2, 0);//value = 1为风速低风 tag = 2为标志为风速控制 mode忽略 |
| | | break; |
| | | case AirCtrlParser.airSpeedAuto://风速自动 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,5,2,0);//value = 5为风速自动 tag = 2为标志为风速控制 mode忽略 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean, ZigbeeDeviceID.Thermostat, 5, 2, 0);//value = 5为风速自动 tag = 2为标志为风速控制 mode忽略 |
| | | break; |
| | | } |
| | | break; |
| | | case AirCtrlParser.dehumTem://当前空调模式为抽湿 |
| | | case AirCtrlParser.refTem: //当前空调模式为制冷 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,state,3,1);//value = state为温度值 tag = 3为标志为温度控制 mode = 1为制冷 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean, ZigbeeDeviceID.Thermostat, state, 3, 1);//value = state为温度值 tag = 3为标志为温度控制 mode = 1为制冷 |
| | | break; |
| | | case AirCtrlParser.heatTem://当前空调模式为制热 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,state,3,0);//value = state为温度值 tag = 3为标志为温度控制 mode = 0为制热 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean, ZigbeeDeviceID.Thermostat, state, 3, 0);//value = state为温度值 tag = 3为标志为温度控制 mode = 0为制热 |
| | | break; |
| | | case AirCtrlParser.autoTem://当前空调模式为自动 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,state,3,2);//value = state为温度值 tag = 3为标志为温度控制 mode = 2为自动 |
| | | HDLCommandText.sendAirStatus(zigbeeDeviceBean, ZigbeeDeviceID.Thermostat, state, 3, 2);//value = state为温度值 tag = 3为标志为温度控制 mode = 2为自动 |
| | | break; |
| | | } |
| | | }else { |
| | | } else { |
| | | // HDLDeviceManager.isACCtrlSuccess = false; |
| | | HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); |
| | | if (acCtrlFailTimer != null) { |
| | |
| | | * @param type |
| | | * @param state 2019-07-09 |
| | | */ |
| | | public static void freshAirCtrl(final AppliancesInfo info, int type, int state,boolean isZigbee) { |
| | | if (isZigbee){ |
| | | switch (type){ |
| | | public static void freshAirCtrl(final AppliancesInfo info, int type, int state, boolean isZigbee) { |
| | | if (isZigbee) { |
| | | switch (type) { |
| | | case FreshAirParser.freshAirSwich: |
| | | switch (state){ |
| | | case FreshAirParser.freshAirOn: |
| | | HDLCommandText.sendStatus(zigbeeDeviceBean,ZigbeeDeviceID.AirPanel,1);//value = 1为新风开 |
| | | break; |
| | | case FreshAirParser.freshAirOff: |
| | | HDLCommandText.sendStatus(zigbeeDeviceBean,ZigbeeDeviceID.AirPanel,0);//value = 0为新风关 |
| | | break; |
| | | } |
| | | break; |
| | | switch (state) { |
| | | case FreshAirParser.freshAirOn: |
| | | HDLCommandText.sendStatus(zigbeeDeviceBean, ZigbeeDeviceID.AirPanel, 1);//value = 1为新风开 |
| | | break; |
| | | case FreshAirParser.freshAirOff: |
| | | HDLCommandText.sendStatus(zigbeeDeviceBean, ZigbeeDeviceID.AirPanel, 0);//value = 0为新风关 |
| | | break; |
| | | } |
| | | break; |
| | | case FreshAirParser.freshAirSpeed://高风、低风 |
| | | switch (state){ |
| | | switch (state) { |
| | | case FreshAirParser.freshAirSpeedMid://控制成高风 |
| | | HDLCommandText.sendStatus(zigbeeDeviceBean,ZigbeeDeviceID.AirPanel,3);//value = 3为新风高风 |
| | | HDLCommandText.sendStatus(zigbeeDeviceBean, ZigbeeDeviceID.AirPanel, 3);//value = 3为新风高风 |
| | | break; |
| | | case FreshAirParser.freshAirSpeedLow://控制成低速 |
| | | case FreshAirParser.freshAirSpeedOff: |
| | | HDLCommandText.sendStatus(zigbeeDeviceBean,ZigbeeDeviceID.AirPanel,1);//value = 1为新风低风 |
| | | HDLCommandText.sendStatus(zigbeeDeviceBean, ZigbeeDeviceID.AirPanel, 1);//value = 1为新风低风 |
| | | break; |
| | | } |
| | | break; |
| | | } |
| | | }else { |
| | | } else { |
| | | // HDLDeviceManager.isFreshAirCtrlSuccess = false; |
| | | HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); |
| | | if (freshAirCtrlFailTimer != null) { |
| | |
| | | * |
| | | * @param info |
| | | */ |
| | | public static void logicCtrl(final AppliancesInfo info,final boolean isZigbee) { |
| | | if (isZigbee){ |
| | | HDLCommandText.sendSceneStatus(zigbeeSceneBean.getScenesId(),0);//控制场景的id,延时时间为0 |
| | | }else { |
| | | public static void logicCtrl(final AppliancesInfo info, final boolean isZigbee) { |
| | | if (isZigbee) { |
| | | HDLCommandText.sendSceneStatus(zigbeeSceneBean.getScenesId(), 0);//控制场景的id,延时时间为0 |
| | | } else { |
| | | // HDLDeviceManager.isSceneCtrlSuccess = false; |
| | | HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); |
| | | |
| | |
| | | // }, 5000); |
| | | // |
| | | // } |
| | | |
| | | /** |
| | | * 获取单一设备状态 |
| | | */ |
| | | public static void getDeviceState(Context context,final AppliancesInfo appliancesInfo,boolean isZigbee) { |
| | | if (isZigbee){ |
| | | zigbeeDeviceDatas = SPUtils.getZigbeeDeviceSaveBean(context,SPUtils.KEY_ZIGBEE_IP); |
| | | zigbeeSceneDatas = SPUtils.getZigbeeSceneSaveBean(context,SPUtils.KEY_ZIGBEE_SCENE_IP); |
| | | public static void getDeviceState(Context context, final AppliancesInfo appliancesInfo, boolean isZigbee) { |
| | | if (isZigbee) { |
| | | zigbeeDeviceDatas = SPUtils.getZigbeeDeviceSaveBean(context, SPUtils.KEY_ZIGBEE_IP); |
| | | zigbeeSceneDatas = SPUtils.getZigbeeSceneSaveBean(context, SPUtils.KEY_ZIGBEE_SCENE_IP); |
| | | HDLCommandText hdlCommandText = new HDLCommandText(); |
| | | for (ZigbeeDeviceSaveBean zigbeeDeviceSaveBean : zigbeeDeviceDatas){ |
| | | if (appliancesInfo.getBigType() == Configuration.LIGTH_BIG_TYPE && appliancesInfo.getLittleType() == 1){ |
| | | for (ZigbeeDeviceSaveBean zigbeeDeviceSaveBean : zigbeeDeviceDatas) { |
| | | if (appliancesInfo.getBigType() == Configuration.LIGTH_BIG_TYPE && appliancesInfo.getLittleType() == 1) { |
| | | //继电器 |
| | | type = ZigbeeDeviceID.OnOffOutput; |
| | | if (zigbeeDeviceSaveBean.getmSubnetID() == appliancesInfo.getDeviceSubnetID() && |
| | |
| | | } |
| | | } |
| | | |
| | | if (appliancesInfo.getBigType() == Configuration.LIGTH_BIG_TYPE && appliancesInfo.getLittleType() == 0){ |
| | | if (appliancesInfo.getBigType() == Configuration.LIGTH_BIG_TYPE && appliancesInfo.getLittleType() == 0) { |
| | | //调光器 |
| | | type = ZigbeeDeviceID.DimmableLight; |
| | | if (zigbeeDeviceSaveBean.getmSubnetID() == appliancesInfo.getDeviceSubnetID() && |
| | |
| | | HDLCommandText.initStatus(zigbeeDeviceSaveBean, ZigbeeDeviceID.DimmableLight); |
| | | } |
| | | } |
| | | if (appliancesInfo.getBigType() == Configuration.CURTAIN_BIG_TYPE && appliancesInfo.getLittleType() == 0){ |
| | | if (appliancesInfo.getBigType() == Configuration.CURTAIN_BIG_TYPE && appliancesInfo.getLittleType() == 0) { |
| | | //窗帘 |
| | | type = ZigbeeDeviceID.WindowCoveringDevice; |
| | | if (zigbeeDeviceSaveBean.getmSubnetID() == appliancesInfo.getDeviceSubnetID() && |
| | |
| | | HDLCommandText.initStatus(zigbeeDeviceSaveBean, ZigbeeDeviceID.WindowCoveringDevice); |
| | | } |
| | | } |
| | | if (appliancesInfo.getBigType() ==Configuration.AIR_BIG_TYPE && appliancesInfo.getLittleType() == 0){ |
| | | if (appliancesInfo.getBigType() == Configuration.AIR_BIG_TYPE && appliancesInfo.getLittleType() == 0) { |
| | | //空调 |
| | | type = ZigbeeDeviceID.Thermostat; |
| | | if (zigbeeDeviceSaveBean.getmSubnetID() == appliancesInfo.getDeviceSubnetID() && |
| | |
| | | HDLCommandText.initStatus(zigbeeDeviceSaveBean, ZigbeeDeviceID.Thermostat); |
| | | } |
| | | } |
| | | if (appliancesInfo.getBigType() ==Configuration.FRESH_AIR_BIG_TYPE && appliancesInfo.getLittleType() == 0){ |
| | | if (appliancesInfo.getBigType() == Configuration.FRESH_AIR_BIG_TYPE && appliancesInfo.getLittleType() == 0) { |
| | | //新风 |
| | | type = ZigbeeDeviceID.AirPanel; |
| | | if (zigbeeDeviceSaveBean.getmSubnetID() == appliancesInfo.getDeviceSubnetID() && |
| | |
| | | } |
| | | } |
| | | } |
| | | for (ZigbeeSceneSaveBean zigbeeSceneSaveBean : zigbeeSceneDatas){ |
| | | if (appliancesInfo.getBigType() == Configuration.GLOBAL_LOGIC_BIG_TYPE && appliancesInfo.getLittleType() == 0){ |
| | | for (ZigbeeSceneSaveBean zigbeeSceneSaveBean : zigbeeSceneDatas) { |
| | | if (appliancesInfo.getBigType() == Configuration.GLOBAL_LOGIC_BIG_TYPE && appliancesInfo.getLittleType() == 0) { |
| | | //场景 |
| | | type = ZigbeeDeviceID.SceneMark; |
| | | if (zigbeeSceneSaveBean.getSubnetId() == appliancesInfo.getDeviceSubnetID() && |
| | |
| | | } |
| | | } |
| | | } |
| | | Log.d("11113", "type: "+type); |
| | | Log.d("11113", "type: " + type); |
| | | //读写状态信息回调 |
| | | HDLCommandText.setStateListener(new StateListener() { |
| | | @Override |
| | | public void onData(final StateEvent event) { |
| | | //上报zigbee回馈信息 |
| | | Log.d("11113", "zigbee 回馈json:" + event.getJson()); |
| | | switch (type){ |
| | | switch (type) { |
| | | case ZigbeeDeviceID.OnOffOutput: |
| | | //继电器设备回调 |
| | | statusReadBackBean = JsonUtil.parseJsonWithGson(event.getJson(), StatusReadBackBean.class); |
| | | if (statusReadBackBean.getValue() == Configuration.RELAY_ON){ |
| | | if (statusReadBackBean.getValue() == Configuration.RELAY_ON) { |
| | | //继电器关 |
| | | appliancesInfo.setCurState(0); |
| | | EventBus.getDefault().post(new DeviceStateEvent(appliancesInfo, true)); |
| | | }else { |
| | | } else { |
| | | //继电器开 |
| | | appliancesInfo.setCurState(100); |
| | | EventBus.getDefault().post(new DeviceStateEvent(appliancesInfo, true)); |
| | | } |
| | | break; |
| | | case ZigbeeDeviceID.WindowCoveringDevice: |
| | | //窗帘设备回调 |
| | | statusReadBackBean = JsonUtil.parseJsonWithGson(event.getJson(), StatusReadBackBean.class); |
| | | case ZigbeeDeviceID.WindowCoveringDevice: |
| | | //窗帘设备回调 |
| | | statusReadBackBean = JsonUtil.parseJsonWithGson(event.getJson(), StatusReadBackBean.class); |
| | | appliancesInfo.setCurState(statusReadBackBean.getValue()); |
| | | EventBus.getDefault().post(new DeviceStateEvent(appliancesInfo,true)); |
| | | EventBus.getDefault().post(new DeviceStateEvent(appliancesInfo, true)); |
| | | break; |
| | | case ZigbeeDeviceID.DimmableLight: |
| | | //调光器设备 |
| | | statusReadBackBean = JsonUtil.parseJsonWithGson(event.getJson(), StatusReadBackBean.class); |
| | | Log.d("2222", "回调数据: "+statusReadBackBean.getValue()); |
| | | Log.d("2222", "回调数据: " + statusReadBackBean.getValue()); |
| | | appliancesInfo.setCurState(statusReadBackBean.getValue()); |
| | | EventBus.getDefault().post(new DeviceStateEvent(appliancesInfo,true)); |
| | | EventBus.getDefault().post(new DeviceStateEvent(appliancesInfo, true)); |
| | | break; |
| | | case ZigbeeDeviceID.Thermostat: |
| | | //温度设备 |
| | | thermostatReadBean = JsonUtil.parseJsonWithGson(event.getJson(),StatusThermostatReadBean.class); |
| | | thermostatReadBean = JsonUtil.parseJsonWithGson(event.getJson(), StatusThermostatReadBean.class); |
| | | int fanMode = thermostatReadBean.getFanmode(); //新风模式 0:Off、1:Low、2:Medium、3:High、4:On、5:Auto、6:Smart |
| | | int thermostatMode = thermostatReadBean.getThermostatmode();//恒温模式 0:Off、1:Auto、3:Cool、4:Heat、5:Emergency heating、6:Precooling、7:Fan only、8:Dry、9:Sleep; |
| | | int coolingSetpoint = thermostatReadBean.getCoolingSetpoint();//制冷温度 |
| | | int heatingSetpoint = thermostatReadBean.getHeatingSetpoint();//制热温度 |
| | | int tag = thermostatReadBean.getTag(); |
| | | switch (tag){ |
| | | switch (tag) { |
| | | case 0://开关模式返回 |
| | | if (fanMode == 0 && thermostatMode == 0){ |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSwich,AirCtrlParser.airOff)); //空调关 |
| | | }else { |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSwich,AirCtrlParser.airOn));//空调开 |
| | | if (fanMode == 0 && thermostatMode == 0) { |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSwich, AirCtrlParser.airOff)); //空调关 |
| | | } else { |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSwich, AirCtrlParser.airOn));//空调开 |
| | | } |
| | | break; |
| | | case 1://恒温器模式返回 |
| | | if (fanMode ==0 && thermostatMode == 0){ |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSwich,AirCtrlParser.airOff));//空调关 |
| | | }else { |
| | | switch (thermostatMode){ |
| | | case 1://自动模式 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airMode,AirCtrlParser.airModeAuto)); |
| | | break; |
| | | case 3://制冷模式 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airMode,AirCtrlParser.airModeRefTem)); |
| | | break; |
| | | case 4://制热模式 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airMode,AirCtrlParser.airModeHeatTem)); |
| | | break; |
| | | case 7://通风模式 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airMode,AirCtrlParser.airModeVen)); |
| | | break; |
| | | case 8://抽湿模式 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airMode,AirCtrlParser.airModeDehum)); |
| | | break; |
| | | } |
| | | if (fanMode == 0 && thermostatMode == 0) { |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSwich, AirCtrlParser.airOff));//空调关 |
| | | } else { |
| | | switch (thermostatMode) { |
| | | case 1://自动模式 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airMode, AirCtrlParser.airModeAuto)); |
| | | break; |
| | | case 3://制冷模式 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airMode, AirCtrlParser.airModeRefTem)); |
| | | break; |
| | | case 4://制热模式 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airMode, AirCtrlParser.airModeHeatTem)); |
| | | break; |
| | | case 7://通风模式 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airMode, AirCtrlParser.airModeVen)); |
| | | break; |
| | | case 8://抽湿模式 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airMode, AirCtrlParser.airModeDehum)); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | break; |
| | | case 2://通风器模式返回 |
| | | if (fanMode == 0 && thermostatMode == 0){ |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSwich,AirCtrlParser.airOff)); //空调关 |
| | | }else { |
| | | switch (fanMode){ |
| | | if (fanMode == 0 && thermostatMode == 0) { |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSwich, AirCtrlParser.airOff)); //空调关 |
| | | } else { |
| | | switch (fanMode) { |
| | | case 1://低风 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSpeed,AirCtrlParser.airSpeedLow)); |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSpeed, AirCtrlParser.airSpeedLow)); |
| | | break; |
| | | case 2://中风 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSpeed,AirCtrlParser.airSpeedMid)); |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSpeed, AirCtrlParser.airSpeedMid)); |
| | | break; |
| | | case 3://高风 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSpeed,AirCtrlParser.airSpeedHigh)); |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSpeed, AirCtrlParser.airSpeedHigh)); |
| | | break; |
| | | case 5://自动 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSpeed,AirCtrlParser.airSpeedAuto)); |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSpeed, AirCtrlParser.airSpeedAuto)); |
| | | break; |
| | | } |
| | | } |
| | | break; |
| | | case 3://设置温度模式返回 |
| | | if (fanMode == 0 && thermostatMode == 0){ |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSwich,AirCtrlParser.airOff)); //空调关 |
| | | }else { |
| | | switch (thermostatMode){ |
| | | if (fanMode == 0 && thermostatMode == 0) { |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSwich, AirCtrlParser.airOff)); //空调关 |
| | | } else { |
| | | switch (thermostatMode) { |
| | | case 1://TODO 自动模式温度返回需要协议上的 |
| | | if (coolingSetpoint !=0 && heatingSetpoint ==0 ){ |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.autoTem,coolingSetpoint)); |
| | | }else { |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.autoTem,heatingSetpoint)); |
| | | if (coolingSetpoint != 0 && heatingSetpoint == 0) { |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.autoTem, coolingSetpoint)); |
| | | } else { |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.autoTem, heatingSetpoint)); |
| | | } |
| | | break; |
| | | case 3://制冷模式 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.refTem,coolingSetpoint)); |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.refTem, coolingSetpoint)); |
| | | break; |
| | | case 4://制热模式 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.heatTem,heatingSetpoint)); |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.heatTem, heatingSetpoint)); |
| | | break; |
| | | case 8://抽湿模式 |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.dehumTem,coolingSetpoint)); |
| | | appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.dehumTem, coolingSetpoint)); |
| | | break; |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | EventBus.getDefault().post(new DeviceStateEvent(appliancesInfo,true)); |
| | | EventBus.getDefault().post(new DeviceStateEvent(appliancesInfo, true)); |
| | | break; |
| | | case ZigbeeDeviceID.AirPanel: |
| | | //新风设备回调 |
| | | statusReadBackBean = JsonUtil.parseJsonWithGson(event.getJson(), StatusReadBackBean.class); |
| | | FreshAirBackInfo freshAirBackInfo = new FreshAirBackInfo(); |
| | | freshAirBackInfo.setAppliancesInfo(appliancesInfo); |
| | | switch (statusReadBackBean.getValue()){ |
| | | switch (statusReadBackBean.getValue()) { |
| | | case 0://风扇关 |
| | | freshAirBackInfo.setIsOn(0); |
| | | freshAirBackInfo.setFreshAirSpeed(0); |
| | |
| | | case 255: |
| | | break; |
| | | } |
| | | EventBus.getDefault().post(new FreshAirFeedBackEvent(freshAirBackInfo,true)); |
| | | EventBus.getDefault().post(new FreshAirFeedBackEvent(freshAirBackInfo, true)); |
| | | break; |
| | | case ZigbeeDeviceID.SceneMark: |
| | | //场景回调 |
| | | statusReadBackBean = JsonUtil.parseJsonWithGson(event.getJson(),StatusReadBackBean.class); |
| | | if (statusReadBackBean.getValue() == 1){ |
| | | statusReadBackBean = JsonUtil.parseJsonWithGson(event.getJson(), StatusReadBackBean.class); |
| | | if (statusReadBackBean.getValue() == 1) { |
| | | LogicCtrlBackInfo logicCtrlBackInfo = new LogicCtrlBackInfo(); |
| | | logicCtrlBackInfo.setAppliancesInfo(appliancesInfo); |
| | | EventBus.getDefault().post(new LogicFeedBackEvent(logicCtrlBackInfo, true)); |
| | |
| | | } |
| | | } |
| | | }); |
| | | }else { |
| | | } else { |
| | | if (appliancesInfo == null) { |
| | | return; |
| | | } |
| | |
| | | && info.getChannelNum() == infos.get(j).getChannelNum() |
| | | ) { |
| | | //这里应该是要修复的,暂时未找到。 |
| | | //20190712解决强制转换int类型闪退 |
| | | int state = HDLUtlis.getIntegerByObject(infos.get(j).getCurStateObject()); |
| | | //20190712解决强制转换int类型闪退 |
| | | int state = HDLUtlis.getIntegerByObject(infos.get(j).getCurStateObject()); |
| | | switch (state) { |
| | | case -1: |
| | | curState = 0; |