| | |
| | | * @param commandType 命令类型 |
| | | */ |
| | | public static void handle(UdpDataBean getDatas, int commandType) { |
| | | // Log.e("panlili", "commandType=" + Integer.toHexString(commandType) + " sourceSubnetID=" + getDatas.sourceSubnetID + " sourceDeviceID=" + getDatas.sourceDeviceID); |
| | | Log.e("panlili", "commandType=" + Integer.toHexString(commandType) + " sourceSubnetID=" + getDatas.sourceSubnetID + " sourceDeviceID=" + getDatas.sourceDeviceID); |
| | | switch (commandType) { |
| | | case Configuration.SEARCH_GATEWAY_BACK_COMMAND: |
| | | break; |
| | |
| | | * |
| | | * @param getDatas |
| | | */ |
| | | private static void handleSearchData(UdpDataBean getDatas) { |
| | | private static synchronized void handleSearchData(UdpDataBean getDatas) { |
| | | |
| | | DevicesData devicesData = new DevicesData(); |
| | | devicesData.setSourceSubnetID(getDatas.sourceSubnetID); |
| | |
| | | EventBus.getDefault().post(new DiscoverNewDevicesEvent(devicesData)); |
| | | |
| | | //过滤掉背景音乐,背景音乐没有备注返回 |
| | | if (devicesDataList.get(devicesDataList.size() - 1).getAppliancesInfoList().get(0).getBigType() != Configuration.AUDIO_BIG_TYPE) { |
| | | for (int i = 0, len = devicesDataList.get(devicesDataList.size() - 1).getAppliancesInfoList().size(); i < len; i++) { |
| | | if (devicesData.getAppliancesInfoList().get(0).getBigType() != Configuration.AUDIO_BIG_TYPE) { |
| | | for (int i = 0, len = devicesData.getAppliancesInfoList().size(); i < len; i++) { |
| | | ListRemarks listRemarksTemp = new ListRemarks(); |
| | | listRemarksTemp.setCallBack(false); |
| | | listRemarksTemp.setAppliancesInfo(devicesDataList.get(devicesDataList.size() - 1).getAppliancesInfoList().get(i)); |
| | | AppliancesInfo appliancesInfo = devicesData.getAppliancesInfoList().get(i); |
| | | Log.d("panlili", "HDLDeviceManager.java:handleSearchData----->getChannelNum= " + appliancesInfo.getChannelNum() + " getDeviceKey=" + appliancesInfo.getDeviceKey()); |
| | | listRemarksTemp.setAppliancesInfo(appliancesInfo); |
| | | listRemarks.add(listRemarksTemp); |
| | | } |
| | | } |
| | |
| | | for (int appPos = 0, len2 = infos.size(); appPos < len2; appPos++) { |
| | | if ((infos.get(appPos).getDeviceSubnetID()) == (getDatas.addBytes[0] & 0xFF) |
| | | && (infos.get(appPos).getDeviceDeviceID()) == (getDatas.addBytes[1] & 0xFF) |
| | | && ((infos.get(appPos).getChannelNum()) == (getDatas.addBytes[2] & 0xFF)) |
| | | && ((infos.get(appPos).getDeviceIndex()) == (getDatas.addBytes[2] & 0xFF))//序号 |
| | | && (infos.get(appPos).getBigType()) == (getDatas.addBytes[3] & 0xFF) |
| | | && ((infos.get(appPos).getLittleType()) == (getDatas.addBytes[4] & 0xFF))) { |
| | | |
| | |
| | | HDLLog.I("remarkStr获取的备注名为:" + remarkStr); |
| | | devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setChannelNum(getDatas.addBytes[5] & 0xFF); |
| | | devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setRemarks(remarkStr); |
| | | // HDLLog.I("getRemarks():" + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getRemarks()); |
| | | |
| | | String key = "K" + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getBigType() |
| | | + "-" + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getLittleType() |
| | |
| | | listRemarksOutter: |
| | | for (int lRPos = 0, len3 = listRemarks.size(); lRPos < len3; lRPos++) { |
| | | //找到F44B对应的设备回路,判断是否已经拿到了数据。 |
| | | |
| | | if (listRemarks.get(lRPos).getAppliancesInfo().getDeviceSubnetID() == (getDatas.addBytes[0] & 0xFF) |
| | | && listRemarks.get(lRPos).getAppliancesInfo().getDeviceDeviceID() == (getDatas.addBytes[1] & 0xFF) |
| | | && listRemarks.get(lRPos).getAppliancesInfo().getChannelNum() == (getDatas.addBytes[2] & 0xFF) |
| | | && listRemarks.get(lRPos).getAppliancesInfo().getDeviceIndex() == (getDatas.addBytes[2] & 0xFF) |
| | | && listRemarks.get(lRPos).getAppliancesInfo().getBigType() == (getDatas.addBytes[3] & 0xFF) |
| | | && listRemarks.get(lRPos).getAppliancesInfo().getLittleType() == (getDatas.addBytes[4] & 0xFF)) { |
| | | |
| | |
| | | } else { |
| | | HDLLog.I("不存在的设备备注,再次搜索备注。设备:子网号:" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceSubnetID() |
| | | + "设备号:" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceDeviceID() |
| | | + "回路号" + listRemarks.get(lRPos).getAppliancesInfo().getChannelNum() |
| | | + "序列号:" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceIndex() |
| | | + "备注:" + listRemarks.get(lRPos).getAppliancesInfo().getRemarks()); |
| | | HandleSearch.getDevRemarks(); |
| | | break listRemarksOutter; |
| | |
| | | } else { |
| | | HDLLog.I("返回备注设备:子网号:" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceSubnetID() |
| | | + ",设备号:" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceDeviceID() |
| | | + ",回路号" + listRemarks.get(lRPos).getAppliancesInfo().getChannelNum() |
| | | + ",序列号:" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceIndex() |
| | | + ",备注:" + listRemarks.get(lRPos).getAppliancesInfo().getRemarks()); |
| | | listRemarks.get(lRPos).setCallBack(true); |
| | | HandleSearch.getDevRemarks(); |
| | |
| | | * @param mRemarks 备注 |
| | | * @return Boolean |
| | | */ |
| | | public static boolean addSecurityDevicesManually(int mSubnetID, int mDeviceID, int mChannelNum, String mRemarks) { |
| | | return addDevicesManuallyWithoutSearching(Configuration.SECURITY_BIG_TYPE, 0, mSubnetID, mDeviceID, mChannelNum, mRemarks); |
| | | public static boolean addSecurityDevicesManually(int mSubnetID, int mDeviceID, int mChannelNum, int mIndex, String mRemarks) { |
| | | return addDevicesManuallyWithoutSearching(Configuration.SECURITY_BIG_TYPE, 0, mSubnetID, mDeviceID, mChannelNum, mIndex, mRemarks); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param mRemarks 备注 |
| | | * @return Boolean |
| | | */ |
| | | public static boolean addAudioDevicesManually(int mSubnetID, int mDeviceID, int mChannelNum, String mRemarks) { |
| | | return addDevicesManuallyWithoutSearching(Configuration.AUDIO_BIG_TYPE, 0, mSubnetID, mDeviceID, mChannelNum, mRemarks); |
| | | public static boolean addAudioDevicesManually(int mSubnetID, int mDeviceID, int mChannelNum, int mIndex, String mRemarks) { |
| | | return addDevicesManuallyWithoutSearching(Configuration.AUDIO_BIG_TYPE, 0, mSubnetID, mDeviceID, mChannelNum, mIndex, mRemarks); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param mRemarks |
| | | * @return |
| | | */ |
| | | public static boolean addDevicesManuallyWithoutSearchingWithNewDevice(int mBigType, int mLittleType, int mSubnetID, int mDeviceID, int mChannelNum, String mRemarks) { |
| | | public static boolean addDevicesManuallyWithoutSearchingWithNewDevice(int mBigType, int mLittleType, int mSubnetID, int mDeviceID, int mChannelNum, int mIndex, String mRemarks) { |
| | | try { |
| | | DevicesData mDevicesData = DeviceParser.addDevicesManuallyWithoutSearching(mBigType, mLittleType, mSubnetID, mDeviceID, mChannelNum, mRemarks); |
| | | DevicesData mDevicesData = DeviceParser.addDevicesManuallyWithoutSearching(mBigType, mLittleType, mSubnetID, mDeviceID, mChannelNum, mIndex, mRemarks); |
| | | if (mDevicesData != null) { |
| | | devicesDataList.add(mDevicesData); |
| | | HandleSearch.OnDeviceListGetSuccessCallBack(); |
| | |
| | | * @param mRemarks |
| | | * @return |
| | | */ |
| | | public static boolean addDevicesManuallyWithoutSearching(int mBigType, int mLittleType, int mSubnetID, int mDeviceID, int mChannelNum, String mRemarks) { |
| | | public static boolean addDevicesManuallyWithoutSearching(int mBigType, int mLittleType, int mSubnetID, int mDeviceID, int mChannelNum, int mIndex, String mRemarks) { |
| | | try { |
| | | |
| | | if (!DeviceParser.isWantData(mBigType, mLittleType)) {//判断是否支持的大类小类 |
| | |
| | | DevicesData mDevicesData = devicesDataList.get(i); |
| | | bCanAdd = getIfCanAddDevice(mDevicesData.getAppliancesInfoList(), mBigType, mLittleType, mChannelNum); |
| | | if (bCanAdd) {//添加子网号 设备号 已存在,并且没有相同的子网号设备号 |
| | | AppliancesInfo mAppliancesInfo = DeviceParser.getDevicesInfo(mDevicesData, mBigType, mLittleType, mChannelNum, mRemarks, mRemarks); |
| | | AppliancesInfo mAppliancesInfo = DeviceParser.getDevicesInfo(mDevicesData, mBigType, mLittleType, mChannelNum, mIndex, mRemarks, mRemarks); |
| | | devicesDataList.get(i).getAppliancesInfoList().add(mAppliancesInfo); |
| | | HandleSearch.OnDeviceListGetSuccessCallBack(); |
| | | HDLLog.I("支持的设备,允许添加"); |
| | |
| | | } |
| | | |
| | | if (!bExistSubnetID) { |
| | | return addDevicesManuallyWithoutSearchingWithNewDevice(mBigType, mLittleType, mSubnetID, mDeviceID, mChannelNum, mRemarks); |
| | | return addDevicesManuallyWithoutSearchingWithNewDevice(mBigType, mLittleType, mSubnetID, mDeviceID, mChannelNum, mIndex, mRemarks); |
| | | } |
| | | |
| | | return bCanAdd; |