From b1569b789eef12cf5d4252620ca7e7d2d9c8b93a Mon Sep 17 00:00:00 2001 From: panlili2024 <14743743+panlili2024@user.noreply.gitee.com> Date: 星期四, 14 十一月 2024 14:26:03 +0800 Subject: [PATCH] sdk重连优化 --- HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java | 38 ++++++++++++++++++++++---------------- 1 files changed, 22 insertions(+), 16 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 e22e886..94d2799 100644 --- a/HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java +++ b/HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java @@ -41,6 +41,7 @@ import com.hdl.sdk.connect.bean.request.ListSidRequest; import com.hdl.sdk.connect.bean.request.ListUploadRequest; import com.hdl.sdk.connect.bean.response.BaseLocalResponse; +import com.hdl.sdk.connect.bean.response.DeviceInfoResponse; import com.hdl.sdk.connect.bean.response.GatewaySearchBean; import com.hdl.sdk.connect.bean.response.UpdateInfo; import com.hdl.sdk.connect.callback.HDLLinkCallBack; @@ -77,12 +78,12 @@ responseTv.setText(""); // //姝e紡鏈嶅姟鍣� - String appKey = "i8hR07jzrIS";//appkey - String appSecret = "BmnJ8RWTtaVEBk24zPPF4UMwfYu0lAWU";//appsecret +// String appKey = "i8hR07jzrIS";//appkey +// String appSecret = "BmnJ8RWTtaVEBk24zPPF4UMwfYu0lAWU";//appsecret //娴嬭瘯鏈嶅姟鍣� -// String appKey ="FcRyUJlLJFF"; -// String appSecret = "wz8wn75ABidx8vXcFGUotqhwFkTaYvvJ"; + String appKey ="FcRyUJlLJFF"; + String appSecret = "wz8wn75ABidx8vXcFGUotqhwFkTaYvvJ"; // String appKey = "L2OZliZRxHc"; // String appSecret = "aCIWSvJDOukXfx3kivsKW11x9xdR3IbV"; @@ -329,8 +330,10 @@ @Override public void onMessage(Object msg) { LinkResponse response = (LinkResponse) msg; + Log.i("onMessage", "response.getTopic():" + response.getTopic()); if ("/user/all/custom/gateway/broadcast_reply".equals(response.getTopic())) { localSecret.setText("瀵嗛挜锛�" + HDLLinkConfig.getInstance().getLocalSecret()); + } } }; @@ -380,22 +383,23 @@ HDLLink.getInstance().removeAllTopicsListener(allTopicsListener); } - void initDeviceInfo() - { + void initDeviceInfo() { AuthenticateRequest.AuthenticateDeviceInfoBean infoBean = new AuthenticateRequest.AuthenticateDeviceInfoBean(); - infoBean.setDeviceMAC("AA00000000000100"); - infoBean.setIPMAC("AA00000000000100"); - infoBean.setDeviceName("闊充箰鎾斁鍣�");//璁惧鍚嶅瓧 - infoBean.setDeviceModel("MCLog.431");//璁惧鍨嬪彿 + infoBean.setDeviceMAC("f2c5d8bad48f"); + infoBean.setIPMAC("f2c5d8bad48f"); + infoBean.setDeviceName("榄旈暅");//璁惧鍚嶅瓧 + infoBean.setDeviceModel("HDLSDK");//璁惧鍨嬪彿 infoBean.setAccessMode("WIFI"); infoBean.setIPGateway("192.168.1.1"); - infoBean.setIPAddress("192.168.1.116"); - infoBean.setGateway_type("music.standard"); + infoBean.setIPAddress("192.168.1.103"); + infoBean.setGateway_type("screen.touch"); infoBean.setHw_version("HW2.0"); infoBean.setFw_version("Fw1.0"); infoBean.setOID("010105000000FE11");//姣忎釜璁惧oid閮借涓嶄竴鏍� infoBean.setSid("110105000000FE08110100000011");//姣忎釜璁惧鐨剆id閮借涓嶄竴鏍� + infoBean.setSupplier("JINMAOYUN"); HDLLinkConfig.getInstance().setDeviceInfoBean(infoBean); + } /** @@ -412,8 +416,8 @@ // 姝e紡鏈嶅姟鍣� String spkStr = "screen.mirror";//浜у搧spk - String macStr = "AA00000000000100";//璁惧鍞竴MAC鍦板潃 - String secret = "e186beeb7974998e";//閫氳繃spk鍜宮ac鎻愪氦浜戠璁よ瘉鍚庡垎閰嶇殑secret + String macStr = "f2c5d8bad48f";//璁惧鍞竴MAC鍦板潃 +// String secret = "e186beeb7974998e";//閫氳繃spk鍜宮ac鎻愪氦浜戠璁よ瘉鍚庡垎閰嶇殑secret String mac_key = stringToMD5(stringToMD5(macStr + secret)); String versionString = "HDL_V1.0.1";// @@ -423,7 +427,7 @@ //1.璁剧疆璁よ瘉淇℃伅 AuthenticateRequest.RequestBean requestBean = new AuthenticateRequest.RequestBean(); requestBean.setMAC(macStr); - requestBean.setSupplier("WISE"); + requestBean.setSupplier("JINMAOYUN"); requestBean.setFirmwareVersion(versionString); requestBean.setHardwareModel("1956F"); AuthenticateRequest.AuthBean authbean = new AuthenticateRequest.AuthBean(); @@ -477,6 +481,7 @@ void searchGatewayBroadcast() { tv.setText("鎼滅储缃戝叧涓�..."); responseTv.setText(""); + HDLLinkConfig.getInstance().getGatewayId(); HDLLink.getInstance().searchGatewayBroadcast(new HDLAuthSocket.SearchGatewayCallBack() { @Override public void onError(HDLLinkException e) { @@ -577,6 +582,7 @@ statusBeanList.add(bean); request.setStatus(statusBeanList); requestList.add(request); + HDLLink.getInstance().propertyDown(requestList, new HDLLinkCallBack() { @Override public void onSuccess(String data) { @@ -827,7 +833,7 @@ AttributesRequest attributes = new AttributesRequest(); attributes.setKey("on_off"); attributes.setData_type("string"); - List<Object> valueList=new ArrayList<>(); + List<Object> valueList = new ArrayList<>(); valueList.add("on"); valueList.add("off"); attributes.setValue(valueList); -- Gitblit v1.8.0