From 4a42989853dd83c0519d0684383430006b7e9625 Mon Sep 17 00:00:00 2001
From: panlili2024 <14743743+panlili2024@user.noreply.gitee.com>
Date: 星期二, 26 八月 2025 17:59:50 +0800
Subject: [PATCH] 获取设备列表序列化

---
 HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java |   78 ++++++++++++++++++--------------------
 1 files changed, 37 insertions(+), 41 deletions(-)

diff --git a/HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java b/HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java
index 5f8e69d..982ef41 100644
--- a/HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java
+++ b/HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java
@@ -38,6 +38,7 @@
 import com.hdl.sdk.common.utils.SPUtils;
 import com.hdl.sdk.common.utils.gson.GsonConvert;
 import com.hdl.sdk.connect.HDLLink;
+import com.hdl.sdk.connect.bean.LinkFunctionInfo;
 import com.hdl.sdk.connect.bean.LinkResponse;
 import com.hdl.sdk.connect.bean.request.AttributesRequest;
 import com.hdl.sdk.connect.bean.request.AuthenticateRequest;
@@ -50,6 +51,7 @@
 import com.hdl.sdk.connect.bean.response.UpdateInfo;
 import com.hdl.sdk.connect.callback.HDLLinkCallBack;
 import com.hdl.sdk.connect.callback.HDLLinkResponseCallBack;
+import com.hdl.sdk.connect.callback.HDLLinkTCallBack;
 import com.hdl.sdk.connect.cloud.CallBackListener;
 import com.hdl.sdk.connect.cloud.CheckAppVersionListener;
 import com.hdl.sdk.connect.cloud.HDLException;
@@ -81,8 +83,8 @@
     private EventListener allTopicsListener;
     private String testLightSid = "020101A19B485D02020100010101";
     private String secret = "";
-    private List<FunctionBean> devicesList = new ArrayList<>();
-    private List<FunctionBean> roomDevicesList = new ArrayList<>();
+    private List<LinkFunctionInfo> devicesList = new ArrayList<>();
+    private List<LinkFunctionInfo> roomDevicesList = new ArrayList<>();
     private List<SceneBean> sceneList = new ArrayList<>();
     private List<SceneDetailBean> sceneDetailList = new ArrayList<>();
     private List<SceneDetailBean> roomSceneList = new ArrayList<>();
@@ -93,8 +95,8 @@
         responseTv.setText("");
 
         String supplier = "JINMAOYUN";//鍘傚晢
-//        String mac = "AA00000000000100";//璁惧鍞竴MAC鍦板潃
-        String mac = editText.getText().toString();
+        String mac = "f2c5d8bad48f";//璁惧鍞竴MAC鍦板潃
+//        String mac = editText.getText().toString();
         String spk = "screen.touch";//浜у搧spk
 
         if (TextUtils.isEmpty(mac)) {
@@ -184,7 +186,6 @@
                 responseTv.setText(info.toString());
                 if (info != null) {
                     HDLLinkConfig.getInstance().setGatewayId(info.getGatewayId());
-                    //HDLLinkConfig.getInstance().setIpAddress(info.ip);
                 }
             }
 
@@ -229,7 +230,7 @@
 
         selectnetwork();
         checkIfCertified();
-        //initDeviceInfo();//涓嶈蛋浠庢満鍏ョ綉鐨勬柟寮忎笉闇�瑕佸垵濮嬪寲
+        initDeviceInfo();//涓嶈蛋浠庢満鍏ョ綉鐨勬柟寮忎笉闇�瑕佸垵濮嬪寲锛岃蛋浠庢満鍏ョ綉鍒欓渶瑕佸垵濮嬪寲
         registerAllTopicsListener();
         HDLLink.getInstance().setDeleteNetworkListener(new DeleteNetworkListener() {
             @Override
@@ -411,9 +412,14 @@
             public void onMessage(Object msg) {
                 LinkResponse response = (LinkResponse) msg;
                 Log.i("onMessage", "response.getTopic():" + response.getTopic());
+                String topic = String.format(TopicConstant.GATEWAY_LOGIN,
+                        HDLLinkConfig.getInstance().getGatewayId()) + "_reply";
+                ;
+
                 if ("/user/all/custom/gateway/broadcast_reply".equals(response.getTopic())) {
                     localSecret.setText("瀵嗛挜锛�" + HDLLinkConfig.getInstance().getLocalSecret());
-
+                } else if (topic.equals(response.getTopic())) {
+                    //tcp杩炴帴鎴愬姛锛屽鐞嗕笟鍔¢�昏緫
                 }
             }
         };
@@ -470,8 +476,8 @@
         infoBean.setDeviceName("榄旈暅");//璁惧鍚嶅瓧
         infoBean.setDeviceModel("HDLSDK");//璁惧鍨嬪彿
         infoBean.setAccessMode("WIFI");
-        infoBean.setIPGateway("192.168.31.1");
-        infoBean.setIPAddress("192.168.31.103");
+        infoBean.setIPGateway("192.168.1.1");
+        infoBean.setIPAddress("192.168.1.103");
         infoBean.setGateway_type("screen.touch");
         infoBean.setHw_version("HW2.0");
         infoBean.setFw_version("Fw1.0");
@@ -504,7 +510,7 @@
         //璁よ瘉鎻愪氦鍙傛暟鍑嗗
 
         //姝e紡鏈嶅姟鍣�
-        String spkStr = "screen.mirror";//浜у搧spk
+        String spkStr = "screen.touch";//浜у搧spk
         String macStr = "f2c5d8bad48f";//璁惧鍞竴MAC鍦板潃
 
         String mac_key = stringToMD5(stringToMD5(macStr + secret));
@@ -568,7 +574,9 @@
     void searchGatewayBroadcast() {
         tv.setText("鎼滅储缃戝叧涓�...");
         responseTv.setText("");
-        HDLLinkConfig.getInstance().getGatewayId();
+
+        String gatewayId = HDLLinkConfig.getInstance().getGatewayId();
+        Log.d("panlili", "MainActivity.java:searchGatewayBroadcast----->gatewayId= " + gatewayId);
         HDLLink.getInstance().searchGatewayBroadcast(new HDLAuthSocket.SearchGatewayCallBack() {
             @Override
             public void onError(HDLLinkException e) {
@@ -591,37 +599,23 @@
     void getFunctionList() {
         tv.setText("鑾峰彇璁惧鍒楄〃涓�...");
         responseTv.setText("");
-        HDLLink.getInstance().getFunctionList(new HDLLinkCallBack() {
+        HDLLink.getInstance().getFunctionInfoList(new HDLLinkTCallBack<List<LinkFunctionInfo>>() {
+            @Override
+            public void onSuccess(List<LinkFunctionInfo> data) {
+                if (data != null && data.size() != 0) {
+                    devicesList.clear();
+                    devicesList.addAll(data);
+
+                    tv.setText("鑾峰彇璁惧鍒楄〃鎴愬姛");
+                    responseTv.setText(data.toString());
+                }
+            }
+
             @Override
             public void onError(HDLLinkException error) {
                 tv.setText(error.getMsg());
             }
-
-            @Override
-            public void onSuccess(String data) {
-                tv.setText("鑾峰彇璁惧鍒楄〃鎴愬姛");
-                responseTv.setText(data);
-
-                handelFunctionList(data);
-            }
         });
-    }
-
-    void handelFunctionList(String data) {
-        try {
-            final LinkResponse linkResponse = GsonConvert.getGson().fromJson(data, new TypeToken<LinkResponse>() {
-            }.getType());
-
-            final BaseLocalResponse<List<FunctionBean>> bean = GsonConvert.getGson().fromJson(linkResponse.getData(), new TypeToken<BaseLocalResponse<List<FunctionBean>>>() {
-            }.getType());
-            devicesList.clear();
-            devicesList.addAll(bean.getObjects());
-
-            Log.d(TAG, "handelFunList-----> " + devicesList.toString());
-        } catch (Exception e) {
-            Log.e(TAG, "handelFunList: " + e.getMessage());
-        }
-
     }
 
     /**
@@ -638,10 +632,12 @@
             sids.add(testLightSid);
         }
 
-        HDLLink.getInstance().getFunctionAttribute(sids, new HDLLinkCallBack() {
+        HDLLink.getInstance().getFunctionAttributeInfo(sids, new HDLLinkTCallBack<List<LinkFunctionInfo>>() {
             @Override
-            public void onSuccess(String msg) {
-                responseTv.setText(msg);
+            public void onSuccess(List<LinkFunctionInfo> data) {
+                if (data != null && data.size() != 0) {
+                    responseTv.setText(data.toString());
+                }
             }
 
             @Override
@@ -702,7 +698,7 @@
         request.setStatus(statusBeanList);
         requestList.add(request);
 
-        HDLLink.getInstance().propertyDown(requestList, new HDLLinkCallBack() {
+        HDLLink.getInstance().propertyDownDevice(requestList, new HDLLinkTCallBack<String>() {
             @Override
             public void onSuccess(String data) {
                 responseTv.setText(data);

--
Gitblit v1.8.0