From beadecb2bbc75b8f153d366df11246719cf97b2f Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期五, 23 二月 2024 14:37:25 +0800 Subject: [PATCH] Merge branch 'dev-hxb' of http://59.41.255.150:6688/r/~wjc/HDLPhotovoltaicDebugAPP into dev-hxb --- /dev/null | 29 ----------------------------- settings.gradle | 2 +- app/build.gradle | 4 ++-- 3 files changed, 3 insertions(+), 32 deletions(-) diff --git a/HDLLinkLocalSdk/.gitignore b/HDLLinkLocalSdk/.gitignore deleted file mode 100644 index 42afabf..0000000 --- a/HDLLinkLocalSdk/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/HDLLinkLocalSdk/build.gradle b/HDLLinkLocalSdk/build.gradle deleted file mode 100644 index ba504e2..0000000 --- a/HDLLinkLocalSdk/build.gradle +++ /dev/null @@ -1,55 +0,0 @@ -plugins { - id 'com.android.library' -} - -android { - compileSdkVersion 29 - - defaultConfig { - minSdkVersion 21 - targetSdkVersion 29 - versionCode 102 - versionName "1.0.2" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles "consumer-rules.pro" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - /** - * 鎵撳寘鑷姩鍛藉悕 - */ - android.libraryVariants.all { variant -> - variant.outputs.all { - outputFileName = "hdl-link-V" + defaultConfig.versionName + ".aar" - } - } -} - -dependencies { - implementation 'com.google.code.gson:gson:2.8.8' - implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'com.google.android.material:material:1.3.0' - implementation 'com.alibaba:fastjson:1.2.66' - api 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0' - api 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1' - implementation 'org.bouncycastle:bcpg-jdk16:1.46' - //浜嬩欢鎬荤嚎 Eventbus - api 'org.greenrobot:eventbus:3.2.0' - //HDLLinkPMSdk SDK - api project(path: ':HDLLinkPMSdk') - -// //鍔犲瘑 -// implementation 'cn.hutool:hutool-all:5.6.5' -// implementation 'org.bouncycastle:bcprov-jdk15on:1.60' -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/consumer-rules.pro b/HDLLinkLocalSdk/consumer-rules.pro deleted file mode 100644 index e69de29..0000000 --- a/HDLLinkLocalSdk/consumer-rules.pro +++ /dev/null diff --git a/HDLLinkLocalSdk/proguard-rules.pro b/HDLLinkLocalSdk/proguard-rules.pro deleted file mode 100644 index 481bb43..0000000 --- a/HDLLinkLocalSdk/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/AndroidManifest.xml b/HDLLinkLocalSdk/src/main/AndroidManifest.xml deleted file mode 100644 index 71bb242..0000000 --- a/HDLLinkLocalSdk/src/main/AndroidManifest.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.hdl.sdk.link"> - -</manifest> \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/GatewayLocationBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/GatewayLocationBean.java deleted file mode 100644 index 3e0d993..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/GatewayLocationBean.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2023/5/18 - * description: - */ -public class GatewayLocationBean implements Serializable { - private String longitude; - private String latitude; - - public String getLongitude() { - return longitude == null ? "" : longitude; - } - - public void setLongitude(@NonNull String longitude) { - this.longitude = longitude; - } - - public String getLatitude() { - return latitude == null ? "" : latitude; - } - - public void setLatitude(@NonNull String latitude) { - this.latitude = latitude; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkAttributesBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkAttributesBean.java deleted file mode 100644 index f233869..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkAttributesBean.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.hdl.sdk.link.bean; - -import androidx.annotation.NonNull; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by jlchen on 1/13/22. - * - */ -public class LinkAttributesBean implements Serializable { - - private String key; - private String data_type; - private List<String> value = new ArrayList<>(); - private String max; - private String min; - - - public List<String> getValue() { - if (value == null) { - return new ArrayList<>(); - } - return value; - } - - public void setValue(@NonNull List<String> value) { - this.value = value; - } - - public String getMax() { - return max == null ? "" : max; - } - - public void setMax(String max) { - this.max = max; - } - - public String getMin() { - return min == null ? "" : min; - } - - public void setMin(String min) { - this.min = min; - } - - @NonNull - public String getKey() { - return key == null ? "" : key; - } - - public void setKey(@NonNull String key) { - this.key = key; - } - - @NonNull - public String getData_type() { - return data_type == null ? "" : data_type; - } - - public void setData_type(@NonNull String data_type) { - this.data_type = data_type; - } - - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateLogicBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateLogicBean.java deleted file mode 100644 index 204248f..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateLogicBean.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/2/16 - * description: - */ -public class LinkCreateLogicBean implements Serializable { - private String sid; - private String name; - private String relation; - private String enable; - //enable甯冮槻銆乨isable鎾掗槻 - private String status; - //"all"--鍏ㄥ畢甯冮槻锛�"normal"--鏅�氭ā寮�,"all_day":24灏忔椂,"mute"锛氶潤闊� - private String type; - private String gatewayId; - private LinkCreateLogicCycleBean cycle = new LinkCreateLogicCycleBean(); - private List<LinkCreateLogicInputBean> input = new ArrayList<>(); - private List<LinkCreateLogicOutputBean> output = new ArrayList<>(); - private NoticeConfigInfo noticeConfig = new NoticeConfigInfo(); - - public NoticeConfigInfo getNoticeConfig() { - return noticeConfig; - } - - public void setNoticeConfig(@NonNull NoticeConfigInfo noticeConfig) { - this.noticeConfig = noticeConfig; - } - - public String getGateWayId() { - return gatewayId == null ? "" : gatewayId; - } - - public void setGateWayId(@NonNull String gateWayId) { - this.gatewayId = gateWayId; - } - - public String getStatus() { - return status == null ? "" : status; - } - - public void setStatus(@NonNull String status) { - this.status = status; - } - - public String getType() { - return type == null ? "" : type; - } - - public void setType(@NonNull String type) { - this.type = type; - } - - public String getSid() { - return sid == null ? "" : sid; - } - - public void setSid(@NonNull String sid) { - this.sid = sid; - } - - public String getName() { - return name == null ? "" : name; - } - - public void setName(@NonNull String name) { - this.name = name; - } - - public String getRelation() { - return relation == null ? "" : relation; - } - - public void setRelation(@NonNull String relation) { - this.relation = relation; - } - - public String getEnable() { - return enable == null ? "" : enable; - } - - public void setEnable(@NonNull String enable) { - this.enable = enable; - } - - public LinkCreateLogicCycleBean getCycle() { - return cycle; - } - - public void setCycle(@NonNull LinkCreateLogicCycleBean cycle) { - this.cycle = cycle; - } - - public List<LinkCreateLogicInputBean> getInput() { - if (input == null) { - return new ArrayList<>(); - } - return input; - } - - public void setInput(@NonNull List<LinkCreateLogicInputBean> input) { - this.input = input; - } - - public List<LinkCreateLogicOutputBean> getOutput() { - if (output == null) { - return new ArrayList<>(); - } - return output; - } - - public void setOutput(@NonNull List<LinkCreateLogicOutputBean> output) { - this.output = output; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateLogicCycleBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateLogicCycleBean.java deleted file mode 100644 index 869f035..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateLogicCycleBean.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/2/16 - * description: - */ -public class LinkCreateLogicCycleBean implements Serializable { - private String type; - private String desc; - private List<String> value = new ArrayList<>(); - - public String getType() { - return type == null ? "" : type; - } - - public void setType(@NonNull String type) { - this.type = type; - } - - public String getDesc() { - return desc == null ? "" : desc; - } - - public void setDesc(@NonNull String desc) { - this.desc = desc; - } - - public List<String> getValue() { - if (value == null) { - return new ArrayList<>(); - } - return value; - } - - public void setValue(@NonNull List<String> value) { - this.value = value; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateLogicInputConditionBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateLogicInputConditionBean.java deleted file mode 100644 index 800a6f2..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateLogicInputConditionBean.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/2/16 - * description: - */ -public class LinkCreateLogicInputConditionBean implements Serializable { - private String key; - private String comparator; - private String data_type; - private String value; - - public String getKey() { - return key == null ? "" : key; - } - - public void setKey(@NonNull String key) { - this.key = key; - } - - public String getComparator() { - return comparator == null ? "" : comparator; - } - - public void setComparator(@NonNull String comparator) { - this.comparator = comparator; - } - - public String getData_type() { - return data_type == null ? "" : data_type; - } - - public void setData_type(@NonNull String data_type) { - this.data_type = data_type; - } - - public String getValue() { - return value == null ? "" : value; - } - - public void setValue(@NonNull String value) { - this.value = value; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateLogicOutputStatusBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateLogicOutputStatusBean.java deleted file mode 100644 index eff3608..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateLogicOutputStatusBean.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/2/16 - * description: - */ -public class LinkCreateLogicOutputStatusBean implements Serializable { - //鈿狅笍 杩欒竟闇�瑕佹坊鍔犲叾浠栧瓧娈� 鍥犱负鍗曠函杩欎簺涓嶅鐢� - private String value; - private String key; - private String attrName; - private String desc; - - public String getAttrName() { - return attrName == null ? "" : attrName; - } - - public void setAttrName(@NonNull String attrName) { - this.attrName = attrName; - } - - public String getDesc() { - return desc == null ? "" : desc; - } - - public void setDesc(@NonNull String desc) { - this.desc = desc; - } - - public String getKey() { - return key == null ? "" : key; - } - - public void setKey(@NonNull String key) { - this.key = key; - } - - public String getValue() { - return value == null ? "" : value; - } - - public void setValue(@NonNull String value) { - this.value = value; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneFunctionControlAttrsBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneFunctionControlAttrsBean.java deleted file mode 100644 index b57338c..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneFunctionControlAttrsBean.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/1/23 - * description: - */ -public class LinkCreateSceneFunctionControlAttrsBean implements Serializable { - private String delay1; - private String sid; - private List<LinkCreateSceneFunctionStatusBean> status = new ArrayList<>(); - - public String getDelay1() { - return delay1 == null ? "" : delay1; - } - - public void setDelay1(@NonNull String delay1) { - this.delay1 = delay1; - } - - public String getSid() { - return sid == null ? "" : sid; - } - - public void setSid(@NonNull String sid) { - this.sid = sid; - } - - public List<LinkCreateSceneFunctionStatusBean> getStatus() { - if (status == null) { - return new ArrayList<>(); - } - return status; - } - - public void setStatus(@NonNull List<LinkCreateSceneFunctionStatusBean> status) { - this.status = status; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneFunctionStatusBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneFunctionStatusBean.java deleted file mode 100644 index 0e10c49..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneFunctionStatusBean.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/1/23 - * description: - */ -public class LinkCreateSceneFunctionStatusBean implements Serializable { - private String value; - private String key; - private String attrName; - private String desc; - private String comparator; - - public String getComparator() { - return comparator == null ? "" : comparator; - } - - public void setComparator(@NonNull String comparator) { - this.comparator = comparator; - } - - public String getValue() { - return value == null ? "" : value; - } - - public void setValue(@NonNull String value) { - this.value = value; - } - - public String getKey() { - return key == null ? "" : key; - } - - public void setKey(@NonNull String key) { - this.key = key; - } - - public String getAttrName() { - return attrName == null ? "" : attrName; - } - - public void setAttrName(@NonNull String attrName) { - this.attrName = attrName; - } - - public String getDesc() { - return desc == null ? "" : desc; - } - - public void setDesc(@NonNull String desc) { - this.desc = desc; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneFunctionattributesBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneFunctionattributesBean.java deleted file mode 100644 index f4f46c1..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneFunctionattributesBean.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/1/23 - * description: - */ -public class LinkCreateSceneFunctionattributesBean implements Serializable { - private String data_type; - private String accessMode; - private String key; - private String desc; - private String maxValue; - private String minValue; - private String unit; - private List<String> value = new ArrayList<>(); - private List<LinkCreateSceneFunctionattributesEnumerationsBean> enumerations = new ArrayList<>(); - - public String getData_type() { - return data_type == null ? "" : data_type; - } - - public void setData_type(@NonNull String data_type) { - this.data_type = data_type; - } - - public String getAccessMode() { - return accessMode == null ? "" : accessMode; - } - - public void setAccessMode(@NonNull String accessMode) { - this.accessMode = accessMode; - } - - public String getKey() { - return key == null ? "" : key; - } - - public void setKey(@NonNull String key) { - this.key = key; - } - - public String getDesc() { - return desc == null ? "" : desc; - } - - public void setDesc(@NonNull String desc) { - this.desc = desc; - } - - public String getMaxValue() { - return maxValue == null ? "" : maxValue; - } - - public void setMaxValue(@NonNull String maxValue) { - this.maxValue = maxValue; - } - - public String getMinValue() { - return minValue == null ? "" : minValue; - } - - public void setMinValue(@NonNull String minValue) { - this.minValue = minValue; - } - - public String getUnit() { - return unit == null ? "" : unit; - } - - public void setUnit(@NonNull String unit) { - this.unit = unit; - } - - public List<String> getValue() { - if (value == null) { - return new ArrayList<>(); - } - return value; - } - - public void setValue(@NonNull List<String> value) { - this.value = value; - } - - public List<LinkCreateSceneFunctionattributesEnumerationsBean> getEnumerations() { - if (enumerations == null) { - return new ArrayList<>(); - } - return enumerations; - } - - public void setEnumerations(@NonNull List<LinkCreateSceneFunctionattributesEnumerationsBean> enumerations) { - this.enumerations = enumerations; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneFunctionattributesEnumerationsBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneFunctionattributesEnumerationsBean.java deleted file mode 100644 index f73d61c..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneFunctionattributesEnumerationsBean.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/1/23 - * description: - */ -public class LinkCreateSceneFunctionattributesEnumerationsBean implements Serializable { - private String value; - private String desc; - - public String getValue() { - return value == null ? "" : value; - } - - public void setValue(@NonNull String value) { - this.value = value; - } - - public String getDesc() { - return desc == null ? "" : desc; - } - - public void setDesc(@NonNull String desc) { - this.desc = desc; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneImageBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneImageBean.java deleted file mode 100644 index 8df6d7b..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneImageBean.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/1/23 - * description: - */ -public class LinkCreateSceneImageBean implements Serializable { - private String id; - private String url; - private String local; - - public LinkCreateSceneImageBean(String id, String url, String local) { - this.id = id; - this.url = url; - this.local = local; - } - - public LinkCreateSceneImageBean() { - } - - public String getId() { - return id == null ? "" : id; - } - - public void setId(@NonNull String id) { - this.id = id; - } - - public String getUrl() { - return url == null ? "" : url; - } - - public void setUrl(@NonNull String url) { - this.url = url; - } - - public String getLocal() { - return local == null ? "" : local; - } - - public void setLocal(@NonNull String local) { - this.local = local; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneImageToCloudBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneImageToCloudBean.java deleted file mode 100644 index 09e64db..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkCreateSceneImageToCloudBean.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/1/23 - * description: - */ -public class LinkCreateSceneImageToCloudBean implements Serializable { - private String imageId; - private String cloudUrl; - private String localUrl; - - public String getImageId() { - return imageId == null ? "" : imageId; - } - - public void setImageId(@NonNull String imageId) { - this.imageId = imageId; - } - - public String getCloudUrl() { - return cloudUrl == null ? "" : cloudUrl; - } - - public void setCloudUrl(@NonNull String cloudUrl) { - this.cloudUrl = cloudUrl; - } - - public String getLocalUrl() { - return localUrl == null ? "" : localUrl; - } - - public void setLocalUrl(@NonNull String localUrl) { - this.localUrl = localUrl; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkEnableLogicBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkEnableLogicBean.java deleted file mode 100644 index cfb835e..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkEnableLogicBean.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/2/21 - * description: - */ -public class LinkEnableLogicBean implements Serializable { - private String sid; - private String enable; - - public LinkEnableLogicBean(String sid, String enable) { - this.sid = sid; - this.enable = enable; - } - - public String getSid() { - return sid == null ? "" : sid; - } - - public void setSid(@NonNull String sid) { - this.sid = sid; - } - - public String getEnable() { - return enable == null ? "" : enable; - } - - public void setEnable(@NonNull String enable) { - this.enable = enable; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkEnableSecurityBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkEnableSecurityBean.java deleted file mode 100644 index 3558569..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkEnableSecurityBean.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/2/21 - * description: - */ -public class LinkEnableSecurityBean implements Serializable { - private String sid; - private String status; - private String alarm; - - public LinkEnableSecurityBean(String sid, String status) { - this.sid = sid; - this.status = status; - } - - public LinkEnableSecurityBean(String sid, String status, String alarm) { - this.sid = sid; - this.status = status; - this.alarm = alarm; - } - - public String getSid() { - return sid == null ? "" : sid; - } - - public void setSid(@NonNull String sid) { - this.sid = sid; - } - - public String getStatus() { - return status == null ? "" : status; - } - - public void setStatus(@NonNull String status) { - this.status = status; - } - - public String getAlarm() { - return alarm == null ? "" : alarm; - } - - public void setAlarm(@NonNull String alarm) { - this.alarm = alarm; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkFunctionBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkFunctionBean.java deleted file mode 100644 index e7a86c8..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkFunctionBean.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.hdl.sdk.link.bean; - -import androidx.annotation.NonNull; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by jlchen on 1/6/22. - */ -public class LinkFunctionBean implements Serializable { - private String sid;//鍔熻兘鐨剆id - private String oid;//妯″潡鐨刼id - private String name;//鍔熻兘鍥炶矾鍚嶅瓧 - private String spk;//spk - private String omodel; - private String src; - private String online; - private List<LinkAttributesBean> attributes = new ArrayList<>();//鍔熻兘灞炴�э紝闇�瑕佸崟鐙彂閫佸姛鑳藉睘鎬ц鍙栫殑鎸囦护璇诲洖鏉� - private List<LinkStatusBean> status = new ArrayList<>();//褰撳墠璁惧鐘舵�佸�硷紝璁惧鎺у埗鐨勬椂鍊欐墠鐢ㄥ埌 - - private boolean templateFlag = false;//妯℃澘鏍囪 - - /** - * 1:灞曠ず 2:涓嶅睍绀� - */ - private String show; - - public String getShow() { - return show == null ? "1" : show; - } - - public void setShow(@NonNull String show) { - this.show = show; - } - - - public boolean isTemplateFlag() { - return templateFlag; - } - - public void setTemplateFlag(boolean templateFlag) { - this.templateFlag = templateFlag; - } - - - @NonNull - public String getSid() { - return sid == null ? "" : sid; - } - - public void setSid(@NonNull String sid) { - this.sid = sid; - } - - @NonNull - public String getOid() { - return oid == null ? "" : oid; - } - - public void setOid(@NonNull String oid) { - this.oid = oid; - } - - @NonNull - public String getName() { - return name == null ? "" : name; - } - - public void setName(@NonNull String name) { - this.name = name; - } - - @NonNull - public String getSpk() { - return spk == null ? "" : spk; - } - - public void setSpk(@NonNull String spk) { - this.spk = spk; - } - - @NonNull - public String getOmodel() { - return omodel == null ? "" : omodel; - } - - public void setOmodel(@NonNull String omodel) { - this.omodel = omodel; - } - - @NonNull - public String getSrc() { - return src == null ? "" : src; - } - - public void setSrc(@NonNull String src) { - this.src = src; - } - - @NonNull - public String getOnline() { - return online == null ? "" : online; - } - - public void setOnline(@NonNull String online) { - this.online = online; - } - - @NonNull - public List<LinkStatusBean> getStatus() { - if (status == null) { - return new ArrayList<>(); - } - return status; - } - - public void setStatus(@NonNull List<LinkStatusBean> status) { - this.status = status; - } - - @NonNull - public List<LinkAttributesBean> getAttributes() { - if (attributes == null) { - return new ArrayList<>(); - } - return attributes; - } - - public void setAttributes(@NonNull List<LinkAttributesBean> attributes) { - this.attributes = attributes; - } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkFunctionWithRoomBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkFunctionWithRoomBean.java deleted file mode 100644 index dfb6b22..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkFunctionWithRoomBean.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import androidx.annotation.NonNull; - -/** - * Created by jlchen on 1/6/22. - */ -public class LinkFunctionWithRoomBean implements Serializable { - private String sid;//鍔熻兘鐨剆id - private String oid;//妯″潡鐨刼id - private String name;//鍔熻兘鍥炶矾鍚嶅瓧 - private String spk;//spk - private String omodel; - private String src; - private String online; - private String roomName; - private List<LinkAttributesBean> attributes = new ArrayList<>();//鍔熻兘灞炴�э紝闇�瑕佸崟鐙彂閫佸姛鑳藉睘鎬ц鍙栫殑鎸囦护璇诲洖鏉� - private List<LinkStatusBean> status = new ArrayList<>();//褰撳墠璁惧鐘舵�佸�硷紝璁惧鎺у埗鐨勬椂鍊欐墠鐢ㄥ埌 - - private boolean templateFlag = false;//妯℃澘鏍囪 - - /** - * 1:灞曠ず 2:涓嶅睍绀� - */ - private String show; - - private boolean hasRoom; - - public boolean isHasRoom() { - return hasRoom; - } - - public void setHasRoom(@NonNull boolean hasRoom) { - this.hasRoom = hasRoom; - } - - public String getRoomName() { - return roomName == null ? "" : roomName; - } - - public void setRoomName(@NonNull String roomName) { - this.roomName = roomName; - } - - public String getShow() { - return show == null ? "1" : show; - } - - public void setShow(@NonNull String show) { - this.show = show; - } - - - public boolean isTemplateFlag() { - return templateFlag; - } - - public void setTemplateFlag(boolean templateFlag) { - this.templateFlag = templateFlag; - } - - - @NonNull - public String getSid() { - return sid == null ? "" : sid; - } - - public void setSid(@NonNull String sid) { - this.sid = sid; - } - - @NonNull - public String getOid() { - return oid == null ? "" : oid; - } - - public void setOid(@NonNull String oid) { - this.oid = oid; - } - - @NonNull - public String getName() { - return name == null ? "" : name; - } - - public void setName(@NonNull String name) { - this.name = name; - } - - @NonNull - public String getSpk() { - return spk == null ? "" : spk; - } - - public void setSpk(@NonNull String spk) { - this.spk = spk; - } - - @NonNull - public String getOmodel() { - return omodel == null ? "" : omodel; - } - - public void setOmodel(@NonNull String omodel) { - this.omodel = omodel; - } - - @NonNull - public String getSrc() { - return src == null ? "" : src; - } - - public void setSrc(@NonNull String src) { - this.src = src; - } - - @NonNull - public String getOnline() { - return online == null ? "" : online; - } - - public void setOnline(@NonNull String online) { - this.online = online; - } - - @NonNull - public List<LinkStatusBean> getStatus() { - if (status == null) { - return new ArrayList<>(); - } - return status; - } - - public void setStatus(@NonNull List<LinkStatusBean> status) { - this.status = status; - } - - @NonNull - public List<LinkAttributesBean> getAttributes() { - if (attributes == null) { - return new ArrayList<>(); - } - return attributes; - } - - public void setAttributes(@NonNull List<LinkAttributesBean> attributes) { - this.attributes = attributes; - } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkIrDeviceBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkIrDeviceBean.java deleted file mode 100644 index df0dd4e..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkIrDeviceBean.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2023/3/13 - * description: - */ -public class LinkIrDeviceBean implements Serializable { - private String sid; - private String name; - private String spk; - private String oid; - private String omodel; - private String online; - private List<LinkAttributesBean> attributes = new ArrayList<>(); - - public String getSid() { - return sid == null ? "" : sid; - } - - public void setSid(@NonNull String sid) { - this.sid = sid; - } - - public String getName() { - return name == null ? "" : name; - } - - public void setName(@NonNull String name) { - this.name = name; - } - - public String getSpk() { - return spk == null ? "" : spk; - } - - public void setSpk(@NonNull String spk) { - this.spk = spk; - } - - public String getOid() { - return oid == null ? "" : oid; - } - - public void setOid(@NonNull String oid) { - this.oid = oid; - } - - public String getOmodel() { - return omodel == null ? "" : omodel; - } - - public void setOmodel(@NonNull String omodel) { - this.omodel = omodel; - } - - public String getOnline() { - return online == null ? "" : online; - } - - public void setOnline(@NonNull String online) { - this.online = online; - } - - public List<LinkAttributesBean> getAttributes() { - if (attributes == null) { - return attributes = new ArrayList<>(); - } - return attributes; - } - - public void setAttributes(@NonNull List<LinkAttributesBean> attributes) { - this.attributes = attributes; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkLogicBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkLogicBean.java deleted file mode 100644 index d0e6f69..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkLogicBean.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/2/16 - * description: 鏄惁鍚屾椂琛ㄧず瀹夐槻璺熻嚜鍔ㄥ寲??? 闇�瑕佹爣娉ㄤ竴涓�????鏄惁闇�瑕佹洿鏂颁竴涓被鍚� - */ -public class LinkLogicBean implements Serializable { - private String sid; - private String name; - /** - * 鑷姩鍖栧紑鍚叧闂� - */ - private String enable; - /** - * 瀹夐槻甯冮槻鎾ら槻浣跨敤 - */ - private String status; - private String gatewayId; - private LinkCreateLogicBean detailInfo = new LinkCreateLogicBean(); - - public String getGateWayId() { - return gatewayId == null ? "" : gatewayId; - } - - public void setGateWayId(@NonNull String gateWayId) { - this.gatewayId = gateWayId; - } - - public String getStatus() { - return status == null ? "" : status; - } - - public void setStatus(@NonNull String status) { - this.status = status; - } - - public String getSid() { - return sid == null ? "" : sid; - } - - public void setSid(@NonNull String sid) { - this.sid = sid; - } - - public String getName() { - return name == null ? "" : name; - } - - public void setName(@NonNull String name) { - this.name = name; - } - - public String getEnable() { - return enable == null ? "" : enable; - } - - public void setEnable(@NonNull String enable) { - this.enable = enable; - } - - public LinkCreateLogicBean getDetailInfo() { - return detailInfo; - } - - public void setDetailInfo(@NonNull LinkCreateLogicBean detailInfo) { - this.detailInfo = detailInfo; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkOidBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkOidBean.java deleted file mode 100644 index ecea4da..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkOidBean.java +++ /dev/null @@ -1,174 +0,0 @@ -package com.hdl.sdk.link.bean; - -import androidx.annotation.NonNull; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by jlchen on 1/10/22. - * Link Oid妯″潡瀵硅薄 - */ -public class LinkOidBean implements Serializable { - - private String oid;//oid - private String device_name;//妯″潡鍚嶅瓧 - private String device_mac;//妯″潡Mac鍦板潃銆乑igBee鐨凞eviceAddr - private String device_model;//ZigBee鐨凪odelIdentifier - private String addresses;// - private String driver_code;// - private String hw_version;//纭欢鐗堟湰 - private String fw_version; - private String src;//鏉ヨ嚜閭d釜椹卞姩 - private String from;//鏉ヨ嚜閭d釜缃戝叧 - private final String protocolType="zigbee";//鍗忚绫诲瀷(bus銆乲nx銆亃igbee) - private String parentOid;//鐖惰澶噊id - private List<ImageInfoBean> image_info = new ArrayList<>();// 涓�涓澶囧彲鑳藉涓浐浠剁増鏈� 鍥轰欢鐗堟湰鍒楄〃 - - // private boolean templateFlag = false;//妯℃澘鏍囪 -// -// public boolean isTemplateFlag() { -// return templateFlag; -// } -// -// public void setTemplateFlag(boolean templateFlag) { -// this.templateFlag = templateFlag; -// } - @NonNull - public String getParentOid() { - return parentOid == null ? "" : parentOid; - } - - public void setParentOid(String parentOid) { - this.parentOid = parentOid; - } - - @NonNull - public String getOid() { - return oid == null ? "" : oid; - } - - public void setOid(@NonNull String oid) { - this.oid = oid; - } - - @NonNull - public String getDevice_name() { - return device_name == null ? "" : device_name; - } - - public void setDevice_name(@NonNull String device_name) { - this.device_name = device_name; - } - - @NonNull - public String getDevice_mac() { - return device_mac == null ? "" : device_mac; - } - - public void setDevice_mac(@NonNull String device_mac) { - this.device_mac = device_mac; - } - - @NonNull - public String getDevice_model() { - return device_model == null ? "" : device_model; - } - - public void setDevice_model(@NonNull String device_model) { - this.device_model = device_model; - } - - @NonNull - public String getAddresses() { - return addresses == null ? "" : addresses; - } - - public void setAddresses(@NonNull String addresses) { - this.addresses = addresses; - } - - @NonNull - public String getDriver_code() { - return driver_code == null ? "" : driver_code; - } - - public void setDriver_code(@NonNull String driver_code) { - this.driver_code = driver_code; - } - - @NonNull - public String getHw_version() { - return hw_version == null ? "" : hw_version; - } - - public void setHw_version(@NonNull String hw_version) { - this.hw_version = hw_version; - } - - @NonNull - public String getFw_version() { - return fw_version == null ? "" : fw_version; - } - - public void setFw_version(@NonNull String fw_version) { - this.fw_version = fw_version; - } - - @NonNull - public String getSrc() { - return src == null ? "" : src; - } - - public void setSrc(@NonNull String src) { - this.src = src; - } - - @NonNull - public String getFrom() { - return from == null ? "" : from; - } - - public void setFrom(@NonNull String from) { - this.from = from; - } - - @NonNull - public List<ImageInfoBean> getImage_info() { - if (image_info == null) { - return new ArrayList<>(); - } - return image_info; - } - - public void setImage_info(@NonNull List<ImageInfoBean> image_info) { - this.image_info = image_info; - } - - /** - * 鍥轰欢鍜岀‖浠剁増鏈� - */ - public static class ImageInfoBean implements Serializable { - private String imageId; - private String fw_version; - - @NonNull - public String getImageId() { - return imageId == null ? "" : imageId; - } - - public void setImageId(@NonNull String imageId) { - this.imageId = imageId; - } - - @NonNull - public String getFw_version() { - return fw_version == null ? "" : fw_version; - } - - public void setFw_version(@NonNull String fw_version) { - this.fw_version = fw_version; - } - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkOtaBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkOtaBean.java deleted file mode 100644 index 4e72b64..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkOtaBean.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import androidx.annotation.NonNull; - -/** - * Created by jlchen on 1/13/22. - * - */ -public class LinkOtaBean implements Serializable { - - private String oid; - private String module; - private long size; - private String version; - private String url; - private String sign_method; - private String sign; - - public String getSign_method() { - return sign_method == null ? "" : sign_method; - } - - public void setSign_method(@NonNull String sign_method) { - this.sign_method = sign_method; - } - - public String getSign() { - return sign == null ? "" : sign; - } - - public void setSign(@NonNull String sign) { - this.sign = sign; - } - - public String getOid() { - return oid == null ? "" : oid; - } - - public void setOid(@NonNull String oid) { - this.oid = oid; - } - - public String getModule() { - return module == null ? "" : module; - } - - public void setModule(@NonNull String module) { - this.module = module; - } - - public long getSize() { - return size; - } - - public void setSize(@NonNull long size) { - this.size = size; - } - - public String getVersion() { - return version == null ? "" : version; - } - - public void setVersion(@NonNull String version) { - this.version = version; - } - - public String getUrl() { - return url == null ? "" : url; - } - - public void setUrl(@NonNull String url) { - this.url = url; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkReNameGWBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkReNameGWBean.java deleted file mode 100644 index 3e50f5c..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkReNameGWBean.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.hdl.sdk.link.bean; - -import androidx.annotation.NonNull; - -import java.io.Serializable; - -public class LinkReNameGWBean implements Serializable { - private String device_name; - - public String getDevice_name() { - return device_name == null ? "" : device_name; - } - - public void setDevice_name(@NonNull String device_name) { - this.device_name = device_name; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkResponseBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkResponseBean.java deleted file mode 100644 index ef27efd..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkResponseBean.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/1/13 - * description: - */ -public class LinkResponseBean implements Serializable { - private String id; - private String code; - private String time_stamp; - - public String getId() { - return id == null ? "" : id; - } - - public void setId(@NonNull String id) { - this.id = id; - } - - public String getCode() { - return code == null ? "" : code; - } - - public void setCode(@NonNull String code) { - this.code = code; - } - - public String getTime_stamp() { - return time_stamp == null ? "" : time_stamp; - } - - public void setTime_stamp(@NonNull String time_stamp) { - this.time_stamp = time_stamp; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkRoomBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkRoomBean.java deleted file mode 100644 index cec4779..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkRoomBean.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.hdl.sdk.link.bean; - -import androidx.annotation.NonNull; - -import java.io.Serializable; - -/** - * Created by jlchen on 12/20/21. - */ -public class LinkRoomBean implements Serializable { - - private String uid;//鎴块棿鎴栬�呮ゼ灞傜殑Id - private String name;//鎴块棿鎴栬�呮ゼ灞傚悕瀛� - private String roomType;//绫诲瀷 FLOOR = 妤煎眰 ROOM = 鎴块棿 - private String roomImage;//鎴块棿鍥剧墖 - private String parentId;//鐖惰妭鐐笽d锛屾埧闂村垎閰嶇殑妤煎眰鐨処D - - public LinkRoomBean(String name) { - this.name = name; - } - - public LinkRoomBean() { - - } - - @NonNull - public String getUid() { - return uid == null ? "" : uid; - } - - public void setUid(@NonNull String uid) { - this.uid = uid; - } - - @NonNull - public String getName() { - return name == null ? "" : name; - } - - public void setName(@NonNull String name) { - this.name = name; - } - - @NonNull - public String getRoomType() { - return roomType == null ? "" : roomType; - } - - public void setRoomType(@NonNull String roomType) { - this.roomType = roomType; - } - - @NonNull - public String getRoomImage() { - return roomImage == null ? "" : roomImage; - } - - public void setRoomImage(@NonNull String roomImage) { - this.roomImage = roomImage; - } - - @NonNull - public String getParentId() { - return parentId == null ? "" : parentId; - } - - public void setParentId(@NonNull String parentId) { - this.parentId = parentId; - } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkRoomBindBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkRoomBindBean.java deleted file mode 100644 index 1d0dd28..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkRoomBindBean.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.hdl.sdk.link.bean; - -import androidx.annotation.NonNull; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by jlchen on 1/10/22. - */ -public class LinkRoomBindBean implements Serializable{ - - private String uid;//鎴块棿uid - private List<LinkSidStrBean> functions = new ArrayList<>();//鍔熻兘鍒楄〃 - private List<LinkSidStrBean> scenes = new ArrayList<>();//鍦烘櫙鍒楄〃鍒楄〃 - - @NonNull - public String getUid() { - return uid == null ? "" : uid; - } - - public void setUid(@NonNull String uid) { - this.uid = uid; - } - - @NonNull - public List<LinkSidStrBean> getFunctions() { - if (functions == null) { - return new ArrayList<>(); - } - return functions; - } - - public void setFunctions(@NonNull List<LinkSidStrBean> functions) { - this.functions = functions; - } - - @NonNull - public List<LinkSidStrBean> getScenes() { - if (scenes == null) { - return new ArrayList<>(); - } - return scenes; - } - - public void setScenes(@NonNull List<LinkSidStrBean> scenes) { - this.scenes = scenes; - } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkSidNameBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkSidNameBean.java deleted file mode 100644 index 666f534..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkSidNameBean.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/1/13 - * description: - */ -public class LinkSidNameBean implements Serializable { - private String sid; - private String name; - - public String getSid() { - return sid == null ? "" : sid; - } - - public void setSid(@NonNull String sid) { - this.sid = sid; - } - - public String getName() { - return name == null ? "" : name; - } - - public void setName(@NonNull String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkSidStrBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkSidStrBean.java deleted file mode 100644 index a6d99a5..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkSidStrBean.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.hdl.sdk.link.bean; - -import androidx.annotation.NonNull; -import java.io.Serializable; - -/** - * Created by jlchen on 1/10/22. - * - * 璁惧鎴栬�呭満鏅痵id - */ -public class LinkSidStrBean implements Serializable { - - private String sid;//璁惧鎴栬�呭満鏅痵id - - public LinkSidStrBean() { - } - - public LinkSidStrBean(String sid) { - this.sid = sid; - } - - @NonNull - public String getSid() { - return sid == null ? "" : sid; - } - - public void setSid(@NonNull String sid) { - this.sid = sid; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkSidUidBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkSidUidBean.java deleted file mode 100644 index f52f858..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkSidUidBean.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/1/13 - * description: - */ -public class LinkSidUidBean implements Serializable { - private String uid; - private List<LinkSidStrBean> functions = new ArrayList<>(); - - public String getUid() { - return uid == null ? "" : uid; - } - - public void setUid(@NonNull String uid) { - this.uid = uid; - } - - public List<LinkSidStrBean> getFunctions() { - if (functions == null) { - return new ArrayList<>(); - } - return functions; - } - - public void setFunctions(@NonNull List<LinkSidStrBean> functions) { - this.functions = functions; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkStatusBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkStatusBean.java deleted file mode 100644 index 3528ea8..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkStatusBean.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by jlchen on 1/13/22. - */ -public class LinkStatusBean implements Serializable { - - private String key; - private String value; - - @NonNull - public String getKey() { - return key == null ? "" : key; - } - - public void setKey(@NonNull String key) { - this.key = key; - } - - @NonNull - public String getValue() { - return value == null ? "" : value; - } - - public void setValue(@NonNull String value) { - this.value = value; - } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkUploadOidBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkUploadOidBean.java deleted file mode 100644 index 4ab629e..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/LinkUploadOidBean.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import androidx.annotation.NonNull; - -public class LinkUploadOidBean implements Serializable{ - - private String oid;//oid - private String device_name;//妯″潡鍚嶅瓧 - private String device_mac;//妯″潡Mac鍦板潃銆乑igBee鐨凞eviceAddr - private String device_model;//ZigBee鐨凪odelIdentifier - private String addresses;// - private String driver_code;// - private String hw_version;//纭欢鐗堟湰 - private String fw_version; - - @NonNull - public String getOid() { - return oid == null ? "" : oid; - } - - public void setOid(@NonNull String oid) { - this.oid = oid; - } - - @NonNull - public String getDevice_name() { - return device_name == null ? "" : device_name; - } - - public void setDevice_name(@NonNull String device_name) { - this.device_name = device_name; - } - - @NonNull - public String getDevice_mac() { - return device_mac == null ? "" : device_mac; - } - - public void setDevice_mac(@NonNull String device_mac) { - this.device_mac = device_mac; - } - - @NonNull - public String getDevice_model() { - return device_model == null ? "" : device_model; - } - - public void setDevice_model(@NonNull String device_model) { - this.device_model = device_model; - } - - @NonNull - public String getAddresses() { - return addresses == null ? "" : addresses; - } - - public void setAddresses(@NonNull String addresses) { - this.addresses = addresses; - } - - @NonNull - public String getDriver_code() { - return driver_code == null ? "" : driver_code; - } - - public void setDriver_code(@NonNull String driver_code) { - this.driver_code = driver_code; - } - - @NonNull - public String getHw_version() { - return hw_version == null ? "" : hw_version; - } - - public void setHw_version(@NonNull String hw_version) { - this.hw_version = hw_version; - } - - @NonNull - public String getFw_version() { - return fw_version == null ? "" : fw_version; - } - - public void setFw_version(@NonNull String fw_version) { - this.fw_version = fw_version; - } - - - - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/NoticeConfigInfo.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/NoticeConfigInfo.java deleted file mode 100644 index 8381b75..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/bean/NoticeConfigInfo.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hdl.sdk.link.bean; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/7/29 - * description: - */ -public class NoticeConfigInfo implements Serializable { - private boolean enable; - private String noticeContent; - - public boolean isEnable() { - return enable; - } - - public void setEnable(@NonNull boolean enable) { - this.enable = enable; - } - - public String getNoticeContent() { - return noticeContent == null ? "" : noticeContent; - } - - public void setNoticeContent(@NonNull String noticeContent) { - this.noticeContent = noticeContent; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/IHDLClient.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/IHDLClient.java deleted file mode 100644 index 2ba494a..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/IHDLClient.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.hdl.sdk.link.common; - -/** - * Created by Tong on 2021/9/28. - * 鍖呭惈鎵�鏈夋搷浣� - */ -public interface IHDLClient { - - - /** - * 鎼滅储缃戝叧 - */ - void searchGateway(); - - - /** - * 鑾峰彇缃戝叧璇︾粏淇℃伅 - */ - void getGatewayInfo(); - - /** - * 鑾峰彇璁惧鍒楄〃 - */ - void getDeviceList(); - - /** - * 鑾峰彇鍔熻兘鍒楄〃 - */ - void getFunctionList(); - - /** - * 鑾峰彇鍔熻兘灞炴�� - */ - void getFunctionAttribute(); - - /** - * 璁惧鎺у埗 - */ - void deviceControl(); - - /** - * 鑾峰彇璁惧鐘舵�� - */ - void getDeviceStatus(); - - /** - * 鏀瑰彉璁惧鐘舵�� - */ - void changeDeviceStatus(); - - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/event/EventListener.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/event/EventListener.java deleted file mode 100644 index e2b3cdf..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/event/EventListener.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.hdl.sdk.link.common.event; - -/** - * Created by Tong on 2021/9/22. - */ -public interface EventListener { - - void onMessage(Object msg); - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/exception/HDLLinkException.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/exception/HDLLinkException.java deleted file mode 100644 index 040ff3b..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/exception/HDLLinkException.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.hdl.sdk.link.common.exception; - -import androidx.annotation.NonNull; - -/** - * Created by Tong on 2021/11/11. - */ -public class HDLLinkException extends RuntimeException { - - private int code = 0; - private String msg = ""; - private Throwable rawThrowable; - - public HDLLinkException() { - } - - public HDLLinkException(String msg) { - this.msg = msg; - } - - public HDLLinkException(int code, String msg) { - this.code = code; - this.msg = msg; - } - - public HDLLinkException(int code) { - this.code = code; - } - - public HDLLinkException(Throwable rawThrowable) { - this.rawThrowable = rawThrowable; - } - - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public @NonNull - String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } - - public Throwable getRawThrowable() { - return rawThrowable; - } - - public void setRawThrowable(Throwable rawThrowable) { - this.rawThrowable = rawThrowable; - } - - public static HDLLinkException getErrorWithCode(HDLLinkCode code){ - return new HDLLinkException(code.getCode(), code.getMsg()); - } - - public static HDLLinkException getErrorWithCode(int code,String msg){ - return new HDLLinkException(code,msg); - } -} - diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/ErrorUtils.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/ErrorUtils.java deleted file mode 100644 index 52bc4cd..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/ErrorUtils.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.hdl.sdk.link.common.utils; - -import com.hdl.sdk.link.HDLLinkLocalSdk; -import com.hdl.sdk.link.R; -import com.hdl.sdk.link.common.exception.HDLLinkCode; - -import java.util.HashMap; - -/** - * Created by hxb on 2023/4/22. - */ -public class ErrorUtils { - //閿�:code 鍊硷細涓嫳鏂囨弿杩� - public static final HashMap<String, String> errorsMap = new HashMap<>(); - - - - /** - * 閫氳繃鐘舵�佺爜鑾峰彇寮傚父瀵硅薄 - * @param code 鐘舵�佺爜 - * @return 寮傚父瀵硅薄 - */ - public static HDLLinkCode getByCode(int code) { - String msg = errorsMap.get(code + ""); - if (msg == null) { - msg = "unkown"; - } - return new HDLLinkCode(code, msg); - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/IdUtils.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/IdUtils.java deleted file mode 100644 index 2b8e659..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/IdUtils.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hdl.sdk.link.common.utils; - -import java.util.UUID; - -/** - * Created by Tong on 2021/10/8. - */ -public class IdUtils { - public static String getUUId() { - return UUID.randomUUID().toString().replaceAll("-", ""); - } - - /** - * Uid 鍒楄〃鍒涘缓浣跨敤 - * @return - */ - public static String getUUIdWithBar() { - return UUID.randomUUID().toString(); - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/IpUtils.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/IpUtils.java deleted file mode 100644 index aadb63e..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/IpUtils.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.hdl.sdk.link.common.utils; - -import android.content.Context; -import android.net.wifi.WifiInfo; -import android.net.wifi.WifiManager; - -import java.net.InetAddress; -import java.net.InterfaceAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.util.Enumeration; - -/** - * Created by Tong on 2021/9/27. - */ -public class IpUtils { - - /** - * @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(); - } - return "255.255.255.255"; - } - - public static boolean isLocalIpAddress(String ipAddress) { - try { - for (Enumeration<NetworkInterface> niEnum = NetworkInterface.getNetworkInterfaces(); - niEnum.hasMoreElements(); ) { - NetworkInterface ni = niEnum.nextElement(); - for (InterfaceAddress interfaceAddress : ni.getInterfaceAddresses()) { - if (ipAddress.equals(interfaceAddress.getAddress().getHostAddress())) { - return true; - } - } - } - } catch (SocketException e) { - e.printStackTrace(); - } - return false; - } - - public static String getIP(Context application) { - WifiManager wifiManager = (WifiManager) application.getApplicationContext().getSystemService(Context.WIFI_SERVICE); - if (!wifiManager.isWifiEnabled()) { - try { - for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) { - NetworkInterface intf = en.nextElement(); - for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements(); ) { - InetAddress inetAddress = enumIpAddr.nextElement(); - if (!inetAddress.isLoopbackAddress()) { - return inetAddress.getHostAddress(); - } - } - } - } catch (SocketException e) { - e.printStackTrace(); - } - } else { - WifiInfo wifiInfo = wifiManager.getConnectionInfo(); - int ipAddress = wifiInfo.getIpAddress(); - return intToIp(ipAddress); - } - return null; - } - - - private static String intToIp(int i) { - - return (i & 0xFF) + "." + - ((i >> 8) & 0xFF) + "." + - ((i >> 16) & 0xFF) + "." + - (i >> 24 & 0xFF); - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/LockArrayMap.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/LockArrayMap.java deleted file mode 100644 index aa75a6e..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/LockArrayMap.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hdl.sdk.link.common.utils; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.collection.ArrayMap; - -/** - * Created by hxb on 2022/10/17. - */ -public class LockArrayMap<K,V> extends ArrayMap<K, V> { - @Nullable - @Override - public V put(K key, V value) { - synchronized (this) { - return super.put(key, value); - } - } - - @Override - public boolean remove(Object key, Object value) { - synchronized (this) { - return super.remove(key, value); - } - } - - @Override - public boolean containsKey(@Nullable Object key) { - synchronized (this) { - return super.containsKey(key); - } - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/LockList.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/LockList.java deleted file mode 100644 index 715d63d..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/LockList.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.hdl.sdk.link.common.utils; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.collection.ArrayMap; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; - -/** - * Created by hxb on 2022/10/17. - */ -public class LockList<T> extends ArrayList<T> { - - @Override - public boolean add(T t) { - synchronized (this) { - return super.add(t); - } - } - - @Override - public T remove(int index) { - synchronized (this) { - return super.remove(index); - } - } - - @Override - public boolean contains(@Nullable Object o) { - synchronized (this) { - return super.contains(o); - } - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/LogUtils.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/LogUtils.java deleted file mode 100644 index 1228aad..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/LogUtils.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.hdl.sdk.link.common.utils; - -import android.util.Log; - -/** - * Created by Tong on 2021/9/23. - */ -public class LogUtils { - - private static final String TAG = "HDLSDK"; - - private static boolean isEnabled = true; - - public static boolean isEnabled() { - return isEnabled; - } - - public static void setEnabled(boolean enabled) { - isEnabled = enabled; - } - - public static void d(String tag, String msg) { - if (tag != null && msg != null && isEnabled) { - Log.d(TAG, tag + "-- " + msg); - } - } - - public static void e(String tag, String msg) { - if (tag != null && msg != null && isEnabled) { - Log.e(TAG, tag + "-- " + msg); - } - } - - public static void w(String tag, String msg) { - if (tag != null && msg != null && isEnabled) { - Log.w(TAG, tag + "-- " + msg); - } - } - - public static void v(String tag, String msg) { - if (tag != null && msg != null && isEnabled) { - Log.v(TAG, tag + "-- " + msg); - } - } - - public static void i(String tag, String msg) { - if (tag != null && msg != null && isEnabled) { - Log.i(TAG, tag + "-- " + msg); - } - } - - public static void i(String msg) { - if (msg != null && isEnabled) { - Log.i(TAG, msg); - } - } - - public static void e(String msg) { - if (msg != null && isEnabled) { - Log.e(TAG, msg); - } - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/SPUtils.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/SPUtils.java deleted file mode 100644 index f5b8810..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/SPUtils.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.hdl.sdk.link.common.utils; - -import android.content.Context; -import android.content.SharedPreferences; - -import androidx.annotation.NonNull; - - -import com.hdl.sdk.link.HDLLinkLocalSdk; - -import java.util.Collections; -import java.util.Map; -import java.util.Set; - -/** - * Created by Tong on 2021/9/28. - */ -public class SPUtils { - private static final String APP_PREFERENCES_KEY = "profile"; - private static SharedPreferences PREFERENCES = - HDLLinkLocalSdk.getInstance().getContext().getApplicationContext().getSharedPreferences(APP_PREFERENCES_KEY, Context.MODE_PRIVATE); - - private static SharedPreferences getAppPreference() { - if (PREFERENCES == null) { - PREFERENCES = HDLLinkLocalSdk.getInstance().getContext().getApplicationContext().getSharedPreferences(APP_PREFERENCES_KEY, Context.MODE_PRIVATE); - } - return PREFERENCES; - } - - - //======閫氱敤瀛樺偍======== - public static void put(@NonNull final String key, final String value) { - getAppPreference().edit().putString(key, value).apply(); - } - - - public static String getString(@NonNull final String key) { - return getString(key, ""); - } - - - public static String getString(@NonNull final String key, final String defaultValue) { - return getAppPreference().getString(key, defaultValue); - } - - - public static void put(@NonNull final String key, final int value) { - put(key, value, false); - } - - - public static void put(@NonNull final String key, final int value, final boolean isCommit) { - getAppPreference().edit().putInt(key, value).apply(); - } - - - public static int getInt(@NonNull final String key) { - return getInt(key, -1); - } - - - public static int getInt(@NonNull final String key, final int defaultValue) { - return getAppPreference().getInt(key, defaultValue); - } - - - public static void put(@NonNull final String key, final long value) { - getAppPreference().edit().putLong(key, value).apply(); - } - - - public static long getLong(@NonNull final String key) { - return getLong(key, -1L); - } - - - public static long getLong(@NonNull final String key, final long defaultValue) { - return getAppPreference().getLong(key, defaultValue); - } - - - public static void put(@NonNull final String key, final float value) { - getAppPreference().edit().putFloat(key, value).apply(); - } - - - public static float getFloat(@NonNull final String key) { - return getFloat(key, -1f); - } - - - public static float getFloat(@NonNull final String key, final float defaultValue) { - return getAppPreference().getFloat(key, defaultValue); - } - - - public static void put(@NonNull final String key, final boolean value) { - getAppPreference().edit().putBoolean(key, value).apply(); - } - - - public static boolean getBoolean(@NonNull final String key) { - return getBoolean(key, false); - } - - - public static boolean getBoolean(@NonNull final String key, final boolean defaultValue) { - return getAppPreference().getBoolean(key, defaultValue); - } - - - public static void put(@NonNull final String key, - final Set<String> value - ) { - - getAppPreference().edit().putStringSet(key, value).apply(); - - } - - - public static Set<String> getStringSet(@NonNull final String key) { - return getStringSet(key, Collections.<String>emptySet()); - } - - - public static Set<String> getStringSet(@NonNull final String key, - final Set<String> defaultValue) { - return getAppPreference().getStringSet(key, defaultValue); - } - - - public static Map<String, ?> getAll() { - return getAppPreference().getAll(); - } - - - public static boolean contains(@NonNull final String key) { - return getAppPreference().contains(key); - } - - - public static void remove(@NonNull final String key) { - getAppPreference().edit().remove(key).apply(); - } - - public static void clear() { - getAppPreference() - .edit() - .clear() - .apply(); - } - - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/ThreadToolUtils.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/ThreadToolUtils.java deleted file mode 100644 index 5110598..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/ThreadToolUtils.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.hdl.sdk.link.common.utils; - -import android.os.Handler; -import android.os.Looper; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; - -/** - * Created by Tong on 2021/9/15. - */ -public class ThreadToolUtils { - - private final Handler uiHandler = new Handler(Looper.getMainLooper()); - - //cpu 鏈�澶х嚎绋嬪绾抽噺 - private final int coreSize = Runtime.getRuntime().availableProcessors() + 1; - - private ThreadToolUtils() { - } - - private static class SingletonInstance { - private static final ThreadToolUtils INSTANCE = new ThreadToolUtils(); - } - - public static ThreadToolUtils getInstance() { - return SingletonInstance.INSTANCE; - } - - - /** - * 绾跨▼鏁伴噺鍥哄畾鐨勭嚎绋嬫睜 - */ - public ExecutorService newFixedThreadPool(int size) { - if (size == 0 || coreSize < size) { - return Executors.newFixedThreadPool(coreSize); - } - return Executors.newFixedThreadPool(size); - } - - /** - * 瀹氭椂浠诲姟绾跨▼姹� - */ - public ScheduledExecutorService newScheduledThreadPool(int size) { - if (size == 0 || coreSize < size) { - return Executors.newScheduledThreadPool(coreSize); - } - return Executors.newScheduledThreadPool(size); - } - - /** - * 鍗曚竴绾跨▼ - */ - public ExecutorService newSingleThreadPool() { - return Executors.newSingleThreadExecutor(); - } - - - public ExecutorService newCachedThreadPool() { - return Executors.newCachedThreadPool(); - } - - /** - * 鍒囨崲鍥炰富绾跨▼ - */ - public void runOnUiThread(Runnable run) { - uiHandler.post(run); - } - - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/gson/GsonConvert.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/gson/GsonConvert.java deleted file mode 100644 index 4ba481b..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/gson/GsonConvert.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.hdl.sdk.link.common.utils.gson; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -import java.lang.reflect.Type; - -/** - * Created by Tong on 2021/9/8. - */ -public class GsonConvert { - - private static Gson gson = null; - - public static Gson getGson() { - if (gson == null) { - synchronized (GsonConvert.class) { - if (gson == null) { - gson = new GsonBuilder() - .setPrettyPrinting() - .disableHtmlEscaping() - .registerTypeAdapter(String.class, new StringTypeAdapter()) - .create(); - } - } - } - return gson; - } - - public static <T> T copyProperties(Object o, Type type) { - return getGson().fromJson(getGson().toJson(o), type); - } - - private static class StringTypeAdapter implements JsonSerializer<String>, JsonDeserializer<String> { - @Override - public String deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) - throws JsonParseException { - if (json instanceof JsonPrimitive) { - return json.getAsString(); - } else { - return json.toString(); - } - } - - @Override - public JsonElement serialize(String src, Type typeOfSrc, JsonSerializationContext context) { - return new JsonPrimitive(src); - } - } - - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/gson/ParameterizedTypeImpl.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/gson/ParameterizedTypeImpl.java deleted file mode 100644 index 642c191..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/common/utils/gson/ParameterizedTypeImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.hdl.sdk.link.common.utils.gson; - - -import androidx.annotation.NonNull; - -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; - -/** - * Created by Tong on 2021/9/17. - */ -public class ParameterizedTypeImpl implements ParameterizedType { - - private final Type[] actualTypeArguments; - private final Type rawType; - private final Type ownerType; - - public ParameterizedTypeImpl(Type rawType, Type[] actualTypeArguments, Type ownerType) { - this.ownerType = ownerType; - this.rawType = rawType; - this.actualTypeArguments = actualTypeArguments; - } - - public static Type getType(Type rawType, Type[] actualTypeArguments) { - return new ParameterizedTypeImpl(rawType, actualTypeArguments, null); - } - - @NonNull - @Override - public Type[] getActualTypeArguments() { - return actualTypeArguments; - } - - - @NonNull - @Override - public Type getRawType() { - return rawType; - } - - - @Override - public Type getOwnerType() { - return ownerType; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/FileRequest.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/FileRequest.java deleted file mode 100644 index 03e7995..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/FileRequest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.hdl.sdk.link.core.bean; - - -/** - * Created by Tong on 2021/9/29. - */ -public class FileRequest extends LinkRequest { - - private String fileId; - private Integer command; - private byte []fileData; - -// private static int info_number; - public FileRequest(String topic, String data, boolean encrypt) { - super(topic, data, encrypt); - } - - - public FileRequest(String fileId, Integer command, byte []fileData,boolean encrypt) { - this.fileId = fileId; - this.command = command; - this.fileData = fileData; -// super.setEncrypt(encrypt); - super.setEncrypt(false); -// info_number++; -// byte[] headBytes = ("hex" + info_number).getBytes(); -// byte[] sendDataBytes = ByteUtils.concatBytes(headBytes, fileData); - super.setData(fileData); - } - - @Override - public byte [] getSendBytes() { - return getData(); - } - - public String getTopic() { - return fileId + "_" + command; - } - - public String getAckTopic() { - return fileId + "_" + ++command; - } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/LinkPacket.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/LinkPacket.java deleted file mode 100644 index 088f82f..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/LinkPacket.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.hdl.sdk.link.core.bean; - -/** - * Created by hxb on 2022/8/4. - */ -public class LinkPacket { - /** - * 涓婚鍐呭 - */ - private String topic; - /** - * 鍘熷鎺ユ敹鐨勬暟鎹紝鍙兘闇�瑕佽В瀵� - */ - private byte []body; - - private boolean cloudPacket; - - public LinkPacket(String topic, byte[] body) { - this(topic,body,false); - } - - public LinkPacket(String topic, byte[] body,boolean cloudPacket) { - this.topic = topic; - this.body = body; - this.cloudPacket=cloudPacket; - } - - - public String getTopic() { - return topic; - } - - public void setTopic(String topic) { - this.topic = topic; - } - - public byte[] getBody() { - return body; - } - - public void setBody(byte[] body) { - this.body = body; - } - - public boolean isCloudPacket() { - return cloudPacket; - } - - public void setCloudPacket(boolean cloudPacket) { - this.cloudPacket = cloudPacket; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/ModbusResponse.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/ModbusResponse.java deleted file mode 100644 index 27c22b0..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/ModbusResponse.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.hdl.sdk.link.core.bean; - -import androidx.annotation.NonNull; - -import com.hdl.sdk.link.common.utils.gson.GsonConvert; - -import java.io.Serializable; - -/** - * Created by hxb on 2021/12/19. - */ -public class ModbusResponse implements Serializable { - - /** - * 鍘熺敓涓婚 - */ - private String topic; - /** - * 鍘熺敓鏁版嵁 - */ - private int []data; - - /** - * 缃戝叧Oid - */ - private String oid; - - - /** - * 鑾峰彇鍘熺敓涓婚 - * - * @return - */ - public String getTopic() { - return topic; - } - - /** - * 璁剧疆鍘熺敓涓婚 - * - * @param topic - */ - public void setTopic(String topic) { - this.topic = topic; - } - - /** - * 鑾峰彇鍘熺敓鏁版嵁 - * - * @return - */ - public int []getData() { - return data; - } - - /** - * 璁剧疆鍘熺敓鏁版嵁 - * - * @param data - */ - public void setData(byte []data) { - if (data == null) { - return; - } - this.data = new int[data.length]; - for (int i = 0; i < data.length; i++) { - this.data[i] = 0xFF & data[i]; - - } - } - - /** - * 鑾峰彇缃戝叧涓昏淇℃伅锛屽彲鑳芥槸oid锛屽彲鑳芥槸缃戝叧Id锛屽彲鑳芥槸mac - * - * @return - */ - public String getOid() { - return oid; - } - - /** - * 璁剧疆Oid - * - * @param - */ - public void setOid(String oid) { - this.oid = oid; - } - - @NonNull - @Override - public String toString() { - return GsonConvert.getGson().toJson(this); - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/ZigbeeResponse.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/ZigbeeResponse.java deleted file mode 100644 index 718facb..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/ZigbeeResponse.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.hdl.sdk.link.core.bean; - -import androidx.annotation.NonNull; - -import com.hdl.sdk.link.common.utils.gson.GsonConvert; - -import java.io.Serializable; - -/** - * Created by hxb on 2021/12/19. - */ -public class ZigbeeResponse implements Serializable { - - /** - * 鍘熺敓涓婚 - */ - private String topic; - /** - * 鍘熺敓鏁版嵁 - */ - private String data; - - /** - * 缃戝叧Oid - */ - private String oid; - - - /** - * 鑾峰彇鍘熺敓涓婚 - * - * @return - */ - public String getTopic() { - return topic; - } - - /** - * 璁剧疆鍘熺敓涓婚 - * - * @param topic - */ - public void setTopic(String topic) { - this.topic = topic; - } - - /** - * 鑾峰彇鍘熺敓鏁版嵁 - * - * @return - */ - public String getData() { - return data; - } - - /** - * 璁剧疆鍘熺敓鏁版嵁 - * - * @param data - */ - public void setData(String data) { - this.data = data; - } - - /** - * 鑾峰彇缃戝叧涓昏淇℃伅锛屽彲鑳芥槸oid锛屽彲鑳芥槸缃戝叧Id锛屽彲鑳芥槸mac - * - * @return - */ - public String getOid() { - return oid; - } - - /** - * 璁剧疆Oid - * - * @param - */ - public void setOid(String oid) { - this.oid = oid; - } - - @NonNull - @Override - public String toString() { - return GsonConvert.getGson().toJson(this); - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/BaseEventBus.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/BaseEventBus.java deleted file mode 100644 index 894e208..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/BaseEventBus.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hdl.sdk.link.core.bean.eventbus; - -public class BaseEventBus { - private String topic; - private String type; - private Object data; - - public String getTopic() { - return topic == null ? "" : topic; - } - - public void setTopic(String topic) { - this.topic = topic; - } - - public String getType() { - return type == null ? "" : type; - } - - public void setType(String type) { - this.type = type; - } - - public Object getData() { - return data; - } - - public void setData(Object data) { - this.data = data; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventBindMiniRemoteSuccessInfo.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventBindMiniRemoteSuccessInfo.java deleted file mode 100644 index 16817ea..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventBindMiniRemoteSuccessInfo.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hdl.sdk.link.core.bean.eventbus; - -import java.io.Serializable; - -/** - * Created by Zoro - * Created on 2021/5/24 - * description: - */ -public class EventBindMiniRemoteSuccessInfo implements Serializable { - -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventCloseSearchDeviceActivityInfo.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventCloseSearchDeviceActivityInfo.java deleted file mode 100644 index 256df37..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventCloseSearchDeviceActivityInfo.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hdl.sdk.link.core.bean.eventbus; - -import java.io.Serializable; - -/** - * Created by Zoro - * Created on 2021/5/24 - * description: - */ -public class EventCloseSearchDeviceActivityInfo implements Serializable { - -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventIRCodeStudySuccessInfo.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventIRCodeStudySuccessInfo.java deleted file mode 100644 index bf18b72..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventIRCodeStudySuccessInfo.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.hdl.sdk.link.core.bean.eventbus; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2021/5/24 - * description: - */ -public class EventIRCodeStudySuccessInfo implements Serializable { - private String topic; - private String content; - - public EventIRCodeStudySuccessInfo(String topic, String content) { - this.topic = topic; - this.content = content; - } - - public String getTopic() { - return topic == null ? "" : topic; - } - - public void setTopic(@NonNull String topic) { - this.topic = topic; - } - - public String getContent() { - return content == null ? "" : content; - } - - public void setContent(@NonNull String content) { - this.content = content; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventMqttAesFailInfo.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventMqttAesFailInfo.java deleted file mode 100644 index 868de85..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventMqttAesFailInfo.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hdl.sdk.link.core.bean.eventbus; - -import java.io.Serializable; - -/** - * Created by Zoro - * Created on 2021/5/24 - * description: - */ -public class EventMqttAesFailInfo implements Serializable { - -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventNotifyDebugModeInfo.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventNotifyDebugModeInfo.java deleted file mode 100644 index 29839f4..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventNotifyDebugModeInfo.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.hdl.sdk.link.core.bean.eventbus; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2021/5/24 - * description: - */ -public class EventNotifyDebugModeInfo implements Serializable { - - private boolean isRemote; - - public boolean isRemote() { - return isRemote; - } - - public void setRemote(@NonNull boolean remote) { - isRemote = remote; - } - - public EventNotifyDebugModeInfo(boolean isRemote) { - this.isRemote = isRemote; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventNotifyGetGateWayInfo.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventNotifyGetGateWayInfo.java deleted file mode 100644 index 5b06130..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventNotifyGetGateWayInfo.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hdl.sdk.link.core.bean.eventbus; - -import java.io.Serializable; - -/** - * Created by Zoro - * Created on 2022/6/29 - * description: - */ -public class EventNotifyGetGateWayInfo implements Serializable { -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventNotifyRefreshGatewayAesKeyInfo.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventNotifyRefreshGatewayAesKeyInfo.java deleted file mode 100644 index 3029952..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/eventbus/EventNotifyRefreshGatewayAesKeyInfo.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.hdl.sdk.link.core.bean.eventbus; - -import java.io.Serializable; - -/** - * Created by Zoro - * Created on 2022/6/29 - * description: - */ -public class EventNotifyRefreshGatewayAesKeyInfo implements Serializable { - - public String getGatewayId() { - return gatewayId; - } - - public void setGatewayId(String gatewayId) { - this.gatewayId = gatewayId; - } - - private String gatewayId; - - -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/AuthenticateRequest.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/AuthenticateRequest.java deleted file mode 100644 index a77548c..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/AuthenticateRequest.java +++ /dev/null @@ -1,310 +0,0 @@ -package com.hdl.sdk.link.core.bean.request; - -import java.io.Serializable; - -/** - * Created by jlchen on 11/11/21. - * - * @Description : AuthenticateRequest - * 涓夋柟缃戠粶璁惧鍏ョ綉鍙婅璇� 璇锋眰鍙傛暟 - * 璇锋眰topic:/user/all/custom/deivce/network_access/request - */ -public class AuthenticateRequest implements Serializable { - private String id; - private String time_stamp; - private AuthenticateDeviceInfoBean objects;//褰撳墠璁惧鍩烘湰淇℃伅 - private AuthBean auth;//璁よ瘉淇℃伅 - - public String getID() { return id; } - public void setID(String value) { this.id = value; } - - public String getTimeStamp() { return time_stamp; } - public void setTimeStamp(String value) { this.time_stamp = value; } - - public AuthenticateDeviceInfoBean getObjects() { return objects; } - public void setObjects(AuthenticateDeviceInfoBean value) { this.objects = value; } - - public AuthBean getAuth() { return auth; } - public void setAuth(AuthBean value) { this.auth = value; } - - public AuthenticateRequest(String id, String time_stamp, AuthenticateDeviceInfoBean objects, AuthBean auth) { - this.id = id; - this.time_stamp = time_stamp; - this.objects = objects; - this.auth = auth; - } - - public static class AuthBean implements Serializable { - private String mac_key;//(mac+secret)鐨勪袱娆d5鍊� - private String spk; - private RequestBean request;//璁惧鐩稿叧淇℃伅 - - public String getMACKey() { return mac_key; } - public void setMACKey(String value) { this.mac_key = value; } - - public String getSpk() { return spk; } - public void setSpk(String value) { this.spk = value; } - - public RequestBean getRequest() { return request; } - public void setRequest(RequestBean value) { this.request = value; } - - public AuthBean() { - - } - public AuthBean(String mac_key, String spk, RequestBean request) { - this.mac_key = mac_key; - this.spk = spk; - this.request = request; - } - } - - public static class RequestBean implements Serializable{ - private String mac;//璁惧mac - private String supplier;//鍘傚 - private String hardware_model;//璁惧鍨嬪彿 - private String firmware_version;//绋嬪簭鐗堟湰 - public RequestBean(){}; - public RequestBean(String mac, String supplier, String hardware_model, String firmware_version) { - this.mac = mac; - this.supplier = supplier; - this.hardware_model = hardware_model; - this.firmware_version = firmware_version; - } - - public String getMAC() { return mac; } - public void setMAC(String value) { this.mac = value; } - - public String getSupplier() { return supplier; } - public void setSupplier(String value) { this.supplier = value; } - - public String getHardwareModel() { return hardware_model; } - public void setHardwareModel(String value) { this.hardware_model = value; } - - public String getFirmwareVersion() { return firmware_version; } - public void setFirmwareVersion(String value) { this.firmware_version = value; } - } - - public static class AuthenticateDeviceInfoBean implements Serializable{ - private String oid;//璁惧鐨凮id - private String device_mac;//璁惧鐨凪ac - private String device_name;// - private String device_model; - private String access_mode; - private String sid; - private String ip_mac; - private String ip_address; - private String netmask = "255.255.255.0"; - private String ip_gateway; - private String dns1 = "114.114.114.114"; - private String dns2 = "8.8.8.8"; - private String gateway_type; - private String hw_version; - private String fw_version; - - public String getOID() { return oid; } - - /** - * 璁惧Oid - * @param value - */ - public void setOID(String value) { this.oid = value; } - - public String getDeviceMAC() { return device_mac; } - - /** - * 璁惧Mac - * @param value - */ - public void setDeviceMAC(String value) { this.device_mac = value; } - - /** - * 璁惧鍚� - * @return - */ - public String getDeviceName() { return device_name; } - - /** - * 璁惧鍚� - * @param value - */ - public void setDeviceName(String value) { this.device_name = value; } - - /** - * 璁惧鍨嬪彿 - * @return - */ - public String getDeviceModel() { return device_model; } - - /** - * 璁惧鍨嬪彿 - * @param value - */ - public void setDeviceModel(String value) { this.device_model = value; } - - /** - * 杩炴帴绫诲瀷锛屾湁绾胯繕鏄棤绾� - * @return - */ - public String getAccessMode() { return access_mode; } - - /** - * 杩炴帴绫诲瀷锛屾湁绾胯繕鏄棤绾� - * @param value - */ - public void setAccessMode(String value) { this.access_mode = value; } - - /** - * 璁惧sid - * @return - */ - public String getSid() { return sid; } - - /** - * 璁惧sid - * @param value - */ - public void setSid(String value) { this.sid = value; } - - /** - * 璁惧IPMAC - * @return - */ - public String getIPMAC() { return ip_mac; } - - /** - * 璁惧IPMAC - * @param value - */ - public void setIPMAC(String value) { this.ip_mac = value; } - - /** - * 璁惧IP鍦板潃 - * @return - */ - public String getIPAddress() { return ip_address; } - - /** - * 璁惧IP鍦板潃 - * @param value - */ - public void setIPAddress(String value) { this.ip_address = value; } - - /** - * 瀛愮綉鎺╃爜 - * @return - */ - public String getNetmask() { return netmask; } - - /** - * 瀛愮綉鎺╃爜 - * @param value - */ - public void setNetmask(String value) { this.netmask = value; } - - /** - * 缃戝叧IP - * @return - */ - public String getIPGateway() { return ip_gateway; } - - /** - * 缃戝叧IP - * @param value - */ - public void setIPGateway(String value) { this.ip_gateway = value; } - - /** - * DNS1 - * @return - */ - public String getDns1() { return dns1; } - - /** - * DNS1 - * @param value - */ - public void setDns1(String value) { this.dns1 = value; } - - /** - * DNS2 - * @return - */ - public String getDns2() { return dns2; } - - /** - * DNS2 - * @param value - */ - public void setDns2(String value) { this.dns2 = value; } - - public VersionBean[] getVersions() {return null; } - public void setVersions(VersionBean[] value) { } - - /** - * 缃戝叧绫诲瀷 - * @return - */ - public String getGateway_type() { - return gateway_type; - } - - /** - * 缃戝叧绫诲瀷 - * @param gateway_type - */ - public void setGateway_type(String gateway_type) { - this.gateway_type = gateway_type; - } - - /** - * 纭欢鐗堟湰 - * @return - */ - public String getHw_version() { - return hw_version; - } - - /** - *纭欢鐗堟湰 - * @param - */ - public void setHw_version(String hw_version) { - this.hw_version = hw_version; - } - - - /** - * 鍥轰欢鐗堟湰 - * @return - */ - public String getFw_version() { - return fw_version; - } - - /** - * 鍥轰欢鐗堟湰 - * @param fw_version - */ - public void setFw_version(String fw_version) { - this.fw_version = fw_version; - } - } - - public static class VersionBean implements Serializable{ - private String module; - private String version; - - public VersionBean(String module, String version) { - this.module = module; - this.version = version; - } - - public String getModule() { - return module; - } - - public void setModule(String value) { - this.module = value; - } - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/BaseLocalRequest.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/BaseLocalRequest.java deleted file mode 100644 index 44fcccf..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/BaseLocalRequest.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.hdl.sdk.link.core.bean.request; - -import java.io.Serializable; - -/** - * Created by Tong on 2021/9/29. - */ -public class BaseLocalRequest<T> implements Serializable { - - - private String id; - private String code; - private String time_stamp; - private T objects; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getTime_stamp() { - return time_stamp; - } - - public void setTime_stamp(String time_stamp) { - this.time_stamp = time_stamp; - } - - public T getObjects() { - return objects; - } - - public void setObjects(T objects) { - this.objects = objects; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/BroadcastRequest.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/BroadcastRequest.java deleted file mode 100644 index d760638..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/BroadcastRequest.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.hdl.sdk.link.core.bean.request; - -import java.io.Serializable; - -/** - * Created by jlchen on 11/11/21. - * - * /user/all/custom/gateway/broadcast - */ -public class BroadcastRequest implements Serializable { - private String id; - private String time_stamp; - private AuthenticateRequest.AuthenticateDeviceInfoBean objects;//褰撳墠璁惧鍩烘湰淇℃伅 - private String code;// - - public BroadcastRequest(String id, String time_stamp, AuthenticateRequest.AuthenticateDeviceInfoBean objects, String code) { - this.id = id; - this.time_stamp = time_stamp; - this.objects = objects; - this.code = code; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTime_stamp() { - return time_stamp; - } - - public void setTime_stamp(String time_stamp) { - this.time_stamp = time_stamp; - } - - public AuthenticateRequest.AuthenticateDeviceInfoBean getObjects() { - return objects; - } - - public void setObjects(AuthenticateRequest.AuthenticateDeviceInfoBean objects) { - this.objects = objects; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/DeviceControlRequest.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/DeviceControlRequest.java deleted file mode 100644 index 5c4c800..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/DeviceControlRequest.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.hdl.sdk.link.core.bean.request; - -import java.io.Serializable; -import java.util.List; - -/** - * Created by Tong on 2021/10/8. - */ -public class DeviceControlRequest implements Serializable { - - private String sid; - private List<StatusBean> status; - - public String getSid() { - return sid; - } - - public void setSid(String sid) { - this.sid = sid; - } - - public List<StatusBean> getStatus() { - return status; - } - - public void setStatus(List<StatusBean> status) { - this.status = status; - } - - public static class StatusBean implements Serializable { - private String key; - private String value; - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/FunctionAttributeRequest.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/FunctionAttributeRequest.java deleted file mode 100644 index b274fde..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/FunctionAttributeRequest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.hdl.sdk.link.core.bean.request; - -import java.io.Serializable; - -/** - * Created by Tong on 2021/10/8. - */ -public class FunctionAttributeRequest implements Serializable { - - private String sid; - - public FunctionAttributeRequest(String sid) { - this.sid = sid; - } - - public String getSid() { - return sid; - } - - public void setSid(String sid) { - this.sid = sid; - } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/PropertyReadRequest.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/PropertyReadRequest.java deleted file mode 100644 index 4136322..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/PropertyReadRequest.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hdl.sdk.link.core.bean.request; - -/** - * Created by Tong on 2021/10/8. - */ -public class PropertyReadRequest { - - private String sid; - - public PropertyReadRequest(String sid) { - this.sid = sid; - } - - public String getSid() { - return sid; - } - - public void setSid(String sid) { - this.sid = sid; - } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/PropertyUpRequest.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/PropertyUpRequest.java deleted file mode 100644 index dfd46b4..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/request/PropertyUpRequest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.hdl.sdk.link.core.bean.request; - -import java.io.Serializable; -import java.util.List; - -/** - * Created by Tong on 2021/10/8. - */ -public class PropertyUpRequest implements Serializable { - - private String sid; - private List<StatusBean> status; - - public String getSid() { - return sid; - } - - public void setSid(String sid) { - this.sid = sid; - } - - public List<StatusBean> getStatus() { - return status; - } - - public void setStatus(List<StatusBean> status) { - this.status = status; - } - - public static class StatusBean implements Serializable{ - private String key; - private String value; - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/AuthenticateResponse.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/AuthenticateResponse.java deleted file mode 100644 index ea7d429..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/AuthenticateResponse.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.hdl.sdk.link.core.bean.response; - -import java.io.Serializable; - -/** - * Created by jlchen on 11/12/21. - * - * @Description : AuthenticateResponseBean - */ -public class AuthenticateResponse extends BaseResponse { - private String code; - private GatewayObjects objects; - private Auth auth; - - public String getCode() { return code; } - public void setCode(String value) { this.code = value; } - - public GatewayObjects getObjects() { return objects; } - public void setObjects(GatewayObjects value) { this.objects = value; } - - public Auth getAuth() { return auth; } - public void setAuth(Auth value) { this.auth = value; } - - public class Auth implements Serializable { - private String localSecret; - - public String getLocalSecret() { return localSecret; } - public void setLocalSecret(String value) { this.localSecret = value; } - } - - public class GatewayObjects implements Serializable { - private String ip_address; - private String gatewayId; - private String oid; - - public String getIPAddress() { return ip_address; } - public void setIPAddress(String value) { this.ip_address = value; } - - public String getGatewayID() { return gatewayId; } - public void setGatewayID(String value) { this.gatewayId = value; } - - public String getOID() { return oid; } - public void setOID(String value) { this.oid = value; } - } - - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/BaseLocalResponse.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/BaseLocalResponse.java deleted file mode 100644 index 2000807..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/BaseLocalResponse.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.hdl.sdk.link.core.bean.response; - -import java.io.Serializable; - -/** - * Created by Tong on 2021/9/29. - */ -public class BaseLocalResponse<T> implements Serializable { - - private String id; - private String time_stamp; - private T objects; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTime_stamp() { - return time_stamp; - } - - public void setTime_stamp(String time_stamp) { - this.time_stamp = time_stamp; - } - - public T getObjects() { - return objects; - } - - public void setObjects(T objects) { - this.objects = objects; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/BaseLocalWithCodeResponse.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/BaseLocalWithCodeResponse.java deleted file mode 100644 index cfd555a..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/BaseLocalWithCodeResponse.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.hdl.sdk.link.core.bean.response; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Tong on 2021/9/29. - */ -public class BaseLocalWithCodeResponse<T> implements Serializable { - - private String id; - private String time_stamp; - private T code; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTime_stamp() { - return time_stamp; - } - - public void setTime_stamp(String time_stamp) { - this.time_stamp = time_stamp; - } - - public T getCode() { - return code; - } - - public void setCode(@NonNull T code) { - this.code = code; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/BaseResponse.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/BaseResponse.java deleted file mode 100644 index 3337610..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/BaseResponse.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.hdl.sdk.link.core.bean.response; - -import java.io.Serializable; - -/** - * Created by jlchen on 11/15/21. - * - * @Description : BaseResponse - */ -public class BaseResponse implements Serializable { - - private String id; - private String time_stamp; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTime_stamp() { - return time_stamp; - } - - public void setTime_stamp(String time_stamp) { - this.time_stamp = time_stamp; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/GatewaySearchBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/GatewaySearchBean.java deleted file mode 100644 index b574beb..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/GatewaySearchBean.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.hdl.sdk.link.core.bean.response; - -import java.io.Serializable; - -/** - * Created by Tong on 2021/9/29. - * 缃戝叧鎼滅储 - */ -public class GatewaySearchBean implements Serializable { - private String device_model; - private String device_name; - private String device_mac; - private String gatewayId; - private String gatewayType; - private String gateway_type; - private String oid; - private String ip_address; - private String access_mode; - private String master; - private boolean isLocalEncrypt;//2021-11-11 鏂板 - - public String getDevice_model() { - return device_model; - } - - public void setDevice_model(String device_model) { - this.device_model = device_model; - } - - public String getDevice_name() { - return device_name; - } - - public void setDevice_name(String device_name) { - this.device_name = device_name; - } - - public String getDevice_mac() { - return device_mac; - } - - public void setDevice_mac(String device_mac) { - this.device_mac = device_mac; - } - - public String getGatewayId() { - return gatewayId; - } - - public void setGatewayId(String gatewayId) { - this.gatewayId = gatewayId; - } - - public String getGatewayType() { - return gatewayType; - } - - public void setGatewayType(String gatewayType) { - this.gatewayType = gatewayType; - } - - public String getGateway_type() { - return gateway_type; - } - - public void setGateway_type(String gateway_type) { - this.gateway_type = gateway_type; - } - - public String getOid() { - return oid; - } - - public void setOid(String oid) { - this.oid = oid; - } - - public String getIp_address() { - return ip_address; - } - - public void setIp_address(String ip_address) { - this.ip_address = ip_address; - } - - public String getAccess_mode() { - return access_mode; - } - - public void setAccess_mode(String access_mode) { - this.access_mode = access_mode; - } - - public String getMaster() { - return master; - } - - public void setMaster(String master) { - this.master = master; - } - - public boolean isLocalEncrypt() { - return isLocalEncrypt; - } - - public void setLocalEncrypt(boolean localEncrypt) { - isLocalEncrypt = localEncrypt; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/NetworkAccessBroadcastResponse.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/NetworkAccessBroadcastResponse.java deleted file mode 100644 index 23a16c4..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/response/NetworkAccessBroadcastResponse.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hdl.sdk.link.core.bean.response; - -/** - * Created by jlchen on 11/15/21. - * - * @Description : NetworkAccessBroadcastResponse - */ -public class NetworkAccessBroadcastResponse extends BaseResponse { - private String ip_address; - private String oid; - private String homeId; - - public String getIPAddress() { return ip_address; } - public void setIPAddress(String value) { this.ip_address = value; } - - public String getOID() { return oid; } - public void setOID(String value) { this.oid = value; } - - public String getHomeID() { return homeId; } - public void setHomeID(String value) { this.homeId = value; } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/scenebatch/SceneCanDeleteInfo.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/scenebatch/SceneCanDeleteInfo.java deleted file mode 100644 index ff13772..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/scenebatch/SceneCanDeleteInfo.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.hdl.sdk.link.core.bean.scenebatch; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/12/9 - * description: - */ -public class SceneCanDeleteInfo implements Serializable { - private String sid; - private String can_delete; - - public String getSid() { - return sid == null ? "" : sid; - } - - public void setSid(@NonNull String sid) { - this.sid = sid; - } - - public String getCan_delete() { - return can_delete == null ? "" : can_delete; - } - - public void setCan_delete(@NonNull String can_delete) { - this.can_delete = can_delete; - } - - -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/scenebatch/SceneGroupInfo.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/scenebatch/SceneGroupInfo.java deleted file mode 100644 index cb7a93d..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/bean/scenebatch/SceneGroupInfo.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hdl.sdk.link.core.bean.scenebatch; - -import java.io.Serializable; - -import androidx.annotation.NonNull; - -/** - * Created by Zoro - * Created on 2022/12/9 - * description: - */ -public class SceneGroupInfo implements Serializable { - private String sid; - private String group; - - public String getSid() { - return sid == null ? "" : sid; - } - - public void setSid(@NonNull String sid) { - this.sid = sid; - } - - public String getGroup() { - return group == null ? "" : group; - } - - public void setGroup(@NonNull String group) { - this.group = group; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/BaseCallBack.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/BaseCallBack.java deleted file mode 100644 index 88d979b..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/BaseCallBack.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hdl.sdk.link.core.callback; - -import com.hdl.sdk.link.common.exception.HDLLinkException; - -/** - * Created by Tong on 2021/11/11. - */ -public interface BaseCallBack { - - void onError(HDLLinkException e); - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/GatewayCallBack.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/GatewayCallBack.java deleted file mode 100644 index 5299977..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/GatewayCallBack.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hdl.sdk.link.core.callback; - -import com.hdl.sdk.link.core.bean.gateway.GatewayBean; - -import java.util.List; - -/** - * Created by hxb on 2021/12/15. - */ -public interface GatewayCallBack extends BaseCallBack { - void onSuccess(List<GatewayBean> gatewayBeanList); -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/HDLLinkResponseCallBack.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/HDLLinkResponseCallBack.java deleted file mode 100644 index 418152a..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/HDLLinkResponseCallBack.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.hdl.sdk.link.core.callback; - - -import com.hdl.sdk.link.core.bean.LinkResponse; - -/** - * Created by jlchen on 11/16/21. - * - * @Description : HDLLinkResponseCallBack - */ -public interface HDLLinkResponseCallBack extends BaseCallBack{ - void onSuccess(LinkResponse msg); -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/HDLLinkTCallBack.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/HDLLinkTCallBack.java deleted file mode 100644 index dfa9885..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/HDLLinkTCallBack.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hdl.sdk.link.core.callback; - -/** - * Created by jlchen on 1/6/22. - * 鏈湴閫氫俊閫氱敤CallBack - */ -public interface HDLLinkTCallBack<T> extends BaseCallBack{ - - void onSuccess(T data); - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/ModbusCallBack.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/ModbusCallBack.java deleted file mode 100644 index 2681d13..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/ModbusCallBack.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hdl.sdk.link.core.callback; - -import com.hdl.sdk.link.core.bean.gateway.GatewayBean; - -import java.util.List; - -/** - * Created by hxb on 2021/12/15. - */ -public interface ModbusCallBack extends BaseCallBack { - void onSuccess(int []data); -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/ZigbeeCallBack.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/ZigbeeCallBack.java deleted file mode 100644 index 5d29b40..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/callback/ZigbeeCallBack.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.hdl.sdk.link.core.callback; - -import org.json.JSONException; - -/** - * Created by hxb on 2021/12/15. - */ -public interface ZigbeeCallBack extends BaseCallBack { - void onSuccess(String body); -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/config/HDLLinkConfig.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/config/HDLLinkConfig.java deleted file mode 100644 index 195ea25..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/config/HDLLinkConfig.java +++ /dev/null @@ -1,211 +0,0 @@ -package com.hdl.sdk.link.core.config; - -import com.hdl.sdk.link.common.utils.LogUtils; -import com.hdl.sdk.link.common.utils.SPUtils; -import com.hdl.sdk.link.core.bean.request.AuthenticateRequest; -import com.hdl.sdk.link.core.bean.response.GatewaySearchBean; - -import androidx.annotation.NonNull; - - -/** - * Created by jlchen on 11/11/21. - * - * @Description : HDLLinkConfig - */ -public class HDLLinkConfig { - private static final String AUTHENTICATE_LS_KEY = "auth_ls_key"; - private static final String AUTHENTICATE_GATEWAYID_KEY = "auth_gatewayid_key"; - private static final String AUTHENTICATE_IPADDRESS_KEY = "auth_ipaddress_key"; - private static final String AUTHENTICATE_IS_LS_KEY = "auth_isls_key"; - private static final String AUTHENTICATE_IS_CLOUD_ENCRYPT_KEY = "cloud_isencrypt_key"; - private static final String AUTHENTICATE_CLOUD_ENCRYPT_KEY = "cloud_encrypt_key"; - private static final String HOME_ID="home_id"; - - private String localSecret;//鏈湴鍔犲瘑瀵嗛挜 - private String gatewayId; - private String ipAddress; - private boolean isLocalEncrypt;//缃戝叧鏄惁闇�瑕佸姞瀵嗛�氳 - private String homeId; - private GatewaySearchBean currentGateway;//褰撳墠缃戝叧 - private String aesKey; - //浜戠缃戝叧鏄惁鍔犲瘑 - private boolean isCloudEncrypt = true; - - private AuthenticateRequest.AuthenticateDeviceInfoBean deviceInfoBean;//褰撳墠璁惧鍩烘湰淇℃伅 - - /** - * instance - */ - private volatile static HDLLinkConfig instance; - - /** - * getInstance - * - * @return AuthenticateConfig - */ - public static synchronized HDLLinkConfig getInstance() { - if (instance == null) { - synchronized (HDLLinkConfig.class) { - if (instance == null) { - instance = new HDLLinkConfig(); - instance.loadConfig(); - } - } - } - return instance; - } - - /** - * 娓呯┖缂撳瓨 - */ - public void clearConfig() { - this.gatewayId = ""; - this.ipAddress = ""; - this.localSecret = ""; - this.isLocalEncrypt = false; - this.homeId=""; - SPUtils.remove(AUTHENTICATE_LS_KEY); - SPUtils.remove(AUTHENTICATE_GATEWAYID_KEY); - SPUtils.remove(AUTHENTICATE_IPADDRESS_KEY); - SPUtils.remove(AUTHENTICATE_IS_LS_KEY); - SPUtils.remove(HOME_ID); - } - - /** - * 鍔犺浇缂撳瓨 - */ - void loadConfig() { - localSecret = SPUtils.getString(AUTHENTICATE_LS_KEY, ""); -// gatewayId = SPUtils.getString(AUTHENTICATE_GATEWAYID_KEY, ""); -// ipAddress = SPUtils.getString(AUTHENTICATE_IPADDRESS_KEY, ""); - isLocalEncrypt = SPUtils.getBoolean(AUTHENTICATE_IS_LS_KEY, false); - isCloudEncrypt = SPUtils.getBoolean(AUTHENTICATE_IS_CLOUD_ENCRYPT_KEY, false); - aesKey = SPUtils.getString(AUTHENTICATE_CLOUD_ENCRYPT_KEY, ""); - homeId=SPUtils.getString(HOME_ID, ""); - } - - - - /** - * 淇濆瓨閰嶇疆 - * - * @param localSecret - * @param gatewayId - * @param ipAddress - */ - public void saveConfig(String localSecret, String gatewayId, String ipAddress) { - this.localSecret = localSecret; - this.gatewayId = gatewayId; - this.ipAddress = ipAddress; - SPUtils.put(AUTHENTICATE_LS_KEY, localSecret); - SPUtils.put(AUTHENTICATE_GATEWAYID_KEY, gatewayId); - SPUtils.put(AUTHENTICATE_IPADDRESS_KEY, ipAddress); - } - - /** - * 閲嶆柊淇濆瓨 - */ - public void reSaveConfig() { - this.saveConfig(this.localSecret, this.gatewayId, this.ipAddress); - } - - public String getAesKey() { - return aesKey == null ? "" : aesKey; - } - - public void setAesKey(@NonNull String aesKey) { - this.aesKey = aesKey; - SPUtils.put(AUTHENTICATE_CLOUD_ENCRYPT_KEY, aesKey); - } - - - public boolean isCloudEncrypt() { - return isCloudEncrypt; - } - - public void setCloudEncrypt(@NonNull boolean cloudEncrypt) { - isCloudEncrypt = cloudEncrypt; - SPUtils.put(AUTHENTICATE_IS_CLOUD_ENCRYPT_KEY, cloudEncrypt); - } - - /** - * 妫�娴嬫槸鍚﹀凡缁忚璇佽繃 - * - * @return - */ - public boolean checkIfCertified() { - //localSecret涓嶄负绌哄苟涓旈暱搴︾瓑浜�16 缃戝叧id涓嶈兘涓虹┖ - return true;//!TextUtils.isEmpty(localSecret) - //&& localSecret.length() == 16 - //&& !TextUtils.isEmpty(gatewayId); - } - - public void setLocalSecret(String localSecret) { - this.localSecret = localSecret; - SPUtils.put(AUTHENTICATE_LS_KEY, localSecret); - } - - public String getLocalSecret() { - return localSecret; - } - - /** - * 褰撳墠浣忓畢缃戝叧Id,oid,mac - * @return - */ - public String getGatewayId() { - return gatewayId; - } - - /** - * 褰撳墠浣忓畢缃戝叧Id - * @param gatewayId - */ - public void setGatewayId(String gatewayId) { - this.gatewayId= gatewayId; - } - - public String getHomeId() { - return homeId; - } - - public void setHomeId(String homeId) { - this.homeId = homeId; - } - - public String getIpAddress() { - return ipAddress; - } - public void setIpAddress(String ipAddress){ - this.ipAddress = ipAddress; - } - - public boolean isLocalEncrypt() { - return isLocalEncrypt; - } - - public void setLocalEncrypt(boolean localEncrypt) { - isLocalEncrypt = localEncrypt; - SPUtils.put(AUTHENTICATE_IS_LS_KEY, isLocalEncrypt); - } - - - /** - * 鎷兼帴缃戝叧ID鑾峰彇瀹屾暣鐨勪富棰� - * - * @param topicStr - * @return - */ - public String getFullTopic(String topicStr) { - return String.format(topicStr, gatewayId); - } - - public AuthenticateRequest.AuthenticateDeviceInfoBean getDeviceInfoBean() { - return deviceInfoBean; - } - - public void setDeviceInfoBean(AuthenticateRequest.AuthenticateDeviceInfoBean deviceInfoBean) { - this.deviceInfoBean = deviceInfoBean; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLModBusConnect.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLModBusConnect.java deleted file mode 100644 index 324b7fe..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLModBusConnect.java +++ /dev/null @@ -1,325 +0,0 @@ -package com.hdl.sdk.link.core.connect; - - -import android.text.TextUtils; - -import com.hdl.sdk.link.common.config.TopicConstant; -import com.hdl.sdk.link.common.event.EventDispatcher; -import com.hdl.sdk.link.common.event.EventListener; -import com.hdl.sdk.link.common.exception.HDLLinkCode; -import com.hdl.sdk.link.common.exception.HDLLinkException; -import com.hdl.sdk.link.common.utils.LogUtils; -import com.hdl.sdk.link.core.bean.LinkRequest; -import com.hdl.sdk.link.core.bean.LinkResponse; -import com.hdl.sdk.link.core.bean.ModbusResponse; -import com.hdl.sdk.link.core.bean.ZigbeeResponse; -import com.hdl.sdk.link.core.bean.gateway.GatewayBean; -import com.hdl.sdk.link.core.callback.ModbusCallBack; -import com.hdl.sdk.link.core.callback.ZigbeeCallBack; -import com.hdl.sdk.link.core.config.HDLLinkConfig; -import com.hdl.sdk.link.gateway.HDLLinkLocalGateway; - -/** - * Created by hxb on 2021/12/8. - * 鍘熺敓閫氳鐩稿叧鎺ュ彛 - */ -public class HDLModBusConnect { - - private static final String TAG = "HDLModbusConnect"; - private static HDLModBusConnect instance; - /** - * 鍐呴儴鐢紝涓昏鏄鐞嗗鐞嗘帀閫忎紶涓婚鍙妉ink涓婚鍚庯紝杩樺師modbus鍘熺敓鏁版嵁鍙婁富棰樼敤 - */ - private final String allTopic = "/Modbus"; - - /** - * 杩斿洖褰撳墠瀹炰緥锛屼笉瀛樺湪灏卞垱寤哄苟鍚屾椂娉ㄥ唽鐩戝惉浜嬩欢 - * - * @return - */ - public static HDLModBusConnect getInstance() { - if (null == instance) { - instance = new HDLModBusConnect(); - instance.initEventListener(); - } - return instance; - } - - /** - * 娉ㄥ唽鐩戝惉Zigbee鎵�鏈夊師鐢熶富棰樺強鏁版嵁 - * - * @param eventListener - */ - public void registerListener(EventListener eventListener) { - if (null == eventListener) { - return; - } - EventDispatcher.getInstance().register(allTopic, eventListener); - } - - /** - * 绉婚櫎鐩戝惉Zigbee鍘熺敓涓婚鍙婃暟鎹� - * - * @param eventListener - */ - public void removeListener(EventListener eventListener) { - if (null == eventListener) { - return; - } - EventDispatcher.getInstance().remove(allTopic, eventListener); - } - - /** - * 鍒濆鍖栫洃鍚簨浠� - */ - private void initEventListener() { - final EventListener eventListener = new EventListener() { - @Override - public void onMessage(Object msg) { - try { - if (msg instanceof LinkResponse) { - LinkResponse linkResponse = (LinkResponse) msg; - if (linkResponse.getTopic() == null || !linkResponse.getTopic().contains("custom/native/inverter/up")) { - return; - } - byte[] data = linkResponse.getByteData(); - ModbusResponse modbusResponse = new ModbusResponse(); - String topic = "Modbus" + data[0] + data[1]; - modbusResponse.setTopic(topic); - modbusResponse.setData(data); - String oid = null; - //鏄惁鏄�氳繃涓荤綉鍏抽�忎紶涓婚 - if (linkResponse.getTopic().contains("/slaveoid/")) { - oid = linkResponse.getTopic().split("/")[8]; - } else { - oid = linkResponse.getTopic().split("/")[2]; - } - modbusResponse.setOid(oid); - for (GatewayBean gatewayBean : HDLLinkLocalGateway.getInstance().getGatewayList()) { - if (oid.equals(gatewayBean.getGatewayId()) || oid.equals(gatewayBean.getDevice_mac()) || oid.equals(gatewayBean.getOid())) { - //涓婇潰鐨刼id鍙兘鏄綉鍏砳d鎴栬�卪ac鎴栬�呮槸oid锛屼笉绠℃槸鍝釜缁熶竴浣跨敤oid琛ㄧず鏂瑰紡 - modbusResponse.setOid(gatewayBean.getOid()); - break; - } - } - - EventDispatcher.getInstance().post(topic, modbusResponse); - //鍙戝竷Zigbee鍘熺敓涓婚鍙婃暟鎹� -// EventDispatcher.getInstance().post(allTopic, modbusResponse); - } - } catch (Exception e) { - LogUtils.e(TAG, "LinkResponse杞琈odbusResponse寮傚父:" + e.getMessage()); - } - } - }; - //娉ㄥ唽鐩存帴閫氳鐨勪富棰橈紝鍖呮嫭鐩存帴鍜屼富缃戝叧閫氳鎴栬�呯洿鎺ュ拰浠庣綉鍏抽�氳 - registerListener(String.format(TopicConstant.NATIVE_MODBUS_UP, "+"), eventListener); - //registerListener(String.format(TopicConstant.NATIVE_MODBUS_DOWN_REPLY, "+"), eventListener); - //registerListener(String.format(TopicConstant.NATIVE_ZIGBEE_UP_SLAVE, "+", "+"), eventListener); - } - - - /** - * 鍙戦�佸師鐢熸暟鎹� - * - * @param gatewayOidOrGatewayId 鐩爣缃戝叧鐨刼id鎴栬�呯綉鍏矷d - * @param payload 鍙戦�佹暟鎹� - * @param baseCallBack 缁撴灉鍥炶皟 - */ - public void Send(String gatewayOidOrGatewayId, byte[] payload, final ModbusCallBack baseCallBack) { - Send(gatewayOidOrGatewayId, payload, 5, baseCallBack); - } - - /** - * 鍙戦�佸師鐢熸暟鎹� - * - * @param gatewayOidOrGatewayId 鐩爣缃戝叧鐨刼id鎴栬�呯綉鍏矷d - * @param payload 鍙戦�佹暟鎹� - * @param timeout 瓒呮椂鏃堕棿(s) - * @param baseCallBack 缁撴灉鍥炶皟 - */ - public void Send(String gatewayOidOrGatewayId, byte[] payload, int timeout, final ModbusCallBack baseCallBack) { - if (payload == null || payload.length == 0) { - if (baseCallBack != null) { - baseCallBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_NULL_ERROR)); - System.out.println("鍙戦�佹暟鎹椂璐熻浇鏁版嵁鏄┖鐨�--->"); - } - return; - } - //濡傛灉鏈湴鏈夐摼鎺ヨ繖涓綉鍏�,鍒欑敤鏈湴杩炴帴 - GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getGatewayByOidOrGatewayId(gatewayOidOrGatewayId); - if (null == gatewayBean) { - LogUtils.i("鎵句笉鍒扮綉鍏筹紝Oid鏄�" + gatewayOidOrGatewayId); - if (null != baseCallBack) { - baseCallBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); - } - return; - } - - String tempTopic = String.format(TopicConstant.NATIVE_MODBUS_DOWN, gatewayOidOrGatewayId); - LinkRequest request = new LinkRequest(tempTopic, payload, gatewayBean.getIsLocalEncrypt());//瑕佷笉瑕佸姞瀵� - -// if ("true".equals(gatewayBean.getMaster())) { - request.setCloudTopic(String.format(TopicConstant.NATIVE_MODBUS_DOWN, HDLLinkConfig.getInstance().getGatewayId())); -// } else { -// request.setCloudTopic(String.format(TopicConstant.NATIVE_MODBUS_DOWN_SLAVE, HDLLinkConfig.getInstance().getGatewayId(), gatewayOidOrGatewayId)); -// } - request.setReplyTopic("Modbus" + payload[0] + payload[1]); - long awaitTime = timeout * 1000L; - - new HDLConnectHelper(awaitTime, 1, gatewayBean.getIp_address(), 8586, request, new HDLConnectHelper.HdlSocketListener() { - @Override - public void onSucceed(Object msg) { - if (msg instanceof int[]) { - if (null != baseCallBack) { - baseCallBack.onSuccess((int[]) msg); - } - } else { - LogUtils.e("鍙戦�丮odbus鍥炶皟瀵硅薄绫诲瀷闈炴暟缁勭被鍨嬶紝绫诲瀷鏄�" + msg.getClass()); - } - } - - @Override - public void onFailure(HDLLinkCode hdlLinkCode) { - if (null != baseCallBack) { - baseCallBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); - } - } - }, true).send(); - } - - - /** - * 鍙戦�佸師鐢熼�忎紶鍛戒护鏁版嵁 - * - * @param gatewayOidOrGatewayId 鐩爣缃戝叧鐨刼id鎴栬�呯綉鍏矷d - * @param responeTopic 鍥炲涓婚 - * @param payload 鍙戦�佹暟鎹� - * @param zigbeeCallBack 缁撴灉鍥炶皟 - */ - public void SendThrough(String gatewayOidOrGatewayId, String responeTopic, String payload, final ZigbeeCallBack zigbeeCallBack) { -// //濡傛灉鏈湴鏈夐摼鎺ヨ繖涓綉鍏�,鍒欑敤鏈湴杩炴帴 -// GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getGatewayByOidOrGatewayId(gatewayOidOrGatewayId); -// if (null == gatewayBean) { -// LogUtils.i("鎵句笉鍒扮綉鍏筹紝Oid鏄�" + gatewayOidOrGatewayId); -// if (null != zigbeeCallBack) { -// zigbeeCallBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); -// } -// return; -// } -// boolean isLocal = gatewayBean.getIsLocalGateway(); -// //濡傛灉鏄湰鍦伴�氳 -// if (isLocal == true) { -// -// String tempTopic = String.format("/user/%s/custom/native/zigbee/down", gatewayOidOrGatewayId); -// String tempTopicReply = String.format("/user/%s/custom/native/zigbee/up", gatewayOidOrGatewayId); -// -// final boolean[] isCallBack = {false}; -// //閫忎紶鍛戒护涓婚澶勭悊 -// final EventListener eventListener = new EventListener() { -// @Override -// public void onMessage(Object msg) { -// if (msg instanceof LinkResponse) { -// LinkResponse linkResponse = (LinkResponse) msg; -// //TODO 濡傛灉閰嶇疆浠庣綉鍏崇殑淇℃伅锛岄�氳繃涓荤綉鍏宠浆杈撅紝杩欓噷oid瑕佸垽鏂笅 -// String body = getZigbeeData(responeTopic, linkResponse); -// if (null != body) { -// isCallBack[0] = true; -// removeListener(tempTopicReply, this); -// if (null != zigbeeCallBack) { -// zigbeeCallBack.onSuccess(body); -// } -// } -// } -// } -// }; -// //娉ㄥ唽鐩戝惉 -// registerListener(tempTopicReply, eventListener); -// -// //涓�瀹氭椂闂村悗杩樻病鏈夋帴鏀跺埌鏁版嵁锛屽氨鍥炶皟澶辫触 -// ScheduledExecutorService scheduledExecutorService = ThreadToolUtils.getInstance().newScheduledThreadPool(1); -// scheduledExecutorService.schedule(new Runnable() { -// @Override -// public void run() { -// removeListener(tempTopicReply, eventListener); -// scheduledExecutorService.shutdownNow(); -// if (!isCallBack[0]) { -// if (null != zigbeeCallBack) { -// zigbeeCallBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GET_Zigbee_FAILURE_ERROR)); -// } -// } -// } -// }, 5, TimeUnit.SECONDS); -// -// //鏈湴鍙戦�� -// LinkRequest request = new LinkRequest(tempTopic, payload, gatewayBean.getIsLocalEncrypt()); -// new HDLConnectHelper(gatewayBean.getIp_address(), request,true).send(); -// } else { -// //璇锋眰涓婚 -// String tempTopic = null; -// //鍥炲涓婚 -// String tempTopicReply = null; -// -// //杩滅▼鍙戦�� -// if ("true".equals(gatewayBean.getMaster())) { -// tempTopic = String.format("/user/%s/custom/native/zigbee/down", com.hdl.sdk.link.core.config.HDLLinkConfig.getInstance().getGatewayId()); -// tempTopicReply = String.format("/user/%s/custom/native/zigbee/up", com.hdl.sdk.link.core.config.HDLLinkConfig.getInstance().getGatewayId()); -// } else { -// tempTopic = String.format("/user/%s/custom/native/zigbee/slaveoid/%s/down", com.hdl.sdk.link.core.config.HDLLinkConfig.getInstance().getGatewayId(), gatewayOidOrGatewayId); -// tempTopicReply = String.format("/user/%s/custom/native/zigbee/slaveoid/%s/up", com.hdl.sdk.link.core.config.HDLLinkConfig.getInstance().getGatewayId(), "+"); -// } -// //TODO 鍚庣画瀹屽杽浜戠鐨勫彂閫佹帴鏀舵柟娉� -// } - } - - - /** - * 澶勭悊zigbee鍥炲鐨勬暟鎹� - * - * @param responeTopic 鍥炲涓婚 - * @param linkResponse 鍥炲鐨勯�忎紶鏁版嵁 - */ - private static String getZigbeeData(String responeTopic, LinkResponse linkResponse) { - //涓婚涓虹┖涓嶅鐞� - if (TextUtils.isEmpty(responeTopic)) { - return null; - } - - String body = linkResponse.getData(); - int index = body.indexOf("{"); - //zigbee鍥炲鐨勬暟鎹墠鏈変富棰橈紝鍚庨潰鎵嶆槸鏁版嵁 - if (index <= 0) - return null; - - String zigbeeTopic = body.substring(0, index).trim(); - //zigbee鐨勮礋杞芥暟鎹� - String bodyData = body.substring(index); - - //涓嶆槸褰撳墠璇锋眰鐨勬暟鎹紝涓嶅鐞� - if (!zigbeeTopic.startsWith(responeTopic)) { - return null; - } - - return bodyData; - //Zigbee浠ュ墠鐨勬帴鏀堕�昏緫 -// HdlZbGatewayReceiveLogic.Current.ZigbeeOldReceiveLogic(reportTopic, bodyData, gatewayMac); - } - - /** - * 娉ㄥ唽鐩戝惉 - */ - static void registerListener(String responseTopic, EventListener eventListener) { - if (!TextUtils.isEmpty(responseTopic)) { - EventDispatcher.getInstance().register(responseTopic, eventListener); - } - } - - /** - * 绉婚櫎鐩戝惉 - */ - static void removeListener(String responseTopic, EventListener eventListener) { - if (!TextUtils.isEmpty(responseTopic)) { - EventDispatcher.getInstance().remove(responseTopic, eventListener); - } - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLTcpConnect.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLTcpConnect.java deleted file mode 100644 index 9ddf6ad..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLTcpConnect.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.hdl.sdk.link.core.connect; - -import com.google.gson.JsonObject; -import com.hdl.sdk.link.common.config.TopicConstant; -import com.hdl.sdk.link.common.exception.HDLLinkException; -import com.hdl.sdk.link.common.utils.IdUtils; -import com.hdl.sdk.link.common.utils.LogUtils; -import com.hdl.sdk.link.common.utils.gson.GsonConvert; -import com.hdl.sdk.link.core.bean.LinkRequest; -import com.hdl.sdk.link.core.bean.LinkResponse; -import com.hdl.sdk.link.core.bean.gateway.GatewayBean; -import com.hdl.sdk.link.core.bean.request.BroadcastRequest; -import com.hdl.sdk.link.core.callback.HDLLinkResponseCallBack; -import com.hdl.sdk.link.core.config.HDLLinkConfig; -import com.hdl.sdk.link.core.protocol.LinkMessageDecoder; -import com.hdl.sdk.link.core.protocol.LinkMessageEncoder; -import com.hdl.sdk.link.gateway.HDLLinkLocalGateway; -import com.hdl.sdk.link.socket.TcpSocketBoot; -import com.hdl.sdk.link.socket.SocketOptions; -import com.hdl.sdk.link.socket.client.IHeartbeat; -import com.hdl.sdk.link.socket.client.TcpClient; -import com.hdl.sdk.link.socket.codec.MessagePipeLine; -import com.hdl.sdk.link.socket.listener.ConnectStatusListener; - -/** - * Created by Tong on 2021/9/26. - * 1銆侀�氳繃Udp 缁勬挱鎴栬�呭箍鎾悳绱㈢綉鍏� - * 2銆侀�氳繃Udp 鑾峰彇Tcp ip 绔彛缁熶竴8586 - */ -public class HDLTcpConnect { - - /** - * tcp榛樿绔彛 - */ - private static final int TCP_PORT = 8586; - - - private ConnectStatusListener statusListener; - - private HDLTcpConnect() { - statusListener = new ConnectStatusListener() { - @Override - public void onConnecting() { - broadcastRequest(); - } - - @Override - public void onConnected() { - - } - - @Override - public void onConnectFailed() { - - } - }; - } - - /** - * 骞挎挱鑷韩淇℃伅缁欎富缃戝叧 - */ - private void broadcastRequest() { - String time = String.valueOf(System.currentTimeMillis()); - if (null == HDLLinkConfig.getInstance().getDeviceInfoBean()) { - LogUtils.i("DeviceInfoBean涓虹┖锛岃璁剧疆褰撳墠瀵硅薄"); - return; - } - BroadcastRequest request = new BroadcastRequest(IdUtils.getUUId(), time, HDLLinkConfig.getInstance().getDeviceInfoBean(), "200"); - HDLUdpConnect.getInstance().udpSendMsg(TopicConstant.BROADCAST, GsonConvert.getGson().toJson(request), true); - HDLUdpConnect.getInstance().udpSendMsg(TopicConstant.BROADCAST, GsonConvert.getGson().toJson(request), true, new HDLLinkResponseCallBack() { - @Override - public void onSuccess(LinkResponse msg) { - LogUtils.i("骞挎挱淇℃伅缁欎富缃戝叧鎴愬姛锛�"); - } - - @Override - public void onError(HDLLinkException e) { - - } - }); - HDLUdpConnect.getInstance().udpSendMsg(TopicConstant.BROADCAST, GsonConvert.getGson().toJson(request), true); - } - - private static class SingletonInstance { - private static final HDLTcpConnect INSTANCE = new HDLTcpConnect(); - } - - public static HDLTcpConnect getInstance() { - return SingletonInstance.INSTANCE; - } - - /** - * 閫氳繃IP鍙婄鍙f壘鍑鸿繛鎺ュ鎴风锛屽鏋滃綋鍓嶆病鏈夎繛鎺ャ�備富瑕佹槸閽堝璋冭瘯杞欢浣跨敤锛屾敮鎸佽繛鎺ヤ富缃戝叧銆佷粠缃戝叧 - * - * @param ip 杩炴帴鐨勭綉鍏矷P - * @return - */ - public static synchronized TcpSocketBoot getTcpSocketBoot(String ip) { - return initTcp(ip); - } - - static int dddd; - /** - * 鍒濆鍖杢cp杩炴帴 - * - * @param ip 杩炴帴鐨勭綉鍏矷P - * @return - */ - public static synchronized TcpSocketBoot initTcp(String ip) { - int port = TCP_PORT; - TcpSocketBoot tcpSocketBoot = TcpSocketBoot.getByEndPoint(ip, port); - - if (null == tcpSocketBoot) { - final SocketOptions options = new SocketOptions(); - final MessagePipeLine pipeLine = new MessagePipeLine(); - pipeLine.add(new LinkMessageDecoder()); - pipeLine.add(new LinkMessageEncoder()); - options.setHandleMessage(pipeLine); - tcpSocketBoot = TcpClient.init(ip, port, options); - tcpSocketBoot.SetHeartbeat(new IHeartbeat() { - @Override - public void heartbeat() { - - String time = String.valueOf(System.currentTimeMillis()); - - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("id", IdUtils.getUUId()); - jsonObject.addProperty("time_stamp", time); - - GatewayBean gatewayBean= HDLLinkLocalGateway.getInstance().getGatewayByOidOrGatewayId(ip); - if(gatewayBean==null){ - return; - } - String topic = String.format(TopicConstant.HEARTBEAT, gatewayBean.getOid()); - - LinkRequest request = new LinkRequest(topic, jsonObject.toString(), false); - new HDLConnectHelper(ip, request, null, true).send(); - } - }); - } - return tcpSocketBoot; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLUdpConnect.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLUdpConnect.java deleted file mode 100644 index 8bcbcb0..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLUdpConnect.java +++ /dev/null @@ -1,620 +0,0 @@ -package com.hdl.sdk.link.core.connect; - -import android.content.Context; -import android.content.Intent; -import android.net.wifi.WifiManager; -import android.text.TextUtils; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; -import com.hdl.sdk.link.HDLLinkLocalSdk; -import com.hdl.sdk.link.common.event.EventDispatcher; -import com.hdl.sdk.link.common.event.EventListener; -import com.hdl.sdk.link.common.exception.HDLLinkCode; -import com.hdl.sdk.link.common.exception.HDLLinkException; -import com.hdl.sdk.link.common.utils.IpUtils; -import com.hdl.sdk.link.common.utils.LogUtils; -import com.hdl.sdk.link.common.utils.ThreadToolUtils; -import com.hdl.sdk.link.core.bean.LinkRequest; -import com.hdl.sdk.link.core.bean.LinkResponse; -import com.hdl.sdk.link.core.bean.gateway.GatewayBean; -import com.hdl.sdk.link.core.bean.request.AuthenticateRequest; -import com.hdl.sdk.link.core.bean.response.AuthenticateResponse; -import com.hdl.sdk.link.core.bean.response.BaseLocalResponse; -import com.hdl.sdk.link.core.bean.response.GatewaySearchBean; -import com.hdl.sdk.link.core.bean.response.NetworkAccessBroadcastResponse; -import com.hdl.sdk.link.core.callback.BaseCallBack; -import com.hdl.sdk.link.core.callback.HDLLinkCallBack; -import com.hdl.sdk.link.core.callback.HDLLinkResponseCallBack; -import com.hdl.sdk.link.common.config.TopicConstant; -import com.hdl.sdk.link.common.utils.IdUtils; -import com.hdl.sdk.link.common.utils.gson.GsonConvert; -import com.hdl.sdk.link.core.config.HDLLinkConfig; -import com.hdl.sdk.link.core.protocol.LinkMessageDecoder; -import com.hdl.sdk.link.core.protocol.LinkMessageDecoderUdp; -import com.hdl.sdk.link.core.protocol.LinkMessageEncoder; -import com.hdl.sdk.link.socket.client.UdpClient; -import com.hdl.sdk.link.socket.codec.MessagePipeLine; -import com.hdl.sdk.link.socket.udp.UdpSocketBoot; -import com.hdl.sdk.link.socket.udp.UdpSocketOptions; - -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - -import static com.hdl.sdk.link.common.config.TopicConstant.DEIVCE_AUTH_REQUEST; - -/** - * Created by jlchen on 11/11/21. - * - * @Description : HDLAuthSocket 鐢变簬鍓嶆湡宸茬粡鍛藉悕濂斤紝涓嶅仛鏇存敼锛屽彲鐢ㄤ綔Udp鏈嶅姟绔娇鐢� - */ -public class HDLUdpConnect { - private static final String TAG = "HDLAuth"; - /** - * udp榛樿绔彛 - */ - public static final int UDP_PORT = 8585; - /** - * 鍥犱负鑰冭檻鍒颁娇鐢ㄤ竴涓鍙o紝瑕佹敮鎸佹帴鏀跺缃戝叧鐨勬暟鎹紝鎵�浠ュ彧鍏佽浣跨敤涓�涓� - */ - private static UdpSocketBoot udpSocketBoot; - // private EventListener authEvent; - //鎼滅储缃戝叧 - private EventListener searchGatewayEvent; - /** - * udp榛樿缁勬挱ip - */ - private static final String UDP_GROUP_IP = "239.0.168.188"; - - private static boolean bindSuccess; - - public static boolean isBindSuccess() { - return bindSuccess; - } - - /** - * instance - */ - private volatile static HDLUdpConnect instance; - - private HDLUdpConnect() { - initListenerGatewayEvent(); - initSearchGatewayEvent(); - } - - /** - * getInstance - * - * @return HDLAuthSocket - */ - public static synchronized HDLUdpConnect getInstance() { - if (instance == null) { - synchronized (HDLLinkConfig.class) { - if (instance == null) { - instance = new HDLUdpConnect(); - } - } - } - return instance; - } - - private UdpSocketOptions getUdpOptions() { - final UdpSocketOptions options = new UdpSocketOptions(); - WifiManager manager = (WifiManager) HDLLinkLocalSdk.getInstance().getContext().getApplicationContext() - .getSystemService(Context.WIFI_SERVICE); - options.setWifiManager(manager); - final MessagePipeLine pipeLine = new MessagePipeLine(); - pipeLine.add(new LinkMessageDecoderUdp()); -// pipeLine.add(new LinkMessageEncoder()); - options.setHandleMessage(pipeLine); - return options; - } - - - /** - * 鑾峰彇褰撳墠udp瀵硅薄锛屽鏋滀笉瀛樺湪灏卞垱寤� - * - * @return 杩斿洖褰撳墠瀵硅薄 - */ - public synchronized UdpSocketBoot getUdpBoot() { - if (null == initUdp()) { - return null; - } - return udpSocketBoot; - } - - - /** - * 鍒濆鍖杣dp 鐩戝惉鍔熻兘 - * - * @return 杩斿洖褰撳墠瀵硅薄 - */ - public synchronized UdpSocketBoot initUdp() { - try { - if (udpSocketBoot == null) { - udpSocketBoot = UdpClient.init("0.0.0.0",UDP_PORT, getUdpOptions()); - udpSocketBoot.bind(); - bindSuccess=true; - } - } catch (Exception e) { - LogUtils.e("鍒濆鍖栫綉鍏冲け璐�:"+e.getMessage()); - return null; - } - - return udpSocketBoot; - } - - - /** - * 寮�濮嬬洃鍚拰鍙戣捣鍏ョ綉鍙婅璇佽姹� - * - * @param request 璁よ瘉璇锋眰淇℃伅 - * @param callBack 缁撴灉鍥炶皟 - */ - public void startAuthenticateRequest(AuthenticateRequest request, HDLLinkCallBack callBack) { - HDLLinkConfig.getInstance().clearConfig(); - //1.鍚姩Socket 寮�鍚洃鍚� - getUdpBoot(); - //2.鏋勫缓鐩戝惉Listener -// authEvent = - //3.鐩戝惉缃戝叧骞挎挱鐨勫叆缃戞寚浠� - EventDispatcher.getInstance().register(TopicConstant.GATEWAY_AUTH_BROADCAST, new EventListener() { - @Override - public void onMessage(Object msg) { - NetworkAccessBroadcastResponse bean = getNetworkAccessBroadcastResponse(msg); - if (bean != null) { - LogUtils.i(TAG, "缃戝叧鍏ョ綉骞挎挱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"); - } - }); - } - - /** - * 缁撴潫鐩戝惉鍏ョ綉鍙婅璇佸箍鎾� - */ - public void endAuthenticateRequest() { - //绉婚櫎鐩戝惉 - EventDispatcher.getInstance().remove(TopicConstant.GATEWAY_AUTH_BROADCAST); - } - - /** - * 鍙戦�佸叆缃戝強璁よ瘉璇锋眰 - * - * @param ip 缃戝叧IP - * @param request 璁よ瘉璇锋眰淇℃伅 - * @param callBack 缁撴灉鍥炶皟 - */ - public void sendAuthenticateRequest(String ip, AuthenticateRequest request, HDLLinkCallBack callBack) { - if (request == null) { - callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_NULL_ERROR)); - } - String topic = DEIVCE_AUTH_REQUEST; - Gson gs = new Gson(); - String requestStr = gs.toJson(request); - LinkRequest linkRequest = new LinkRequest(topic, requestStr, false); -// linkRequest.setReplyTopic(requestStr + "_reply"); - new HDLConnectHelper(ip, linkRequest, new HDLConnectHelper.HdlSocketListener() { - @Override - public void onSucceed(Object msg) { - if (callBack == null) return; - try { - AuthenticateResponse bean = getAuthenticateResponseBean(msg); - if (bean != null) { - 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)); - } - } catch (Exception e) { - callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_ERROR)); - } - } - - @Override - public void onFailure(HDLLinkCode hdlLinkCode) { - LogUtils.i(TAG, "onFailure: "); - if (callBack == null) return; - callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); - } - }, false).send(); - } - -// /** -// * 鍙戦�佸叆缃戝強璁よ瘉璇锋眰 -// * -// * @param callBack 缁撴灉鍥炶皟 -// */ -// public void sendAuthenticateRequest(CallBack callBack) { -// String macStr = "AA000000000000BB"; -// String secret = "87ae414b7a853f65"; -// String mac_key = stringToMD5(stringToMD5(macStr + secret)); -// -// String versionString = "HDL_V1.0.1"; -// String time = String.valueOf(System.currentTimeMillis()); -// -// //1.璁剧疆璁よ瘉淇℃伅 -// AuthenticateRequest.RequestBean requestBean = new AuthenticateRequest.RequestBean(); -// requestBean.setMAC(macStr); -// requestBean.setSupplier("HDL"); -// requestBean.setFirmwareVersion(versionString); -// requestBean.setHardwareModel("1956F"); -// AuthenticateRequest.AuthBean authbean = new AuthenticateRequest.AuthBean(); -// authbean.setSpk("ir.module"); -// authbean.setMACKey(mac_key); -// authbean.setRequest(requestBean); -// -// -// //2.璁剧疆璁惧淇℃伅 -// AuthenticateDeviceInfoBean infoBean = new AuthenticateDeviceInfoBean(); -// infoBean.setDeviceMAC(macStr); -// infoBean.setIPMAC(macStr); -// infoBean.setDeviceName("HDL闈㈡澘"); -// infoBean.setAccessMode("HDL"); -// infoBean.setOID(getOid()); -// infoBean.setSid(getSid()); -//// 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); -// -// String ip = IpUtils.getBroadcastAddress(); -// ip = "192.168.10.102"; -// sendAuthenticateRequest(ip, request, callBack); -// } - - public interface SearchGatewayCallBack extends BaseCallBack { - /** - * 鎼滅储缃戝叧鎴愬姛 - * - * @param gatewaySearchBean - */ - void onSuccess(GatewaySearchBean gatewaySearchBean); - } - - - /** - * 鏆傚仠鎼滅储缃戝叧 - */ - public void endSearchAllGateway() { - - } - - /** - * 缁勬挱鎼滅储鎸囧畾缃戝叧鏄惁鍦ㄧ嚎锛屾悳绱㈠埌鍒欒繑鍥炴寚瀹氱殑缃戝叧瀵硅薄 - * - * @param callBack 鍥炶皟 - */ - public void searchGatewayMulticast(SearchGatewayCallBack callBack) { - searchGateway(HDLLinkConfig.getInstance().getGatewayId(), UDP_GROUP_IP, UDP_PORT, callBack); - } - - /** - * 缁勬挱鎼滅储鎸囧畾缃戝叧鏄惁鍦ㄧ嚎锛屾悳绱㈠埌鍒欒繑鍥炴寚瀹氱殑缃戝叧瀵硅薄 - * - * @param callBack 鍥炶皟 - */ - public void searchGatewayBroadcast(SearchGatewayCallBack callBack) { - if (!HDLLinkConfig.getInstance().checkIfCertified()) { - if (callBack != null) { - callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_UNAUTHORIZED_ERROR)); - } - return; - } - String ip = IpUtils.getBroadcastAddress(); - searchGateway(HDLLinkConfig.getInstance().getGatewayId(), ip, UDP_PORT, callBack); - } - - /** - * 閫氱敤鍙戦�佹寚浠� - * 1绉掓病鍝嶅簲灏辫浠栭噸鏂板彂閫�,閲嶈瘯3娆� - * - * @param topic 鍙戦�佹暟鎹� - * @param bodyStr 鍥炲鐨勪富棰� - * @param broadcast 鏄惁瑕佸箍鎾� - * @param callBack 鍥炶皟 - */ - public void udpSendMsg(String topic, String bodyStr, boolean broadcast, HDLLinkResponseCallBack callBack) { - if (TextUtils.isEmpty(topic) || TextUtils.isEmpty(bodyStr)) { - if (callBack != null) { - callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_NULL_ERROR)); - } - return; - } - - if (!HDLLinkConfig.getInstance().checkIfCertified()) { - if (callBack != null) { - callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_UNAUTHORIZED_ERROR)); - } - return; - } - - LinkRequest message = new LinkRequest(topic, bodyStr, false); - String ip = HDLLinkConfig.getInstance().getIpAddress(); - if (broadcast) { - ip = IpUtils.getBroadcastAddress(); - } - new HDLConnectHelper(ip, message, new HDLConnectHelper.HdlSocketListener() { - @Override - public void onSucceed(Object msg) { - if (callBack == null) return; - callBack.onSuccess((LinkResponse) msg); - } - - @Override - public void onFailure(HDLLinkCode hdlLinkCode) { - if (callBack == null) return; - callBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); - } - } - , false).send(); - } - - /** - * 閫氱敤鍙戦�佹寚浠� 鍙彂涓�娆★紝涓嶇洃鍚洖澶嶏紝涓嶉噸鍙� - * - * @param topic 鍙戦�佹暟鎹� - * @param bodyStr 鍥炲鐨勪富棰� - * @param broadcast 鏄惁骞挎挱 - */ - public void udpSendMsg(String topic, String bodyStr, boolean broadcast) { - if (TextUtils.isEmpty(topic) || TextUtils.isEmpty(bodyStr)) { - LogUtils.e("udpSendMsg", "鍙傛暟涓嶈兘涓虹┖"); - return; - } - if (!HDLLinkConfig.getInstance().checkIfCertified()) { - LogUtils.e("udpSendMsg", "鏈璇侊紝璇峰厛璁よ瘉"); - return; - } - LinkRequest message = new LinkRequest(topic, bodyStr, HDLLinkConfig.getInstance().isLocalEncrypt()); - String ip = HDLLinkConfig.getInstance().getIpAddress(); - if (broadcast) { - ip = IpUtils.getBroadcastAddress(); - } - new HDLConnectHelper(ip, message, false).send(); - } - - private GatewaySearchBean getGatewaySearchBean(Object msg) { - GatewaySearchBean searchBean = null; - if (msg instanceof LinkResponse) { - LinkResponse linkResponse = (LinkResponse) msg; - String data = linkResponse.getData(); - if (!TextUtils.isEmpty(data)) { - final BaseLocalResponse<GatewaySearchBean> response = GsonConvert.getGson().fromJson(data, new TypeToken<BaseLocalResponse<GatewaySearchBean>>() { - }.getType()); - searchBean = response.getObjects(); - } - } - return searchBean; - } - - private AuthenticateResponse getAuthenticateResponseBean(Object msg) { - AuthenticateResponse mBean = null; - if (msg instanceof LinkResponse) { - LinkResponse linkResponse = (LinkResponse) msg; - String data = linkResponse.getData(); - if (!TextUtils.isEmpty(data)) { - AuthenticateResponse response = GsonConvert.getGson().fromJson(data, new TypeToken<AuthenticateResponse>() { - }.getType()); - mBean = response; - } - - } - return mBean; - } - - private NetworkAccessBroadcastResponse getNetworkAccessBroadcastResponse(Object msg) { - NetworkAccessBroadcastResponse mBean = null; - if (msg instanceof LinkResponse) { - LinkResponse linkResponse = (LinkResponse) msg; - String data = linkResponse.getData(); - if (!TextUtils.isEmpty(data)) { - NetworkAccessBroadcastResponse response = GsonConvert.getGson().fromJson(data, new TypeToken<NetworkAccessBroadcastResponse>() { - }.getType()); - mBean = response; - } - - } - return mBean; - } - - /** - * 缃戝叧鎼滅储鐩稿叧 - */ - private static final int MAX_SEARCH_COUNT = 10;//鎬诲叡鎼滅储娴嬭瘯 - private final AtomicInteger searchGatewayCount = new AtomicInteger(0); - ; - private final AtomicBoolean isSearchGatewaySuccess = new AtomicBoolean(true); - private String searchGatewayId = ""; - private SearchGatewayCallBack mSearchGatewayCallBack; - - private void initSearchGatewayEvent() { - LogUtils.i("鎼滅储缃戝叧", "initSearchGatewayEvent"); - searchGatewayEvent = new EventListener() { - @Override - public void onMessage(Object msg) { - try { - if (msg instanceof LinkResponse) { - LinkResponse linkResponse = (LinkResponse) msg; - String data = linkResponse.getData(); - if (!TextUtils.isEmpty(data)) { - final BaseLocalResponse<GatewaySearchBean> response = GsonConvert.getGson().fromJson(data, new TypeToken<BaseLocalResponse<GatewaySearchBean>>() { - }.getType()); - GatewaySearchBean searchBean = response.getObjects(); - if (searchBean != null && !TextUtils.isEmpty(searchBean.getGatewayId())) { - if (searchBean.getGatewayId().contains(searchGatewayId)) { - removeSearchGatewayEvent();//绉婚櫎鎼滅储缃戝叧鐩戝惉 - isSearchGatewaySuccess.set(true);//鎼滅储鎴愬姛鏍囪 - searchGatewayCount.set(11);//娆℃暟鏍囪 - HDLLinkConfig.getInstance().setLocalEncrypt(searchBean.isLocalEncrypt());//璁剧疆鏄惁鍔犲瘑 - if (mSearchGatewayCallBack != null) { - mSearchGatewayCallBack.onSuccess(searchBean); - } - } - } - } - } - } catch (Exception e) { - - } - } - }; - } - - private void initListenerGatewayEvent() { - LogUtils.i("鍒濆鍖栨案涔呯洃鍚綉鍏冲箍鎾簨浠讹紝涓嶇敤绉婚櫎姝や簨浠�"); - EventListener gatewayEvent = new EventListener() { - @Override - public void onMessage(Object msg) { - try { - if (msg instanceof LinkResponse) { - LinkResponse linkResponse = (LinkResponse) msg; - String data = linkResponse.getData(); -// LogUtils.i("鎺ユ敹鍒扮綉鍏充俊鎭細" + data); - if (!TextUtils.isEmpty(data)) { - final BaseLocalResponse<GatewayBean> response = GsonConvert.getGson().fromJson(data, new TypeToken<BaseLocalResponse<GatewayBean>>() { - }.getType()); - GatewayBean gateway = response.getObjects(); - if (gateway != null) { - if (!TextUtils.isEmpty(gateway.getGatewayId()) - && !TextUtils.isEmpty(gateway.getHomeId())) { - //涓荤綉鍏冲苟涓旀槸褰撳墠缁戝畾鐨勭綉鍏� - if ("true".equals(gateway.getMaster().toLowerCase())) { - if (gateway.getGatewayId().equals(HDLLinkConfig.getInstance().getGatewayId()) - || gateway.getDevice_mac().equals(HDLLinkConfig.getInstance().getGatewayId()) - || gateway.getOid().equals(HDLLinkConfig.getInstance().getGatewayId()) - || gateway.getHomeId().equals(HDLLinkConfig.getInstance().getHomeId())) { - HDLLinkConfig.getInstance().setLocalEncrypt(gateway.getIsLocalEncrypt());//璁剧疆鏄惁鍔犲瘑 - HDLLinkConfig.getInstance().setIpAddress(gateway.getIp_address()); - //鏇存柊褰撳墠缃戝叧鐨勪俊鎭� - HDLLinkConfig.getInstance().reSaveConfig(); - } - } - } - - if(TextUtils.isEmpty(gateway.getHomeId())||gateway.getHomeId().equals(HDLLinkConfig.getInstance().getHomeId())) { - HDLTcpConnect.initTcp(gateway.getIp_address());//鍒濆鍖朤CP杩炴帴 - } - } - } - } - } catch (Exception e) { - - } - } - }; - EventDispatcher.getInstance().registerIo(TopicConstant.GATEWAY_SEARCH_REPLY, gatewayEvent); - } - - /** - * 鎼滅储鎸囧畾缃戝叧鏄惁鍦ㄧ嚎锛屾悳绱㈠埌鍒欒繑鍥炴寚瀹氱殑缃戝叧瀵硅薄 - * - * @param gatewayId 缃戝叧id - * @param ipAddress 鐩爣鐨処P鍦板潃 - * @param port 鐩爣鐨勭鍙� - * @param callBack 鍥炶皟 - */ - public void searchGateway(String gatewayId, String ipAddress, int port, SearchGatewayCallBack callBack) { - this.searchGatewayId = gatewayId; - this.mSearchGatewayCallBack = callBack; - //閲嶇疆鍙傛暟 - searchGatewayCount.set(0); - isSearchGatewaySuccess.set(false); - String time = String.valueOf(System.currentTimeMillis()); - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("id", IdUtils.getUUId()); - jsonObject.addProperty("time_stamp", time); - LinkRequest message = new LinkRequest(TopicConstant.GATEWAY_SEARCH, - jsonObject.toString(), false); - //娉ㄥ唽鎼滅储缃戝叧鐩戝惉 - registerSearchGatewayEvent(); - new Thread(new Runnable() { - @Override - public void run() { - while (searchGatewayCount.get() < 10 && (!isSearchGatewaySuccess.get())) { - try { - //鎼滅储缃戝叧 - searchGatewayCount.set(searchGatewayCount.get() + 1); - LogUtils.i("鎼滅储缃戝叧绗�" + searchGatewayCount.get() + "娆�"); - new HDLConnectHelper(ipAddress, message, false).send(); - Thread.sleep(1000L); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - if (!isSearchGatewaySuccess.get()) { - //鎼滅储10娆★紝鎸囧畾缃戝叧閮芥病鍥炲锛屽洖璋冭秴鏃� - callBackSearchGatewayTimeout(); - LogUtils.e("鎼滅储10娆★紝鎸囧畾缃戝叧閮芥病鍥炲锛屽洖璋冭秴鏃�"); - } - } - }).start(); - } - - - /** - * 娉ㄥ唽鎼滅储缃戝叧鐩戝惉 - */ - private void registerSearchGatewayEvent() { - LogUtils.i("娉ㄥ唽鎼滅储缃戝叧鐩戝惉"); - EventDispatcher.getInstance().registerIo(TopicConstant.GATEWAY_SEARCH_REPLY, searchGatewayEvent); - } - - /** - * 绉婚櫎鎼滅储缃戝叧鐩戝惉 - */ - private void removeSearchGatewayEvent() { - LogUtils.i("鎼滅储缃戝叧", "绉婚櫎鎼滅储缃戝叧鐩戝惉"); - EventDispatcher.getInstance().remove(TopicConstant.GATEWAY_SEARCH_REPLY, searchGatewayEvent); - } - - /** - * 鍥炶皟鎼滅储缃戝叧瓒呮椂 - */ - private void callBackSearchGatewayTimeout() { - removeSearchGatewayEvent(); - ThreadToolUtils.getInstance().runOnUiThread(new Runnable() { - @Override - public void run() { - if (mSearchGatewayCallBack != null) { - mSearchGatewayCallBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_SEARCH_GATEWAY_TIMEOUT_ERROR)); - } - } - }); - } - - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLZigbeeConnect.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLZigbeeConnect.java deleted file mode 100644 index cf10133..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/connect/HDLZigbeeConnect.java +++ /dev/null @@ -1,358 +0,0 @@ -package com.hdl.sdk.link.core.connect; - - -import android.text.TextUtils; - -import com.hdl.sdk.link.common.config.TopicConstant; -import com.hdl.sdk.link.common.event.EventDispatcher; -import com.hdl.sdk.link.common.event.EventListener; -import com.hdl.sdk.link.common.exception.HDLLinkCode; -import com.hdl.sdk.link.common.exception.HDLLinkException; -import com.hdl.sdk.link.common.utils.LogUtils; -import com.hdl.sdk.link.common.utils.ThreadToolUtils; -import com.hdl.sdk.link.core.bean.LinkRequest; -import com.hdl.sdk.link.core.bean.LinkResponse; -import com.hdl.sdk.link.core.bean.ZigbeeResponse; -import com.hdl.sdk.link.core.bean.gateway.GatewayBean; -import com.hdl.sdk.link.core.callback.ZigbeeCallBack; -import com.hdl.sdk.link.core.config.HDLLinkConfig; -import com.hdl.sdk.link.gateway.HDLLinkLocalGateway; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -/** - * Created by hxb on 2021/12/8. - * 鍘熺敓閫氳鐩稿叧鎺ュ彛 - */ -public class HDLZigbeeConnect { - - private static final String TAG="HDLZigbeeConnect"; - private static HDLZigbeeConnect instance; - /** - * 鍐呴儴鐢紝涓昏鏄鐞嗗鐞嗘帀閫忎紶涓婚鍙妉ink涓婚鍚庯紝杩樺師Zigbee鍘熺敓鏁版嵁鍙婁富棰樼敤 - */ - private final String zigbeeAllTopic = "/Zigbee"; - - /** - * 杩斿洖褰撳墠瀹炰緥锛屼笉瀛樺湪灏卞垱寤哄苟鍚屾椂娉ㄥ唽鐩戝惉浜嬩欢 - * - * @return - */ - public static HDLZigbeeConnect getInstance() { - if (null == instance) { - instance = new HDLZigbeeConnect(); - instance.initEventListener(); - } - return instance; - } - - /** - * 娉ㄥ唽鐩戝惉Zigbee鎵�鏈夊師鐢熶富棰樺強鏁版嵁 - * - * @param eventListener - */ - public void registerListener(EventListener eventListener) { - if(null==eventListener){ - return; - } - EventDispatcher.getInstance().register(zigbeeAllTopic, eventListener); - } - - /** - * 绉婚櫎鐩戝惉Zigbee鍘熺敓涓婚鍙婃暟鎹� - * - * @param eventListener - */ - public void removeListener(EventListener eventListener) { - if(null==eventListener){ - return; - } - EventDispatcher.getInstance().remove(zigbeeAllTopic, eventListener); - } - - /** - * 鍒濆鍖栫洃鍚簨浠� - */ - private void initEventListener() { - final EventListener eventListener = new EventListener() { - @Override - public void onMessage(Object msg) { - try { - if (msg instanceof LinkResponse) { - LinkResponse linkResponse = (LinkResponse) msg; - String body = linkResponse.getData(); - int index = body.indexOf("{"); - //zigbee鍥炲鐨勬暟鎹墠鏈変富棰橈紝鍚庨潰鎵嶆槸鏁版嵁 - if (index <= 0) - return; - - String zigbeeTopic = body.substring(0, index).trim(); - //zigbee鐨勮礋杞芥暟鎹� - String bodyData = body.substring(index); - - ZigbeeResponse zigbeeResponse = new ZigbeeResponse(); - zigbeeResponse.setTopic(zigbeeTopic); - zigbeeResponse.setData(bodyData); - String oid = null; - //鏄惁鏄�氳繃涓荤綉鍏抽�忎紶涓婚 - if (linkResponse.getTopic().contains("/slaveoid/")) { - oid = linkResponse.getTopic().split("/")[8]; - } else { - oid = linkResponse.getTopic().split("/")[2]; - } - zigbeeResponse.setOid(oid); - for (GatewayBean gatewayBean : HDLLinkLocalGateway.getInstance().getGatewayList()) { - if (oid.equals(gatewayBean.getGatewayId()) || oid.equals(gatewayBean.getDevice_mac()) || oid.equals(gatewayBean.getOid())) { - //涓婇潰鐨刼id鍙兘鏄綉鍏砳d鎴栬�卪ac鎴栬�呮槸oid锛屼笉绠℃槸鍝釜缁熶竴浣跨敤oid琛ㄧず鏂瑰紡 - zigbeeResponse.setOid(gatewayBean.getOid()); - break; - } - } - EventDispatcher.getInstance().post(zigbeeTopic, zigbeeResponse); - //鍙戝竷Zigbee鍘熺敓涓婚鍙婃暟鎹� - EventDispatcher.getInstance().post(zigbeeAllTopic, zigbeeResponse); - } - } catch (Exception e) { - LogUtils.e(TAG,"LinkResponse杞琙igbeeResponse寮傚父:"+ e.getMessage()); - } - } - }; - // - //娉ㄥ唽鐩存帴閫氳鐨勪富棰橈紝鍖呮嫭鐩存帴鍜屼富缃戝叧閫氳鎴栬�呯洿鎺ュ拰浠庣綉鍏抽�氳 -// registerListener(String.format(TopicConstant.NATIVE_ZIGBEE_DOWN_REPLY, "+"), eventListener); - - //娉ㄥ唽鐩存帴閫氳鐨勪富棰橈紝鍖呮嫭鐩存帴鍜屼富缃戝叧閫氳鎴栬�呯洿鎺ュ拰浠庣綉鍏抽�氳 - registerListener(String.format(TopicConstant.NATIVE_ZIGBEE_UP, "+"), eventListener); - - //娉ㄥ唽閫氳繃涓荤綉鍏抽�忎紶浠庣綉鍏崇殑涓婚 -// registerListener(String.format(TopicConstant.NATIVE_ZIGBEE_DOWN_SLAVE_REPLY, "+", "+"), eventListener); - - registerListener(String.format(TopicConstant.NATIVE_ZIGBEE_UP_SLAVE, "+", "+"), eventListener); - } - - /** - * 鍙戦�佸師鐢熸暟鎹� - * - * @param gatewayOidOrGatewayId 鐩爣缃戝叧鐨刼id鎴栬�呯綉鍏矷d - * @param responeTopic 鍥炲涓婚 - * @param payload 鍙戦�佹暟鎹� - * @param zigbeeCallBack 缁撴灉鍥炶皟 - */ - public void Send(String gatewayOidOrGatewayId,String responeTopic, String payload, final ZigbeeCallBack zigbeeCallBack) { - //濡傛灉鏈湴鏈夐摼鎺ヨ繖涓綉鍏�,鍒欑敤鏈湴杩炴帴 - GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getGatewayByOidOrGatewayId(gatewayOidOrGatewayId); - if (null == gatewayBean) { - LogUtils.i("鎵句笉鍒扮綉鍏筹紝Oid鏄�" + gatewayOidOrGatewayId); - if (null != zigbeeCallBack) { - zigbeeCallBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); - } - return; - } - - String tempTopic = String.format(TopicConstant.NATIVE_ZIGBEE_DOWN, gatewayOidOrGatewayId); - LinkRequest request = new LinkRequest(tempTopic, payload, gatewayBean.getIsLocalEncrypt()); - - if ("true".equals(gatewayBean.getMaster())) { - request.setCloudTopic(String.format(TopicConstant.NATIVE_ZIGBEE_DOWN, HDLLinkConfig.getInstance().getGatewayId())); - } else { - request.setCloudTopic(String.format(TopicConstant.NATIVE_ZIGBEE_DOWN_SLAVE, HDLLinkConfig.getInstance().getGatewayId(), gatewayOidOrGatewayId)); - } - request.setReplyTopic(responeTopic); -// final boolean[] isCallBack = {false}; -// //閫忎紶鍛戒护涓婚澶勭悊 -// final EventListener eventListener = new EventListener() { -// @Override -// public void onMessage(Object msg) { -// if (msg instanceof ZigbeeResponse) { -// ZigbeeResponse linkResponse = (ZigbeeResponse) msg; -// //TODO 濡傛灉閰嶇疆浠庣綉鍏崇殑淇℃伅锛岄�氳繃涓荤綉鍏宠浆杈撅紝杩欓噷oid瑕佸垽鏂笅 -// if (responeTopic.equals(linkResponse.getTopic())) { -// isCallBack[0] = true; -// removeListener(zigbeeAllTopic, this); -// if (null != zigbeeCallBack) { -// zigbeeCallBack.onSuccess(linkResponse.getData()); -// } -// } -// } -// } -// }; -// //娉ㄥ唽鐩戝惉 -// registerListener(zigbeeAllTopic, eventListener); - - long timeout = 8 * 1000; - /** - * 闇�瑕佺壒娈婂鐞嗕竴浜涗富棰� 闇�瑕佸欢闀胯秴鏃舵椂闂� - */ - if (responeTopic.equals("Bind/SetBind_Respon") || responeTopic.equals("Bind/ClearBindInfo_Respon")) { - timeout = 20 * 1000; - } -// //涓�瀹氭椂闂村悗杩樻病鏈夋帴鏀跺埌鏁版嵁锛屽氨鍥炶皟澶辫触 -// ScheduledExecutorService scheduledExecutorService = ThreadToolUtils.getInstance().newScheduledThreadPool(1); -// scheduledExecutorService.schedule(new Runnable() { -// @Override -// public void run() { -// removeListener(zigbeeAllTopic, eventListener); -// scheduledExecutorService.shutdownNow(); -// if (!isCallBack[0]) { -// if (null != zigbeeCallBack) { -// zigbeeCallBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GET_Zigbee_FAILURE_ERROR)); -// } -// } -// } -// }, timeout, TimeUnit.SECONDS); - new HDLConnectHelper(timeout, 1, gatewayBean.getIp_address(), 8586, request, new HDLConnectHelper.HdlSocketListener() { - @Override - public void onSucceed(Object msg) { - if (msg instanceof String) { - if (null != zigbeeCallBack) { - zigbeeCallBack.onSuccess(msg+""); - } - } - } - - @Override - public void onFailure(HDLLinkCode hdlLinkCode) { - if (null != zigbeeCallBack) { - zigbeeCallBack.onError(HDLLinkException.getErrorWithCode(hdlLinkCode)); - } - } - }, true).send(); - } - - - - /** - * 鍙戦�佸師鐢熼�忎紶鍛戒护鏁版嵁 - * - * @param gatewayOidOrGatewayId 鐩爣缃戝叧鐨刼id鎴栬�呯綉鍏矷d - * @param responeTopic 鍥炲涓婚 - * @param payload 鍙戦�佹暟鎹� - * @param zigbeeCallBack 缁撴灉鍥炶皟 - */ - public void SendThrough(String gatewayOidOrGatewayId, String responeTopic, String payload, final ZigbeeCallBack zigbeeCallBack) { -// //濡傛灉鏈湴鏈夐摼鎺ヨ繖涓綉鍏�,鍒欑敤鏈湴杩炴帴 -// GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getGatewayByOidOrGatewayId(gatewayOidOrGatewayId); -// if (null == gatewayBean) { -// LogUtils.i("鎵句笉鍒扮綉鍏筹紝Oid鏄�" + gatewayOidOrGatewayId); -// if (null != zigbeeCallBack) { -// zigbeeCallBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GATEWAY_NOT_EXIST)); -// } -// return; -// } -// boolean isLocal = gatewayBean.getIsLocalGateway(); -// //濡傛灉鏄湰鍦伴�氳 -// if (isLocal == true) { -// -// String tempTopic = String.format("/user/%s/custom/native/zigbee/down", gatewayOidOrGatewayId); -// String tempTopicReply = String.format("/user/%s/custom/native/zigbee/up", gatewayOidOrGatewayId); -// -// final boolean[] isCallBack = {false}; -// //閫忎紶鍛戒护涓婚澶勭悊 -// final EventListener eventListener = new EventListener() { -// @Override -// public void onMessage(Object msg) { -// if (msg instanceof LinkResponse) { -// LinkResponse linkResponse = (LinkResponse) msg; -// //TODO 濡傛灉閰嶇疆浠庣綉鍏崇殑淇℃伅锛岄�氳繃涓荤綉鍏宠浆杈撅紝杩欓噷oid瑕佸垽鏂笅 -// String body = getZigbeeData(responeTopic, linkResponse); -// if (null != body) { -// isCallBack[0] = true; -// removeListener(tempTopicReply, this); -// if (null != zigbeeCallBack) { -// zigbeeCallBack.onSuccess(body); -// } -// } -// } -// } -// }; -// //娉ㄥ唽鐩戝惉 -// registerListener(tempTopicReply, eventListener); -// -// //涓�瀹氭椂闂村悗杩樻病鏈夋帴鏀跺埌鏁版嵁锛屽氨鍥炶皟澶辫触 -// ScheduledExecutorService scheduledExecutorService = ThreadToolUtils.getInstance().newScheduledThreadPool(1); -// scheduledExecutorService.schedule(new Runnable() { -// @Override -// public void run() { -// removeListener(tempTopicReply, eventListener); -// scheduledExecutorService.shutdownNow(); -// if (!isCallBack[0]) { -// if (null != zigbeeCallBack) { -// zigbeeCallBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GET_Zigbee_FAILURE_ERROR)); -// } -// } -// } -// }, 5, TimeUnit.SECONDS); -// -// //鏈湴鍙戦�� -// LinkRequest request = new LinkRequest(tempTopic, payload, gatewayBean.getIsLocalEncrypt()); -// new HDLConnectHelper(gatewayBean.getIp_address(), request,true).send(); -// } else { -// //璇锋眰涓婚 -// String tempTopic = null; -// //鍥炲涓婚 -// String tempTopicReply = null; -// -// //杩滅▼鍙戦�� -// if ("true".equals(gatewayBean.getMaster())) { -// tempTopic = String.format("/user/%s/custom/native/zigbee/down", com.hdl.sdk.link.core.config.HDLLinkConfig.getInstance().getGatewayId()); -// tempTopicReply = String.format("/user/%s/custom/native/zigbee/up", com.hdl.sdk.link.core.config.HDLLinkConfig.getInstance().getGatewayId()); -// } else { -// tempTopic = String.format("/user/%s/custom/native/zigbee/slaveoid/%s/down", com.hdl.sdk.link.core.config.HDLLinkConfig.getInstance().getGatewayId(), gatewayOidOrGatewayId); -// tempTopicReply = String.format("/user/%s/custom/native/zigbee/slaveoid/%s/up", com.hdl.sdk.link.core.config.HDLLinkConfig.getInstance().getGatewayId(), "+"); -// } -// //TODO 鍚庣画瀹屽杽浜戠鐨勫彂閫佹帴鏀舵柟娉� -// } - } - - - /** - * 澶勭悊zigbee鍥炲鐨勬暟鎹� - * - * @param responeTopic 鍥炲涓婚 - * @param linkResponse 鍥炲鐨勯�忎紶鏁版嵁 - */ - private static String getZigbeeData(String responeTopic, LinkResponse linkResponse) { - //涓婚涓虹┖涓嶅鐞� - if(TextUtils.isEmpty(responeTopic)){ - return null; - } - - String body = linkResponse.getData(); - int index = body.indexOf("{"); - //zigbee鍥炲鐨勬暟鎹墠鏈変富棰橈紝鍚庨潰鎵嶆槸鏁版嵁 - if (index <= 0) - return null; - - String zigbeeTopic = body.substring(0, index).trim(); - //zigbee鐨勮礋杞芥暟鎹� - String bodyData = body.substring(index); - - //涓嶆槸褰撳墠璇锋眰鐨勬暟鎹紝涓嶅鐞� - if (!zigbeeTopic.startsWith(responeTopic)) { - return null; - } - - return bodyData; - //Zigbee浠ュ墠鐨勬帴鏀堕�昏緫 -// HdlZbGatewayReceiveLogic.Current.ZigbeeOldReceiveLogic(reportTopic, bodyData, gatewayMac); - } - - /** - * 娉ㄥ唽鐩戝惉 - */ - static void registerListener(String responseTopic, EventListener eventListener) { - if (!TextUtils.isEmpty(responseTopic)) { - EventDispatcher.getInstance().register(responseTopic, eventListener); - } - } - - /** - * 绉婚櫎鐩戝惉 - */ - static void removeListener(String responseTopic, EventListener eventListener) { - if (!TextUtils.isEmpty(responseTopic)) { - EventDispatcher.getInstance().remove(responseTopic, eventListener); - } - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/protocol/LinkMessageDecoder.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/protocol/LinkMessageDecoder.java deleted file mode 100644 index aa07c9d..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/protocol/LinkMessageDecoder.java +++ /dev/null @@ -1,323 +0,0 @@ -package com.hdl.sdk.link.core.protocol; - - -import com.hdl.sdk.link.common.utils.LogUtils; -import com.hdl.sdk.link.common.event.EventDispatcher; -import com.hdl.sdk.link.common.utils.ByteUtils; -import com.hdl.sdk.link.core.bean.LinkPacket; -import com.hdl.sdk.link.core.bean.LinkResponse; -import com.hdl.sdk.link.core.utils.ByteBufferUtils; -import com.hdl.sdk.link.core.utils.QueueUtils; -import com.hdl.sdk.link.gateway.HDLLinkLocalGateway; -import com.hdl.sdk.link.socket.bean.Packet; -import com.hdl.sdk.link.socket.codec.ByteToMessageDecoder; - -import java.nio.ByteBuffer; - -/** - * Created by Tong on 2021/9/22. - * link鍗忚绮樺寘鎷嗗寘 - */ -public class LinkMessageDecoder extends ByteToMessageDecoder<LinkResponse> { - - private static final String TAG=LinkMessageDecoder.class.getName(); - //instance - private volatile static LinkMessageDecoder instance; - - //getInstance - public static synchronized LinkMessageDecoder getInstance() { - if (instance == null) { - synchronized (LinkMessageDecoder.class) { - if (instance == null) { - instance = new LinkMessageDecoder(); - } - } - } - return instance; - } - - /** - * 鎺ユ敹鏁版嵁缂撳啿鍖� - */ - private final ByteBuffer byteBuffer; - - private final byte[] head = "Topic:".getBytes(); - - public LinkMessageDecoder() { - byteBuffer = ByteBuffer.allocate(1024 * 200);//100K - } - - /// <summary> - /// 鑾峰彇鍐呭闀垮害 - /// </summary> - /// <param name="topMsgs"></param> - /// <returns></returns> - int getLenght(String[] topMsgs) { - try { - for (int i = 0; i < topMsgs.length; i++) { - String topMsg = topMsgs[i].trim(); - if (topMsg.startsWith("Length:")) { - return Integer.parseInt(topMsg.replace("Length:", "").trim()); - } - } - } catch (Exception e) { - LogUtils.e("寮傚父鏁版嵁锛�" + topMsgs[0] + "\r\n" + topMsgs[1]); - return -1; - } - //鎵句笉鍒伴暱搴� - return -1; - } - - /// <summary> - /// 鑾峰彇涓婚 - /// </summary> - /// <param name="topMsgs"></param> - /// <returns></returns> - private String getTopic(String[] topMsgs) { - for (int i = 0; i < topMsgs.length; i++) { - String topMsg = topMsgs[i].trim(); - if (topMsg.startsWith("Topic:")) { - return topMsg.replace("Topic:", ""); - } - } - //鎵句笉鍒颁富棰� - return null; - } - - /** - * 鑾峰彇鏁版嵁鐨勫紑濮嬩綅缃� - * - * @return 鏁版嵁浣嶇殑寮�濮嬬储寮� - */ - int getBodyIndex() { - byte r = (byte) '\r'; - byte n = (byte) '\n'; - for (int i = 0; i < byteBuffer.position(); i++) { - //鎵惧嚭鏁版嵁鍐呭鍓嶉潰鐨勪袱涓崲琛� - if (3 <= i && byteBuffer.get(i - 3) == r && byteBuffer.get(i - 2) == n && byteBuffer.get(i - 1) == r && byteBuffer.get(i) == n) { - //鍓╀綑鐨勬暟鎹� - return i + 1; - } - } - return -1; - } - - /** - * 鑾峰彇澶撮儴鏁版嵁 - * - * @return - */ - String getHeader() { - int bodyIndex = getBodyIndex(); - if (bodyIndex < 0) { - //娌℃湁鎵惧埌澶撮儴鏁版嵁 - return null; - } else { - byte bodyBytes[] = ByteBufferUtils.copyBytes(byteBuffer, bodyIndex); - return new String(bodyBytes); - } - } - - /** - * 鑾峰彇鏁版嵁鍐呭 - * - * @param lenght - * @return - */ - byte[] getBody(int index, int lenght) { - //鏄惁宸茬粡鑾峰彇瀹屾暣鎵�鏈夌殑鏁版嵁 - byte[] bodyBytes = new byte[lenght]; - if (index < 0 || byteBuffer.position() < index + lenght) { - //褰撳墠鏁版嵁杩樻病鏈夋帴鏀跺畬鎴� - return null; - } - - for (int i = 0; i < bodyBytes.length; i++) { - bodyBytes[i] = byteBuffer.get(index + i); - } - return bodyBytes; - } - - - /** - * 杩欒竟澶勭悊浜嗙紦瀛樻暟鎹矘鍖呯殑鎯呭喌锛屾瘡娆¤姹傞兘闇�瑕佸惂褰撳墠瀹屾暣鐨勬枃浠堕櫎鍘� 浠ヤ究浜庝笅娆$殑杩斿洖 - * tempList鐢ㄤ簬瀛樺偍澶氫綑鐨勬暟鎹� - * contentList鐢ㄤ簬鏈鏁版嵁鐨勫瓨鍌紙鍙戦�佺粰璁㈤槄鐨勬暟鎹級 - */ - byte[] geBody() { - int len = 3 + 4 + 4 + ((byteBuffer.get(7) & 0xFF) * 256 * 256 * 256) + ((byteBuffer.get(8) & 0xFF) * 256 * 256) + ((byteBuffer.get(9) * 256) & 0xFF) + (byteBuffer.get(10) & 0xFf); - byte[] bodyBytes = new byte[len]; - for (int i = 0; i < len; i++) { - bodyBytes[i] = byteBuffer.get(i); - } - - int endIndex = byteBuffer.position(); - byteBuffer.clear(); - for (int i = len; i < endIndex; i++) { - byteBuffer.put(byteBuffer.get(i)); - } - return bodyBytes; - } - - /** - * 绉婚櫎鍙兘瀛樺湪鐨勬棤鏁堟暟鎹� - */ - void removeInVoidBytes() { - int index = 0; - boolean isMatch = false; - for (; index < byteBuffer.position() - head.length; index++) { - isMatch = true; - for (int j = 0, k = 0; j < head.length; j++, k++) { - if (head[j] != byteBuffer.get(index + k)) { - isMatch = false; - break; - } - } - if (isMatch) { - break; - } - } - - if (0 < index && isMatch) { - int endIndex = byteBuffer.position(); - byteBuffer.clear(); - for (int i = index; i < endIndex; i++) { - byteBuffer.put(byteBuffer.get(i)); - } - } - } - - /** - * 绉婚櫎鍒版寚瀹氫綅缃墠闈㈢殑鏁版嵁 - * - * @param position 鎸囧畾浣嶇疆 - */ - void remove(int position) { - int endIndex = byteBuffer.position(); - byteBuffer.clear(); - for (int i = position; i < endIndex; i++) { - byteBuffer.put(byteBuffer.get(i)); - } - } - - void fileManger(int commandAck, byte[] recevieBytes) { - String topic = "65531_" + commandAck; - LinkResponse response = new LinkResponse(); - response.setTopic(topic); - response.setByteData(recevieBytes); - EventDispatcher.getInstance().post(response.getTopic(), response); - } - - int bytes2int(byte[] bytes) { - int result = 0; - if (bytes.length == 2) { - int c = (bytes[0] & 0xff) << 8; - int d = (bytes[1] & 0xff); - result = c | d; - } else if (bytes.length == 4) { - return bytes[3] & 0xFF | // - (bytes[2] & 0xFF) << 8 | // - (bytes[1] & 0xFF) << 16 | // - (bytes[0] & 0xFF) << 24; // - } - return result; - } - - public String byte2hex(byte[] bytes) { - StringBuilder sb = new StringBuilder(); - String tmp = null; - for (byte b : bytes) { - //灏嗘瘡涓瓧鑺備笌0xFF杩涜涓庤繍绠楋紝鐒跺悗杞寲涓�10杩涘埗锛岀劧鍚庡�熷姪浜嶪nteger鍐嶈浆鍖栦负16杩涘埗 - tmp = Integer.toHexString(0xFF & b); - if (tmp.length() == 1) { - tmp = "0" + tmp; - } - sb.append(tmp + " "); - } - return sb.toString(); - } - - @Override - protected synchronized LinkResponse decoder(Packet packet) { - try { - if (null == packet) { - return null; - } - byteBuffer.put(packet.getBytes()); - } catch (Exception e) { - LogUtils.e("鎺ユ敹鍒版暟鎹紓甯�:\r\n" + e.getMessage()); - byteBuffer.flip(); - byteBuffer.clear(); - } - try { - //濡傛灉澶氭潯鍛戒护鎵撳寘鍦ㄤ竴鏉℃暟鎹腑锛岄兘闇�瑕佸鐞嗗畬 - while (true) { - if (byteBuffer.position() > 2) {//鍒ゆ柇鏄惁鏄枃浠跺鐞嗛�氱煡 wxr - byte[] topBytes = new byte[3]; - topBytes[0] = byteBuffer.get(0); - topBytes[1] = byteBuffer.get(1); - topBytes[2] = byteBuffer.get(2); - if (new String(topBytes).equals("hex")) { - //TODO 杩欏潡浠g爜缁熶竴绉诲嚭鍏跺畠鍦版柟澶勭悊 - byte[] commandBytes = ByteBufferUtils.copyBytes(byteBuffer, 5, 2); - int command = bytes2int(commandBytes); - byte[] submitBytes = geBody(); - if (command == 258 || command == 260 || command == 261) { - //璇诲彇椹卞姩鍒楄〃鍝嶅簲 ||椹卞姩瀹夎鐢宠鍝嶅簲 - if (submitBytes.length > 11) { - byte[] rangeBytes = ByteUtils.copyBytes(submitBytes, 11, submitBytes.length - 11); - fileManger(command, rangeBytes); - } else { - //鏂逛究闂鎺掓煡 - fileManger(command, submitBytes); - } - } else { - //缁欑妗′娇鐢� 鍚庨潰鐨勪笟鍔℃渶濂介兘鍦ㄨ繖杈瑰鐞� 涓嶇劧浼氶�犳垚涓氬姟鍒嗘暎 - fileManger(command, submitBytes); - } - continue; - } - } - removeInVoidBytes();//绉婚櫎鍙兘瀛樺湪鐨勬棤鏁堟暟鎹� - - //澶撮儴鏁版嵁 - String header = getHeader(); - - if (header == null) { - break; - } - String[] topMsgs = header.split("\r\n"); - - String topic = getTopic(topMsgs); - int lenght = getLenght(topMsgs); - if (topic == null || lenght <= 0) { - //鑾峰彇涓嶅埌涓婚鎴栬�呭ご閮ㄦ暟鎹繕娌℃湁鎺ユ敹瀹屾垚 - break; - } - - int bodyIndex = getBodyIndex(); - //鏄惁宸茬粡鑾峰彇瀹屾暣鎵�鏈夌殑鏁版嵁 - byte[] body = getBody(bodyIndex, lenght); - - if (body == null) { - //褰撳墠鏁版嵁杩樻病鏈夋帴鏀跺畬鎴� - break; - } - - remove(bodyIndex + lenght); - - if (topic.contains("heartbeat_reply")) { - if (packet.getSocket() != null) { - packet.getSocket().setSoTimeout(10 * 1000); - } - continue; - } - - QueueUtils.getInstance().add(new LinkPacket(topic, body)); - } - } catch (Exception ee) { - LogUtils.e("澶勭悊鎺ユ敹鐨勬暟鎹紓甯�:\r\n" + ee.getMessage()); - } - return null; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/protocol/LinkMessageDecoderUdp.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/protocol/LinkMessageDecoderUdp.java deleted file mode 100644 index cc8b7f7..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/protocol/LinkMessageDecoderUdp.java +++ /dev/null @@ -1,322 +0,0 @@ -package com.hdl.sdk.link.core.protocol; - - -import com.hdl.sdk.link.common.event.EventDispatcher; -import com.hdl.sdk.link.common.utils.ByteUtils; -import com.hdl.sdk.link.common.utils.LogUtils; -import com.hdl.sdk.link.core.bean.LinkPacket; -import com.hdl.sdk.link.core.bean.LinkResponse; -import com.hdl.sdk.link.core.utils.ByteBufferUtils; -import com.hdl.sdk.link.core.utils.QueueUtils; -import com.hdl.sdk.link.socket.bean.Packet; -import com.hdl.sdk.link.socket.codec.ByteToMessageDecoder; - -import java.nio.ByteBuffer; - -/** - * Created by Tong on 2021/9/22. - * link鍗忚绮樺寘鎷嗗寘 - */ -public class LinkMessageDecoderUdp extends ByteToMessageDecoder<LinkResponse> { - - private static final String TAG= LinkMessageDecoderUdp.class.getName(); - //instance - private volatile static LinkMessageDecoderUdp instance; - - //getInstance - public static synchronized LinkMessageDecoderUdp getInstance() { - if (instance == null) { - synchronized (LinkMessageDecoderUdp.class) { - if (instance == null) { - instance = new LinkMessageDecoderUdp(); - } - } - } - return instance; - } - - /** - * 鎺ユ敹鏁版嵁缂撳啿鍖� - */ - private final ByteBuffer byteBuffer; - - private final byte[] head = "Topic:".getBytes(); - - public LinkMessageDecoderUdp() { - byteBuffer = ByteBuffer.allocate(1024 * 200);//100K - } - - /// <summary> - /// 鑾峰彇鍐呭闀垮害 - /// </summary> - /// <param name="topMsgs"></param> - /// <returns></returns> - int getLenght(String[] topMsgs) { - try { - for (int i = 0; i < topMsgs.length; i++) { - String topMsg = topMsgs[i].trim(); - if (topMsg.startsWith("Length:")) { - return Integer.parseInt(topMsg.replace("Length:", "").trim()); - } - } - } catch (Exception e) { - LogUtils.e("寮傚父鏁版嵁锛�" + topMsgs[0] + "\r\n" + topMsgs[1]); - return -1; - } - //鎵句笉鍒伴暱搴� - return -1; - } - - /// <summary> - /// 鑾峰彇涓婚 - /// </summary> - /// <param name="topMsgs"></param> - /// <returns></returns> - private String getTopic(String[] topMsgs) { - for (int i = 0; i < topMsgs.length; i++) { - String topMsg = topMsgs[i].trim(); - if (topMsg.startsWith("Topic:")) { - return topMsg.replace("Topic:", ""); - } - } - //鎵句笉鍒颁富棰� - return null; - } - - /** - * 鑾峰彇鏁版嵁鐨勫紑濮嬩綅缃� - * - * @return 鏁版嵁浣嶇殑寮�濮嬬储寮� - */ - int getBodyIndex() { - byte r = (byte) '\r'; - byte n = (byte) '\n'; - for (int i = 0; i < byteBuffer.position(); i++) { - //鎵惧嚭鏁版嵁鍐呭鍓嶉潰鐨勪袱涓崲琛� - if (3 <= i && byteBuffer.get(i - 3) == r && byteBuffer.get(i - 2) == n && byteBuffer.get(i - 1) == r && byteBuffer.get(i) == n) { - //鍓╀綑鐨勬暟鎹� - return i + 1; - } - } - return -1; - } - - /** - * 鑾峰彇澶撮儴鏁版嵁 - * - * @return - */ - String getHeader() { - int bodyIndex = getBodyIndex(); - if (bodyIndex < 0) { - //娌℃湁鎵惧埌澶撮儴鏁版嵁 - return null; - } else { - byte bodyBytes[] = ByteBufferUtils.copyBytes(byteBuffer, bodyIndex); - return new String(bodyBytes); - } - } - - /** - * 鑾峰彇鏁版嵁鍐呭 - * - * @param lenght - * @return - */ - byte[] getBody(int index, int lenght) { - //鏄惁宸茬粡鑾峰彇瀹屾暣鎵�鏈夌殑鏁版嵁 - byte[] bodyBytes = new byte[lenght]; - if (index < 0 || byteBuffer.position() < index + lenght) { - //褰撳墠鏁版嵁杩樻病鏈夋帴鏀跺畬鎴� - return null; - } - - for (int i = 0; i < bodyBytes.length; i++) { - bodyBytes[i] = byteBuffer.get(index + i); - } - return bodyBytes; - } - - - /** - * 杩欒竟澶勭悊浜嗙紦瀛樻暟鎹矘鍖呯殑鎯呭喌锛屾瘡娆¤姹傞兘闇�瑕佸惂褰撳墠瀹屾暣鐨勬枃浠堕櫎鍘� 浠ヤ究浜庝笅娆$殑杩斿洖 - * tempList鐢ㄤ簬瀛樺偍澶氫綑鐨勬暟鎹� - * contentList鐢ㄤ簬鏈鏁版嵁鐨勫瓨鍌紙鍙戦�佺粰璁㈤槄鐨勬暟鎹級 - */ - byte[] geBody() { - int len = 3 + 4 + 4 + ((byteBuffer.get(7) & 0xFF) * 256 * 256 * 256) + ((byteBuffer.get(8) & 0xFF) * 256 * 256) + ((byteBuffer.get(9) * 256) & 0xFF) + (byteBuffer.get(10) & 0xFf); - byte[] bodyBytes = new byte[len]; - for (int i = 0; i < len; i++) { - bodyBytes[i] = byteBuffer.get(i); - } - - int endIndex = byteBuffer.position(); - byteBuffer.clear(); - for (int i = len; i < endIndex; i++) { - byteBuffer.put(byteBuffer.get(i)); - } - return bodyBytes; - } - - /** - * 绉婚櫎鍙兘瀛樺湪鐨勬棤鏁堟暟鎹� - */ - void removeInVoidBytes() { - int index = 0; - boolean isMatch = false; - for (; index < byteBuffer.position() - head.length; index++) { - isMatch = true; - for (int j = 0, k = 0; j < head.length; j++, k++) { - if (head[j] != byteBuffer.get(index + k)) { - isMatch = false; - break; - } - } - if (isMatch) { - break; - } - } - - if (0 < index && isMatch) { - int endIndex = byteBuffer.position(); - byteBuffer.clear(); - for (int i = index; i < endIndex; i++) { - byteBuffer.put(byteBuffer.get(i)); - } - } - } - - /** - * 绉婚櫎鍒版寚瀹氫綅缃墠闈㈢殑鏁版嵁 - * - * @param position 鎸囧畾浣嶇疆 - */ - void remove(int position) { - int endIndex = byteBuffer.position(); - byteBuffer.clear(); - for (int i = position; i < endIndex; i++) { - byteBuffer.put(byteBuffer.get(i)); - } - } - - void fileManger(int commandAck, byte[] recevieBytes) { - String topic = "65531_" + commandAck; - LinkResponse response = new LinkResponse(); - response.setTopic(topic); - response.setByteData(recevieBytes); - EventDispatcher.getInstance().post(response.getTopic(), response); - } - - int bytes2int(byte[] bytes) { - int result = 0; - if (bytes.length == 2) { - int c = (bytes[0] & 0xff) << 8; - int d = (bytes[1] & 0xff); - result = c | d; - } else if (bytes.length == 4) { - return bytes[3] & 0xFF | // - (bytes[2] & 0xFF) << 8 | // - (bytes[1] & 0xFF) << 16 | // - (bytes[0] & 0xFF) << 24; // - } - return result; - } - - public String byte2hex(byte[] bytes) { - StringBuilder sb = new StringBuilder(); - String tmp = null; - for (byte b : bytes) { - //灏嗘瘡涓瓧鑺備笌0xFF杩涜涓庤繍绠楋紝鐒跺悗杞寲涓�10杩涘埗锛岀劧鍚庡�熷姪浜嶪nteger鍐嶈浆鍖栦负16杩涘埗 - tmp = Integer.toHexString(0xFF & b); - if (tmp.length() == 1) { - tmp = "0" + tmp; - } - sb.append(tmp + " "); - } - return sb.toString(); - } - - @Override - protected final LinkResponse decoder(Packet packet) { - try { - if (null == packet) { - return null; - } - byteBuffer.put(packet.getBytes()); - } catch (Exception e) { - LogUtils.e("鎺ユ敹鍒版暟鎹紓甯�:\r\n" + e.getMessage()); - byteBuffer.flip(); - byteBuffer.clear(); - } - try { - //濡傛灉澶氭潯鍛戒护鎵撳寘鍦ㄤ竴鏉℃暟鎹腑锛岄兘闇�瑕佸鐞嗗畬 - while (true) { - if (byteBuffer.position() > 2) {//鍒ゆ柇鏄惁鏄枃浠跺鐞嗛�氱煡 wxr - byte[] topBytes = new byte[3]; - topBytes[0] = byteBuffer.get(0); - topBytes[1] = byteBuffer.get(1); - topBytes[2] = byteBuffer.get(2); - if (new String(topBytes).equals("hex")) { - //TODO 杩欏潡浠g爜缁熶竴绉诲嚭鍏跺畠鍦版柟澶勭悊 - byte[] commandBytes = ByteBufferUtils.copyBytes(byteBuffer, 5, 2); - int command = bytes2int(commandBytes); - byte[] submitBytes = geBody(); - if (command == 258 || command == 260 || command == 261) { - //璇诲彇椹卞姩鍒楄〃鍝嶅簲 ||椹卞姩瀹夎鐢宠鍝嶅簲 - if (submitBytes.length > 11) { - byte[] rangeBytes = ByteUtils.copyBytes(submitBytes, 11, submitBytes.length - 11); - fileManger(command, rangeBytes); - } else { - //鏂逛究闂鎺掓煡 - fileManger(command, submitBytes); - } - } else { - //缁欑妗′娇鐢� 鍚庨潰鐨勪笟鍔℃渶濂介兘鍦ㄨ繖杈瑰鐞� 涓嶇劧浼氶�犳垚涓氬姟鍒嗘暎 - fileManger(command, submitBytes); - } - continue; - } - } - removeInVoidBytes();//绉婚櫎鍙兘瀛樺湪鐨勬棤鏁堟暟鎹� - - //澶撮儴鏁版嵁 - String header = getHeader(); - - if (header == null) { - break; - } - String[] topMsgs = header.split("\r\n"); - - String topic = getTopic(topMsgs); - int lenght = getLenght(topMsgs); - if (topic == null || lenght <= 0) { - //鑾峰彇涓嶅埌涓婚鎴栬�呭ご閮ㄦ暟鎹繕娌℃湁鎺ユ敹瀹屾垚 - break; - } - - int bodyIndex = getBodyIndex(); - //鏄惁宸茬粡鑾峰彇瀹屾暣鎵�鏈夌殑鏁版嵁 - byte[] body = getBody(bodyIndex, lenght); - - if (body == null) { - //褰撳墠鏁版嵁杩樻病鏈夋帴鏀跺畬鎴� - break; - } - - remove(bodyIndex + lenght); - - if (topic.contains("heartbeat_reply")) { - if (packet.getSocket() != null) { - packet.getSocket().setSoTimeout(10 * 1000); - } - continue; - } - - QueueUtils.getInstance().add(new LinkPacket(topic, body)); - } - } catch (Exception ee) { - LogUtils.e("澶勭悊鎺ユ敹鐨勬暟鎹紓甯�:\r\n" + ee.getMessage()); - } - return null; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/protocol/LinkMessageEncoder.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/protocol/LinkMessageEncoder.java deleted file mode 100644 index d09e37a..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/protocol/LinkMessageEncoder.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.hdl.sdk.link.core.protocol; - - -import com.hdl.sdk.link.socket.bean.Packet; -import com.hdl.sdk.link.socket.codec.MessageToByteEncoder; - -/** - * Created by Tong on 2021/9/22. - * link鍗忚鍚堝寘 - */ -public class LinkMessageEncoder extends MessageToByteEncoder { - - @Override - protected Packet encode(Packet packet) throws Exception { - return packet; - } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/AesUtil.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/AesUtil.java deleted file mode 100644 index 942e76e..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/AesUtil.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.hdl.sdk.link.core.utils; - - -import android.text.TextUtils; - -import com.hdl.sdk.link.common.utils.LogUtils; - -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; - -/** - * Aes 鍔犺В瀵嗗伐鍏风被 - * - * @author yangtao - * 2020骞�10鏈�29鏃� - */ -public class AesUtil { - - private static final String CIPHER_INSTANCE = "AES/CBC/PKCS7Padding"; - private static final String AES_ALGORITHM = "AES"; - -// static { -// //AES/CBC/PKCS7Padding 渚濊禆 -// Security.addProvider(new BouncyCastleProvider()); -// } - - /** - * AES鍔犲瘑 - * - * @param key - * @return - * @throws Exception - */ - public static byte[] aesEncrypt(byte[] content, String key) { - return encrypt(content, key.getBytes(), CIPHER_INSTANCE, true, null); - } - - /** - * AES瑙e瘑 - * - * @param key - * @return - * @throws Exception - */ - public static byte[] aesDecrypt(byte[] content, String key) { - if (content == null || TextUtils.isEmpty(key)) { - LogUtils.i("鏁版嵁瑙e瘑锛�","content锛�"+content+" key:"+key); - return null; - } - return decrypt(content, key.getBytes(), CIPHER_INSTANCE, true, null); - } - - - /** - * 鍔犲瘑 - * - * @param content 寰呭姞瀵嗗瓧绗︿覆 - * @param keyByte aesKye鐨刪exStr - * @param cipherInstance AES绠楁硶濉厖鏂瑰紡 - * @param isIv 鏄惁浣跨敤鍋忕Щ閲� ECB妯″紡涓嶅彲鐢� - * @param iv 鍋忕Щ閲� 涓嶄紶榛樿瀵嗛挜 - * @return - */ - public static byte[] encrypt(byte[] content, byte[] keyByte, String cipherInstance, Boolean isIv, byte[] iv) { - try { - //KEY杞崲 - Key key = new SecretKeySpec(keyByte, AES_ALGORITHM); - //鍔犲瘑 - Cipher cipher = Cipher.getInstance(cipherInstance); - if (isIv != null && isIv) { - //鍋忕Щ閲� 涓嶄紶榛樿瀵嗛挜 - if (iv == null) { - iv = keyByte; - } - IvParameterSpec ivps = new IvParameterSpec(iv); - cipher.init(Cipher.ENCRYPT_MODE, key, ivps); - } else { - cipher.init(Cipher.ENCRYPT_MODE, key); - } - byte[] result = cipher.doFinal(content); - return result; - } catch (NoSuchAlgorithmException e) { - LogUtils.e(e.getMessage()); - } catch (InvalidKeyException e) { - LogUtils.e(e.getMessage()); - } catch (NoSuchPaddingException e) { - LogUtils.e(e.getMessage()); - } catch (BadPaddingException e) { - LogUtils.e(e.getMessage()); - } catch (IllegalBlockSizeException e) { - LogUtils.e(e.getMessage()); - } catch (InvalidAlgorithmParameterException e) { - LogUtils.e(e.getMessage()); - } - return null; - } - - /** - * 瑙e瘑 - * - * @param contentByte 寰呰В瀵嗗緟瀛楃涓瞙exStr - * @param contentByte 瀵嗛挜 - * @param cipherInstance AES绠楁硶濉厖鏂瑰紡 - * @param isIv 鏄惁浣跨敤鍋忕Щ閲� ECB妯″紡涓嶅彲鐢� - * @param iv 鍋忕Щ閲� 涓嶄紶榛樿瀵嗛挜 - * @return - */ - public static byte[] decrypt(byte[] contentByte, byte[] keyByte, String cipherInstance, Boolean isIv, byte[] iv) { - try { - //KEY杞崲 - Key key = new SecretKeySpec(keyByte, AES_ALGORITHM); - //瑙e瘑 - Cipher cipher = Cipher.getInstance(cipherInstance); - if (isIv != null && isIv) { - //鍋忕Щ閲� 涓嶄紶榛樿瀵嗛挜 - if (iv == null) { - iv = keyByte; - } - IvParameterSpec ivps = new IvParameterSpec(iv); - cipher.init(Cipher.DECRYPT_MODE, key, ivps); - } else { - cipher.init(Cipher.DECRYPT_MODE, key); - } - byte[] result = cipher.doFinal(contentByte); - return result; - } catch (NoSuchAlgorithmException e) { - LogUtils.e(e.getMessage()); - } catch (InvalidKeyException e) { - LogUtils.e(e.getMessage()); - } catch (NoSuchPaddingException e) { - LogUtils.e(e.getMessage()); - } catch (BadPaddingException e) { - LogUtils.e(e.getMessage()); - } catch (IllegalBlockSizeException e) { - LogUtils.e(e.getMessage()); - } catch (InvalidAlgorithmParameterException e) { - LogUtils.e(e.getMessage()); - } - return null; - } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/ByteBufferUtils.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/ByteBufferUtils.java deleted file mode 100644 index 99e1e5d..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/ByteBufferUtils.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.hdl.sdk.link.core.utils; - -import java.nio.ByteBuffer; - -/** - * Created by hxb on 2022/8/3. - * - */ -public class ByteBufferUtils { - - /** - * 鑾峰彇ByteBuffer鎸囧畾浣嶇疆鏁版嵁 - * - * @param byteBuffer 婧愬璞� - * @param length 鎸囧畾闀垮害 - * @return 鏍规嵁闀垮害鐢熸垚鐨勬暟缁� - */ - public static byte[] copyBytes(ByteBuffer byteBuffer, int length) { - return copyBytes(byteBuffer,0,length); - } - - /** - * 澶嶅埗鎸囧畾浣嶇疆鐨勬暟鎹� - * @param byteBuffer - * @param index - * @param length - * @return - */ - public static byte[] copyBytes(ByteBuffer byteBuffer, int index,int length) { - byte[] bytes = new byte[length]; - for (int i = 0; i < bytes.length; i++) { - bytes[i] = byteBuffer.get(index + i); - } - return bytes; - } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/ByteUtils.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/ByteUtils.java deleted file mode 100644 index a2e095e..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/ByteUtils.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hdl.sdk.link.core.utils; - -/** - * Created by hxb on 2022/8/5. - */ -public class ByteUtils { - - public static String encodeHexString(byte[] data) { - - StringBuilder sb = new StringBuilder(); - - for (byte b : data) { - - sb.append(String.format("%02x ", b)); - - } - return sb.toString(); - - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/EncryptUtil.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/EncryptUtil.java deleted file mode 100644 index b12a06e..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/EncryptUtil.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.hdl.sdk.link.core.utils; - -import android.text.TextUtils; - -import com.hdl.sdk.link.common.config.TopicConstant; -import com.hdl.sdk.link.common.utils.ByteUtils; - -import com.hdl.sdk.link.common.utils.LogUtils; -import com.hdl.sdk.link.core.bean.LinkRequest; -import com.hdl.sdk.link.core.config.HDLLinkConfig; - -import java.io.UnsupportedEncodingException; - -/** - * Created by hxb on 2021/12/23. - */ -public class EncryptUtil { - /** - * 鑾峰彇鍔犲瘑鏁版嵁 - * - * @param linkRequest 璇锋眰鏁版嵁 - * @return - */ - public static byte[] getEncryBytes(LinkRequest linkRequest) throws UnsupportedEncodingException { - //鍒ゆ柇鏄惁闇�瑕佸姞瀵� - if (ifNeedEncrypt(linkRequest.getTopic(), linkRequest.isEncrypt())) { - //闇�瑕佸姞瀵� - byte[] dataBytes = AesUtil.aesEncrypt(linkRequest.getData(), HDLLinkConfig.getInstance().getLocalSecret()); - String headString = "Topic:" + linkRequest.getTopic() + "\r\n" + "Length:" + dataBytes.length + "\r\n" + "\r\n"; - byte[] headBytes = headString.getBytes("utf-8"); - byte[] sendBytes = ByteUtils.concatBytes(headBytes, dataBytes); - return sendBytes; - } else { - return linkRequest.getSendBytes(); - } - } - - /** - * 鍔犲瘑鏁版嵁 - * - * param bytes 闇�瑕佸姞瀵嗘暟鎹� - * @param secret 鍔犲瘑瀵嗛挜 - * @return - */ - public static byte[] encryBytes(byte []bytes,String secret) { - if(bytes==null|| TextUtils.isEmpty(secret)){ - LogUtils.i("浼犲叆鏁版嵁鍐呭涓虹┖鎴栬�呭瘑閽ヤ负绌�"); - return null; - } - return AesUtil.aesEncrypt(bytes, secret); - } - - /** - * 鍒ゆ柇褰撳墠涓婚鏁版嵁鏄惁闇�瑕佸姞瀵� - * - * @param topicStr 褰撳墠涓婚 - * @return - */ - public static boolean ifNeedEncrypt(String topicStr, boolean isLocalEncrypt) { - //杩囨护鐩稿叧闇�瑕佸姞瀵嗙殑涓婚 - return (!topicStr.contains(TopicConstant.GATEWAY_AUTH_BROADCAST) //缃戝叧骞挎挱鍏ョ綉鎸囦护 - && !topicStr.contains(TopicConstant.DEIVCE_AUTH_REQUEST) //鍏ョ綉璁よ瘉 - && !topicStr.contains(TopicConstant.GATEWAY_SEARCH) //鎼滅储缃戝叧涓婚 - && !topicStr.contains(TopicConstant.GATEWAY_SEARCH_REPLY) //鎼滅储缃戝叧涓婚鍥炲 - && !topicStr.equals(TopicConstant.BROADCAST) - && isLocalEncrypt//鍚敤鍔犲瘑鏍囧織 - ); - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/HexUtil.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/HexUtil.java deleted file mode 100644 index 41373e0..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/HexUtil.java +++ /dev/null @@ -1,449 +0,0 @@ -package com.hdl.sdk.link.core.utils; - -import android.util.Log; - -import java.math.BigDecimal; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Date; - -/** - * Created by Zoro - * Created on 2021/9/17 - * description: - */ -public class HexUtil { - private static final char[] DIGITS_LOWER = {'0', '1', '2', '3', '4', '5', - '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - - private static final char[] DIGITS_UPPER = {'0', '1', '2', '3', '4', '5', - '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; - - public static char[] encodeHex(byte[] data) { - return encodeHex(data, true); - } - - public static char[] encodeHex(byte[] data, boolean toLowerCase) { - return encodeHex(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER); - } - - protected static char[] encodeHex(byte[] data, char[] toDigits) { - if (data == null) - return null; - int l = data.length; - char[] out = new char[l << 1]; - for (int i = 0, j = 0; i < l; i++) { - out[j++] = toDigits[(0xF0 & data[i]) >>> 4]; - out[j++] = toDigits[0x0F & data[i]]; - } - return out; - } - - - public static String encodeHexStr(byte[] data) { - return encodeHexStr(data, true); - } - - public static String encodeHexStr(byte[] data, boolean toLowerCase) { - return encodeHexStr(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER); - } - - - protected static String encodeHexStr(byte[] data, char[] toDigits) { - return new String(encodeHex(data, toDigits)); - } - - public static String formatHexString(byte[] data) { - return formatHexString(data, false); - } - - public static String formatHexString(byte[] data, boolean addSpace) { - if (data == null || data.length < 1) - return null; - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < data.length; i++) { - String hex = Integer.toHexString(data[i] & 0xFF); - if (hex.length() == 1) { - hex = '0' + hex; - } - sb.append(hex); - if (addSpace) - sb.append(" "); - } - return sb.toString().trim(); - } - - public static byte[] decodeHex(char[] data) { - - int len = data.length; - - if ((len & 0x01) != 0) { - throw new RuntimeException("Odd number of characters."); - } - - byte[] out = new byte[len >> 1]; - - // two characters form the hex value. - for (int i = 0, j = 0; j < len; i++) { - int f = toDigit(data[j], j) << 4; - j++; - f = f | toDigit(data[j], j); - j++; - out[i] = (byte) (f & 0xFF); - } - - return out; - } - - /** - * 灏嗗崄鍏繘鍒跺瓧绗︿覆瑙g爜涓篵yte[] - * - * @param hexStr 鍗佸叚杩涘埗String - * @return byte[] - */ - public static byte[] decodeHex(String hexStr) { - if ("".equals(hexStr)) { - return null; - } - hexStr = hexStr.replace(" ",""); - return decodeHex(hexStr.toCharArray()); - } - - public static byte[] addAll(byte[]... arrays) { - if (arrays.length == 1) { - return arrays[0]; - } - - // 璁$畻鎬婚暱搴� - int length = 0; - for (byte[] array : arrays) { - if (null != array) { - length += array.length; - } - } - - final byte[] result = new byte[length]; - length = 0; - for (byte[] array : arrays) { - if (null != array) { - System.arraycopy(array, 0, result, length, array.length); - length += array.length; - } - } - return result; - } - - - - protected static int toDigit(char ch, int index) { - int digit = Character.digit(ch, 16); - if (digit == -1) { - throw new RuntimeException("Illegal hexadecimal character " + ch - + " at index " + index); - } - return digit; - } - - - public static byte[] hexStringToBytes(String hexString) { - if (hexString == null || hexString.equals("")) { - return null; - } - hexString = hexString.toUpperCase(); - int length = hexString.length() / 2; - char[] hexChars = hexString.toCharArray(); - byte[] d = new byte[length]; - for (int i = 0; i < length; i++) { - int pos = i * 2; - d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1])); - } - return d; - } - - public static byte charToByte(char c) { - return (byte) "0123456789ABCDEF".indexOf(c); - } - - public static String extractData(byte[] data, int position) { - return HexUtil.formatHexString(new byte[]{data[position]}); - } - - public static String bytesToHexString(byte[] data) { - String result = ""; - for (int i = 0; i < data.length; i++) { - String hexString = Integer.toHexString(data[i] & 0xFF); - if (hexString.length() == 1) { - hexString = '0' + hexString; - } - result += hexString.toUpperCase(); - } - return result; - } - - /** - * byte杞�16杩涘埗 - * - * @param b - * @return - */ - public static String binaryToHex(byte b) { - String str = byteToBit(b); - String hexStr = Integer.toHexString(Integer.parseInt(str, 2)); - StringBuffer stringBuffer = new StringBuffer(); - if (hexStr.length() == 1) { - stringBuffer.append("0"); - } - stringBuffer.append(hexStr); - return stringBuffer.toString().toUpperCase(); - } - - /** - * byte杞崄杩涘埗 - * - * @param b - * @return - */ - public static int binaryToDecimal(byte b) { - String str = byteToBit(b); - return Integer.parseInt(str, 2); - } - - /** - * Byte杞珺it - */ - public static String byteToBit(byte b) { - return "" + (byte) ((b >> 7) & 0x1) + (byte) ((b >> 6) & 0x1) - + (byte) ((b >> 5) & 0x1) + (byte) ((b >> 4) & 0x1) - + (byte) ((b >> 3) & 0x1) + (byte) ((b >> 2) & 0x1) - + (byte) ((b >> 1) & 0x1) + (byte) ((b >> 0) & 0x1); - } - - /** - * int杞琤yte - * - * @param res - * @return - */ - public static byte[] int2byte(int res) { - byte[] targets = new byte[2]; - - targets[1] = (byte) (res & 0xff);// 鏈�浣庝綅 - targets[0] = (byte) ((res >> 8) & 0xff);// 娆′綆浣� - /*targets[2] = (byte) ((res >> 16) & 0xff);// 娆¢珮浣� - targets[3] = (byte) (res >>> 24);// 鏈�楂樹綅,鏃犵鍙峰彸绉�*/ - return targets; - } - - /** - * Bit杞珺yte - */ - public static byte bitToByte(String byteStr) { - int re, len; - if (null == byteStr) { - return 0; - } - len = byteStr.length(); - if (len != 4 && len != 8) { - return 0; - } - if (len == 8) {// 8 bit澶勭悊 - if (byteStr.charAt(0) == '0') {// 姝f暟 - re = Integer.parseInt(byteStr, 2); - } else {// 璐熸暟 - re = Integer.parseInt(byteStr, 2) - 256; - } - } else {// 4 bit澶勭悊 - re = Integer.parseInt(byteStr, 2); - } - return (byte) re; - } - - /** - * 瑙f瀽浣撹剛鏁版嵁 - * - * @param first - * @param second - * @param b - * @return - */ - public static double getData(int first, int second, byte[] b) { - double data = ((b[first] & 0xFF) << 8) + (b[second] & 0xFF); - Log.e("", "data = " + data); - return data / 10; - } - - /** - * 瑙f瀽浣撹剛鏁版嵁 - * - * @param first - * @param second - * @param b - * @return - */ - public static int getDataInt(int first, int second, byte[] b) { - int data = ((b[first] & 0xFF) << 8) + (b[second] & 0xFF); - Log.e("", "getDataInt = " + data); - return data; - } - - - // 鑾峰彇绯荤粺鏃堕棿 - public static String getTime() { - SimpleDateFormat formatter = new SimpleDateFormat("HHmmss"); - Date curDate = new Date(System.currentTimeMillis()); - String str = formatter.format(curDate); - return str; - } - - // 鑾峰彇绯荤粺鏃ユ湡 - public static String getDate() { - SimpleDateFormat formatter = new SimpleDateFormat("yyMMdd"); - Date curDate = new Date(System.currentTimeMillis()); - String str = formatter.format(curDate); - return str; - } - - /** - * 鑾峰彇褰撳墠绯荤粺鏃堕棿 - * - * @return - */ - public static String getCurrentTime() { - SimpleDateFormat formatter = new SimpleDateFormat("yy-MM-dd HH:mm:ss"); - Date curDate = new Date(System.currentTimeMillis()); - String str = formatter.format(curDate); - return str; - } - - /** - * 鍚堝苟鏁扮粍 - * - * @return - */ - public static byte[] concat(byte[] b, byte[] mByte) { - byte[] result = Arrays.copyOf(b, b.length + mByte.length); - System.arraycopy(mByte, 0, result, b.length, mByte.length); - return result; - } - - /** - * 瀛楃涓查暱搴︾瓑浜�1鐨勮瘽锛岃ˉ0 - * - * @param str - * @return - */ - public static String addZero(String str) { - //L.i(ParseData.class, "addZero"); - StringBuffer sBuffer = new StringBuffer(); - if (str.length() == 1) { - sBuffer.append("0"); - sBuffer.append(str); - return sBuffer.toString(); - } else { - return str; - } - } - - public static double getPercent(double d) { - if (d > 100) { - return 0.0; - } - return d; - } - - /** - * byte鏁扮粍杞瑂tr - * - * @param b - * @return - */ - public static String byteArr2Str(byte[] b) { - if (b.length != 0) { - StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append("["); - for (int i = 0; i < b.length; i++) { - stringBuffer.append(addZero(binaryToHex(b[i]))); - if (i < b.length - 1) { - stringBuffer.append(","); - } - } - stringBuffer.append("]"); - return stringBuffer.toString(); - } - return null; - } - - /** - * 淇濈暀灏忔暟鐐瑰悗count浣� - * - * @param d - * @param count - * @return - */ - public static double keepDecimal(double d, int count) { - BigDecimal decimal = new BigDecimal(d); - return decimal.setScale(count, BigDecimal.ROUND_HALF_UP).doubleValue(); - } - - /** - * kg杞琹b - * - * @param weight - * @return - */ - public static double kg2lb(double weight) { - return keepDecimal(weight * 2.2046226, 1); - } - - /** - * kg杞琷in - * - * @param weight - * @return - */ - public static double kg2jin(double weight) { - return keepDecimal(weight * 2, 1); - } - - /** - * kg杞瑂t - * - * @param weight - * @return - */ - public static String kg2st(double weight) { - double lbData = kg2lb(weight); - StringBuffer stringBuffer = new StringBuffer(); - int lb = (int) (lbData / 14); - int st = (int) lbData % 14; - stringBuffer.append(lb); - stringBuffer.append(":"); - stringBuffer.append(addZero(String.valueOf(st))); - return stringBuffer.toString(); - } - - public static String int2HexStr(int i) { - return binaryToHex(Integer.valueOf(i).byteValue()); - } - - public static byte[] hexStringToByte(String hex) { - int len = (hex.length() / 2); - byte[] result = new byte[len]; - char[] chars = hex.toCharArray(); - for (int i = 0; i < len; i++) { - int pos = i * 2; - result[i] = (byte) (toByte(chars[pos]) << 4 | toByte(chars[pos + 1])); - } - return result; - } - - private static byte toByte(char c) { - byte b = (byte) "0123456789ABCDEF".indexOf(c); - return b; - } - - public static String formatTo1(double f) { - BigDecimal bg = new BigDecimal(f); - return bg.setScale(1, BigDecimal.ROUND_HALF_UP).toString(); - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/LanguageUtils.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/LanguageUtils.java deleted file mode 100644 index 70ba132..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/LanguageUtils.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.hdl.sdk.link.core.utils; - -/** - * Created by hxb on 2023/2/9. - */ -public class LanguageUtils { -// public static String -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/LinkResponseUtils.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/LinkResponseUtils.java deleted file mode 100644 index 57ca709..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/LinkResponseUtils.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.hdl.sdk.link.core.utils; - -import android.text.TextUtils; - -import com.google.gson.reflect.TypeToken; -import com.hdl.sdk.link.common.utils.LogUtils; -import com.hdl.sdk.link.common.utils.gson.GsonConvert; - -import com.hdl.sdk.link.core.bean.LinkResponse; -import com.hdl.sdk.link.core.bean.response.BaseLocalResponse; -import com.hdl.sdk.link.core.bean.response.BaseLocalWithCodeResponse; - -import java.lang.reflect.Type; - -/** - * Created by jlchen on 1/6/22. - */ -public class LinkResponseUtils<T> { - - public Type getType(){ - return new TypeToken<BaseLocalResponse<T>>() {}.getType(); - } - - /** - * 杞崲鎻愬彇LinkResponse閲岄潰鐨刼bjects - * - * @param msg - * @return - */ - public static <T> T convertLinkResponse(Object msg, Type type) { - T bean = null; - if (msg != null && msg instanceof LinkResponse) { - LinkResponse linkResponse = (LinkResponse) msg; - String data = linkResponse.getData(); - if (!TextUtils.isEmpty(data)) { - try { - final BaseLocalResponse<T> response = GsonConvert.getGson().fromJson(data, type); - if (response != null) { - bean = response.getObjects(); - } - } catch (Exception e) { - LogUtils.e("convertLinkResponse catch:" + e.getMessage()); - } - } - } - return bean; - } - - /** - * 杞崲鎻愬彇LinkResponse閲岄潰鐨刼bjects 鍙湁杩斿洖code 鍒ゆ柇200鏄垚鍔� - * - * @param msg - * @return - */ - public static <T> T convertLinkWithCodeResponse(Object msg, Type type) { - T bean = null; - if (msg != null && msg instanceof LinkResponse) { - LinkResponse linkResponse = (LinkResponse) msg; - String data = linkResponse.getData(); - if (!TextUtils.isEmpty(data)) { - try { - final BaseLocalWithCodeResponse<T> response = GsonConvert.getGson().fromJson(data, type); - if (response != null) { - bean = response.getCode(); - } - } catch (Exception e) { - LogUtils.e("convertLinkResponse catch:" + e.getMessage()); - } - } - } - return bean; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/ProtocolParse.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/ProtocolParse.java deleted file mode 100644 index 92a611b..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/ProtocolParse.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.hdl.sdk.link.core.utils; - -import android.text.TextUtils; - -/** - * Created by Tong on 2021/9/22. - * 瑙f瀽Link鍗忚 - */ -public class ProtocolParse { - - private String topic; - private int length; - private int dataIndex; - - public ProtocolParse(byte[] bytes) { - parse(bytes); - } - - private void parse(byte[] bytes) { - try { - String[] split = new String(bytes, "utf-8").split("\r\n"); - setTopic(parseTopic(split)); - setLength(parseLength(split)); - } catch (Exception e) { - e.printStackTrace(); - } - } - - private static String parseTopic(String[] bytes) { - try { - for (String s : bytes) { - if (s.startsWith("Topic:")) { - return s.replace("Topic:", ""); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - private static int parseLength(String[] bytes) { - try { - for (String s : bytes) { - if (!TextUtils.isEmpty(s) && s.startsWith("Length:")) { - return Integer.parseInt(s.replace("Length:", "")); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - return -1; - } - - - - public String getTopic() { - return topic; - } - - public void setTopic(String topic) { - this.topic = topic; - } - - public int getLength() { - return length; - } - - public void setLength(int length) { - this.length = length; - } - - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/mqtt/AesUtil.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/mqtt/AesUtil.java deleted file mode 100644 index 01fbe3f..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/mqtt/AesUtil.java +++ /dev/null @@ -1,286 +0,0 @@ -package com.hdl.sdk.link.core.utils.mqtt; - - - -import com.hdl.sdk.link.common.utils.LogUtils; -import com.hdl.sdk.link.core.utils.HexUtil; - -import org.bouncycastle.jce.provider.BouncyCastleProvider; - -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.Security; - -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; - - -/** - * Aes 鍔犺В瀵嗗伐鍏风被 - * - * @author yangtao - * 2020骞�10鏈�29鏃� - */ -public class AesUtil { - - private static final String CIPHER_INSTANCE = "AES/ECB/PKCS5Padding"; - private static final String AES_ALGORITHM = "AES"; - - static { - //AES/CBC/PKCS7Padding 渚濊禆 - Security.addProvider(new BouncyCastleProvider()); - } - - /** - * AES鍔犲瘑 - * - * @param key - * @return - * @throws Exception - */ - public static byte[] aesEncrypt(byte[] content, String key) { - return encrypt(content, key.getBytes(), "AES/CBC/PKCS7Padding", true, null); - } - - /** - * AES瑙e瘑 - * - * @param key - * @return - * @throws Exception - */ - public static byte[] aesDecrypt(byte[] content, String key) { - return decrypt(content, key.getBytes(), "AES/CBC/PKCS7Padding", true, null); - } - - /** - * 鍔犲瘑 - * - * @param content 寰呭姞瀵嗗瓧绗︿覆 - * @param keyHex aesKye鐨刪exStr - * @return - */ - public static String encrypt(String content, String keyHex) { - return HexUtil.encodeHexStr(encrypt(content.getBytes(), HexUtil.decodeHex(keyHex), CIPHER_INSTANCE, false, null)); - } - - /** - * 鍔犲瘑 - * - * @param content 寰呭姞瀵嗗瓧绗︿覆 - * @param key 瀵嗛挜 - * @return - */ - public static String encrypt(String content, byte[] key) { - return HexUtil.encodeHexStr(encrypt(content.getBytes(), key, CIPHER_INSTANCE, false, null)); - } - - /** - * 鍔犲瘑 - * - * @param content 寰呭姞瀵嗗瓧绗︿覆 - * @param keyHex aesKye鐨刪exStr - * @return - */ - public static byte[] encryptReturnByte(String content, String keyHex) { - return encrypt(content.getBytes(), HexUtil.decodeHex(keyHex), CIPHER_INSTANCE, false, null); - } - - /** - * 鍔犲瘑 - * - * @param content 寰呭姞瀵嗗瓧绗︿覆 - * @param key 瀵嗛挜 - * @return - */ - public static byte[] encryptReturnByte(String content, byte[] key) { - return encrypt(content.getBytes(), key, CIPHER_INSTANCE, false, null); - } - - /** - * 鍔犲瘑 - * - * @param content 寰呭姞瀵嗗瓧绗︿覆 - * @param keyByte aesKye鐨刪exStr - * @param cipherInstance AES绠楁硶濉厖鏂瑰紡 - * @param isIv 鏄惁浣跨敤鍋忕Щ閲� ECB妯″紡涓嶅彲鐢� - * @param iv 鍋忕Щ閲� 涓嶄紶榛樿瀵嗛挜 - * @return - */ - public static byte[] encrypt(byte[] content, byte[] keyByte, String cipherInstance, Boolean isIv, byte[] iv) { - try { - //KEY杞崲 - Key key = new SecretKeySpec(keyByte, AES_ALGORITHM); - //鍔犲瘑 - Cipher cipher = Cipher.getInstance(cipherInstance); - if (isIv != null && isIv) { - //鍋忕Щ閲� 涓嶄紶榛樿瀵嗛挜 - if (iv == null) { - iv = keyByte; - } - IvParameterSpec ivps = new IvParameterSpec(iv); - cipher.init(Cipher.ENCRYPT_MODE, key, ivps); - } else { - cipher.init(Cipher.ENCRYPT_MODE, key); - } - byte[] result = cipher.doFinal(content); - return result; - } catch (NoSuchAlgorithmException e) { - LogUtils.e(e.getMessage()); - } catch (InvalidKeyException e) { - LogUtils.e(e.getMessage()); - } catch (NoSuchPaddingException e) { - LogUtils.e(e.getMessage()); - } catch (BadPaddingException e) { - LogUtils.e(e.getMessage()); - } catch (IllegalBlockSizeException e) { - LogUtils.e(e.getMessage()); - } catch (InvalidAlgorithmParameterException e) { - LogUtils.e(e.getMessage()); - } - return null; - } - - /** - * 瑙e瘑 - * - * @param contentHex 寰呰В瀵嗗緟瀛楃涓瞙exStr - * @param keyHex desKye鐨刪exStr - * @return - */ - public static String decrypt(String contentHex, String keyHex) { - return new String(decrypt(HexUtil.decodeHex(contentHex), HexUtil.decodeHex(keyHex), CIPHER_INSTANCE, false, null)); - } - - /** - * 瑙e瘑 - * - * @param contentHex 寰呰В瀵嗗緟瀛楃涓瞙exStr - * @param key 瀵嗛挜 - * @return - */ - public static String decrypt(String contentHex, byte[] key) { - return new String(decrypt(HexUtil.decodeHex(contentHex), key, CIPHER_INSTANCE, false, null)); - } - - /** - * 瑙e瘑 - * - * @param content 寰呰В瀵嗗緟鍐呭 - * @param keyHex 瀵嗛挜 - * @return - */ - public static String decrypt(byte[] content, String keyHex) { - return new String(decrypt(content, HexUtil.decodeHex(keyHex), CIPHER_INSTANCE, false, null)); - } - - /** - * 瑙e瘑 - * - * @param content 寰呰В瀵嗗緟鍐呭 - * @param key 瀵嗛挜 - * @return - */ - public static String decrypt(byte[] content, byte[] key) { - return new String(decrypt(content, key, CIPHER_INSTANCE, false, null)); - } - - - /** - * 瑙e瘑 - * - * @param contentByte 寰呰В瀵嗗緟瀛楃涓瞙exStr - * @param contentByte 瀵嗛挜 - * @param cipherInstance AES绠楁硶濉厖鏂瑰紡 - * @param isIv 鏄惁浣跨敤鍋忕Щ閲� ECB妯″紡涓嶅彲鐢� - * @param iv 鍋忕Щ閲� 涓嶄紶榛樿瀵嗛挜 - * @return - */ - public static byte[] decrypt(byte[] contentByte, byte[] keyByte, String cipherInstance, Boolean isIv, byte[] iv) { - try { - //KEY杞崲 - Key key = new SecretKeySpec(keyByte, AES_ALGORITHM); - //瑙e瘑 - Cipher cipher = Cipher.getInstance(cipherInstance); - if (isIv != null && isIv) { - //鍋忕Щ閲� 涓嶄紶榛樿瀵嗛挜 - if (iv == null) { - iv = keyByte; - } - IvParameterSpec ivps = new IvParameterSpec(iv); - cipher.init(Cipher.DECRYPT_MODE, key, ivps); - } else { - cipher.init(Cipher.DECRYPT_MODE, key); - } - byte[] result = cipher.doFinal(contentByte); - return result; - } catch (NoSuchAlgorithmException e) { - LogUtils.e(e.getMessage()); - } catch (InvalidKeyException e) { - LogUtils.e(e.getMessage()); - } catch (NoSuchPaddingException e) { - LogUtils.e(e.getMessage()); - } catch (BadPaddingException e) { - LogUtils.e(e.getMessage()); - } catch (IllegalBlockSizeException e) { - LogUtils.e(e.getMessage()); - } catch (InvalidAlgorithmParameterException e) { - LogUtils.e(e.getMessage()); - } - return null; - } - - - public static void main(String[] args) { -// jiemi(); - //jiami(); - } - - public static void jiami() { - String key = "1f6714fc-fb9b-4a"; - String content = "{\"id\":\"123\",\"objects\":[{\"sid\":\"0001011565879801020200010101\",\"type\":\"PWD\",\"local_id\":\"2\"}],\"time_stamp\":\"1603281282000\"}"; - byte[] res = aesEncrypt(content.getBytes(), key); - System.out.println(HexUtil.encodeHexStr(res)); - } - - /** - * - * @param str - * @param houseId - * @return - */ - public static String jiemi(byte[] str, String houseId) { - byte[] rs = aesDecrypt(str, HouseIdSecretUtil.getSecret(houseId)); - String content = new String(rs); - return content; - } - -// public static void main(String[] args) { -// try { -// //绗竴姝ワ細 鐢熸垚KEY -// //KeyGenerator keyGenerator = KeyGenerator.getInstance(AES_ALGORITHM); -// //keyGenerator.init(256); -// //绗簩姝ワ細 浜х敓瀵嗛挜 -// //SecretKey secretKey = keyGenerator.generateKey(); -// //绗笁姝ワ細 鑾峰彇瀵嗛挜 -// //byte[] keyBytes = secretKey.getEncoded(); -// //System.out.println(byteArrayToHexStr(keyBytes)); -// String src = "aaaaaaaaaVVVVaaaAAAA鏃�"; -// String pwd = "41151AF257BFDB7859EEC62FB341EE95EE42E648FE24E1F8CE8DADE287CC1E5C"; -// String mw = encrypt(src,pwd); -// System.out.println("mw:"+mw); -// String jm = decrypt(mw,pwd); -// System.out.println("jm:"+jm); -// -// }catch (Exception e){ -// -// } -// -// } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/mqtt/HouseIdSecretUtil.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/mqtt/HouseIdSecretUtil.java deleted file mode 100644 index bc2a93b..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/core/utils/mqtt/HouseIdSecretUtil.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.hdl.sdk.link.core.utils.mqtt; - -/** - * 浣忓畢瀵嗛挜鑾峰彇宸ュ叿绫� - * - * @author yangtao - * @date 2021.2.26 - */ -public class HouseIdSecretUtil { - - public static String getSecret(String homeId) { - String temp = new StringBuffer().append(homeId).reverse().toString(); - if (temp.length() > 16) { - return temp.substring(0, 16); - } - //闀垮害涓嶅16浣嶇敤0琛ラ綈 - for (int i = temp.length(); i < 16; i++) { - temp += "0"; - } - return temp; - } - - public static String getSecret(Long homeId) { - return getSecret(homeId.toString()); - } - - public static void main(String[] args) { - System.out.println(getSecret("1363358800782790658")); - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/gateway/bean/GatewaySearchBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/gateway/bean/GatewaySearchBean.java deleted file mode 100644 index f0a02e3..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/gateway/bean/GatewaySearchBean.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.hdl.sdk.link.gateway.bean; - -import java.io.Serializable; - -/** - * Created by jlchen on 12/16/21. - */ -public class GatewaySearchBean implements Serializable { - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/gateway/type/GatewayMasterType.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/gateway/type/GatewayMasterType.java deleted file mode 100644 index 1ad5fa2..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/gateway/type/GatewayMasterType.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hdl.sdk.link.gateway.type; - -import androidx.annotation.StringDef; - -import java.lang.annotation.Retention; - -import static java.lang.annotation.RetentionPolicy.SOURCE; - -/** - * Created by jlchen on 12/30/21. - */ -@Retention(SOURCE) -@StringDef({GatewayMasterType.MasterTrue,GatewayMasterType.MasterFalse,GatewayMasterType.NO_CONFIG}) -public @interface GatewayMasterType { - //涓荤綉鍏� - String MasterTrue = "true"; - //浠庣綉鍏� - String MasterFalse = "false"; - //鏈厤缃� - String NO_CONFIG = "no_config"; -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/SocketOptions.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/SocketOptions.java deleted file mode 100644 index d92529a..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/SocketOptions.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.hdl.sdk.link.socket; - - -import com.hdl.sdk.link.socket.codec.IHandleMessage; -import com.hdl.sdk.link.socket.listener.ConnectStatusListener; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by Tong on 2021/9/22. - * socket閰嶇疆 - */ -public class SocketOptions { - - //鍙戦�佺洰鏍囧湴鍧�IP - private String ip=""; - private int port; - - //澶勭悊鏁版嵁 - private IHandleMessage handleMessage; - - //鐩戝惉鐘舵�� - private List<ConnectStatusListener> mConnectStatusListener; - - - public String getIp() { - return ip; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public IHandleMessage getHandleMessage() { - return handleMessage; - } - - public void setHandleMessage(IHandleMessage handleMessage) { - this.handleMessage = handleMessage; - } - - public void clearConnectStatusListener() { - if (mConnectStatusListener != null && !mConnectStatusListener.isEmpty()) { - mConnectStatusListener.clear(); - } - } - - public void addConnectStatusListener(ConnectStatusListener connectStatusListener) { - if (mConnectStatusListener == null) { - mConnectStatusListener = new ArrayList<>(); - } - mConnectStatusListener.add(connectStatusListener); - } - - public void removeConnectStatusListener(ConnectStatusListener connectStatusListener) { - if (mConnectStatusListener != null) { - mConnectStatusListener.remove(connectStatusListener); - } - } - - public List<ConnectStatusListener> getConnectStatusListener() { - return mConnectStatusListener; - } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/SocketPool.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/SocketPool.java deleted file mode 100644 index 79e11f6..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/SocketPool.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.hdl.sdk.link.socket; - -import com.hdl.sdk.link.socket.client.IClient; - -import java.net.DatagramSocket; -import java.net.InetSocketAddress; -import java.net.SocketException; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Created by Tong on 2021/10/19. - * 璁″垝鍙傝�僩eneric-pool銆丆ommons Pool杩涜瀹屽杽 - */ -public class SocketPool { - - private final ConcurrentHashMap<String, IClient> mPool; - private final ConcurrentHashMap<String, DatagramSocket> mUdpClientPool; - - private SocketPool() { - mPool = new ConcurrentHashMap<>(); - mUdpClientPool = new ConcurrentHashMap<>(); - } - - - private static class SingletonInstance { - private static final SocketPool INSTANCE = new SocketPool(); - } - - public static SocketPool getInstance() { - return SingletonInstance.INSTANCE; - } - - public void clear() { - mPool.clear(); - mUdpClientPool.clear(); - } - - public synchronized DatagramSocket getUdpSocket(InetSocketAddress address) throws SocketException { - DatagramSocket socket = null; - final String key = address.getPort() + ""; - if (mUdpClientPool.containsKey(key)) { - socket = mUdpClientPool.get(key); - if (socket != null && socket.isClosed()) { - mUdpClientPool.remove(key); - socket = null; - } - } - if (socket == null) { - socket = new DatagramSocket(address); - mUdpClientPool.put(key, socket); - } - return socket; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/SocketRequest.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/SocketRequest.java deleted file mode 100644 index d710ad6..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/SocketRequest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.hdl.sdk.link.socket; - -import java.util.UUID; - -/** - * Created by Tong on 2021/9/22. - */ -public class SocketRequest { - - private String action; - - private byte[] data; - - public SocketRequest(byte[] data) { - this.data = data; - action = UUID.randomUUID().toString(); - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public byte[] getData() { - return data; - } - - public void setData(byte[] data) { - this.data = data; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/annotation/ConnectStatus.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/annotation/ConnectStatus.java deleted file mode 100644 index 9ecb29c..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/annotation/ConnectStatus.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hdl.sdk.link.socket.annotation; - -import androidx.annotation.IntDef; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Target; - -/** - * Created by Tong on 2021/9/22. - */ -@Target({ElementType.TYPE_PARAMETER, ElementType.PARAMETER}) -@IntDef({ConnectStatus.CONNECTING, - ConnectStatus.CONNECTED, - ConnectStatus.DISCONNECT}) -public @interface ConnectStatus { - - /** - * 杩炴帴涓� - */ - int CONNECTING = 0; - - /** - * 杩炴帴鎴愬姛 - */ - int CONNECTED = 1; - - /** - * 杩炴帴鍏抽棴 - */ - int DISCONNECT = 2; -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/bean/Packet.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/bean/Packet.java deleted file mode 100644 index e2558a8..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/bean/Packet.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.hdl.sdk.link.socket.bean; - -import java.net.Socket; -import java.net.SocketOption; - -/** - * Created by hxb on 2021/12/23. - */ -public class Packet { - private byte []bytes; - private Socket socket; - - public Packet( byte []bytes, Socket socket){ - this.bytes=bytes; - this.socket=socket; - } - public Packet(byte []bytes){ - this(bytes,null); - } - - - /** - * 鎺ユ敹鎴栬�呭彂閫佺殑鏁版嵁 - * @return - */ - public byte[] getBytes() { - return bytes; - } - - /** - * 鎺ユ敹鎴栬�呭彂閫佺殑鏁版嵁 - * @param bytes - */ - public void setBytes(byte[] bytes) { - this.bytes = bytes; - } - - public Socket getSocket() { - return socket; - } - - public void setSocket(Socket socket) { - this.socket = socket; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/client/IClient.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/client/IClient.java deleted file mode 100644 index 71293d7..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/client/IClient.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.hdl.sdk.link.socket.client; - - -import com.hdl.sdk.link.socket.SocketOptions; - -/** - * Created by Tong on 2021/9/22. - */ -public interface IClient { - - void connect() throws Exception; - - void disconnect(); - - - SocketOptions getOptions(); - - /** - * 鐩戝惉鏁版嵁 - */ - void onHandleResponse() throws Exception; - - /** - * 鍙戦�佹秷鎭� - */ - void sendMsg(byte[] msg) throws Exception; - - /** - * 杩炴帴鐘舵�� - */ - void onConnectStatus(int status); -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/client/IHeartbeat.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/client/IHeartbeat.java deleted file mode 100644 index 9a4e7a4..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/client/IHeartbeat.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.hdl.sdk.link.socket.client; - -/** - * Created by hxb on 2022/2/16. - */ -public interface IHeartbeat { - void heartbeat(); -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/client/IUdpClient.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/client/IUdpClient.java deleted file mode 100644 index 7db851e..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/client/IUdpClient.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.hdl.sdk.link.socket.client; - -import com.hdl.sdk.link.socket.udp.UdpSocketOptions; - -/** - * Created by hxb on 2021/12/12. - */ -public interface IUdpClient { - - /** - * 缁戝畾绔彛 - */ - void bind() throws Exception; - - /** - * 鍏抽棴褰撳墠杩炴帴 - * @return - */ - boolean close(); - - - UdpSocketOptions getOptions(); - - /** - * 鐩戝惉鏁版嵁 - */ - void onHandleResponse() throws Exception; - - /** - * 鍙戦�佹暟鎹� - * @param ipAddress 鐩爣IP - * @param port 绔彛 - * @param msg 鍙戦�佹暟鎹� - * @throws Exception - */ - void sendMsg(String ipAddress,int port, byte[] msg) throws Exception; - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/client/TcpClient.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/client/TcpClient.java deleted file mode 100644 index d5e6f38..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/client/TcpClient.java +++ /dev/null @@ -1,176 +0,0 @@ -package com.hdl.sdk.link.socket.client; - - - -import com.hdl.sdk.link.common.utils.LogUtils; -import com.hdl.sdk.link.common.utils.ThreadToolUtils; -import com.hdl.sdk.link.core.protocol.LinkMessageDecoder; -import com.hdl.sdk.link.socket.TcpSocketBoot; -import com.hdl.sdk.link.socket.SocketOptions; -import com.hdl.sdk.link.socket.annotation.ConnectStatus; -import com.hdl.sdk.link.socket.bean.Packet; -import com.hdl.sdk.link.socket.codec.IHandleMessage; -import com.hdl.sdk.link.socket.listener.ConnectStatusListener; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.util.List; - - -/** - * Created by Tong on 2021/9/15. - */ -public final class TcpClient implements IClient { - - - private SocketOptions socketOptions; - - private final String ip; - private final int port; - - private Socket mSocket; - - private byte[] readBuffer = new byte[4*1024]; - - private TcpClient(String ip, int port, SocketOptions socketOptions) { - this.socketOptions = socketOptions; - this.ip = ip; - this.port = port; - socketOptions.setIp(ip); - socketOptions.setPort(port); - } - - public static TcpSocketBoot init(String ip, int port, SocketOptions options) { - return new TcpSocketBoot(new TcpClient(ip, port, options)); - } - - - - - @Override - public void connect() throws Exception { - mSocket = getSocket(); - mSocket.connect(new InetSocketAddress(ip, port), 3 * 1000); - mSocket.setTcpNoDelay(true); - mSocket.setReuseAddress(true); -// mSocket.setKeepAlive(true); -// mSocket.setSoTimeout(12 * 1000); - } - - - - - @Override - public void disconnect() { - if (mSocket != null) { - try { - mSocket.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - @Override - public synchronized SocketOptions getOptions() { - if (socketOptions == null) { - socketOptions = new SocketOptions(); - } - return socketOptions; - } - - @Override - public void onHandleResponse() throws Exception { - final InputStream stream = getInputStream(); - if (stream != null && getOptions() != null) { - int len = 0; - - if ((len = stream.read(readBuffer)) == -1) { - throw new Exception("缃戝叧鏂紑"); - } - - byte[] bytes = new byte[len]; - System.arraycopy(readBuffer, 0, bytes, 0, len); - socketOptions.getHandleMessage().read(new Packet(bytes, mSocket)); - } - } - - @Override - public synchronized void sendMsg(byte[] msg) throws Exception { - final OutputStream outputStream = getOutStream(); - if (outputStream != null && getOptions() != null) { - try { -// IHandleMessage handleMessage = getOptions().getHandleMessage(); -// handleMessage.write(handleMessage.write(msg)); - getOutStream().write(msg); - - }finally { - outputStream.flush(); - } - } - } - - - /** - * 澶勭悊杩炴帴鐘舵�� - */ - public void onConnectStatus(int status) { - ThreadToolUtils.getInstance().runOnUiThread(new Runnable() { - @Override - public void run() { - final List<ConnectStatusListener> list = getOptions().getConnectStatusListener(); - if (list != null && !list.isEmpty()) { - for (ConnectStatusListener listener : list) { - switch (status) { - case ConnectStatus - .CONNECTING: - listener.onConnecting(); - break; - case ConnectStatus - .CONNECTED: - listener.onConnected(); - break; - case ConnectStatus - .DISCONNECT: - listener.onConnectFailed(); - break; - } - } - } - } - }); - } - - - private synchronized Socket getSocket() { - return new Socket(); - } - - private InputStream getInputStream() { - if (mSocket != null && mSocket.isConnected() && !mSocket.isClosed()) { - try { - return mSocket.getInputStream(); - } catch (IOException e) { - e.printStackTrace(); - } - } - return null; - } - - - private OutputStream getOutStream() { - if (mSocket != null && mSocket.isConnected() && !mSocket.isClosed()) { - try { - return mSocket.getOutputStream(); - } catch (IOException e) { - e.printStackTrace(); - } - } - return null; - } - - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/client/UdpClient.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/client/UdpClient.java deleted file mode 100644 index 2e94009..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/client/UdpClient.java +++ /dev/null @@ -1,191 +0,0 @@ -package com.hdl.sdk.link.socket.client; - - -import android.net.wifi.WifiManager; -import android.text.TextUtils; - -import com.hdl.sdk.link.common.utils.LogUtils; -import com.hdl.sdk.link.core.protocol.LinkMessageDecoder; -import com.hdl.sdk.link.socket.SocketPool; -import com.hdl.sdk.link.socket.bean.Packet; -import com.hdl.sdk.link.socket.udp.UdpSocketBoot; -import com.hdl.sdk.link.socket.udp.UdpSocketOptions; -import com.hdl.sdk.link.socket.codec.IHandleMessage; - -import java.io.IOException; -import java.net.DatagramPacket; -import java.net.DatagramSocket; -import java.net.Inet4Address; -import java.net.InetAddress; -import java.net.InetSocketAddress; - - -/** - * Created by hxb on 2021/12/12. - */ -public class UdpClient implements IUdpClient { - - /** - * 褰撳墠socket - */ - private DatagramSocket mSocket; - - /** - * 鎺ユ敹鏁版嵁鍖� - */ - private DatagramPacket receivePacket; - - /** - * 缂撳啿鍖哄ぇ灏� - */ - private final int BUFFER = 2 * 1024; - - /** - * 鏈湴鐩戝惉IP鍦板潃 - */ - private String ipAddress; - /** - * 鏈湴鐩戝惉绔彛 - */ - private int port; - - /** - * socket閰嶇疆淇℃伅 - */ - private UdpSocketOptions socketOptions; - - WifiManager.MulticastLock lock; - - /** - * 鍒濆鍖栧弬鏁� - * @param ipAddress 鏈湴鐩戝惉绔彛 - * @param port 鏈湴鐩戝惉绔彛 - * @param socketOptions - */ - public UdpClient(String ipAddress, int port, UdpSocketOptions socketOptions) { - this.ipAddress = ipAddress; - this.port = port; - this.socketOptions = socketOptions; - byte[] receiveByte = new byte[BUFFER]; - receivePacket = new DatagramPacket(receiveByte, receiveByte.length); - this.lock= socketOptions.getWifiManager().createMulticastLock("UDPwifi"); - } - - /** - * 鍒濆鍖栧弬鏁� - * @param ipAddress 鏈湴鐩戝惉IP鍦板潃 - * @param port 鏈湴鐩戝惉绔彛 - * @param options - * @return - */ - public static UdpSocketBoot init(String ipAddress, int port, UdpSocketOptions options) { - return new UdpSocketBoot(new UdpClient(ipAddress, port, options)); - } - - /** - * 鍒濆鍖栧弬鏁� - * @param port 鏈湴鐩戝惉绔彛 - * @param options - * @return - */ - public static UdpSocketBoot init(int port, UdpSocketOptions options) { - return init("0.0.0.0", port, options); - } - - @Override - public synchronized void bind() throws Exception { - try { - //宸茬粡缁戝畾杩囧氨涓嶇敤鍐嶇粦瀹� - if (null != mSocket) { - return; - } - - lock.acquire(); - if (TextUtils.isEmpty(ipAddress)) { - mSocket = SocketPool.getInstance().getUdpSocket(new InetSocketAddress(Inet4Address.getByName("0.0.0.0"), port)); - } - else{ - mSocket = SocketPool.getInstance().getUdpSocket(new InetSocketAddress(Inet4Address.getByName(ipAddress), port)); - } - mSocket.setBroadcast(true); -// mSocket.setReuseAddress(true); - - } catch (Exception e) { - throw e; - } - } - - @Override - public boolean close() { - try { - mSocket.close(); - } catch (Exception e) { - - } - mSocket = null; - return true; - } - - @Override - public UdpSocketOptions getOptions() { - return this.socketOptions; - } - - @Override - public void onHandleResponse() throws Exception { - if (mSocket == null) { - return; - } - try { - mSocket.receive(receivePacket); - } catch (Exception e) { - LogUtils.e("鎺ユ敹鍒癠dp鏁版嵁鍖呭紓甯革紝寮傚父淇℃伅锛�" + e.getMessage()); - return; - } - if (receivePacket.getLength() == 0) { - LogUtils.i("鎺ユ敹鍒癠dp鏁版嵁鍖咃紝鏁版嵁鍖呴暱搴︿负0锛�" + receivePacket.getAddress().getHostAddress() + ":" + receivePacket.getPort()); - return; - } - //鎺掗櫎鑷繁鍙戝嚭鍘荤殑 -// try { -// if (IpUtils.isLocalIpAddress(receivePacket.getAddress().getHostAddress())) -// return; -// } catch (Exception ignored) { -// -// } - - try { - LogUtils.i("鎺ユ敹鍒癠dp鏁版嵁鍖咃紝缃戠粶鍦板潃锛�" + receivePacket.getAddress().getHostAddress() + ":" + receivePacket.getPort()); - -// IHandleMessage handleMessage = getOptions().getHandleMessage(); -// if (handleMessage != null) { -// byte[] data = new byte[receivePacket.getLength()]; -// System.arraycopy(receivePacket.getData(), 0, data, 0, data.length); -// handleMessage.read(new Packet(receivePacket.getAddress().getHostAddress(), data,null)); -// } - - byte[] data = new byte[receivePacket.getLength()]; - System.arraycopy(receivePacket.getData(), 0, data, 0, data.length); - socketOptions.getHandleMessage().read(new Packet(data)); - - } catch (Exception e) { - LogUtils.i("鎺ユ敹鍒癠dp鏁版嵁鍖咃紝澶勭悊寮傚父锛�" + e.getMessage()); - } - } - - - @Override - public void sendMsg(String ipAddress,int port, byte[] msg) throws Exception { - if (msg == null) { - return; - } - final DatagramPacket sendPacket = new DatagramPacket(msg, msg.length, InetAddress.getByName(ipAddress), port); - if (mSocket != null) { - mSocket.send(sendPacket); - } else { - DatagramSocket datagramSocket = new DatagramSocket(); - datagramSocket.send(sendPacket); - datagramSocket.close(); - } - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/ByteToMessageDecoder.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/ByteToMessageDecoder.java deleted file mode 100644 index 617f543..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/ByteToMessageDecoder.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hdl.sdk.link.socket.codec; - -import com.hdl.sdk.link.socket.bean.Packet; - -/** - * Created by Tong on 2021/9/22. - */ -public abstract class ByteToMessageDecoder<T> implements IHandleFlow<T> { - - protected abstract T decoder(Packet packet) - throws Exception; - - @Override - public synchronized T read(Packet packet) throws Exception { - return decoder(packet); - } -// -// @Override -// public final byte[] write(Packet data) { -// return data; -// } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/IHandleFlow.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/IHandleFlow.java deleted file mode 100644 index 3ce442f..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/IHandleFlow.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.hdl.sdk.link.socket.codec; - -import com.hdl.sdk.link.socket.bean.Packet; - -/** - * Created by Tong on 2021/9/23. - */ -public interface IHandleFlow<T> { - - T read(Packet packet) throws Exception; - -// byte[] write(Packet packet) throws Exception; - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/IHandleMessage.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/IHandleMessage.java deleted file mode 100644 index 1c7a223..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/IHandleMessage.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hdl.sdk.link.socket.codec; - -import com.hdl.sdk.link.socket.bean.Packet; - -/** - * Created by Tong on 2021/9/27. - */ -public interface IHandleMessage { - void read(Packet packet) throws Exception; - -// byte[] write(Packet packet) throws Exception; -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/IMessagePipeLine.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/IMessagePipeLine.java deleted file mode 100644 index 41128df..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/IMessagePipeLine.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hdl.sdk.link.socket.codec; - -/** - * Created by Tong on 2021/9/23. - */ -public interface IMessagePipeLine { - - void add(IHandleFlow flow); - - void clear(); -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/MessagePipeLine.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/MessagePipeLine.java deleted file mode 100644 index ea5fd27..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/MessagePipeLine.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.hdl.sdk.link.socket.codec; - -import com.hdl.sdk.link.socket.bean.Packet; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by Tong on 2021/9/23. - */ -public class MessagePipeLine implements IMessagePipeLine, IHandleMessage { - - public final List<IHandleFlow> queue = new ArrayList<>(); - - @Override - public void add(IHandleFlow flow) { - queue.add(flow); - } - - @Override - public synchronized void clear() { - queue.clear(); - } - - @Override - public synchronized void read(Packet packet) throws Exception { - for (int i = 0; i < queue.size(); i++) { - IHandleFlow flow = queue.get(i); - Object read = flow.read(packet); -// try { -// out = Objects.requireNonNull(read); -// } catch (Exception ignored) { -// } - } - } - -// @Override -// public byte[] write(Packet packet) throws Exception { -// for (int i = 0; i < queue.size(); i++) { -// IHandleFlow flow = queue.get(i); -// byte[] write = flow.write(packet); -// } -// return new byte[0]; -// } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/MessageToByteEncoder.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/MessageToByteEncoder.java deleted file mode 100644 index e093590..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/codec/MessageToByteEncoder.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.hdl.sdk.link.socket.codec; - - -import com.hdl.sdk.link.socket.bean.Packet; - -/** - * Created by Tong on 2021/9/22. - */ -public abstract class MessageToByteEncoder implements IHandleFlow { - - - protected abstract Packet encode(Packet packet) - throws Exception; - - @Override - public final Object read(Packet packet) { - return packet; - } - -// @Override -// public byte[] write(Packet packet) throws Exception { -// return encode(packet); -// } - - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/listener/ConnectStatusListener.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/listener/ConnectStatusListener.java deleted file mode 100644 index 9efb726..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/listener/ConnectStatusListener.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.hdl.sdk.link.socket.listener; - -/** - * Created by Tong on 2021/9/22. - * 杩炴帴鐘舵�� - */ -public interface ConnectStatusListener { - - /** - * 杩炴帴涓� - */ - default void onConnecting() { - } - - /** - * 杩炴帴鎴愬姛 - */ - default void onConnected() { - } - - /** - * 杩炴帴澶辫触 - */ - default void onConnectFailed() { - } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/listener/SendListener.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/listener/SendListener.java deleted file mode 100644 index e9a84f1..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/listener/SendListener.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hdl.sdk.link.socket.listener; - -/** - * Created by Tong on 2021/9/22. - */ -public interface SendListener { - - void onSucceed(); - - void onError(); -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/udp/UdpSocketBoot.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/udp/UdpSocketBoot.java deleted file mode 100644 index 4e039f7..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/udp/UdpSocketBoot.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.hdl.sdk.link.socket.udp; - -import android.text.TextUtils; - -import androidx.collection.ArrayMap; - -import com.hdl.sdk.link.common.utils.LogUtils; -import com.hdl.sdk.link.common.utils.ThreadToolUtils; -import com.hdl.sdk.link.socket.listener.SendListener; -import com.hdl.sdk.link.socket.SocketRequest; -import com.hdl.sdk.link.socket.client.IUdpClient; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * Created by hxb on 2021/12/12. - */ -public class UdpSocketBoot { - - private final IUdpClient client; - - private final AtomicBoolean isOpenRetry = new AtomicBoolean(false); - - private final AtomicInteger resendCount = new AtomicInteger(0); - - private ExecutorService receiveThread; - - private final ArrayMap<String, SendListener> sendMap = new ArrayMap<>(); - - - public IUdpClient getClient() { - return client; - } - - public UdpSocketBoot(IUdpClient client) { - this.client = client; - } - - /** - * 缁戝畾 socket - * @throws Exception 鍙兘绔彛鍐茬獊 - */ - public void bind() throws Exception { - client.bind(); - initReceiveThread(); - } - - /** - * 鍒濆鍖栨帴鏀剁嚎绋� - */ - private void initReceiveThread() { - if(null!=receiveThread){ - return; - } - receiveThread = ThreadToolUtils.getInstance().newFixedThreadPool(1); - receiveThread.execute(new Runnable() { - @Override - public void run() { - while (true) { - try { - client.onHandleResponse(); - } catch (Exception e) { - LogUtils.i("鎺ユ敹绾跨▼寮傚父锛�"+e.getMessage()); - } - } - } - }); - } - - - /** - * 鍙戦�佹暟鎹� - * @param ipAddress 鐩殑鐨処P鍦板潃 - * @param port 绔彛 - * @param msg 鍙戦�佹暟鎹� - * @param listener 鍙戦�佸洖璋� - */ - public void sendMsg(String ipAddress,int port,byte[] msg, SendListener listener) { - sendMsg(ipAddress,port, msg, true, listener); - } - - /** - * 鍙戦�佹暟鎹� - * @param ipAddress 鐩殑鐨処P鍦板潃 - * @param port 绔彛 - * @param msg 鍙戦�佹暟鎹� - */ - public void sendMsg(String ipAddress,int port,byte[] msg) { - sendMsg(ipAddress,port, msg, true, null); - } - - /** - * 鍙戦�佹暟鎹� - * @param ipAddress 鐩殑IP鍦板潃 - * @param port 绔彛 - * @param msg 鍙戦�佺殑鏁版嵁 - * @param isRefreshRetry 鏄惁瑕侀噸鍙� - * @param listener 鍙戦�佸洖璋� - */ - public void sendMsg(String ipAddress,int port, byte[] msg, boolean isRefreshRetry, SendListener listener) { - if (isRefreshRetry) { - //閲嶇疆杩炴帴娆℃暟 - resendCount.set(0); - } - try { - SocketRequest request = new SocketRequest(msg); - if (listener != null && !TextUtils.isEmpty(request.getAction())) { - sendMap.put(request.getAction(), listener); - } - client.sendMsg(ipAddress,port, msg); - } catch (Exception e) { - LogUtils.e("鍙戦�佸け璐�:" + e.getMessage()); - } - } - - /** - * 鍏抽棴褰撳墠socket - */ - public synchronized void close() { - isOpenRetry.set(false); - sendMap.clear(); - receiveThread.shutdown(); - receiveThread=null; - client.close(); - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/udp/UdpSocketOptions.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/udp/UdpSocketOptions.java deleted file mode 100644 index 38ad296..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/udp/UdpSocketOptions.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.hdl.sdk.link.socket.udp; - - -import android.net.wifi.WifiManager; - -import com.hdl.sdk.link.socket.codec.IHandleMessage; - -/** - * Created by hxb on 2021/12/12. - */ -public class UdpSocketOptions { - - //澶勭悊鏁版嵁 - private IHandleMessage handleMessage; - private WifiManager wifiManager; - - public IHandleMessage getHandleMessage() { - return handleMessage; - } - - public void setHandleMessage(IHandleMessage handleMessage) { - this.handleMessage = handleMessage; - } - - public WifiManager getWifiManager() { - return wifiManager; - } - - public void setWifiManager(WifiManager wifiManager) { - this.wifiManager = wifiManager; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/HDLLinkLocalZigBee.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/HDLLinkLocalZigBee.java deleted file mode 100644 index 957bac3..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/HDLLinkLocalZigBee.java +++ /dev/null @@ -1,392 +0,0 @@ -package com.hdl.sdk.link.zigbee; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; -import com.hdl.sdk.link.common.event.EventListener; -import com.hdl.sdk.link.common.exception.HDLLinkCode; -import com.hdl.sdk.link.common.exception.HDLLinkException; -import com.hdl.sdk.link.common.utils.LogUtils; -import com.hdl.sdk.link.common.utils.ThreadToolUtils; -import com.hdl.sdk.link.common.utils.gson.GsonConvert; -import com.hdl.sdk.link.core.bean.ZigbeeResponse; -import com.hdl.sdk.link.core.callback.ZigbeeCallBack; -import com.hdl.sdk.link.core.connect.HDLZigbeeConnect; -import com.hdl.sdk.link.zigbee.bean.PanelVibrationBean; -import com.hdl.sdk.link.zigbee.bean.TimeDataBean; -import com.hdl.sdk.link.zigbee.bean.ZBBaseSendBean; -import com.hdl.sdk.link.zigbee.bean.ZBDeviceBean; -import com.hdl.sdk.link.zigbee.callback.ZBDeviceListCallBack; -import com.hdl.sdk.link.zigbee.config.ZigBee; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * Created by jlchen on 12/16/21. - * ZigBee鍘熺敓鍗忚鐩稿叧 - */ -public class HDLLinkLocalZigBee { - private static final String TAG = "HDLLinkLocalZigBee"; - private static final String Cluster_ID = "Cluster_ID"; - private static final String Command = "Command"; - //instance - private volatile static HDLLinkLocalZigBee instance; - - //getInstance - public static synchronized HDLLinkLocalZigBee getInstance() { - if (instance == null) { - synchronized (HDLLinkLocalZigBee.class) { - if (instance == null) { - instance = new HDLLinkLocalZigBee(); - } - } - } - return instance; - } - - - /** - * 鍙戦�佹秷鎭粰缃戝叧 - * - * @param gatewayOid - * @param replyTopic 鍥炲涓婚 - * @param payload - * @param callback - */ - public void sendData(String gatewayOid, String replyTopic, String payload, ZigbeeCallBack callback) { - //娉ㄦ剰 gatewayId鏄~瑕佽繛鎺ョ殑缃戝叧锛屽彲浠ユ槸涓荤綉鍏崇殑Id锛屼篃鍙互鏄粠缃戝叧鐨処d - HDLZigbeeConnect.getInstance().Send(gatewayOid, replyTopic, payload, callback); - } - - /********************************缃戝叧鐩稿叧********************************/ - /** - * 鍙戦�佹寚浠ゅ埌缃戝叧杩涜瀹氫綅(缃戝叧LED闂儊璇嗗埆) - * - * @param gatewayOid 缃戝叧id - * @param callback - */ - public void locationGateway(String gatewayOid, ZigbeeCallBack callback) { - JsonObject jObject = new JsonObject(); - jObject.addProperty(Cluster_ID, 0); - jObject.addProperty(Command, ZigBee.CommandType.GwLinuxLocate); - sendData(gatewayOid, ZigBee.ReplyTopicType.GwLinuxLocate, jObject.toString(), callback); - } - - /********************************璁惧鐩稿叧********************************/ - /** - * 璁剧疆璁惧鍏ョ綉鏂瑰紡 - * 璁剧疆1娆′箣鍚庝繚鎸佽缃殑鏂瑰紡 - * 閲嶅惎鎭㈠榛樿鏂瑰紡 - * - * @param gatewayOid 缃戝叧oid - * @param deviceJoiningMode 0锛氶粯璁わ紱1锛氭柊鏂瑰紡锛堝揩閫熷叆缃戯級 - */ - public void setDeviceJoiningMode(String gatewayOid, int deviceJoiningMode, ZigbeeCallBack callback) { - JsonObject jObject = new JsonObject(); - jObject.addProperty("Cluster_ID", 0); - jObject.addProperty("Command", 180); - JsonObject data = new JsonObject(); - data.addProperty("mode", deviceJoiningMode); - jObject.add("Data", data); - sendData(gatewayOid, ZigBee.ReplyTopicType.SetJoiningModeRespon, jObject.toString(), callback); - } - - /** - * 璁剧疆鎼滅储鏂拌澶囧紑鍚垨鑰呭叧闂� - * - * @param gatewayOid 缃戝叧oid - * @param time 寮�鍚悳绱㈣澶囩殑鏃堕棿(鍗曚綅锛氱) 0:鍏抽棴鎼滅储 255锛氫竴鐩村紑鍚� - * @param callback - */ - public void sendSearchDevice(String gatewayOid, int time, ZigbeeCallBack callback) { - ZBBaseSendBean<TimeDataBean> baseSendBean = new ZBBaseSendBean(0, ZigBee.CommandType.SearchNewDevice, new TimeDataBean(time)); - sendData(gatewayOid, ZigBee.ReplyTopicType.SearchNewDevice, GsonConvert.getGson().toJson(baseSendBean), callback); - } - - /** - * 鎼滅储璁惧 - * - * @param gatewayOid - * @param callback - */ - public void startSearchDevice(String gatewayOid, ZigbeeCallBack callback) { - sendSearchDevice(gatewayOid, 255, callback); - } - - /** - * 鏆傚仠鎼滅储璁惧 - * - * @param gatewayOid - * @param callback - */ - public void stopSearchDevice(String gatewayOid, ZigbeeCallBack callback) { - sendSearchDevice(gatewayOid, 0, callback); - } - - /** - * 瀹氫綅璁惧 闂儊5绉� - * 璇ユ潯鎸囦护璁惧涓嶅洖澶嶏紝鎵�鏈夋病callBack - * 鍙戦�佽鍛戒护锛岃澶囨寚绀虹伅灏嗛棯鐑併�俢luster 鍒楄〃涓敮鎸� Identify 鍔熻兘锛屽嵆鍖呭惈 cluster=3 鐨勮 澶囧彲浠ヤ娇鐢ㄨ鎺ュ彛銆� - * - * @param gatewayOid - * @param deviceAddr 鍗曟挱鏃朵负璁惧鑺傜偣鐨� mac 鍦� 鍧� 绫诲瀷鏄瓧绗︼紙16 涓瓧绗︼級 缁勬挱鏃朵负缁� id 绫诲瀷鏄暟鍊� 骞挎挱鏃朵负 null - * @param epoint 璁惧绔彛鍙� 鍜� mac 鍦板潃鍏卞悓鏍囪瘑鍞竴鐨� zigbee 璁惧 鏁板�艰寖鍥� 0-255 - */ - public void locationDevice(String gatewayOid, String deviceAddr, int epoint) { - JsonObject jObject = new JsonObject(); - jObject.addProperty("DeviceAddr", deviceAddr); - jObject.addProperty("Epoint", epoint); - jObject.addProperty(Cluster_ID, 3); - jObject.addProperty(Command, 0); - jObject.addProperty("SendMode", 2);//鍙戦�佹ā寮� 缁勬挱: 1 鍗曟挱: 2 骞挎挱: 15 - JsonObject data = new JsonObject(); - data.addProperty("Time", 5);//闂儊鏃堕棿锛堢锛� - jObject.add("Data", data); - sendData(gatewayOid, ZigBee.ReplyTopicType.Identify, jObject.toString(), null); - } - - - /** - * 璁惧鍒楄〃-璁惧鍒犻櫎锛堜娇璁惧绂荤綉锛� - * 閫氳繃璇ユ寚浠ゅ彲浠ヤ娇璁惧鑴辩褰撳墠 zigbee 缃戠粶锛岃璁惧淇℃伅涔熷皢浼氬湪缃戝叧涓婂垹闄ゃ�� - * 娉ㄦ剰锛氬皢浼氬垹闄ゅ悓涓� MAC 鍦板潃涓嬫墍鏈変笉鍚岀鍙g殑璁惧锛屽涓�涓� 2 璺寜閿澶囷紝瀹冨叿鏈変袱涓� 鎸夐敭锛屽湪璁惧鍒楄〃涓婅繖涓や釜鎸夐敭鍏锋湁鐩稿悓鐨� mac锛屼絾绔彛鍙锋槸涓嶅悓鐨勩�備娇鐢ㄨ鎸囦护璁╀换鎰� 涓�涓寜閿缃戯紝鍙︿竴涓篃浼氱缃戙�� - * - * @param gatewayOid - * @param compelClear 0锛氫笉寮哄埗娓呴櫎銆傞渶瑕佽妭鐐硅澶� 鍙嶉绂荤綉纭淇℃伅鍚庢墠鑳藉垹闄よ 澶囦俊鎭�� - * 1锛氬己鍒舵竻闄ゃ�備笉闇�瑕佽妭鐐硅澶� 鍙嶉绂荤綉纭淇℃伅锛岀洿鎺ュ垹闄よ 澶囦俊鎭�� - */ - public void removeDevice(String gatewayOid, int compelClear, List<String> deviceAddrList, ZigbeeCallBack callback) { - if (deviceAddrList == null || deviceAddrList.size() == 0) { - LogUtils.e("娌℃湁瑕佸垹闄ゅ埌鏁版嵁"); - return; - } - JsonArray addrList = new JsonArray(); - for (String addr : deviceAddrList) { - JsonObject aObject = new JsonObject(); - aObject.addProperty("DeviceAddr", addr); - addrList.add(aObject); - } - JsonObject jObject = new JsonObject(); - jObject.addProperty(Cluster_ID, 0); - jObject.addProperty(Command, ZigBee.CommandType.RemoveDevice); - JsonObject data = new JsonObject(); - data.addProperty("CompelClear", compelClear); - data.add("DeviceAddrList", addrList); - jObject.add("Data", data); - sendData(gatewayOid, ZigBee.ReplyTopicType.RemoveDevice, jObject.toString(), callback); - } - - /** - * 璁惧鍒楄〃-鑾峰彇鏈湴缃戝叧璁惧 EPDeviceId 鍒楄〃 - * 锛堢綉鍏充竴涓竴涓繑鍥炵鐐硅澶囪缁嗕俊鎭級 - * - * @param gatewayOid - * @param callback - */ - public void getZigBeeDeviceList(String gatewayOid, ZBDeviceListCallBack callback) { - JsonObject jObject = new JsonObject(); - jObject.addProperty(Cluster_ID, 0); - jObject.addProperty(Command, ZigBee.CommandType.GetDeviceInfo); - //鏄惁鑾峰彇鍒楄〃鎴愬姛鏍囪 - AtomicBoolean isSuccess = new AtomicBoolean(false); - //鎼滅储5s绛夊緟鏍囪 - AtomicInteger timeOut = new AtomicInteger(0); - //璁惧鍒楄〃 - List<ZBDeviceBean> list = new ArrayList<>(); - //娉ㄥ唽鐩戝惉浜嬩欢 - EventListener zigBeeEventListener = new EventListener() { - @Override - public synchronized void onMessage(Object msg) { - if (msg instanceof ZigbeeResponse) { - ZigbeeResponse zigbeeResponse = (ZigbeeResponse) msg; - try { - if (zigbeeResponse.getTopic().equals(ZigBee.ReplyTopicType.GetDeviceInfo)) { - final ZBDeviceBean bean = GsonConvert.getGson().fromJson(zigbeeResponse.getData(), new TypeToken<ZBDeviceBean>() { - }.getType()); - - - if (bean == null) { - LogUtils.i("鑾峰彇鍒扮殑Zigbee璁惧鍒楄〃鍙嶇郴鍒楀寲澶辫触:\r\n" + zigbeeResponse.getData()); - } else { - bean.setGatewayMac(zigbeeResponse.getOid()); - LogUtils.i("zigbeeResponse ZBDeviceBean:" + bean.getDeviceAddr() + "锛�" + bean.getEpoint()); - if (bean.getData().getTotalNum() == 0) { - //鍥炲绌虹殑璁惧鍒楄〃 - list.clear(); - if (callback != null) { - callback.onSuccess(list); - } - HDLZigbeeConnect.getInstance().removeListener(this); - isSuccess.set(true); - } else { - list.add(bean); -// LogUtils.i("getZigBeeDeviceList 閲嶇疆鏃堕棿涓�0"); - timeOut.set(0);//鏀跺埌涓�涓澶囧垯閲嶇疆鏃堕棿 - //濡傛灉褰撳墠搴忓彿绛変簬鎬绘暟锛屼唬琛ㄦ槸鏈�鍚庝竴涓澶囦簡锛屽洖璋冩垚鍔� - if (bean.getData().getDeviceNum() == bean.getData().getTotalNum()) { - if (callback != null) { - callback.onSuccess(list); - } - HDLZigbeeConnect.getInstance().removeListener(this); - isSuccess.set(true); - LogUtils.i("getZigBeeDeviceList璇诲彇瀹屾垚"); - timeOut.set(6);//璁℃椂缁撴潫鏍囪 - } - - } - } - } - } catch (Exception e) { - LogUtils.e(TAG, "鎺ユ敹鐨勬暟鎹唴瀹�:" + zigbeeResponse.getData() + " 寮傚父淇℃伅:" + e.getMessage()); - } - } - } - }; - HDLZigbeeConnect.getInstance().registerListener(zigBeeEventListener); - //鍙戦�佹暟鎹� - sendData(gatewayOid, "", jObject.toString(), null); - //5绉掑悗杩樻病鏈夋帴鏀跺埌鏁版嵁锛屽氨鍥炶皟澶辫触 - ScheduledExecutorService scheduledExecutorService = ThreadToolUtils.getInstance().newScheduledThreadPool(1); - scheduledExecutorService.schedule(new Runnable() { - @Override - public void run() { - while (timeOut.get() < 5) { - try { - timeOut.set(timeOut.get() + 1); - LogUtils.i("getZigBeeDeviceList 璁℃椂锛�" + timeOut.get() + "s"); - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - //绉婚櫎鐩戝惉浜嬩欢 - HDLZigbeeConnect.getInstance().removeListener(zigBeeEventListener); - if (!isSuccess.get()) { - if (null != callback) { - callback.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_GET_Zigbee_DEVICE_LIST_FAILURE_ERROR)); - } - } - LogUtils.i("getZigBeeDeviceList 5s鍊掕鏃剁粨鏉�"); - scheduledExecutorService.shutdownNow(); - } - }, 1, TimeUnit.SECONDS); - - } - - /** - * 淇敼璁惧绔彛锛堟寜閿級鍚嶇О - * - * @param gatewayOid - * @param deviceAddr - * @param epoint - * @param deviceName - * @param callback - */ - public void renameDeviceName(String gatewayOid, String deviceAddr, int epoint, String deviceName, ZigbeeCallBack callback) { - JsonObject jObject = new JsonObject(); - jObject.addProperty("DeviceAddr", deviceAddr); - jObject.addProperty("Epoint", epoint); - jObject.addProperty(Cluster_ID, 0); - jObject.addProperty(Command, ZigBee.CommandType.DeviceRename); - JsonObject data = new JsonObject(); - data.addProperty("DeviceName", deviceName); - jObject.add("Data", data); - sendData(gatewayOid, ZigBee.ReplyTopicType.DeviceRename, jObject.toString(), callback); - } - - /** - * 瀵圭鐐瑰洖璺澶囧姛鑳界被鍨嬭繘琛岃缃 onoffoutput 鍥炶矾,杩涜璁剧疆涓烘櫘閫氬紑鍏虫垨鎻掑骇鎴栫伅鍏� - * - * @param gatewayOid - * @param deviceAddr 璁惧鑺傜偣鐨� mac 鍦板潃 锛堟渶澶� 16 涓瓧绗︼級 - * @param epoint 璁惧绔彛鍙� 鍜� mac 鍦板潃鍏卞悓鏍囪瘑鍞竴鐨� zigbee 璁惧 鏁板�艰寖鍥� 0-255 - * @param functionType 鐢ㄦ潵琛ㄧず瀹為檯鍥炶矾鐢ㄤ簬浠�涔� 鍔熻兘锛屽彲鎵╁睍 0-缁х數鍣ㄦ帴鏅�氬紑鍏� 1-缁х數鍣ㄦ帴鐏厜 2-鎻掑骇 - * @param callback - */ - public void setEPDeviceFunctionType(String gatewayOid, String deviceAddr, int epoint, int functionType, ZigbeeCallBack callback) { - JsonObject jObject = new JsonObject(); - jObject.addProperty("DeviceAddr", deviceAddr); - jObject.addProperty("Epoint", epoint); - jObject.addProperty(Cluster_ID, 0); - jObject.addProperty(Command, ZigBee.CommandType.SetEPDeviceFunctionType); - JsonObject data = new JsonObject(); - data.addProperty("FunctionType", functionType); - jObject.add("Data", data); - sendData(gatewayOid, ZigBee.ReplyTopicType.SetEPDeviceFunctionType, jObject.toString(), callback); - } - - - /********闈㈡澘闇囧姩鍔熻兘********/ - /** - * 鑾峰彇绠�绾﹂潰鏉块渿鍔ㄥ姛鑳界殑淇℃伅 - */ - public void getPanelVibrationInfo(String gatewayOid, String deviceAddr, int epoint, String passData, ZigbeeCallBack callback) { -// //缁勮鍙戦�佹暟鎹� -// JsonObject jObject = new JsonObject(); -// jObject.addProperty("DeviceAddr", deviceAddr); -// jObject.addProperty("Epoint", 200); -// jObject.addProperty(Cluster_ID, 64513); -// jObject.addProperty(Command, 0); -// JsonObject data = new JsonObject(); -// data.addProperty("PassData", "050108110101"); -// jObject.add("Data", data); -// sendClientDataPassthrough(device, jObject.toString(), "0802", 18, 6, null, callback); -// sendClientDataPassthrough(gatewayOid,deviceAddr,epoint,passData,callback); - - } - - /** - * 璁剧疆绠�绾﹂潰鏉块渿鍔ㄥ姛鑳界殑淇℃伅 - * - * @param device - * @param deviceAddr - * @param panelVibrationBean - * @param callback - */ - public void setPanelVibrationInfo(String device, String deviceAddr, PanelVibrationBean panelVibrationBean, ZigbeeCallBack callback) { -// String passData = "0800081104"; -// passData += panelVibrationBean.getIsEnable() ? "01" : "00"; -//// passData += Convert.ToString(panelVibrationBean.getStrength(), 16).PadLeft(2, '0'); -//// String time = Convert.ToString(panelVibrationBean.getTime(), 16).PadLeft(4, '0'); -//// //浣庝綅鍦ㄥ墠锛岄珮浣嶅湪鍚� -//// passData += time.Substring(2, 2); -//// passData += time.Substring(0, 2); -// -//// var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; -//// var data = new Newtonsoft.Json.Linq.JObject { { "PassData", passData } }; -//// jObject.Add("Data", data); -// -// JsonObject jObject = new JsonObject(); -// jObject.addProperty("DeviceAddr", deviceAddr); -// jObject.addProperty("Epoint", 200); -// jObject.addProperty(Cluster_ID, 64513); -// jObject.addProperty(Command, 0); -// JsonObject data = new JsonObject(); -// data.addProperty("PassData", passData); -// jObject.add("Data", data); -// -// sendClientDataPassthrough(device, jObject.toString(), "0002", 16, 6, null, callback); - } - - - /** - * 寮�鍏虫帶鍒�(浠呯敤浜巆luster=6鐨勮澶囷級 璁惧鏀寔cluster=6鐨勮澶囨墠鑳借皟鐢ㄨ鎺ュ彛 - * - * @param command 0:鍏抽棴 1:鎵撳紑 2:鍙栧弽 - */ - public void switchControl(String gatewayOid, int command, ZBDeviceBean deviceBean) { - JsonObject jObject = new JsonObject(); - jObject.addProperty("DeviceAddr", deviceBean.getDeviceAddr()); - jObject.addProperty("Epoint", deviceBean.getEpoint()); - jObject.addProperty(Cluster_ID, 6); - jObject.addProperty(Command, command); - jObject.addProperty("SendMode", 2); - sendData(gatewayOid, "", jObject.toString(), null); - } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/bean/PanelVibrationBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/bean/PanelVibrationBean.java deleted file mode 100644 index 11b6f86..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/bean/PanelVibrationBean.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.hdl.sdk.link.zigbee.bean; - -import java.io.Serializable; - -/** - * Created by jlchen on 12/17/21. - */ -public class PanelVibrationBean implements Serializable { - - private Boolean isEnable;//闇囧姩浣胯兘 - private int strength;//闇囧姩寮哄害(鍗佽繘鍒�) - private int time;//闇囧姩鏃堕棿(鍗佽繘鍒�) - - public Boolean getIsEnable() { - return isEnable; - } - - public void setIsEnable(Boolean enable) { - isEnable = enable; - } - - public int getStrength() { - return strength; - } - - public void setStrength(int strength) { - this.strength = strength; - } - - public int getTime() { - return time; - } - - public void setTime(int time) { - this.time = time; - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/bean/TimeDataBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/bean/TimeDataBean.java deleted file mode 100644 index 634c3ab..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/bean/TimeDataBean.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hdl.sdk.link.zigbee.bean; - -/** - * Created by jlchen on 12/16/21. - */ -public class TimeDataBean { - - private int time;//0-255 - - public TimeDataBean(int time) { - this.time = time; - } - - public int getTime() { - return time; - } - - public void setTime(int time) { - this.time = time; - } -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/bean/ZBBaseSendBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/bean/ZBBaseSendBean.java deleted file mode 100644 index 814b610..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/bean/ZBBaseSendBean.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.hdl.sdk.link.zigbee.bean; - - -/** - * Created by jlchen on 12/16/21. - */ -public class ZBBaseSendBean<T> { - private int Cluster_ID;//绨� id - private int Command;//鎿嶄綔鐮� - private T data;//鏁版嵁 - - public ZBBaseSendBean(int cluster_ID, int command, T data) { - Cluster_ID = cluster_ID; - Command = command; - this.data = data; - } - - public int getCluster_ID() { - return Cluster_ID; - } - - public void setCluster_ID(int cluster_ID) { - Cluster_ID = cluster_ID; - } - - public int getCommand() { - return Command; - } - - public void setCommand(int command) { - Command = command; - } - - public T getData() { - return data; - } - - public void setData(T data) { - this.data = data; - } - -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/bean/ZBDeviceBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/bean/ZBDeviceBean.java deleted file mode 100644 index 1536506..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/bean/ZBDeviceBean.java +++ /dev/null @@ -1,565 +0,0 @@ -package com.hdl.sdk.link.zigbee.bean; - -import androidx.annotation.NonNull; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by jlchen on 12/29/21. - * 鎼滅储ZigBee璁惧鍥炶矾鍥炲 - */ -public class ZBDeviceBean implements Serializable { - /// <summary> - /// 瀹為檯鐨勮澶噄d - /// <para>258:color dimmable light,璋冨叧鐏� </para> - /// <para>10:Door lock,闂ㄩ攣</para> - /// <para>514:Window covering device,绐楀笜</para> - /// <para>515:Window covering controller锛岀獥甯樻帶鍒跺櫒</para> - /// <para>769:Thermostat,鎭掓俯闈㈡澘/绌鸿皟</para> - /// <para>770:Temperature Sensor,娓╁害浼犳劅鍣�</para> - /// <para>775:Temperature Sensor,婀垮害浼犳劅鍣�</para> - /// <para>262:Light sensor,鍏夌収浼犳劅鍣�</para> - /// <para>1026:sensor,浼犳劅鍣紝鍏蜂綋绫诲瀷鐨勪紶鎰熷櫒DeviceType鏉ュ尯鍒�</para> - /// </summary> - private int Device_ID; - /// MAC鍦板潃 - private String DeviceAddr; - //璁惧绔彛鍙� - //鍜宮ac鍦板潃鍏卞悓鏍囪瘑鍞竴鐨剒igbee璁惧 - //鏁板�艰寖鍥�0-255 - //濡傛灉鏃犺澶囪瀛楁涓嶅瓨鍦� - private int Epoint; - //杩斿洖鍏ョ綉璁惧淇℃伅 - private int Data_ID; - //璁惧璇︾粏淇℃伅 - private ZBDataBean Data; - //鑷畾涔夋坊鍔犲瓧娈� 鍙兘鏄痮id锛屽彲鑳芥槸缃戝叧Id锛屽彲鑳芥槸mac - private String gatewayMac; - - /** - * 妯℃澘鍖归厤鏍囪 wxr 鑷畾涔� 2022-02-23 16:09:44 - */ - private boolean templateSettingFlag = false; - public boolean isTemplateSettingFlag() { - return templateSettingFlag; - } - - public void setTemplateSettingFlag(boolean templateSettingFlag) { - this.templateSettingFlag = templateSettingFlag; - } - private String templateAddr ; - - private String linkSid; - private String linkSpk; - private String linkOid; - private String linkName; - - public ZBDeviceBean() { - } - - public ZBDeviceBean(String linkSid, String linkSpk, String linkOid, String linkName) { - this.linkSid = linkSid; - this.linkSpk = linkSpk; - this.linkOid = linkOid; - this.linkName = linkName; - } - - public String getLinkSid() { - return linkSid == null ? "" : linkSid; - } - - public void setLinkSid(@NonNull String linkSid) { - this.linkSid = linkSid; - } - - public String getLinkSpk() { - return linkSpk == null ? "" : linkSpk; - } - - public void setLinkSpk(@NonNull String linkSpk) { - this.linkSpk = linkSpk; - } - - public String getLinkOid() { - return linkOid == null ? "" : linkOid; - } - - public void setLinkOid(@NonNull String linkOid) { - this.linkOid = linkOid; - } - - public String getLinkName() { - return linkName == null ? "" : linkName; - } - - public void setLinkName(@NonNull String linkName) { - this.linkName = linkName; - } - - public String getTemplateAddr() { - return templateAddr == null ? "" : templateAddr; - } - - public void setTemplateAddr(String templateAddr) { - this.templateAddr = templateAddr; - } - - @NonNull - public String getGatewayMac() { - return gatewayMac == null ? "" : gatewayMac; - } - - public void setGatewayMac(@NonNull String gatewayMac) { - this.gatewayMac = gatewayMac; - } - - public int getDevice_ID() { - return Device_ID; - } - - public void setDevice_ID(int Device_ID) { - this.Device_ID = Device_ID; - } - - @NonNull - public String getDeviceAddr() { - return DeviceAddr == null ? "" : DeviceAddr; - } - - public void setDeviceAddr(@NonNull String DeviceAddr) { - this.DeviceAddr = DeviceAddr; - } - - public int getEpoint() { - return Epoint; - } - - public void setEpoint(int Epoint) { - this.Epoint = Epoint; - } - - public int getData_ID() { - return Data_ID; - } - - public void setData_ID(int Data_ID) { - this.Data_ID = Data_ID; - } - - - - public ZBDataBean getData() { - if(Data == null){ - Data = new ZBDataBean(); - } - return Data; - } - - public void setData(ZBDataBean Data) { - this.Data = Data; - } - - /** - * 璁惧璇︾粏淇℃伅 - */ - public static class ZBDataBean implements Serializable{ - private int TotalNum;//鍏ョ綉璁惧鎬绘暟銆傜瓑浜�0鏃讹紝琛ㄧず娌℃湁璁惧淇℃伅锛屼笅闈㈠瓧娈靛皢涓嶅瓨鍦ㄣ�� - private int DeviceNum;//鏍囪瘑褰撳墠璁惧鏄彂閫佺殑鏄鍑犱釜璁惧銆侱eviceNum浠�1寮�濮嬫瘡鍙戦�佷竴涓澶囦俊鎭紝涓嬩竴涓澶囦俊鎭殑DeviceNum灏嗗姞1銆傜洿鍒癉eviceNum绛変簬TotalNum璇存槑鎵�鏈夎澶囦俊鎭彂閫佸畬姣� - private int JoinTime;//鍏ョ綉鐨剈tc鏃堕棿鎴� - private int ZigbeeType;//1:璺敱鍣ㄨ澶� 2锛氱粓绔澶囷紝鐢垫睜璁惧 - private int NwkAddr;//璁惧缃戠粶鍦板潃 - private int DeviceType;//璇ュ瓧娈典富瑕侀拡瀵笽AS瀹夐槻璁惧璁剧珛銆傛墍鏈塈AS瀹夐槻璁惧鍏辩敤涓�涓狣eviceID涓�1026銆傛墍浠ヨ鍖哄垎瀛愯澶囩被鍨嬶紝闇�瑕佽瀛楁銆� - //鐢ㄤ簬鍒ゆ柇璁惧鐨剒igbee鍗忚鐗堟湰銆�49246锛歓LL1.0鏍囧噯璁惧銆�260锛� ZHA1.2鏍囧噯璁惧銆� Z3.0鏍囧噯璁惧銆� - // 41440锛歓GP3.0鏍囧噯璁惧銆�265锛歓SE1.4鏍囧噯璁惧銆� - private int Profile; - //璁惧mac鍚嶇О - private String MacName; - //璁惧鍚� - private String DeviceName; - //0锛氳澶囦笉鍦ㄧ嚎 1锛氳澶囧湪绾� - private int IsOnline; - //杈撳叆绨囧垪琛� - //绔偣鍥炶矾鑷韩鎷ユ湁澶氬皯鍔熻兘锛屽彲浠ヨ鎺у埗锛涜鎺у姛鑳� - //鍙傝�儂igbee鑱旂洘鏂囨。 - private List<InClusterListBean> InClusterList; - //杈撳嚭绨囧垪琛� - //绔偣鍥炶矾鍙互鎺у埗鍏朵粬璁惧澶氬皯鍔熻兘锛涙帶鍒跺姛鑳� - //鍙傝�儂igbee鑱旂洘鏂囨。 - private List<OutClusterListBean> OutClusterList; - //鐢ㄤ簬璁板綍璁惧鏈�鏂颁笂鎶ョ殑灞炴�х姸鎬佷俊鎭�傛渶澶ф敮鎸佽褰�16涓睘鎬х姸鎬侊紝涓斿彧璁板綍灞炴�у�奸暱搴︿笉澶т簬4瀛楄妭鐨勬暟鎹�� - private List<AttributeStatusBean> AttributeStatus; - //褰撳墠杩愯绋嬪簭鐗堟湰淇℃伅 - private int ImgVersion; - //褰撳墠闀滃儚绫诲瀷id - private int ImgTypeId; - //纭欢鐗堟湰 - private int HwVersion; - //椹卞姩浠g爜銆備负0鏃讹紝琛ㄧずzigbee鍗忚皟鍣ㄨ澶囥�傚叾浠栧�艰〃绀轰负铏氭嫙椹卞姩璁惧 - private int DriveCode; - //璁惧鎵�鍦ㄧ綉鍏崇殑缃戝叧id - private String GwId; - //鎵�鏈夋寚瀹歝luster鏄惁閮藉凡缁忔垚鍔熺粦瀹氬崗璋冨櫒 - //0锛氭湭瀹屽叏缁戝畾 - //1锛氬凡缁忕粦瀹� - private int ClusterBindZbSuccess; - //鏄惁鑾峰彇鎵�鏈夐粯璁ょ粦瀹氫俊鎭� - //0锛氬惁 - //1锛氭槸 - private int IsGetAllDefaultBind; - //鍒堕�犲晢鍚嶅瓧 - private String ManufacturerName; - //璁惧鍨嬪彿 - private String ModelIdentifier; - //浜у搧鐮� 搴忓垪鍙� - private String ProductCode; - //鐢ㄦ潵琛ㄧず瀹為檯鍥炶矾鐢ㄤ簬浠�涔堝姛鑳斤紝鍙墿灞� - //0-缁х數鍣ㄦ帴鏅�氬紑鍏� - //1-缁х數鍣ㄦ帴鐏厜 - //鎻掑骇 - private String FunctionType; - - public int getTotalNum() { - return TotalNum; - } - - public void setTotalNum(int TotalNum) { - this.TotalNum = TotalNum; - } - - public int getDeviceNum() { - return DeviceNum; - } - - public void setDeviceNum(int DeviceNum) { - this.DeviceNum = DeviceNum; - } - - public int getJoinTime() { - return JoinTime; - } - - public void setJoinTime(int JoinTime) { - this.JoinTime = JoinTime; - } - - public int getZigbeeType() { - return ZigbeeType; - } - - public void setZigbeeType(int ZigbeeType) { - this.ZigbeeType = ZigbeeType; - } - - public int getNwkAddr() { - return NwkAddr; - } - - public void setNwkAddr(int NwkAddr) { - this.NwkAddr = NwkAddr; - } - - public int getDeviceType() { - return DeviceType; - } - - public void setDeviceType(int DeviceType) { - this.DeviceType = DeviceType; - } - - public int getProfile() { - return Profile; - } - - public void setProfile(int Profile) { - this.Profile = Profile; - } - - @NonNull - public String getMacName() { - return MacName == null ? "" : MacName; - } - - public void setMacName(@NonNull String MacName) { - this.MacName = MacName; - } - - @NonNull - public String getDeviceName() { - return DeviceName == null ? "" : DeviceName; - } - - public void setDeviceName(@NonNull String DeviceName) { - this.DeviceName = DeviceName; - } - - public int getIsOnline() { - return IsOnline; - } - - public void setIsOnline(int IsOnline) { - this.IsOnline = IsOnline; - } - - @NonNull - public List<InClusterListBean> getInClusterList() { - if (InClusterList == null) { - return new ArrayList<>(); - } - return InClusterList; - } - - public void setInClusterList(@NonNull List<InClusterListBean> InClusterList) { - this.InClusterList = InClusterList; - } - - @NonNull - public List<OutClusterListBean> getOutClusterList() { - if (OutClusterList == null) { - return new ArrayList<>(); - } - return OutClusterList; - } - - public void setOutClusterList(@NonNull List<OutClusterListBean> OutClusterList) { - this.OutClusterList = OutClusterList; - } - - @NonNull - public List<AttributeStatusBean> getAttributeStatus() { - if (AttributeStatus == null) { - return new ArrayList<>(); - } - return AttributeStatus; - } - - public void setAttributeStatus(@NonNull List<AttributeStatusBean> AttributeStatus) { - this.AttributeStatus = AttributeStatus; - } - - public int getImgVersion() { - return ImgVersion; - } - - public void setImgVersion(int ImgVersion) { - this.ImgVersion = ImgVersion; - } - - public int getImgTypeId() { - return ImgTypeId; - } - - public void setImgTypeId(int ImgTypeId) { - this.ImgTypeId = ImgTypeId; - } - - public int getHwVersion() { - return HwVersion; - } - - public void setHwVersion(int HwVersion) { - this.HwVersion = HwVersion; - } - - public int getDriveCode() { - return DriveCode; - } - - public void setDriveCode(int DriveCode) { - this.DriveCode = DriveCode; - } - - @NonNull - public String getGwId() { - return GwId == null ? "" : GwId; - } - - public void setGwId(@NonNull String GwId) { - this.GwId = GwId; - } - - public int getClusterBindZbSuccess() { - return ClusterBindZbSuccess; - } - - public void setClusterBindZbSuccess(int ClusterBindZbSuccess) { - this.ClusterBindZbSuccess = ClusterBindZbSuccess; - } - - public int getIsGetAllDefaultBind() { - return IsGetAllDefaultBind; - } - - public void setIsGetAllDefaultBind(int IsGetAllDefaultBind) { - this.IsGetAllDefaultBind = IsGetAllDefaultBind; - } - - @NonNull - public String getManufacturerName() { - return ManufacturerName == null ? "" : ManufacturerName; - } - - public void setManufacturerName(@NonNull String ManufacturerName) { - this.ManufacturerName = ManufacturerName; - } - - @NonNull - public String getModelIdentifier() { - return ModelIdentifier == null ? "" : ModelIdentifier; - } - - public void setModelIdentifier(@NonNull String ModelIdentifier) { - this.ModelIdentifier = ModelIdentifier; - } - - @NonNull - public String getProductCode() { - return ProductCode == null ? "" : ProductCode; - } - - public void setProductCode(@NonNull String ProductCode) { - this.ProductCode = ProductCode; - } - - public String getFunctionType() { - return FunctionType; - } - - public void setFunctionType(String FunctionType) { - this.FunctionType = FunctionType; - } - - /** - * 杈撳叆绨� - */ - public static class InClusterListBean implements Serializable{ - /// <summary> - /// 璁惧鏀寔鐨勮緭鍏ュ姛鑳� - /// <para>0:Basic,璁惧鏀寔鈥滃熀纭�灞炴�р�� </para> - /// <para>3:Identify,璁惧鏀寔鈥滆瘑鍒姛鑳解��</para> - /// <para>4:Groups,璁惧鏀寔鈥滅粍鍔熻兘鈥�</para> - /// <para>5:Scenes,璁惧鏀寔鈥滃満鏅姛鑳解��</para> - /// <para>6:on/off,璁惧鏀寔鈥滃紑鍏冲姛鑳解��</para> - /// 寮�鍏冲姛鑳界殑璁惧濡傦細璋冨叧鐏�/缁х數鍣�/绐楀笜绛夈�傘�傘�� - /// <para>8:Level Control,璁惧鏀寔鈥滀寒搴﹁皟鑺傚姛鑳解��</para> - /// 浜害璋冭妭鍔熻兘鐨勮澶囧锛氳皟鍏崇伅銆傘�傘�� - /// <para>257:Door Lock,璁惧鏀寔鈥滈棬閿佸姛鑳解��</para> - /// 闂ㄩ攣鍔熻兘鐨勮澶囧锛氶棬閿併�傘�傘�� - /// <para>258:Window Covering,璁惧鏀寔鈥滅獥甯樻帶鍒跺姛鑳解��</para> - /// 绐楀笜鎺у埗鍔熻兘鐨勮澶囧锛氱獥甯�/寮�鍚堝笜/鍗峰笜銆傘�傘�� - /// <para>513:Thermostat,璁惧鏀寔鈥滄亽娓╁櫒鍔熻兘鈥�</para> - /// 鎭掓俯鍣ㄥ姛鑳界殑璁惧濡傦細绌鸿皟銆傘�傘�� - /// <para>768:Color Control,璁惧鏀寔鈥滈鑹茶皟鑺傚姛鑳解��</para> - /// 棰滆壊璋冭妭鍔熻兘鐨勮澶囧锛氳皟鍏夌伅銆傘�傘�� - /// <para>1026:Temperature Measurement,璁惧鏀寔鈥滄俯搴︽祴閲忓姛鑳解��</para> - /// 娓╁害娴嬮噺鍔熻兘鐨勮澶囧锛氭俯搴︿紶鎰熷櫒銆傘�傘�� - /// <para>1029:Relative Humidity Measurement,璁惧鏀寔鈥滄箍搴︽祴閲忓姛鑳解��</para> - /// 婀垮害娴嬮噺鍔熻兘鐨勮澶囧锛氭箍搴︿紶鎰熷櫒銆傘�傘�� - /// <para>1066:Pm2.5 Measurement,璁惧鏀寔鈥減m2.5娴嬮噺鍔熻兘鈥�</para> - /// Pm2.5娴嬮噺鍔熻兘鐨勮澶囧锛歅m2.5浼犳劅鍣ㄣ�傘�傘�� - /// </summary> - private int InCluster; - - public int getInCluster() { - return InCluster; - } - - public void setInCluster(int inCluster) { - this.InCluster = inCluster; - } - } - - /** - * 杈撳嚭绨� - */ - public static class OutClusterListBean implements Serializable{ - /// <summary> - /// 璁惧鏀寔鐨勮緭鍑哄姛鑳� - /// <para>0:Basic,璁惧鏀寔鈥滃熀纭�灞炴�р�� </para> - /// <para>3:Identify,璁惧鏀寔鈥滆瘑鍒姛鑳解��</para> - /// <para>4:Groups,璁惧鏀寔鈥滅粍鍔熻兘鈥�</para> - /// <para>5:Scenes,璁惧鏀寔鈥滃満鏅姛鑳解��</para> - /// <para>6:on/off,璁惧鏀寔鈥滃紑鍏冲姛鑳解��</para> - /// 寮�鍏冲姛鑳界殑璁惧濡傦細璋冨叧鐏�/缁х數鍣�/绐楀笜绛夈�傘�傘�� - /// <para>8:Level Control,璁惧鏀寔鈥滀寒搴﹁皟鑺傚姛鑳解��</para> - /// 浜害璋冭妭鍔熻兘鐨勮澶囧锛氳皟鍏崇伅銆傘�傘�� - /// <para>257:Door Lock,璁惧鏀寔鈥滈棬閿佸姛鑳解��</para> - /// 闂ㄩ攣鍔熻兘鐨勮澶囧锛氶棬閿併�傘�傘�� - /// <para>258:Window Covering,璁惧鏀寔鈥滅獥甯樻帶鍒跺姛鑳解��</para> - /// 绐楀笜鎺у埗鍔熻兘鐨勮澶囧锛氱獥甯�/寮�鍚堝笜/鍗峰笜銆傘�傘�� - /// <para>513:Thermostat,璁惧鏀寔鈥滄亽娓╁櫒鍔熻兘鈥�</para> - /// 鎭掓俯鍣ㄥ姛鑳界殑璁惧濡傦細绌鸿皟銆傘�傘�� - /// <para>768:Color Control,璁惧鏀寔鈥滈鑹茶皟鑺傚姛鑳解��</para> - /// 棰滆壊璋冭妭鍔熻兘鐨勮澶囧锛氳皟鍏夌伅銆傘�傘�� - /// <para>1026:Temperature Measurement,璁惧鏀寔鈥滄俯搴︽祴閲忓姛鑳解��</para> - /// 娓╁害娴嬮噺鍔熻兘鐨勮澶囧锛氭俯搴︿紶鎰熷櫒銆傘�傘�� - /// <para>1029:Relative Humidity Measurement,璁惧鏀寔鈥滄箍搴︽祴閲忓姛鑳解��</para> - /// 婀垮害娴嬮噺鍔熻兘鐨勮澶囧锛氭箍搴︿紶鎰熷櫒銆傘�傘�� - /// </summary> - private int OutCluster; - - public int getOutCluster() { - return OutCluster; - } - - public void setOutCluster(int outCluster) { - this.OutCluster = outCluster; - } - } - - /** - * 璁惧鏈�鏂颁笂鎶ョ殑灞炴�х姸鎬佷俊鎭� - */ - public static class AttributeStatusBean implements Serializable{ - - /// <summary> - /// 灞炴�х皣id - /// </summary> - private int ClusterId; - /// <summary> - /// 灞炴�d - /// </summary> - private int AttributeId; - /// <summary> - /// 灞炴�у�硷紝杩欎釜涓滆タ涓嶉渶瑕佷粈涔堥珮浣嶅湪鍚庝綆浣嶅湪鍓�,瀹冨凡缁忔槸杞负浜�10杩涘埗 - /// </summary> - private int AttributeData; - /// <summary> - /// 灞炴�х姸鎬佹渶鍚庢洿鏂扮殑utc鏃堕棿鎴� - /// </summary> - private int ReportTime; - - public int getClusterId() { - return ClusterId; - } - - public void setClusterId(int clusterId) { - this.ClusterId = ClusterId; - } - - public int getAttributeId() { - return AttributeId; - } - - public void setAttributeId(int AttributeId) { - this.AttributeId = AttributeId; - } - - public int getAttributeData() { - return AttributeData; - } - - public void setAttributeData(int attributeData) { - this.AttributeData = AttributeData; - } - - public int getReportTime() { - return ReportTime; - } - - public void setReportTime(int ReportTime) { - this.ReportTime = ReportTime; - } - } - } -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/bean/ZBDeviceModuleBean.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/bean/ZBDeviceModuleBean.java deleted file mode 100644 index ea4af5e..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/bean/ZBDeviceModuleBean.java +++ /dev/null @@ -1,32 +0,0 @@ -//package com.hdl.sdk.link.zigbee.bean; -// -//import androidx.annotation.NonNull; -// -//import java.util.ArrayList; -//import java.util.List; -// -///** -// * Created by jlchen on 12/29/21. -// * 鍘熺敓ZigBee璁炬ā鍧� -// */ -//public class ZBDeviceModuleBean { -// -// //鍘熺敓ZigBee璁惧鍥炶矾鍒楄〃 -// private List<ZBDeviceBean> deviceLoopList = new ArrayList<>(); -// -// public ZBDeviceModuleBean(List<ZBDeviceBean> deviceLoopList) { -// this.deviceLoopList = deviceLoopList; -// } -// -// @NonNull -// public List<ZBDeviceBean> getDeviceLoopList() { -// if (deviceLoopList == null) { -// return new ArrayList<>(); -// } -// return deviceLoopList; -// } -// -// public void setDeviceLoopList(@NonNull List<ZBDeviceBean> deviceLoopList) { -// this.deviceLoopList = deviceLoopList; -// } -//} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/callback/HDLZBCallBack.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/callback/HDLZBCallBack.java deleted file mode 100644 index 7c21660..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/callback/HDLZBCallBack.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hdl.sdk.link.zigbee.callback; - -/** - * Created by jlchen on 12/16/21. - */ -public interface HDLZBCallBack { - - void onSuccess(String msg); - - void onError(String error); - -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/callback/ZBDeviceListCallBack.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/callback/ZBDeviceListCallBack.java deleted file mode 100644 index 2bdec6b..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/callback/ZBDeviceListCallBack.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.hdl.sdk.link.zigbee.callback; - -import com.hdl.sdk.link.core.callback.BaseCallBack; -import com.hdl.sdk.link.zigbee.bean.ZBDeviceBean; - -import java.util.List; - -/** - * Created by jlchen on 12/29/21. - */ -public interface ZBDeviceListCallBack extends BaseCallBack { - void onSuccess(List<ZBDeviceBean> list); -} diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/config/ZBDeviceType.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/config/ZBDeviceType.java deleted file mode 100644 index 2be9bda..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/config/ZBDeviceType.java +++ /dev/null @@ -1,161 +0,0 @@ -package com.hdl.sdk.link.zigbee.config; - -/** - * Created by jlchen on 12/29/21. - */ - -import androidx.annotation.IntDef; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * ZigBee璁惧绫诲瀷 - * device_ID 瀵瑰簲鐨勮澶囨灇涓� - */ -@IntDef({ZBDeviceType.UnKown}) -@Retention(RetentionPolicy.SOURCE) -public @interface ZBDeviceType{ - int UnKown = 0x9999; - int ZbGateway = 0x9998; - /// <summary> - /// 骞茬粨鐐� - /// <para>璁惧ID涓�0</para> - /// <para>瀹氫箟瀵硅薄锛歅anel</para> - /// </summary> - int OnOffSwitch = 0; - /// <summary> - /// 浜害鎺у埗寮�鍏� - /// <para>璁惧ID涓�2</para> - /// <para>瀹氫箟瀵硅薄 LevelControlSwitch</para> - /// </summary> - int LevelControlSwitch = 1; - /// <summary> - /// 缁х數鍣� - /// <para>璁惧ID涓�2</para> - /// <para>瀹氫箟瀵硅薄锛歍oggleLight</para> - /// </summary> - int OnOffOutput = 2; - /// <summary> - /// 闂ㄩ攣 - /// <para>璁惧ID涓�10</para> - /// <para>瀹氫箟瀵硅薄锛欴oorLock</para> - /// </summary> - int DoorLock = 10; - /// <summary> - /// 璁惧ID涓�257鐨勮澶� - /// <para>璋冨厜鐏細鏀寔浜害</para> - /// <para>璋冨厜璁惧</para> - /// </summary> - int DimmableLight = 257; - /// <summary> - /// 璁惧ID涓�258鐨勮澶� - /// <para>鑹叉俯鐏�</para> - /// <para>瀹氫箟瀵硅薄锛欳olorTemperatureLight</para> - /// </summary> - int ColorTemperatureLight = 258; - /// <summary> - /// 璋冨厜鍣ㄦ帶鍒跺櫒 - /// <para>璁惧ID涓�260</para> - /// <para>瀹氫箟瀵硅薄 DimmerSwitch</para> - /// </summary> - int DimmerSwitch = 260; - /// <summary> - /// 棰滆壊璋冨厜鐏紑鍏� - /// <para>璁惧ID涓�261</para> - /// <para>瀹氫箟瀵硅薄 LevelControlSwitch</para> - /// </summary> - int ColorDimmerSwitch = 261; - /// <summary> - /// 绐楀笜璁惧ID - /// <para>Rollershade:鍗峰笜</para> - /// </summary> - int WindowCoveringDevice = 514; - /// <summary> - /// 绐楀笜鎺у埗鍣ㄨ澶嘔D - /// <para>CurtainController:绐楀笜鎺у埗鍣�</para> - /// </summary> - int WindowCoveringController = 515; - /// <summary> - /// 璁惧ID涓�528鐨勮澶� - /// <para>棰滆壊璋冨厜鐏細鏀寔浜害/鑹插害/楗卞拰搴�</para> - /// <para>璋冨厜璁惧</para> - /// <para>瀹氫箟瀵硅薄锛欳olorDimmableLight</para> - /// </summary> - int ColorDimmableLight = 528; - /// <summary> - /// 鎭掓俯鍣� - /// <para>璁惧ID涓�769</para> - /// <para>瀹氫箟瀵硅薄锛欰C</para> - /// </summary> - int Thermostat = 769; - /// <summary> - /// <para>娓╂箍搴︿紶鎰熷櫒</para> - /// <para>璁惧ID涓�770</para> - /// <para>瀹氫箟瀵硅薄锛歍emperatureSensor</para> - /// <para>娉ㄦ剰瀹冧笌HumiditySensor涓嶄竴鏍�;瀹冨叿浣撴槸娓╁害杩樻槸婀垮害;闇�瑕佸彂鍛戒护鍘昏鍙�</para> - /// </summary> - int TemperatureSensor = 770; - /// <summary> - /// <para>PM2.5浼犳劅鍣�</para> - /// <para>璁惧ID涓�777</para> - /// <para>瀹氫箟瀵硅薄锛歅MSensor</para> - /// </summary> - int PMSensor = 777; - /// <summary> - /// 瀹夐槻璁惧 - /// <para>璁惧ID涓�1026鐨勮澶�</para> - /// <para>瀹氫箟瀵硅薄锛欼ASZone</para> - /// </summary> - int IASZone = 1026; - /// <summary> - /// 铚傞福鍣� - /// <para>璁惧ID涓�1027鐨勮澶�</para> - /// <para>瀹氫箟瀵硅薄锛欱uzzer</para> - /// </summary> - int Buzzer = 1027; - /// <summary> - /// 鎺у埗婧愯澶� - /// <para>璁惧ID涓�0</para> - /// <para>瀹氫箟瀵硅薄锛歅anel</para> - /// </summary> - int OtaPanelDevice = 49152; - /// <summary> - /// 鎺у埗婧愯澶� - /// <para>璁惧ID涓�0</para> - /// <para>瀹氫箟瀵硅薄锛歅anel</para> - /// </summary> - int OtaDevice = 49153; - /// <summary> - /// 绌烘皵寮�鍏� - /// </summary> - int AirSwitch = 53249; - /// <summary> - /// 涓户鍣� - /// </summary> - int Repeater = 53250; - /// 杞崲鍣� - /// <para>璁惧ID涓�53251</para> - /// <para>瀹氫箟瀵硅薄锛歍ransverter</para> - /// </summary> - int Transverter = 0xD003; - /// <summary> - /// <para>鏅捐。鏋�</para> - /// <para>璁惧ID涓�0xD004 </para> - /// <para>瀹氫箟瀵硅薄锛欰irer</para> - /// </summary> - int Airer = 0xD004; - - /// 鏂伴 - /// <para>璁惧ID涓�53504</para> - /// <para>瀹氫箟瀵硅薄锛欶reshAirAC</para> - /// </summary> - int FreshAir = 0xD100; - - /// <summary> - /// <para>婀垮害浼犳劅鍣�</para> - /// <para>璁惧ID涓�53760</para> - /// <para>瀹氫箟瀵硅薄锛欻umiditySensor</para> - /// <para>娉ㄦ剰瀹冧笌TemperatureSensor涓嶄竴鏍�;杩欎釜id瀹氭浜嗗氨鏄箍搴︿紶鎰熷櫒</para> - /// </summary> - int HumiditySensor = 0xD200; -} \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/config/ZigBee.java b/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/config/ZigBee.java deleted file mode 100644 index b4426de..0000000 --- a/HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/zigbee/config/ZigBee.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.hdl.sdk.link.zigbee.config; - -import androidx.annotation.IntDef; -import androidx.annotation.StringDef; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Created by jlchen on 12/16/21. - * ZigBee鍘熺敓鍗忚鎺у埗鐮佺浉鍏� - */ -public class ZigBee { - - - -// /** -// * 涓婚 -// */ -// @StringDef({}) -// @Retention(RetentionPolicy.SOURCE) -// public @interface TopicType { -// //鍙戦�佹寚浠ゅ埌缃戝叧杩涜瀹氫綅(缃戝叧LED闂儊璇嗗埆) -// String GwLinuxLocate = "GwLinuxLocate"; -// //璁惧鍒楄〃-鑾峰彇鏈湴缃戝叧璁惧 EPDeviceId 鍒楄〃 -// String GetDeviceInfo = "GetDeviceInfo"; -// //鑾峰彇鍏ョ綉璁惧 -// String SearchNewDevice = "SearchNewDevice"; -// //淇敼璁惧绔彛锛堟寜閿級鍚嶇О -// String DeviceRename = "DeviceRename"; -// //璁惧鍒楄〃-璁惧鍒犻櫎锛堜娇璁惧绂荤綉锛� -// String RemoveDevice = "RemoveDevice"; -// //璁惧鎺у埗-鏃� Id-3-identify 瀹氫綅鍔熻兘 -// String Identify = "Identify"; -// //瀵圭鐐瑰洖璺澶囧姛鑳界被鍨嬭繘琛岃缃� -// String SetEPDeviceFunctionType = "Device/SetEPDeviceFunctionType"; -// -// } - - /** - * 鍥炲涓婚 - */ - @StringDef({}) - @Retention(RetentionPolicy.SOURCE) - public @interface ReplyTopicType { - //鍙戦�佹寚浠ゅ埌缃戝叧杩涜瀹氫綅(缃戝叧LED闂儊璇嗗埆) - String GwLinuxLocate = "GwLinuxLocate_Respon"; - //璁惧鍒楄〃-鑾峰彇鏈湴缃戝叧璁惧 EPDeviceId 鍒楄〃 - String GetDeviceInfo = "DeviceInfoRespon"; - //鑾峰彇鍏ョ綉璁惧 - String SearchNewDevice = "Device/SearchNewDevice"; - //淇敼璁惧绔彛锛堟寜閿級鍚嶇О - String DeviceRename = "DeviceRenameRespon"; - //璁惧鍒楄〃-璁惧鍒犻櫎锛堜娇璁惧绂荤綉锛� - String RemoveDevice = "RemoveDeviceRespon"; - //璁惧鎺у埗-鏃� Id-3-identify 瀹氫綅鍔熻兘 - String Identify = "Identify"; - //瀵圭鐐瑰洖璺澶囧姛鑳界被鍨嬭繘琛岃缃� - String SetEPDeviceFunctionType = "Device/SetEPDeviceFunctionType"; - //鏂拌澶囧叆缃� - String DeviceInComingRespon = "DeviceInComingRespon"; - //璁剧疆鍏ョ綉娴佺▼鏂瑰紡 - String SetJoiningModeRespon = "SetJoiningMode_Respon"; - - } - - /** - * 鎺у埗鐮� - */ - @IntDef({CommandType.SearchNewDevice}) - @Retention(RetentionPolicy.SOURCE) - public @interface CommandType { - //鍙戦�佹寚浠ゅ埌缃戝叧杩涜瀹氫綅(缃戝叧LED闂儊璇嗗埆) - int GwLinuxLocate = 85; - //璁惧鍒楄〃-鑾峰彇鏈湴缃戝叧璁惧 EPDeviceId 鍒楄〃 - int GetDeviceInfo = 93; - //鑾峰彇鍏ョ綉璁惧 - int SearchNewDevice = 94; - //淇敼璁惧绔彛锛堟寜閿級鍚嶇О - int DeviceRename = 96; - //璁惧鍒楄〃-璁惧鍒犻櫎锛堜娇璁惧绂荤綉锛� - int RemoveDevice = 99; - //瀵圭鐐瑰洖璺澶囧姛鑳界被鍨嬭繘琛岃缃� - int SetEPDeviceFunctionType = 110; - - } - -} diff --git a/HDLLinkLocalSdk/src/main/res/values-zh/strings_code.xml b/HDLLinkLocalSdk/src/main/res/values-zh/strings_code.xml deleted file mode 100644 index 4cf6a06..0000000 --- a/HDLLinkLocalSdk/src/main/res/values-zh/strings_code.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="HDL_DATA_ERROR">鍙傛暟寮傚父</string> - <string name="HDL_DATA_NULL_ERROR">鍙傛暟涓嶈兘涓虹┖</string> - <string name="HDL_AUTH_ERROR">璁よ瘉澶辫触</string> - <string name="HDL_SEND_ERROR">鍙戦�佸け璐�</string> - <string name="HDL_TIMEOUT_ERROR">瓒呮椂锛岀綉鍏虫棤鍥炲</string> - <string name="HDL_UNAUTHORIZED_ERROR">鏈璇侊紝璇峰厛璁よ瘉</string> - <string name="HDL_AUTH_ERROR_GATEWAY_NOT_REGISTERED">璁よ瘉澶辫触锛岀綉鍏虫湭娉ㄥ唽鍒颁簯绔�</string> - <string name="HDL_SEARCH_GATEWAY_TIMEOUT_ERROR">鎼滅储缃戝叧澶辫触锛岃秴鏃�</string> - <string name="HDL_AUTH_MAC_KEY_ERROR">璁よ瘉澶辫触锛岃MAC瀵瑰簲鐨勮澶囧瘑閽ヤ笉瀛樺湪</string> - <string name="HDL_DATA_PARSING_ERROR">鏁版嵁瑙f瀽寮傚父</string> - <string name="HDL_GET_DEVICE_LIST_ERROR">鑾峰彇璁惧鍒楄〃澶辫触</string> - <string name="HDL_GET_FUNCTION_LIST_ERROR">鑾峰彇鍔熻兘鍒楄〃澶辫触</string> - <string name="HDL_GET_FUNCTION_PROPERTIES_ERROR">鑾峰彇鍔熻兘灞炴�уけ璐�</string> - <string name="HDL_CONTROL_FAILURE_ERROR">鎺у埗澶辫触</string> - <string name="HDL_GET_GATEWAY_FAILURE_ERROR">鑾峰彇缃戝叧鍒楄〃澶辫触</string> - <string name="HDL_GET_Zigbee_FAILURE_ERROR">鍙戦�佽秴鏃讹紝缃戝叧鏃犲搷搴�</string> - <string name="HDL_GATEWAY_NOT_EXIST">缃戝叧涓嶅瓨鍦�</string> - <string name="HDL_GET_Zigbee_DEVICE_LIST_FAILURE_ERROR">鑾峰彇鍘熺敓璁惧鍒楄〃澶辫触</string> - <string name="HDL_MILLIMETER_NOT_EXIST">姣背娉笉瀛樺湪</string> - <string name="HDL_UNKOWN_CODE">鏈煡閿欒</string> - <string name="HDL_APPLICATION_EXCEPTION">绯荤粺寮傚父</string> - <string name="HDL_TOPIC_NOT_RIGHT">涓婚娌℃湁鍖归厤</string> - <string name="HDL_OBJECT_NOT_SUPPORT">瀵硅薄涓嶆敮鎸�</string> - <string name="HDL_GATEWAY_REMOTE_NOT_RESPONSE">缃戝叧鏈湴杩炴帴澶辫触锛岄�氳繃杩滅▼閫氳涓嶅洖澶�</string> - <string name="SUCCESS">鎴愬姛</string> - <string name="HDL_GATEWAY_FOUND_LOCALLY">鏈湴鎵句笉鍒扮綉鍏�</string> -</resources> \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/res/values/arrays-error.xml b/HDLLinkLocalSdk/src/main/res/values/arrays-error.xml deleted file mode 100644 index 0260f1f..0000000 --- a/HDLLinkLocalSdk/src/main/res/values/arrays-error.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string-array name="gateway"></string-array> - <string-array name="cloud"></string-array> - <string-array name="app"></string-array> -</resources> \ No newline at end of file diff --git a/HDLLinkLocalSdk/src/main/res/values/strings_code.xml b/HDLLinkLocalSdk/src/main/res/values/strings_code.xml deleted file mode 100644 index def3c73..0000000 --- a/HDLLinkLocalSdk/src/main/res/values/strings_code.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> -<string name="HDL_DATA_ERROR">Parameter exception</string> -<string name="HDL_DATA_NULL_ERROR">Parameter cannot be empty</string> -<string name="HDL_AUTH_ERROR">Authentication failed</string> -<string name="HDL_SEND_ERROR">fail in send</string> -<string name="HDL_TIMEOUT_ERROR">timeout,gateway no response</string> -<string name="HDL_UNAUTHORIZED_ERROR">Not certified, please authenticate first</string> -<string name="HDL_AUTH_ERROR_GATEWAY_NOT_REGISTERED">Authentication failed. The gateway is not registered to the cloud</string> -<string name="HDL_SEARCH_GATEWAY_TIMEOUT_ERROR">Failed to search gateway, timeout</string> -<string name="HDL_AUTH_MAC_KEY_ERROR">Authentication failed. The device key corresponding to the MAC does not exist</string> -<string name="HDL_DATA_PARSING_ERROR">Data parsing error</string> -<string name="HDL_GET_DEVICE_LIST_ERROR">Failed to get device list</string> -<string name="HDL_GET_FUNCTION_LIST_ERROR">Failed to get function list</string> -<string name="HDL_GET_FUNCTION_PROPERTIES_ERROR">Failed to get function attribute</string> -<string name="HDL_CONTROL_FAILURE_ERROR">Control failure</string> -<string name="HDL_GET_GATEWAY_FAILURE_ERROR">Failed to get gateway list</string> -<string name="HDL_GET_Zigbee_FAILURE_ERROR">Sending timeout, no response from gateway</string> -<string name="HDL_GATEWAY_NOT_EXIST">Gateway does not exist</string> -<string name="HDL_GET_Zigbee_DEVICE_LIST_FAILURE_ERROR">Failed to get the device list</string> -<string name="HDL_MILLIMETER_NOT_EXIST">Millimeter does not exist</string> -<string name="HDL_UNKOWN_CODE">Unkown Error</string> -<string name="HDL_APPLICATION_EXCEPTION">System Exception</string> -<string name="HDL_TOPIC_NOT_RIGHT">Theme does not match</string> -<string name="HDL_OBJECT_NOT_SUPPORT">Object not supported</string> -<string name="HDL_GATEWAY_REMOTE_NOT_RESPONSE">Gateway local connection failed, unable to reply through remote communication</string> -<string name="SUCCESS">success</string> -<string name="HDL_GATEWAY_FOUND_LOCALLY">The gateway cannot be found locally</string> -</resources> \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index c68e838..016ef7e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -123,8 +123,8 @@ //浜岀淮鐮佸簱 implementation project(path: ':third-zxing') //Link鏈湴搴� - implementation project(path: ':HDLLinkLocalSdk') -// implementation project(path: ':HDLLinkPMSdk') + implementation project(path: ':HDLLinkPMSdk') + implementation 'com.hdl.android.link.local.sdk:localsdk:1.0.0' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' diff --git a/settings.gradle b/settings.gradle index 8a951a7..39f477e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,7 +1,7 @@ rootProject.name = "PhotovoltaicDebug" include ':app' include ':third-zxing' -include ':HDLLinkLocalSdk' +//include ':HDLLinkLocalSdk' include ':HDLLinkPMSdk' include ':HDLLog' include ':countrypicker' -- Gitblit v1.8.0