From d6d95564b016c281bfa2e8c2454db8d71083e858 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期二, 26 十一月 2019 17:48:09 +0800
Subject: [PATCH] 2019-11-26 1.控制命令改为广播模式。

---
 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java |   89 ++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 85 insertions(+), 4 deletions(-)

diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java
index 7e97d83..ddd3bda 100644
--- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java
+++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java
@@ -4,6 +4,9 @@
 import android.content.Intent;
 import android.text.TextUtils;
 
+import com.google.gson.Gson;
+import com.google.gson.JsonSyntaxException;
+import com.google.gson.reflect.TypeToken;
 import com.hdl.sdk.hdl_core.Config.Configuration;
 import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig;
 import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.AirCtrlBackInfo;
@@ -95,12 +98,16 @@
     public static void init(Context context) {
         viewContext = context;
 //        HDLUdpCore.initMulticastSocket();
+
+
         HandleSearch.rcuIp = (String) SPUtils.getParam(context, SPUtils.KEY_RCU_IP_, "");
         Crc.localSubnetID = (int) SPUtils.getParam(context, SPUtils.KEY_SUB_ID_, 254);
         Crc.localDeviceID = (int) SPUtils.getParam(context, SPUtils.KEY_DEVICE_ID, 80);
+
 //        HandleSearch.curSearchMode = HandleSearch.GET_BUS_DEVICES;
 //        HDLUdpCore.initMulticastSocket6000();
     }
+
 
 
     /**
@@ -213,7 +220,7 @@
                         SPUtils.setParam(viewContext, SPUtils.KEY_HDL_RCU_IP, getDatas.ipAddress);
                     }
                     handleSearchData(getDatas);
-                    HandleSearch.deviceListCallBack();//鎵嬪姩娣诲姞璁惧鎴愬姛绔嬪埢杩斿洖
+                    HandleSearch.OnDeviceListGetSuccessCallBack();//鎵嬪姩娣诲姞璁惧鎴愬姛绔嬪埢杩斿洖
                     HDLCommand.cusSendCommand(Configuration.MANUAL_ADD_DEVICE_BACK_COMMAND,
                             Crc.localSubnetID,
                             Crc.localDeviceID,
@@ -230,7 +237,7 @@
                 break;
             case Configuration.MANUAL_ADD_REMARK_COMMAND:
                 handleRemarkCurStateData(getDatas);
-                HandleSearch.deviceListCallBack();//鎵嬪姩娣诲姞澶囨敞鎴愬姛绔嬪埢杩斿洖
+                HandleSearch.OnDeviceListGetSuccessCallBack();//鎵嬪姩娣诲姞澶囨敞鎴愬姛绔嬪埢杩斿洖
                 HDLCommand.cusSendCommand(Configuration.MANUAL_ADD_REMARK_BACK_COMMAND,
                         Crc.localSubnetID,
                         Crc.localDeviceID,
@@ -839,7 +846,7 @@
                                 setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true);
                                 for (int oldAirInedx = 0; oldAirInedx < oldAirInfo.length; oldAirInedx++) {
                                     if (oldAirInedx == 0) {
-//                                        if (oldAirInfo[0] != newAirInfo[8]) {//2019 鍘绘帀鐩稿悓寮�鍏崇姸鎬佸垽鏂�,瑙e喅寮�鐘舵�佷笅,璋冪敤寮�鍛戒护鐘舵�佷笅,涓嶅仠閲嶅彂闂
+                                        if (oldAirInfo[0] != newAirInfo[8]) {//2019 鍘绘帀鐩稿悓寮�鍏崇姸鎬佸垽鏂�,瑙e喅寮�鐘舵�佷笅,璋冪敤寮�鍛戒护鐘舵�佷笅,涓嶅仠閲嶅彂闂
                                             oldAirInfo[0] = newAirInfo[8];
                                             curAirInfo = new byte[]{AirCtrlParser.airSwich, newAirInfo[8]};
                                             if (curAirInfo.length > 1) {
@@ -853,7 +860,7 @@
                                                 EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true));
 
                                             }
-//                                        }
+                                        }
                                     } else if (oldAirInedx == 1) {
 //                        int mode = ((newAirInfo[4] & 0xf0) >> 4);
                                         int mode = newAirInfo[9] & 0xff;
@@ -2413,4 +2420,78 @@
         if(success == null) success = false;
         return success;
     }
+
+    /**
+     * 淇濆瓨璁惧鏁版嵁鍒楄〃
+     * 鏍规嵁闇�瑕侊紝瀹炴椂淇濆瓨褰撳墠鏁版嵁
+     * 2019-10-14
+     * @return boolean
+     */
+    public static boolean saveDevicesDataList() {
+        try {
+            Gson gson = new Gson();
+            String jsonStr = gson.toJson(devicesDataList); //灏哃ist杞崲鎴怞son
+//            HDLLog.info("saveDevicesDataList:  \n" + jsonStr);
+            SPUtils.setParam(viewContext, SPUtils.KEY_DEVICE_DATA_LIST, jsonStr);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 鍔犺浇鏈湴璁惧鏁版嵁鍒楄〃
+     *
+     * @return devicesDataList
+     */
+    public static List<DevicesData> getLocalDevicesDataList() {
+        try {
+            String getJsonStr = SPUtils.getParam(viewContext, SPUtils.KEY_DEVICE_DATA_LIST, "").toString();
+//            HDLLog.I("getJsonStr:  \n" + getJsonStr);
+            if (!TextUtils.isEmpty(getJsonStr))  //闃茬┖鍒ゆ柇
+            {
+                Gson gson = new Gson();
+                devicesDataList = gson.fromJson(getJsonStr, new TypeToken<List<DevicesData>>() {
+                }.getType()); //灏唈son瀛楃涓茶浆鎹㈡垚List闆嗗悎
+
+            }
+        } catch (JsonSyntaxException e) {
+            e.printStackTrace();
+        }
+        if (devicesDataList == null) devicesDataList = new ArrayList<>();
+        List<DevicesData> devicesDataList2 = devicesDataList;
+
+        setRemarkList();//鍔犺浇澶囨敞list
+
+        if (!TextUtils.isEmpty(HandleSearch.rcuIp)) {//鍒ゆ柇涔嬪墠鏄惁涓篟UC妯″紡
+            HandleSearch.curSearchMode = HandleSearch.GET_RCU_DEVICES;
+            HDLUdpCore.closeSocket6000();
+            HDLUdpCore.init6008();
+        }else {
+            HandleSearch.curSearchMode = HandleSearch.GET_BUS_DEVICES;
+            HDLUdpCore.closeSocket6008();
+            HDLUdpCore.init6000();
+        }
+
+        return devicesDataList2;
+    }
+
+
+
+    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) {
+                for (int i = 0, len = devicesDataList.get(j).getAppliancesInfoList().size(); i < len; i++) {
+                    ListRemarks listRemarksTemp = new ListRemarks();
+                    listRemarksTemp.setCallBack(false);
+                    listRemarksTemp.setAppliancesInfo(devicesDataList.get(j).getAppliancesInfoList().get(i));
+                    listRemarks.add(listRemarksTemp);
+                }
+            }
+        }
+    }
+
+
 }

--
Gitblit v1.8.0