JLChen
2019-11-26 d6d95564b016c281bfa2e8c2454db8d71083e858
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java
@@ -27,6 +27,7 @@
import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LightFeedBackEvent;
import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent;
import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog;
import com.hdl.sdk.hdl_core.Util.NetUtil.NetWorkUtil;
import com.hdl.sdk.hdl_core.Util.SPUtil.SPUtils;
import com.hdl.sdk.hdl_core.Util.TransformUtil.HDLUtlis;
@@ -63,6 +64,21 @@
        HDLDeviceManager.init(context);
    }
//    /**
//     * 获取本地广播IP
//     * @return
//     */
//    public static String getLocalBroadCastIp(){
//        return NetWorkUtil.getLocalBroadCast();
//    }
    /**
     * 获取本地广播IP
     * @return
     */
    public static String getLocalBroadCastIp(){
        return NetWorkUtil.getLocalBroadCast();
    }
    /**
     * 是否开启SDK日志打印
@@ -617,7 +633,7 @@
            }
        }
        //更新所有设备状态
        HandleSearch.refreshAllDevicesState();
//        HandleSearch.refreshAllDevicesState(30);
        if (!deviceStateBeanList.isEmpty()) {
            return deviceStateBeanList;
        } else {
@@ -649,7 +665,7 @@
                    ) {
//                        curState = (int) infos.get(j).getCurState();//旧
                        //20190712解决强制转换int类型闪退
                        curState = HDLUtlis.getIntegerByObject(infos.get(j).getCurState());
                        curState = HDLUtlis.getIntegerByObject(infos.get(j).getCurStateObject());
                        break outter;
                    }
@@ -680,7 +696,7 @@
                    ) {
                        //这里应该是要修复的,暂时未找到。
                         //20190712解决强制转换int类型闪退
                        int  state = HDLUtlis.getIntegerByObject(infos.get(j).getCurState());
                        int  state = HDLUtlis.getIntegerByObject(infos.get(j).getCurStateObject());
                        switch (state) {
                            case -1:
                                curState = 0;
@@ -815,7 +831,7 @@
//            HDLLog.info("发出数据:"+sendData+"子网id:"+info.getDeviceSubnetID()+" 设备id:"+info.getDeviceDeviceID());
            cusSendCommand(command,
                    info.getDeviceSubnetID(), info.getDeviceDeviceID(), musicBytes,
                    info.getPort(), info.getIpAddress());
                    info.getPort(), getLocalBroadCastIp());
        }
    }
@@ -857,7 +873,7 @@
//            HDLLog.info("发出数据:"+sendData+"子网id:"+info.getDeviceSubnetID()+" 设备id:"+info.getDeviceDeviceID());
            cusSendCommand(command,
                    info.getDeviceSubnetID(), info.getDeviceDeviceID(), musicBytes,
                    info.getPort(), info.getIpAddress());
                    info.getPort(), getLocalBroadCastIp());
        }
    }
@@ -891,7 +907,7 @@
//            HDLLog.info("发出数据:"+sendData+"子网id:"+info.getDeviceSubnetID()+" 设备id:"+info.getDeviceDeviceID());
            cusSendCommand(command,
                    info.getDeviceSubnetID(), info.getDeviceDeviceID(), musicBytes,
                    info.getPort(), info.getIpAddress());
                    info.getPort(), getLocalBroadCastIp());
        }
    }
@@ -920,7 +936,7 @@
     */
    private static void addSendData(final AppliancesInfo info, byte[] addBytes, final int type) {
        final Crc sendDatas = new Crc(info.getStateCommand(), info.getDeviceSubnetID(), info.getDeviceDeviceID(), addBytes, info.getPort(), info.getIpAddress());
        final Crc sendDatas = new Crc(info.getStateCommand(), info.getDeviceSubnetID(), info.getDeviceDeviceID(), addBytes, info.getPort(), getLocalBroadCastIp());
        sendDatas.count = 0;
@@ -966,7 +982,7 @@
//                        }
                    }
                    if (!sendDatas.isCtrlSuccess) {
                        cusSendCommand(sendDatas.command, info.getDeviceSubnetID(), info.getDeviceDeviceID(), sendDatas.addBytes, info.getPort(), info.getIpAddress());
                        cusSendCommand(sendDatas.command, info.getDeviceSubnetID(), info.getDeviceDeviceID(), sendDatas.addBytes, info.getPort(), getLocalBroadCastIp());
                    } else {
//                        HDLLog.info("控制已成功,停止");
                        sendCycleTimer.cancel();