HDLSDK/app/build.gradle
@@ -6,7 +6,7 @@ compileSdk 31 defaultConfig { applicationId "com.hdl.hdlsdk" applicationId "com.hdl.hdlsdk1" minSdk 21 targetSdk 31 versionCode 1 HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java
@@ -4,12 +4,14 @@ import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.contract.ActivityResultContracts; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.Manifest; import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.text.TextUtils; import android.util.Log; @@ -27,6 +29,7 @@ import com.hdl.sdk.common.exception.HDLLinkException; import com.hdl.sdk.common.utils.IdUtils; import com.hdl.sdk.common.utils.IpUtils; import com.hdl.sdk.common.utils.LogUtils; import com.hdl.sdk.common.utils.gson.GsonConvert; import com.hdl.sdk.connect.HDLLink; import com.hdl.sdk.connect.bean.LinkRequest; @@ -45,15 +48,18 @@ import com.hdl.sdk.connect.protocol.LinkMessageEncoder; import com.hdl.sdk.socket.SocketOptions; import com.hdl.sdk.socket.codec.MessagePipeLine; import java.util.Base64; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Base64; import java.util.List; import java.util.Map; import static com.hdl.sdk.common.config.TopicConstant.GATEWAY_SEARCH_REPLY; import static java.util.Base64.*; public class MainActivity extends AppCompatActivity { @@ -71,10 +77,12 @@ super.onDestroy(); removeAllTopicsListener(); } void init(){ HDLLinkConfig.getInstance().setLocalSecret("7d04c4e3c2b7d600"); HDLLinkConfig.getInstance().setGatewayId("1473119283609321473"); void init() { // HDLLinkConfig.getInstance().setLocalSecret("7d04c4e3c2b7d600"); // HDLLinkConfig.getInstance().setGatewayId("1473119283609321473"); // HDLLinkConfig.getInstance().setLocalEncrypt(true); } @RequiresApi(api = Build.VERSION_CODES.O) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -83,6 +91,7 @@ tv = findViewById(R.id.state_tv); rv = findViewById(R.id.rv); rv.setLayoutManager(new LinearLayoutManager(this)); init(); checkIfCertified(); initDeviceInfo(); @@ -257,18 +266,18 @@ void initDeviceInfo() { AuthenticateRequest.AuthenticateDeviceInfoBean infoBean = new AuthenticateRequest.AuthenticateDeviceInfoBean(); infoBean.setDeviceMAC("123456789"); infoBean.setIPMAC("12345678900"); infoBean.setDeviceMAC("AA000000000000AF"); infoBean.setIPMAC("AA000000000000AF"); infoBean.setDeviceName("音乐播放器");//设备名字 infoBean.setDeviceModel("MCLog.431");//设备型号 infoBean.setAccessMode("WIFI"); infoBean.setIPGateway("192.168.88.1"); infoBean.setIPAddress("192.168.88.100"); infoBean.setIPGateway("192.168.1.1"); infoBean.setIPAddress("192.168.1.101"); infoBean.setGateway_type("music.standard"); infoBean.setHw_version("HW2.0"); infoBean.setFw_version("Fw1.0"); infoBean.setOID("010105000000FE08"); infoBean.setSid("010105000000FE08110100000000"); infoBean.setOID("010105000000FE10");//每个设备oid都要不一样 infoBean.setSid("110105000000FE08110100000000");//每个设备的sid都要不一样 HDLLinkConfig.getInstance().setDeviceInfoBean(infoBean); } @@ -281,8 +290,8 @@ //测试服务 String spkStr = "ir.module";//产品spk String macStr = "AA000000000000BB";//设备唯一MAC地址 String secret = "87ae414b7a853f65";//通过spk和mac提交云端认证后分配的secret String macStr = "AA000000000000AF";//设备唯一MAC地址 String secret = "44b360eb74b7ba64";//通过spk和mac提交云端认证后分配的secret // //正式服务器 // String spkStr = "screen.mirror";//产品spk @@ -292,35 +301,20 @@ String mac_key = stringToMD5(stringToMD5(macStr + secret)); String versionString = "HDL_V1.0.1";// String time = String.valueOf(System.currentTimeMillis()); HDLLinkConfig.getInstance().getDeviceInfoBean().setDeviceMAC(macStr); //1.设置认证信息 AuthenticateRequest.RequestBean requestBean = new AuthenticateRequest.RequestBean(); requestBean.setMAC(macStr); requestBean.setSupplier("raysgem"); requestBean.setSupplier("WISE"); requestBean.setFirmwareVersion(versionString); requestBean.setHardwareModel("1956F"); AuthenticateRequest.AuthBean authbean = new AuthenticateRequest.AuthBean(); authbean.setSpk(spkStr); authbean.setMACKey(mac_key); authbean.setRequest(requestBean); //2.设置设备信息 AuthenticateRequest.AuthenticateDeviceInfoBean infoBean = new AuthenticateRequest.AuthenticateDeviceInfoBean(); infoBean.setDeviceMAC(macStr); infoBean.setIPMAC(macStr); infoBean.setDeviceName("红外宝");//设备名字 infoBean.setDeviceModel("HDL");// infoBean.setAccessMode("WIFI"); infoBean.setIPGateway("192.168.88.1"); infoBean.setIPAddress(IpUtils.getIP(this));//根据真实的IP地址填写 infoBean.setOID("010105000000FE08"); infoBean.setSid("010105000000FE08110100000000"); infoBean.setHw_version("1.0"); infoBean.setFw_version("1.0"); // infoBean.set AuthenticateRequest request = new AuthenticateRequest(IdUtils.getUUId(), time, infoBean, authbean); //HDLLinkConfig.getInstance().getDeviceInfoBean()这个初始化的时候要先设置好 AuthenticateRequest request = new AuthenticateRequest(IdUtils.getUUId(), time, HDLLinkConfig.getInstance().getDeviceInfoBean(), authbean); HDLLink.getInstance().startAuthenticateRequest(request, new HDLLinkCallBack() { @Override public void onError(HDLLinkException e) { HDLSDK/hdl-common/build.gradle
@@ -9,7 +9,7 @@ minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion versionCode 2 versionName "1.0.5" versionName "1.0.6" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" HDLSDK/hdl-common/src/main/java/com/hdl/sdk/common/HDLSdk.java
@@ -11,6 +11,16 @@ private Context context; /** * 获取当前版本 * @return */ public String getVersion() { return version; } private String version="1.0.6"; private HDLSdk() { } @@ -24,6 +34,7 @@ public void init(Context context) { this.context = context.getApplicationContext(); LogUtils.i("Version:" + version); } public Context getContext() { HDLSDK/hdl-common/src/main/java/com/hdl/sdk/common/config/TopicConstant.java
@@ -87,4 +87,12 @@ */ public static final String BROADCAST_REPLY="/user/all/custom/gateway/broadcast_reply"; /** * 心跳检测 */ public static final String HEARTBEAT="/user/%s/custom/gateway/heartbeat"; /** * 心跳检测回复 */ public static final String HEARTBEAT_REPLY="/user/%s/custom/gateway/heartbeat_reply"; } HDLSDK/hdl-common/src/main/java/com/hdl/sdk/common/utils/IpUtils.java
@@ -19,21 +19,21 @@ * @return 广播地址 */ public static String getBroadcastAddress() { try { for (Enumeration<NetworkInterface> niEnum = NetworkInterface.getNetworkInterfaces(); niEnum.hasMoreElements(); ) { NetworkInterface ni = niEnum.nextElement(); if (!ni.isLoopback()) { for (InterfaceAddress interfaceAddress : ni.getInterfaceAddresses()) { if (interfaceAddress.getBroadcast() != null) { return interfaceAddress.getBroadcast().toString().substring(1); } } } } } catch (SocketException e) { e.printStackTrace(); } // try { // for (Enumeration<NetworkInterface> niEnum = NetworkInterface.getNetworkInterfaces(); // niEnum.hasMoreElements(); ) { // NetworkInterface ni = niEnum.nextElement(); // if (!ni.isLoopback()) { // for (InterfaceAddress interfaceAddress : ni.getInterfaceAddresses()) { // if (interfaceAddress.getBroadcast() != null) { // return interfaceAddress.getBroadcast().toString().substring(1); // } // } // } // } // } catch (SocketException e) { // e.printStackTrace(); // } return "255.255.255.255"; } HDLSDK/hdl-connect/build.gradle
@@ -9,7 +9,7 @@ minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion versionCode 2 versionName "1.0.5" versionName "1.0.6" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/bean/LinkRequest.java
@@ -88,11 +88,13 @@ String headString = "Topic:" + getTopic() + "\r\n" + "Length:" + dataBytes.length + "\r\n" + "\r\n"; byte[] headBytes = headString.getBytes("utf-8"); byte[] sendBytes = ByteUtils.concatBytes(headBytes, dataBytes); LogUtils.i(headString + "\r\n" + data); LogUtils.i("发送数据:\r\n" + headString + "\r\n" + data); return sendBytes; } else { return this.toString().getBytes("utf-8"); String sendString = this.toString(); LogUtils.i("发送数据:\r\n" + sendString); return sendString.getBytes("utf-8"); } } catch (Exception e) { HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/config/HDLLinkConfig.java
@@ -168,7 +168,7 @@ return (!topicStr.contains(TopicConstant.GATEWAY_AUTH_BROADCAST) //网关广播入网指令 && !topicStr.contains(TopicConstant.DEIVCE_AUTH_REQUEST) //入网认证 && !topicStr.contains(TopicConstant.GATEWAY_SEARCH) //搜索网关主题 && !topicStr.equals(TopicConstant.BROADCAST) && !topicStr.contains(TopicConstant.BROADCAST) && isLocalEncrypt//启用加密标志 ); } HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/protocol/LinkMessageDecoder.java
@@ -1,6 +1,7 @@ package com.hdl.sdk.connect.protocol; import android.annotation.TargetApi; import android.os.Build; import android.util.Log; @@ -116,7 +117,7 @@ } } @RequiresApi(api = Build.VERSION_CODES.O) @Override protected synchronized LinkResponse decoder(Object msg) throws Exception { if (msg instanceof byte[]) { @@ -164,19 +165,24 @@ body = bodyBytes; } else { try { LogUtils.e("解密失败,数据内容是:\r\n" + Base64.getEncoder().encodeToString(body)); LogUtils.e("解密失败,数据内容是:\r\n"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) LogUtils.e(Base64.getEncoder().encodeToString(body)); else { LogUtils.e(new String(body, "utf-8")); } } catch (Exception e) { } } } String bodyString = new String(body, "utf-8"); response.setData(bodyString); LogUtils.i( "接收到数据:" + response.getTopic() + "\r\n" + response.getData()); //非正常数据,返回 if (!(bodyString.startsWith("{") || bodyString.startsWith("["))) { continue; } response.setData(bodyString); LogUtils.i( "LinkMessageDecoder->decoder:" + response.getTopic() + "\r\n" + response.getData()); //解析完成,topic发送一次 EventDispatcher.getInstance().post(response.getTopic(), response); } HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLAuthSocket.java
@@ -141,15 +141,15 @@ public void onMessage(Object msg) { NetworkAccessBroadcastResponse bean = getNetworkAccessBroadcastResponse(msg); if (bean != null) { LogUtils.i(TAG, "网关入网广播IP: " + bean.getIPAddress()); //移除监听 EventDispatcher.getInstance().remove(TopicConstant.GATEWAY_AUTH_BROADCAST); LogUtils.i("网关入网广播IP: " + bean.getIPAddress()); String ipStr = bean.getIPAddress(); if (!TextUtils.isEmpty(ipStr)) { sendAuthenticateRequest(ipStr, request, callBack); } } //移除监听 EventDispatcher.getInstance().remove(TopicConstant.GATEWAY_AUTH_BROADCAST); LogUtils.i(TAG, "移除监听 authEvent"); } }); } HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLSocket.java
@@ -27,6 +27,7 @@ import com.hdl.sdk.connect.protocol.LinkMessageEncoder; import com.hdl.sdk.socket.SocketBoot; import com.hdl.sdk.socket.SocketOptions; import com.hdl.sdk.socket.client.IHeartbeat; import com.hdl.sdk.socket.client.TcpClient; import com.hdl.sdk.socket.codec.MessagePipeLine; import com.hdl.sdk.socket.listener.ConnectStatusListener; @@ -413,6 +414,27 @@ //如果没有初始化,或者网关IP更改了,就重新初始化 if (tcpBoot == null||!getTcpOptions().getIp().equals(getTcpIp())) { tcpBoot = TcpClient.init(getTcpIp(), getTcpPort(), getTcpOptions()); tcpBoot.SetHeartbeat(new IHeartbeat() { @Override public void heartbeat() { if(HDLLinkConfig.getInstance().getDeviceInfoBean()==null||HDLLinkConfig.getInstance().getDeviceInfoBean().getOID()==null) { LogUtils.i("DeviceInfoBean为空,需要设置才能正常心跳"); return; } String time = String.valueOf(System.currentTimeMillis()); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("id", IdUtils.getUUId()); jsonObject.addProperty("time_stamp", time); String topic = String.format(TopicConstant.HEARTBEAT, HDLLinkConfig.getInstance().getDeviceInfoBean().getOID()); LinkRequest message = new LinkRequest(topic, jsonObject.toString()); sendMsg(message.getSendBytes(), null, null, null); } }); } return tcpBoot; @@ -574,46 +596,48 @@ public void sendMsg(byte[] data, String eventTag, HDLLinkCallBack callBack, SendListener sendListener) { try { final AtomicInteger sendCount = new AtomicInteger(0); if(eventTag!=null) { final AtomicInteger sendCount = new AtomicInteger(0); final ScheduledExecutorService threadPool = ThreadToolUtils.getInstance().newScheduledThreadPool(1); final EventListener eventListener = new EventListener() { @Override public void onMessage(Object msg) { if (msg instanceof LinkResponse) { LogUtils.i("sendMsg onSuccess"); threadPool.shutdownNow(); LogUtils.i("sendMsg eventListener remove"); EventDispatcher.getInstance().remove(eventTag, this); if (callBack != null) { callBack.onSuccess(msg.toString()); final ScheduledExecutorService threadPool = ThreadToolUtils.getInstance().newScheduledThreadPool(1); final EventListener eventListener = new EventListener() { @Override public void onMessage(Object msg) { if (msg instanceof LinkResponse) { LogUtils.i("sendMsg onSuccess"); threadPool.shutdownNow(); LogUtils.i("sendMsg eventListener remove"); EventDispatcher.getInstance().remove(eventTag, this); if (callBack != null) { callBack.onSuccess(msg.toString()); } } } } }; }; threadPool.scheduleWithFixedDelay(new Runnable() { @Override public void run() { if (sendCount.get() < 3) { sendCount.set(sendCount.get() + 1); getTcp().sendMsg(data); } else { threadPool.shutdownNow(); LogUtils.e("sendMsg eventListener remove"); EventDispatcher.getInstance().remove(eventTag, eventListener); ThreadToolUtils.getInstance().runOnUiThread(new Runnable() { @Override public void run() { if (callBack != null) { callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_SEND_ERROR)); threadPool.scheduleWithFixedDelay(new Runnable() { @Override public void run() { if (sendCount.get() < 3) { sendCount.set(sendCount.get() + 1); getTcp().sendMsg(data); } else { threadPool.shutdownNow(); LogUtils.e("sendMsg eventListener remove"); EventDispatcher.getInstance().remove(eventTag, eventListener); ThreadToolUtils.getInstance().runOnUiThread(new Runnable() { @Override public void run() { if (callBack != null) { callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_SEND_ERROR)); } } } }); }); } } } }, 1000, 500, TimeUnit.MILLISECONDS); EventDispatcher.getInstance().register(eventTag, eventListener); }, 1000, 500, TimeUnit.MILLISECONDS); EventDispatcher.getInstance().register(eventTag, eventListener); } //先发送一次 getTcp().sendMsg(data, new SendListener() { @Override HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HdlSocketHelper.java
@@ -21,7 +21,7 @@ */ public class HdlSocketHelper { private static final Long DEF_SEND_TIMEOUT = 500L; private static final Long DEF_SEND_TIMEOUT = 1000L; private static final int DEF_MAX_RETRY = 4; private static final int DEF_SEND_ONE = 1; HDLSDK/hdl-socket/build.gradle
@@ -9,7 +9,7 @@ minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion versionCode 2 versionName "1.0.5" versionName "1.0.6" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/SocketBoot.java
@@ -5,13 +5,18 @@ import androidx.collection.ArrayMap; import com.google.gson.JsonObject; import com.hdl.sdk.common.config.TopicConstant; import com.hdl.sdk.common.utils.IdUtils; import com.hdl.sdk.common.utils.LogUtils; import com.hdl.sdk.common.utils.ThreadToolUtils; import com.hdl.sdk.socket.annotation.ConnectStatus; import com.hdl.sdk.socket.client.IClient; import com.hdl.sdk.socket.client.IHeartbeat; import com.hdl.sdk.socket.listener.SendListener; import java.net.ConnectException; import java.util.Date; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingDeque; @@ -29,8 +34,17 @@ private ExecutorService connectThread; private ExecutorService sendThread; private ExecutorService receiveThread; private ExecutorService heartbeatThread; private final IClient client; private IHeartbeat iHeartbeat; public void SetHeartbeat(IHeartbeat iHeartbeat){ this.iHeartbeat=iHeartbeat; } /** * 当前接收到数据的时间 */ private static long time=System.currentTimeMillis(); /** * tcp是否已经连接 @@ -50,6 +64,7 @@ initConnectThread(); initReceiveThread(); initSendThread(); initHeartbeat(); } /** @@ -125,6 +140,7 @@ if (connected) { //读取数据 client.onHandleResponse(); time= System.currentTimeMillis(); } else { try { Thread.sleep(1000); @@ -157,7 +173,7 @@ if (!connected) { reconect(); } Thread.sleep(10*1000); Thread.sleep(3*1000); } catch (Exception e) { } @@ -166,6 +182,39 @@ }); } } /** * 初始化重新心跳线程 */ private void initHeartbeat() { if (heartbeatThread == null) { heartbeatThread = ThreadToolUtils.getInstance().newFixedThreadPool(1); heartbeatThread.execute(new Runnable() { @Override public void run() { while (true) { try { //10秒 if (connected && 10 * 1000 < (System.currentTimeMillis() - time)) { time = System.currentTimeMillis(); //心跳检测 try { if (iHeartbeat != null) iHeartbeat.heartbeat(); } catch (Exception e) { } } Thread.sleep(1000); } catch (Exception e) { } } } }); } } /** * 重新连接 */ HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/client/IHeartbeat.java
New file @@ -0,0 +1,8 @@ package com.hdl.sdk.socket.client; /** * Created by hxb on 2022/2/16. */ public interface IHeartbeat { void heartbeat(); } HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/client/TcpClient.java
@@ -17,6 +17,7 @@ import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketAddress; import java.net.StandardSocketOptions; import java.util.ArrayList; import java.util.List; @@ -75,7 +76,7 @@ mSocket.connect(new InetSocketAddress(ip, port), 3 * 1000); mSocket.setTcpNoDelay(true); mSocket.setReuseAddress(true); mSocket.setKeepAlive(true); // mSocket.setKeepAlive(true); mSocket.setSoTimeout(20 * 1000); tcpClientList.add(this); @@ -117,7 +118,6 @@ if (handleMessage != null) { byte []bytes = new byte[len]; System.arraycopy(readBuffer,0,bytes,0,len); LogUtils.i("收到TCP数据",new String(bytes)); //完整的数据才回调 handleMessage.read(bytes); } HDLSDK_DEMO/app/src/main/java/com/hdl/hdlsdk/MainActivity.java
@@ -72,6 +72,25 @@ removeAllTopicsListener(); } void initDeviceInfo() { AuthenticateRequest.AuthenticateDeviceInfoBean infoBean = new AuthenticateRequest.AuthenticateDeviceInfoBean(); infoBean.setDeviceMAC("123456789"); infoBean.setIPMAC("12345678900"); infoBean.setDeviceName("音乐播放器");//设备名字 infoBean.setDeviceModel("MCLog.431");//设备型号 infoBean.setAccessMode("WIFI"); infoBean.setIPGateway("192.168.88.1"); infoBean.setIPAddress("192.168.88.100"); infoBean.setGateway_type("music.standard"); infoBean.setHw_version("HW2.0"); infoBean.setFw_version("Fw1.0"); infoBean.setOID("010105000000FE08"); infoBean.setSid("010105000000FE08110100000000"); HDLLinkConfig.getInstance().setDeviceInfoBean(infoBean); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -82,7 +101,7 @@ rv.setLayoutManager(new LinearLayoutManager(this)); checkIfCertified(); initDeviceInfo(); registerAllTopicsListener(); ActivityResultLauncher<String[]> launcher = registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), new ActivityResultCallback<Map<String, Boolean>>() { @@ -262,7 +281,7 @@ String macStr = "AA000000000000BB";//设备唯一MAC地址 String secret = "87ae414b7a853f65";//通过spk和mac提交云端认证后分配的secret //正式服务器 // //正式服务器 // String spkStr = "screen.mirror";//产品spk // String macStr = "AA000000000000AC";//设备唯一MAC地址 // String secret = "ee62124c151b737c";//通过spk和mac提交云端认证后分配的secret @@ -270,6 +289,7 @@ String mac_key = stringToMD5(stringToMD5(macStr + secret)); String versionString = "HDL_V1.0.1";// String time = String.valueOf(System.currentTimeMillis()); HDLLinkConfig.getInstance().getDeviceInfoBean().setDeviceMAC(macStr); //1.设置认证信息 AuthenticateRequest.RequestBean requestBean = new AuthenticateRequest.RequestBean(); @@ -281,23 +301,8 @@ authbean.setSpk(spkStr); authbean.setMACKey(mac_key); authbean.setRequest(requestBean); //2.设置设备信息 AuthenticateRequest.AuthenticateDeviceInfoBean infoBean = new AuthenticateRequest.AuthenticateDeviceInfoBean(); infoBean.setDeviceMAC(macStr); infoBean.setIPMAC(macStr); infoBean.setDeviceName("红外宝");//设备名字 infoBean.setDeviceModel("HDL");// infoBean.setAccessMode("WIFI"); infoBean.setIPGateway("192.168.88.1"); infoBean.setIPAddress(IpUtils.getIP(this)); infoBean.setOID("010105000000FE08"); infoBean.setSid("010105000000FE08110100000000"); // infoBean.set AuthenticateRequest.VersionBean[] versionBeans = new AuthenticateRequest.VersionBean[]{new AuthenticateRequest.VersionBean("FW", versionString), new AuthenticateRequest.VersionBean("HW", "1956F")}; infoBean.setVersions(versionBeans); AuthenticateRequest request = new AuthenticateRequest(IdUtils.getUUId(), time, infoBean, authbean); //HDLLinkConfig.getInstance().getDeviceInfoBean()这个初始化的时候要先设置好 AuthenticateRequest request = new AuthenticateRequest(IdUtils.getUUId(), time, HDLLinkConfig.getInstance().getDeviceInfoBean(), authbean); HDLLink.getInstance().startAuthenticateRequest(request, new HDLLinkCallBack() { @Override public void onError(HDLLinkException e) {