From 43e38e768360ac8ced4f31fb4a423f2badda5587 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期一, 13 十二月 2021 15:49:05 +0800
Subject: [PATCH] 2021-12-13 1.优化udp发送
---
HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLAuthSocket.java | 45 +++++++++++++++++++++++++++------------------
1 files changed, 27 insertions(+), 18 deletions(-)
diff --git a/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLAuthSocket.java b/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLAuthSocket.java
index ac97593..8442f03 100644
--- a/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLAuthSocket.java
+++ b/HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLAuthSocket.java
@@ -178,30 +178,39 @@
String requestStr = gs.toJson(request);
LinkRequest message = new LinkRequest(topic, requestStr);
- HdlSocketHelper.sendUdp(getUdpBoot(), ip, UDP_PORT, message,new HdlSocketHelper.HdlSocketListener() {
+ HdlSocketHelper.sendUdp(getUdpBoot(), ip, UDP_PORT, message, new HdlSocketHelper.HdlSocketListener() {
@Override
public void onSucceed(Object msg) {
if (callBack == null) return;
try {
AuthenticateResponse bean = getAuthenticateResponseBean(msg);
if (bean != null) {
- String localSecret = "";
- String gatewayId = "";
- String ipAddress = "";
- if (bean.getAuth() != null) {
- localSecret = bean.getAuth().getLocalSecret();
- }
- if (bean.getObjects() != null) {
- gatewayId = bean.getObjects().getGatewayID();
- ipAddress = bean.getObjects().getIPAddress();
- }
- //鍒ゆ柇缃戝叧鏄惁宸茬粡娉ㄥ唽鍒颁簯绔�
- if (TextUtils.isEmpty(localSecret) || TextUtils.isEmpty(gatewayId)) {
- //璁よ瘉澶辫触锛岀綉鍏虫湭娉ㄥ唽鍒颁簯绔�
- callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_AUTH_ERROR_GATEWAY_NOT_REGISTERED));
- } else {
- HDLLinkConfig.getInstance().saveConfig(localSecret, gatewayId, ipAddress);
- callBack.onSuccess("璁よ瘉鎴愬姛");
+ if (bean.getCode().equals("200")) {
+ String localSecret = "";
+ String gatewayId = "";
+ String ipAddress = "";
+ if (bean.getAuth() != null) {
+ localSecret = bean.getAuth().getLocalSecret();
+ }
+ if (bean.getObjects() != null) {
+ gatewayId = bean.getObjects().getGatewayID();
+ ipAddress = bean.getObjects().getIPAddress();
+ }
+ //鍒ゆ柇缃戝叧鏄惁宸茬粡娉ㄥ唽鍒颁簯绔�
+ if (TextUtils.isEmpty(localSecret) || TextUtils.isEmpty(gatewayId)) {
+ //璁よ瘉澶辫触锛岀綉鍏虫湭娉ㄥ唽鍒颁簯绔�
+ callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_AUTH_ERROR_GATEWAY_NOT_REGISTERED));
+ } else {
+ HDLLinkConfig.getInstance().saveConfig(localSecret, gatewayId, ipAddress);
+ callBack.onSuccess("璁よ瘉鎴愬姛");
+ }
+ } else if (bean.getCode().equals("14013")){
+ //璁よ瘉澶辫触锛岃MAC瀵瑰簲鐨勮澶囧瘑閽ヤ笉瀛樺湪
+ callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_AUTH_MAC_KEY_ERROR_));
+ } else{
+ //璁よ瘉澶辫触锛岄敊璇爜锛�
+ LogUtils.e("璁よ瘉澶辫触锛岄敊璇爜锛�" + bean.getCode());
+ callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_AUTH_ERROR));
}
} else {
callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_ERROR));
--
Gitblit v1.8.0