From de72a7843ceb868c89fc11983e315849caa28573 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期五, 05 十一月 2021 13:13:15 +0800
Subject: [PATCH] 2021-11-05 1.可以适配声必可易pro面板的串口485通信测试demo
---
HDL_TTLSDK485/README.md | 10
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlCurtainActivity.java | 325
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSecurity/Parser/SecurityParser.java | 116
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSensor/SensorCtrlBackInfo.java | 26
.idea/misc.xml | 132
HDL_TTLSDK485/proguard-rules.pro | 21
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/SecurityAlarmFeedBackEvent.java | 24
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSecurity/SecurityBackInfo.java | 133
app/src/main/res/layout/activity_main.xml | 106
app/src/main/res/layout/activity_appliances_new.xml | 27
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/SettingActivity.java | 108
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/AddDevicesManuallyNEWActivity.java | 131
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/MCUActivity.java | 690 +
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLWarning/WarningType.java | 139
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmTypeBean.java | 10
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlActivity.java | 1478 +++
app/src/main/res/mipmap-mdpi/ic_item_light_w.png | 0
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Config/Configuration.java | 236
app/src/main/res/mipmap-mdpi/ic_item_light.png | 0
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/RemarkTimes.java | 13
app/src/main/res/mipmap-mdpi/ic_launcher.png | 0
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLLight/LightCtrlBackInfo.java | 98
app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/HDLUtlis.java | 107
HDL_TTLSDK485/libs/armeabi-v7a/libserial_port.so | 0
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLCommonSwitch/CommonSwitchBackInfo.java | 38
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png | 0
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSecurity/SecurityArmingStateBackInfo.java | 24
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlLogicActivity.java | 129
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/SensorActivity.java | 502 +
app/src/test/java/com/hdl/sdk/ttl_sdk/ExampleUnitTest.java | 17
app/src/main/res/layout/activity_ctrl.xml | 160
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/DiscoverNewDevicesEvent.java | 19
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/DeviceStateBean.java | 81
app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/HDLLog.java | 23
gradle/wrapper/gradle-wrapper.properties | 6
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/UpdateRemarkFeedBackEvent.java | 17
app/src/main/res/values/colors.xml | 22
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/MCUConfigurationBean.java | 126
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSensor/DryContactSensorBackEvent.java | 22
app/src/main/res/layout/activity_ctrl_common_switch.xml | 50
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/HDLListener/IMcuOtaListener.java | 24
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/RcuLight.java | 31
app/src/main/res/mipmap-mdpi/ic_item_air_w.png | 0
app/src/main/res/layout/activity_ctrl_air.xml | 155
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLLogic/LogicCtrlBackInfo.java | 49
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlAirHVACActivity.java | 429 +
app/src/main/res/drawable-v24/ic_launcher_foreground.xml | 34
app/src/main/res/mipmap-mdpi/ic_item_logic.png | 0
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLCommand.java | 1546 +++
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/SecurityStateBean.java | 90
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml | 5
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/RcuIpListEvent.java | 16
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/BgmInfoEvent.java | 52
app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeCroe.java | 14
app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/ApkTool.java | 51
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/AppliancesListActivity.java | 186
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/AirFeedBackEvent.java | 27
.idea/encodings.xml | 4
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmCtrlListBean.java | 20
HDL_TTLSDK485/libs/x86/libserial_port.so | 0
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/EventCode.java | 17
gradlew.bat | 84
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlLightActivity.java | 197
app/src/main/res/layout/activity_setting.xml | 59
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmCtrlBean.java | 15
app/src/main/res/mipmap-mdpi/ic_item_air.png | 0
app/src/main/res/layout/list_item_appliances.xml | 74
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/AirHVACBackInfo.java | 136
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/ListRemarks.java | 26
app/src/main/res/layout/activity_ctrl_security.xml | 262
app/build.gradle | 66
app/src/main/res/values/dimens.xml | 23
app/src/main/res/mipmap-mdpi/ic_item_curtain_w.png | 0
app/src/main/res/mipmap-mdpi/ic_item_audio_w.png | 0
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/Crc.java | 188
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/CurtainFeedBackEvent.java | 28
app/src/main/res/layout/activity_zigbee.xml | 109
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/UdpDataBean.java | 12
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/DeviceStateEvent.java | 28
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HandleSearch.java | 560 +
app/src/main/res/layout/activity_ctrl_curtain.xml | 85
.gitignore | 71
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/MainActivity.java | 453 +
app/src/main/res/layout/activity_sensor.xml | 37
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/RCUSaveEvent.java | 17
app/src/main/java/com/hdl/sdk/ttl_sdk/base/BaseActivity.java | 99
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/DevicesInfoEvent.java | 33
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/HetDevicesCtrlEvent.java | 16
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/MCUFeedBackEvent.java | 36
build.gradle | 27
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Parser/DeviceParser.java | 969 ++
HDL_TTLSDK485/.gitignore | 1
settings.gradle | 1
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/AudioInfoEvent.java | 69
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/AddDevicesManuallyActivity.java | 204
app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeCommand.java | 109
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/AirCtrlBackInfo.java | 114
app/src/main/AndroidManifest.xml | 57
app/src/main/res/layout/activity_send_test.xml | 84
app/src/main/res/mipmap-mdpi/ic_item_logic_w.png | 0
app/src/main/res/layout/list_item_device_list.xml | 48
.idea/runConfigurations.xml | 12
app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/HDLWarningType.java | 136
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java | 448 +
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/LightFeedBackEvent.java | 26
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/AppliancesInfoEvent.java | 21
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlAirActivity.java | 754 +
app/src/main/res/layout/activity_mcu.xml | 271
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLLogic/LogicMode.java | 29
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLTtlSdk.java | 37
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSensor/SensorStateBackInfo.java | 21
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/SceneInfoEvent.java | 33
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlSecurityActivity.java | 318
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/HDLAudio.java | 394
HDL_TTLSDK485/src/main/AndroidManifest.xml | 19
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/AirHVACFeedBackEvent.java | 24
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlCommonSwitchActivity.java | 182
.idea/jarRepositories.xml | 25
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Utils/HDLUtlis/HDLStringUtils.java | 281
app/src/main/res/layout/activity_add_devices_manually.xml | 105
app/src/main/res/mipmap-mdpi/arrow_more.png | 0
app/src/main/res/values/strings.xml | 17
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/LogicFeedBackEvent.java | 28
app/src/main/res/layout/activity_add_devices_manually_new.xml | 103
HDL_TTLSDK485/src/main/res/values/strings.xml | 4
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmModeBean.java | 26
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/DevicesData.java | 59
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml | 5
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmStatusBean.java | 10
app/src/main/res/layout/activity_appliances.xml | 24
app/src/main/res/mipmap-mdpi/ic_launcher_round.png | 0
.idea/compiler.xml | 6
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/CommonSwitchStateBackEvent.java | 27
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Utils/HDLUtlis/HDLUtlis.java | 92
app/proguard-rules.pro | 21
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/MCUCrc.java | 58
app/src/main/java/com/hdl/sdk/ttl_sdk/HDLApplication.java | 34
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLCurtain/CurtainCtrlBackInfo.java | 76
app/src/main/res/values/styles.xml | 19
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/SendTestActivity.java | 161
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlAudioActivity.java | 289
app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigbeeActivity2.java | 631 +
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Config/MCUConstants.java | 54
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/ZigbeeActivity.java | 384
HDL_TTLSDK485/build.gradle | 92
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/ThirdPartyBgmInfoEvent.java | 14
app/src/main/java/com/hdl/sdk/ttl_sdk/adapter/HDLMainListAdapter.java | 85
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/SecurityArmingFeedBackEvent.java | 35
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmSourceBean.java | 7
app/src/main/res/drawable/hdl_btn_click_effect.xml | 6
app/src/main/res/layout/hdl_toolbar_top_view_b.xml | 82
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLCurtain/Parser/CurtainCtrlParser.java | 42
gradle.properties | 13
app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeDataBean.java | 11
HDL_TTLSDK485/src/main/java/android/serialport/api/SerialPortFinder.java | 127
app/src/main/res/drawable/hdl_item_selector_effect.xml | 5
app/src/main/res/mipmap-xxhdpi/ic_launcher.png | 0
app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/HDLUriUtils.java | 143
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLDeviceManager.java | 3156 +++++++
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/WarningInfoEvent.java | 17
app/src/main/res/mipmap-hdpi/ic_launcher_round.png | 0
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/DeviceFeedbackEvent.java | 18
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmVolBean.java | 12
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Utils/SPUtils/SPUtils.java | 109
app/src/main/res/mipmap-mdpi/ic_open_bin.png | 0
app/libs/HDL_TTLSDK-release.aar | 0
gradlew | 172
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmCtrlSongBean.java | 11
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/RcuCurtain.java | 31
app/src/main/res/mipmap-mdpi/ic_search.png | 0
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png | 0
app/src/main/res/layout/activity_ctrl_light.xml | 44
app/src/main/java/com/hdl/sdk/ttl_sdk/activity/BootComplete.java | 26
app/src/main/res/layout/activity_ctrl_air_hvac.xml | 78
app/src/main/res/mipmap-hdpi/ic_launcher.png | 0
HDL_TTLSDK485/src/main/java/android/serialport/api/SerialPort.java | 91
README.md | 6
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLSerialPortCore.java | 875 ++
app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeCtrl.java | 14
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/AppliancesInfo.java | 244
.idea/codeStyles/codeStyleConfig.xml | 5
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/CommonSwitchCtrlBackEvent.java | 27
app/src/main/res/mipmap-mdpi/ic_item_audio.png | 0
app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeCtrl2.java | 20
app/src/main/res/mipmap-mdpi/ic_item_curtain.png | 0
app/src/main/res/mipmap-xhdpi/ic_launcher.png | 0
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png | 0
gradle/wrapper/gradle-wrapper.jar | 0
app/src/main/res/drawable/ic_launcher_background.xml | 170
app/src/main/java/com/hdl/sdk/ttl_sdk/adapter/HDLAppliancesListAdapter.java | 128
app/src/main/res/layout/activity_audio.xml | 137
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/Config/HDLApConfig.java | 73
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLSerialPortCoreOld.java | 797 +
app/src/main/res/drawable/hdl_shape_item_select.xml | 13
app/.gitignore | 1
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png | 0
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/MCUDataBean.java | 34
app/src/main/res/mipmap-mdpi/ic_top_back.png | 0
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/SearchCountBean.java | 13
.idea/codeStyles/Project.xml | 116
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/MideaDevicesCtrlEvent.java | 16
app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/MyAppInfo.java | 37
HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Utils/LogUtils/HDLLog.java | 34
app/src/androidTest/java/com/hdl/sdk/ttl_sdk/ExampleInstrumentedTest.java | 26
HDL_TTLSDK485/libs/gson-2.8.5.jar | 0
app/src/main/res/layout/activity_ctrl_logic.xml | 43
206 files changed, 24,830 insertions(+), 3 deletions(-)
diff --git a/.gitignore b/.gitignore
index 3a36c6e..cce944c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,14 @@
+
+# Created by https://www.gitignore.io/api/android
+# Edit at https://www.gitignore.io/?templates=android
+
+### Android ###
# Built application files
*.apk
*.ap_
+*.aab
-# Files for the Dalvik VM
+# Files for the ART/Dalvik VM
*.dex
# Java class files
@@ -11,6 +17,8 @@
# Generated files
bin/
gen/
+out/
+release/
# Gradle files
.gradle/
@@ -22,5 +30,64 @@
# Proguard folder generated by Eclipse
proguard/
-#Log Files
+# Log Files
*.log
+
+# Android Studio Navigation editor temp files
+.navigation/
+
+# Android Studio captures folder
+captures/
+
+# IntelliJ
+*.iml
+.idea/workspace.xml
+.idea/tasks.xml
+.idea/gradle.xml
+.idea/assetWizardSettings.xml
+.idea/dictionaries
+.idea/libraries
+# Android Studio 3 in .gitignore file.
+.idea/caches
+.idea/modules.xml
+# Comment next line if keeping position of elements in Navigation Editor is relevant for you
+.idea/navEditor.xml
+
+# Keystore files
+# Uncomment the following lines if you do not want to check your keystore files in.
+#*.jks
+#*.keystore
+
+# External native build folder generated in Android Studio 2.2 and later
+.externalNativeBuild
+
+# Google Services (e.g. APIs or Firebase)
+# google-services.json
+
+# Freeline
+freeline.py
+freeline/
+freeline_project_description.json
+
+# fastlane
+fastlane/report.xml
+fastlane/Preview.html
+fastlane/screenshots
+fastlane/test_output
+fastlane/readme.md
+
+# Version control
+vcs.xml
+
+# lint
+lint/intermediates/
+lint/generated/
+lint/outputs/
+lint/tmp/
+# lint/reports/
+
+### Android Patch ###
+gen-external-apklibs
+output.json
+
+# End of https://www.gitignore.io/api/android
\ No newline at end of file
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..681f41a
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,116 @@
+<component name="ProjectCodeStyleConfiguration">
+ <code_scheme name="Project" version="173">
+ <codeStyleSettings language="XML">
+ <indentOptions>
+ <option name="CONTINUATION_INDENT_SIZE" value="4" />
+ </indentOptions>
+ <arrangement>
+ <rules>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <NAME>xmlns:android</NAME>
+ <XML_ATTRIBUTE />
+ <XML_NAMESPACE>^$</XML_NAMESPACE>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <NAME>xmlns:.*</NAME>
+ <XML_ATTRIBUTE />
+ <XML_NAMESPACE>^$</XML_NAMESPACE>
+ </AND>
+ </match>
+ <order>BY_NAME</order>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <NAME>.*:id</NAME>
+ <XML_ATTRIBUTE />
+ <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <NAME>.*:name</NAME>
+ <XML_ATTRIBUTE />
+ <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <NAME>name</NAME>
+ <XML_ATTRIBUTE />
+ <XML_NAMESPACE>^$</XML_NAMESPACE>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <NAME>style</NAME>
+ <XML_ATTRIBUTE />
+ <XML_NAMESPACE>^$</XML_NAMESPACE>
+ </AND>
+ </match>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <NAME>.*</NAME>
+ <XML_ATTRIBUTE />
+ <XML_NAMESPACE>^$</XML_NAMESPACE>
+ </AND>
+ </match>
+ <order>BY_NAME</order>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <NAME>.*</NAME>
+ <XML_ATTRIBUTE />
+ <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+ </AND>
+ </match>
+ <order>ANDROID_ATTRIBUTE_ORDER</order>
+ </rule>
+ </section>
+ <section>
+ <rule>
+ <match>
+ <AND>
+ <NAME>.*</NAME>
+ <XML_ATTRIBUTE />
+ <XML_NAMESPACE>.*</XML_NAMESPACE>
+ </AND>
+ </match>
+ <order>BY_NAME</order>
+ </rule>
+ </section>
+ </rules>
+ </arrangement>
+ </codeStyleSettings>
+ </code_scheme>
+</component>
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000..a55e7a1
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+<component name="ProjectCodeStyleConfiguration">
+ <state>
+ <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
+ </state>
+</component>
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..61a9130
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="CompilerConfiguration">
+ <bytecodeTargetLevel target="1.8" />
+ </component>
+</project>
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..15a15b2
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="Encoding" addBOMForNewFiles="with NO BOM" />
+</project>
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..a5f05cd
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="RemoteRepositoriesConfiguration">
+ <remote-repository>
+ <option name="id" value="central" />
+ <option name="name" value="Maven Central repository" />
+ <option name="url" value="https://repo1.maven.org/maven2" />
+ </remote-repository>
+ <remote-repository>
+ <option name="id" value="jboss.community" />
+ <option name="name" value="JBoss Community repository" />
+ <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
+ </remote-repository>
+ <remote-repository>
+ <option name="id" value="BintrayJCenter" />
+ <option name="name" value="BintrayJCenter" />
+ <option name="url" value="https://jcenter.bintray.com/" />
+ </remote-repository>
+ <remote-repository>
+ <option name="id" value="Google" />
+ <option name="name" value="Google" />
+ <option name="url" value="https://dl.google.com/dl/android/maven2/" />
+ </remote-repository>
+ </component>
+</project>
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..fdb9c66
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="EntryPointsManager">
+ <list size="1">
+ <item index="0" class="java.lang.String" itemvalue="android.support.annotation.IntDef" />
+ </list>
+ </component>
+ <component name="JavadocGenerationManager">
+ <option name="OUTPUT_DIRECTORY" value="$PROJECT_DIR$/../鍏朵粬/doc" />
+ <option name="OTHER_OPTIONS" value="-encoding utf-8 -charset utf-8" />
+ </component>
+ <component name="MarkdownProjectSettings">
+ <PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="NONE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="false" showSelectionInPreview="true">
+ <PanelProvider>
+ <provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
+ </PanelProvider>
+ </PreviewSettings>
+ <ParserSettings gitHubSyntaxChange="false">
+ <PegdownExtensions>
+ <option name="ABBREVIATIONS" value="false" />
+ <option name="ANCHORLINKS" value="true" />
+ <option name="ASIDE" value="false" />
+ <option name="ATXHEADERSPACE" value="true" />
+ <option name="AUTOLINKS" value="true" />
+ <option name="DEFINITIONS" value="false" />
+ <option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
+ <option name="FENCED_CODE_BLOCKS" value="true" />
+ <option name="FOOTNOTES" value="false" />
+ <option name="HARDWRAPS" value="false" />
+ <option name="HTML_DEEP_PARSER" value="false" />
+ <option name="INSERTED" value="false" />
+ <option name="QUOTES" value="false" />
+ <option name="RELAXEDHRULES" value="true" />
+ <option name="SMARTS" value="false" />
+ <option name="STRIKETHROUGH" value="true" />
+ <option name="SUBSCRIPT" value="false" />
+ <option name="SUPERSCRIPT" value="false" />
+ <option name="SUPPRESS_HTML_BLOCKS" value="false" />
+ <option name="SUPPRESS_INLINE_HTML" value="false" />
+ <option name="TABLES" value="true" />
+ <option name="TASKLISTITEMS" value="true" />
+ <option name="TOC" value="false" />
+ <option name="WIKILINKS" value="true" />
+ </PegdownExtensions>
+ <ParserOptions>
+ <option name="COMMONMARK_LISTS" value="true" />
+ <option name="DUMMY" value="false" />
+ <option name="EMOJI_SHORTCUTS" value="true" />
+ <option name="FLEXMARK_FRONT_MATTER" value="false" />
+ <option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="false" />
+ <option name="GFM_TABLE_RENDERING" value="true" />
+ <option name="GITBOOK_URL_ENCODING" value="false" />
+ <option name="GITHUB_EMOJI_URL" value="false" />
+ <option name="GITHUB_LISTS" value="false" />
+ <option name="GITHUB_WIKI_LINKS" value="true" />
+ <option name="JEKYLL_FRONT_MATTER" value="false" />
+ <option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
+ </ParserOptions>
+ </ParserSettings>
+ <HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true">
+ <GeneratorProvider>
+ <provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
+ </GeneratorProvider>
+ <headerTop />
+ <headerBottom />
+ <bodyTop />
+ <bodyBottom />
+ </HtmlSettings>
+ <CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssTextEnabled="false" isDynamicPageWidth="true">
+ <StylesheetProvider>
+ <provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
+ </StylesheetProvider>
+ <ScriptProviders />
+ <cssText />
+ </CssSettings>
+ <HtmlExportSettings updateOnSave="false" parentDir="$ProjectFileDir$" targetDir="$ProjectFileDir$" cssDir="" scriptDir="" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetExt="" useTargetExt="false" noCssNoScripts="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" />
+ <LinkMapSettings>
+ <textMaps />
+ </LinkMapSettings>
+ </component>
+ <component name="NullableNotNullManager">
+ <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
+ <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
+ <option name="myNullables">
+ <value>
+ <list size="15">
+ <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
+ <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
+ <item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
+ <item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
+ <item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
+ <item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
+ <item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
+ <item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
+ <item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
+ <item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
+ <item index="10" class="java.lang.String" itemvalue="android.annotation.Nullable" />
+ <item index="11" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
+ <item index="12" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.Nullable" />
+ <item index="13" class="java.lang.String" itemvalue="io.reactivex.annotations.Nullable" />
+ <item index="14" class="java.lang.String" itemvalue="io.reactivex.rxjava3.annotations.Nullable" />
+ </list>
+ </value>
+ </option>
+ <option name="myNotNulls">
+ <value>
+ <list size="14">
+ <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
+ <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
+ <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
+ <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
+ <item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
+ <item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
+ <item index="6" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
+ <item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
+ <item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
+ <item index="9" class="java.lang.String" itemvalue="android.annotation.NonNull" />
+ <item index="10" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
+ <item index="11" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.NonNull" />
+ <item index="12" class="java.lang.String" itemvalue="io.reactivex.annotations.NonNull" />
+ <item index="13" class="java.lang.String" itemvalue="io.reactivex.rxjava3.annotations.NonNull" />
+ </list>
+ </value>
+ </option>
+ </component>
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+ <output url="file://$PROJECT_DIR$/build/classes" />
+ </component>
+ <component name="ProjectType">
+ <option name="id" value="Android" />
+ </component>
+</project>
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..7f68460
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="RunConfigurationProducerService">
+ <option name="ignoredProducers">
+ <set>
+ <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
+ <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
+ <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
+ </set>
+ </option>
+ </component>
+</project>
\ No newline at end of file
diff --git a/HDL_TTLSDK485/.gitignore b/HDL_TTLSDK485/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/HDL_TTLSDK485/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/HDL_TTLSDK485/README.md b/HDL_TTLSDK485/README.md
new file mode 100644
index 0000000..4fe130c
--- /dev/null
+++ b/HDL_TTLSDK485/README.md
@@ -0,0 +1,10 @@
+## Android_HDL_SDK_TTL
+
+HDL TTL Android SDK Copyright (c) 2019 HDL Inc.
+
+榄旈暅SDK椤圭洰
+
+2019-8-21
+V1.0.2
+1.SDK澧炲姞鎺ユ敹鏁版嵁澧炲姞Arc鏍¢獙锛�
+2.SDK澧炲姞鎺ユ敹鏁版嵁澧炲姞鐩爣瀛愮綉鍙疯澶囧彿鍒ゆ柇杩囨护锛�
\ No newline at end of file
diff --git a/HDL_TTLSDK485/build.gradle b/HDL_TTLSDK485/build.gradle
new file mode 100644
index 0000000..06f5296
--- /dev/null
+++ b/HDL_TTLSDK485/build.gradle
@@ -0,0 +1,92 @@
+apply plugin: 'com.android.library'
+//apply plugin: 'com.novoda.bintray-release'
+
+android {
+ buildToolsVersion '28.0.3'
+ compileSdkVersion 28
+ defaultConfig {
+ minSdkVersion 17
+ targetSdkVersion 28
+ versionCode 1
+ versionName "1.0.1"
+
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ ndk {
+ moduleName "serial_port"
+ abiFilters "armeabi-v7a","x86"
+ }
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+
+ sourceSets {
+ main {
+ jni.srcDirs = []
+ jniLibs.srcDirs = ['libs']
+ }
+ }
+ }
+
+ /**
+ * 鎵撳寘鑷姩鍛藉悕
+ */
+ android.libraryVariants.all { variant ->
+ variant.outputs.all {
+ outputFileName = "HDL_TTLSDK485_V" +
+ defaultConfig.versionName + ".B" + defaultConfig.versionCode + "." + releaseTime() + ".aar"
+ }
+ }
+
+
+// lintOptions {
+// abortOnError false
+// warning 'InvalidPackage'
+// }
+}
+
+def releaseTime() {
+ return new Date().format("yyyyMMdd")
+}
+
+dependencies {
+ implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
+ implementation 'com.android.support:appcompat-v7:28.0.0'
+ api 'org.greenrobot:eventbus:3.0.0'
+// api 'com.google.code.gson:gson:2.8.5'
+// testImplementation 'junit:junit:4.12'
+// androidTestImplementation 'com.android.support.test:runner:1.0.2'
+// androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+
+}
+
+
+//task makeJar(type: Copy) {
+////鍒犻櫎瀛樺湪鐨�
+// delete'build/libs/test.jar'
+////璁剧疆鎷疯礉鐨勬枃浠�
+// from('build/intermediates/packaged-classes/release/')
+////鎵撹繘jar鍖呭悗鐨勬枃浠剁洰褰�
+// into('build/libs/')
+////灏哻asses.jar鏀惧叆build/libs/鐩綍涓�
+////include ,exclude鍙傛暟鏉ヨ缃繃婊�
+////锛堟垜浠彧鍏冲績classes.jar杩欎釜鏂囦欢锛�
+// include('classes.jar')
+////閲嶅懡鍚�
+// rename ('classes.jar','test.jar')
+//}
+//makeJar.dependsOn(build)
+
+
+
+
+//publish {
+// userOrg = 'tommydai'
+// groupId = 'com.hdl.sdk'
+// artifactId = 'hdlsdk'
+// publishVersion = '1.5.8'
+// desc = 'HDL core libray'
+//}
+
diff --git a/HDL_TTLSDK485/libs/armeabi-v7a/libserial_port.so b/HDL_TTLSDK485/libs/armeabi-v7a/libserial_port.so
new file mode 100644
index 0000000..6b230b9
--- /dev/null
+++ b/HDL_TTLSDK485/libs/armeabi-v7a/libserial_port.so
Binary files differ
diff --git a/HDL_TTLSDK485/libs/gson-2.8.5.jar b/HDL_TTLSDK485/libs/gson-2.8.5.jar
new file mode 100644
index 0000000..0d5baf3
--- /dev/null
+++ b/HDL_TTLSDK485/libs/gson-2.8.5.jar
Binary files differ
diff --git a/HDL_TTLSDK485/libs/x86/libserial_port.so b/HDL_TTLSDK485/libs/x86/libserial_port.so
new file mode 100644
index 0000000..1039113
--- /dev/null
+++ b/HDL_TTLSDK485/libs/x86/libserial_port.so
Binary files differ
diff --git a/HDL_TTLSDK485/proguard-rules.pro b/HDL_TTLSDK485/proguard-rules.pro
new file mode 100644
index 0000000..f1b4245
--- /dev/null
+++ b/HDL_TTLSDK485/proguard-rules.pro
@@ -0,0 +1,21 @@
+# 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
diff --git a/HDL_TTLSDK485/src/main/AndroidManifest.xml b/HDL_TTLSDK485/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..fb53545
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/AndroidManifest.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.hdl.sdk.ttl">
+
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+ <uses-permission android:name="adnroid.permission.CHANGE_WIFI_STATE" />
+ <uses-permission android:name="android.permission.RAISED_THREAD_PRIORITY" />
+ <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+ <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
+ <application
+ android:allowBackup="true"
+ android:label="@string/app_name"
+ android:supportsRtl="true">
+
+ </application>
+
+</manifest>
diff --git a/HDL_TTLSDK485/src/main/java/android/serialport/api/SerialPort.java b/HDL_TTLSDK485/src/main/java/android/serialport/api/SerialPort.java
new file mode 100644
index 0000000..445b9ea
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/android/serialport/api/SerialPort.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2009 Cedric Priscal
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.serialport.api;
+
+import java.io.File;
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import android.util.Log;
+
+public class SerialPort {
+
+ private static final String TAG = "SerialPort";
+
+ /*
+ * Do not remove or rename the field mFd: it is used by native method
+ * close();
+ */
+ private FileDescriptor mFd;
+ private FileInputStream mFileInputStream;
+ private FileOutputStream mFileOutputStream;
+
+ public SerialPort(File device, int baudrate, int flags) throws SecurityException, IOException {
+
+// /* Check access permission */
+// if (!device.canRead() || !device.canWrite()) {
+// try {
+// /* Missing read/write permission, trying to chmod the file */
+// Process su;
+// su = Runtime.getRuntime().exec("/system/bin/su");
+// String cmd = "chmod 666 " + device.getAbsolutePath() + "\n" + "exit\n";
+// su.getOutputStream().write(cmd.getBytes());
+// if ((su.waitFor() != 0) || !device.canRead() || !device.canWrite()) {
+// throw new SecurityException();
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// throw new SecurityException();
+// }
+// }
+
+ mFd = open(device.getAbsolutePath(), baudrate, flags);
+ if (mFd == null) {
+ Log.e(TAG, "native open returns null");
+ throw new IOException();
+ }
+ mFileInputStream = new FileInputStream(mFd);
+ mFileOutputStream = new FileOutputStream(mFd);
+ }
+
+ // Getters and setters
+ public InputStream getInputStream() {
+ return mFileInputStream;
+ }
+
+ public OutputStream getOutputStream() {
+ return mFileOutputStream;
+ }
+
+ // JNI
+ private native static FileDescriptor open(String path, int baudrate, int flags);
+
+ public native void close();
+
+ public static native int BackLight_ON();
+
+ public static native int BackLight_OFF();
+
+
+ static {
+ System.loadLibrary("serial_port");
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/android/serialport/api/SerialPortFinder.java b/HDL_TTLSDK485/src/main/java/android/serialport/api/SerialPortFinder.java
new file mode 100644
index 0000000..0d80d1a
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/android/serialport/api/SerialPortFinder.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2009 Cedric Priscal
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.serialport.api;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.LineNumberReader;
+import java.util.Iterator;
+import java.util.Vector;
+
+import android.util.Log;
+
+public class SerialPortFinder {
+
+ public class Driver {
+ public Driver(String name, String root) {
+ mDriverName = name;
+ mDeviceRoot = root;
+ }
+
+ private String mDriverName;
+ private String mDeviceRoot;
+ Vector<File> mDevices = null;
+
+ public Vector<File> getDevices() {
+ if (mDevices == null) {
+ mDevices = new Vector<File>();
+ File dev = new File("/dev");
+ File[] files = dev.listFiles();
+ int i;
+ for (i = 0; i < files.length; i++) {
+ if (files[i].getAbsolutePath().startsWith(mDeviceRoot)) {
+ Log.d(TAG, "Found new device: " + files[i]);
+ mDevices.add(files[i]);
+ }
+ }
+ }
+ return mDevices;
+ }
+
+ public String getName() {
+ return mDriverName;
+ }
+ }
+
+ private static final String TAG = "SerialPort";
+
+ private Vector<Driver> mDrivers = null;
+
+ Vector<Driver> getDrivers() throws IOException {
+ if (mDrivers == null) {
+ mDrivers = new Vector<Driver>();
+ LineNumberReader r = new LineNumberReader(new FileReader("/proc/tty/drivers"));
+ String l;
+ while ((l = r.readLine()) != null) {
+ // Issue 3:
+ // Since driver name may contain spaces, we do not extract
+ // driver name with split()
+ String drivername = l.substring(0, 0x15).trim();
+ String[] w = l.split(" +");
+ if ((w.length >= 5) && (w[w.length - 1].equals("serial"))) {
+ Log.d(TAG, "Found new driver " + drivername + " on " + w[w.length - 4]);
+ // mDrivers.add(new Driver(drivername, w[w.length-4]));
+ mDrivers.add(new Driver(drivername, w[w.length - 4]));
+ }
+ }
+ r.close();
+ }
+ return mDrivers;
+ }
+
+ public String[] getAllDevices() {
+ Vector<String> devices = new Vector<String>();
+ // Parse each driver
+ Iterator<Driver> itdriv;
+ try {
+ itdriv = getDrivers().iterator();
+ while (itdriv.hasNext()) {
+ Driver driver = itdriv.next();
+ Iterator<File> itdev = driver.getDevices().iterator();
+ while (itdev.hasNext()) {
+ String device = itdev.next().getName();
+ String value = String.format("%s (%s)", device, driver.getName());
+ devices.add(value);
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return devices.toArray(new String[devices.size()]);
+ }
+
+ public String[] getAllDevicesPath() {
+ Vector<String> devices = new Vector<String>();
+ // Parse each driver
+ Iterator<Driver> itdriv;
+ try {
+ itdriv = getDrivers().iterator();
+ while (itdriv.hasNext()) {
+ Driver driver = itdriv.next();
+ Iterator<File> itdev = driver.getDevices().iterator();
+ while (itdev.hasNext()) {
+ String device = itdev.next().getAbsolutePath();
+ devices.add(device);
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return devices.toArray(new String[devices.size()]);
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Config/Configuration.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Config/Configuration.java
new file mode 100644
index 0000000..172ffc9
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Config/Configuration.java
@@ -0,0 +1,236 @@
+package com.hdl.sdk.ttl.Config;
+
+public class Configuration {
+ public static final String UNKNOW_TYPE = "Unknow Type";
+ public static final int HDL_SDK_DEV_TYPE = 58009;
+
+ //瀹剁數绫诲瀷鐮�
+ //澶х被
+ /**鐏厜绫�*/
+ public static final int LIGTH_BIG_TYPE = 1; //
+ /**绐楀笜绫�*/
+ public static final int CURTAIN_BIG_TYPE = 2;
+ /**浼犳劅鍣ㄧ被*/
+ public static final int SENSOR_BIG_TYPE = 5;//2019-07-03 灞忚斀 2019-11-1 鍘诲睆钄�
+ /**绌鸿皟绫�*/
+ public static final int AIR_BIG_TYPE = 7;
+ /**鑳屾櫙闊充箰绫�*/
+ public static final int AUDIO_BIG_TYPE = 9;
+ /**瀹夐槻鍔熻兘*/
+ public static final int SECURITY_BIG_TYPE = 10;
+ /**閫昏緫鍔熻兘绫�*/
+ public static final int LOGIC_BIG_TYPE = 12;
+ /**鍏ㄥ眬鍦烘櫙*/
+ public static final int GLOBAL_LOGIC_BIG_TYPE = 17;
+
+ /**閫氱敤寮�鍏�*/
+ public static final int COMMON_SWITCH_BIG_TYPE = 100;
+
+ //灏忕被 鍏堜笉鍋氬垎绫�
+// public static final int AIR_LITTLE_TYPE = 0;
+
+
+// public static final int LLTTLE_TYPE_SENSOR_DRY_CONTACT = 0;//2019-11-4 鏂板浼犳劅鍣ㄥ皬绫�
+// public static final int LLTTLE_TYPE_SENSOR_MOVEMENT_DETECTOR = 1;
+// public static final int LLTTLE_TYPE_SENSOR_TEMP = 2;
+// public static final int LLTTLE_TYPE_SENSOR_HUMIDITY = 3;
+// public static final int LLTTLE_TYPE_SENSOR_ILLUMINACE = 4;
+// public static final int LLTTLE_TYPE_SENSOR_VOC = 5;
+// public static final int LLTTLE_TYPE_SENSOR_PM_2_POINT_5 = 6;
+// public static final int LLTTLE_TYPE_SENSOR_C02 = 7;
+// public static final int LLTTLE_TYPE_SENSOR_LPG = 8;
+// public static final int LLTTLE_TYPE_SENSOR_CO_H2 = 9;
+// public static final int LLTTLE_TYPE_SENSOR_CH4 = 10;
+// public static final int LLTTLE_TYPE_SENSOR_SMOG = 11;
+// public static final int LLTTLE_TYPE_SENSOR_WIND_SPEED = 12;
+// public static final int LLTTLE_TYPE_SENSOR_WIND_PRESSURE = 13;
+// public static final int LLTTLE_TYPE_SENSOR_LIQUID_FLOW = 14;
+// public static final int LLTTLE_TYPE_SENSOR_LIQUID_PRESSURE = 15;
+// public static final int LLTTLE_TYPE_SENSOR_LIQUID_DEPTH = 16;
+// public static final int LLTTLE_TYPE_SENSOR_RAIN_FALL = 17;
+// public static final int LLTTLE_TYPE_SENSOR_WEIGHT = 18;
+// public static final int LLTTLE_TYPE_SENSOR_HEIGHT_LENGTH = 19;
+// public static final int LLTTLE_TYPE_SENSOR_OBJECT_SPEED = 20;
+// public static final int LLTTLE_TYPE_SENSOR_SHAKE = 21;
+// public static final int LLTTLE_TYPE_SENSOR_VOLTAGE = 22;
+// public static final int LLTTLE_TYPE_SENSOR_ELECTRICITY = 23;
+// public static final int LLTTLE_TYPE_SENSOR_POWER = 24;
+ // public static final int LLTTLE_TYPE_SENSOR_POWER = 25;
+ // public static final int LLTTLE_TYPE_SENSOR_POWER = 26;
+ // public static final int LLTTLE_TYPE_SENSOR_POWER = 27;
+//
+
+ //鎿嶄綔鍒嗙被鐮�
+// public static final int SEARCH = 100;//鎼滅储
+ public static final int CONTROL = 101;//鎺у埗
+ public static final int STATE = 102;//鐘舵��
+// public static final int REMARKS = 103;//澶囨敞
+// public static final int HET_DEVICES = 104;//绗笁鏂� 鍜岃�屾嘲
+// public static final int Midea_DEVICES = 105;//绗笁鏂� 缇庣殑
+// public static final int JAV_DEVICES = 106;//绗笁鏂� Jav
+// public static final int GET_LOGIC_INFO = 107;//閫昏緫淇℃伅
+// public static final int XW_DEVICES = 108;//绗笁鏂� 鍚戝線
+// public static final int WARNING = 109;//鎶ヨ
+// public static final int AUDIO = 110;//鑳屾櫙闊充箰
+// public static final int RCU_CHANGE = 111;
+// public static final int RCU_SEARCH = 112;
+// public static final int RCU_MODIFY = 113;
+// public static final int RCU_READ = 114;
+// public static final int RCU_CAST = 115;
+// public static final int MANUAL_ADD_DEVICE = 116;
+// public static final int MANUAL_ADD_REMARK = 117;
+
+
+ //鍥哄畾Bus绔彛鍊�
+ public static final int PORT = 6000;
+ public static final int GET_DEVICE_FROM_BUS_PORT = 8641;
+
+
+ //绠�鏄撶紪绋嬭澶囨悳绱㈡搷浣滅爜銆佽澶囪鍙栨搷浣滅爜
+ public static final int DEVICES_SEARCH_COMMAND = 0xE548;
+ public static final int DEVICES_SEARCH_BACK_COMMAND = 0xE549;
+ public static final int DEVICES_READ_COMMAND = 0xE44A;//绠�鏄撶紪绋嬩緷娆′粠璁惧璇诲彇(鑾峰彇澶囨敞淇℃伅)
+ public static final int DEVICES_READ_BACK_COMMAND = 0xE44B;//绠�鏄撶紪绋嬭鍙栬繑鍥�(鏀跺埌澶囨敞淇℃伅)
+ //****************2019-07鏂板****************
+ public static final int DEVICES_MODIFY_COMMAND = 0xE44C;//绠�鏄撶紪绋嬩慨鏀瑰熀鏈俊鎭紙鍗曠嫭淇敼鍥炶矾澶囨敞锛�
+ public static final int DEVICES_MODIFY_BACK_COMMAND = 0xE44D;//绠�鏄撶紪绋嬩慨鏀瑰熀鏈俊鎭洖澶�
+ public static final int MODULE_UPDATE_REMARK_COMMAND = 0x0010;//妯″潡淇敼澶囨敞
+ public static final int MODULE_UPDATE_REMARK_BACK_COMMAND = 0x0011;//妯″潡淇敼澶囨敞鍥炲
+
+ //鎵嬪姩娣诲姞璁惧鐩稿叧鎿嶄綔鐮�
+ public static final int MANUAL_ADD_DEVICE_COMMAND = 0x6F00;
+ public static final int MANUAL_ADD_DEVICE_BACK_COMMAND = 0x6F01;
+ public static final int MANUAL_ADD_REMARK_COMMAND = 0x6F02;
+ public static final int MANUAL_ADD_REMARK_BACK_COMMAND = 0x6F03;
+
+ //鐏厜鎿嶄綔鐮併�佺姸鎬佽鍙栫爜
+ public static final int LIGHT_CTRL_COMMAND = 0x0031;
+ public static final int LIGHT_CTRL_BACK_COMMAND = 0x0032;
+ public static final int LIGHT_STATE_COMMAND = 0x0033;
+ public static final int LIGHT_STATE_BACK_COMMAND = 0x0034;
+
+ //绐楀笜鎿嶄綔鐮併�佺姸鎬佽鍙栫爜
+ public static final int CURTAIN_CTRL_COMMAND = 0xE3E0;
+ public static final int CURTAIN_CTRL_BACK_COMMAND = 0xE3E1;
+ public static final int CURTAIN_STATE_COMMAND = 0xE3E2;
+ public static final int CURTAIN_STATE_BACK_COMMAND = 0xE3E3;
+
+ public static final int CURTAIN_STATE_BROADCAST_BACK_COMMAND = 0xE3E4;
+
+
+ //绌鸿皟鎿嶄綔鐮併�佺姸鎬佽鍙栫爜锛堢洰鍓嶄粎鏀寔閫氱敤绌鸿皟闈㈡澘锛�
+ public static final int AIR_CTRL_COMMAND = 0xE3D8;
+ public static final int AIR_CTRL_BACK_COMMAND = 0xE3D9;
+ public static final int AIR_STATE_COMMAND = 0xE3DA;
+ public static final int AIR_STATE_BACK_COMMAND = 0xE3DB;
+
+ public static final int AIR_HVAC_CTRL_COMMAND = 0x193A;
+ public static final int AIR_HVAC_CTRL_BACK_COMMAND = 0x193B;
+ public static final int AIR_HVAC_STATE_COMMAND = 0x1938;
+ public static final int AIR_HVAC_STATE_BACK_COMMAND = 0x1939;
+// public static final int AIR_HVAC_STATE_BACK_COMMAND = 0x209A;
+
+
+ //閫昏緫妯″潡鎿嶄綔鐮併�佺姸鎬佽鍙栫爜
+ public static final int LOGIC_CTRL_COMMAND = 0x0002;
+ public static final int LOGIC_CTRL_BACK_COMMAND = 0x0003;
+ public static final int LOGIC_STATE_COMMAND = 0x000C;
+ public static final int LOGIC_STATE_BACK_COMMAND = 0x000D;
+
+ //骞叉帴鐐� 姘存蹈銆侀棬纾併�佺叅姘斻�佺儫闆�
+ public static final int DRY_CONTACT_STATE_COMMAND = 0x15CE;//璇诲彇骞茶妭鐐圭姸鎬�
+ public static final int DRY_CONTACT_STATE_BACK_COMMAND = 0x15CF;// 骞茶妭鐐圭姸鎬佸洖澶�
+
+ public static final int DRY_CONTACT_BROADCAST_STATE_COMMAND = 0x15D0;//骞茶妭鐐圭姸鎬佷富鍔ㄥ箍鎾弽棣�
+
+
+ //鍏鍙d氦鎹㈡満浼犳劅鍣� 浼犳劅鍣ㄦ搷浣滅爜
+ public static final int SENSOR_STATE_COMMAND = 0xE4F9;
+ public static final int SENSOR_STATE_BACK_COMMAND = 0xE4FA;
+ public static final int SENSOR_BROADCAST_STATE_BACK_COMMAND = 0x353A;
+ //瑙f瀽锛�0xE4F9 鍛戒护涓鸿鍙栦紶鎰熷櫒鍛戒护锛�0xE4FA 涓鸿鍙栬繑鍥炲�笺�傝嫢瑕佷笉鏂幏鍙栦紶鎰熷櫒 鐨勭姸鎬侊紝
+ //搴旇寮�鍚紶鎰熷櫒浣胯兘鍔熻兘锛屽紑鍚悗浼犳劅鍣ㄥ氨浼氬彂鍑� 0x353A 鐨勫箍鎾姸鎬侊紝涓嶉渶 瑕佷竴鐩磋鍙栵紝鍙渶鎺ユ敹鍗冲彲銆�0x353A 涓� 0xE4FA 杩斿洖鐨勬槸涓�鏍风殑鏍煎紡鐘舵�併��
+
+// public static final int SENSOR_BROADCAST_COMMAND = 0x1647;
+ public static final int WARNING_COMMAND = 0xF606;
+ //澶勭悊杞彂闊充箰鏁版嵁
+ public static final int AUDIO_CTRL_READ_COMMAND = 0x192E;
+ public static final int AUDIO_CTRL_READ_BACK_COMMAND = 0x192F;
+ public static final int MUSIC2_COMMAND = 0x0218;
+ public static final int MUSIC3_COMMAND = 0x021A;
+ public static final int AUDIO_MenuPlay_INSTRUCTION_COMMAND = 0x1970;
+ public static final int AUDIO_MenuPlay_INSTRUCTION_BACK_COMMAND = 0x1971;
+
+// public static final int COMMOND_COMMAND = 0xE01C;
+// public static final int COMMOND_BACK_COMMAND = 0xE01D;
+
+
+ //瀹夐槻鍔熻兘妯″潡鎿嶄綔鐮併�佺姸鎬佽鍙栫爜 ARMING甯冮槻 ALARM鎶ヨ
+ public static final int SECURITY_ARMING_CTRL_COMMAND = 0x0104;//甯冮槻璁剧疆
+ public static final int SECURITY_ARMING_CTRL_BACK_COMMAND = 0x0105;//甯冮槻璁剧疆鍙嶉
+ public static final int SECURITY_STATE_COMMAND = 0x011E;//璇诲彇瀹夐槻璁剧疆
+ public static final int SECURITY_STATE_BACK_COMMAND = 0x011F;//璇诲彇瀹夐槻璁剧疆鍙嶉
+ public static final int SECURITY_ALARM_CTRL_COMMAND = 0x010C;//鎶ヨ璁剧疆
+ public static final int SECURITY_ALARM_CTRL_BACK_COMMAND = 0x010D;//鎶ヨ璁剧疆鍙嶉
+
+ /**
+ * 閫氱敤寮�鍏�
+ */
+ public static final int COMMON_SWITCH_CTRL_COMMAND = 0xE01C;//閫氱敤寮�鍏虫帶鍒�
+ public static final int COMMON_SWITCH_CTRL_BACK_COMMAND = 0xE01D;//閫氱敤寮�鍏虫帶鍒跺弽棣�
+ public static final int COMMON_SWITCH_STATE_COMMAND = 0xE018;//璇婚�氱敤寮�鍏崇姸鎬�
+ public static final int COMMON_SWITCH_STATE_BACK_COMMAND = 0xE019;//璇婚�氱敤寮�鍏崇姸鎬佸弽棣�
+
+
+// /**
+// * RCU 閰嶇疆鏁版嵁
+// *
+// *
+// *
+// *
+// *
+// */
+//
+//
+// //鍥哄畾RCU鍙戦�佺鍙�
+// public static final int RCU_SEND_PORT = 6006;
+// //鍥哄畾RCU鎺ユ敹绔彛
+// public static final int RCU_RECEIVE_PORT = 6008;
+// //鍥哄畾RCU 缁勬挱鍦板潃
+// public static final String RCU_MULTI_IP = "224.0.168.188";
+//
+// //鎺ユ敹鏇存崲鏀瑰彉涓篟CU璁惧鐨勬搷浣滅爜
+// public static final int RCU_CHANGE_COMMAND = 0xE506;
+// public static final int RCU_CHANGE_BACK_COMMAND = 0xE507;
+//
+// //鍏呭綋璁惧绔鍙戠幇鐨勬搷浣滅爜
+// public static final int RCU_SEARCH_COMMAND = 0xE54A;
+// public static final int RCU_SEARCH_BACK_COMMAND = 0xE54B;
+//
+// //淇敼澶囨敞鎿嶄綔鐮�
+// public static final int RCU_MODIFY_COMMAND = 0xE54C;
+// public static final int RCU_MODIFY_BACK_COMMAND = 0xE54D;
+//
+// //RCU璇诲彇SDK淇℃伅鎿嶄綔鐮�
+// public static final int RCU_READ_SDK_INFO_COMMAND = 0xE508;
+// public static final int RCU_READ_SDK_INFO_BACK_COMMAND = 0xE509;
+//
+// //RCU鎴块棿鐘舵�佸箍鎾搷浣滅爜
+// public static final int RCU_ROOM_CAST_COMMAND = 0x20D2;
+//
+//
+// //RCU绐楀笜鎿嶄綔鐮併�佺姸鎬佽鍙栫爜
+// public static final int RCU_CURTAIN_CTRL_COMMAND = 0x2069;
+// public static final int RCU_CURTAIN_CTRL_BACK_COMMAND = 0x206A;
+// // public static final int RCU_CURTAIN_STATE_BACK_COMMAND = 0x;
+// public static final int RCU_CURTAIN_CAST_COMMAND = 0x2099;
+//
+// //RCU绌鸿皟鎿嶄綔鐮併�佺姸鎬佽鍙栫爜锛堢洰鍓嶄粎鏀寔閫氱敤绌鸿皟闈㈡澘锛�
+// public static final int RCU_AIR_CTRL_COMMAND = 0x2065;
+// public static final int RCU_AIR_CTRL_BACK_COMMAND = 0x2066;
+// public static final int RCU_AIR_CAST_COMMAND = 0x209A;
+
+
+
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Config/MCUConstants.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Config/MCUConstants.java
new file mode 100644
index 0000000..890819f
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Config/MCUConstants.java
@@ -0,0 +1,54 @@
+package com.hdl.sdk.ttl.Config;
+
+/**
+ * Created by JLChen on 2019/7/12
+ */
+public class MCUConstants {
+ /**
+ * HDL Buspro V1.0
+ */
+ //0xA8 寮曞澶�
+ public static final int MCU_BOOT_HEAD = 0xA8;
+
+ //0x00 涓嬪彂鏁版嵁
+ public static final int MCU_COMMAND_SEND = 0x00;
+ //0x80 涓婃姤鏁版嵁
+ public static final int MCU_COMMAND_SEND_BACK = 0x80;
+
+ //0x01 妫�娴嬩涪鍖呯姸鎬�
+ public static final int MCU_DETECT_PACKET_LOSS_STATUS = 0x01;
+ //0x81 妫�娴嬩涪鍖呯姸鎬佽繑鍥�
+ public static final int MCU_DETECT_PACKET_LOSS_STATUS_BACK = 0x81;
+
+ //0x02 璇婚厤缃俊鎭�
+ public static final int MCU_READ_CONFIGURATION = 0x02;
+ //0x82 璇婚厤缃繑鍥�
+ public static final int MCU_READ_CONFIGURATION_BACK = 0x82;
+
+ //0x03 鍐欓厤缃俊鎭�
+ public static final int MCU_WRITE_CONFIGURATION = 0x03;
+ //0x83 鍐欓厤缃俊鎭繑鍥�
+ public static final int MCU_WRITE_CONFIGURATION_BACK = 0x83;
+
+ //0x04 璇锋眰鍗囩骇
+ public static final int MCU_REQUEST_UPGRADE = 0x04;
+ //0x84 璇锋眰鍗囩骇杩斿洖
+ public static final int MCU_REQUEST_UPGRADE_BACK = 0x84;
+
+ //0x85 鍙戦�佸崌绾ф暟鎹�
+ public static final int MCU_SEND_UPGRADE_DATA = 0x05;
+ //0x05 鍙戦�佸崌绾ф暟鎹繑鍥�
+ public static final int MCU_SEND_UPGRADE_DATA_BACK = 0x85;
+
+ //0x06 閲嶅惎 MCU
+ public static final int MCU_RESTART = 0x06;
+ //0x86 閲嶅惎杩斿洖
+ public static final int MCU_RESTART_BACK = 0x86;
+
+
+
+
+
+
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/Config/HDLApConfig.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/Config/HDLApConfig.java
new file mode 100644
index 0000000..aece8d7
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/Config/HDLApConfig.java
@@ -0,0 +1,73 @@
+package com.hdl.sdk.ttl.HDLAppliances.Config;
+
+/**
+ * Created by Tommy on 2018/4/22.
+ */
+
+public class HDLApConfig {
+
+ public static final int TYPE_LIGHT_DIMMER = 101;
+ public static final int TYPE_LIGHT_RELAY = 102;
+ public static final int TYPE_LIGHT_MIX_DIMMER = 103;
+ public static final int TYPE_LIGHT_MIX_RELAY = 104;
+
+ public static final int TYPE_CURTAIN_GLYSTRO = 201;
+ public static final int TYPE_CURTAIN_ROLLER = 202;
+ public static final int TYPE_CURTAIN_MODULE = 203;
+
+ public static final int TYPE_AC_HVAC = 301;
+ public static final int TYPE_AC_COOLMASTER = 302;
+ public static final int TYPE_AC_INFRARED = 303;
+ public static final int TYPE_AC_PANEL = 304;
+
+
+ public static final int TYPE_MUSIC_MODULE = 401;
+ public static final int TYPE_MUSIC_THIRD_PARTY_MODULE = 402;
+ public static final int TYPE_MUSIC_NEW_MODULE = 403;
+
+ public static final int TYPE_LOGIC_MODULE = 501;
+ public static final int TYPE_GLOBAL_LOGIC_MODULE = 502;
+
+ //2019-7-29 鏂板瀹夐槻鍔熻兘妯″潡
+ public static final int TYPE_SECURITY_MODULE = 1001;
+// public static final int SECURITY_CONTROL_PANEL = 1002;
+
+ public static final int TYPE_SENSOR_DRY_CONTACT = 601;//2019-07-03 灞忚斀
+ public static final int TYPE_SENSOR_MOVEMENT_DETECTOR = 602;
+ public static final int TYPE_SENSOR_TEMP = 603;
+ public static final int TYPE_SENSOR_HUMIDITY = 604;
+ public static final int TYPE_SENSOR_ILLUMINACE = 605;
+ public static final int TYPE_SENSOR_VOC = 606;
+ public static final int TYPE_SENSOR_PM_2_POINT_5 = 607;
+ public static final int TYPE_SENSOR_C02 = 608;
+ public static final int TYPE_SENSOR_LPG = 609;
+ public static final int TYPE_SENSOR_CO_H2 = 610;
+ public static final int TYPE_SENSOR_CH4 = 611;
+ public static final int TYPE_SENSOR_SMOG = 612;
+ public static final int TYPE_SENSOR_WIND_SPEED = 613;
+ public static final int TYPE_SENSOR_WIND_PRESSURE = 614;
+ public static final int TYPE_SENSOR_LIQUID_FLOW = 615;
+ public static final int TYPE_SENSOR_LIQUID_PRESSURE = 616;
+ public static final int TYPE_SENSOR_LIQUID_DEPTH = 617;
+ public static final int TYPE_SENSOR_RAIN_FALL = 618;
+ public static final int TYPE_SENSOR_WEIGHT = 619;
+ public static final int TYPE_SENSOR_HEIGHT_LENGTH = 620;
+ public static final int TYPE_SENSOR_OBJECT_SPEED = 621;
+ public static final int TYPE_SENSOR_SHAKE = 622;
+ public static final int TYPE_SENSOR_VOLTAGE = 623;
+ public static final int TYPE_SENSOR_ELECTRICITY = 624;
+ public static final int TYPE_SENSOR_POWER = 625;
+
+ public static final int TYPE_SENSOR_FLOODING = 626; //姘存蹈//2019-11-4 鏂板
+ public static final int TYPE_SENSOR_DOOR_MAGNET= 627; //闂ㄧ銆佺獥纾�
+ public static final int TYPE_SENSOR_EMERGENCY_BUTTON = 628; //绱ф�ユ寜閽�
+
+
+
+ public static final int TYPE_COMMON_SWITCH = 10001;//閫氱敤寮�鍏�
+
+
+
+
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/AirCtrlBackInfo.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/AirCtrlBackInfo.java
new file mode 100644
index 0000000..7136f24
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/AirCtrlBackInfo.java
@@ -0,0 +1,114 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition;
+
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+
+import java.io.Serializable;
+
+/**
+ * Created by djl on 2017/4/1.
+ * 绌鸿皟
+ */
+
+public class AirCtrlBackInfo implements Serializable {
+ AppliancesInfo appliancesInfo;
+ String remarks;
+ int isOn;//0=鍏筹紝1=寮�
+ int refTemp;//鍒跺喎娓╁害鐐� 0-84
+ int airSpeed;//椋庨�� 0 =鑷姩, 1 = 楂橀, 1 = 涓, 3 = 浣庨
+ int airMode;//绌鸿皟妯″紡0 = 鍒跺喎, 1 = 鍒剁儹, 1 = 閫氶, 3 =鑷姩, 4 = 鎶芥箍
+ int heatTemp;//鍒剁儹娓╁害鐐� 0-84
+ int autoTemp;//鑷姩娓╁害鐐� 0-84
+ int upTemp;//涓婂崌娓╁害
+ int downTemp;//涓嬮檷娓╁害
+ byte[] curState ;//鎺у埗鍥為淇℃伅
+
+
+ public AppliancesInfo getAppliancesInfo() {
+ return appliancesInfo;
+ }
+
+ public void setAppliancesInfo(AppliancesInfo appliancesInfo) {
+ this.appliancesInfo = appliancesInfo;
+ }
+
+ public byte[] getCurState() {
+ return curState;
+ }
+
+ public void setCurState(byte[] curState) {
+ this.curState = curState;
+ }
+
+ public String getRemarks() {
+ return remarks;
+ }
+
+ public void setRemarks(String remarks) {
+ this.remarks = remarks;
+ }
+
+ public int getIsOn() {
+ return isOn;
+ }
+
+ public void setIsOn(int isOn) {
+ this.isOn = isOn;
+ }
+
+ public int getRefTemp() {
+ return refTemp;
+ }
+
+ public void setRefTemp(int refTemp) {
+ this.refTemp = refTemp;
+ }
+
+ public int getAirSpeed() {
+ return airSpeed;
+ }
+
+ public void setAirSpeed(int airSpeed) {
+ this.airSpeed = airSpeed;
+ }
+
+ public int getAirMode() {
+ return airMode;
+ }
+
+ public void setAirMode(int airMode) {
+ this.airMode = airMode;
+ }
+
+ public int getHeatTemp() {
+ return heatTemp;
+ }
+
+ public void setHeatTemp(int heatTemp) {
+ this.heatTemp = heatTemp;
+ }
+
+ public int getAutoTemp() {
+ return autoTemp;
+ }
+
+ public void setAutoTemp(int autoTemp) {
+ this.autoTemp = autoTemp;
+ }
+
+ public int getUpTemp() {
+ return upTemp;
+ }
+
+ public void setUpTemp(int upTemp) {
+ this.upTemp = upTemp;
+ }
+
+ public int getDownTemp() {
+ return downTemp;
+ }
+
+ public void setDownTemp(int downTemp) {
+ this.downTemp = downTemp;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/AirHVACBackInfo.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/AirHVACBackInfo.java
new file mode 100644
index 0000000..bdd681b
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/AirHVACBackInfo.java
@@ -0,0 +1,136 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition;
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+
+import java.io.Serializable;
+
+/**
+ * Created by JLChen on 2019/8/6
+ */
+public class AirHVACBackInfo implements Serializable {
+ private AppliancesInfo appliancesInfo;
+ private String remarks;
+ private int channelNum;//鍥炶矾鍙�
+ private int isOn;//0=鍏筹紝1=寮�
+ private int refTemp;//鍒跺喎娓╁害鐐� 0-84
+ private int heatTemp;//鍒剁儹娓╁害鐐� 0-84
+ private int autoTemp;//鑷姩娓╁害鐐� 0-84
+ private int wettedTemp;//鎶芥箍娓╁害鐐�
+ private int airSpeed;//椋庨�� 0 =鑷姩, 1 = 楂橀, 1 = 涓, 3 = 浣庨
+ private int airMode;//绌鸿皟妯″紡0 = 鍒跺喎, 1 = 鍒剁儹, 1 = 閫氶, 3 =鑷姩, 4 = 鎶芥箍
+ // private int upTemp;//涓婂崌娓╁害
+// private int downTemp;//涓嬮檷娓╁害
+ private byte[] curState ;//鎺у埗鍥為淇℃伅
+
+ public AirHVACBackInfo(){
+
+ }
+
+ public AirHVACBackInfo(AppliancesInfo mAppliancesInfo) {
+ this.appliancesInfo = mAppliancesInfo;
+ this.curState = mAppliancesInfo.getArrCurState();
+ this.remarks = mAppliancesInfo.getRemarks();
+
+ if (this.curState == null) return;
+
+ if (this.curState.length >= 13) {
+ this.channelNum = this.curState[0] & 0xFF;
+ this.refTemp = this.curState[3] & 0xFF;//鍒跺喎娓╁害鐐� 0-84
+ this.heatTemp = this.curState[4] & 0xFF;//鍒剁儹娓╁害鐐� 0-84
+ this.autoTemp = this.curState[5] & 0xFF;//鑷姩娓╁害鐐� 0-84
+ this.isOn = this.curState[8] & 0xFF;//鍙彇浣�4浣�
+ this.airMode = this.curState[9] & 0xFF;
+ this.airSpeed = this.curState[10] & 0xFF;
+ }
+
+ }
+
+ public AppliancesInfo getAppliancesInfo() {
+ return appliancesInfo;
+ }
+
+ public void setAppliancesInfo(AppliancesInfo appliancesInfo) {
+ this.appliancesInfo = appliancesInfo;
+ }
+
+ public String getRemarks() {
+ return remarks;
+ }
+
+ public void setRemarks(String remarks) {
+ this.remarks = remarks;
+ }
+
+ public int getChannelNum() {
+ return channelNum;
+ }
+
+ public void setChannelNum(int channelNum) {
+ this.channelNum = channelNum;
+ }
+
+ public int getIsOn() {
+ return isOn;
+ }
+
+ public void setIsOn(int isOn) {
+ this.isOn = isOn;
+ }
+
+ public int getRefTemp() {
+ return refTemp;
+ }
+
+ public void setRefTemp(int refTemp) {
+ this.refTemp = refTemp;
+ }
+
+ public int getHeatTemp() {
+ return heatTemp;
+ }
+
+ public void setHeatTemp(int heatTemp) {
+ this.heatTemp = heatTemp;
+ }
+
+ public int getAutoTemp() {
+ return autoTemp;
+ }
+
+ public void setAutoTemp(int autoTemp) {
+ this.autoTemp = autoTemp;
+ }
+
+ public int getWettedTemp() {
+ return wettedTemp;
+ }
+
+ public void setWettedTemp(int wettedTemp) {
+ this.wettedTemp = wettedTemp;
+ }
+
+ public int getAirSpeed() {
+ return airSpeed;
+ }
+
+ public void setAirSpeed(int airSpeed) {
+ this.airSpeed = airSpeed;
+ }
+
+ public int getAirMode() {
+ return airMode;
+ }
+
+ public void setAirMode(int airMode) {
+ this.airMode = airMode;
+ }
+
+ public byte[] getCurState() {
+ return curState;
+ }
+
+ public void setCurState(byte[] curState) {
+ this.curState = curState;
+ }
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java
new file mode 100644
index 0000000..3827c58
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java
@@ -0,0 +1,448 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition.Parser;
+
+
+import com.hdl.sdk.ttl.Config.Configuration;
+import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLDeviceManager;
+
+/**
+ * Created by Tommy on 2017/7/20.
+ */
+
+public class AirCtrlParser {
+ public static final int fail = 0;
+ public static final int infrared = 1;
+ public static final int panelLock = 2;
+
+ public static final int airSwich = 3;
+ public static final int airOn = 1;//绌鸿皟寮�
+ public static final int airOff = 0;//绌鸿皟鍏�
+
+ public static final int refTem = 4;//鍒跺喎娓╁害
+
+ public static final int airSpeed = 5;//椋庨��
+ public static final int airSpeedAuto = 0;//椋庨�熻嚜鍔�
+ public static final int airSpeedHigh = 1;//椋庨�熼珮椋�
+ public static final int airSpeedMid = 2;//椋庨�熶腑椋�
+ public static final int airSpeedLow = 3;//椋庨�熶綆椋�
+
+ public static final int airMode = 6;//绌鸿皟妯″紡
+ public static final int airModeRefTem = 0;//绌鸿皟妯″紡鍒跺喎
+ public static final int airModeHeatTem = 1;//绌鸿皟妯″紡鍒剁儹
+ public static final int airModeVen = 2;//绌鸿皟妯″紡閫氶
+ public static final int airModeAuto = 3;//绌鸿皟妯″紡鑷姩
+ public static final int airModeDehum = 4;//绌鸿皟妯″紡鎶芥箍
+
+ public static final int heatTem = 7;//鍒剁儹娓╁害
+ public static final int autoTem = 8;//鑷姩娓╁害
+ public static final int upTem = 9;//涓婂崌娓╁害
+ public static final int downTem = 10;//涓嬮檷娓╁害
+
+ public static final int dehumTem = 19;//鎶芥箍娓╁害
+
+
+ public static byte[] getAirPanelAddByte(int type, int arg2) {
+ byte[] addBytes;
+ switch (type) {
+ case airSwich:
+ if (arg2 == airOff) {
+ addBytes = new byte[]{airSwich, (byte) arg2};
+ } else if (arg2 == airOn) {
+ addBytes = new byte[]{airSwich, (byte) arg2};
+ } else {
+ addBytes = new byte[]{fail};
+ }
+ break;
+ case refTem:
+ addBytes = new byte[]{refTem, (byte) arg2};
+ break;
+ case airSpeed:
+ switch (arg2) {
+ case airSpeedAuto:
+ addBytes = new byte[]{airSpeed, airSpeedAuto};
+ break;
+ case airSpeedHigh:
+ addBytes = new byte[]{airSpeed, airSpeedHigh};
+ break;
+ case airSpeedMid:
+ addBytes = new byte[]{airSpeed, airSpeedMid};
+ break;
+ case airSpeedLow:
+ addBytes = new byte[]{airSpeed, airSpeedLow};
+ break;
+ default:
+ addBytes = new byte[]{fail};
+ break;
+ }
+ break;
+ case airMode:
+ switch (arg2) {
+ case airModeRefTem:
+ addBytes = new byte[]{airMode, airModeRefTem};
+ break;
+ case airModeHeatTem:
+ addBytes = new byte[]{airMode, airModeHeatTem};
+ break;
+ case airModeVen:
+ addBytes = new byte[]{airMode, airModeVen};
+ break;
+ case airModeAuto:
+ addBytes = new byte[]{airMode, airModeAuto};
+ break;
+ case airModeDehum:
+ addBytes = new byte[]{airMode, airModeDehum};
+ break;
+ default:
+ addBytes = new byte[]{fail};
+ break;
+ }
+ break;
+ case heatTem:
+ addBytes = new byte[]{heatTem, (byte) arg2};
+ break;
+ case autoTem:
+ addBytes = new byte[]{autoTem, (byte) arg2};
+ break;
+ case dehumTem:
+ addBytes = new byte[]{dehumTem, (byte) arg2};
+ break;
+ case upTem:
+ addBytes = new byte[]{upTem, (byte) arg2};
+ break;
+ case downTem:
+ addBytes = new byte[]{downTem, (byte) arg2};
+ break;
+ default:
+ addBytes = new byte[]{fail};
+ break;
+ }
+ return addBytes;
+ }
+
+ public static byte[] getAcAddByte(AppliancesInfo appliancesInfo, int type, int state) {
+
+ try {
+ AppliancesInfo newInfo = null;
+ byte[] airBytes = null;
+ outter:
+ for (int i = 0; i < HDLDeviceManager.devicesDataList.size(); i++) {
+ if (appliancesInfo.getDeviceSubnetID() == HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID()
+ && appliancesInfo.getDeviceDeviceID() == HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID()) {
+ for (int j = 0; j < HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().size(); j++) {
+ if (HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType() == Configuration.AIR_BIG_TYPE
+ && HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType() != HDLApConfig.TYPE_AC_PANEL
+ && appliancesInfo.getChannelNum() == HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum()) {
+ newInfo = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j);
+ if (newInfo.getArrCurState() == null) {
+ newInfo.setArrCurState(new byte[13]);
+ }
+ airBytes = newInfo.getArrCurState();
+ break outter;
+ }
+
+ }
+ }
+ }
+ byte[] addBytes = new byte[13];
+ if (airBytes != null && airBytes.length >= 13) {
+ System.arraycopy(airBytes, 0, addBytes, 0, airBytes.length);
+ addBytes[0] = (byte) newInfo.getChannelNum();
+
+ switch (type) {
+ case airSwich://璁剧疆寮�鍏崇姸鎬�
+ if (state == airOff) {
+ addBytes[8] = 0;
+ } else {
+ addBytes[8] = 1;
+ }
+ break;
+ case refTem:
+ case heatTem:
+ case autoTem:
+ case dehumTem://璁剧疆娓╁害
+ addBytes[8] = 1;
+ addBytes[3] = (byte) state;
+ addBytes[4] = (byte) state;
+ addBytes[5] = (byte) state;
+ addBytes[6] = (byte) state;
+ addBytes[11] = (byte) state;
+ break;
+ case upTem://鍗囨俯
+ addBytes[8] = 1;
+ addBytes[3] = (byte) ((airBytes[2] & 0xff) + state);
+ addBytes[4] = (byte) ((airBytes[2] & 0xff) + state);
+ addBytes[5] = (byte) ((airBytes[2] & 0xff) + state);
+ addBytes[6] = (byte) ((airBytes[2] & 0xff) + state);
+ addBytes[11] = (byte) ((airBytes[2] & 0xff) + state);
+ break;
+ case downTem://闄嶆俯
+ addBytes[8] = 1;
+ addBytes[3] = (byte) ((airBytes[2] & 0xff) - state);
+ addBytes[4] = (byte) ((airBytes[2] & 0xff) - state);
+ addBytes[5] = (byte) ((airBytes[2] & 0xff) - state);
+ addBytes[6] = (byte) ((airBytes[2] & 0xff) - state);
+ addBytes[11] = (byte) ((airBytes[2] & 0xff) - state);
+ break;
+ case airMode://璁剧疆绌鸿皟妯″紡
+ addBytes[8] = 1;
+ addBytes[7] = (byte) (state * 16 + (airBytes[3] & 0xff));
+ addBytes[9] = (byte) state;
+ break;
+ case airSpeed://璁剧疆椋庨��
+ addBytes[8] = 1;
+ addBytes[7] = (byte) ((airBytes[1] & 0xff) * 16 + state);
+ addBytes[10] = (byte) state;
+ break;
+ }
+ }else {
+ addBytes[0] = (byte) newInfo.getChannelNum();
+ addBytes[1] = 0;
+ addBytes[2] = (byte)28;
+ addBytes[3] = (byte)28;
+ addBytes[4] = (byte)28;
+ addBytes[5] = (byte)28;
+ addBytes[6] = (byte)28;
+ addBytes[7] = 0;
+ addBytes[8] = 1;
+ addBytes[9] = 0;
+ addBytes[10] = 0;
+ addBytes[11] = (byte)28;
+ addBytes[12] = 0;
+ switch (type) {
+ case airSwich://璁剧疆寮�鍏崇姸鎬�
+ if (state == airOff) {
+ addBytes[8] = 0;
+ } else {
+ addBytes[8] = 1;
+ }
+ break;
+ case refTem:
+ case heatTem:
+ case autoTem:
+ case dehumTem://璁剧疆娓╁害
+ addBytes[8] = 1;
+ addBytes[3] = (byte) state;
+ addBytes[4] = (byte) state;
+ addBytes[5] = (byte) state;
+ addBytes[6] = (byte) state;
+ addBytes[11] = (byte) state;
+ break;
+ case upTem://鍗囨俯
+ addBytes[8] = 1;
+ addBytes[3] = (byte) (28 + state);
+ addBytes[4] = (byte) (28 + state);
+ addBytes[5] = (byte) (28 + state);
+ addBytes[6] = (byte) (28 + state);
+ addBytes[11] = (byte) (28 + state);
+ break;
+ case downTem://闄嶆俯
+ addBytes[8] = 1;
+ addBytes[3] = (byte) (28 - state);
+ addBytes[4] = (byte) (28 - state);
+ addBytes[5] = (byte) (28 - state);
+ addBytes[6] = (byte) (28 - state);
+ addBytes[11] = (byte) (28 - state);
+ break;
+ case airMode://璁剧疆绌鸿皟妯″紡
+ addBytes[8] = 1;
+ addBytes[7] = (byte) (state * 16);
+ addBytes[9] = (byte) state;
+ break;
+ case airSpeed://璁剧疆椋庨��
+ addBytes[8] = 1;
+ addBytes[7] = (byte) (state);
+ addBytes[10] = (byte) state;
+ break;
+ }
+ }
+
+
+ return addBytes;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return new byte[]{fail};
+ }
+
+ }
+
+// public static byte[] getRcuAirAddByte(AppliancesInfo I,int type, int arg2){
+// byte[] addBytes = new byte[9];
+// addBytes[4] = 1;
+// byte[] curAirInfo = I.getArrCurState();
+// switch (I.getChannelNum()){
+// case 1:
+// curAirInfo = HDLDeviceManager.air1Info;
+// break;
+// case 2:
+// curAirInfo = HDLDeviceManager.air2Info;
+// break;
+// case 3:
+// curAirInfo = HDLDeviceManager.air3Info;
+// break;
+// case 4:
+// curAirInfo = HDLDeviceManager.air4Info;
+// break;
+// }
+//
+// byte airSwitch = curAirInfo[0];
+// byte aircurMode = curAirInfo[1];
+// byte airTem = curAirInfo[2];
+// byte aircurSpeed = curAirInfo[3];
+// byte aircurTem = curAirInfo[4];
+// byte airBAIFENG = curAirInfo[5];
+//
+// addBytes[0] = (byte) I.getChannelNum();
+// addBytes[1] = airSwitch;
+// switch (aircurMode){
+// case 0:
+// addBytes[2] = airTem;
+// break;
+// case 1:
+// addBytes[5] = airTem;
+// break;
+// case 2:
+// break;
+// case 3:
+// addBytes[6] = airTem;
+// break;
+// }
+// addBytes[3] = (byte) ((aircurMode << 4) | aircurSpeed);
+// addBytes[4] = 1;
+// addBytes[8] = airBAIFENG;
+// switch (type){
+// case airSwich:
+// if(arg2 == airOff){
+// addBytes[1] = 0;
+// }else if(arg2 == airOn){
+// addBytes[1] = 1;
+// }
+// break;
+// case refTem:
+// addBytes[2] = (byte) arg2;
+// addBytes[5] = (byte) arg2;
+// addBytes[6] = (byte) arg2;
+// addBytes[7] = (byte) arg2;
+// break;
+// case airSpeed :
+// int modifyLow;
+// int height = ((addBytes[3] & 0xf0) >> 4);//鑾峰彇楂�4浣�
+// switch (arg2){
+// case airSpeedAuto:
+// modifyLow = 0;
+// addBytes[3] = (byte)((height<<4)|modifyLow);
+// break;
+// case airSpeedHigh:
+// modifyLow = 1;
+// addBytes[3] = (byte)((height<<4)|modifyLow);
+// break;
+// case airSpeedMid:
+// modifyLow = 2;
+// addBytes[3] = (byte)((height<<4)|modifyLow);
+// break;
+// case airSpeedLow:
+// modifyLow = 3;
+// addBytes[3] = (byte)((height<<4)|modifyLow);
+// break;
+// default:
+// addBytes = new byte[]{fail};
+// break;
+// }
+// break;
+// case airMode:
+// int modify;
+// int low = (addBytes[3] & 0x0f);//鑾峰彇浣�4浣�
+// switch (arg2){
+// case airModeRefTem:
+//
+// modify = 0;
+// addBytes[3] = (byte)((modify<<4)|low);
+// break;
+// case airModeHeatTem:
+// modify = 1;
+// addBytes[3] = (byte)((modify<<4)|low);
+// break;
+// case airModeVen:
+// modify = 2;
+// addBytes[3] = (byte)((modify<<4)|low);
+// break;
+// case airModeAuto:
+// modify = 3;
+// addBytes[3] = (byte)((modify<<4)|low);
+// break;
+// case airModeDehum:
+// modify = 4;
+// addBytes[3] = (byte)((modify<<4)|low);
+// break;
+// default:
+// addBytes = new byte[]{fail};
+// break;
+// }
+// break;
+// case heatTem:
+// addBytes[2] = (byte) arg2;
+// addBytes[5] = (byte) arg2;
+// addBytes[6] = (byte) arg2;
+// addBytes[7] = (byte) arg2;
+// break;
+// case autoTem:
+// addBytes[2] = (byte) arg2;
+// addBytes[5] = (byte) arg2;
+// addBytes[6] = (byte) arg2;
+// addBytes[7] = (byte) arg2;
+// break;
+// case dehumTem:
+// addBytes[2] = (byte) arg2;
+// addBytes[5] = (byte) arg2;
+// addBytes[6] = (byte) arg2;
+// addBytes[7] = (byte) arg2;
+// break;
+// case upTem:
+//// int height2 = ((addBytes[3] & 0xf0) >> 4);//鑾峰彇楂�4浣�
+//// switch (height2){
+//// case 0:
+//// addBytes[2] = (byte) (arg2 + (airTem & 0xFF));
+//// break;
+//// case 1:
+//// addBytes[5] = (byte) (arg2 + (airTem & 0xFF));
+//// break;
+//// case 3:
+//// addBytes[6] = (byte) (arg2 + (airTem & 0xFF));
+//// break;
+//// case 4:
+//// addBytes[7] = (byte) (arg2 + (airTem & 0xFF));
+//// break;
+//// }
+// addBytes[2] = (byte) (arg2 + (airTem & 0xFF));
+// addBytes[5] = (byte) (arg2 + (airTem & 0xFF));
+// addBytes[6] = (byte) (arg2 + (airTem & 0xFF));
+// addBytes[7] = (byte) (arg2 + (airTem & 0xFF));
+// break;
+// case downTem:
+//// int height3= ((addBytes[3] & 0xf0) >> 4);//鑾峰彇楂�4浣�
+//// switch (height3){
+//// case 0:
+//// addBytes[2] = (byte) ((airTem & 0xFF)-arg2 );
+//// break;
+//// case 1:
+//// addBytes[5] = (byte) ((airTem & 0xFF)-arg2 );
+//// break;
+//// case 3:
+//// addBytes[6] = (byte) ((airTem & 0xFF)-arg2 );
+//// break;
+//// case 4:
+//// addBytes[7] = (byte) ((airTem & 0xFF)-arg2 );
+//// break;
+//// }
+// addBytes[2] = (byte) ((airTem & 0xFF)-arg2 );
+// addBytes[5] = (byte) ((airTem & 0xFF)-arg2 );
+// addBytes[6] = (byte) ((airTem & 0xFF)-arg2 );
+// addBytes[7] = (byte) ((airTem & 0xFF)-arg2 );
+// break;
+// default:
+// addBytes = new byte[]{fail};
+// break;
+// }
+// return addBytes;
+// }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/HDLAudio.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/HDLAudio.java
new file mode 100644
index 0000000..68498d4
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/HDLAudio.java
@@ -0,0 +1,394 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLAudio;
+
+import android.util.Log;
+
+import com.hdl.sdk.ttl.Config.Configuration;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.UdpDataBean;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.AudioInfoEvent;
+import com.hdl.sdk.ttl.Utils.HDLUtlis.HDLStringUtils;
+
+import org.greenrobot.eventbus.EventBus;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static com.hdl.sdk.ttl.Utils.HDLUtlis.HDLStringUtils.stringToAscii;
+
+
+/**
+ * Created by Tommy on 2017/10/24.
+ * 闊充箰鎾斁鍣�
+ */
+
+public class HDLAudio {
+ //*SsPLAYSTOP 鎾斁/鍋滄
+//*SsPLAYPAUSE 鎾斁/鍋滄
+//*SsPLAY 鎾斁
+//*SsSTOP 鍋滄
+//#SsDISPINFO,DUR1945,POS0,STATUS2
+// DUR鍚庢暟鍊硷細涓烘瓕鏇叉挱鏀炬�绘椂闂� 锛堢脳10锛屽疄闄呮椂闂寸殑10鍊嶏級
+// POS鍚庢暟鍊硷細涓烘瓕鏇插凡鎾斁鏃堕棿 锛堢脳10锛屽疄闄呮椂闂寸殑10鍊嶏級
+// STATUS鍚庢暟鍊硷細涓�1琛ㄧずstop,涓�2琛ㄧずplay,涓�3琛ㄧずpause
+//*SsPREVLIST 涓婁竴鍒楄〃
+//*SsNEXTLIST<CR> 涓嬩竴鍒楄〃
+//*SsPREV<CR> 涓婁竴棣� s鏄簮鍙�(1-9)
+//*SsNEXT<CR> 涓嬩竴棣� s鏄簮鍙�(1-9)
+ public static final int CALLBACK_SONG_NAME_LIST = 100;//鑾峰彇闊充箰鍒楄〃
+ public static final int CALLBACK_CURRENT_VOLUME = 101;//褰撳墠闊抽噺
+ public static final int CALLBACK_AUDIO_LIST_NUM = 102;//褰撳墠鍒楄〃鏁�
+ public static final int CALLBACK_CURRENT_LIST_NAME = 103;//褰撳墠鍒楄〃鍚�
+ public static final int CALLBACK_CURRENT_SONG_NUM = 104;//褰撳墠姝屾洸鏁�
+ public static final int CALLBACK_CURRENT_SONG_NAME = 105;//褰撳墠姝屾洸鍚�
+ public static final int CALLBACK_CURRENT_SONG_INFO = 106;//褰撳墠姝屾洸淇℃伅
+ public static final int CALLBACK_CURRENT_MODE = 107;//褰撳墠鎾斁妯″紡
+
+ public static final int GET_AUDIO_LIST = 200;
+ public static final int SET_AUDIO_VOL = 201;
+ public static final int SET_AUDIO_PLAYSTOP = 202;
+ public static final int SET_AUDIO_PLAYPAUSE = 203;
+ public static final int SET_CHOOSE_PLAY_SONG = 204;
+ public static final int SET_NEXT_SONG = 205;
+ public static final int SET_PRE_SONG = 206;
+ public static final int GET_AUDIO_MODE = 207;
+ public static final int SET_AUDIO_MODE_UP = 208;
+ public static final int SET_AUDIO_MODE_DOWN = 209;
+ public static final int GET_AUDIO_CURRRENT_INFO = 210;
+ public static final int SET_NEXT_LIST = 211;
+ public static final int SET_PRE_LIST = 212;
+
+ public static final int TEXT = 300;
+
+ public static boolean isSetPreNextList = false;
+ public static List<String> numStr = new ArrayList<>();
+ public static List<String> songNameList = new ArrayList<>();
+ public static int curListNum = 0;
+ private static Timer timer = null;
+
+ public static void parseAudioData(UdpDataBean getDatas, AppliancesInfo audioInfo) {
+
+ List<Integer> intAllData = new ArrayList<>();
+ List<Integer> intMusicData = new ArrayList<>();
+ List<Integer> intName = new ArrayList<>();
+ int posSTX = 0;
+// String allData = "";
+ for (int i = 0; i < getDatas.addBytes.length; i++) {
+// allData += (getDatas.AddBytes[i]&0xff)+",";
+ if ((getDatas.addBytes[i] & 0xff) == 2) {
+ posSTX = i;
+ }
+ if (posSTX == 0) {
+ intAllData.add(getDatas.addBytes[i] & 0xFF);
+ if ((getDatas.addBytes[i] & 0xff) != 44) {
+ intMusicData.add(getDatas.addBytes[i] & 0xFF);
+ }
+
+ } else {
+ if ((getDatas.addBytes[i] & 0xff) != 2 && (getDatas.addBytes[i] & 0xff) != 3) {
+ intName.add(getDatas.addBytes[i] & 0xFF);
+ }
+ if ((getDatas.addBytes[i] & 0xff) == 3) {
+ intName.remove(intName.size() - 1);
+ break;
+ }
+ }
+ }
+// Log.i("djl","鎵�鏈夋暟鎹細"+allData);
+ for (int i = 0; i < intName.size(); i++) {
+ if (i % 2 != 0) {
+ intAllData.add(intName.get(i - 1) * 256 + intName.get(i));
+ }
+ }
+
+ String musicData = "";
+ for (int i = 0; i < intAllData.size(); i++) {
+ musicData += intAllData.get(i) + ",";
+ }
+ musicData = HDLStringUtils.asciiToString(musicData);
+// Log.i("djl","闊充箰ascii锛�"+musicData);
+
+ handleMusicData(getDatas, musicData, intMusicData, audioInfo);
+
+ }
+
+ private static void handleMusicData(final UdpDataBean getDatas, String musicData, List<Integer> intMusicData, AppliancesInfo audioInfo) {
+ Log.i("djl","musicData = "+musicData);
+ String[] arrMusicData = musicData.split(",");
+ if (isExitData(arrMusicData[0], "DISPLINE1")) {
+ String[] arr1 = arrMusicData[1].split(":");
+ if (arr1.length <= 1) {
+ return;
+ }
+ String[] arr2 = arr1[1].split("/");
+ int[] audioListInfo = new int[2];
+ audioListInfo[0] = Integer.parseInt(arr2[0]);
+ audioListInfo[1] = Integer.parseInt(arr2[1]);
+
+ if (isSetPreNextList) {
+ isSetPreNextList = false;
+ numStr.clear();
+ songNameList.clear();
+ AppliancesInfo info = new AppliancesInfo();
+ info.setDeviceSubnetID(getDatas.sourceSubnetID);
+ info.setDeviceDeviceID(getDatas.sourceDeviceID);
+ HDLCommand.audioCtrl(info, HDLAudio.GET_AUDIO_LIST, audioListInfo[0]);
+ }
+
+ EventBus.getDefault().post(new AudioInfoEvent(CALLBACK_AUDIO_LIST_NUM, audioListInfo, audioInfo));
+ } else if (isExitData(arrMusicData[0], "DISPLINE2")) {
+ EventBus.getDefault().post(new AudioInfoEvent(CALLBACK_CURRENT_LIST_NAME, arrMusicData[1], audioInfo));
+ } else if (isExitData(arrMusicData[0], "DISPLINE3")) {
+// String[] songNumInfoStr = new String[2];
+// songNumInfoStr[0] = "";
+// songNumInfoStr[1] = "";
+// for (int i = 2, len = arrMusicData[1].length(); i < len; i++) {
+// if (i == 2) {
+// songNumInfoStr[0] += arrMusicData[1].charAt(i);
+// } else if (i >= 4) {
+// songNumInfoStr[1] += arrMusicData[1].charAt(i) + "";
+// }
+// }
+// int[] songNumInfo = new int[2];
+// songNumInfo[0] = Integer.parseInt(songNumInfoStr[0]);
+// songNumInfo[1] = Integer.parseInt(songNumInfoStr[1]);
+// EventBus.getDefault().post(new AudioInfoEvent(CALLBACK_CURRENT_SONG_NUM, songNumInfo, audioInfo));
+
+ //2019-8-7 鏂规璋冩暣
+ String arrMusicDataStr = arrMusicData[1].toString();
+ String[] arrMusicDataStrArray = arrMusicDataStr.split("/");
+ if(arrMusicDataStrArray.length > 1){
+ int[] songNumInfo = new int[2];
+ String regEx="[^0-9]";
+ Pattern mPattern = Pattern.compile(regEx);
+ Matcher mMatcher0 = mPattern.matcher(arrMusicDataStrArray[0]);
+ songNumInfo[0] = Integer.parseInt(mMatcher0.replaceAll("").trim());
+ Matcher mMatcher1 = mPattern.matcher(arrMusicDataStrArray[1]);
+ songNumInfo[1] = Integer.parseInt(mMatcher1.replaceAll("").trim());
+ EventBus.getDefault().post(new AudioInfoEvent(CALLBACK_CURRENT_SONG_NUM, songNumInfo, audioInfo));
+ }
+
+ } else if (isExitData(arrMusicData[0], "DISPLINE4")) {
+ EventBus.getDefault().post(new AudioInfoEvent(CALLBACK_CURRENT_SONG_NAME, arrMusicData[1], audioInfo));
+ } else if (isExitData(arrMusicData[0], "DISPINFO")) {
+ String durStr = "";
+ String posStr = "";
+ String statusStr = "";
+ for (int i = 3, len = arrMusicData[1].length(); i < len; i++) {
+ if (Character.isDigit(arrMusicData[1].charAt(i))) {
+ durStr += arrMusicData[1].charAt(i);
+ }
+ }
+
+ for (int i = 3, len = arrMusicData[2].length(); i < len; i++) {
+ if (Character.isDigit(arrMusicData[2].charAt(i))) {
+ posStr += arrMusicData[2].charAt(i);
+ }
+ }
+
+ statusStr += arrMusicData[3].charAt(6);
+
+ int durInt = Integer.parseInt(durStr) / 10;
+ int posInt = Integer.parseInt(posStr) / 10;
+ int statusInt = Integer.parseInt(statusStr);
+ EventBus.getDefault().post(new AudioInfoEvent(CALLBACK_CURRENT_SONG_INFO, new int[]{durInt, posInt, statusInt}, audioInfo));
+ } else if (isExitData(arrMusicData[0], "DISPMODE")) {
+ String audioModeStr = arrMusicData[1].charAt(6) + "";
+ EventBus.getDefault().post(new AudioInfoEvent(CALLBACK_CURRENT_MODE, Integer.parseInt(audioModeStr), audioInfo));
+ } else if (isExitData(musicData, ",ON,SRC") || isExitData(musicData, ",OFF,SRC")) {
+ String vol = arrMusicData[3];
+ String volNum = "";
+ for (int i = 3, len = vol.length(); i < len; i++) {
+ if (Character.isDigit(vol.charAt(i))) {
+ volNum += vol.charAt(i);
+ }
+ }
+ EventBus.getDefault().post(new AudioInfoEvent(CALLBACK_CURRENT_VOLUME, 79 - (Integer.parseInt(volNum)), audioInfo));
+ } else if (isExitData(arrMusicData[0], "TYPE")) {
+ Log.i("djl","Type ----> musicData = "+musicData);
+ byte[] musicBytes = audioGetListParse(curListNum, 1);
+ sendAudioData(getDatas, musicBytes);
+ } else if (isExitData(arrMusicData[0], "LIST")) {
+
+ String num = "";
+ for (int i = 12; i < 15; i++) {
+ num += arrMusicData[0].charAt(i);
+ }
+ int intNum = Integer.parseInt(num);
+ if (curListNum == intNum) {//鍒ゆ柇鍥炲鐨勬暟鎹槸鍚︿负褰撳墠鍒楄〃鏁�
+ byte[] musicBytes = audioGetListParse(curListNum, 2);
+ sendAudioData(getDatas, musicBytes);
+ }
+ } else if (isExitData(arrMusicData[0], "SONG")) {
+ String num = "";
+ for (int i = 12; i < 15; i++) {
+ num += arrMusicData[0].charAt(i);
+ }
+ int intNum = Integer.parseInt(num);
+ if (curListNum == intNum) {
+ //鍒ゆ柇鍥炲鐨勬暟鎹槸鍚︿负褰撳墠鍒楄〃鏁�
+ if (timer == null) {
+ timer = new Timer();
+ } else {
+ timer.cancel();
+ timer = null;
+ timer = new Timer();
+ }
+ if (numStr.size() == 0) {
+ numStr.add(arrMusicData[0]);
+ songNameList.add(arrMusicData[1]);
+ } else {
+ if (!numStr.contains(arrMusicData[0])) {
+ numStr.add(arrMusicData[0]);
+ songNameList.add(arrMusicData[1]);
+ }
+ }
+ final byte[] musicBytes = new byte[intMusicData.size() + 1];
+ musicBytes[musicBytes.length - 1] = 13;
+ for (int i = 0, len = musicBytes.length - 1; i < len; i++) {
+ musicBytes[i] = (byte) intMusicData.get(i).intValue();
+ }
+ int num1 = musicBytes[musicBytes.length - 5] & 0xff;
+ int num2 = musicBytes[musicBytes.length - 4] & 0xff;
+ int num3 = musicBytes[musicBytes.length - 3] & 0xff;
+ int num4 = musicBytes[musicBytes.length - 2] & 0xff;
+ if (num4 == 48) {
+ if ((num3) == 57) {
+ num3 = 48;
+ if (num2 == 57) {
+ num2 = 48;
+ num1++;
+ } else {
+ num2++;
+ }
+
+ } else {
+ num3++;
+ }
+ musicBytes[0] = 42;
+ musicBytes[musicBytes.length - 5] = (byte) num1;
+ musicBytes[musicBytes.length - 4] = (byte) num2;
+ musicBytes[musicBytes.length - 3] = (byte) num3;
+ musicBytes[musicBytes.length - 2] = 49;
+
+ timer.schedule(new TimerTask() {
+ public void run() {
+ sendAudioData(getDatas, musicBytes);
+ }
+ }, 500, 300);
+ sendAudioData(getDatas, musicBytes);
+ } else {
+ EventBus.getDefault().post(new AudioInfoEvent(CALLBACK_SONG_NAME_LIST, songNameList, audioInfo));
+ AppliancesInfo info = new AppliancesInfo();
+ info.setDeviceSubnetID(getDatas.sourceSubnetID);
+ info.setDeviceDeviceID(getDatas.sourceDeviceID);
+
+ }
+ }
+
+
+ }
+ }
+
+
+ private static void sendAudioData(UdpDataBean getDatas, byte[] musicBytes) {
+// String sendData = "";
+// for(int i = 0,len = musicBytes.length;i<len;i++){
+// sendData += musicBytes[i]+",";
+// }
+// sendData = HDLStringUtils.asciiToString(sendData);
+// Log.i("djl","鍙戝嚭鏁版嵁锛�"+sendData);
+ HDLCommand.cusSendCommand(Configuration.AUDIO_MenuPlay_INSTRUCTION_COMMAND,
+ getDatas.sourceSubnetID, getDatas.sourceDeviceID, musicBytes);
+ }
+
+ private static boolean isExitData(String str, String type) {
+ return str.indexOf(type) != -1;
+ }
+
+ public static byte[] audioVolparse(int vol) {
+ if (vol > 79 || vol < 0) {
+ Log.i("djl", "闈炴硶鏁版嵁");
+ return null;
+ } else {
+ int intAsc = 79 - vol;
+ String strAsc = "";
+ if (intAsc < 10) {
+ strAsc = "0" + intAsc;
+ } else {
+ strAsc += intAsc / 10;
+ strAsc += intAsc % 10;
+ }
+ String byteAsc = stringToAscii(strAsc);
+ String[] arrAsc = byteAsc.split(",");
+ int a1 = Integer.parseInt(arrAsc[0]);
+ int a2 = Integer.parseInt(arrAsc[1]);
+ return new byte[]{0x2A, 0x5A, 0x31, 0x56, 0x4F, 0x4C, (byte) a1, (byte) a2, 0x0D};
+ }
+ }
+
+ public static byte[] audioChooseSongParse(int value1, int value2) {
+ int listNum = value1;
+ int songNum = value2 + 1;
+ String songNumStrAsc = "";
+ String listNumStrAsc = "";
+ if (songNum < 10) {
+ songNumStrAsc = "00" + songNum;
+ } else if (songNum >= 10 && songNum < 100) {
+ songNumStrAsc = "0" + songNum;
+ } else {
+ songNumStrAsc += songNum;
+ }
+
+ if (listNum < 10) {
+ listNumStrAsc = "00" + listNum;
+ } else if (listNum >= 10 && listNum < 100) {
+ listNumStrAsc = "0" + listNum;
+ } else {
+ listNumStrAsc += listNum;
+ }
+
+ String songNumByteAsc = stringToAscii(songNumStrAsc);
+ String listNumByteAsc = stringToAscii(listNumStrAsc);
+
+ String[] songNumArrAsc = songNumByteAsc.split(",");
+ String[] listNumArrAsc = listNumByteAsc.split(",");
+
+ int a1 = Integer.parseInt(songNumArrAsc[0]);
+ int a2 = Integer.parseInt(songNumArrAsc[1]);
+ int a3 = Integer.parseInt(songNumArrAsc[2]);
+
+ int b1 = Integer.parseInt(listNumArrAsc[0]);
+ int b2 = Integer.parseInt(listNumArrAsc[1]);
+ int b3 = Integer.parseInt(listNumArrAsc[2]);
+//*Z011SONG001
+ return new byte[]{0x2A, 0x5A, 0x30, 0x31, 0x31, 0x53, 0x4F, 0x4E, 0x47, 0x30
+ , 0x30, 0x31, (byte) b1, (byte) b2, (byte) b3, (byte) a1, (byte) a2, (byte) a3, 0x32, 0x0D};
+ }
+
+ private static byte[] audioGetListParse(int num, int type) {
+ String strAsc = "";
+ if (num < 10) {
+ strAsc = "00" + num;
+ } else if (num >= 10 && num < 100) {
+ strAsc = "0" + num;
+ } else {
+ strAsc += num;
+ }
+ String byteAsc = stringToAscii(strAsc);
+ String[] arrAsc = byteAsc.split(",");
+ int a1 = Integer.parseInt(arrAsc[0]);
+ int a2 = Integer.parseInt(arrAsc[1]);
+ int a3 = Integer.parseInt(arrAsc[2]);
+ if (type == 1) {
+ return new byte[]{0x2A, 0x5A, 0x30, 0x31, 0x31, 0x4C, 0x49, 0x53,
+ 0x54, 0x30, 0x30, 0x31, (byte) a1, (byte) a2, (byte) a3, 0x31, 0x0D};
+ } else {
+ return new byte[]{42, 90, 48, 49, 49, 83, 79, 78, 71, 48, 48, 49, (byte) a1, (byte) a2, (byte) a3, 48, 48, 49, 49, 13};
+ }
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmCtrlBean.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmCtrlBean.java
new file mode 100644
index 0000000..d393269
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmCtrlBean.java
@@ -0,0 +1,15 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLAudio.bean;
+
+//*SsPLAYSTOP<CR>
+//*SsPLAYSTOP<CR>
+//*SsPLAY<CR>
+//*SsSTOP<CR>
+//绗笁鏂硅儗鏅煶涔愭帶鍒� 鎾斁銆佹殏鍋溿�佸仠姝� 鍥炲Bean
+public class HDLBgmCtrlBean {
+ private int sourceNum;//婧愬彿
+ private int songDur;//褰撳墠姝屾洸鎬绘椂闀匡紙绉掞級
+ private int songPos;//褰撳墠姝屾洸宸叉挱鏀炬椂闂达紙绉掞級
+ private int songStatus;//褰撳墠姝屾洸鎾斁鐘舵�併�傚��1锛氬仠姝紝鍊�2锛氭挱鏀撅紝鍊�3锛氭殏鍋�
+
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmCtrlListBean.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmCtrlListBean.java
new file mode 100644
index 0000000..00595ab
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmCtrlListBean.java
@@ -0,0 +1,20 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLAudio.bean;
+
+//*SsPREVLIST<CR>
+//*SsPREVLIST<CR>
+//绗笁鏂硅儗鏅煶涔愪笂涓�鍒楄〃銆佷笅涓�鍒楄〃 鍥炲Bean
+public class HDLBgmCtrlListBean {
+ private int sourceNum;//婧愬彿
+ private int listNum;//褰撳墠鍒楄〃鍙�
+ private int listSum;//鍒楄〃鎬绘暟
+ private int songNum;//褰撳墠姝屾洸鍙�
+ private int songSum;//姝屾洸鎬绘暟
+ private String songName;//姝屾洸鍚嶏紝涓嶈秴杩�50涓瓧鑺�
+ private int songDur;//褰撳墠姝屾洸鎬绘椂闀匡紙绉掞級
+ private int songPos;//褰撳墠姝屾洸宸叉挱鏀炬椂闂达紙绉掞級
+ private int songStatus;//褰撳墠姝屾洸鎾斁鐘舵�併�傚��1锛氬仠姝紝鍊�2锛氭挱鏀撅紝鍊�3锛氭殏鍋�
+
+
+
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmCtrlSongBean.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmCtrlSongBean.java
new file mode 100644
index 0000000..b00a811
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmCtrlSongBean.java
@@ -0,0 +1,11 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLAudio.bean;
+
+public class HDLBgmCtrlSongBean {
+ private int sourceNum;//婧愬彿
+ private int songNum;//褰撳墠姝屾洸鍙�
+ private int songSum;//姝屾洸鎬绘暟
+ private String songName;//姝屾洸鍚嶏紝涓嶈秴杩�50涓瓧鑺�
+ private int songDur;//褰撳墠姝屾洸鎬绘椂闀匡紙绉掞級
+ private int songPos;//褰撳墠姝屾洸宸叉挱鏀炬椂闂达紙绉掞級
+ private int songStatus;//褰撳墠姝屾洸鎾斁鐘舵�併�傚��1锛氬仠姝紝鍊�2锛氭挱鏀撅紝鍊�3锛氭殏鍋�
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmModeBean.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmModeBean.java
new file mode 100644
index 0000000..6c3ea5c
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmModeBean.java
@@ -0,0 +1,26 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLAudio.bean;
+
+//*SsPLAYMODE?<CR>
+//*SsMODE+<CR>
+//*SsPLAYMODE?<CR>
+ //绗笁鏂硅儗鏅煶涔愭挱鏀炬ā寮� 鍥炲Bean
+public class HDLBgmModeBean {
+ private int sourceNum;//婧愬彿
+ private int playMode;//鎾斁妯″紡銆傚��0锛氭湭鐭ャ�傚��1锛氬崟鏇叉挱鏀俱�傚��2锛氬崟鏇插惊鐜�傚��3锛氳繛缁挱鏀俱�傚��4锛氳繛鎾惊鐜�
+
+ public int getSourceNum() {
+ return sourceNum;
+ }
+
+ public void setSourceNum(int sourceNum) {
+ this.sourceNum = sourceNum;
+ }
+
+ public int getPlayMode() {
+ return playMode;
+ }
+
+ public void setPlayMode(int playMode) {
+ this.playMode = playMode;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmSourceBean.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmSourceBean.java
new file mode 100644
index 0000000..7739729
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmSourceBean.java
@@ -0,0 +1,7 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLAudio.bean;
+
+public class HDLBgmSourceBean {
+ private int areaNum;//鍖哄彿
+ private int sourceNum;//婧愬彿
+ private int curVol;//褰撳墠闊抽噺銆傝寖鍥�0-79銆傚绗笁鏂规湁100闊抽噺鍊硷紝搴旇鍥炲79
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmStatusBean.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmStatusBean.java
new file mode 100644
index 0000000..fbaf284
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmStatusBean.java
@@ -0,0 +1,10 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLAudio.bean;
+//*SsPLAYSTOP<CR>
+//绗笁鏂硅儗鏅煶涔愯幏鍙栫姸鎬� 鍥炲Bean
+public class HDLBgmStatusBean {
+ private int areaNum;//鍖哄彿
+ private int sourceNum;//婧愬彿
+ private int songDur;//褰撳墠姝屾洸鎬绘椂闀匡紙绉掞級
+ private int songPos;//褰撳墠姝屾洸宸叉挱鏀炬椂闂达紙绉掞級
+ private int songStatus;//褰撳墠姝屾洸鎾斁鐘舵�併�傚��1锛氬仠姝紝鍊�2锛氭挱鏀撅紝鍊�3锛氭殏鍋�
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmTypeBean.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmTypeBean.java
new file mode 100644
index 0000000..71fa913
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmTypeBean.java
@@ -0,0 +1,10 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLAudio.bean;
+//*ZzzsTYPExxxy<CR>
+public class HDLBgmTypeBean {
+ private String areaNum;//鍖哄彿
+ private String sourceNum;//婧愬彿
+ private String typeNum;//001-999
+ private String isEnd;//0琛ㄧず杩斿洖绫诲瀷鐩綍鏈粨鏉燂紝1琛ㄧず杩斿洖绫诲瀷鐩綍缁撴潫
+ private String typeName;//绫诲瀷鍚�
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmVolBean.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmVolBean.java
new file mode 100644
index 0000000..6984ef2
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLAudio/bean/HDLBgmVolBean.java
@@ -0,0 +1,12 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLAudio.bean;
+
+//绗笁鏂硅儗鏅煶涔� 闊抽噺 鍥炲Bean
+//*ZzVOLx <CR>
+public class HDLBgmVolBean {
+ private int areaNum;//鍖哄彿
+ private int sourceNum;//婧愬彿
+ private int curVol;//褰撳墠闊抽噺銆傝寖鍥�0-79銆傚绗笁鏂规湁100闊抽噺鍊硷紝搴旇鍥炲79
+
+
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLCommonSwitch/CommonSwitchBackInfo.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLCommonSwitch/CommonSwitchBackInfo.java
new file mode 100644
index 0000000..22614f8
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLCommonSwitch/CommonSwitchBackInfo.java
@@ -0,0 +1,38 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLCommonSwitch;
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+
+/**
+ * Created by jlchen on 2020-04-01.
+ */
+public class CommonSwitchBackInfo {
+
+ private AppliancesInfo appliancesInfo;
+ private int switchNum; //鍥炶矾鍙�
+ private int switchState; //寮�鍏崇姸鎬�
+
+ public AppliancesInfo getAppliancesInfo() {
+ return appliancesInfo;
+ }
+
+ public void setAppliancesInfo(AppliancesInfo appliancesInfo) {
+ this.appliancesInfo = appliancesInfo;
+ }
+
+
+ public int getSwitchNum() {
+ return switchNum;
+ }
+
+ public void setSwitchNum(int switchNum) {
+ this.switchNum = switchNum;
+ }
+
+ public int getSwitchState() {
+ return switchState;
+ }
+
+ public void setSwitchState(int switchState) {
+ this.switchState = switchState;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLCurtain/CurtainCtrlBackInfo.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLCurtain/CurtainCtrlBackInfo.java
new file mode 100644
index 0000000..f1d1c09
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLCurtain/CurtainCtrlBackInfo.java
@@ -0,0 +1,76 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLCurtain;
+
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+
+import java.io.Serializable;
+
+/**
+ * Created by djl on 2017/4/1.
+ * 绐楀笜妯″潡
+ */
+
+public class CurtainCtrlBackInfo implements Serializable {
+ //绐楀笜鍙�
+ int num;
+
+ int state;
+
+ String remarks;
+
+ String parentRemarks;
+
+ public AppliancesInfo appliancesInfo;
+
+
+
+ public String getRemarks() {
+ return remarks;
+ }
+
+ public void setRemarks(String remarks) {
+ this.remarks = remarks;
+ }
+
+ public AppliancesInfo getAppliancesInfo() {
+ return appliancesInfo;
+ }
+
+ public void setAppliancesInfo(AppliancesInfo appliancesInfo) {
+ this.appliancesInfo = appliancesInfo;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public int getState() {
+ return state;
+ }
+
+ public void setState(int state) {
+ this.state = state;
+ }
+
+ public String getParentRemarks() {
+ return parentRemarks;
+ }
+
+ public void setParentRemarks(String parentRemarks) {
+ this.parentRemarks = parentRemarks;
+ }
+
+ @Override
+ public String toString() {
+ return "CurtainCtrlBackInfo{" +
+ "num=" + num +
+ ", state=" + state +
+ ", remarks='" + remarks + '\'' +
+ ", parentRemarks='" + parentRemarks + '\'' +
+ '}';
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLCurtain/Parser/CurtainCtrlParser.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLCurtain/Parser/CurtainCtrlParser.java
new file mode 100644
index 0000000..8c03e98
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLCurtain/Parser/CurtainCtrlParser.java
@@ -0,0 +1,42 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLCurtain.Parser;
+
+/**
+ * Created by Tommy on 2017/7/21.
+ */
+
+public class CurtainCtrlParser {
+ public static final int curtainPause = -1;//0
+ public static final int curtainOn = -2;//1
+ public static final int curtainOff = -3;//2
+
+ public static final int TYPE_STATE_PAUSE = 0;
+ public static final int TYPE_STATE_OPEN = 1;
+ public static final int TYPE_STATE_CLOSE = 2;
+
+// //杩欎釜鏂规硶鍙鐞嗕簡绐楀笜鍙峰皬浜�17鐨勬儏鍐�
+ public static byte[] getCurtainAddByte(int curtainNum, int state){
+ byte[] addBytes;
+ int newState = state;
+ switch (state){
+ case curtainPause:
+ newState = 0;
+ break;
+ case curtainOn:
+ newState = 1;
+ break;
+ case curtainOff:
+ newState = 2;
+ break;
+ default:
+ break;
+ }
+ addBytes = new byte[]{(byte) curtainNum, (byte) newState};
+ return addBytes;
+ }
+
+// //杩欎釜鏂规硶鍙鐞嗕簡绐楀笜鍙峰皬浜�17鐨勬儏鍐�
+// public static byte[] getCurtainAddByte(int curtainNum, int state){
+// return new byte[]{(byte) curtainNum, (byte) state};
+// }
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLLight/LightCtrlBackInfo.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLLight/LightCtrlBackInfo.java
new file mode 100644
index 0000000..380a309
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLLight/LightCtrlBackInfo.java
@@ -0,0 +1,98 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLLight;
+
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+
+import java.io.Serializable;
+
+/**
+ * Created by djl on 2017/4/1.
+ * 璋冨厜鍣�
+ */
+
+public class LightCtrlBackInfo implements Serializable {
+ AppliancesInfo appliancesInfo;
+ int channelNum ;//鍥炶矾鍙�
+// int isSuccess;//F8 = 鎴愬姛 F5 = 澶辫触
+ int brightness ;//浜害
+ int channelCount;//鍥炶矾鎬绘暟
+ int deviceChannelCount;//璁惧鍥炶矾鎬绘暟
+ String remarks ;//澶囨敞
+ String parentRemarks;//妯″潡澶囨敞
+ int physicsChannelNum;//RCU 鐏厜鐗规湁
+
+ public String getParentRemarks() {
+ return parentRemarks;
+ }
+
+ public void setParentRemarks(String parentRemarks) {
+ this.parentRemarks = parentRemarks;
+ }
+
+ public String getRemarks() {
+ return remarks;
+ }
+
+ public void setRemarks(String remarks) {
+ this.remarks = remarks;
+ }
+
+ public AppliancesInfo getAppliancesInfo() {
+ return appliancesInfo;
+ }
+
+ public void setAppliancesInfo(AppliancesInfo appliancesInfo) {
+ this.appliancesInfo = appliancesInfo;
+ }
+
+ public int getChannelNum() {
+ return channelNum;
+ }
+
+ public void setChannelNum(int channelNum) {
+ this.channelNum = channelNum;
+ }
+
+
+ public int getBrightness() {
+ return brightness;
+ }
+
+ public void setBrightness(int brightness) {
+ this.brightness = brightness;
+ }
+
+ public int getChannelCount() {
+ return channelCount;
+ }
+
+ public void setChannelCount(int channelCount) {
+ this.channelCount = channelCount;
+ }
+
+ public int getDeviceChannelCount() {
+ return deviceChannelCount;
+ }
+
+ public void setDeviceChannelCount(int deviceChannelCount) {
+ this.deviceChannelCount = deviceChannelCount;
+ }
+
+ public int getPhysicsChannelNum() {
+ return physicsChannelNum;
+ }
+
+ public void setPhysicsChannelNum(int physicsChannelNum) {
+ this.physicsChannelNum = physicsChannelNum;
+ }
+
+ @Override
+ public String toString() {
+ return "LightCtrlBackInfo{" +
+ ", channelNum=" + channelNum +
+ ", brightness=" + brightness +
+ ", remarks='" + remarks + '\'' +
+ ", parentRemarks='" + parentRemarks + '\'' +
+ '}';
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLLogic/LogicCtrlBackInfo.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLLogic/LogicCtrlBackInfo.java
new file mode 100644
index 0000000..a0fec72
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLLogic/LogicCtrlBackInfo.java
@@ -0,0 +1,49 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLLogic;
+
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+
+/**
+ * Created by Tommy on 2017/7/20.
+ * 閫昏緫妯″潡
+ */
+
+public class LogicCtrlBackInfo {
+
+ int areaNum;//鍖哄彿
+ int sceneNum;//鍦烘櫙鍙�
+ AppliancesInfo appliancesInfo;
+ String remarks;
+
+ public AppliancesInfo getAppliancesInfo() {
+ return appliancesInfo;
+ }
+
+ public void setAppliancesInfo(AppliancesInfo appliancesInfo) {
+ this.appliancesInfo = appliancesInfo;
+ }
+
+ public String getRemarks() {
+ return remarks;
+ }
+
+ public void setRemarks(String remarks) {
+ this.remarks = remarks;
+ }
+
+ public int getAreaNum() {
+ return areaNum;
+ }
+
+ public void setAreaNum(int areaNum) {
+ this.areaNum = areaNum;
+ }
+
+ public int getSceneNum() {
+ return sceneNum;
+ }
+
+ public void setSceneNum(int sceneNum) {
+ this.sceneNum = sceneNum;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLLogic/LogicMode.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLLogic/LogicMode.java
new file mode 100644
index 0000000..2085a9e
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLLogic/LogicMode.java
@@ -0,0 +1,29 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLLogic;
+
+import java.io.Serializable;
+
+/**
+ * 閫昏緫妯″潡Bean
+ * Created by Tommy on 2017/7/21.
+ */
+
+public class LogicMode implements Serializable {
+ int AreaNum;//鍖哄煙鍙�
+ int AreaSceneNum;//鍖哄煙鍦烘櫙鍙�
+
+ public int getAreaNum() {
+ return AreaNum;
+ }
+
+ public void setAreaNum(int areaNum) {
+ AreaNum = areaNum;
+ }
+
+ public int getAreaSceneNum() {
+ return AreaSceneNum;
+ }
+
+ public void setAreaSceneNum(int areaSceneNum) {
+ AreaSceneNum = areaSceneNum;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSecurity/Parser/SecurityParser.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSecurity/Parser/SecurityParser.java
new file mode 100644
index 0000000..8e9ae9c
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSecurity/Parser/SecurityParser.java
@@ -0,0 +1,116 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLSecurity.Parser;
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+
+/**
+ * Created by JLChen on 2019/7/29
+ */
+public class SecurityParser {
+
+ public static final int fail = 0;
+ /**
+ * 甯冮槻璁剧疆
+ */
+ //甯冮槻绫诲瀷 6 =鎾ら槻 5 = 鐧藉ぉ甯冮槻 4 = 鏅氫笂鏈夊甯冮槻 3 = 澶滈棿甯冮槻 2 = 绂诲紑甯冮槻 1 = 鍋囨湡甯冮槻
+ public static final int ARMING_HOLIDAY = 1;
+ public static final int ARMING_LEAVE = 2;
+ public static final int ARMING_AT_NIGHT = 3;
+ public static final int ARMING_AT_NIGHT_WITH_GUEST = 4;
+ public static final int ARMING_DURING_THE_DAY = 5;
+ public static final int ARMING_DISARMING = 6;
+
+ public static final int ARMING_FAIL = 7;//甯冮槻澶辫触
+// public static final int ARMING_UNKNOWM = -1;//鏈煡鐘舵��
+
+ //鑾峰彇甯冮槻 bytes鏁版嵁
+ public static byte[] getArmingByte(AppliancesInfo appliancesInfo, int state) {
+ try {
+ if (state < 0 || state > 6) {//鍙傛暟閿欒榛樿鎾ら槻
+ state = 6;
+ }
+ byte[] addBytes = new byte[2];
+ addBytes[0] = (byte) appliancesInfo.getChannelNum();
+ addBytes[1] = (byte) state;
+ return addBytes;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return new byte[]{fail};
+ }
+
+ }
+
+
+// Bit 4 0 = 姝e父鐘舵�� , 1 = 鐢垫祦鎶ヨ
+// Bit 3 0 =姝e父鐘舵��, 1 = 绱ф�ユ姤璀�
+// Bit 2 0 =姝e父鐘舵��, 1 = 绐佸彂鎶ヨ
+// Bit 1 0 =姝e父鐘舵��, 1 =鐓ゆ皵鎶ヨ
+// Bit 0 0 =姝e父鐘舵��, 1 = 鐏 3
+//
+// Encode Bit Value
+// Bit 7 0 =姝e父鐘舵��, 1 = 娓╁害鎶ヨ
+// Bit 6 0 =姝e父鐘舵��, 1 = 鍔熺巼鎶ヨ
+// Bit 5 0 =姝e父鐘舵��, 1 = 鏃犲0鎶ヨ
+//private int CurrentAlarm; //鐢垫祦鎶ヨ
+// private int EmergencyAlarm; //绱ф�ユ姤璀�
+// private int SuddenAlarm; //绐佸彂鎶ヨ
+// private int FireAlarm; //鐏 3
+//
+// private int TemperatureAlarm;//娓╁害鎶ヨ
+// private int PowerAlarm; //鍔熺巼鎶ヨ
+// private int SilentAlarm; //鏃犲0鎶ヨ
+ /**
+ * 鎶ヨ璁剧疆 ALARM
+ */
+ public static final int ALARM_CURRENT = 4; //鐢垫祦鎶ヨ
+ public static final int ALARM_EMERGENCY = 3; //绱ф�ユ姤璀�
+ public static final int ALARM_SUDDEN = 2; //绐佸彂鎶ヨ
+ public static final int ALARM_GAS = 1; //鐓ゆ皵鎶ヨ
+ public static final int ALARM_FIRE = 0; //鐏 3
+ public static final int ALARM_TEMPERATURE = 7; //娓╁害鎶ヨ
+ public static final int ALARM_POWER = 6; //鍔熺巼鎶ヨ
+ public static final int ALARM_SILENT = 5; //鏃犲0鎶ヨ
+
+ //鑾峰彇鎶ヨ璁剧疆 bytes鏁版嵁 鍙姤璀︿竴绉嶆儏鍐�
+ public static byte[] getAlarmByte(AppliancesInfo appliancesInfo, int state) {
+ try {
+ byte[] addBytes = new byte[3];
+ addBytes[0] = (byte) appliancesInfo.getChannelNum();
+ switch (state) {
+ case ALARM_FIRE:
+ addBytes[1] = 0x01;
+ break;
+ case ALARM_GAS:
+ addBytes[1] = (byte) (1 << 1);
+ break;
+ case ALARM_SUDDEN:
+ addBytes[1] = (byte) (1 << 2);
+ break;
+ case ALARM_EMERGENCY:
+ addBytes[1] = (byte) (1 << 3);
+ break;
+ case ALARM_CURRENT:
+ addBytes[1] = (byte) (1 << 4);
+ break;
+
+ case ALARM_SILENT:
+ addBytes[2] = (byte) (1 << 5);
+ break;
+ case ALARM_POWER:
+ addBytes[2] = (byte) (1 << 6);
+ break;
+ case ALARM_TEMPERATURE:
+ addBytes[2] = (byte) (1 << 7);
+ break;
+ default:
+ break;
+ }
+
+ return addBytes;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return new byte[]{fail};
+ }
+
+ }
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSecurity/SecurityArmingStateBackInfo.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSecurity/SecurityArmingStateBackInfo.java
new file mode 100644
index 0000000..734e86e
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSecurity/SecurityArmingStateBackInfo.java
@@ -0,0 +1,24 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLSecurity;
+
+/**
+ * Created by JLChen on 2019/8/9
+ */
+public class SecurityArmingStateBackInfo {
+ private int armingState; //甯冮槻鐘舵�� 6 = 鎾ら槻 5 = 鐧藉ぉ甯冮槻 4 = 鏅氫笂鏈夊甯冮槻 3 = 澶滈棿甯冮槻 2 = 绂诲紑甯冮槻 1 = 鍋囨湡甯冮槻
+
+ public SecurityArmingStateBackInfo(byte[] curState) {
+ armingState = -1;
+ if (curState == null) return;
+ if (curState.length >= 2) {
+ armingState = curState[1] & 0xFF;
+ }
+ }
+
+ public int getArmingState() {
+ return armingState;
+ }
+
+ public void setArmingState(int armingState) {
+ this.armingState = armingState;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSecurity/SecurityBackInfo.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSecurity/SecurityBackInfo.java
new file mode 100644
index 0000000..ef1e4ba
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSecurity/SecurityBackInfo.java
@@ -0,0 +1,133 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLSecurity;
+
+import android.widget.TextView;
+
+import com.hdl.sdk.ttl.HDLAppliances.HDLSecurity.Parser.SecurityParser;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.SecurityStateBean;
+
+/**
+ * Created by JLChen on 2019/7/29
+ * 瀹夐槻妯″潡
+ */
+public class SecurityBackInfo {
+
+ private AppliancesInfo appliancesInfo;
+ private String remarks;
+ private int channelNum; //鍥炶矾鍙�
+ private SecurityStateBean mSecurityStateBean;
+
+ private byte[] curState; //杩斿洖淇℃伅
+
+ public SecurityBackInfo() {
+
+ }
+
+ public SecurityBackInfo(AppliancesInfo mAppliancesInfo) {
+ this.appliancesInfo = mAppliancesInfo;
+ this.remarks = mAppliancesInfo.getRemarks();
+ this.curState = mAppliancesInfo.getArrCurState();
+ this.mSecurityStateBean = new SecurityStateBean();
+
+ if (this.curState == null) return;
+
+ if (this.curState.length >= 3) {
+ this.channelNum = this.curState[0] & 0xFF;
+ this.mSecurityStateBean.alarmCurrent = this.curState[1] & 0x10;
+ this.mSecurityStateBean.alarmEmergency = this.curState[1] & 0x08;
+ this.mSecurityStateBean.alarmSudden = this.curState[1] & 0x04;
+ this.mSecurityStateBean.alarmGas = this.curState[1] & 0x02;
+ this.mSecurityStateBean.alarmFire = this.curState[1] & 0x01;
+ this.mSecurityStateBean.alarmTemperature = this.curState[2] & 0x80;
+ this.mSecurityStateBean.alarmPower = this.curState[2] & 0x40;
+ this.mSecurityStateBean.alarmSilent = this.curState[2] & 0x20;
+ int mCurState = this.curState[2] & 0x1F;
+
+ switch (mCurState) {
+ case 0:
+ this.mSecurityStateBean.armingState = SecurityParser.ARMING_DISARMING;//鎾ら槻鐘舵��
+ break;
+ case 1:
+ this.mSecurityStateBean.armingState = SecurityParser.ARMING_HOLIDAY;//鍋囨湡甯冮槻
+ break;
+ case 2:
+ this.mSecurityStateBean.armingState = SecurityParser.ARMING_LEAVE;//绂诲紑甯冮槻
+ break;
+ case 4:
+ this.mSecurityStateBean.armingState = SecurityParser.ARMING_AT_NIGHT;//澶滈棿甯冮槻
+ break;
+ case 8:
+ this.mSecurityStateBean.armingState = SecurityParser.ARMING_AT_NIGHT_WITH_GUEST;//鏅氫笂鏈夊甯冮槻
+ break;
+ case 10:
+ this.mSecurityStateBean.armingState = SecurityParser.ARMING_DURING_THE_DAY;//鐧藉ぉ甯冮槻
+ break;
+ default:
+// this.armingState = SecurityParser.ARMING_DISARMING;//鎾ら槻鐘舵��
+ this.mSecurityStateBean.armingState = -1; //鏈煡鐘舵��
+ break;
+ }
+
+
+ }
+
+ }
+
+
+ public AppliancesInfo getAppliancesInfo() {
+ return appliancesInfo;
+ }
+
+ public void setAppliancesInfo(AppliancesInfo appliancesInfo) {
+ this.appliancesInfo = appliancesInfo;
+ }
+
+ public String getRemarks() {
+ return remarks;
+ }
+
+ public void setRemarks(String remarks) {
+ this.remarks = remarks;
+ }
+
+ public int getChannelNum() {
+ return channelNum;
+ }
+
+ public void setChannelNum(int channelNum) {
+ this.channelNum = channelNum;
+ }
+
+ public SecurityStateBean getSecurityStateBean() {
+ return mSecurityStateBean;
+ }
+
+ public void setSecurityStateBean(SecurityStateBean securityStateBean) {
+ mSecurityStateBean = securityStateBean;
+ }
+
+ public byte[] getCurState() {
+ return curState;
+ }
+
+ public void setCurState(byte[] curState) {
+ this.curState = curState;
+ }
+}
+
+
+// Bit 4 0 = 姝e父鐘舵�� , 1 = 鐢垫祦鎶ヨ
+// Bit 3 0 =姝e父鐘舵��, 1 = 绱ф�ユ姤璀�
+// Bit 2 0 =姝e父鐘舵��, 1 = 绐佸彂鎶ヨ
+// Bit 1 0 =姝e父鐘舵��, 1 = 鐓ゆ皵鎶ヨ
+// Bit 0 0 =姝e父鐘舵��, 1 = 鐏 3
+//
+// Encode Bit Value
+// Bit 7 0 =姝e父鐘舵��, 1 = 娓╁害鎶ヨ
+// Bit 6 0 =姝e父鐘舵��, 1 = 鍔熺巼鎶ヨ
+// Bit 5 0 =姝e父鐘舵��, 1 = 鏃犲0鎶ヨ
+// Bit 4 0 =姝e父鐘舵��, 1 = 鐧藉ぉ甯冮槻鐘舵��
+// Bit 3 0 =姝e父鐘舵��, 1 = 鏅氫笂鏈夊甯冮槻
+// Bit 2 0 =姝e父鐘舵��, 1 = 澶滈棿甯冮槻
+// Bit 1 0 =姝e父鐘舵��, 1 = 绂诲紑甯冮槻
+// Bit 0 0 =姝e父鐘舵��, 1 = 鍋囨湡甯冮槻
\ No newline at end of file
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSensor/DryContactSensorBackEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSensor/DryContactSensorBackEvent.java
new file mode 100644
index 0000000..7c5a5b7
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSensor/DryContactSensorBackEvent.java
@@ -0,0 +1,22 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLSensor;
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DeviceStateEvent;
+
+public class DryContactSensorBackEvent extends DeviceStateEvent {
+
+ private int mState;
+
+ public DryContactSensorBackEvent(AppliancesInfo appliancesInfo, boolean isSuccess) {
+ super(appliancesInfo, isSuccess);
+
+ }
+ public DryContactSensorBackEvent(AppliancesInfo appliancesInfo, boolean isSuccess, int mState) {
+ super(appliancesInfo, isSuccess);
+ this.mState = mState;
+ }
+
+ public int getState() {
+ return mState;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSensor/SensorCtrlBackInfo.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSensor/SensorCtrlBackInfo.java
new file mode 100644
index 0000000..0f48df7
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSensor/SensorCtrlBackInfo.java
@@ -0,0 +1,26 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLSensor;
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DeviceStateEvent;
+
+import java.io.Serializable;
+
+public class SensorCtrlBackInfo extends DeviceStateEvent implements Serializable {
+
+ private String unit;
+
+ public SensorCtrlBackInfo(AppliancesInfo appliancesInfo, boolean isSuccess) {
+ super(appliancesInfo, isSuccess);
+
+ }
+
+
+
+ public String getUnit() {
+ return unit;
+ }
+
+ public void setUnit(String unit) {
+ this.unit = unit;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSensor/SensorStateBackInfo.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSensor/SensorStateBackInfo.java
new file mode 100644
index 0000000..b83ab12
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLSensor/SensorStateBackInfo.java
@@ -0,0 +1,21 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLSensor;
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DeviceStateEvent;
+
+public class SensorStateBackInfo extends DeviceStateEvent {
+ private String unite;
+
+ public SensorStateBackInfo(AppliancesInfo appliancesInfo, boolean isSuccess) {
+ super(appliancesInfo, isSuccess);
+
+ }
+ public SensorStateBackInfo(AppliancesInfo appliancesInfo, boolean isSuccess,String unite) {
+ super(appliancesInfo, isSuccess);
+ this.unite = unite;
+ }
+
+ public String getUnite() {
+ return unite;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLWarning/WarningType.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLWarning/WarningType.java
new file mode 100644
index 0000000..ab64672
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLAppliances/HDLWarning/WarningType.java
@@ -0,0 +1,139 @@
+package com.hdl.sdk.ttl.HDLAppliances.HDLWarning;
+
+/**
+ * HDL 璀︽姤
+ * Created by Tommy on 2017/10/10.
+ */
+
+public class WarningType {
+ public final static int switchWarning = 1;
+ public final static int intrudeWarning = 2;
+ public final static int overTemperatureWarning = 3;
+ public final static int lowTemperatureWarning = 4;
+ public final static int overHumidityWarning = 5;
+ public final static int lowHumidityWarning = 6;
+ public final static int highVoltageWarning = 7;
+ public final static int lowVoltageWarning = 8;
+ public final static int overloadWarning = 9;
+ public final static int highWaterPressureWarning = 10;
+ public final static int lowWaterPressureWarning = 11;
+ public final static int overLiquidLevelWarning = 12;
+ public final static int lowLiquidLevelWarning = 13;
+ public final static int leakingWarning = 14;
+ public final static int overPM2_5Warning = 15;
+ public final static int overPM10Warning = 16;
+ public final static int emergencyAlarm = 17;
+ public final static int glassesBrokenWarning = 18;
+ public final static int COWarning = 19;
+ public final static int gasWarning = 20;
+ public final static int fireWarning = 21;
+ public final static int smokeWarning = 22;
+ public final static int hijackWarning = 23;
+ public final static int passwordWrongWarning = 24;
+ public final static int anti_dismantleWarning = 25;
+ public final static int fingerPrintWrongWarning = 26;
+ public final static int notLockedWarning = 27;
+ public final static int lowBatteryWarning = 28;
+
+
+ public static String getWarningType(int type){
+ String warningType = "";
+ switch (type){
+ case switchWarning:
+ warningType = "寮�鍏虫姤璀�";
+ break;
+ case intrudeWarning:
+ warningType = "闂叆鎶ヨ";
+ break;
+ case overTemperatureWarning:
+ warningType = "娓╁害杩囬珮鎶ヨ";
+ break;
+ case lowTemperatureWarning:
+ warningType = "娓╁害杩囦綆鎶ヨ";
+ break;
+ case overHumidityWarning:
+ warningType = "婀垮害杩囦綆鎶ヨ";
+ break;
+ case lowHumidityWarning:
+ warningType = "婀垮害杩囬珮鎶ヨ";
+ break;
+ case highVoltageWarning:
+ warningType = "楂樼數鍘嬫姤璀�";
+ break;
+ case lowVoltageWarning:
+ warningType = "浣庣數鍘嬫姤璀�";
+ break;
+ case overloadWarning:
+ warningType = "杩囪浇鎶ヨ";
+ break;
+ case highWaterPressureWarning:
+ warningType = "姘村帇杩囬珮";
+ break;
+ case lowWaterPressureWarning:
+ warningType = "姘村帇杩囦綆";
+ break;
+ case overLiquidLevelWarning:
+ warningType = "娑蹭綅瓒呴檺";
+ break;
+ case lowLiquidLevelWarning:
+ warningType = "娑蹭綅杩囦綆";
+ break;
+ case leakingWarning:
+ warningType = "婕忔按鎶ヨ";
+ break;
+ case overPM2_5Warning:
+ warningType = "PM2.5瓒呴檺";
+ break;
+ case overPM10Warning:
+ warningType = "PM10瓒呴檺";
+ break;
+ case emergencyAlarm:
+ warningType = "绱ф�ユ姤璀�";
+ break;
+ case glassesBrokenWarning:
+ warningType = "鐜荤拑鐮寸鎶ヨ";
+ break;
+ case COWarning:
+ warningType = "CO鎶ヨ";
+ break;
+ case gasWarning:
+ warningType = "鐕冩皵鎶ヨ";
+ break;
+ case fireWarning:
+ warningType = "鐏伨鎶ヨ";
+ break;
+ case smokeWarning:
+ warningType = "鐑熼浘鎶ヨ";
+ break;
+ case hijackWarning:
+ warningType = "鍔寔鎶ヨ";
+ break;
+ case passwordWrongWarning:
+ warningType = "瀵嗙爜閿欒璀﹀憡";
+ break;
+ case anti_dismantleWarning:
+ warningType = "闃叉媶銆侀槻鎾姤璀�";
+ break;
+ case fingerPrintWrongWarning:
+ warningType = "鎸囩汗閿欒鎶ヨ";
+ break;
+ case notLockedWarning:
+ warningType = "闂ㄦ湭閿佸ソ";
+ break;
+ case lowBatteryWarning:
+ warningType = "鐢甸噺涓嶈冻鐘舵��";
+ break;
+ default:
+ warningType = "鏈煡璀﹀憡绫诲瀷";
+ break;
+
+ }
+ return warningType;
+ }
+
+
+
+
+
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/AppliancesInfo.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/AppliancesInfo.java
new file mode 100644
index 0000000..1568fae
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/AppliancesInfo.java
@@ -0,0 +1,244 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Bean;
+
+import com.hdl.sdk.ttl.HDLAppliances.HDLLogic.LogicMode;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+/**
+ * Created by djl on 2017/3/30.
+ */
+
+public class AppliancesInfo implements Serializable {
+ private String deviceName;//璁惧鍚嶇О
+ private int bigType;//澶х被
+ private int littleType;//灏忕被
+ private int ctrlCommand;//鎿嶄綔鐮�
+ private int ctrlBackCommand;//鎿嶄綔杩斿洖鐮�
+ private int stateCommand;//璇诲彇鐘舵�佺爜
+ private int stateBackCommand;//璇诲彇鐘舵�佽繑鍥炵爜
+ private int channelNum;//鍥炶矾鍙�
+ private int deviceSubnetID;//璁惧瀛愮綉鍙�
+ private int deviceDeviceID;//璁惧鍙�
+ private Object curState;//褰撳墠鐘舵��
+ private String remarks;//澶囨敞
+ private String parentRemarks;//妯″潡澶囨敞
+ private byte[] arrCurState;//鐘舵�佸弽棣堣褰曟暟鎹�
+ private int deviceType;//璁惧绫诲瀷
+ // private int port;
+// private String ipAddress;
+ private LogicMode logicMode;//閫昏緫妯″潡鐗规湁
+ private int physicsChannelNum;//RCU 鐏厜鐗规湁
+// private byte[] feedbackState;//鐘舵�佸弽棣堣褰曟暟鎹� 20190729鏂板
+
+ private int intCurState;
+ private String deviceKey;
+
+// public int getPort() {
+// return port;
+// }
+//
+// public void setPort(int port) {
+// this.port = port;
+// }
+//
+// public String getIpAddress() {
+// return ipAddress;
+// }
+//
+// public void setIpAddress(String ipAddress) {
+// this.ipAddress = ipAddress;
+// }
+
+ public int getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(int deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public int getPhysicsChannelNum() {
+ return physicsChannelNum;
+ }
+
+ public void setPhysicsChannelNum(int physicsChannelNum) {
+ this.physicsChannelNum = physicsChannelNum;
+ }
+
+ public byte[] getArrCurState() {
+ return arrCurState;
+ }
+
+ public void setArrCurState(byte[] arrCurState) {
+ this.arrCurState = arrCurState;
+ }
+
+ public String getParentRemarks() {
+ return parentRemarks;
+ }
+
+ public void setParentRemarks(String parentRemarks) {
+ this.parentRemarks = parentRemarks;
+ }
+
+ public Object getCurState() {
+ return curState;
+ }
+
+ public void setCurState(Object curState) {
+ this.curState = curState;
+ }
+
+ public int getDeviceSubnetID() {
+ return deviceSubnetID;
+ }
+
+ public void setDeviceSubnetID(int deviceSubnetID) {
+ this.deviceSubnetID = deviceSubnetID;
+ }
+
+ public int getDeviceDeviceID() {
+ return deviceDeviceID;
+ }
+
+ public void setDeviceDeviceID(int deviceDeviceID) {
+ this.deviceDeviceID = deviceDeviceID;
+ }
+
+ public int getLittleType() {
+ return littleType;
+ }
+
+ public void setLittleType(int littleType) {
+ this.littleType = littleType;
+ }
+
+ public int getBigType() {
+ return bigType;
+ }
+
+ public void setBigType(int bigType) {
+ this.bigType = bigType;
+ }
+
+ public int getChannelNum() {
+ return channelNum;
+ }
+
+ public void setChannelNum(int channelNum) {
+ this.channelNum = channelNum;
+ }
+
+ public String getRemarks() {
+ return remarks;
+ }
+
+ public void setRemarks(String remarks) {
+ this.remarks = remarks;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public void setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ }
+
+ public int getCtrlCommand() {
+ return ctrlCommand;
+ }
+
+ public void setCtrlCommand(int ctrlCommand) {
+ this.ctrlCommand = ctrlCommand;
+ }
+
+ public int getCtrlBackCommand() {
+ return ctrlBackCommand;
+ }
+
+ public void setCtrlBackCommand(int ctrlBackCommand) {
+ this.ctrlBackCommand = ctrlBackCommand;
+ }
+
+ public int getStateCommand() {
+ return stateCommand;
+ }
+
+ public void setStateCommand(int stateCommand) {
+ this.stateCommand = stateCommand;
+ }
+
+ public int getStateBackCommand() {
+ return stateBackCommand;
+ }
+
+ public void setStateBackCommand(int stateBackCommand) {
+ this.stateBackCommand = stateBackCommand;
+ }
+
+ public LogicMode getLogicMode() {
+ return logicMode;
+ }
+
+ public void setLogicMode(LogicMode logicMode) {
+ this.logicMode = logicMode;
+ }
+
+ public int getIntCurState() {
+ return intCurState;
+ }
+
+ public void setIntCurState(int intCurState) {
+ this.intCurState = intCurState;
+ }
+
+// public byte[] getFeedbackState() {
+// return feedbackState;
+// }
+//
+// public void setFeedbackState(byte[] feedbackState) {
+// this.feedbackState = feedbackState;
+// }
+
+ public String getDeviceKey() {
+ if (deviceKey == null) {
+ deviceKey = "K" + this.bigType
+ + "-" + this.littleType
+ + "-" + this.deviceSubnetID
+ + "-" + this.deviceDeviceID
+ + "-" + this.channelNum;
+ }
+ return deviceKey;
+ }
+
+ public void setDeviceKey(String deviceKey) {
+ this.deviceKey = deviceKey;
+ }
+
+ @Override
+ public String toString() {
+ return "AppliancesInfo{" +
+ "deviceName='" + deviceName + '\'' +
+ ", bigType=" + bigType +
+ ", littleType=" + littleType +
+ ", ctrlCommand=" + ctrlCommand +
+ ", ctrlBackCommand=" + ctrlBackCommand +
+ ", stateCommand=" + stateCommand +
+ ", stateBackCommand=" + stateBackCommand +
+ ", channelNum=" + channelNum +
+ ", deviceSubnetID=" + deviceSubnetID +
+ ", deviceDeviceID=" + deviceDeviceID +
+ ", curState=" + curState +
+ ", remarks='" + remarks + '\'' +
+ ", parentRemarks='" + parentRemarks + '\'' +
+// ", arrCurState=" + Arrays.toString(arrCurState) +
+ ", deviceType=" + deviceType +
+// ", port=" + port +
+// ", ipAddress='" + ipAddress + '\'' +
+ ", logicMode=" + logicMode +
+ ", physicsChannelNum=" + physicsChannelNum +
+ '}';
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/DeviceStateBean.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/DeviceStateBean.java
new file mode 100644
index 0000000..333a94b
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/DeviceStateBean.java
@@ -0,0 +1,81 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Bean;
+
+/**
+ * 姝ょ被涓昏鐢ㄤ簬鎻愪緵缁欑涓夋柟浣跨敤
+ */
+public class DeviceStateBean {
+
+ private int bigType;//澶х被
+ private int littleType;//灏忕被
+ private int channelNum ;//鍥炶矾鍙�
+ private int curState;
+ private byte[] arrCurState;
+ private int deviceType;
+
+ private int deviceSubnetID;//璁惧瀛愮綉鍙�
+ private int deviceDeviceID;//璁惧鍙�
+
+ public int getDeviceSubnetID() {
+ return deviceSubnetID;
+ }
+
+ public void setDeviceSubnetID(int deviceSubnetID) {
+ this.deviceSubnetID = deviceSubnetID;
+ }
+
+ public int getDeviceDeviceID() {
+ return deviceDeviceID;
+ }
+
+ public void setDeviceDeviceID(int deviceDeviceID) {
+ this.deviceDeviceID = deviceDeviceID;
+ }
+
+ public int getBigType() {
+ return bigType;
+ }
+
+ public void setBigType(int bigType) {
+ this.bigType = bigType;
+ }
+
+ public int getLittleType() {
+ return littleType;
+ }
+
+ public void setLittleType(int littleType) {
+ this.littleType = littleType;
+ }
+
+ public int getChannelNum() {
+ return channelNum;
+ }
+
+ public void setChannelNum(int channelNum) {
+ this.channelNum = channelNum;
+ }
+
+ public int getCurState() {
+ return curState;
+ }
+
+ public void setCurState(int curState) {
+ this.curState = curState;
+ }
+
+ public byte[] getArrCurState() {
+ return arrCurState;
+ }
+
+ public void setArrCurState(byte[] arrCurState) {
+ this.arrCurState = arrCurState;
+ }
+
+ public int getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(int deviceType) {
+ this.deviceType = deviceType;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/DevicesData.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/DevicesData.java
new file mode 100644
index 0000000..ce1b6a2
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/DevicesData.java
@@ -0,0 +1,59 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Bean;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Created by djl on 2017/3/24.
+ * 鎵�鏈夌畝鏄撶紪绋�
+ */
+
+public class DevicesData implements Serializable {
+ List<AppliancesInfo> appliancesInfoList;
+ int sourceSubnetID;
+ int sourceDeviceID;
+ byte[] addByte;
+ String remark;
+
+ public String getRemark() {
+ return remark;
+ }
+
+ public void setRemark(String remark) {
+ this.remark = remark;
+ }
+
+ public List<AppliancesInfo> getAppliancesInfoList() {
+ return appliancesInfoList;
+ }
+
+ public void setAppliancesInfoList(List<AppliancesInfo> appliancesInfoList) {
+ this.appliancesInfoList = appliancesInfoList;
+ }
+
+ public int getSourceSubnetID() {
+ return sourceSubnetID;
+ }
+
+ public void setSourceSubnetID(int sourceSubnetID) {
+ this.sourceSubnetID = sourceSubnetID;
+ }
+
+ public int getSourceDeviceID() {
+ return sourceDeviceID;
+ }
+
+ public void setSourceDeviceID(int sourceDeviceID) {
+ this.sourceDeviceID = sourceDeviceID;
+ }
+
+ public byte[] getAddByte() {
+ return addByte;
+ }
+
+ public void setAddByte(byte[] addByte) {
+ this.addByte = addByte;
+ }
+
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/ListRemarks.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/ListRemarks.java
new file mode 100644
index 0000000..1e689c4
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/ListRemarks.java
@@ -0,0 +1,26 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Bean;
+
+/**
+ * Created by Tommy on 2017/10/20.
+ */
+
+public class ListRemarks {
+ boolean isCallBack;
+ AppliancesInfo appliancesInfo;
+
+ public boolean isCallBack() {
+ return isCallBack;
+ }
+
+ public void setCallBack(boolean callBack) {
+ isCallBack = callBack;
+ }
+
+ public AppliancesInfo getAppliancesInfo() {
+ return appliancesInfo;
+ }
+
+ public void setAppliancesInfo(AppliancesInfo appliancesInfo) {
+ this.appliancesInfo = appliancesInfo;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/MCUConfigurationBean.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/MCUConfigurationBean.java
new file mode 100644
index 0000000..db0075a
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/MCUConfigurationBean.java
@@ -0,0 +1,126 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Bean;
+
+/**
+ * Created by JLChen on 2019/7/24
+ */
+public class MCUConfigurationBean {
+
+// 鍗忚绫诲瀷[1byte 0:Buspro,1:zigbee,2:KNX,3:Modbus, 5:鑷畾涔塢
+// 娉㈢壒鐜嘯1byte 0:1200锛�1:2400,2:4800:3:9600,4:19200,5:38400,6:57600,7:115200,8:250000]
+// 寮�濮嬩綅[1byte 0: 鍥哄畾1bit]
+// 鏁版嵁浣峓1byte 0:8bit,1:9bit]
+// 鏍¢獙浣峓1byte 0:鏃�, 1:鍋�, 2:濂�,]
+// 鍋滄浣峓1byte 0:0.5bit, 1:bit, 2:2bit, 3:1.5bit]
+ public static final int TYPE_BUSPRO = 0;
+ public static final int TYPE_ZIGBEE = 1;
+ public static final int TYPE_KNX = 2;
+ public static final int TYPE_MODBUS = 3;
+ public static final int TYPE_DIY = 5;
+
+// 娉㈢壒鐜嘯1byte 0:1200锛�1:2400,2:4800:3:9600,4:19200,5:38400,6:57600,7:115200,8:250000]
+ public static final int BAUDRATE_1200 = 0;
+ public static final int BAUDRATE_2400 = 1;
+ public static final int BAUDRATE_4800 = 2;
+ public static final int BAUDRATE_9600 = 3;
+ public static final int BAUDRATE_19200 = 4;
+ public static final int BAUDRATE_38400 = 5;
+ public static final int BAUDRATE_57600 = 6;
+ public static final int BAUDRATE_115200 = 7;
+ public static final int BAUDRATE_250000 = 8;
+
+ //鏍¢獙浣峓1byte 0:鏃�, 1:鍋�, 2:濂�,]
+ public static final int CHECKBIT_NO = 0;
+ public static final int CHECKBIT_EVEN = 1;
+ public static final int CHECKBIT_ODD = 2;
+ //鍋滄浣峓1byte 0:0.5bit, 1:bit, 2:2bit, 3:1.5bit]
+ public static final int STOPBIT_0_5 = 0;
+ public static final int STOPBIT_1 = 1;
+ public static final int STOPBIT_2 = 2;
+ public static final int STOPBIT_1_5 = 3;
+
+
+ //鍗忚绫诲瀷
+ private int mcuAgreementType;
+ //娉㈢壒鐜�
+ private int mcuBaudrate;
+ //寮�濮嬩綅
+ private int mcuStartBit;
+ //鏁版嵁浣�
+ private int mcuDataBit;
+ //妫�楠屼綅
+ private int mcuCheckBit;
+ //鍋滄浣�
+ private int mcuStopBit;
+
+ /**
+ * 榄旈暅MCU鍗忚
+ * @return
+ */
+ public byte[] getMCUConfigurationSendBytes() {
+ //绾犳寮傚父鏁版嵁
+ if(this.mcuAgreementType < 0 || this.mcuAgreementType > 5) this.mcuAgreementType = 0;
+ if(this.mcuBaudrate < 0 || this.mcuBaudrate > 8) this.mcuBaudrate = 0;
+ if(this.mcuDataBit < 0 || this.mcuDataBit > 1) this.mcuDataBit = 0;
+ if(this.mcuCheckBit < 0 || this.mcuCheckBit > 2) this.mcuCheckBit = 0;
+ if(this.mcuStopBit < 0 || this.mcuStopBit > 3) this.mcuStopBit = 0;
+
+
+ byte[] sendBytes = new byte[6];
+ //Boot code
+ sendBytes[0] = (byte) this.mcuAgreementType;
+ sendBytes[1] = (byte) this.mcuBaudrate; //娉㈢壒鐜�
+ sendBytes[2] = (byte) 0; //寮�濮嬩綅
+ sendBytes[3] = (byte) this.mcuDataBit; //鏁版嵁浣�
+ sendBytes[4] = (byte) this.mcuCheckBit; //妫�楠屼綅
+ sendBytes[5] = (byte) this.mcuStopBit; //鍋滄浣�
+ return sendBytes;
+ }
+
+ public int getMcuAgreementType() {
+ return mcuAgreementType;
+ }
+
+ public void setMcuAgreementType(int mcuAgreementType) {
+ this.mcuAgreementType = mcuAgreementType;
+ }
+
+ public int getMcuBaudrate() {
+ return mcuBaudrate;
+ }
+
+ public void setMcuBaudrate(int mcuBaudrate) {
+ this.mcuBaudrate = mcuBaudrate;
+ }
+
+ public int getMcuStartBit() {
+ return mcuStartBit;
+ }
+
+ public void setMcuStartBit(int mcuStartBit) {
+ this.mcuStartBit = mcuStartBit;
+ }
+
+ public int getMcuDataBit() {
+ return mcuDataBit;
+ }
+
+ public void setMcuDataBit(int mcuDataBit) {
+ this.mcuDataBit = mcuDataBit;
+ }
+
+ public int getMcuCheckBit() {
+ return mcuCheckBit;
+ }
+
+ public void setMcuCheckBit(int mcuCheckBit) {
+ this.mcuCheckBit = mcuCheckBit;
+ }
+
+ public int getMcuStopBit() {
+ return mcuStopBit;
+ }
+
+ public void setMcuStopBit(int mcuStopBit) {
+ this.mcuStopBit = mcuStopBit;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/MCUDataBean.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/MCUDataBean.java
new file mode 100644
index 0000000..a40b9aa
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/MCUDataBean.java
@@ -0,0 +1,34 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Bean;
+
+/**
+ * Created by JLChen on 2019/7/23
+ */
+public class MCUDataBean {
+ public int command;
+ public byte[] receiveBytes;
+ public MCUConfigurationBean mMCUConfigurationBean;
+
+ public int getCommand() {
+ return command;
+ }
+
+ public void setCommand(int command) {
+ this.command = command;
+ }
+
+ public byte[] getReceiveBytes() {
+ return receiveBytes;
+ }
+
+ public void setReceiveBytes(byte[] receiveBytes) {
+ this.receiveBytes = receiveBytes;
+ }
+
+ public MCUConfigurationBean getMCUConfigurationBean() {
+ return mMCUConfigurationBean;
+ }
+
+ public void setMCUConfigurationBean(MCUConfigurationBean MCUConfigurationBean) {
+ mMCUConfigurationBean = MCUConfigurationBean;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/RcuCurtain.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/RcuCurtain.java
new file mode 100644
index 0000000..cb9a0a0
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/RcuCurtain.java
@@ -0,0 +1,31 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Bean;
+
+public class RcuCurtain {
+ int chanelNum ;
+ int curState;
+ int littleType;
+
+ public int getChanelNum() {
+ return chanelNum;
+ }
+
+ public void setChanelNum(int chanelNum) {
+ this.chanelNum = chanelNum;
+ }
+
+ public int getCurState() {
+ return curState;
+ }
+
+ public void setCurState(int curState) {
+ this.curState = curState;
+ }
+
+ public int getLittleType() {
+ return littleType;
+ }
+
+ public void setLittleType(int littleType) {
+ this.littleType = littleType;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/RcuLight.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/RcuLight.java
new file mode 100644
index 0000000..92ec82f
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/RcuLight.java
@@ -0,0 +1,31 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Bean;
+
+public class RcuLight {
+ int physicsChanelNum ;
+ int curState;
+ int littleType;
+
+ public int getLittleType() {
+ return littleType;
+ }
+
+ public void setLittleType(int littleType) {
+ this.littleType = littleType;
+ }
+
+ public int getPhysicsChanelNum() {
+ return physicsChanelNum;
+ }
+
+ public void setPhysicsChanelNum(int physicsChanelNum) {
+ this.physicsChanelNum = physicsChanelNum;
+ }
+
+ public int getCurState() {
+ return curState;
+ }
+
+ public void setCurState(int curState) {
+ this.curState = curState;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/RemarkTimes.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/RemarkTimes.java
new file mode 100644
index 0000000..c7519d4
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/RemarkTimes.java
@@ -0,0 +1,13 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Bean;
+
+public class RemarkTimes {
+ int count;
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/SearchCountBean.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/SearchCountBean.java
new file mode 100644
index 0000000..9cc344f
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/SearchCountBean.java
@@ -0,0 +1,13 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Bean;
+
+public class SearchCountBean {
+ private int count ;
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/SecurityStateBean.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/SecurityStateBean.java
new file mode 100644
index 0000000..64abf96
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/SecurityStateBean.java
@@ -0,0 +1,90 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Bean;
+
+/**
+ * Created by JLChen on 2019/7/29
+ */
+public class SecurityStateBean {
+ public int alarmCurrent; //鐢垫祦鎶ヨ
+ public int alarmEmergency; //绱ф�ユ姤璀�
+ public int alarmSudden; //绐佸彂鎶ヨ
+ public int alarmGas; //鐓ゆ皵鎶ヨ
+ public int alarmFire; //鐏 3
+
+ public int alarmTemperature;//娓╁害鎶ヨ
+ public int alarmPower; //鍔熺巼鎶ヨ
+ public int alarmSilent; //鏃犲0鎶ヨ
+
+ public int armingState; //甯冮槻鐘舵�� 6 = 鎾ら槻 5 = 鐧藉ぉ甯冮槻 4 = 鏅氫笂鏈夊甯冮槻 3 = 澶滈棿甯冮槻 2 = 绂诲紑甯冮槻 1 = 鍋囨湡甯冮槻
+
+ public int getAlarmCurrent() {
+ return alarmCurrent;
+ }
+
+ public void setAlarmCurrent(int alarmCurrent) {
+ this.alarmCurrent = alarmCurrent;
+ }
+
+ public int getAlarmEmergency() {
+ return alarmEmergency;
+ }
+
+ public void setAlarmEmergency(int alarmEmergency) {
+ this.alarmEmergency = alarmEmergency;
+ }
+
+ public int getAlarmSudden() {
+ return alarmSudden;
+ }
+
+ public void setAlarmSudden(int alarmSudden) {
+ this.alarmSudden = alarmSudden;
+ }
+
+ public int getAlarmGas() {
+ return alarmGas;
+ }
+
+ public void setAlarmGas(int alarmGas) {
+ this.alarmGas = alarmGas;
+ }
+
+ public int getAlarmFire() {
+ return alarmFire;
+ }
+
+ public void setAlarmFire(int alarmFire) {
+ this.alarmFire = alarmFire;
+ }
+
+ public int getAlarmTemperature() {
+ return alarmTemperature;
+ }
+
+ public void setAlarmTemperature(int alarmTemperature) {
+ this.alarmTemperature = alarmTemperature;
+ }
+
+ public int getAlarmPower() {
+ return alarmPower;
+ }
+
+ public void setAlarmPower(int alarmPower) {
+ this.alarmPower = alarmPower;
+ }
+
+ public int getAlarmSilent() {
+ return alarmSilent;
+ }
+
+ public void setAlarmSilent(int alarmSilent) {
+ this.alarmSilent = alarmSilent;
+ }
+
+ public int getArmingState() {
+ return armingState;
+ }
+
+ public void setArmingState(int armingState) {
+ this.armingState = armingState;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/UdpDataBean.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/UdpDataBean.java
new file mode 100644
index 0000000..2e0c0f1
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Bean/UdpDataBean.java
@@ -0,0 +1,12 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Bean;
+
+public class UdpDataBean {
+ public int sourceSubnetID;//鍙戦�佽�呭瓙缃戝彿
+ public int sourceDeviceID;
+ public int desSubnetID;//鐩爣鎺ユ敹鑰呭瓙缃戝彿
+ public int desDeviceID;
+ public int command;
+ public byte[] addBytes;
+// public int port;
+// public String ipAddress;
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/Crc.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/Crc.java
new file mode 100644
index 0000000..54a87db
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/Crc.java
@@ -0,0 +1,188 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Core;
+
+import com.hdl.sdk.ttl.Config.MCUConstants;
+import com.hdl.sdk.ttl.Utils.LogUtils.HDLLog;
+
+/**
+ * Modify by JLChen on 2019/6/26
+ */
+public class Crc {
+ private static int[] crctab = new int[]{0x0000, 0x1021, 0x2042, 0x3063,
+ 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b,
+ 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252,
+ 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a,
+ 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401,
+ 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b, 0x8528, 0x9509,
+ 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672, 0x1611, 0x0630,
+ 0x76d7, 0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738,
+ 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4, 0x58e5, 0x6886, 0x78a7,
+ 0x0840, 0x1861, 0x2802, 0x3823, 0xc9cc, 0xd9ed, 0xe98e, 0xf9af,
+ 0x8948, 0x9969, 0xa90a, 0xb92b, 0x5af5, 0x4ad4, 0x7ab7, 0x6a96,
+ 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e,
+ 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5,
+ 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae, 0xfd8f, 0xcdec, 0xddcd,
+ 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4,
+ 0x3e13, 0x2e32, 0x1e51, 0x0e70, 0xff9f, 0xefbe, 0xdfdd, 0xcffc,
+ 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca, 0xa1eb,
+ 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3,
+ 0x5004, 0x4025, 0x7046, 0x6067, 0x83b9, 0x9398, 0xa3fb, 0xb3da,
+ 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2,
+ 0x4235, 0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb, 0x95a8, 0x8589,
+ 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2, 0x24c3, 0x14a0, 0x0481,
+ 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8,
+ 0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0,
+ 0x6657, 0x7676, 0x4615, 0x5634, 0xd94c, 0xc96d, 0xf90e, 0xe92f,
+ 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827,
+ 0x18c0, 0x08e1, 0x3882, 0x28a3, 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e,
+ 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 0x4a75, 0x5a54, 0x6a37, 0x7a16,
+ 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d,
+ 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64, 0x4c45,
+ 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xef1f, 0xff3e, 0xcf5d, 0xdf7c,
+ 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74,
+ 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0};
+
+ public byte[] addBytes;
+ public int command = 0;
+ //褰撳墠APP璁惧瀛愮綉鍙�
+ public static int localSubnetID = 254;
+ //褰撳墠APP璁惧璁惧鍙�
+ public static int localDeviceID = 80;
+ public int desSubnetID = 0;
+ public int desDeviceID = 0;
+ // Device type
+ public static int DeviceType = 424;
+ // public int port = 0;
+// public String ipAddress = "";
+ public int count = 0;//鏉冨疁涔嬭锛屽悗缁垹鎺�
+ public boolean isCtrlSuccess;//鏉冨疁涔嬭锛屽悗缁垹鎺�
+
+ public Crc(int command, int desSubnetID, int desDeviceID, byte[] addBytes) {
+ this.command = command;
+ this.desSubnetID = desSubnetID;
+ this.desDeviceID = desDeviceID;
+ this.addBytes = addBytes;
+ }
+
+ public Crc(int command, int sourceSubID, int sourceDeviceID, int desSubnetID, int desDeviceID, byte[] addBytes) {
+ localSubnetID = sourceSubID;
+ localDeviceID = sourceDeviceID;
+ this.command = command;
+ this.desSubnetID = desSubnetID;
+ this.desDeviceID = desDeviceID;
+ this.addBytes = addBytes;
+ }
+
+ private static int xcrc(int crc, byte cp) {
+ int t1, t2, t3, t4, t5, t6;
+ t1 = (crc >> 8);
+ t2 = (t1 & 0xff);
+ t3 = (cp & 0xff);
+ t4 = (crc << 8);
+ t5 = (t2 ^ t3);
+ t6 = (crctab[t5] ^ t4);
+ return t6;
+ }
+
+ public static void ConCRC(byte[] bufin, int n) {
+ int crc16 = 0;
+ int i;
+ for (i = 0; i < n; i++) {
+ crc16 = xcrc(crc16, bufin[i]);
+ }
+ bufin[i] = (byte) (crc16 >> 8);
+ bufin[i + 1] = (byte) (crc16 & 0xff);
+ }
+
+ public static boolean checkCRC(byte[] bufin) {
+ try {
+ int crc16 = 0;
+ int i;
+ //鍘绘帀AAAA澶�
+ for ( i = 2; i < bufin.length - 2; i++) {
+ crc16 = xcrc(crc16, bufin[i]);
+ }
+ return (bufin[i] == (byte) (crc16 >> 8)) && (bufin[i + 1] == (byte) (crc16 & 0xff));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+
+ }
+
+
+ /**
+ * 鏃у崗璁�
+ * @return
+ */
+ public byte[] GetSendBytes() {
+
+ byte[] crcBytes = new byte[9 + this.addBytes.length + 2];
+
+ byte[] sendBytes = new byte[2 + crcBytes.length];
+
+ //Boot code
+ sendBytes[0] = (byte) 0xAA;
+ sendBytes[1] = (byte) 0xAA;
+ crcBytes[0] = (byte) crcBytes.length;
+ crcBytes[1] = (byte) localSubnetID;
+ crcBytes[2] = (byte) localDeviceID;
+ crcBytes[3] = (byte) (DeviceType / 256);
+ crcBytes[4] = (byte) (DeviceType % 256);
+ crcBytes[5] = (byte) (this.command / 256);
+ crcBytes[6] = (byte) (this.command % 256);
+ crcBytes[7] = (byte) this.desSubnetID;
+ crcBytes[8] = (byte) this.desDeviceID;
+ System.arraycopy(this.addBytes, 0, crcBytes, 9, this.addBytes.length);
+ ConCRC(crcBytes, crcBytes.length - 2);
+ System.arraycopy(crcBytes, 0, sendBytes, 2, crcBytes.length);
+
+ return sendBytes;
+ }
+
+
+
+//
+// // 2.閫氫俊鍗忚
+//// 寮曞澶� 鎺у埗鍩� 鏁版嵁闀垮害 鏁版嵁 鏍¢獙鐮�
+//// 168[1byte] 0-255[1byte] 0-1500[2byte] [Nbyte] [1byte]
+// /**
+// * 榄旈暅MCU鍗忚
+// * @return
+// */
+// public byte[] GetSendBytes() {
+// byte[] busBytes = GetHDLSendBytes();
+// byte[] sendBytes = new byte[5 + busBytes.length];
+//
+// //Boot code
+// sendBytes[0] = (byte) MCUConstants.MCU_BOOT_HEAD;
+// sendBytes[1] = (byte) MCUConstants.MCU_COMMAND_SEND;
+// sendBytes[2] = (byte) ((busBytes.length) / 256); //鏁版嵁闀垮害锛氬幓闄ゅ紩瀵煎ご鐨勯暱搴�
+// sendBytes[3] = (byte) ((busBytes.length) % 256); //鏁版嵁闀垮害锛氬幓闄ゅ紩瀵煎ご鐨勯暱搴�
+//
+// System.arraycopy(busBytes, 0, sendBytes, 4, busBytes.length);
+//
+// sendBytes[sendBytes.length-1] = MCUCrc.getMcuChecksum(sendBytes); //璁剧疆鏍¢獙鐮�
+//
+// return sendBytes;
+// }
+
+
+
+// /**
+// * 鏍¢獙鐮佽绠�
+// * @param packet
+// * @return
+// * 澶村紩瀵肩爜鍜屽熬鏍¢獙鐮佷笉妫�楠� 鎵�浠=1锛屽紑濮� i < (packet.length - 2)
+// */
+// public static byte getMcuChecksum(byte[] packet)
+// {
+// byte mSum = 0;
+// for(int i = 1; i < (packet.length - 2); i++)
+// {
+// mSum += (byte)packet[i];
+// }
+// mSum = (byte) ((~mSum) + 1);
+// return mSum;
+//
+// }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLCommand.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLCommand.java
new file mode 100644
index 0000000..84a4bb7
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLCommand.java
@@ -0,0 +1,1546 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Core;
+
+import android.content.Context;
+
+import com.hdl.sdk.ttl.Config.Configuration;
+import com.hdl.sdk.ttl.Config.MCUConstants;
+import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig;
+import com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition.AirCtrlBackInfo;
+import com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser;
+import com.hdl.sdk.ttl.HDLAppliances.HDLAudio.HDLAudio;
+import com.hdl.sdk.ttl.HDLAppliances.HDLCommonSwitch.CommonSwitchBackInfo;
+import com.hdl.sdk.ttl.HDLAppliances.HDLCurtain.CurtainCtrlBackInfo;
+import com.hdl.sdk.ttl.HDLAppliances.HDLCurtain.Parser.CurtainCtrlParser;
+import com.hdl.sdk.ttl.HDLAppliances.HDLLight.LightCtrlBackInfo;
+import com.hdl.sdk.ttl.HDLAppliances.HDLLogic.LogicCtrlBackInfo;
+import com.hdl.sdk.ttl.HDLAppliances.HDLSecurity.Parser.SecurityParser;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.DeviceStateBean;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.MCUDataBean;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.AirFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.CommonSwitchCtrlBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.CurtainFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DeviceStateEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.EventCode;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.LightFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.MCUFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.SecurityArmingFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.UpdateRemarkFeedBackEvent;
+import com.hdl.sdk.ttl.Utils.HDLUtlis.HDLUtlis;
+import com.hdl.sdk.ttl.Utils.LogUtils.HDLLog;
+import com.hdl.sdk.ttl.Utils.SPUtils.SPUtils;
+
+
+import org.greenrobot.eventbus.EventBus;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * Modify by JLChen on 2019/6/27
+ */
+public class HDLCommand {
+
+ public static int mRequestTimeout = 5000;//榛樿璇锋眰瓒呮椂鏃堕棿
+ private static Timer getStateFailTimer = null;//鑾峰彇璁惧鐘舵�佸け璐imer
+ private static Timer lightCtrlFailTimer = null;//鎺у埗鐏厜澶辫触Timer
+ private static Timer curtainCtrlFailTimer = null;//鎺у埗绐楀笜澶辫触Timer
+ private static Timer acCtrlFailTimer = null;//鎺у埗绌鸿皟澶辫触Timer
+ private static Timer sceneCtrlFailTimer = null;//鎺у埗鍦烘櫙澶辫触Timer
+ private static Timer remarkUpdateFailTimer = null;//鏇存柊澶囨敞澶辫触Timer
+ private static Timer mcuCtrlFailTimer = null;//MCU鎿嶄綔澶辫触Timer
+ private static Timer securityCtrlFailTimer = null;//瀹夐槻妯″潡鎿嶄綔澶辫触Timer
+ private static Timer commonSwitchCtrlFailTimer = null;//閫氱敤寮�鍏冲け璐imer
+
+
+// /**
+// * 鍒濆鍖� SDK
+// *
+// * @param context
+// */
+// public static void init(Context context, String mPathname, int mBaudrate) {
+// HDLDeviceManager.init(context);
+// HDLSerialPortCore.initHDLSerialPort(mPathname, mBaudrate);
+// }
+//
+// /**
+// * 鏄惁寮�鍚疭DK鏃ュ織鎵撳嵃
+// *
+// * @param bOpen
+// */
+// public static void setHDLLogOpen(boolean bOpen) {
+// HDLLog.setHDLLogOpen(bOpen);
+// }
+
+// /**
+// * 閲婃斁璧勬簮
+// */
+// public static void release() {
+// HDLDeviceManager.release();
+// }
+
+ /**
+ * 鑾峰彇瀹跺眳璁惧
+ */
+ public static void getHomeDevices() {
+ HandleSearch.getHomeDevices();
+ }
+
+ /**
+ * 鍙戠幇鏂拌澶囨悳绱�,涓嶄細娓呯┖鍘熻澶囧垪琛ㄦ暟鎹�
+ */
+ public static void getNewHomeDevices() {
+ HandleSearch.getNewHomeDevices();
+ }
+
+ /**
+ * 鍙栨秷鎼滅储绛夊畾鏃跺櫒
+ */
+ public static void cancelSearching() {
+ HandleSearch.isSearching = false;
+ if (HandleSearch.searchTimer != null) {
+ HandleSearch.searchTimer.cancel();
+ HandleSearch.searchTimer = null;
+ }
+
+ if (HandleSearch.searchTwiceTimer != null) {
+ HandleSearch.searchTwiceTimer.cancel();
+ HandleSearch.searchTwiceTimer = null;
+ }
+
+ if (HandleSearch.searchFailTimer != null) {
+ HandleSearch.searchFailTimer.cancel();
+ HandleSearch.searchFailTimer = null;
+ }
+
+ if (HandleSearch.remarkTimer != null) {
+ HandleSearch.remarkTimer.cancel();
+ HandleSearch.remarkTimer = null;
+
+ }
+ }
+
+ /**
+ * 淇敼鏇存柊妯″潡澶囨敞鍚�
+ *
+ * @param mSubnetID 瀛愮綉鍙�
+ * @param mDeviceID 璁惧鍙�
+ * @param remakeBytes 20190701
+ */
+ public static void updateModuleRemark(int mSubnetID, int mDeviceID, byte[] remakeBytes) {
+ /***澶囨敞鍚嶅瓧闄愬埗涓�20瀛楄妭浠ュ唴*/
+ if (remakeBytes.length > 20) return;
+
+ HDLDeviceManager.isUpdateRemarkSuccess = false;
+ if (remarkUpdateFailTimer != null) {
+ remarkUpdateFailTimer.cancel();
+ remarkUpdateFailTimer = null;
+ }
+
+ byte[] updateBytes = new byte[20];
+
+
+ System.arraycopy(remakeBytes, 0, updateBytes, 0, remakeBytes.length);
+ cusSendCommand(Configuration.MODULE_UPDATE_REMARK_COMMAND,
+ mSubnetID, mDeviceID, updateBytes);
+
+ remarkUpdateFailTimer = new Timer();
+ remarkUpdateFailTimer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ if (!HDLDeviceManager.isUpdateRemarkSuccess) {
+ EventBus.getDefault().post(new UpdateRemarkFeedBackEvent(false));
+ }
+ }
+ }, mRequestTimeout);
+ }
+
+// /**
+// * 淇敼鏌愬洖璺娉ㄥ悕
+// * @param newName 20190701
+// */
+// public static void updateLoopRemark(final AppliancesInfo info, String newName) {
+// byte[] updateBytes = new byte[20];
+// byte[] remakeBytes = HDLStringUtils.stringtoBytes(newName);
+// System.arraycopy(remakeBytes, 0, updateBytes, 0, remakeBytes.length);
+//
+// cusSendCommand(Configuration.DEVICES_MODIFY_COMMAND,
+// info.getDeviceSubnetID(), info.getDeviceDeviceID(), updateBytes);
+// }
+
+ /**
+ * 鎺у埗鐏厜
+ *
+ * @param info
+ * @param state
+ */
+ public static void lightCtrl(final AppliancesInfo info, int state) {
+// HDLDeviceManager.isLightCtrlSuccess = false;
+ HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false);
+ if (lightCtrlFailTimer != null) {
+ lightCtrlFailTimer.cancel();
+ lightCtrlFailTimer = null;
+ }
+ if ((!(state >= 0 && state <= 100))
+ || (info.getBigType() != Configuration.LIGTH_BIG_TYPE)
+ || info.getChannelNum() == 0
+ ) {
+ HDLLog.I("djlCtrl: " + "鐏厜璁惧鎺у埗涓嶅湪鑼冨洿鍐呮垨涓嶆槸鐏厜璁惧"
+ + " \nstate = " + state
+ + " \nLittleType = " + info.getLittleType()
+ + " \nBigType = " + info.getBigType()
+ );
+ return;
+ }
+
+ byte[] bytes;
+ switch (info.getLittleType()) {
+ case 0:
+ case 1:
+ //鍙兘鏈夊尯鍒�
+ bytes = new byte[]{(byte) info.getChannelNum(), (byte) state, 0, 0};
+ break;
+ case 9:
+ bytes = new byte[]{(byte) info.getPhysicsChannelNum(), (byte) state, 0, 0};
+ break;
+ case 10:
+ bytes = new byte[]{(byte) info.getPhysicsChannelNum(), (byte) state, 0, 0};
+ break;
+ default:
+ bytes = new byte[]{0};
+ break;
+ }
+ //閰掑簵鐨勬槸鐗╃悊鍥炶矾鍙凤紝闇�瑕佹祴璇曘�傚彲鑳戒細鍑虹幇闂
+// HDLDeviceManager.curCtrlLightType = I.getDeviceType();
+// byte[] bytes = new byte[]{(byte) I.getChannelNum(), (byte) state, 0, 0};
+ addSendData(info, bytes, Configuration.CONTROL);
+
+ lightCtrlFailTimer = new Timer();
+
+ lightCtrlFailTimer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) {
+ LightCtrlBackInfo lightCtrlBackInfo = new LightCtrlBackInfo();
+ lightCtrlBackInfo.setAppliancesInfo(info);
+ lightCtrlBackInfo.setChannelNum(info.getChannelNum());
+ EventBus.getDefault().post(new LightFeedBackEvent(lightCtrlBackInfo, false));
+ }
+ }
+ }, mRequestTimeout);
+ }
+
+
+ /**
+ * 鎺у埗绐楀笜
+ *
+ * @param info
+ * @param state
+ */
+ public static void curtainCtrl(final AppliancesInfo info, int state) {
+// HDLDeviceManager.isCurtainCtrlSuccess = false;
+ HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false);
+ if (curtainCtrlFailTimer != null) {
+ curtainCtrlFailTimer.cancel();
+ curtainCtrlFailTimer = null;
+ }
+ byte[] bytes;
+ if (info.getBigType() == Configuration.CURTAIN_BIG_TYPE) {
+ if (info.getLittleType() == 1 || info.getLittleType() == 0) {
+ //杩欓噷鏄垽鏂嵎甯樼數鏈哄拰寮�鍚堝笜鐢垫満
+ int newChannelNum;
+ if (state == CurtainCtrlParser.curtainOff
+ || state == CurtainCtrlParser.curtainOn
+ || state == CurtainCtrlParser.curtainPause) {
+ newChannelNum = info.getChannelNum();
+ } else {
+ newChannelNum = info.getChannelNum() + 16;
+ }
+ bytes = CurtainCtrlParser.getCurtainAddByte(newChannelNum, state);
+ } else {
+ bytes = CurtainCtrlParser.getCurtainAddByte(info.getChannelNum(), state);
+ }
+
+ addSendData(info, bytes, Configuration.CONTROL);
+
+ curtainCtrlFailTimer = new Timer();
+
+ curtainCtrlFailTimer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) {
+ CurtainCtrlBackInfo curtainCtrlBackInfo = new CurtainCtrlBackInfo();
+ curtainCtrlBackInfo.setAppliancesInfo(info);
+ curtainCtrlBackInfo.setNum(info.getChannelNum());
+ EventBus.getDefault().post(new CurtainFeedBackEvent(curtainCtrlBackInfo, false));
+ }
+ }
+ }, mRequestTimeout);
+
+
+ } else {
+ HDLLog.I("djlCtrl; 涓嶆槸绐楀笜璁惧"
+ + " \nstate = " + state
+ + " \nLittleType = " + info.getLittleType()
+ + " \nBigType = " + info.getBigType()
+ );
+ }
+ }
+
+
+ /**
+ * 鎺у埗绌鸿皟
+ *
+ * @param info
+ * @param type
+ * @param state // * @param bCelsius 鍒ゆ柇鎽勬皬搴� 杩樻槸 鍗庢皬搴�(鈩�)
+ */
+ public static void airCtrl(final AppliancesInfo info, int type, int state) {
+// HDLDeviceManager.isACCtrlSuccess = false;
+ HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false);
+ if (acCtrlFailTimer != null) {
+ acCtrlFailTimer.cancel();
+ acCtrlFailTimer = null;
+ }
+ if (info.getBigType() == Configuration.AIR_BIG_TYPE) {
+ if (info.getDeviceType() == HDLApConfig.TYPE_AC_PANEL) {
+ addSendData(info, AirCtrlParser.getAirPanelAddByte(type, state), Configuration.CONTROL);
+ } else {
+ byte[] airbytes = AirCtrlParser.getAcAddByte(info, type, state);
+ if (airbytes != null) {
+ addSendData(info, airbytes, Configuration.CONTROL);
+ }
+ }
+
+ acCtrlFailTimer = new Timer();
+ acCtrlFailTimer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) {
+ AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo();
+ airCtrlBackInfo.setAppliancesInfo(info);
+ EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, false));
+ }
+ }
+ }, mRequestTimeout);
+
+
+ } else {
+ HDLLog.I("绌鸿皟璁惧鎺у埗涓嶅湪鑼冨洿鍐�"
+ + " LittleType = " + info.getLittleType()
+ + " BigType = " + info.getBigType()
+ );
+ }
+ }
+
+
+ /**
+ * 鎺у埗閫氱敤寮�鍏�
+ *
+ * @param info
+ */
+ public static void commonSwitchCtrl(final AppliancesInfo info, int state) {
+
+ HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false);
+ if (info.getBigType() == Configuration.COMMON_SWITCH_BIG_TYPE) {
+
+ if (commonSwitchCtrlFailTimer != null) {
+ commonSwitchCtrlFailTimer.cancel();
+ commonSwitchCtrlFailTimer = null;
+ }
+
+ byte[] bytes = new byte[]{(byte) info.getChannelNum(), (byte) state};
+
+ addSendData(info, bytes, Configuration.CONTROL);
+
+ commonSwitchCtrlFailTimer = new Timer();
+ commonSwitchCtrlFailTimer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) {
+ HDLLog.I("閫氱敤寮�鍏虫帶鍒跺け璐�");
+ CommonSwitchBackInfo mCommonSwitchBackInfo = new CommonSwitchBackInfo();
+ mCommonSwitchBackInfo.setAppliancesInfo(info);
+ EventBus.getDefault().post(new CommonSwitchCtrlBackEvent(mCommonSwitchBackInfo, false));
+ }
+ }
+ }, mRequestTimeout);
+ } else {
+ HDLLog.I("djlCtrl: 閫氱敤寮�鍏宠澶囨帶鍒朵笉鍦ㄨ寖鍥村唴"
+ + " LittleType = " + info.getLittleType()
+ + " BigType = " + info.getBigType()
+ );
+ }
+ }
+
+
+ /**
+ * 鑾峰彇閫氱敤寮�鍏崇姸鎬�
+ * @param info
+ */
+ public static void getCommonSwitchStateFromNetwork(final AppliancesInfo info) {
+ if (info == null) {
+ return;
+ }
+ HDLDeviceManager.isGetDeviceStateSuccess = false;
+ switch (info.getDeviceType()) {
+ case HDLApConfig.TYPE_COMMON_SWITCH:
+ //鍙戦�佽幏鐏厜鐘舵�佹暟鎹�
+ addSendData(info, new byte[0], Configuration.STATE);
+ break;
+ default:
+ HDLLog.I("涓嶆槸閫氱敤寮�鍏宠澶�");
+ break;
+ }
+ }
+
+ /**
+ * 瀹夐槻妯″潡 甯冮槻璁剧疆
+ * 2019-7-29
+ * @param info
+ */
+ public static void securityArmingCtrl(final AppliancesInfo info, int state) {
+// HDLDeviceManager.isSecurityCtrlSuccess = false;
+ HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false);
+ if (securityCtrlFailTimer != null) {
+ securityCtrlFailTimer.cancel();
+ securityCtrlFailTimer = null;
+ }
+ if (info.getBigType() == Configuration.SECURITY_BIG_TYPE) {
+ byte[] sendbytes = SecurityParser.getArmingByte(info, state);
+ addSendData(info, sendbytes, Configuration.CONTROL);
+ securityCtrlFailTimer = new Timer();
+ securityCtrlFailTimer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) {
+ EventBus.getDefault().post(new SecurityArmingFeedBackEvent(info,0, false));
+ }
+ }
+ }, 5000);
+
+ } else {
+ HDLLog.I("瀹夐槻妯″潡涓嶅湪鑼冨洿鍐�"
+ + " LittleType = " + info.getLittleType()
+ + " BigType = " + info.getBigType()
+ );
+ }
+ }
+
+ /**
+ * 瀹夐槻妯″潡 鎶ヨ璁剧疆
+ * 2019-7-29
+ * @param info
+ * @param state 鍙戦�佺殑鎶ヨ鍐呭锛屽彧鎶ヨ涓�绉�
+ */
+ public static void securitySendAlarm(final AppliancesInfo info, int state) {
+ if (info.getBigType() == Configuration.SECURITY_BIG_TYPE) {
+ byte[] sendbytes = SecurityParser.getAlarmByte(info, state);
+ cusSendCommand(Configuration.SECURITY_ALARM_CTRL_COMMAND, info.getDeviceSubnetID(), info.getDeviceDeviceID(), sendbytes);
+ } else {
+ HDLLog.I("涓嶆槸瀹夐槻妯″潡"
+ + " LittleType = " + info.getLittleType()
+ + " BigType = " + info.getBigType()
+ );
+ }
+ }
+
+ /**
+ * 鎺у埗閫昏緫妯″潡
+ *
+ * @param info
+ */
+ public static void logicCtrl(final AppliancesInfo info) {
+// HDLDeviceManager.isSceneCtrlSuccess = false;
+ HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false);
+ if (info.getBigType() == Configuration.LOGIC_BIG_TYPE
+ || info.getBigType() == Configuration.GLOBAL_LOGIC_BIG_TYPE) {
+ if (info.getLogicMode() == null) {
+// HDLSerialPortCore.sendTestCMD(HDLTest.CODE_LOGIC_MODE_NULL, HDLTest.EXCEPTION_TEST_PORT);
+ return;
+ } else {
+ addSendData(info, new byte[]{(byte) info.getLogicMode().getAreaNum(),
+ (byte) info.getLogicMode().getAreaSceneNum()}, Configuration.CONTROL);
+ }
+
+
+ if (sceneCtrlFailTimer != null) {
+ sceneCtrlFailTimer.cancel();
+ sceneCtrlFailTimer = null;
+ }
+ sceneCtrlFailTimer = new Timer();
+ sceneCtrlFailTimer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) {
+ HDLLog.I("閫昏緫鎺у埗澶辫触");
+ LogicCtrlBackInfo logicCtrlBackInfo = new LogicCtrlBackInfo();
+ logicCtrlBackInfo.setAppliancesInfo(info);
+ EventBus.getDefault().post(new LogicFeedBackEvent(logicCtrlBackInfo, false));
+ }
+ }
+ }, mRequestTimeout);
+ } else {
+ HDLLog.I("djlCtrl: 閫昏緫妯″潡璁惧鎺у埗涓嶅湪鑼冨洿鍐�"
+ + " LittleType = " + info.getLittleType()
+ + " BigType = " + info.getBigType()
+ );
+ }
+ }
+
+ // 鑾峰彇鍗曚竴鍥炶矾璁惧鐘舵��
+ // 璇诲彇璁惧鐘舵��
+// public static void getDeviceState(final AppliancesInfo I) {
+// HDLDeviceManager.isGetDeviceStateSuccess = false;
+// switch (I.getBigType()) {
+// case Configuration.LIGTH_BIG_TYPE:
+// addSendData(I, new byte[]{}, Configuration.STATE);
+// break;
+// case Configuration.CURTAIN_BIG_TYPE:
+// if (I.getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) {
+// addSendData(I, new byte[]{(byte) I.getChannelNum()}, Configuration.STATE);
+// } else {
+// addSendData(I, new byte[]{(byte) (I.getChannelNum() + 16)}, Configuration.STATE);
+// }
+// break;
+// case Configuration.AIR_BIG_TYPE:
+// addSendData(I, new byte[]{AirCtrlParser.airSwich}, Configuration.STATE);
+//// addSendData(I,new byte[]{AirCtrlParser.refTem},Configuration.STATE);
+// addSendData(I, new byte[]{AirCtrlParser.airSpeed}, Configuration.STATE);
+// addSendData(I, new byte[]{AirCtrlParser.airMode}, Configuration.STATE);
+//// addSendData(I,new byte[]{AirCtrlParser.heatTem},Configuration.STATE);
+//// addSendData(I,new byte[]{AirCtrlParser.autoTem},Configuration.STATE);
+// break;
+// }
+//
+// if (I.getBigType() == Configuration.AIR_BIG_TYPE) {
+// return;
+// }
+// if (getStateFailTimer != null) {
+// getStateFailTimer.cancel();
+// getStateFailTimer = null;
+// }
+// getStateFailTimer = new Timer();
+// getStateFailTimer.schedule(new TimerTask() {
+// @Override
+// public void run() {
+// if (!HDLDeviceManager.isGetDeviceStateSuccess) {
+// EventBus.getDefault().post(new DeviceStateEvent(I, false));
+// }
+// }
+// }, mRequestTimeout);
+//
+// }
+
+ /**
+ * 鎺у埗绐楀笜
+ *
+ * @param info
+ */
+ public static void curtainGetState(final AppliancesInfo info) {
+ byte[] bytes = new byte[1];
+ if (info.getBigType() == Configuration.CURTAIN_BIG_TYPE) {
+ if (info.getLittleType() == 1 || info.getLittleType() == 0) {
+ //杩欓噷鏄垽鏂嵎甯樼數鏈哄拰寮�鍚堝笜鐢垫満
+ int newChannelNum;
+ int state = HDLUtlis.getIntegerByObject(info.getCurState());
+ if (state == CurtainCtrlParser.TYPE_STATE_PAUSE
+ || state == CurtainCtrlParser.TYPE_STATE_OPEN
+ || state == CurtainCtrlParser.TYPE_STATE_CLOSE) {
+ newChannelNum = info.getChannelNum();
+ } else {
+ newChannelNum = info.getChannelNum() + 16;
+ }
+ bytes[0] = (byte) newChannelNum;
+ } else {
+ bytes[0] = (byte) info.getChannelNum();
+ }
+
+ addSendData(info, bytes, Configuration.STATE);
+ } else {
+ HDLLog.I("djlCtrl; 涓嶆槸绐楀笜璁惧"
+ + " \nLittleType = " + info.getLittleType()
+ + " \nBigType = " + info.getBigType()
+ );
+ }
+ }
+
+//
+// /**
+// * 缃戠粶涓婅幏鍙栧崟涓�璁惧鐘舵��
+// * 閫氳繃鍙戦�佹煡璇㈡寚浠よ幏鍙�
+// * 绌鸿皟鐘舵�佽鍙栵紙鐩墠浠呮敮鎸侀�氱敤绌鸿皟闈㈡澘锛�
+// *
+// * @param info
+// */
+// public static void getDeviceStateFromNetwork(final AppliancesInfo info) {
+// if (info == null) {
+// return;
+// }
+// HDLDeviceManager.isGetDeviceStateSuccess = false;
+// switch (info.getDeviceType()) {
+// case HDLApConfig.TYPE_LIGHT_DIMMER:
+// case HDLApConfig.TYPE_LIGHT_RELAY:
+// case HDLApConfig.TYPE_LIGHT_MIX_DIMMER:
+// case HDLApConfig.TYPE_LIGHT_MIX_RELAY:
+// //鍙戦�佽幏鐏厜鐘舵�佹暟鎹�
+// addSendData(info, new byte[0], Configuration.STATE);
+// break;
+//
+// case HDLApConfig.TYPE_CURTAIN_GLYSTRO:
+// case HDLApConfig.TYPE_CURTAIN_ROLLER:
+// case HDLApConfig.TYPE_CURTAIN_MODULE:
+// addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE);
+// break;
+//
+// case HDLApConfig.TYPE_AC_HVAC:
+// case HDLApConfig.TYPE_AC_COOLMASTER:
+// case HDLApConfig.TYPE_AC_INFRARED:
+// case HDLApConfig.TYPE_AC_PANEL:
+// //鏆備笉鏀寔
+//
+// break;
+//
+// default:
+// break;
+//
+// }
+// }
+
+ /**
+ * 鑾峰彇绐楀笜璁惧鐘舵��
+ * @param info
+ */
+ public static void getCurtainDeviceStateFromNetwork(final AppliancesInfo info) {
+ if (info == null) {
+ return;
+ }
+ HDLDeviceManager.isGetDeviceStateSuccess = false;
+ switch (info.getDeviceType()) {
+ case HDLApConfig.TYPE_CURTAIN_GLYSTRO:
+ case HDLApConfig.TYPE_CURTAIN_ROLLER:
+ case HDLApConfig.TYPE_CURTAIN_MODULE:
+ addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE);
+ break;
+ default:
+ HDLLog.I("涓嶆槸绐楀笜璁惧");
+ break;
+ }
+ }
+
+ /**
+ * 鑾峰彇鐏厜璁惧鐘舵��
+ * @param info
+ */
+ public static void getLightDeviceStateFromNetwork(final AppliancesInfo info) {
+ if (info == null) {
+ return;
+ }
+ HDLDeviceManager.isGetDeviceStateSuccess = false;
+ switch (info.getDeviceType()) {
+ case HDLApConfig.TYPE_LIGHT_DIMMER:
+ case HDLApConfig.TYPE_LIGHT_RELAY:
+ case HDLApConfig.TYPE_LIGHT_MIX_DIMMER:
+ case HDLApConfig.TYPE_LIGHT_MIX_RELAY:
+ //鍙戦�佽幏鐏厜鐘舵�佹暟鎹�
+ addSendData(info, new byte[0], Configuration.STATE);
+ break;
+ default:
+ HDLLog.I("涓嶆槸鐏厜璁惧");
+ break;
+ }
+ }
+
+
+
+ /**
+ * 鑾峰彇閫昏緫 鍦烘櫙鍙�
+ * @param info
+ */
+ public static void getLogicDeviceStateFromNetwork(final AppliancesInfo info) {
+ if (info == null) {
+ return;
+ }
+ HDLDeviceManager.isGetDeviceStateSuccess = false;
+ switch (info.getDeviceType()) {
+ case HDLApConfig.TYPE_LOGIC_MODULE:
+ case HDLApConfig.TYPE_GLOBAL_LOGIC_MODULE:
+ //鍙戦�佽幏鍙栧満鏅彿
+ addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE);
+ break;
+ default:
+ HDLLog.I("涓嶆槸閫昏緫璁惧");
+ break;
+ }
+ }
+
+ /**
+ * 鑾峰彇瀹夐槻妯″潡鐘舵��
+ * @param info
+ */
+ public static void getSecurityStateFromNetwork(final AppliancesInfo info) {
+ if (info == null) {
+ return;
+ }
+ HDLDeviceManager.isGetDeviceStateSuccess = false;
+ switch (info.getDeviceType()) {
+ case HDLApConfig.TYPE_SECURITY_MODULE:
+ //鍙戦�佽幏瀹夐槻妯″潡鐘舵�佹暟鎹�
+ addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE);
+ break;
+ default:
+ HDLLog.I("涓嶆槸瀹夐槻妯″潡");
+ break;
+ }
+ }
+
+ /**
+ * 鑾峰彇浼犳劅鍣ㄦā鍧楃姸鎬�
+ * @param info
+ */
+ public static void getSensorStateFromNetwork(final AppliancesInfo info) {
+ if (info == null) {
+ return;
+ }
+ HDLDeviceManager.isGetDeviceStateSuccess = false;
+ switch (info.getDeviceType()) {
+ case HDLApConfig.TYPE_SENSOR_DRY_CONTACT:
+ case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR:
+ case HDLApConfig.TYPE_SENSOR_TEMP:
+ case HDLApConfig.TYPE_SENSOR_HUMIDITY:
+ case HDLApConfig.TYPE_SENSOR_ILLUMINACE:
+ case HDLApConfig.TYPE_SENSOR_VOC:
+ case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5:
+ case HDLApConfig.TYPE_SENSOR_C02:
+ case HDLApConfig.TYPE_SENSOR_LPG:
+ case HDLApConfig.TYPE_SENSOR_CO_H2:
+ case HDLApConfig.TYPE_SENSOR_CH4:
+ case HDLApConfig.TYPE_SENSOR_SMOG:
+ case HDLApConfig.TYPE_SENSOR_WIND_SPEED:
+ case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE:
+ case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW:
+ case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE:
+ case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH:
+ case HDLApConfig.TYPE_SENSOR_RAIN_FALL:
+ case HDLApConfig.TYPE_SENSOR_WEIGHT:
+ case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH:
+ case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED:
+ case HDLApConfig.TYPE_SENSOR_SHAKE:
+ case HDLApConfig.TYPE_SENSOR_VOLTAGE:
+ case HDLApConfig.TYPE_SENSOR_ELECTRICITY:
+ case HDLApConfig.TYPE_SENSOR_POWER:
+ case HDLApConfig.TYPE_SENSOR_FLOODING:
+ case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET:
+ case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON:
+ //鍙戦�佽幏浼犳劅鍣ㄦā鍧楃姸鎬佹暟鎹�
+ byte[] sendDatabyte = new byte[]{
+ (byte) info.getBigType(),
+ (byte) info.getLittleType(),
+ (byte) info.getChannelNum()
+ };
+
+ addSendData(info, sendDatabyte, Configuration.STATE);
+ break;
+ default:
+ HDLLog.I("涓嶆槸浼犳劅鍣ㄦā鍧�");
+ break;
+ }
+ }
+
+ /**
+ * 鑾峰彇骞叉帴鐐逛紶鎰熷櫒妯″潡鐘舵��
+ * @param info
+ */
+ public static void getDryContactSensorStateFromNetwork(final AppliancesInfo info) {
+ if (info == null) {
+ return;
+ }
+ HDLDeviceManager.isGetDeviceStateSuccess = false;
+ switch (info.getDeviceType()) {
+ case HDLApConfig.TYPE_SENSOR_DRY_CONTACT:
+ case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR:
+ case HDLApConfig.TYPE_SENSOR_TEMP:
+ case HDLApConfig.TYPE_SENSOR_HUMIDITY:
+ case HDLApConfig.TYPE_SENSOR_ILLUMINACE:
+ case HDLApConfig.TYPE_SENSOR_VOC:
+ case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5:
+ case HDLApConfig.TYPE_SENSOR_C02:
+ case HDLApConfig.TYPE_SENSOR_LPG:
+ case HDLApConfig.TYPE_SENSOR_CO_H2:
+ case HDLApConfig.TYPE_SENSOR_CH4:
+ case HDLApConfig.TYPE_SENSOR_SMOG:
+ case HDLApConfig.TYPE_SENSOR_WIND_SPEED:
+ case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE:
+ case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW:
+ case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE:
+ case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH:
+ case HDLApConfig.TYPE_SENSOR_RAIN_FALL:
+ case HDLApConfig.TYPE_SENSOR_WEIGHT:
+ case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH:
+ case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED:
+ case HDLApConfig.TYPE_SENSOR_SHAKE:
+ case HDLApConfig.TYPE_SENSOR_VOLTAGE:
+ case HDLApConfig.TYPE_SENSOR_ELECTRICITY:
+ case HDLApConfig.TYPE_SENSOR_POWER:
+ case HDLApConfig.TYPE_SENSOR_FLOODING:
+ case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET:
+ case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON:
+ //鍙戦�佽幏浼犳劅鍣ㄦā鍧楃姸鎬佹暟鎹�
+ byte[] sendDatabyte = new byte[]{
+ (byte) 1,
+ (byte) info.getChannelNum()
+ };
+
+ addSendData(info, sendDatabyte, Configuration.STATE);
+ break;
+ default:
+ HDLLog.I("涓嶆槸浼犳劅鍣ㄦā鍧�");
+ break;
+ }
+ }
+
+ /**
+ * 鑾峰彇HVAC绌鸿皟璁惧鐘舵��
+ * @param info
+ */
+ public static void getHVACDeviceStateFromNetwork(final AppliancesInfo info) {
+ if (info == null) {
+ return;
+ }
+ HDLDeviceManager.isGetDeviceStateSuccess = false;
+ switch (info.getDeviceType()) {
+ case HDLApConfig.TYPE_AC_HVAC:
+// case HDLApConfig.TYPE_AC_PANEL:
+ //鍙戦�丠VAC鐘舵�佹暟鎹�
+ addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE);
+ break;
+ default:
+ HDLLog.I("涓嶆槸HVAC绌鸿皟璁惧");
+ break;
+ }
+ }
+
+
+ /**
+ * 鑾峰彇鍗曚竴璁惧鐘舵��
+ * 浠嶴DK鏈湴鑾峰彇
+ *
+ * @param info
+ */
+ public static void getDeviceStateFromLocal(final AppliancesInfo info) {
+ if (info == null) {
+ return;
+ }
+ HDLDeviceManager.isGetDeviceStateSuccess = false;
+ switch (info.getDeviceType()) {
+ case HDLApConfig.TYPE_LIGHT_DIMMER:
+ case HDLApConfig.TYPE_LIGHT_RELAY:
+ case HDLApConfig.TYPE_LIGHT_MIX_DIMMER:
+ case HDLApConfig.TYPE_LIGHT_MIX_RELAY:
+ int lightState = getLightState(info);
+ info.setCurState(lightState);
+ EventBus.getDefault().post(new DeviceStateEvent(info, true));
+ break;
+
+ case HDLApConfig.TYPE_CURTAIN_GLYSTRO:
+ case HDLApConfig.TYPE_CURTAIN_ROLLER:
+ case HDLApConfig.TYPE_CURTAIN_MODULE:
+ int curtainState = getCurtainState(info);
+ info.setCurState(curtainState);
+ EventBus.getDefault().post(new DeviceStateEvent(info, true));
+ break;
+
+ case HDLApConfig.TYPE_AC_HVAC:
+ case HDLApConfig.TYPE_AC_COOLMASTER:
+ case HDLApConfig.TYPE_AC_INFRARED:
+ case HDLApConfig.TYPE_AC_PANEL:
+ //2019-8-21 澧炲姞鍒ょ┖
+ byte[] acState = getACState(info);
+ if (acState != null && acState.length >= 4) {
+ info.setArrCurState(new byte[]{AirCtrlParser.airSwich, acState[0]});
+ EventBus.getDefault().post(new DeviceStateEvent(info, true));
+
+ info.setArrCurState(new byte[]{AirCtrlParser.airMode, acState[1]});
+ EventBus.getDefault().post(new DeviceStateEvent(info, true));
+
+ switch (acState[1] & 0xff) {
+ case AirCtrlParser.airModeRefTem:
+ info.setArrCurState(new byte[]{AirCtrlParser.refTem, acState[2]});
+ EventBus.getDefault().post(new DeviceStateEvent(info, true));
+ break;
+ case AirCtrlParser.airModeHeatTem:
+ info.setArrCurState(new byte[]{AirCtrlParser.heatTem, acState[2]});
+ EventBus.getDefault().post(new DeviceStateEvent(info, true));
+ break;
+ case AirCtrlParser.airModeAuto:
+ info.setArrCurState(new byte[]{AirCtrlParser.autoTem, acState[2]});
+ EventBus.getDefault().post(new DeviceStateEvent(info, true));
+ break;
+ case AirCtrlParser.airModeDehum:
+ info.setArrCurState(new byte[]{AirCtrlParser.autoTem, acState[2]});
+ EventBus.getDefault().post(new DeviceStateEvent(info, true));
+ break;
+ default:
+ break;
+ }
+
+ if ((acState[1] & 0xff) != AirCtrlParser.airModeDehum) {
+ info.setArrCurState(new byte[]{AirCtrlParser.airSpeed, acState[3]});
+ EventBus.getDefault().post(new DeviceStateEvent(info, true));
+ }
+ }
+ break;
+ case HDLApConfig.TYPE_SECURITY_MODULE://2019-7-29
+ byte[] ArrCurState = getSecurityState(info);
+ info.setArrCurState(ArrCurState);
+ EventBus.getDefault().post(new DeviceStateEvent(info, true));
+ break;
+
+// case HDLApConfig.TYPE_SENSOR_DRY_CONTACT://灞忚斀20190703
+// case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR:
+// case HDLApConfig.TYPE_SENSOR_TEMP:
+// case HDLApConfig.TYPE_SENSOR_HUMIDITY:
+// case HDLApConfig.TYPE_SENSOR_ILLUMINACE:
+// case HDLApConfig.TYPE_SENSOR_VOC:
+// case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5:
+// case HDLApConfig.TYPE_SENSOR_C02:
+// case HDLApConfig.TYPE_SENSOR_LPG:
+// case HDLApConfig.TYPE_SENSOR_CO_H2:
+// case HDLApConfig.TYPE_SENSOR_CH4:
+// case HDLApConfig.TYPE_SENSOR_SMOG:
+// case HDLApConfig.TYPE_SENSOR_WIND_SPEED:
+// case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE:
+// case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW:
+// case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE:
+// case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH:
+// case HDLApConfig.TYPE_SENSOR_RAIN_FALL:
+// case HDLApConfig.TYPE_SENSOR_WEIGHT:
+// case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH:
+// case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED:
+// case HDLApConfig.TYPE_SENSOR_SHAKE:
+// case HDLApConfig.TYPE_SENSOR_VOLTAGE:
+// case HDLApConfig.TYPE_SENSOR_ELECTRICITY:
+// case HDLApConfig.TYPE_SENSOR_POWER:
+// case HDLApConfig.TYPE_SENSOR_FLOODING:
+// case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET:
+// case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON:
+// //鍙戦�佽幏鍙栦紶鎰熷櫒鎵�鏈夋暟鎹�
+// addSendData(info, new byte[]{(byte) info.getBigType(), (byte) info.getLittleType(), (byte) info.getChannelNum()}, Configuration.STATE);
+// break;
+ default:
+ break;
+
+ }
+ }
+
+ /**
+ * 鑾峰彇鎵�鏈夎澶囩姸鎬�
+ *
+ * @return
+ */
+ public static List<DeviceStateBean> getAllDevicesState() {
+ List<DeviceStateBean> deviceStateBeanList = new ArrayList<>();
+ for (int i = 0; i < HDLDeviceManager.devicesDataList.size(); i++) {
+ List<AppliancesInfo> appliancesInfos = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0; j < appliancesInfos.size(); j++) {
+ if (appliancesInfos.get(j).getBigType() == Configuration.LIGTH_BIG_TYPE
+ || appliancesInfos.get(j).getBigType() == Configuration.CURTAIN_BIG_TYPE
+ || appliancesInfos.get(j).getBigType() == Configuration.AIR_BIG_TYPE
+ ) {
+ DeviceStateBean deviceStateBean = new DeviceStateBean();
+ deviceStateBean.setDeviceSubnetID(appliancesInfos.get(j).getDeviceSubnetID());
+ deviceStateBean.setDeviceDeviceID(appliancesInfos.get(j).getDeviceDeviceID());
+ deviceStateBean.setBigType(appliancesInfos.get(j).getBigType());
+ deviceStateBean.setLittleType(appliancesInfos.get(j).getLittleType());
+ deviceStateBean.setDeviceType(appliancesInfos.get(j).getDeviceType());
+ deviceStateBean.setChannelNum(appliancesInfos.get(j).getChannelNum());
+ if (deviceStateBean.getBigType() == Configuration.AIR_BIG_TYPE) {
+ if (appliancesInfos.get(j).getArrCurState() != null) {
+ deviceStateBean.setArrCurState(appliancesInfos.get(j).getArrCurState());
+ }
+
+ } else {
+ deviceStateBean.setCurState(appliancesInfos.get(j).getIntCurState());
+
+ }
+ deviceStateBeanList.add(deviceStateBean);
+ }
+
+ }
+ }
+// //鏇存柊鎵�鏈夎澶囩姸鎬� 2019-07-03鍘绘帀
+// HandleSearch.refreshAllDevicesState();
+ if (!deviceStateBeanList.isEmpty()) {
+ return deviceStateBeanList;
+ } else {
+ return null;
+ }
+
+
+ }
+
+
+ /**
+ * 鑾峰彇鐏厜鐘舵��
+ *
+ * @param info
+ * @return
+ */
+ private static int getLightState(final AppliancesInfo info) {
+ int curState = 0;
+ outter:
+ for (int i = 0, len = HDLDeviceManager.devicesDataList.size(); i < len; i++) {
+ if (HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID() == info.getDeviceSubnetID()
+ && HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID() == info.getDeviceDeviceID()
+ ) {
+ List<AppliancesInfo> infos = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (info.getBigType() == infos.get(j).getBigType()
+ && info.getLittleType() == infos.get(j).getLittleType()
+ && info.getChannelNum() == infos.get(j).getChannelNum()
+ ) {
+ curState = HDLUtlis.getIntegerByObject(infos.get(j).getCurState());
+ break outter;
+ }
+
+ }
+ }
+ }
+ return curState;
+ }
+
+ /**
+ * 鑾峰彇绐楀笜鐘舵��
+ *
+ * @param info
+ * @return
+ */
+ private static int getCurtainState(final AppliancesInfo info) {
+ int curState = 0;
+ outter:
+ for (int i = 0, len = HDLDeviceManager.devicesDataList.size(); i < len; i++) {
+ if (HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID() == info.getDeviceSubnetID()
+ && HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID() == info.getDeviceDeviceID()
+ ) {
+ List<AppliancesInfo> infos = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (info.getBigType() == infos.get(j).getBigType()
+ && info.getLittleType() == infos.get(j).getLittleType()
+ && info.getChannelNum() == infos.get(j).getChannelNum()
+ ) {
+ //杩欓噷搴旇鏄淇鐨勶紝鏆傛椂鏈壘鍒般��
+ //2019-07 淇敼
+ int mCurState = HDLUtlis.getIntegerByObject(infos.get(j).getCurState());
+ switch (mCurState) {
+ case -1:
+ curState = 0;
+ break;
+ case -2:
+ curState = 1;
+ break;
+ case -3:
+ curState = 2;
+ break;
+ default:
+ curState = mCurState;
+ break;
+
+ }
+
+ break outter;
+ }
+
+ }
+ }
+ }
+ return curState;
+ }
+
+ /**
+ * 鑾峰彇绌鸿皟鐘舵��
+ *
+ * @param info
+ * @return
+ */
+ private static byte[] getACState(final AppliancesInfo info) {
+ byte[] curState = new byte[0];
+ outter:
+ for (int i = 0, len = HDLDeviceManager.devicesDataList.size(); i < len; i++) {
+ if (HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID() == info.getDeviceSubnetID()
+ && HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID() == info.getDeviceDeviceID()
+ ) {
+ List<AppliancesInfo> infos = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (info.getBigType() == infos.get(j).getBigType()
+ && info.getLittleType() == infos.get(j).getLittleType()
+ && info.getChannelNum() == infos.get(j).getChannelNum()
+ ) {
+ switch (info.getDeviceType()) {
+ case HDLApConfig.TYPE_AC_HVAC:
+ case HDLApConfig.TYPE_AC_PANEL:
+ curState = infos.get(j).getArrCurState();
+ break;
+ default:
+ break;
+ }
+ break outter;
+ }
+
+ }
+ }
+ }
+ return curState;
+ }
+
+ /**
+ * 鑾峰彇瀹夐槻妯″潡鏈湴鐘舵��
+ *
+ * @param info
+ * @return
+ */
+ private static byte[] getSecurityState(final AppliancesInfo info) {
+ byte[] curState = new byte[0];
+ outter:
+ for (int i = 0, len = HDLDeviceManager.devicesDataList.size(); i < len; i++) {
+ if (HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID() == info.getDeviceSubnetID()
+ && HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID() == info.getDeviceDeviceID()
+ ) {
+ List<AppliancesInfo> infos = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (info.getBigType() == infos.get(j).getBigType()
+ && info.getLittleType() == infos.get(j).getLittleType()
+ && info.getChannelNum() == infos.get(j).getChannelNum()
+ ) {
+ curState = infos.get(j).getArrCurState();
+ break outter;
+ }
+ }
+
+ break outter;
+ }
+
+ }
+ return curState;
+ }
+
+
+
+ /**
+ * 鑳屾櫙闊充箰鎺у埗
+ *
+ * @param info
+ * @param type
+ */
+ public static void audioCtrl(AppliancesInfo info, int type) {
+ byte[] musicBytes;
+ int command;
+ switch (type) {
+ case HDLAudio.SET_AUDIO_PLAYSTOP:
+ command = Configuration.AUDIO_CTRL_READ_COMMAND;
+ musicBytes = new byte[]{0x2A, 0x53, 0x31, 0x50, 0x4C, 0x41, 0x59, 0x53, 0x54, 0x4F, 0x50, 0x0D};
+ break;
+ case HDLAudio.SET_AUDIO_PLAYPAUSE:
+ command = Configuration.AUDIO_CTRL_READ_COMMAND;
+ musicBytes = new byte[]{42, 83, 49, 80, 76, 65, 89, 80, 65, 85, 83, 69, 0x0D};
+ break;
+ case HDLAudio.SET_NEXT_SONG:
+ command = Configuration.AUDIO_CTRL_READ_COMMAND;
+ musicBytes = new byte[]{0x2A, 0x53, 0x31, 0x4E, 0x45, 0x58, 0x54, 0x0D};
+ break;
+ case HDLAudio.SET_PRE_SONG:
+ command = Configuration.AUDIO_CTRL_READ_COMMAND;
+ musicBytes = new byte[]{0x2A, 0x53, 0x31, 0x50, 0x52, 0x45, 0x56, 0x0D};
+ break;
+ case HDLAudio.GET_AUDIO_MODE:
+ command = Configuration.AUDIO_CTRL_READ_COMMAND;
+ musicBytes = new byte[]{0x2A, 0x53, 0x31, 0x50, 0x4C, 0x41, 0x59, 0x4D, 0x4F, 0x44, 0x45, 0x3F, 0x0D};
+ break;
+ case HDLAudio.SET_AUDIO_MODE_UP:
+ command = Configuration.AUDIO_CTRL_READ_COMMAND;
+ musicBytes = new byte[]{0x2A, 0x53, 0x31, 0x4D, 0x4F, 0x44, 0x45, 0x2B, 0x0D};
+ break;
+ case HDLAudio.SET_AUDIO_MODE_DOWN:
+ command = Configuration.AUDIO_CTRL_READ_COMMAND;
+ musicBytes = new byte[]{0x2A, 0x53, 0x31, 0x4D, 0x4F, 0x44, 0x45, 0x2D, 0x0D};
+ break;
+ case HDLAudio.GET_AUDIO_CURRRENT_INFO:
+ command = Configuration.AUDIO_CTRL_READ_COMMAND;
+ //*Z1STAUS?褰掍负閿�
+ musicBytes = new byte[]{0x2A, 0x5A, 0x31, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x3F, 0x0D};
+ break;
+ case HDLAudio.SET_PRE_LIST:
+ HDLAudio.isSetPreNextList = true;
+ command = Configuration.AUDIO_CTRL_READ_COMMAND;
+ musicBytes = new byte[]{0x2A, 0x53, 0x31, 0x50, 0x52, 0x45, 0x56, 0x4C, 0x49, 0x53, 0x54, 0x0D};
+ break;
+ case HDLAudio.SET_NEXT_LIST:
+ HDLAudio.isSetPreNextList = true;
+ command = Configuration.AUDIO_CTRL_READ_COMMAND;
+ musicBytes = new byte[]{0x2A, 0x53, 0x31, 0x4E, 0x45, 0x58, 0x54, 0x4C, 0x49, 0x53, 0x54, 0x0D};
+ break;
+ case HDLAudio.TEXT:
+ command = Configuration.AUDIO_MenuPlay_INSTRUCTION_COMMAND;
+ musicBytes = new byte[]{0x2A, 0x5A, 0x30, 0x31, 0x31, 0x4C, 0x49, 0x53, 0x54, 0x30, 0x30, 0x31, 0x30, 0x30, 0x32, 0x31, 0x0D};
+ break;
+ default:
+ command = 0;
+ musicBytes = null;
+ break;
+ }
+ if (musicBytes != null) {
+// String sendData = "";
+// for(int i = 0,len = musicBytes.length;i<len;i++){
+// sendData += musicBytes[i]+",";
+// }
+// sendData = HDLStringUtils.asciiToString(sendData);
+// HDLLog.I("鍙戝嚭鏁版嵁锛�"+sendData+"瀛愮綉id:"+I.getDeviceSubnetID()+" 璁惧id锛�"+I.getDeviceDeviceID());
+ cusSendCommand(command,
+ info.getDeviceSubnetID(), info.getDeviceDeviceID(), musicBytes);
+ }
+
+ }
+
+ /**
+ * 鑳屾櫙闊充箰鎺у埗
+ *
+ * @param info
+ * @param type
+ * @param value
+ */
+ public static void audioCtrl(AppliancesInfo info, int type, int value) {
+ byte[] musicBytes;
+ int command;
+ switch (type) {
+ case HDLAudio.GET_AUDIO_LIST:
+ HDLAudio.numStr.clear();
+ HDLAudio.songNameList.clear();
+ HDLAudio.curListNum = value;
+ command = Configuration.AUDIO_MenuPlay_INSTRUCTION_COMMAND;
+ //*Z011TYPE0011褰掍綅閿�
+ musicBytes = new byte[]{0x2A, 0x5A, 0x30, 0x31, 0x31, 0x54, 0x59, 0x50, 0x45, 0x30, 0x30, 0x31, 0x31, 0x0D};
+ break;
+ case HDLAudio.SET_AUDIO_VOL:
+ command = Configuration.AUDIO_CTRL_READ_COMMAND;
+ musicBytes = HDLAudio.audioVolparse(value);
+ break;
+ default:
+ command = 0;
+ musicBytes = null;
+ break;
+ }
+ if (musicBytes != null) {
+// String sendData = "";
+// for(int i = 0,len = musicBytes.length;i<len;i++){
+// sendData += musicBytes[i]+",";
+// }
+// sendData = HDLStringUtils.asciiToString(sendData);
+// HDLLog.I("鍙戝嚭鏁版嵁锛�"+sendData+"瀛愮綉id:"+I.getDeviceSubnetID()+" 璁惧id锛�"+I.getDeviceDeviceID());
+ cusSendCommand(command,
+ info.getDeviceSubnetID(), info.getDeviceDeviceID(), musicBytes);
+ }
+ }
+
+ /**
+ * @param info
+ * @param type
+ * @param listId 鍒楄〃鍙�
+ * @param songId 姝屾洸鍙�
+ */
+ public static void audioCtrl(AppliancesInfo info, int type, int listId, int songId) {
+ byte[] musicBytes;
+ int command;
+ switch (type) {
+
+ case HDLAudio.SET_CHOOSE_PLAY_SONG:
+ command = Configuration.AUDIO_MenuPlay_INSTRUCTION_COMMAND;
+ musicBytes = HDLAudio.audioChooseSongParse(listId, songId);
+ break;
+ default:
+ command = 0;
+ musicBytes = null;
+ break;
+ }
+
+ if (musicBytes != null) {
+// String sendData = "";
+// for(int i = 0,len = musicBytes.length;i<len;i++){
+// sendData += musicBytes[i]+",";
+// }
+// sendData = HDLStringUtils.asciiToString(sendData);
+// HDLLog.I("鍙戝嚭鏁版嵁锛�"+sendData+"瀛愮綉id:"+I.getDeviceSubnetID()+" 璁惧id锛�"+I.getDeviceDeviceID());
+ cusSendCommand(command,
+ info.getDeviceSubnetID(), info.getDeviceDeviceID(), musicBytes);
+ }
+
+ }
+
+
+// /**
+// * 鎻愪緵绗笁鏂硅皟鐢ㄨ缃湰鍦板瓙缃戝彿銆佽澶囧彿
+// * @param context
+// * @param subId
+// * @param deviceId
+// */
+// public static void setLocalId(Context context, int subId, int deviceId) {
+// Crc.localDeviceID = deviceId;
+// Crc.localSubnetID = subId;
+// SPUtils.setParam(context, SPUtils.KEY_SUB_ID, subId);
+// SPUtils.setParam(context, SPUtils.KEY_DEVICE_ID, deviceId);
+// }
+
+ /**
+ * 鍒ゆ柇ID鏄惁鍦ㄨ姹傝寖鍥村唴
+ */
+ public static Boolean getIfValueInScope(int mValue) {
+ return mValue >= 0 && mValue < 255;
+ }
+
+ /**
+ * 鎻愪緵绗笁鏂硅皟鐢ㄨ缃湰鍦板瓙缃戝彿銆佽澶囧彿 鑼冨洿0 - 254
+ *
+ * @param context
+ * @param mSubnetID
+ * @param mDeviceID
+ */
+ public static boolean saveSubnetAndDeviceID(Context context, int mSubnetID, int mDeviceID) {
+ try {
+ if (getIfValueInScope(mSubnetID) && getIfValueInScope(mDeviceID)) {
+ Crc.localSubnetID = mSubnetID;
+ Crc.localDeviceID = mDeviceID;
+ SPUtils.setParam(context, SPUtils.KEY_SUB_ID, mSubnetID);
+ SPUtils.setParam(context, SPUtils.KEY_DEVICE_ID, mDeviceID);
+ return true;
+ } else {
+ throw new SecurityException("====saveSubnetAndDeviceID ID鑼冨洿0-254=======");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * 鍗曡澶囧彂閫佸懡浠�
+ * 鐩墠鎺у埗鍙戦�佹鏁颁负3娆�
+ * 鍙戜竴鏉�,琛ュ彂3鏉★紝闂撮殧500ms
+ *
+ * @param info
+ * @param addBytes
+ * @param type
+ */
+ private static void addSendData(final AppliancesInfo info, byte[] addBytes, final int type) {
+
+ final Crc sendDatas = new Crc(info.getStateCommand(), info.getDeviceSubnetID(), info.getDeviceDeviceID(), addBytes);
+ sendDatas.count = 0;
+
+ final Timer sendCycleTimer = new Timer();
+ sendCycleTimer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ //2019-07 鎺у埗鍙戦�佹鏁�
+ if (sendDatas.count >= 4) {
+ sendCycleTimer.cancel();
+ } else {
+ sendDatas.count++;
+ if (type == Configuration.STATE) {
+ sendDatas.command = info.getStateCommand();
+ sendDatas.isCtrlSuccess = HDLDeviceManager.isGetDeviceStateSuccess;
+ } else if (type == Configuration.CONTROL) {
+ sendDatas.command = info.getCtrlCommand();
+ HDLLog.I("getDeviceKey锛� " + info.getDeviceKey());//2019-8-2
+ sendDatas.isCtrlSuccess = HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info);
+
+// switch (info.getBigType()) {
+// case Configuration.LIGTH_BIG_TYPE:
+// sendDatas.isCtrlSuccess = HDLDeviceManager.isLightCtrlSuccess;
+// break;
+// case Configuration.CURTAIN_BIG_TYPE:
+// sendDatas.isCtrlSuccess = HDLDeviceManager.isCurtainCtrlSuccess;
+// break;
+// case Configuration.AIR_BIG_TYPE:
+// sendDatas.isCtrlSuccess = HDLDeviceManager.isACCtrlSuccess;
+// break;
+// case Configuration.LOGIC_BIG_TYPE:
+// sendDatas.isCtrlSuccess = HDLDeviceManager.isSceneCtrlSuccess;
+// break;
+// case Configuration.SECURITY_BIG_TYPE:
+// sendDatas.isCtrlSuccess = HDLDeviceManager.isSecurityCtrlSuccess;
+// break;
+// default:
+// sendDatas.isCtrlSuccess = false;
+// }
+ }
+ if (!sendDatas.isCtrlSuccess) {
+ HDLLog.I("鎺у埗鍙戦�佺" + sendDatas.count + "娆�");
+ cusSendCommand(sendDatas.command, info.getDeviceSubnetID(), info.getDeviceDeviceID(), sendDatas.addBytes);
+ } else {
+ sendCycleTimer.cancel();
+ }
+ }
+
+ }
+ }, 1, 500);
+
+
+ }
+
+
+ /**
+ * 鍙戦�佸箍鎾垨鐐瑰鐐瑰懡浠�
+ *
+ * @param command 鎿嶄綔鐮�
+ * @param subnetID 瀛愮綉鍙�
+ * @param deviceID 璁惧鍙�
+ * @param addBytes 闄勫姞鏁版嵁
+ */
+ public static void cusSendCommand(int command, int subnetID, int deviceID, byte[] addBytes) {
+ Crc sendDatas = new Crc(command, subnetID, deviceID, addBytes);
+ HDLSerialPortCore.sendData(sendDatas);
+
+ }
+
+ /**
+ * 鍙戦�佺粍鎾懡浠�
+ * 杩欎釜鏂规硶鐩墠浠呯敤鍦ㄦ嬁鍒癛cu ip鍦板潃
+ *
+ * @param command 鎿嶄綔鐮�
+ * @param subnetID 瀛愮綉鍙�
+ * @param deviceID 璁惧鍙�
+ * @param addBytes 闄勫姞鏁版嵁
+ */
+ public static void cusSendMulticastCommand(int command, int subnetID, int deviceID, byte[] addBytes) {
+ Crc sendDatas = new Crc(command, subnetID, deviceID, addBytes);
+ HDLSerialPortCore.sendMulticastData(sendDatas);
+ }
+
+//
+// /**
+// * 璁剧疆鏄惁寮�鍚�忎紶
+// * 閫忎紶鏁版嵁锛屼笉璧癰us鍗忚锛岀洿鎺ヨ浆鍙戯紝涓嶅仛鏁版嵁鏍煎紡澶勭悊
+// * @param bOpen
+// */
+// public static void setHDLPassThroughOpen(boolean bOpen){
+// if(HDLSerialPortCore.bPassThrough != bOpen){
+// HDLSerialPortCore.bPassThrough = bOpen;
+// }
+// }
+//
+//
+// //**************************MCU涓插彛鍗忚鎸囦护**************************
+// /**
+// * 鍙戦�佹暟鎹�
+// */
+// private static void HDLSendMCUData(final MCUCrc mcuDataList, boolean bPassThrough){
+// if(HDLSerialPortCore.bPassThrough != bPassThrough){
+// HDLSerialPortCore.bPassThrough = bPassThrough;
+// }
+// if(bPassThrough){
+// HDLSerialPortCore.sendMCUData(mcuDataList);
+// }else {
+// HDLDeviceManager.isMCUCtrlSuccess = false;
+// if (mcuCtrlFailTimer != null) {
+// mcuCtrlFailTimer.cancel();
+// mcuCtrlFailTimer = null;
+// }
+// HDLSerialPortCore.sendMCUData(mcuDataList);
+//
+// mcuCtrlFailTimer = new Timer();
+// mcuCtrlFailTimer.schedule(new TimerTask() {
+// @Override
+// public void run() {
+// if (!HDLDeviceManager.isMCUCtrlSuccess) {
+//// MCUDataBean mMCUDataBean = new MCUDataBean();
+//// mMCUDataBean.command = mcuDataList.mcuCommand;
+// EventBus.getDefault().post(new MCUFeedBackEvent(new MCUDataBean(), EventCode.FAILURE_TIMEOUT, "MCU璇锋眰瓒呮椂锛岃绋嶅悗鍐嶈瘯"));
+// }
+// }
+// }, mRequestTimeout);
+// }
+//
+// }
+//
+// /**
+// * 2019-8-9
+// * 閫忎紶鏁版嵁
+// * 閫忎紶鏁版嵁锛屼笉璧癰us鍗忚锛岀洿鎺ヨ浆鍙戯紝涓嶅仛鏁版嵁鏍煎紡澶勭悊
+// */
+// public static void mcuSendTransparentData(byte[] sendData) {
+// MCUCrc sendDatas = new MCUCrc(MCUConstants.MCU_COMMAND_SEND, sendData);
+// HDLSendMCUData(sendDatas, true);
+// }
+//
+//
+// /**
+// * 妫�娴嬩涪鍖呯姸鎬�
+// */
+// public static void mcuGetDetectPacketLossStatus() {
+// MCUCrc sendDatas = new MCUCrc(MCUConstants.MCU_DETECT_PACKET_LOSS_STATUS, new byte[0]);
+// HDLSendMCUData(sendDatas, false);
+// }
+//
+// /**
+// * 璇婚厤缃俊鎭�
+// */
+// public static void mcuReadConfiguration() {
+// MCUCrc sendDatas = new MCUCrc(MCUConstants.MCU_READ_CONFIGURATION, new byte[0]);
+// HDLSendMCUData(sendDatas, false);
+// }
+//
+// /**
+// * 鍐欓厤缃俊鎭�
+// */
+// public static void mcuWriteConfiguration(byte[] sendData) {
+// MCUCrc sendDatas = new MCUCrc(MCUConstants.MCU_WRITE_CONFIGURATION, sendData);
+// HDLSendMCUData(sendDatas, false);
+// }
+//
+// /**
+// * 璇锋眰鍗囩骇
+// * sendData 鏂囦欢澶у皬[4byte]
+// */
+// public static void mcuRequestUpgrade(byte[] sendData) {
+// MCUCrc sendDatas = new MCUCrc(MCUConstants.MCU_REQUEST_UPGRADE, sendData);
+// HDLSendMCUData(sendDatas, false);
+// }
+//
+// /**
+// * 璇锋眰鍗囩骇
+// * sendData 鍗囩骇鏂囦欢
+// */
+// public static void mcuRequestUpgradeWithFile(byte[] upgradeFileDatas) {
+// try {
+// HDLSerialPortCore.upgradeFileDatas = upgradeFileDatas;
+// mcuRequestUpgrade(HDLUtlis.intToByteArray(upgradeFileDatas.length));
+// } catch (Exception e) {
+// e.printStackTrace();
+// HDLSerialPortCore.upgradeFileDatas = null;//閲婃斁
+// HDLLog.E("mcuRequestUpgradeWithFile 鍑洪敊");
+// }
+// }
+//
+//
+// /**
+// * 鍙戦�佸崌绾ф暟鎹�
+// * sendData 鏂囦欢鍦板潃[4byte] 鏁版嵁闀垮害[2byte]
+// * 鍥哄畾锛�1024锛屽惁鍒欎笉澶勭悊
+// */
+// public static void mcuSendUpgradeData(byte[] sendData) {
+// MCUCrc sendDatas = new MCUCrc(MCUConstants.MCU_SEND_UPGRADE_DATA, sendData);
+//// HDLSendMCUData(sendDatas, false);
+// HDLSerialPortCore.sendMCUData(sendDatas);
+// }
+//
+// /**
+// * 閲嶅惎MCU
+// * 鏃堕棿锛�1byte锛夛細鑼冨洿1-10s
+// * 褰撲负0xF8鐨勬椂鍊欙紝浠h〃閲嶅惎鎴愬姛
+// */
+// public static void mcuSendRestart() {
+// MCUCrc sendDatas = new MCUCrc(MCUConstants.MCU_RESTART, new byte[0]);
+// HDLSendMCUData(sendDatas, false);
+// }
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLDeviceManager.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLDeviceManager.java
new file mode 100644
index 0000000..b2ab1a2
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLDeviceManager.java
@@ -0,0 +1,3156 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Core;
+
+import android.content.Context;
+import android.content.Intent;
+import android.text.TextUtils;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonSyntaxException;
+import com.google.gson.reflect.TypeToken;
+import com.hdl.sdk.ttl.Config.MCUConstants;
+import com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition.AirHVACBackInfo;
+import com.hdl.sdk.ttl.HDLAppliances.HDLCommonSwitch.CommonSwitchBackInfo;
+import com.hdl.sdk.ttl.HDLAppliances.HDLSecurity.SecurityBackInfo;
+import com.hdl.sdk.ttl.HDLAppliances.HDLSensor.DryContactSensorBackEvent;
+import com.hdl.sdk.ttl.HDLAppliances.HDLSensor.SensorStateBackInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.MCUConfigurationBean;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.MCUDataBean;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.AirHVACFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.CommonSwitchCtrlBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.CommonSwitchStateBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DiscoverNewDevicesEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.EventCode;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.MCUFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.SecurityAlarmFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.SecurityArmingFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.UpdateRemarkFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.Parser.DeviceParser;
+import com.hdl.sdk.ttl.Config.Configuration;
+import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig;
+import com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition.AirCtrlBackInfo;
+import com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser;
+import com.hdl.sdk.ttl.HDLAppliances.HDLAudio.HDLAudio;
+import com.hdl.sdk.ttl.HDLAppliances.HDLCurtain.CurtainCtrlBackInfo;
+import com.hdl.sdk.ttl.HDLAppliances.HDLCurtain.Parser.CurtainCtrlParser;
+import com.hdl.sdk.ttl.HDLAppliances.HDLLight.LightCtrlBackInfo;
+import com.hdl.sdk.ttl.HDLAppliances.HDLLogic.LogicCtrlBackInfo;
+import com.hdl.sdk.ttl.HDLAppliances.HDLLogic.LogicMode;
+import com.hdl.sdk.ttl.HDLAppliances.HDLWarning.WarningType;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.DevicesData;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.ListRemarks;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.RcuCurtain;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.RcuLight;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.UdpDataBean;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.AirFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.CurtainFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DeviceStateEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.LightFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.WarningInfoEvent;
+import com.hdl.sdk.ttl.Utils.HDLUtlis.HDLStringUtils;
+import com.hdl.sdk.ttl.Utils.HDLUtlis.HDLUtlis;
+import com.hdl.sdk.ttl.Utils.LogUtils.HDLLog;
+import com.hdl.sdk.ttl.Utils.SPUtils.SPUtils;
+//import com.hdl.sdk.ttl.Utils.TransformUtils.DataConverseUtils;
+
+import org.greenrobot.eventbus.EventBus;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.ConcurrentHashMap;
+
+//import static com.hdl.sdk.ttl.Utils.TransformUtils.HDLStringUtils.byte2String;
+
+//import static com.hdl.sdk.ttl.Utils.TransformUtils.HDLStringUtils.byte2String;
+
+
+/**
+ * Created by djl on 2017/3/27.
+ * 璁惧绠$悊绫�
+ * 姝ょ被浜嬭澶囨墍鏈変俊鎭殑绠$悊绫伙紝浣滀负涓�涓腑鎺э紝
+ * 鍖呮嫭鎼滅储锛岃鍙栵紝鎺у埗绛夋墍鏈夋搷浣滅殑绠$悊
+ */
+
+public class HDLDeviceManager {
+ public static List<String> rcuIpList = new ArrayList<>();//缁熻Rcu ip鍦板潃鍒楄〃
+ public static List<DevicesData> devicesDataList = new ArrayList<>();//缁熻鎼滅储鍒楄〃
+ public static List<DevicesData> realDevicesDataList = new ArrayList<>();//缁熻鎼滅储鍒楄〃
+ private static Context viewContext;
+ public static List<ListRemarks> listRemarks = new ArrayList<>();
+ public static List<RcuLight> rcuLightList = new ArrayList<>();
+ public static List<RcuCurtain> rcuCurtainList = new ArrayList<>();
+ public static boolean isLogicCtrl = false;
+ public static ConcurrentHashMap<String, Boolean> ctrlSuccessStateHashMap = new ConcurrentHashMap<>();//2019-8-2
+
+
+// public static byte[] air1Info = null;
+// public static byte[] air2Info = null;
+// public static byte[] air3Info = null;
+// public static byte[] air4Info = null;
+
+ public static boolean isGetDeviceStateSuccess = false; //鍒ゆ柇鑾峰彇璁惧鐘舵�佹槸鍚︽帶鍒舵垚鍔�
+ public static boolean isUpdateRemarkSuccess = false; //鍒ゆ柇淇敼璁惧鍚嶆槸鍚︽垚鍔�
+ public static boolean isMCUCtrlSuccess = false; //鍒ゆ柇鏄惁涓嶮CU閫氫俊鎴愬姛
+
+// public static boolean isGetRcuIpSuccess = false;
+// public static boolean isLightCtrlSuccess = false; //鍒ゆ柇鐏厜鏄惁鎺у埗鎴愬姛
+// public static boolean isCurtainCtrlSuccess = false; //鍒ゆ柇绐楀笜鏄惁鎺у埗鎴愬姛
+// public static boolean isACCtrlSuccess = false; //鍒ゆ柇绌鸿皟鏄惁鎺у埗鎴愬姛
+// public static boolean isSceneCtrlSuccess = false; //鍒ゆ柇鍦烘櫙鏄惁鎺у埗鎴愬姛
+// public static boolean isSecurityCtrlSuccess = false; //鍒ゆ柇瀹夐槻妯″潡鏄惁閫氫俊鎴愬姛
+
+
+ /**
+ * 鍒濆鍖� SDK HDLDeviceManager鍒濆鍖�
+ *
+ * @param context 涓婁笅鏂�
+ */
+ public static void init(Context context) {
+ viewContext = context.getApplicationContext();
+ Crc.localSubnetID = (int) SPUtils.getParam(viewContext, SPUtils.KEY_SUB_ID, SPUtils.DEFAULT_SUB_ID);
+ Crc.localDeviceID = (int) SPUtils.getParam(viewContext, SPUtils.KEY_DEVICE_ID, SPUtils.DEFAULT_DEVICE_ID);
+ /*** 瀛愮綉鍙疯澶囧彿 Error correction*/
+ if (!HDLCommand.getIfValueInScope(Crc.localSubnetID)) {
+ Crc.localSubnetID = SPUtils.DEFAULT_SUB_ID;
+ SPUtils.setParam(viewContext, SPUtils.KEY_SUB_ID, SPUtils.DEFAULT_SUB_ID);
+ }
+ if (!HDLCommand.getIfValueInScope(Crc.localDeviceID)) {
+ Crc.localSubnetID = SPUtils.DEFAULT_DEVICE_ID;
+ SPUtils.setParam(viewContext, SPUtils.KEY_DEVICE_ID, SPUtils.DEFAULT_DEVICE_ID);
+ }
+ }
+
+ /**
+ * 閲婃斁鍏抽棴涓插彛
+ */
+ public static void release() {
+ HDLSerialPortCore.closeSerialPort();
+ }
+
+ /**
+ * 澶勭悊CommandData骞惰繑鍥炴悳绱㈡垨鎺у埗鐨勬湁鐢ㄤ俊鎭�
+ *
+ * @param getDatas
+ * @param commandType 鍛戒护绫诲瀷
+ */
+ public static void handle(UdpDataBean getDatas, int commandType) {
+ switch (commandType) {
+ case Configuration.DEVICES_SEARCH_BACK_COMMAND:
+ if (HandleSearch.isGetRcuIp) {
+// handleRcuIp(getDatas);
+ } else {
+ boolean isExit = false;
+ for (DevicesData value : realDevicesDataList) {
+ if (value.getSourceDeviceID() == getDatas.sourceDeviceID
+ && value.getSourceSubnetID() == getDatas.sourceSubnetID) {
+ HDLLog.I("Device is Exit " + value.getRemark());
+ isExit = true;
+ break;
+ }
+ }
+ if (!isExit) {
+ handleSearchData(getDatas);
+ }
+ }
+ break;
+ /***2020-04-01 鏂板閫氱敤寮�鍏�**/
+ case Configuration.COMMON_SWITCH_CTRL_BACK_COMMAND:
+ handleCommonSwitchCtrlData(getDatas);
+ break;
+ case Configuration.COMMON_SWITCH_STATE_BACK_COMMAND:
+ handleCommonSwitchStateData(getDatas);
+ break;
+// 鎺у埗璁惧
+ case Configuration.LIGHT_CTRL_BACK_COMMAND:
+ case Configuration.CURTAIN_CTRL_BACK_COMMAND:
+ case Configuration.AIR_CTRL_BACK_COMMAND:
+ case Configuration.LOGIC_CTRL_BACK_COMMAND:
+ handleCtrlData(getDatas);
+ break;
+ case Configuration.AIR_HVAC_CTRL_BACK_COMMAND:
+ handleHVACCtrlData(getDatas);
+ break;
+ case Configuration.SECURITY_ARMING_CTRL_BACK_COMMAND://20190729鏂板
+ case Configuration.SECURITY_ALARM_CTRL_BACK_COMMAND://鎶ヨ璁剧疆鍙嶉
+ handleSecurityCtrlData(getDatas);
+ break;
+// 鑾峰彇璁惧澶囨敞
+ case Configuration.DEVICES_READ_BACK_COMMAND:
+ if (isLogicCtrl) {
+ isLogicCtrl = false;
+ handleLogicAir(getDatas);
+ } else {
+ handleRemarkCurStateData(getDatas);
+ }
+ break;
+// 鑾峰彇璁惧鐘舵��
+ case Configuration.AIR_STATE_BACK_COMMAND:
+ handleAirStateData(getDatas);
+ break;
+ case Configuration.SENSOR_STATE_BACK_COMMAND:
+ handleSensorBroadcastStateData(getDatas);
+ break;
+ case Configuration.SENSOR_BROADCAST_STATE_BACK_COMMAND:
+ handleSensorBroadcastStateData(getDatas);
+ break;
+ case Configuration.DRY_CONTACT_STATE_BACK_COMMAND:
+ case Configuration.DRY_CONTACT_BROADCAST_STATE_COMMAND:
+ handleDryContactBroadcastStateData(getDatas);
+ break;
+
+ case Configuration.LIGHT_STATE_BACK_COMMAND:
+ handleLightStateData(getDatas);
+ case Configuration.CURTAIN_STATE_BACK_COMMAND:
+ handleCurtainStateData(getDatas);
+ case Configuration.CURTAIN_STATE_BROADCAST_BACK_COMMAND:
+ handleCurtainBroadcastStateData(getDatas);
+ break;
+ case Configuration.SECURITY_STATE_BACK_COMMAND:
+ handleSecurityStateData(getDatas);
+ break;
+ case Configuration.AIR_HVAC_STATE_BACK_COMMAND:
+// handleRcuAirCastData(getDatas);
+ handleHVACStateData(getDatas);//2019-06-27
+ break;
+ case Configuration.LOGIC_STATE_BACK_COMMAND:
+// handleRcuAirCastData(getDatas);
+ handleLOGICStateData(getDatas);//2019-06-27
+ break;
+
+// case Configuration.RCU_ROOM_CAST_COMMAND:
+// handleRcuLightCastData(getDatas);
+// break;
+// case Configuration.RCU_CURTAIN_CAST_COMMAND:
+// handleRcuCurtainCastData(getDatas);
+// break;
+ case Configuration.WARNING_COMMAND:
+ handleWarningData(getDatas);
+ break;
+ case Configuration.AUDIO_CTRL_READ_BACK_COMMAND:
+ case Configuration.AUDIO_MenuPlay_INSTRUCTION_BACK_COMMAND:
+ handleAudioData(getDatas);
+ break;
+// case Configuration.RCU_SEARCH_COMMAND:
+// handleRcuSearchData(getDatas);
+// break;
+// case Configuration.RCU_READ_SDK_INFO_COMMAND:
+// handleRcuReadInfo(getDatas);
+// break;
+ case Configuration.MANUAL_ADD_DEVICE_COMMAND:
+ boolean isExit = false;
+ for (DevicesData value : realDevicesDataList) {
+ if (value.getSourceDeviceID() == getDatas.sourceDeviceID
+ && value.getSourceSubnetID() == getDatas.sourceSubnetID) {
+ isExit = true;
+ break;
+ }
+ }
+ if (!isExit) {
+ handleSearchData(getDatas);
+ HandleSearch.OnDeviceListGetSuccessCallBack();//鎵嬪姩娣诲姞璁惧鎴愬姛绔嬪埢杩斿洖
+ HDLCommand.cusSendCommand(Configuration.MANUAL_ADD_DEVICE_BACK_COMMAND,
+ Crc.localSubnetID,
+ Crc.localDeviceID,
+ new byte[]{1});
+ } else {
+ //娣诲姞澶辫触锛屽凡缁忓瓨鍦ㄤ簡鐩稿悓鐨勫瓙缃慽d銆佽澶噄d
+ HDLCommand.cusSendCommand(Configuration.MANUAL_ADD_DEVICE_BACK_COMMAND,
+ Crc.localSubnetID,
+ Crc.localDeviceID,
+ new byte[]{0});
+ }
+ break;
+ case Configuration.MANUAL_ADD_REMARK_COMMAND:
+ handleRemarkCurStateData(getDatas);
+ HandleSearch.OnDeviceListGetSuccessCallBack();//鎵嬪姩娣诲姞澶囨敞鎴愬姛绔嬪埢杩斿洖
+ HDLCommand.cusSendCommand(Configuration.MANUAL_ADD_REMARK_BACK_COMMAND,
+ Crc.localSubnetID,
+ Crc.localDeviceID,
+ new byte[]{1});
+ break;
+ case Configuration.DEVICES_MODIFY_BACK_COMMAND:
+ HDLLog.I("GET DEVICES_MODIFY_BACK_COMMAND");
+ break;
+ case Configuration.MODULE_UPDATE_REMARK_BACK_COMMAND:
+// HDLLog.I("GET MODULE_UPDATE_REMARK_BACK_COMMAND");
+ handleModuleUpdateRemarkData(getDatas);//淇敼妯″潡澶囨敞
+ break;
+
+// 鎺у埗鍜屽皵娉拌澶�
+// case Configuration.HET_DEVICES:
+// Log.d("djlHet", "Configuration.HET_DEVICES send");
+// EventBus.getDefault().post(new HetDevicesCtrlEvent(getDatas.addBytes));
+// break;
+// 鎺у埗缇庣殑璁惧
+// case Configuration.Midea_DEVICES:
+// Log.d("djlMidea", "Configuration.Midea_DEVICES send");
+// EventBus.getDefault().post(new MideaDevicesCtrlEvent(getDatas.addBytes));
+// break;
+// 鎺у埗Jav璁惧
+// case Configuration.JAV_DEVICES:
+// Log.d("djlJav", "Configuration.Jav_DEVICES send");
+// Intent javIntent = new Intent();
+// javIntent.setAction("com.hdl.jav.hdljavlib.action");
+// javIntent.putExtra("HdlJav", getDatas.addBytes);
+// viewContext.sendBroadcast(javIntent);
+// break;
+// case Configuration.GET_LOGIC_INFO:
+// 澶勭悊閫昏緫妯″潡淇℃伅
+// handleLogicData(getDatas);
+// break;
+
+ default:
+ break;
+ }
+ }
+
+ /**
+ * 澶勭悊鎼滅储璁惧鏁版嵁
+ * 鍙戠幇鏂拌澶囧鐞�
+ *
+ * @param getDatas
+ */
+ private static void handleSearchData(UdpDataBean getDatas) {
+
+ DevicesData devicesData = new DevicesData();
+ devicesData.setSourceSubnetID(getDatas.sourceSubnetID);
+ devicesData.setSourceDeviceID(getDatas.sourceDeviceID);
+ devicesData.setAddByte(getDatas.addBytes);
+ byte[] remarkByte;
+ if (getDatas.addBytes.length >= 22) {
+ remarkByte = new byte[20];
+ System.arraycopy(getDatas.addBytes, 2, remarkByte, 0, remarkByte.length);
+ } else {
+ remarkByte = new byte[getDatas.addBytes.length - 2];
+ System.arraycopy(getDatas.addBytes, 2, remarkByte, 0, getDatas.addBytes.length - 2);
+ }
+
+ String remarkStr = HDLStringUtils.byte2String(remarkByte);
+ HDLLog.I("remarkStr锛�" + remarkStr);
+ devicesData.setRemark(remarkStr);
+ boolean isExitData = DeviceParser.parse(getDatas.addBytes, devicesData, remarkStr);
+
+ realDevicesDataList.add(devicesData);//璁板綍鎵�鏈夌殑鎺ユ敹鍒拌澶囷紝鍖呮嫭SDK涓嶆敮鎸佺殑璁惧绉嶇被銆備綔鐢細浣滀负鍙戦�佺浜屾鎼滅储鍛戒护鏃剁敤鍒�
+
+ /********************杈呭姪璋冭瘯鎵撳嵃*******************/
+ String addData = "";
+ for (int i = 22, len = getDatas.addBytes.length; i < len; i++) {
+ addData += " arr" + i + " = " + (getDatas.addBytes[i] & 0xFF) + ",";
+ }
+ HDLLog.I("鎵�鏈夎澶囧垪琛� 绗� " + realDevicesDataList.size() + " 涓ā鍧� "
+ + " \n婧愬瓙缃戝彿 = " + (getDatas.sourceSubnetID)
+ + " \n婧愯澶囧彿 = " + (getDatas.sourceDeviceID)
+ + " \n妯″潡澶囨敞 = " + devicesData.getRemark()
+ + " \n闄勫姞鏁版嵁 = " + addData
+ + " \nisExitData = " + (isExitData ? "绗﹀悎" : "涓嶇鍚�")
+ );
+ /********************杈呭姪璋冭瘯鎵撳嵃*******************/
+
+
+// 鍒ゆ柇鏄惁绗﹀悎瑕佹眰鐨勫ぇ绫诲皬绫�
+ if (isExitData) {
+ devicesDataList.add(devicesData);//璁板綍鎵�鏈夌殑鎺ユ敹鍒拌澶囷紝涓嶅寘鎷琒DK涓嶆敮鎸佺殑璁惧绉嶇被
+ /**2019-07-03 鍙戠幇鏂拌澶囷紝杩欓噷鍙互鍙戦�侀�氱煡浜嬩欢锛屽苟浼犻�掓柊鐨勮澶囨暟鎹�*/
+ EventBus.getDefault().post(new DiscoverNewDevicesEvent(devicesData));
+
+// 杩囨护鎺夎儗鏅煶涔愶紝鑳屾櫙闊充箰娌℃湁澶囨敞杩斿洖
+ if (devicesDataList.get(devicesDataList.size() - 1).getAppliancesInfoList().get(0).getBigType() != Configuration.AUDIO_BIG_TYPE) {
+ for (int i = 0, len = devicesDataList.get(devicesDataList.size() - 1).getAppliancesInfoList().size(); i < len; i++) {
+ ListRemarks listRemarksTemp = new ListRemarks();
+ listRemarksTemp.setCallBack(false);
+ listRemarksTemp.setAppliancesInfo(devicesDataList.get(devicesDataList.size() - 1).getAppliancesInfoList().get(i));
+ listRemarks.add(listRemarksTemp);
+ }
+ }
+
+// HDLCommand.HDLgetDevRemarks(devicesDataList.get(devicesDataList.size()-1).getAppliancesInfoList());
+
+ /********************杈呭姪璋冭瘯鎵撳嵃*******************/
+ String deviceName = "";
+ for (int i = 0, len = devicesData.getAppliancesInfoList().size(); i < len; i++) {
+ deviceName += " " + devicesData.getAppliancesInfoList().get(i).getDeviceName() + " ";
+ }
+
+ HDLLog.I("\n --------> HDL SDK鏀寔鐨勮澶囧垪琛� 绗� " + devicesDataList.size() + " 涓ā鍧� "
+ + " \n婧愬瓙缃戝彿 = " + (getDatas.sourceSubnetID)
+ + " \n婧愯澶囧彿 = " + (getDatas.sourceDeviceID)
+ + " \n鐩爣瀛愮綉鍙� = " + (getDatas.desSubnetID)
+ + " \n鐩爣璁惧鍙� = " + (getDatas.desDeviceID)
+ + " \n婧愭ā鍧楀悇鍥炶矾绫诲瀷 = " + deviceName
+ + " \n妯″潡澶囨敞 = " + devicesData.getRemark()
+ );
+ /********************杈呭姪璋冭瘯鎵撳嵃*******************/
+ }
+ }
+
+ /**
+ * 澶勭悊鐏厜杩斿洖
+ * 2020-1-18
+ * 淇娣峰悎璋冨厜娣峰悎寮�鍏� 绫绘ā鍧楅棶棰�
+ *
+ * @param getDatas
+ */
+ private static void handleLightCtrlData(UdpDataBean getDatas) {
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (infos.get(j).getLittleType() == 9 || infos.get(j).getLittleType() == 10) {
+
+ if (infos.get(j).getPhysicsChannelNum() == (getDatas.addBytes[0] & 0xFF)) {
+
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[2] & 0xFF);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[2] & 0xFF);
+ AppliancesInfo lightInfo1 = infos.get(j);
+ lightInfo1.setCurState(getDatas.addBytes[2] & 0xFF);
+ LightCtrlBackInfo info1 = new LightCtrlBackInfo();
+ info1.setParentRemarks(lightInfo1.getParentRemarks());
+ info1.setAppliancesInfo(lightInfo1);
+ info1.setRemarks(lightInfo1.getRemarks());
+ info1.setChannelNum(lightInfo1.getChannelNum());
+ info1.setPhysicsChannelNum(lightInfo1.getPhysicsChannelNum());
+ info1.setBrightness(getDatas.addBytes[2] & 0xFF);
+ setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
+ EventBus.getDefault().post(new LightFeedBackEvent(info1, true));
+ break outter;
+ }
+
+
+ } else {
+ if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {
+ AppliancesInfo lightInfo = infos.get(j);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[2] & 0xFF);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[2] & 0xFF);
+ LightCtrlBackInfo info = new LightCtrlBackInfo();
+ info.setParentRemarks(lightInfo.getParentRemarks());
+ info.setAppliancesInfo(lightInfo);
+ info.setRemarks(lightInfo.getRemarks());
+ info.setChannelNum(getDatas.addBytes[0] & 0xFF);
+// info.setIsSuccess(getDatas.AddBytes[1] & 0xFF);
+ info.setBrightness(getDatas.addBytes[2] & 0xFF);
+// info.setChannelCount(getDatas.AddBytes[3] & 0xFF);
+// info.setDeviceChannelCount(getDatas.AddBytes[4] & 0xFF);
+// isLightCtrlSuccess = true;
+ setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
+ EventBus.getDefault().post(new LightFeedBackEvent(info, true));
+ break outter;
+ }
+ }
+
+ }
+ }
+ }
+
+
+ }
+
+
+ /**
+ * 澶勭悊璁惧鎺у埗鏁版嵁
+ *
+ * @param getDatas
+ */
+ private static void handleCtrlData(UdpDataBean getDatas) {
+ switch (getDatas.command) {
+ case Configuration.LIGHT_CTRL_BACK_COMMAND:
+ handleLightCtrlData(getDatas);
+
+ break;
+ case Configuration.CURTAIN_CTRL_BACK_COMMAND:
+// if (TextUtils.isEmpty(HandleSearch.rcuIp)){
+//
+// }else{
+// AppliancesInfo curtainInfo = new AppliancesInfo();
+// for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+// if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+// && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+// ) {
+// List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+// for (int j = 0, len2 = infos.size(); j < len2; j++) {
+// if (infos.get(j).getBigType() == Configuration.CURTAIN_BIG_TYPE
+// && infos.get(j).getChannelNum() == (getDatas.addBytes[1] & 0xFF)) {
+// for (int k = 0; k < rcuCurtainList.size(); k++) {
+// if (devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum() == rcuCurtainList.get(k).getChanelNum()
+// && devicesDataList.get(i).getAppliancesInfoList().get(j).getLittleType() == rcuCurtainList.get(k).getLittleType()
+// ) {
+// int state;
+// switch (getDatas.addBytes[2] & 0xFF) {
+// case 0:
+// state = CurtainCtrlParser.curtainPause;
+// break;
+// case 1:
+// state = CurtainCtrlParser.curtainOn;
+// break;
+// case 2:
+// state = CurtainCtrlParser.curtainOff;
+// break;
+// default:
+// state = 0;
+// break;
+// }
+// rcuCurtainList.get(k).setCurState(state);
+// devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[2] & 0xFF);
+//// HDLLog.I("鎺у埗 rcuCurtainList鍥炶矾鍙凤細"+rcuCurtainList.get(k).getChanelNum()
+//// + " state = "+rcuCurtainList.get(k).getCurState()
+//// );
+// }
+// }
+//
+// curtainInfo = infos.get(j);
+// }
+//
+// }
+// }
+// }
+// CurtainCtrlBackInfo curtainCtrlBackInfo = new CurtainCtrlBackInfo();
+// curtainCtrlBackInfo.setRemarks(curtainInfo.getRemarks());
+// curtainCtrlBackInfo.setParentRemarks(curtainInfo.getParentRemarks());
+// curtainCtrlBackInfo.setAppliancesInfo(curtainInfo);
+// curtainCtrlBackInfo.setNum(getDatas.addBytes[1] & 0xFF);
+// curtainCtrlBackInfo.setState(getDatas.addBytes[2] & 0xFF);
+// isCurtainCtrlSuccess = true;
+// EventBus.getDefault().post(new CurtainFeedBackEvent(curtainCtrlBackInfo, true));
+// }
+
+
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ inner:
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ AppliancesInfo curtainInfo;
+ if ((getDatas.addBytes[0] & 0xFF) >= 17) {
+ if (((getDatas.addBytes[0] & 0xFF) - 16) == infos.get(j).getChannelNum()) {
+ curtainInfo = infos.get(j);
+ } else {
+ continue inner;
+ }
+ } else {
+ if ((getDatas.addBytes[0] & 0xFF) == infos.get(j).getChannelNum()) {
+ curtainInfo = infos.get(j);
+ } else {
+ continue inner;
+ }
+ }
+
+ CurtainCtrlBackInfo curtainCtrlBackInfo = new CurtainCtrlBackInfo();
+ curtainCtrlBackInfo.setRemarks(curtainInfo.getRemarks());
+ curtainCtrlBackInfo.setParentRemarks(curtainInfo.getParentRemarks());
+ curtainCtrlBackInfo.setAppliancesInfo(curtainInfo);
+// isCurtainCtrlSuccess = true;
+ setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
+ if (curtainInfo.getDeviceType() == HDLApConfig.TYPE_CURTAIN_GLYSTRO
+ || curtainInfo.getDeviceType() == HDLApConfig.TYPE_CURTAIN_ROLLER) {
+ if ((getDatas.addBytes[0] & 0xFF) >= 17) {
+ int curState = getDatas.addBytes[1] & 0xFF;
+ if (curState == 1) {
+ //杩欎釜鍒ゆ柇寰堝偦锛岀獥甯樺叧鍒扮櫨鍒嗘瘮涓�0锛屼細璺冲埌1杩斿洖鍥炴潵锛屽彧鑳藉己鍒舵敼涓�0
+ curState = 0;
+ }
+ if (curState == 99) {
+ curState = 100;
+ }
+ curtainCtrlBackInfo.setState(curState);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(curState);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(curState);
+ curtainCtrlBackInfo.setNum((getDatas.addBytes[0] & 0xFF) - 16);
+ EventBus.getDefault().post(new CurtainFeedBackEvent(curtainCtrlBackInfo, true));
+ }
+ }
+ if (curtainInfo.getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) {
+ if ((getDatas.addBytes[0] & 0xFF) < 17) {
+ int state = getDatas.addBytes[1] & 0xFF;
+ switch (getDatas.addBytes[1] & 0xFF) {//杩欓噷涔熷簲璇ユ敼鎴�0锛�1锛�2
+ case 0:
+ state = CurtainCtrlParser.curtainPause;
+ break;
+ case 1:
+ state = CurtainCtrlParser.curtainOn;
+ break;
+ case 2:
+ state = CurtainCtrlParser.curtainOff;
+ break;
+ default:
+ state = 0;
+ break;
+ }
+ curtainCtrlBackInfo.setState(state);
+ curtainCtrlBackInfo.setNum(getDatas.addBytes[0] & 0xFF);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(state);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(state);
+ EventBus.getDefault().post(new CurtainFeedBackEvent(curtainCtrlBackInfo, true));
+ }
+ }
+
+
+ break outter;
+
+
+ }
+ }
+ }
+
+ break;
+ case Configuration.AIR_CTRL_BACK_COMMAND:
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (infos.get(j).getDeviceType() == HDLApConfig.TYPE_AC_PANEL) {
+// airInfo = infos.get(j);//涓�鑸彧鏈変竴涓潰鏉�
+ // 濡傛灉鏈夊涓┖璋冮潰鏉匡紝杩欏皢浼氬嚭閿�
+ AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo();
+ airCtrlBackInfo.setAppliancesInfo(infos.get(j));
+// isACCtrlSuccess = true;
+ setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
+ if ((getDatas.addBytes[0] & 0xFF) == AirCtrlParser.airMode) {
+ airCtrlBackInfo.setCurState(new byte[]{getDatas.addBytes[0], getDatas.addBytes[1]});
+ byte[] airCurState = devicesDataList.get(i).getAppliancesInfoList().get(j).getArrCurState();
+ switch (getDatas.addBytes[0] & 0xff) {
+ case 3:
+ //寮�鍏�
+ airCurState[0] = getDatas.addBytes[1];
+ break;
+ case 4:
+ //鍒跺喎娓╁害
+ airCurState[2] = getDatas.addBytes[1];
+ break;
+ case 5:
+ //椋庨��
+ airCurState[3] = getDatas.addBytes[1];
+ break;
+ case 6:
+ //妯″紡
+ airCurState[1] = getDatas.addBytes[1];
+ break;
+ case 7:
+ //鍒剁儹娓╁害
+ airCurState[2] = getDatas.addBytes[1];
+ break;
+ case 8:
+ //鑷姩娓╁害
+ airCurState[2] = getDatas.addBytes[1];
+ break;
+ case 9:
+ //涓婂崌娓╁害
+ airCurState[2] = (byte) ((airCurState[2] & 0xff) + (getDatas.addBytes[1] & 0xff));
+ break;
+ case 10:
+ //涓嬮檷娓╁害
+ airCurState[2] = (byte) ((airCurState[2] & 0xff) - (getDatas.addBytes[1] & 0xff));
+ break;
+ default:
+ break;
+ }
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(airCurState);
+ } else {
+ airCtrlBackInfo.setCurState(getDatas.addBytes);
+ byte[] airCurState = devicesDataList.get(i).getAppliancesInfoList().get(j).getArrCurState();
+ switch (getDatas.addBytes[0] & 0xff) {
+ case 3:
+ //寮�鍏�
+ airCurState[0] = getDatas.addBytes[1];
+ break;
+ case 4:
+ //鍒跺喎娓╁害
+ airCurState[2] = getDatas.addBytes[1];
+ break;
+ case 5:
+ //椋庨��
+ airCurState[3] = getDatas.addBytes[1];
+ break;
+ case 6:
+ //妯″紡
+ airCurState[1] = getDatas.addBytes[1];
+ break;
+ case 7:
+ //鍒剁儹娓╁害
+ airCurState[2] = getDatas.addBytes[1];
+ break;
+ case 8:
+ //鑷姩娓╁害
+ airCurState[2] = getDatas.addBytes[1];
+ break;
+ case 9:
+ //涓婂崌娓╁害
+ airCurState[2] = (byte) ((airCurState[2] & 0xff) + (getDatas.addBytes[1] & 0xff));
+ break;
+ case 10:
+ //涓嬮檷娓╁害
+ airCurState[2] = (byte) ((airCurState[2] & 0xff) - (getDatas.addBytes[1] & 0xff));
+ break;
+ default:
+ break;
+ }
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(airCurState);
+ }
+ //涓婂崌娓╁害銆佷笅闄嶆俯搴︿笉杩斿洖銆�
+ if ((airCtrlBackInfo.getCurState()[0] & 0xff) != 9 && (airCtrlBackInfo.getCurState()[0] & 0xff) != 10) {
+ EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true));
+ }
+
+ break outter;
+ }
+ }
+ }
+ }
+
+
+ break;
+// case Configuration.AIR_HVAC_CTRL_BACK_COMMAND: //2019-8-6 灞忚斀
+// outter:
+// for (int devIndex = 0, len = devicesDataList.size(); devIndex < len; devIndex++) {
+// if (devicesDataList.get(devIndex).getSourceSubnetID() == getDatas.sourceSubnetID
+// && devicesDataList.get(devIndex).getSourceDeviceID() == getDatas.sourceDeviceID
+// ) {
+// List<AppliancesInfo> infos = devicesDataList.get(devIndex).getAppliancesInfoList();
+// for (int appIndex = 0, len2 = infos.size(); appIndex < len2; appIndex++) {
+// if ((infos.get(appIndex).getDeviceType() == HDLApConfig.TYPE_AC_HVAC
+// || infos.get(appIndex).getDeviceType() == HDLApConfig.TYPE_AC_COOLMASTER
+// || infos.get(appIndex).getDeviceType() == HDLApConfig.TYPE_AC_INFRARED)
+// && infos.get(appIndex).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {
+//// String airbytes = "193b 闄勫姞鏁版嵁锛�";
+//// for (int i = 0; i < getDatas.addBytes.length; i++) {
+//// airbytes += (getDatas.addBytes[i] & 0xff) + ",";
+//// }
+//// HDLLog.I( airbytes);
+// AppliancesInfo airInfo = infos.get(appIndex);
+// int indexI = devIndex;
+// int indexJ = appIndex;
+//
+// final byte[] oldAirInfo;
+//// HDLLog.I("KKKKKKDD"+(getDatas.addBytes[0] & 0xFF));
+// switch (getDatas.addBytes[0] & 0xFF) {
+// case 1:
+// oldAirInfo = air1Info;
+// break;
+// case 2:
+// oldAirInfo = air2Info;
+// break;
+// case 3:
+// oldAirInfo = air3Info;
+// break;
+// case 4:
+// oldAirInfo = air4Info;
+// break;
+// default:
+// oldAirInfo = new byte[1];
+// break;
+// }
+// byte[] newAirInfo = getDatas.addBytes;
+// byte[] curAirInfo = new byte[]{0};
+// boolean isModeChange = false;
+// if (oldAirInfo == null || oldAirInfo.length == 0) {
+// return;
+// }
+// for (int oldAirInedx = 0; oldAirInedx < oldAirInfo.length; oldAirInedx++) {
+// if (oldAirInedx == 0) {
+// setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true);
+// if (oldAirInfo[0] != newAirInfo[8]) {//2019-8-2 鍘绘帀鐩稿悓寮�鍏崇姸鎬佸垽鏂�,瑙e喅寮�鐘舵�佷笅,璋冪敤寮�鍛戒护鐘舵�佷笅,涓嶅仠閲嶅彂闂
+// oldAirInfo[0] = newAirInfo[8];
+// curAirInfo = new byte[]{AirCtrlParser.airSwich, newAirInfo[8]};
+// if (curAirInfo.length > 1) {
+// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(oldAirInfo);
+// airInfo.setArrCurState(oldAirInfo);
+// AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo();
+// airCtrlBackInfo.setAppliancesInfo(airInfo);
+// airCtrlBackInfo.setCurState(curAirInfo);
+//// isACCtrlSuccess = true;
+//// setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true);
+// EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true));
+//
+// }
+//
+// }
+// } else if (oldAirInedx == 1) {
+//// int mode = ((newAirInfo[4] & 0xf0) >> 4);
+// int mode = newAirInfo[9] & 0xff;
+// setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true);
+// if (oldAirInfo[1] != (byte) mode) {
+// isModeChange = true;
+// oldAirInfo[1] = (byte) mode;
+// curAirInfo = new byte[]{AirCtrlParser.airMode, (byte) mode};
+// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(oldAirInfo);
+// airInfo.setArrCurState(oldAirInfo);
+// AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo();
+// airCtrlBackInfo.setAppliancesInfo(airInfo);
+// airCtrlBackInfo.setCurState(curAirInfo);
+//// isACCtrlSuccess = true;
+//// setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true);
+// EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true));
+//
+// }
+// } else if (oldAirInedx == 2) {
+// int mode = newAirInfo[9] & 0xff;
+// byte newAirTem = newAirInfo[11];
+// setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true);
+//
+// if (oldAirInfo[2] != newAirTem) {
+// oldAirInfo[2] = newAirTem;
+// switch (mode) {
+// case 0:
+// curAirInfo = new byte[]{AirCtrlParser.refTem, newAirTem};
+// break;
+// case 1:
+// curAirInfo = new byte[]{AirCtrlParser.heatTem, newAirTem};
+// break;
+// case 3:
+// curAirInfo = new byte[]{AirCtrlParser.autoTem, newAirTem};
+// break;
+// case 4:
+// curAirInfo = new byte[]{AirCtrlParser.dehumTem, newAirTem};
+// break;
+// }
+// if (curAirInfo.length > 1) {
+// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(oldAirInfo);
+// airInfo.setArrCurState(oldAirInfo);
+// AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo();
+// airCtrlBackInfo.setAppliancesInfo(airInfo);
+// airCtrlBackInfo.setCurState(curAirInfo);
+//// isACCtrlSuccess = true;
+//// setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true);
+// EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true));
+//
+// }
+// }
+// } else if (oldAirInedx == 3) {
+//// int speed = (newAirInfo[4] & 0x0f);//鑾峰彇浣�4浣�
+// int speed = newAirInfo[10];
+// setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true);
+// if (oldAirInfo[3] != (byte) speed) {
+// oldAirInfo[3] = (byte) speed;
+// curAirInfo = new byte[]{AirCtrlParser.airSpeed, (byte) speed};
+// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(oldAirInfo);
+// airInfo.setArrCurState(oldAirInfo);
+// AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo();
+// airCtrlBackInfo.setAppliancesInfo(airInfo);
+// airCtrlBackInfo.setCurState(curAirInfo);
+//// isACCtrlSuccess = true;
+//// setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true);
+// EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true));
+//
+// }
+// }
+// }
+//
+// switch (getDatas.addBytes[0] & 0xFF) {
+// case 1:
+// air1Info = oldAirInfo;
+// break;
+// case 2:
+// air2Info = oldAirInfo;
+// break;
+// case 3:
+// air3Info = oldAirInfo;
+// break;
+// case 4:
+// air4Info = oldAirInfo;
+// break;
+// }
+//
+//
+//// if (curAirInfo.length > 1) {
+////// if (isModeChange) {
+////// isACCtrlSuccess = true;
+////// getAirInfo(hvacInfo);
+////// } else {f
+////// airInfo.setArrCurState(oldAirInfo);
+////// AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo();
+////// airCtrlBackInfo.setAppliancesInfo(airInfo);
+////// airCtrlBackInfo.setCurState(curAirInfo);
+////// isACCtrlSuccess = true;
+////// EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true));
+////// }
+////
+//// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(oldAirInfo);
+//// airInfo.setArrCurState(oldAirInfo);
+//// AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo();
+//// airCtrlBackInfo.setAppliancesInfo(airInfo);
+//// airCtrlBackInfo.setCurState(curAirInfo);
+////// isACCtrlSuccess = true;
+//// setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true);
+//// EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true));
+////
+//// }
+//
+//
+// break outter;
+// }
+// }
+// }
+// }
+//
+// break;
+ case Configuration.LOGIC_CTRL_BACK_COMMAND:
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if ((infos.get(j).getBigType() == Configuration.LOGIC_BIG_TYPE
+ || infos.get(j).getBigType() == Configuration.GLOBAL_LOGIC_BIG_TYPE)
+ && infos.get(j).getLogicMode().getAreaNum() == (getDatas.addBytes[0] & 0xFF)
+ && infos.get(j).getLogicMode().getAreaSceneNum() == (getDatas.addBytes[1] & 0xFF)
+ ) {
+ AppliancesInfo sceneInfo = infos.get(j);
+ LogicMode logicMode = new LogicMode();
+ logicMode.setAreaNum(getDatas.addBytes[0] & 0xFF);
+ logicMode.setAreaSceneNum(getDatas.addBytes[1] & 0xFF);
+ sceneInfo.setLogicMode(logicMode);
+
+ LogicCtrlBackInfo logicCtrlBackInfo = new LogicCtrlBackInfo();
+ logicCtrlBackInfo.setAppliancesInfo(sceneInfo);
+ logicCtrlBackInfo.setAreaNum(getDatas.addBytes[0] & 0xFF);
+ logicCtrlBackInfo.setSceneNum(getDatas.addBytes[1] & 0xFF);
+// isSceneCtrlSuccess = true;
+ setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
+ EventBus.getDefault().post(new LogicFeedBackEvent(logicCtrlBackInfo, true));
+
+ break outter;
+ }
+ }
+ }
+ }
+
+ break;
+ }
+ }
+
+ /**
+ * 澶勭悊瀹夐槻璁惧
+ * 20190729
+ *
+ * @param getDatas
+ */
+ private static void handleSecurityCtrlData(UdpDataBean getDatas) {
+ switch (getDatas.command) {
+ //Arming 甯冮槻璁剧疆鍙嶉
+ case Configuration.SECURITY_ARMING_CTRL_BACK_COMMAND:
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (getDatas.addBytes.length > 0) {
+ if (infos.get(j).getBigType() == Configuration.SECURITY_BIG_TYPE
+ && infos.get(j).getDeviceType() == HDLApConfig.TYPE_SECURITY_MODULE
+ && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {
+ if (getDatas.addBytes.length >= 2) {
+ AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
+// isSecurityCtrlSuccess = true;
+ setDeviceCtrlSuccessStateWithInfo(mInfo, true);
+ EventBus.getDefault().post(new SecurityArmingFeedBackEvent(mInfo, getDatas.addBytes[1] & 0xFF, true));
+ } else {
+ HDLLog.E("甯冮槻璁剧疆 鍙嶉鏁版嵁寮傚父");
+ }
+ break outter;
+ }
+ }
+ }
+ break outter;
+ }
+ }
+
+ break;
+
+ //ALARM 鎶ヨ璁剧疆鍙嶉
+ case Configuration.SECURITY_ALARM_CTRL_BACK_COMMAND:
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (getDatas.addBytes.length > 0) {
+ if (infos.get(j).getBigType() == Configuration.SECURITY_BIG_TYPE
+ && infos.get(j).getDeviceType() == HDLApConfig.TYPE_SECURITY_MODULE
+ && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {
+ if (getDatas.addBytes.length >= 3) {
+ //byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getArrCurState();
+
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes);
+ AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
+
+ SecurityBackInfo info = new SecurityBackInfo(mInfo);
+// isSecurityCtrlSuccess = true;
+ setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
+ EventBus.getDefault().post(new SecurityAlarmFeedBackEvent(info, true));
+ } else {
+ HDLLog.E("鎶ヨ璁剧疆鍙嶉 鍙嶉鏁版嵁寮傚父");
+ }
+
+ break outter;
+ }
+ }
+ }
+ break outter;
+ }
+ }
+
+ break;
+ }
+ }
+
+
+ /**
+ * 澶勭悊HVAC 鎺у埗鍥炶皟
+ * 2019-8-6
+ *
+ * @param getDatas
+ */
+ private static void handleHVACCtrlData(UdpDataBean getDatas) {
+ switch (getDatas.command) {
+ case Configuration.AIR_HVAC_CTRL_BACK_COMMAND:
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (getDatas.addBytes.length > 0) {
+ if (infos.get(j).getBigType() == Configuration.AIR_BIG_TYPE
+ && infos.get(j).getDeviceType() == HDLApConfig.TYPE_AC_HVAC
+ && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {
+
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes);
+ AppliancesInfo mHvacAirInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
+ AirHVACBackInfo info = new AirHVACBackInfo(mHvacAirInfo);
+ setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
+ EventBus.getDefault().post(new AirHVACFeedBackEvent(info, true));
+ break outter;
+ } else {
+ HDLLog.E("鎺у埗HVAC鐘舵�佸弽棣堟暟鎹紓甯�");
+ }
+ break outter;
+ }
+ }
+ }
+ }
+ break;
+ }
+
+ }
+
+
+// private static void getAirInfo(final AppliancesInfo hvacInfo) {
+//
+// isLogicCtrl = true;
+// timerAir = new Timer();
+// timerAir.schedule(new TimerTask() {
+// @Override
+// public void run() {
+// if (isLogicCtrl) {
+// HDLCommand.HDLgetAirInfo(hvacInfo);
+// } else {
+// timerAir.cancel();
+// }
+//
+// }
+// }, 100, 500);
+// }
+
+
+ /**
+ * 澶勭悊閫昏緫绌鸿皟鏁版嵁
+ *
+ * @param getDatas
+ */
+ private static void handleLogicAir(UdpDataBean getDatas) {
+ AppliancesInfo newInfo1 = null;
+ for (int devPos = 0, len = devicesDataList.size(); devPos < len; devPos++) {
+ if (devicesDataList.get(devPos).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(devPos).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(devPos).getAppliancesInfoList();
+ for (int appPos = 0, len2 = infos.size(); appPos < len2; appPos++) {
+ switch (infos.get(appPos).getBigType()) {
+ case Configuration.AIR_BIG_TYPE:
+ switch (infos.get(appPos).getLittleType()) {
+ case 0:
+ byte[] airInfo = new byte[6];
+ System.arraycopy(getDatas.addBytes, 23, airInfo, 0, airInfo.length);
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setArrCurState(airInfo);
+ newInfo1 = devicesDataList.get(devPos).getAppliancesInfoList().get(appPos);
+ break;
+ }
+ break;
+ }
+ }
+ }
+ }
+
+// getAppInfo(newInfo);
+ final AppliancesInfo newInfo = newInfo1;
+ final byte[] airCurInfo;
+ if (newInfo == null) {
+ return;
+ }
+ airCurInfo = newInfo.getArrCurState();
+
+ new Timer().schedule(new TimerTask() {
+ @Override
+ public void run() {
+ newInfo.setArrCurState(new byte[]{AirCtrlParser.airSwich, airCurInfo[0]});
+ EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+ }
+ }, 1000);
+
+
+ new Timer().schedule(new TimerTask() {
+ @Override
+ public void run() {
+ newInfo.setArrCurState(new byte[]{AirCtrlParser.airMode, airCurInfo[1]});
+ EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+ }
+ }, 2000);
+
+
+ switch (airCurInfo[1] & 0xFF) {
+ case 0:
+
+ new Timer().schedule(new TimerTask() {
+ @Override
+ public void run() {
+ newInfo.setArrCurState(new byte[]{AirCtrlParser.refTem, airCurInfo[2]});
+ EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+ }
+ }, 3000);
+
+
+ new Timer().schedule(new TimerTask() {
+ @Override
+ public void run() {
+ newInfo.setArrCurState(new byte[]{AirCtrlParser.airSpeed, airCurInfo[3]});
+ EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+ }
+ }, 4000);
+
+ break;
+ case 1:
+ new Timer().schedule(new TimerTask() {
+ @Override
+ public void run() {
+ newInfo.setArrCurState(new byte[]{AirCtrlParser.heatTem, airCurInfo[2]});
+ EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+ }
+ }, 3000);
+ new Timer().schedule(new TimerTask() {
+ @Override
+ public void run() {
+ newInfo.setArrCurState(new byte[]{AirCtrlParser.airSpeed, airCurInfo[3]});
+ EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+ }
+ }, 4000);
+
+ break;
+ case 2:
+// 閫氶妯″紡鏃犳俯搴�
+ new Timer().schedule(new TimerTask() {
+ @Override
+ public void run() {
+ newInfo.setArrCurState(new byte[]{AirCtrlParser.airSpeed, airCurInfo[3]});
+ EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+ }
+ }, 3000);
+
+ break;
+ case 3:
+ new Timer().schedule(new TimerTask() {
+ @Override
+ public void run() {
+ newInfo.setArrCurState(new byte[]{AirCtrlParser.autoTem, airCurInfo[2]});
+ EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+ }
+ }, 3000);
+
+ new Timer().schedule(new TimerTask() {
+ @Override
+ public void run() {
+ newInfo.setArrCurState(new byte[]{AirCtrlParser.airSpeed, airCurInfo[3]});
+ EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+ }
+ }, 4000);
+
+
+ break;
+ case 4:
+ //鎶芥箍妯″紡鏃犻閫�
+ new Timer().schedule(new TimerTask() {
+ @Override
+ public void run() {
+ newInfo.setArrCurState(new byte[]{AirCtrlParser.dehumTem, airCurInfo[2]});
+ EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+ }
+ }, 3000);
+
+ break;
+ }
+ }
+
+ /**
+ * 澶勭悊鎵�鏈夊娉ㄦ暟鎹�佽缃綋鍓嶈澶囩姸鎬�
+ *
+ * @param getDatas
+ */
+ private static void handleRemarkCurStateData(UdpDataBean getDatas) {
+ outter:
+ for (int devPos = 0, len = devicesDataList.size(); devPos < len; devPos++) {
+ if (devicesDataList.get(devPos).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(devPos).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(devPos).getAppliancesInfoList();
+ for (int appPos = 0, len2 = infos.size(); appPos < len2; appPos++) {
+ if ((infos.get(appPos).getBigType()) == (getDatas.addBytes[0] & 0xFF)
+ && ((infos.get(appPos).getLittleType()) == (getDatas.addBytes[1] & 0xFF))
+ && ((infos.get(appPos).getChannelNum()) == (getDatas.addBytes[2] & 0xFF))
+ ) {
+
+ //2019-8-20
+ byte[] remarkByte;
+ if (getDatas.addBytes.length >= 23) {
+ remarkByte = new byte[20];
+ System.arraycopy(getDatas.addBytes, 3, remarkByte, 0, remarkByte.length);
+ } else {
+ remarkByte = new byte[getDatas.addBytes.length - 3];
+ System.arraycopy(getDatas.addBytes, 3, remarkByte, 0, getDatas.addBytes.length - 3);
+ }
+
+ String remarkStr = HDLStringUtils.byte2String(remarkByte);
+ HDLLog.I("remarkStr鍥炶矾锛�" + remarkStr);
+
+// byte[] remark = new byte[20];
+// //纭欢鐨勫瓧鑺傛祦鍗忚鎻愪緵鏈夎锛屾敹鍒版煇纭欢鎻愪緵澶囨敞涓嶈冻20闀垮害锛岃В鍐宠繖闂鐨勬潈瀹滀箣璁�
+// int length;
+// if (getDatas.addBytes.length < 20) {
+// length = getDatas.addBytes.length;
+// } else {
+// length = remark.length;
+// }
+// System.arraycopy(getDatas.addBytes, 3, remark, 0, length);
+
+// String remarkStr = HDLStringUtils.byte2String(remark);
+// HDLLog.I("remarkStr鍥炶矾锛�" + remarkStr);
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setRemarks(remarkStr);
+
+ switch (infos.get(appPos).getBigType()) {
+ case Configuration.LOGIC_BIG_TYPE:
+ case Configuration.GLOBAL_LOGIC_BIG_TYPE:
+ LogicMode logicMode = new LogicMode();
+ logicMode.setAreaNum(getDatas.addBytes[getDatas.addBytes.length - 2] & 0xFF);
+ logicMode.setAreaSceneNum(getDatas.addBytes[getDatas.addBytes.length - 1] & 0xFF);
+
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setLogicMode(logicMode);
+
+ break;
+ case Configuration.LIGTH_BIG_TYPE:
+ switch (infos.get(appPos).getLittleType()) {
+ case 0:
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setCurState(getDatas.addBytes[getDatas.addBytes.length - 1] & 0xFF);
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setIntCurState(getDatas.addBytes[getDatas.addBytes.length - 1] & 0xFF);
+ break;
+ case 1:
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setCurState(getDatas.addBytes[getDatas.addBytes.length - 1] & 0xFF);
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setIntCurState(getDatas.addBytes[getDatas.addBytes.length - 1] & 0xFF);
+ break;
+ case 9:
+ RcuLight rcuLight = new RcuLight();
+ rcuLight.setPhysicsChanelNum(getDatas.addBytes[getDatas.addBytes.length - 1] & 0xFF);
+ rcuLight.setCurState(getDatas.addBytes[getDatas.addBytes.length - 2] & 0xFF);
+ rcuLight.setLittleType(9);
+ rcuLightList.add(rcuLight);
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setPhysicsChannelNum(getDatas.addBytes[getDatas.addBytes.length - 1] & 0xFF);
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setCurState(getDatas.addBytes[getDatas.addBytes.length - 2] & 0xFF);
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setIntCurState(getDatas.addBytes[getDatas.addBytes.length - 2] & 0xFF);
+ break;
+ case 10:
+ RcuLight rcu2Light = new RcuLight();
+ rcu2Light.setPhysicsChanelNum(getDatas.addBytes[getDatas.addBytes.length - 1] & 0xFF);
+ rcu2Light.setCurState(getDatas.addBytes[getDatas.addBytes.length - 2] & 0xFF);
+ rcu2Light.setLittleType(10);
+ rcuLightList.add(rcu2Light);
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setPhysicsChannelNum(getDatas.addBytes[getDatas.addBytes.length - 1] & 0xFF);
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setCurState(getDatas.addBytes[getDatas.addBytes.length - 2] & 0xFF);
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setIntCurState(getDatas.addBytes[getDatas.addBytes.length - 2] & 0xFF);
+ break;
+
+ }
+ break;
+ case Configuration.CURTAIN_BIG_TYPE:
+ int curtainState;
+ switch (infos.get(appPos).getLittleType()) {
+ case 0:
+ curtainState = getDatas.addBytes[25] & 0xFF;
+ if (curtainState == 1) {
+ curtainState = 0;
+ } else if (curtainState == 99) {
+ curtainState = 100;
+ }
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setCurState(curtainState);
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setIntCurState(curtainState);
+ break;
+ case 1:
+ curtainState = getDatas.addBytes[23] & 0xFF;
+ if (curtainState == 1) {
+ curtainState = 0;
+ } else if (curtainState == 99) {
+ curtainState = 100;
+ }
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setCurState(curtainState);
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setIntCurState(curtainState);
+ break;
+ case 2:
+// if (!TextUtils.isEmpty(HandleSearch.rcuIp)) {
+// RcuCurtain rcuCurtain = new RcuCurtain();
+// rcuCurtain.setChanelNum(getDatas.addBytes[2] & 0xFF);
+// rcuCurtain.setLittleType(2);
+// int state = -1;
+// switch (getDatas.addBytes[getDatas.addBytes.length - 1] & 0xFF) {
+// case 0:
+// state = CurtainCtrlParser.curtainPause;
+// break;
+// case 1:
+// state = CurtainCtrlParser.curtainOn;
+// break;
+// case 2:
+// state = CurtainCtrlParser.curtainOff;
+// break;
+// }
+// rcuCurtain.setCurState(state);
+// rcuCurtainList.add(rcuCurtain);
+// }
+
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setCurState(getDatas.addBytes[getDatas.addBytes.length - 1] & 0xFF);
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setIntCurState(getDatas.addBytes[getDatas.addBytes.length - 1] & 0xFF);
+ break;
+
+ }
+ break;
+
+ case Configuration.AIR_BIG_TYPE:
+ switch (infos.get(appPos).getLittleType()) {
+ case 0:
+ byte[] hvacBytes = new byte[getDatas.addBytes.length - 23];
+ for (int i = 23; i < getDatas.addBytes.length; i++) {
+ hvacBytes[i - 23] = getDatas.addBytes[i];
+ }
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setArrCurState(hvacBytes);
+// switch (devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getChannelNum()) {
+// case 1:
+// if (air1Info == null) {
+// air1Info = hvacBytes;
+// }
+// break;
+// case 2:
+// if (air2Info == null) {
+// air2Info = hvacBytes;
+// }
+// break;
+// case 3:
+// if (air3Info == null) {
+// air3Info = hvacBytes;
+// }
+// break;
+// case 4:
+// if (air4Info == null) {
+// air4Info = hvacBytes;
+// }
+// break;
+//
+// }
+ break;
+ case 3:
+ byte[] newBytes = new byte[getDatas.addBytes.length - 24 + 1];
+ for (int i = 24; i < getDatas.addBytes.length; i++) {
+ newBytes[i - 24] = getDatas.addBytes[i];
+ }
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setArrCurState(newBytes);
+ break;
+ }
+ break;
+ case Configuration.SENSOR_BIG_TYPE://2019-07-03 灞忚斀
+// String aa = "浼犳劅鍣ㄥ娉細";
+// for (int i = 0; i < getDatas.addBytes.length; i++) {
+// aa += (getDatas.addBytes[i] & 0xff) + ",";
+// }
+// HDLLog.I( aa);
+
+ int curState;
+ if (getDatas.addBytes.length >= 26) {//2019-11-7 鐗规畩澶勭悊锛屼慨鏀瑰洖璺彿
+ curState = (int) (getDatas.addBytes[24] & 0xff);
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setChannelNum(getDatas.addBytes[25] & 0xff);
+
+ } else {
+ curState = (int) (getDatas.addBytes[getDatas.addBytes.length - 1] & 0xff);
+ }
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setCurState(curState);
+ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setIntCurState((int) curState);
+ break;
+ default:
+ HDLLog.I("鏈壘鍒版绫诲瀷璁惧锛�" + infos.get(appPos).getBigType());
+ break;
+ }
+ listRemarksOutter:
+ for (int lRPos = 0, len3 = listRemarks.size(); lRPos < len3; lRPos++) {
+ //鎵惧埌E44B瀵瑰簲鐨勮澶囧洖璺紝鍒ゆ柇鏄惁宸茬粡鎷垮埌浜嗘暟鎹��
+ if (listRemarks.get(lRPos).getAppliancesInfo().getDeviceSubnetID() == getDatas.sourceSubnetID
+ && listRemarks.get(lRPos).getAppliancesInfo().getDeviceDeviceID() == getDatas.sourceDeviceID
+ && listRemarks.get(lRPos).getAppliancesInfo().getBigType() == (getDatas.addBytes[0] & 0xFF)
+ && listRemarks.get(lRPos).getAppliancesInfo().getLittleType() == (getDatas.addBytes[1] & 0xFF)
+ && listRemarks.get(lRPos).getAppliancesInfo().getChannelNum() == (getDatas.addBytes[2] & 0xFF)
+ ) {
+
+
+ //鑻ユ病鎷垮埌鏁版嵁锛屽垯鎷挎暟鎹紱鑻ュ凡缁忔嬁鍒版暟鎹紝闇�瑕佸垽鏂璴istRemarks鍏ㄩ儴鏉$洰鏄惁鎷垮埌澶囨敞銆�
+ if (listRemarks.get(lRPos).isCallBack()) {
+ for (int lR2Pos = 0, len4 = listRemarks.size(); lR2Pos < len4; lR2Pos++) {
+ if (listRemarks.get(lR2Pos).isCallBack()) {
+ if (lR2Pos == (len4 - 1)) {
+ HDLLog.I("鏀跺埌澶囨敞鍛戒护锛屽凡瀛樺湪姝よ澶囧娉紝杩囨护");
+ break listRemarksOutter;
+ }
+ } else {
+ HDLLog.I("涓嶅瓨鍦ㄧ殑璁惧澶囨敞锛屽啀娆℃悳绱㈠娉ㄣ�傝澶囷細瀛愮綉鍙凤細" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceSubnetID()
+ + "璁惧鍙凤細" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceDeviceID()
+ + "鍥炶矾鍙�" + listRemarks.get(lRPos).getAppliancesInfo().getChannelNum()
+ + "澶囨敞锛�" + listRemarks.get(lRPos).getAppliancesInfo().getRemarks());
+ HandleSearch.getDevRemarks();
+ break listRemarksOutter;
+ }
+ }
+ } else {
+ HDLLog.I("杩斿洖澶囨敞璁惧锛氬瓙缃戝彿锛�" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceSubnetID()
+ + ",璁惧鍙凤細" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceDeviceID()
+ + ",鍥炶矾鍙�" + listRemarks.get(lRPos).getAppliancesInfo().getChannelNum()
+ + ",澶囨敞锛�" + listRemarks.get(lRPos).getAppliancesInfo().getRemarks());
+ listRemarks.get(lRPos).setCallBack(true);
+ HandleSearch.getDevRemarks();
+ break listRemarksOutter;
+
+ }
+
+ }
+ }
+
+ break outter;
+
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * 澶勭悊淇敼璁惧澶囨敞鍚庣殑鍥炶皟
+ *
+ * @param getDatas
+ */
+ private static void handleModuleUpdateRemarkData(UdpDataBean getDatas) {
+ if (getDatas.desSubnetID == Crc.localSubnetID && getDatas.desDeviceID == Crc.localDeviceID) {
+ isUpdateRemarkSuccess = true;
+ EventBus.getDefault().post(new UpdateRemarkFeedBackEvent(true));
+ }
+ }
+
+
+ /**
+ * 澶勭悊璁惧鐘舵�佹暟鎹�
+ *
+ * @param getDatas
+ */
+ private static void handleStateData(UdpDataBean getDatas) {
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ switch (devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType()) {
+ case Configuration.SENSOR_BIG_TYPE://2019-07-03 灞忚斀
+ isGetDeviceStateSuccess = true;
+ AppliancesInfo sensorInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
+ float value = HDLUtlis.byte2Float(Arrays.copyOfRange(getDatas.addBytes, 5, 8));
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(value);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState((int) value);
+
+ sensorInfo.setCurState(value);
+
+
+ String unite = "";
+ switch (sensorInfo.getDeviceType()) {
+ case HDLApConfig.TYPE_SENSOR_DRY_CONTACT:
+ unite = "";
+ break;
+ case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR:
+ unite = "";
+ break;
+ case HDLApConfig.TYPE_SENSOR_TEMP:
+ if ((getDatas.addBytes[4] & 0xff) == 0) {
+ unite = "掳C";
+ } else {
+ unite = "掳F";
+ }
+
+ break;
+ case HDLApConfig.TYPE_SENSOR_HUMIDITY:
+ unite = "%";
+ break;
+ case HDLApConfig.TYPE_SENSOR_ILLUMINACE:
+ unite = "LUX";
+ break;
+ case HDLApConfig.TYPE_SENSOR_VOC:
+ unite = "";
+ break;
+ case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5:
+ switch (getDatas.addBytes[4] & 0xff) {
+ case 0:
+ unite = "mg/m3";
+ break;
+ case 1:
+ unite = "ppm";
+ break;
+ case 2:
+ unite = "渭m";
+ break;
+ default:
+ unite = "";
+ break;
+ }
+
+ break;
+ case HDLApConfig.TYPE_SENSOR_C02:
+ switch (getDatas.addBytes[4] & 0xff) {
+ case 0:
+ unite = "mg/m3";
+ break;
+ case 1:
+ unite = "ppm";
+ break;
+ default:
+ unite = "";
+ break;
+ }
+ break;
+ case HDLApConfig.TYPE_SENSOR_LPG:
+ unite = "ppm";
+ break;
+ case HDLApConfig.TYPE_SENSOR_CO_H2:
+ unite = "ppm";
+ break;
+ case HDLApConfig.TYPE_SENSOR_CH4:
+ unite = "ppm";
+ break;
+ case HDLApConfig.TYPE_SENSOR_SMOG:
+ unite = "";
+ break;
+ case HDLApConfig.TYPE_SENSOR_WIND_SPEED:
+ unite = "m/s";
+ break;
+ case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE:
+ unite = "Pa";
+ break;
+ case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW:
+ unite = "";
+ break;
+ case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE:
+ unite = "Pa";
+ break;
+ case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH:
+ unite = "mm";
+ break;
+ case HDLApConfig.TYPE_SENSOR_RAIN_FALL:
+ switch (getDatas.addBytes[4] & 0xff) {
+ case 0:
+ unite = "鏃犻洦";
+ break;
+ case 1:
+ unite = "灏忛洦";
+ break;
+ case 2:
+ unite = "澶ч洦";
+ break;
+ default:
+ unite = "";
+ break;
+ }
+ break;
+ case HDLApConfig.TYPE_SENSOR_WEIGHT:
+ unite = "KG";
+ break;
+ case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH:
+ unite = "mm";
+ break;
+ case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED:
+ unite = "m/s";
+ break;
+ case HDLApConfig.TYPE_SENSOR_SHAKE:
+ unite = "mm";
+ break;
+ case HDLApConfig.TYPE_SENSOR_VOLTAGE:
+ switch (getDatas.addBytes[4] & 0xff) {
+ case 0:
+ unite = "V";
+ break;
+ case 1:
+ unite = "渭V";
+ break;
+ default:
+ unite = "";
+ break;
+ }
+ break;
+ case HDLApConfig.TYPE_SENSOR_ELECTRICITY:
+ switch (getDatas.addBytes[4] & 0xff) {
+ case 0:
+ unite = "A";
+ break;
+ case 1:
+ unite = "渭A";
+ break;
+ default:
+ unite = "";
+ break;
+ }
+ break;
+ case HDLApConfig.TYPE_SENSOR_POWER:
+ unite = "W";
+ break;
+ case HDLApConfig.TYPE_SENSOR_FLOODING://姘存蹈
+ unite = "";
+ break;
+ case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET://闂ㄧ
+ unite = "";
+ break;
+ case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON://绱ф�ユ寜閽�
+ unite = "";
+ break;
+
+ default:
+ unite = "鏈煡鍗曚綅";
+ break;
+ }
+
+
+// EventBus.getDefault().post(new DeviceStateEvent(sensorInfo, true));
+ HDLLog.I("鍙戦�佷紶鎰熷櫒閫氱煡鏇存柊");
+ EventBus.getDefault().post(new SensorStateBackInfo(sensorInfo, true, unite));
+ break;
+ default:
+ HDLLog.I("handle state 娌℃湁鎵惧埌鍖归厤绫诲瀷");
+ break;
+ }
+
+ }
+ break outter;
+ }
+ }
+ }
+
+ /**
+ * 澶勭悊浼犳劅鍣� 骞挎挱鏁版嵁
+ * 2019-11-4 鏂颁慨鏀�
+ *
+ * @param getDatas
+ */
+ private static void handleSensorBroadcastStateData(UdpDataBean getDatas) {
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (infos.get(j).getBigType() == Configuration.SENSOR_BIG_TYPE
+ && infos.get(j).getLittleType() == (getDatas.addBytes[1] & 0xFF)
+ && infos.get(j).getChannelNum() == (getDatas.addBytes[2] & 0xFF)) {//2019-07-29
+ isGetDeviceStateSuccess = true;
+ AppliancesInfo sensorInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
+ float value = HDLUtlis.byte2Float(Arrays.copyOfRange(getDatas.addBytes, 5, 8));
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(value);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState((int) value);
+
+ sensorInfo.setCurState(value);
+
+ String unite = "";
+ switch (sensorInfo.getDeviceType()) {
+ case HDLApConfig.TYPE_SENSOR_DRY_CONTACT:
+ unite = "";
+ break;
+ case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR:
+ unite = "";
+ break;
+ case HDLApConfig.TYPE_SENSOR_TEMP:
+ if ((getDatas.addBytes[4] & 0xff) == 0) {
+ unite = "掳C";
+ } else {
+ unite = "掳F";
+ }
+
+ break;
+ case HDLApConfig.TYPE_SENSOR_HUMIDITY:
+ unite = "%";
+ break;
+ case HDLApConfig.TYPE_SENSOR_ILLUMINACE:
+ unite = "LUX";
+ break;
+ case HDLApConfig.TYPE_SENSOR_VOC:
+ unite = "";
+ break;
+ case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5:
+ switch (getDatas.addBytes[4] & 0xff) {
+ case 0:
+ unite = "mg/m3";
+ break;
+ case 1:
+ unite = "ppm";
+ break;
+ case 2:
+ unite = "渭m";
+ break;
+ default:
+ unite = "";
+ break;
+ }
+
+ break;
+ case HDLApConfig.TYPE_SENSOR_C02:
+ switch (getDatas.addBytes[4] & 0xff) {
+ case 0:
+ unite = "mg/m3";
+ break;
+ case 1:
+ unite = "ppm";
+ break;
+ default:
+ unite = "";
+ break;
+ }
+ break;
+ case HDLApConfig.TYPE_SENSOR_LPG:
+ unite = "ppm";
+ break;
+ case HDLApConfig.TYPE_SENSOR_CO_H2:
+ unite = "ppm";
+ break;
+ case HDLApConfig.TYPE_SENSOR_CH4:
+ unite = "ppm";
+ break;
+ case HDLApConfig.TYPE_SENSOR_SMOG:
+ unite = "";
+ break;
+ case HDLApConfig.TYPE_SENSOR_WIND_SPEED:
+ unite = "m/s";
+ break;
+ case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE:
+ unite = "Pa";
+ break;
+ case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW:
+ unite = "";
+ break;
+ case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE:
+ unite = "Pa";
+ break;
+ case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH:
+ unite = "mm";
+ break;
+ case HDLApConfig.TYPE_SENSOR_RAIN_FALL:
+ switch (getDatas.addBytes[4] & 0xff) {
+ case 0:
+ unite = "鏃犻洦";
+ break;
+ case 1:
+ unite = "灏忛洦";
+ break;
+ case 2:
+ unite = "澶ч洦";
+ break;
+ default:
+ unite = "";
+ break;
+ }
+ break;
+ case HDLApConfig.TYPE_SENSOR_WEIGHT:
+ unite = "KG";
+ break;
+ case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH:
+ unite = "mm";
+ break;
+ case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED:
+ unite = "m/s";
+ break;
+ case HDLApConfig.TYPE_SENSOR_SHAKE:
+ unite = "mm";
+ break;
+ case HDLApConfig.TYPE_SENSOR_VOLTAGE:
+ switch (getDatas.addBytes[4] & 0xff) {
+ case 0:
+ unite = "V";
+ break;
+ case 1:
+ unite = "渭V";
+ break;
+ default:
+ unite = "";
+ break;
+ }
+ break;
+ case HDLApConfig.TYPE_SENSOR_ELECTRICITY:
+ switch (getDatas.addBytes[4] & 0xff) {
+ case 0:
+ unite = "A";
+ break;
+ case 1:
+ unite = "渭A";
+ break;
+ default:
+ unite = "";
+ break;
+ }
+ break;
+ case HDLApConfig.TYPE_SENSOR_POWER:
+ unite = "W";
+ break;
+ case HDLApConfig.TYPE_SENSOR_FLOODING:
+ unite = "";
+ break;
+ case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET:
+ unite = "";
+ break;
+ case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON:
+ unite = "";
+ break;
+ default:
+ unite = "鏈煡鍗曚綅";
+ break;
+ }
+
+// EventBus.getDefault().post(new DeviceStateEvent(sensorInfo, true));
+ HDLLog.I("鍙戦�佷紶鎰熷櫒閫氱煡鏇存柊");
+ EventBus.getDefault().post(new SensorStateBackInfo(sensorInfo, true, unite));
+
+ break outter;
+ } else {
+ HDLLog.I("handle state 娌℃湁鎵惧埌鍖归厤绫诲瀷");
+ }
+ }
+ break outter;
+ }
+
+ }
+
+ }
+
+// /**
+// * 澶勭悊浼犳劅鍣� 骞挎挱鏁版嵁
+// *
+// * @param getDatas
+// */
+// private static void handleSensorBroadcastStateData(UdpDataBean getDatas) {
+// outter:
+// for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+// if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+// && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+// ) {
+// List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+// for (int j = 0, len2 = infos.size(); j < len2; j++) {
+// switch (devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType()) {
+// case Configuration.SENSOR_BIG_TYPE://2019-07-03 灞忚斀
+// isGetDeviceStateSuccess = true;
+// AppliancesInfo sensorInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
+// float value = HDLUtlis.byte2Float(Arrays.copyOfRange(getDatas.addBytes, 5, 8));
+// devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(value);
+// devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState((int) value);
+//
+// sensorInfo.setCurState(value);
+//
+//
+// String unite = "";
+// switch (sensorInfo.getDeviceType()) {
+// case HDLApConfig.TYPE_SENSOR_DRY_CONTACT:
+// unite = "";
+// break;
+// case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR:
+// unite = "";
+// break;
+// case HDLApConfig.TYPE_SENSOR_TEMP:
+// if ((getDatas.addBytes[4] & 0xff) == 0) {
+// unite = "掳C";
+// } else {
+// unite = "掳F";
+// }
+//
+// break;
+// case HDLApConfig.TYPE_SENSOR_HUMIDITY:
+// unite = "%";
+// break;
+// case HDLApConfig.TYPE_SENSOR_ILLUMINACE:
+// unite = "LUX";
+// break;
+// case HDLApConfig.TYPE_SENSOR_VOC:
+// unite = "";
+// break;
+// case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5:
+// switch (getDatas.addBytes[4] & 0xff) {
+// case 0:
+// unite = "mg/m3";
+// break;
+// case 1:
+// unite = "ppm";
+// break;
+// case 2:
+// unite = "渭m";
+// break;
+// default:
+// unite = "";
+// break;
+// }
+//
+// break;
+// case HDLApConfig.TYPE_SENSOR_C02:
+// switch (getDatas.addBytes[4] & 0xff) {
+// case 0:
+// unite = "mg/m3";
+// break;
+// case 1:
+// unite = "ppm";
+// break;
+// default:
+// unite = "";
+// break;
+// }
+// break;
+// case HDLApConfig.TYPE_SENSOR_LPG:
+// unite = "ppm";
+// break;
+// case HDLApConfig.TYPE_SENSOR_CO_H2:
+// unite = "ppm";
+// break;
+// case HDLApConfig.TYPE_SENSOR_CH4:
+// unite = "ppm";
+// break;
+// case HDLApConfig.TYPE_SENSOR_SMOG:
+// unite = "";
+// break;
+// case HDLApConfig.TYPE_SENSOR_WIND_SPEED:
+// unite = "m/s";
+// break;
+// case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE:
+// unite = "Pa";
+// break;
+// case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW:
+// unite = "";
+// break;
+// case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE:
+// unite = "Pa";
+// break;
+// case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH:
+// unite = "mm";
+// break;
+// case HDLApConfig.TYPE_SENSOR_RAIN_FALL:
+// switch (getDatas.addBytes[4] & 0xff) {
+// case 0:
+// unite = "鏃犻洦";
+// break;
+// case 1:
+// unite = "灏忛洦";
+// break;
+// case 2:
+// unite = "澶ч洦";
+// break;
+// default:
+// unite = "";
+// break;
+// }
+// break;
+// case HDLApConfig.TYPE_SENSOR_WEIGHT:
+// unite = "KG";
+// break;
+// case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH:
+// unite = "mm";
+// break;
+// case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED:
+// unite = "m/s";
+// break;
+// case HDLApConfig.TYPE_SENSOR_SHAKE:
+// unite = "mm";
+// break;
+// case HDLApConfig.TYPE_SENSOR_VOLTAGE:
+// switch (getDatas.addBytes[4] & 0xff) {
+// case 0:
+// unite = "V";
+// break;
+// case 1:
+// unite = "渭V";
+// break;
+// default:
+// unite = "";
+// break;
+// }
+// break;
+// case HDLApConfig.TYPE_SENSOR_ELECTRICITY:
+// switch (getDatas.addBytes[4] & 0xff) {
+// case 0:
+// unite = "A";
+// break;
+// case 1:
+// unite = "渭A";
+// break;
+// default:
+// unite = "";
+// break;
+// }
+// break;
+// case HDLApConfig.TYPE_SENSOR_POWER:
+// unite = "W";
+// break;
+// case HDLApConfig.TYPE_SENSOR_FLOODING:
+// unite = "";
+// break;
+// case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET:
+// unite = "";
+// break;
+// case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON:
+// unite = "";
+// break;
+// default:
+// unite = "鏈煡鍗曚綅";
+// break;
+// }
+//
+//
+//// EventBus.getDefault().post(new DeviceStateEvent(sensorInfo, true));
+// HDLLog.I("鍙戦�佷紶鎰熷櫒閫氱煡鏇存柊");
+// EventBus.getDefault().post(new SensorStateBackInfo(sensorInfo, true, unite));
+// break;
+// default:
+// HDLLog.I("handle state 娌℃湁鎵惧埌鍖归厤绫诲瀷");
+// break;
+// }
+//
+// }
+// break outter;
+// }
+// }
+// }
+
+
+ /**
+ * 澶勭悊鐏厜妯″潡鍥炶皟
+ * 20190726鏂板
+ *
+ * @param getDatas
+ */
+ private static void handleLightStateData(UdpDataBean getDatas) {
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (infos.get(j).getBigType() == Configuration.LIGTH_BIG_TYPE) { //2019-07-26鍥犱负鏌ョ伅鍏夌姸鎬佹槸鏌ヨ鎵�浠ュ洖璺紝鎵�浠ヨ鎶婃墍鏈夊洖璺伅鍏夌姸鎬侀兘鎺ㄩ�佷竴娆�
+ isGetDeviceStateSuccess = true;
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[j + 1] & 0xFF);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[j + 1] & 0xFF);
+ EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true));
+// HDLLog.I("HDLlightState" + devicesDataList.get(i).getAppliancesInfoList().get(j).toString());
+ } else {
+ HDLLog.I("handleLightStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷");
+ }
+ }
+ break outter;
+ }
+ }
+ }
+
+ /**
+ * 澶勭悊绐楀笜妯″潡 E3E4骞挎挱鍥炶皟
+ * 2019-12-16 鏂板
+ *
+ * @param getDatas
+ */
+ private static void handleCurtainBroadcastStateData(UdpDataBean getDatas) {
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (infos.get(j).getBigType() == Configuration.CURTAIN_BIG_TYPE
+ && infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) { //鎶婃墍鏈夌獥甯樼姸鎬侀兘鎺ㄩ�佷竴娆�
+
+ if (getDatas.addBytes.length - 1 < j) return;
+
+ int state = 0;
+ switch (getDatas.addBytes[j] & 0xFF) {//杩欓噷涔熷簲璇ユ敼鎴�0锛�1锛�2
+ case 0:
+ state = CurtainCtrlParser.curtainPause;
+ break;
+ case 1:
+ state = CurtainCtrlParser.curtainOn;
+ break;
+ case 2:
+ state = CurtainCtrlParser.curtainOff;
+ break;
+ default:
+ state = 0;
+ break;
+ }
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[j] & 0xFF);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[j] & 0xFF);
+
+ AppliancesInfo curtainInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
+ curtainInfo.setCurState(state);
+ EventBus.getDefault().post(new DeviceStateEvent(curtainInfo, true));
+// HDLLog.I("CurtainBroadcastState" + curtainInfo.toString());
+ } else {
+ HDLLog.I("CurtainBroadcastState 娌℃湁鎵惧埌鍖归厤绫诲瀷");
+ }
+ }
+ break outter;
+ }
+ }
+ }
+
+ /**
+ * 澶勭悊绐楀笜
+ * 20190726鏂板
+ *
+ * @param getDatas
+ */
+ private static void handleCurtainStateData(UdpDataBean getDatas) {
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (infos.get(j).getBigType() == Configuration.CURTAIN_BIG_TYPE) {
+ int state = 0;
+ if (infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE//绐楀笜妯″潡
+ && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-07-17
+
+ switch (getDatas.addBytes[1] & 0xFF) {//杩欓噷涔熷簲璇ユ敼鎴�0锛�1锛�2
+ case 0:
+ state = CurtainCtrlParser.curtainPause;
+ break;
+ case 1:
+ state = CurtainCtrlParser.curtainOn;
+ break;
+ case 2:
+ state = CurtainCtrlParser.curtainOff;
+ break;
+ default:
+ state = 0;
+ break;
+ }
+ isGetDeviceStateSuccess = true;
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[1] & 0xFF);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[1] & 0xFF);
+ AppliancesInfo curtainInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
+ curtainInfo.setCurState(state);
+ EventBus.getDefault().post(new DeviceStateEvent(curtainInfo, true));
+
+ break outter;
+ } else if (infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_GLYSTRO || infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_ROLLER) {
+ if ((getDatas.addBytes[0] & 0xFF) >= 17
+ && ((getDatas.addBytes[0] & 0xFF) - 16) == infos.get(j).getChannelNum()) {//绐楀笜鍙峰ぇ浜庣瓑浜�17 鍑� 16 = 褰撳墠绐楀笜鍥炶矾鍙�
+ state = getDatas.addBytes[1] & 0xFF;
+ if (state == 1) {
+ state = 0;//杩欎釜鍒ゆ柇鏄皢鐧惧垎姣斾负1锛屽己鍒舵敼涓�0.
+ }
+ if (state == 99) {
+ state = 100;//杩欎釜鍒ゆ柇鏄皢鐧惧垎姣斾负99锛屽己鍒舵敼涓�100.
+ }
+ isGetDeviceStateSuccess = true;
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[1] & 0xFF);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[1] & 0xFF);
+ AppliancesInfo curtainInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
+ curtainInfo.setCurState(state);
+ EventBus.getDefault().post(new DeviceStateEvent(curtainInfo, true));
+ break outter;
+ } else {
+ if ((getDatas.addBytes[0] & 0xFF) == infos.get(j).getChannelNum()) {
+ switch (getDatas.addBytes[1] & 0xFF) {//杩欓噷涔熷簲璇ユ敼鎴�0锛�1锛�2
+ case 0:
+ state = CurtainCtrlParser.curtainPause;
+ break;
+ case 1:
+ state = CurtainCtrlParser.curtainOn;
+ break;
+ case 2:
+ state = CurtainCtrlParser.curtainOff;
+ break;
+ default:
+ state = 0;
+ break;
+ }
+ isGetDeviceStateSuccess = true;
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[1] & 0xFF);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[1] & 0xFF);
+ AppliancesInfo curtainInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
+ curtainInfo.setCurState(state);
+ EventBus.getDefault().post(new DeviceStateEvent(curtainInfo, true));
+ break outter;
+ }
+
+ }
+
+ }
+
+
+ } else {
+ HDLLog.I("handleCurtainStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷");
+ }
+ }
+ break outter;
+ }
+ }
+ }
+
+ /**
+ * 澶勭悊绌鸿皟璁惧鐘舵�佹暟鎹�
+ * 20190726鏂板
+ *
+ * @param getDatas
+ */
+ private static void handleAirStateData(UdpDataBean getDatas) {
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (infos.get(j).getBigType() == Configuration.AIR_BIG_TYPE
+ && infos.get(j).getDeviceType() == HDLApConfig.TYPE_AC_PANEL) {//2019-07-26
+ isGetDeviceStateSuccess = true;
+ AppliancesInfo appliancesInfo = devicesDataList.get(i).getAppliancesInfoList().get(j);
+ appliancesInfo.setArrCurState(getDatas.addBytes);
+ byte[] airBytes = appliancesInfo.getArrCurState();
+ switch (getDatas.addBytes[0] & 0xff) {
+ case AirCtrlParser.airSwich:
+ airBytes[0] = getDatas.addBytes[1];
+ break;
+ case AirCtrlParser.airMode:
+ airBytes[1] = getDatas.addBytes[1];
+ break;
+ case AirCtrlParser.refTem:
+ case AirCtrlParser.heatTem:
+ case AirCtrlParser.autoTem:
+ case AirCtrlParser.dehumTem:
+ airBytes[2] = getDatas.addBytes[1];
+ break;
+ case AirCtrlParser.airSpeed:
+ airBytes[3] = getDatas.addBytes[1];
+ break;
+ default:
+ break;
+ }
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(airBytes);
+
+ //涓婂崌銆佷笅闄嶆俯搴︿笉杩斿洖
+ if ((getDatas.addBytes[0] & 0xff) != 9 && (getDatas.addBytes[0] & 0xff) != 10) {
+ EventBus.getDefault().post(new DeviceStateEvent(appliancesInfo, true));
+ }
+ } else {
+ HDLLog.I("handleAirStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷");
+ }
+ }
+ break outter;
+ }
+ }
+ }
+
+ /**
+ * 璇诲彇鍦烘櫙鍙峰弽棣�
+ *
+ * @param getDatas
+ */
+ private static void handleLOGICStateData(UdpDataBean getDatas) {
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if ((infos.get(j).getBigType() == Configuration.LOGIC_BIG_TYPE
+ || infos.get(j).getBigType() == Configuration.GLOBAL_LOGIC_BIG_TYPE)
+ && infos.get(j).getLogicMode().getAreaNum() == (getDatas.addBytes[0] & 0xFF)
+ ) {
+
+ AppliancesInfo sceneInfo = infos.get(j);
+ LogicMode logicMode = new LogicMode();
+ logicMode.setAreaNum(getDatas.addBytes[0] & 0xFF);
+ logicMode.setAreaSceneNum(getDatas.addBytes[1] & 0xFF);
+ sceneInfo.setLogicMode(logicMode);
+
+ LogicCtrlBackInfo logicCtrlBackInfo = new LogicCtrlBackInfo();
+ logicCtrlBackInfo.setAppliancesInfo(sceneInfo);
+ logicCtrlBackInfo.setAreaNum(getDatas.addBytes[0] & 0xFF);
+ logicCtrlBackInfo.setSceneNum(getDatas.addBytes[1] & 0xFF);
+ isGetDeviceStateSuccess = true;
+ EventBus.getDefault().post(new LogicFeedBackEvent(logicCtrlBackInfo, true));
+
+ break outter;
+ } else {
+ HDLLog.I("handleLOGICStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷");
+ }
+ }
+ break outter;
+ }
+ }
+ }
+
+ /**
+ * 璇诲彇瀹夐槻璁剧疆鍙嶉
+ * 20190729鏂板
+ *
+ * @param getDatas
+ */
+ private static void handleSecurityStateData(UdpDataBean getDatas) {
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (infos.get(j).getBigType() == Configuration.SECURITY_BIG_TYPE
+ && infos.get(j).getDeviceType() == HDLApConfig.TYPE_SECURITY_MODULE
+ && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-07-29
+ if (getDatas.addBytes.length >= 2) {
+ isGetDeviceStateSuccess = true;
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes);
+ EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true));
+ } else {
+ isGetDeviceStateSuccess = true;
+ EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), false));
+ HDLLog.I("handleSecurityStateData 杩斿洖addBytes鏁版嵁寮傚父");
+ }
+ break outter;
+ } else {
+ HDLLog.I("handleSecurityStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷");
+ }
+ }
+ break outter;
+ }
+ }
+ }
+
+ /**
+ * 璇诲彇HVAC鐘舵�佸弽棣�
+ *
+ * @param getDatas
+ */
+ private static void handleHVACStateData(UdpDataBean getDatas) {
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (infos.get(j).getBigType() == Configuration.AIR_BIG_TYPE
+ && infos.get(j).getDeviceType() == HDLApConfig.TYPE_AC_HVAC
+ && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-8-6
+
+ isGetDeviceStateSuccess = true;
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes);
+ EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true));
+ break outter;
+ } else {
+ HDLLog.I("handleHVACStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷");
+ }
+ }
+ break outter;
+ }
+ }
+ }
+
+
+ /**
+ * 骞叉帴鐐瑰箍鎾姸鎬佸弽棣堝弽棣�
+ * 20191105鏂板
+ *
+ * @param getDatas
+ */
+ private static void handleDryContactBroadcastStateData(UdpDataBean getDatas) {
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (infos.get(j).getBigType() == Configuration.SENSOR_BIG_TYPE
+ && infos.get(j).getChannelNum() == (getDatas.addBytes[1] & 0xFF)) {//2019-07-29
+ if (getDatas.addBytes.length >= 3) {
+ isGetDeviceStateSuccess = true;
+ int state = getDatas.addBytes[2] & 0xFF;
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(state);
+// devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes);
+ EventBus.getDefault().post(new DryContactSensorBackEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true, state));
+ } else {
+ isGetDeviceStateSuccess = true;
+ EventBus.getDefault().post(new DryContactSensorBackEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), false));
+ HDLLog.I("DryContac 杩斿洖addBytes鏁版嵁寮傚父");
+ }
+ break outter;
+ } else {
+// HDLLog.I("DryContac 娌℃湁鎵惧埌鍖归厤绫诲瀷");
+ }
+ }
+ break outter;
+ }
+ }
+ }
+
+ /**
+ * 閫氱敤寮�鍏虫帶鍒跺弽棣�
+ *
+ * @param getDatas
+ */
+ private static void handleCommonSwitchCtrlData(UdpDataBean getDatas) {
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID) {
+
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (infos.get(j).getBigType() == Configuration.COMMON_SWITCH_BIG_TYPE
+ && infos.get(j).getDeviceType() == HDLApConfig.TYPE_COMMON_SWITCH) {
+
+ if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {
+ //澶х被銆佸皬绫汇�佸洖璺彿閮藉尮閰�
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[1] & 0xFF);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[1] & 0xFF);
+ AppliancesInfo mSwitchInfo = infos.get(j);
+ CommonSwitchBackInfo info = new CommonSwitchBackInfo();
+ info.setAppliancesInfo(mSwitchInfo);
+ info.setSwitchNum(getDatas.addBytes[0] & 0xFF);
+ info.setSwitchState(getDatas.addBytes[1] & 0xFF);
+ setDeviceCtrlSuccessStateWithInfo(infos.get(j), true);
+ EventBus.getDefault().post(new CommonSwitchCtrlBackEvent(info, true));
+ break outter;//璺冲嚭寰幆
+ }
+ }
+ }
+
+ break outter;//璺冲嚭寰幆
+ }
+ }
+ }
+
+ /**
+ * 閫氱敤寮�鍏宠鐘舵�佸弽棣堝弽棣�
+ *
+ * @param getDatas
+ */
+ private static void handleCommonSwitchStateData(UdpDataBean getDatas) {
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID) {
+
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (infos.get(j).getBigType() == Configuration.COMMON_SWITCH_BIG_TYPE
+ && infos.get(j).getDeviceType() == HDLApConfig.TYPE_COMMON_SWITCH) {
+
+ if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {
+ //澶х被銆佸皬绫汇�佸洖璺彿閮藉尮閰�
+ if (getDatas.addBytes.length >= 2) {
+ isGetDeviceStateSuccess = true;
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[1] & 0xFF);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[1] & 0xFF);
+ AppliancesInfo mSwitchInfo = infos.get(j);
+ CommonSwitchBackInfo info = new CommonSwitchBackInfo();
+ info.setAppliancesInfo(mSwitchInfo);
+ info.setSwitchNum(getDatas.addBytes[0] & 0xFF);
+ info.setSwitchState(getDatas.addBytes[1] & 0xFF);
+ EventBus.getDefault().post(new CommonSwitchStateBackEvent(info, true));
+ }
+ break outter;//璺冲嚭寰幆
+ }
+ }
+ }
+
+ break outter;//璺冲嚭寰幆
+ }
+ }
+ }
+
+// /**
+// * 璇诲彇HVAC鐘舵�佸弽棣�
+// *
+// * @param getDatas
+// */
+// private static void handleHVACStateData(UdpDataBean getDatas) {
+// int count = getDatas.addBytes.length / 11;
+//
+// for (int airIndex = 0; airIndex < count; airIndex++) {
+// outter:
+// for (int indexI = 0, len = devicesDataList.size(); indexI < len; indexI++) {
+// if (devicesDataList.get(indexI).getSourceSubnetID() == getDatas.sourceSubnetID
+// && devicesDataList.get(indexI).getSourceDeviceID() == getDatas.sourceDeviceID
+// ) {
+// List<AppliancesInfo> infos = devicesDataList.get(indexI).getAppliancesInfoList();
+// for (int indexJ = 0, len2 = infos.size(); indexJ < len2; indexJ++) {
+// if (infos.get(indexJ).getBigType() == Configuration.AIR_BIG_TYPE
+// && infos.get(indexJ).getDeviceType() != HDLApConfig.TYPE_AC_PANEL
+// && infos.get(indexJ).getChannelNum() == (getDatas.addBytes[airIndex * 11] & 0xFF)) {
+// AppliancesInfo appliancesInfo = devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ);
+//
+// switch (getDatas.addBytes[airIndex * 11] & 0xff) {
+// case 1:
+// handleAirCastData(getDatas, air1Info, airIndex, appliancesInfo);
+// air1Info[0] = getDatas.addBytes[1 + 0 * 11];
+// air1Info[1] = (byte) ((getDatas.addBytes[3 + 0 * 11] & 0xf0) >> 4);
+// switch (air1Info[0] & 0xff) {
+// case 0:
+// air1Info[2] = getDatas.addBytes[2 + 0 * 11];
+// break;
+// case 1:
+// air1Info[2] = getDatas.addBytes[6 + 0 * 11];
+// break;
+// case 3:
+// air1Info[2] = getDatas.addBytes[8 + 0 * 11];
+// break;
+// case 4:
+// air1Info[2] = getDatas.addBytes[9 + 0 * 11];
+// break;
+//
+// }
+//
+// air1Info[3] = (byte) (getDatas.addBytes[3 + 0 * 11] & 0x0f);
+// air1Info[4] = getDatas.addBytes[5 + 0 * 11];
+// air1Info[5] = getDatas.addBytes[10 + 0 * 11];
+//// HDLLog.info( "209a air1Info = " + air1Info[0] + " " + air1Info[1] + " " + air1Info[2] + " " + air1Info[3] + " " + air1Info[4] + " " + air1Info[5]);
+//// String arrString = "209a 闄勫姞鏁版嵁锛�";
+//// for (int i = 0; i < getDatas.addBytes.length; i++) {
+//// arrString += (getDatas.addBytes[i] & 0xff) + ",";
+//// }
+//// HDLLog.info( arrString);
+// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air1Info);
+// break;
+// case 2:
+// handleAirCastData(getDatas, air2Info, airIndex, appliancesInfo);
+// air2Info[0] = getDatas.addBytes[1 + 1 * 11];
+// air2Info[1] = (byte) ((getDatas.addBytes[3 + 1 * 11] & 0xf0) >> 4);
+// switch (air2Info[0] & 0xff) {
+// case 0:
+// air2Info[2] = getDatas.addBytes[2 + 1 * 11];
+// break;
+// case 1:
+// air2Info[2] = getDatas.addBytes[6 + 1 * 11];
+// break;
+// case 3:
+// air2Info[2] = getDatas.addBytes[8 + 1 * 11];
+// break;
+// case 4:
+// air2Info[2] = getDatas.addBytes[9 + 1 * 11];
+// break;
+//
+// }
+// air2Info[3] = (byte) (getDatas.addBytes[3 + 1 * 11] & 0x0f);
+// air2Info[4] = getDatas.addBytes[5 + 1 * 11];
+// air2Info[5] = getDatas.addBytes[10 + 1 * 11];
+// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air2Info);
+// break;
+// case 3:
+// handleAirCastData(getDatas, air3Info, airIndex, appliancesInfo);
+// air3Info[0] = getDatas.addBytes[1 + 2 * 11];
+// air3Info[1] = (byte) ((getDatas.addBytes[3 + 2 * 11] & 0xf0) >> 4);
+// switch (air3Info[0] & 0xff) {
+// case 0:
+// air3Info[2] = getDatas.addBytes[2 + 2 * 11];
+// break;
+// case 1:
+// air3Info[2] = getDatas.addBytes[6 + 2 * 11];
+// break;
+// case 3:
+// air3Info[2] = getDatas.addBytes[8 + 2 * 11];
+// break;
+// case 4:
+// air3Info[2] = getDatas.addBytes[9 + 2 * 11];
+// break;
+// }
+// air3Info[3] = (byte) (getDatas.addBytes[3 + 2 * 11] & 0x0f);
+// air3Info[4] = getDatas.addBytes[5 + 2 * 11];
+// air3Info[5] = getDatas.addBytes[10 + 2 * 11];
+// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air3Info);
+// break;
+// case 4:
+// handleAirCastData(getDatas, air4Info, airIndex, appliancesInfo);
+// air4Info[0] = getDatas.addBytes[1 + 3 * 11];
+// air4Info[1] = (byte) ((getDatas.addBytes[3 + 3 * 11] & 0xf0) >> 4);
+// switch (air4Info[0] & 0xff) {
+// case 0:
+// air4Info[2] = getDatas.addBytes[2 + 3 * 11];
+// break;
+// case 1:
+// air4Info[2] = getDatas.addBytes[6 + 3 * 11];
+// break;
+// case 3:
+// air4Info[2] = getDatas.addBytes[8 + 3 * 11];
+// break;
+// case 4:
+// air4Info[2] = getDatas.addBytes[9 + 3 * 11];
+// break;
+// }
+// air4Info[3] = (byte) (getDatas.addBytes[3 + 3 * 11] & 0x0f);
+// air4Info[4] = getDatas.addBytes[5 + 3 * 11];
+// air4Info[5] = getDatas.addBytes[10 + 3 * 11];
+// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air4Info);
+// break;
+//
+// }
+// }
+//
+// }
+// }
+// }
+//
+//
+// }
+//
+//
+// }
+//
+//
+// /**
+// * 澶勭悊瀹跺眳绌鸿皟骞挎挱娑堟伅
+// *
+// * @param getDatas
+// * @param airInfo
+// * @param airIndex
+// * @param oldInfo
+// */
+// private static void handleAirCastData(UdpDataBean getDatas, final byte[] airInfo, int airIndex, final AppliancesInfo oldInfo) {
+// if (airInfo[0] != getDatas.addBytes[1 + airIndex * 11]) {
+//
+//// EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+// new Timer().schedule(new TimerTask() {
+// @Override
+// public void run() {
+// final AppliancesInfo newInfo = oldInfo;
+// newInfo.setArrCurState(new byte[]{AirCtrlParser.airSwich, airInfo[0]});
+//// HDLLog.info( "0x209A in 绌鸿皟寮�鍏虫敼鍙�" + " appliancesInfo subid = " + newInfo.getDeviceSubnetID()
+//// + " devID = " + newInfo.getDeviceDeviceID() + " 鍥炶矾鍙凤細" + newInfo.getChannelNum() + " devType" + newInfo.getDeviceType());
+// EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+// }
+// }, 500);
+// }
+//
+//// HDLLog.info( "airIndex = " + airIndex + " 209a 妯″紡鍊� = " + ((getDatas.addBytes[3 + airIndex * 11] & 0xf0) >> 4) + " 鎴� = " + ((getDatas.addBytes[7 + airIndex * 11] & 0xf0) >> 4));
+// if (airInfo[1] != (byte) ((getDatas.addBytes[3 + airIndex * 11] & 0xf0) >> 4)) {
+// new Timer().schedule(new TimerTask() {
+// @Override
+// public void run() {
+// final AppliancesInfo newInfo = oldInfo;
+// newInfo.setArrCurState(new byte[]{AirCtrlParser.airMode, airInfo[1]});
+//// HDLLog.info( "0x209A in 绌鸿皟妯″紡鏀瑰彉" + " appliancesInfo subid = " + newInfo.getDeviceSubnetID()
+//// + " devID = " + newInfo.getDeviceDeviceID() + " 鍥炶矾鍙凤細" + newInfo.getChannelNum() + " devType" + newInfo.getDeviceType());
+// EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+// }
+// }, 1000);
+// }
+//
+//
+// switch (airInfo[1] & 0xff) {
+// case 0:
+// if (airInfo[2] != getDatas.addBytes[2 + airIndex * 11]) {
+// new Timer().schedule(new TimerTask() {
+// @Override
+// public void run() {
+// final AppliancesInfo newInfo = oldInfo;
+// newInfo.setArrCurState(new byte[]{AirCtrlParser.refTem, airInfo[2]});
+//// HDLLog.info( "0x209A in 绌鸿皟娓╁害鏀瑰彉" + " appliancesInfo subid = " + newInfo.getDeviceSubnetID()
+//// + " devID = " + newInfo.getDeviceDeviceID() + " 鍥炶矾鍙凤細" + newInfo.getChannelNum() + " devType" + newInfo.getDeviceType());
+// EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+// }
+// }, 1500);
+// }
+//
+// break;
+// case 1:
+// if (airInfo[2] != getDatas.addBytes[6 + airIndex * 11]) {
+//// airInfo[2] = getDatas.addBytes[6 + airIndex * 11];
+//
+//// EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+// new Timer().schedule(new TimerTask() {
+// @Override
+// public void run() {
+// final AppliancesInfo newInfo = oldInfo;
+// newInfo.setArrCurState(new byte[]{AirCtrlParser.heatTem, airInfo[2]});
+//// HDLLog.info( "0x209A in 绌鸿皟娓╁害鏀瑰彉" + " appliancesInfo subid = " + newInfo.getDeviceSubnetID()
+//// + " devID = " + newInfo.getDeviceDeviceID() + " 鍥炶矾鍙凤細" + newInfo.getChannelNum() + " devType" + newInfo.getDeviceType());
+// EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+// }
+// }, 1500);
+// }
+//
+// break;
+// case 3:
+// if (airInfo[2] != getDatas.addBytes[8 + airIndex * 11]) {
+//// airInfo[2] = getDatas.addBytes[8 + airIndex * 11];
+//
+//// EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+// new Timer().schedule(new TimerTask() {
+// @Override
+// public void run() {
+// final AppliancesInfo newInfo = oldInfo;
+// newInfo.setArrCurState(new byte[]{AirCtrlParser.autoTem, airInfo[2]});
+//// HDLLog.info( "0x209A in 绌鸿皟娓╁害鏀瑰彉" + " appliancesInfo subid = " + newInfo.getDeviceSubnetID()
+//// + " devID = " + newInfo.getDeviceDeviceID() + " 鍥炶矾鍙凤細" + newInfo.getChannelNum() + " devType" + newInfo.getDeviceType());
+// EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+// }
+// }, 1500);
+// }
+//
+// break;
+// case 4:
+// if (airInfo[2] != getDatas.addBytes[9 + airIndex * 11]) {
+//// airInfo[2] = getDatas.addBytes[9 + airIndex * 11];
+//
+//// EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+// new Timer().schedule(new TimerTask() {
+// @Override
+// public void run() {
+// final AppliancesInfo newInfo = oldInfo;
+// newInfo.setArrCurState(new byte[]{AirCtrlParser.dehumTem, airInfo[2]});
+//// HDLLog.info( "0x209A in 绌鸿皟娓╁害鏀瑰彉" + " appliancesInfo subid = " + newInfo.getDeviceSubnetID()
+//// + " devID = " + newInfo.getDeviceDeviceID() + " 鍥炶矾鍙凤細" + newInfo.getChannelNum() + " devType" + newInfo.getDeviceType());
+// EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+// }
+// }, 1500);
+// }
+//
+// break;
+// }
+//
+//// HDLLog.info( "airInfo[3] = " + (airInfo[3] & 0xff) + " 绗�3浣� 浣�4浣嶉閫� = "+(getDatas.addBytes[3 + airIndex * 11] & 0x0f));
+//// HDLLog.info( "airInfo[3] = " + (airInfo[3] & 0xff) + " 绗�7浣� 浣�4浣嶉閫� = "+(getDatas.addBytes[7 + airIndex * 11] & 0x0f));
+// if (airInfo[3] != (byte) (getDatas.addBytes[3 + airIndex * 11] & 0x0f)) {
+//// airInfo[3] = (byte) (getDatas.addBytes[3 + airIndex * 11] & 0x0f);
+//
+//// EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+//
+// new Timer().schedule(new TimerTask() {
+// @Override
+// public void run() {
+//
+// final AppliancesInfo newInfo = oldInfo;
+// newInfo.setArrCurState(new byte[]{AirCtrlParser.airSpeed, airInfo[3]});
+//// HDLLog.info( "绌鸿皟椋庨�熸敼鍙�" + " appliancesInfo subid = " + newInfo.getDeviceSubnetID()
+//// + " devID = " + newInfo.getDeviceDeviceID() + " 鍥炶矾鍙凤細" + newInfo.getChannelNum() + " devType" + newInfo.getDeviceType());
+//// HDLLog.info( "鍙戦�佺┖璋冩敼鍙橀閫焏ata = " + Arrays.toString(newInfo.getArrCurState()));
+// EventBus.getDefault().post(new DeviceStateEvent(newInfo, true));
+// }
+// }, 2000);
+// }
+//
+// //瀹ゆ俯銆佹憜椋庢病鏈夎繑鍥炪�備笅涓増鏈渶瑕佽�冭檻
+// if (airInfo[4] != getDatas.addBytes[5 + airIndex * 11]) {
+//// airInfo[4] = getDatas.addBytes[5 + airIndex * 11];
+// }
+//
+// if (airInfo[5] != getDatas.addBytes[10 + airIndex * 11]) {
+//// airInfo[5] = getDatas.addBytes[10 + airIndex * 11];
+// }
+// }
+
+ /**
+ * 姝ゆ柟娉曞熀鏈病鐢ㄥ埌锛岄�昏緫妯″潡鐨勬帶鍒朵俊鎭凡缁忓湪handleCtrlData涓鐞嗚繃浜�
+ * <p>
+ * 澶勭悊閫昏緫妯″潡鏁版嵁
+ *
+ * @param getDatas
+ */
+ private static void handleLogicData(UdpDataBean getDatas) {
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum() == ((byte) (getDatas.addBytes[2] & 0xFF) & 0xFF)) {
+ LogicMode logicMode = new LogicMode();
+ logicMode.setAreaNum((byte) (getDatas.addBytes[23] & 0xFF) & 0xFF);
+ logicMode.setAreaSceneNum((byte) (getDatas.addBytes[24] & 0xFF) & 0xFF);
+ byte[] remark = new byte[20];
+ System.arraycopy(getDatas.addBytes, 3, remark, 0, remark.length);
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setRemarks(HDLStringUtils.byte2String(remark));
+ devicesDataList.get(i).getAppliancesInfoList().get(j).setLogicMode(logicMode);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * 澶勭悊璀︽姤鏁版嵁
+ *
+ * @param getDatas
+ */
+ private static void handleWarningData(UdpDataBean getDatas) {
+ int warningTypeId = 0;
+ if (getDatas.addBytes.length == 4) {
+ warningTypeId = (getDatas.addBytes[2] & 0xFF) * 256 + (getDatas.addBytes[3] & 0xFF);
+ EventBus.getDefault().post(new WarningInfoEvent(warningTypeId));
+ Intent warningIntent = new Intent();
+ warningIntent.setAction("com.hdl.action.WARNING");
+ warningIntent.putExtra("HdlWarning", warningTypeId);
+ viewContext.sendBroadcast(warningIntent);
+ } else {
+ warningTypeId = getDatas.addBytes[2] & 0xFF;
+ EventBus.getDefault().post(new WarningInfoEvent(warningTypeId));
+ Intent warningIntent = new Intent();
+ warningIntent.setAction("com.hdl.action.WARNING");
+ warningIntent.putExtra("HdlWarning", warningTypeId);//2019-07
+ viewContext.sendBroadcast(warningIntent);
+ }
+
+
+ Intent warningIntent = new Intent();
+ warningIntent.setAction("com.hdl.devices.warning");
+ warningIntent.putExtra("HdlWarning",
+ WarningType.getWarningType((getDatas.addBytes[2] & 0xFF) * 256 + (getDatas.addBytes[3] & 0xFF)));
+ viewContext.sendBroadcast(warningIntent);
+ }
+
+ /**
+ * 澶勭悊HDL闊充箰鍗忚
+ *
+ * @param getDatas
+ */
+ private static void handleAudioData(UdpDataBean getDatas) {
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID
+ ) {
+ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList();
+ for (int j = 0, len2 = infos.size(); j < len2; j++) {
+ if (infos.get(j).getBigType() == Configuration.AUDIO_BIG_TYPE) {
+ //鏆傛椂鍙敮鎸佹棫鐗堣儗鏅煶涔�
+ if (infos.get(j).getDeviceType() == HDLApConfig.TYPE_MUSIC_MODULE) {
+ HDLAudio.parseAudioData(getDatas, infos.get(j));
+ }
+ break outter;
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
+ * 淇濆瓨璁惧鏁版嵁鍒楄〃
+ * 鏍规嵁闇�瑕侊紝瀹炴椂淇濆瓨褰撳墠鏁版嵁
+ *
+ * @return boolean
+ */
+ public static boolean saveDevicesDataList() {
+ try {
+ Gson gson = new Gson();
+ String jsonStr = gson.toJson(devicesDataList); //灏哃ist杞崲鎴怞son
+// HDLLog.I("saveDevicesDataList: \n" + jsonStr);
+ SPUtils.setParam(viewContext, SPUtils.KEY_DEVICE_DATA_LIST, jsonStr);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * 鍔犺浇鏈湴璁惧鏁版嵁鍒楄〃
+ *
+ * @return devicesDataList
+ */
+ public static List<DevicesData> getLocalDevicesDataList() {
+ try {
+ String getJsonStr = SPUtils.getParam(viewContext, SPUtils.KEY_DEVICE_DATA_LIST, "").toString();
+// HDLLog.I("getJsonStr: \n" + getJsonStr);
+ if (!TextUtils.isEmpty(getJsonStr)) //闃茬┖鍒ゆ柇
+ {
+ Gson gson = new Gson();
+ devicesDataList = gson.fromJson(getJsonStr, new TypeToken<List<DevicesData>>() {
+ }.getType()); //灏唈son瀛楃涓茶浆鎹㈡垚List闆嗗悎
+
+
+ }
+ } catch (JsonSyntaxException e) {
+ e.printStackTrace();
+ }
+ if (devicesDataList == null) devicesDataList = new ArrayList<>();
+ List<DevicesData> devicesDataList2 = devicesDataList;
+ setRemarkList();//鍔犺浇澶囨敞list
+ return devicesDataList2;
+ }
+
+
+ private static void setRemarkList() {
+ listRemarks.clear();
+ for (int j = 0; j < devicesDataList.size(); j++) {
+ if (devicesDataList.get(j).getAppliancesInfoList().get(0).getBigType() != Configuration.AUDIO_BIG_TYPE) {
+ for (int i = 0, len = devicesDataList.get(j).getAppliancesInfoList().size(); i < len; i++) {
+ ListRemarks listRemarksTemp = new ListRemarks();
+ listRemarksTemp.setCallBack(false);
+ listRemarksTemp.setAppliancesInfo(devicesDataList.get(j).getAppliancesInfoList().get(i));
+ listRemarks.add(listRemarksTemp);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * 澶勭悊MCU杩斿洖鐨勫懡浠ゆ暟鎹�
+ *
+ * @param mMCUDataBean
+ */
+ public static void HandleMCUData(MCUDataBean mMCUDataBean) {
+ isMCUCtrlSuccess = true;
+ switch (mMCUDataBean.command) {
+ case MCUConstants.MCU_COMMAND_SEND_BACK: //0x80 涓婃姤鏁版嵁 閫忎紶鐨勮瘽鐩存帴杩斿洖
+ case MCUConstants.MCU_DETECT_PACKET_LOSS_STATUS_BACK://0x81 妫�娴嬩涪鍖呯姸鎬佽繑鍥�
+ case MCUConstants.MCU_REQUEST_UPGRADE_BACK: //0x84 璇锋眰鍗囩骇杩斿洖
+ //涓婇潰3绉嶈繑鍥炴暟鎹洿鎺ヨ繑鍥烇紝鍏堜笉澶勭悊
+ EventBus.getDefault().post(new MCUFeedBackEvent(mMCUDataBean, EventCode.SUCCESS));
+ break;
+ case MCUConstants.MCU_READ_CONFIGURATION_BACK: //0x82 璇婚厤缃繑鍥�
+ case MCUConstants.MCU_WRITE_CONFIGURATION_BACK: //0x83 鍐欓厤缃俊鎭繑鍥�
+ if (mMCUDataBean.receiveBytes.length > 5) {
+ MCUConfigurationBean mcuConfigurationBean = new MCUConfigurationBean();
+ mcuConfigurationBean.setMcuAgreementType(mMCUDataBean.receiveBytes[0] & 0xFF);
+ mcuConfigurationBean.setMcuBaudrate(mMCUDataBean.receiveBytes[1] & 0xFF);
+ mcuConfigurationBean.setMcuStartBit(mMCUDataBean.receiveBytes[2] & 0xFF);
+ mcuConfigurationBean.setMcuDataBit(mMCUDataBean.receiveBytes[3] & 0xFF);
+ mcuConfigurationBean.setMcuCheckBit(mMCUDataBean.receiveBytes[4] & 0xFF);
+ mcuConfigurationBean.setMcuStopBit(mMCUDataBean.receiveBytes[5] & 0xFF);
+ mMCUDataBean.setMCUConfigurationBean(mcuConfigurationBean);
+
+ EventBus.getDefault().post(new MCUFeedBackEvent(mMCUDataBean, EventCode.SUCCESS));
+ } else {
+ EventBus.getDefault().post(new MCUFeedBackEvent(mMCUDataBean, EventCode.FAILURE_DATA_ERROR, "鏁版嵁寮傚父"));
+ }
+
+ break;
+ case MCUConstants.MCU_RESTART_BACK: //0x86 閲嶅惎杩斿洖
+ if (mMCUDataBean.receiveBytes.length > 0) {
+ if ((mMCUDataBean.receiveBytes[0] & 0xFF) == 0xF8) {
+ //閲嶅惎鎴愬姛鎴栬�呭崌绾ф垚鍔熷悗閲嶅惎鎴愬姛
+ EventBus.getDefault().post(new MCUFeedBackEvent(mMCUDataBean, EventCode.SUCCESS));
+ }
+// else {
+//// 閲嶅惎澶辫触
+// EventBus.getDefault().post(new MCUFeedBackEvent(mMCUDataBean, EventCode.FAILURE_TIMEOUT, "閲嶅惎澶辫触"));
+// }
+ }
+
+ break;
+ default:
+ break;
+ }
+ }
+
+
+ /**
+ * 璁剧疆鎺у埗鏄惁鎴愬姛鐘舵��
+ *
+ * @param info
+ * @param success
+ */
+ public static void setDeviceCtrlSuccessStateWithInfo(AppliancesInfo info, Boolean success) {
+// if(info.getDeviceKey() == null) return;
+
+ ctrlSuccessStateHashMap.put(info.getDeviceKey(), success);
+ }
+
+ /**
+ * 鑾峰彇鏄惁鎺у埗鎴愬姛
+ *
+ * @param info
+ * @return 缁撴灉
+ */
+ public static Boolean getDeviceCtrlSuccessStateWithInfo(AppliancesInfo info) {
+// if(info.getDeviceKey() == null) return false;
+
+ Boolean success = ctrlSuccessStateHashMap.get(info.getDeviceKey());
+ if (success == null) success = false;
+ return success;
+ }
+
+ /**
+ * 鎵嬪姩娣诲姞涓�涓畨闃叉ā鍧�
+ *
+ * @param mSubnetID 瀛愮綉鍙�
+ * @param mDeviceID 璁惧鍙�
+ * @param mChannelNum 鍖哄彿
+ * @param mRemarks 澶囨敞
+ * @return Boolean
+ */
+ public static boolean addSecurityDevicesManually(int mSubnetID, int mDeviceID, int mChannelNum, String mRemarks) {
+ return addDevicesManuallyWithoutSearching(Configuration.SECURITY_BIG_TYPE, 0, mSubnetID, mDeviceID, mChannelNum, mRemarks);
+ }
+
+ /**
+ * 鎵嬪姩娣诲姞涓�涓煶涔愭挱鏀惧櫒妯″潡
+ *
+ * @param mSubnetID 瀛愮綉鍙�
+ * @param mDeviceID 璁惧鍙�
+ * @param mChannelNum 鍖哄彿
+ * @param mRemarks 澶囨敞
+ * @return Boolean
+ */
+ public static boolean addAudioDevicesManually(int mSubnetID, int mDeviceID, int mChannelNum, String mRemarks) {
+ return addDevicesManuallyWithoutSearching(Configuration.AUDIO_BIG_TYPE, 0, mSubnetID, mDeviceID, mChannelNum, mRemarks);
+ }
+
+ /**
+ * 鎵嬪姩娣诲姞涓嶆敮鎸佺畝鏄撶紪绋嬫悳绱㈢殑璁惧
+ * 娣诲姞瀛愮綉鍙� 璁惧鍙� 涓嶅瓨鍦�
+ *
+ * @param mBigType
+ * @param mLittleType
+ * @param mSubnetID
+ * @param mDeviceID
+ * @param mChannelNum
+ * @param mRemarks
+ * @return
+ */
+ public static boolean addDevicesManuallyWithoutSearchingWithNewDevice(int mBigType, int mLittleType, int mSubnetID, int mDeviceID, int mChannelNum, String mRemarks) {
+ try {
+ DevicesData mDevicesData = DeviceParser.addDevicesManuallyWithoutSearching(mBigType, mLittleType, mSubnetID, mDeviceID, mChannelNum, mRemarks);
+ if (mDevicesData != null) {
+ devicesDataList.add(mDevicesData);
+ HandleSearch.OnDeviceListGetSuccessCallBack();
+ HDLLog.I("鏀寔鐨勮澶囷紝鍏佽娣诲姞");
+ return true;
+ } else {
+ HDLLog.I("涓嶆敮鎸佺殑璁惧锛屼笉鍏佽娣诲姞");
+ return false;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+// HDLLog.I("涓嶆敮鎸佺殑璁惧锛屼笉鍏佽娣诲姞");
+ return false;
+ }
+ }
+
+ /**
+ * 鎵嬪姩娣诲姞涓嶆敮鎸佺畝鏄撶紪绋嬫悳绱㈢殑璁惧
+ *
+ * @param mBigType
+ * @param mLittleType
+ * @param mSubnetID
+ * @param mDeviceID
+ * @param mChannelNum
+ * @param mRemarks
+ * @return
+ */
+ public static boolean addDevicesManuallyWithoutSearching(int mBigType, int mLittleType, int mSubnetID, int mDeviceID, int mChannelNum, String mRemarks) {
+ try {
+
+ if (!DeviceParser.isWantData(mBigType, mLittleType)) {//鍒ゆ柇鏄惁鏀寔鐨勫ぇ绫诲皬绫�
+ return false;//涓嶆敮鎸佽繑鍥炲け璐�
+ }
+
+ boolean bExistSubnetID = false;
+ boolean bCanAdd = false;
+ outter:
+ for (int i = 0, len = devicesDataList.size(); i < len; i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == mSubnetID
+ && devicesDataList.get(i).getSourceDeviceID() == mDeviceID
+ ) {
+ bExistSubnetID = true;
+ DevicesData mDevicesData = devicesDataList.get(i);
+ bCanAdd = getIfCanAddDevice(mDevicesData.getAppliancesInfoList(), mBigType, mLittleType, mChannelNum);
+ if (bCanAdd) {//娣诲姞瀛愮綉鍙� 璁惧鍙� 宸插瓨鍦紝骞朵笖娌℃湁鐩稿悓鐨勫瓙缃戝彿璁惧鍙�
+ AppliancesInfo mAppliancesInfo = DeviceParser.getDevicesInfo(mDevicesData, mBigType, mLittleType, mChannelNum, mRemarks, mRemarks);
+ devicesDataList.get(i).getAppliancesInfoList().add(mAppliancesInfo);
+ HandleSearch.OnDeviceListGetSuccessCallBack();
+ HDLLog.I("鏀寔鐨勮澶囷紝鍏佽娣诲姞");
+ }
+ break outter;
+ }
+ }
+
+ if (!bExistSubnetID) {
+ return addDevicesManuallyWithoutSearchingWithNewDevice(mBigType, mLittleType, mSubnetID, mDeviceID, mChannelNum, mRemarks);
+ }
+
+ return bCanAdd;
+
+ } catch (Exception e) {
+ e.printStackTrace();
+// HDLLog.I("涓嶆敮鎸佺殑璁惧锛屼笉鍏佽娣诲姞");
+ return false;
+ }
+ }
+
+ /**
+ * 鍒ゆ柇鏄惁瀛樺湪 鐩稿悓澶х被銆佸皬绫汇�佸洖璺殑璁惧
+ *
+ * @param appliancesInfoList
+ * @param mBigType
+ * @param mLittleType
+ * @param mChannelNum
+ * @return
+ */
+ private static boolean getIfCanAddDevice(List<AppliancesInfo> appliancesInfoList, int mBigType, int mLittleType, int mChannelNum) {
+ boolean bCanAddN = true;
+ for (int i = 0, len = appliancesInfoList.size(); i < len; i++) {
+ if (appliancesInfoList.get(i).getBigType() == mBigType
+ && appliancesInfoList.get(i).getLittleType() == mLittleType
+ && appliancesInfoList.get(i).getChannelNum() == mChannelNum
+ ) {
+ bCanAddN = false;
+ }
+ }
+ return bCanAddN;
+ }
+
+
+ /**
+ * 娓呯┖璁惧鍒楄〃
+ * 2019-8-6
+ */
+ public static void clearAllDeviceList() {
+ devicesDataList.clear();
+ realDevicesDataList.clear();
+ listRemarks.clear();
+ HandleSearch.OnDeviceListGetSuccessCallBack();
+ }
+
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLSerialPortCore.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLSerialPortCore.java
new file mode 100644
index 0000000..ec3647e
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLSerialPortCore.java
@@ -0,0 +1,875 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Core;
+
+
+import android.serialport.api.SerialPort;
+import android.widget.TextView;
+
+import com.hdl.sdk.ttl.Config.Configuration;
+import com.hdl.sdk.ttl.Config.MCUConstants;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.MCUDataBean;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.UdpDataBean;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.EventCode;
+import com.hdl.sdk.ttl.HDLDeviceManger.HDLListener.IMcuOtaListener;
+import com.hdl.sdk.ttl.Utils.HDLUtlis.HDLStringUtils;
+import com.hdl.sdk.ttl.Utils.HDLUtlis.HDLUtlis;
+import com.hdl.sdk.ttl.Utils.LogUtils.HDLLog;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.InvalidParameterException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by JLChen on 2019/6/26
+ * 涓插彛绠$悊绫�
+ */
+public class HDLSerialPortCore {
+ //涓插彛璁惧璺緞鍚�
+ private static String mPathname = "/dev/ttyS2";
+ //娉㈢壒鐜�
+ private static int mBaudrate = 115200;
+
+ // public static SerialPortFinder mSerialPortFinder = new SerialPortFinder();
+ private static SerialPort mSerialPort = null;
+ private static InputStream mInputStream = null;
+ private static OutputStream mOutputStream = null;
+ // private static HDLReadDatasThread mHDLReadDatasThread = new HDLReadDatasThread();
+
+ // private static HDLRead485DatasThread mHDLRead485DatasThread = new HDLRead485DatasThread();
+ private static HDLReadMCUDatasThread mHDLReadMCUDatasThread = new HDLReadMCUDatasThread();
+ private static HDLSendDatasThread mHDLSendDatasThread = new HDLSendDatasThread();
+
+ public static List<byte[]> mSendDatasList = new ArrayList<byte[]>();//鍙戦�佹暟鎹槦鍒�
+ private static List<Byte> mReceiveDatasList = new ArrayList<Byte>();//鎺ユ敹鏁版嵁闃熷垪
+// private static List<Byte> mReceive485DatasList = new ArrayList<Byte>();//485鎺ユ敹鏁版嵁闃熷垪
+
+ public static Boolean bPassThrough = false; //鍒ゆ柇鏄惁閫忎紶
+ public static IMcuOtaListener mIMcuOtaListener;
+ public static byte[] upgradeFileDatas; //鍗囩骇鏂囦欢鏁版嵁
+
+ /*** 涓插彛鏄惁鎵撳紑鎴愬姛*/
+ private static boolean bOpenSuccess = false;
+
+// private static boolean b485DatascChangeStop = false;
+
+ public static SerialPort getSerialPort() throws SecurityException, IOException, InvalidParameterException {
+ if (mSerialPort == null) {
+ mSerialPort = new SerialPort(new File(mPathname), mBaudrate, 0);
+ mInputStream = mSerialPort.getInputStream();//璋冪敤瀵硅薄SerialPort鏂规硶锛岃幏鍙栦覆鍙d腑"璇诲拰鍐�"鐨勬暟鎹祦
+ mOutputStream = mSerialPort.getOutputStream();
+ bOpenSuccess = true;
+ }
+ return mSerialPort;
+ }
+
+ /**
+ * 鍒濆鍖栦覆鍙�
+ */
+ public static void initHDLSerialPort(String mmPathname, int mmBaudrate) {
+ openSerialPort(mmPathname, mmBaudrate);
+ }
+
+ /**
+ * 鍒ゆ柇涓插彛鏄惁鎵撳紑
+ */
+ public static Boolean getIsSerialPortOpen() {
+ return bOpenSuccess;
+ }
+
+ /**
+ * 鎵撳紑涓插彛锛屾帴鏀舵暟鎹�
+ * 閫氳繃涓插彛锛屾帴鏀跺崟鐗囨満鍙戦�佹潵鐨勬暟鎹�
+ */
+ public static Boolean openSerialPort(String mmPathname, int mmBaudrate) {
+ if (mSerialPort != null) {
+ HDLLog.I("HDLSDK 涓插彛 宸插惎鍔�");
+ } else {
+ HDLLog.I("HDLSDK 涓插彛 init");
+ try {
+ mPathname = mmPathname;
+ mBaudrate = mmBaudrate;
+ mSerialPort = new SerialPort(new File(mPathname), mBaudrate, 0);
+ HDLLog.I("HDLSDK 涓插彛鍚姩鎴愬姛");
+ //璋冪敤瀵硅薄SerialPort鏂规硶锛岃幏鍙栦覆鍙d腑"璇诲拰鍐�"鐨勬暟鎹祦
+ mInputStream = mSerialPort.getInputStream();
+ mOutputStream = mSerialPort.getOutputStream();
+ bOpenSuccess = true;
+ startHDLThread();
+ } catch (IOException e) {
+ e.printStackTrace();
+ bOpenSuccess = false;
+ HDLLog.I("HDLSDK 涓插彛鍚姩澶辫触 IOException");
+ } catch (InvalidParameterException e) {
+ e.printStackTrace();
+ bOpenSuccess = false;
+ HDLLog.I("HDLSDK 涓插彛鍚姩澶辫触 InvalidParameterException");
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ bOpenSuccess = false;
+ HDLLog.I("HDLSDK 涓插彛鍚姩澶辫触 SecurityException");
+ }
+ }
+ return bOpenSuccess;
+ }
+
+ /**
+ * 鍏抽棴涓插彛
+ * 鍏抽棴涓插彛涓殑杈撳叆杈撳嚭娴�
+ */
+ public static void closeSerialPort() {
+ HDLLog.I("鍏抽棴涓插彛");
+ try {
+ mSendDatasList.clear();//娓呯┖鍙戦�侀槦鍒�
+ mReceiveDatasList.clear();//娓呯┖鎺ユ敹闃熷垪
+ bOpenSuccess = false;
+// HDLCommand.cancelSearching();
+
+// if (mHDLRead485DatasThread != null) mHDLRead485DatasThread.interrupt();
+ if (mHDLReadMCUDatasThread != null) mHDLReadMCUDatasThread.interrupt();
+ if (mHDLSendDatasThread != null) mHDLSendDatasThread.interrupt();
+
+ if (mInputStream != null) {
+ mInputStream.close();
+ }
+ if (mOutputStream != null) {
+ mOutputStream.close();
+ }
+ if (mSerialPort != null) {
+ mSerialPort.close();
+ mSerialPort = null;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * 鍚姩涓插彛 鍙戦�佸拰鎺ユ敹绾跨▼
+ */
+ private static void startHDLThread() {
+// mHDLRead485DatasThread = new HDLRead485DatasThread();
+ mHDLReadMCUDatasThread = new HDLReadMCUDatasThread();
+ mHDLSendDatasThread = new HDLSendDatasThread();
+// mHDLRead485DatasThread.start();
+ mHDLReadMCUDatasThread.start();
+ mHDLSendDatasThread.start();
+ }
+
+//
+// /**
+// * 涓插彛鎺ユ敹绾跨▼
+// *
+// * @author 2019骞�06鏈�26鏃�
+// */
+// private static class HDLReadDatasThread extends Thread {
+//
+// @Override
+// public void run() {
+// super.run();
+// HDLLog.I("鎺ユ敹绾跨▼ 寮�鍚�");
+//
+// while (bOpenSuccess) {
+// int size = 0;
+// try {
+// if (mInputStream == null) return;
+//
+// byte[] buffer = new byte[64];
+// size = mInputStream.read(buffer);
+// for (int i = 0; i < size; i++) {
+// mReceiveDatasList.add(buffer[i]);
+// }
+//
+// while (0 < mReceiveDatasList.size()) {
+// HDLLog.I("arraylist.size():" + mReceiveDatasList.size());
+// if (mReceiveDatasList.size() < 3) break;//2019-07-02
+// int len = -1;
+// int startIndex = 0;
+// for (startIndex = 0; startIndex < mReceiveDatasList.size(); startIndex++) {
+// if ((mReceiveDatasList.get(startIndex) & 0xFF) == 0xAA
+// && (mReceiveDatasList.get(startIndex + 1) & 0xFF) == 0xAA) {
+// len = (mReceiveDatasList.get(startIndex + 2) & 0xFF) + 2;//鍙戠幇len浼氬嚭鐜拌礋鏁板鍔� & 0xFF 杩愮畻
+// break;
+// }
+// }
+// if (len == -1 || mReceiveDatasList.size() < len) break;
+//
+// HDLLog.I("startIndex:" + startIndex + " LEN:" + len);
+// for (int i = 0; i < startIndex; i++) {
+// if (mReceiveDatasList.size() < 1) break;//2019-07-02
+// mReceiveDatasList.remove(0);
+// }
+// byte[] tempBytes = new byte[len];
+// for (int i = 0; i < tempBytes.length; i++) {
+// if (mReceiveDatasList.size() < 1) break;//2019-07-02
+//
+// tempBytes[i] = mReceiveDatasList.get(0);
+// mReceiveDatasList.remove(0);
+// }
+// HandleHDLdata(tempBytes);
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// HDLLog.I("error:" + e.getMessage());
+// }
+// }
+// HDLLog.I("鎺ユ敹绾跨▼ 鍏抽棴");
+// }
+// }
+
+ /**
+ * 涓插彛鎺ユ敹绾跨▼
+ * 瀵规帴HDL鍗忚
+ * 寮曞澶� 鎺у埗鍩� 鏁版嵁闀垮害 鏁版嵁 鏍¢獙鐮�
+ * 0xA8
+ *
+ * @author 2019骞�07鏈�12鏃�
+ */
+ private static class HDLReadMCUDatasThread extends Thread {
+
+ @Override
+ public void run() {
+ super.run();
+ HDLLog.I("鎺ユ敹绾跨▼ 寮�鍚�");
+ while (bOpenSuccess) {
+ int size = 0;
+ try {
+ Thread.sleep(1);//2019-07 闄嶄綆CPU鍗犵敤鐜�
+ if (mInputStream == null) return;
+ byte[] buffer = new byte[64];
+
+ size = mInputStream.read(buffer);
+// HDLLog.I("mReceiveDatasList锛� " + HDLStringUtils.ByteArrToHex(buffer, 0, buffer.length) );
+ for (int i = 0; i < size; i++) {
+ mReceiveDatasList.add(buffer[i]);
+ }
+
+ while (0 < mReceiveDatasList.size()) {
+// HDLLog.I("arraylist.size():" + mReceiveDatasList.size());
+ if (mReceiveDatasList.size() < 3) break;//2019-07-02
+ if (mReceiveDatasList.size() > 3000) { //鏁版嵁缂撳瓨澶閿欒鎯呭喌涓� 娓呯┖涓�娆�
+ mReceiveDatasList.clear();
+ break;//2019-07-24
+ }
+
+ int len = -1;
+ int startIndex = 0;
+
+ for (startIndex = 0; startIndex < mReceiveDatasList.size(); startIndex++) {
+ if ((mReceiveDatasList.get(startIndex) & 0xFF) == 0xAA
+ && (mReceiveDatasList.get(startIndex + 1) & 0xFF) == 0xAA) {
+ len = (mReceiveDatasList.get(startIndex + 2) & 0xFF) + 2;//鍙戠幇len浼氬嚭鐜拌礋鏁板鍔� & 0xFF 杩愮畻
+ break;
+ }
+ }
+
+ if (len == -1 || mReceiveDatasList.size() < len) break;
+// HDLLog.I("startIndex:" + startIndex + " LEN:" + len);
+ for (int i = 0; i < startIndex; i++) {
+ if (mReceiveDatasList.size() < 1) break;//2019-07-02
+ mReceiveDatasList.remove(0);
+ }
+ byte[] tempBytes = new byte[len];
+ for (int i = 0; i < tempBytes.length; i++) {
+ if (mReceiveDatasList.size() < 1) break;//2019-07-02
+
+ tempBytes[i] = mReceiveDatasList.get(0);
+ mReceiveDatasList.remove(0);
+ }
+
+ HandleHDLdata(tempBytes);
+
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ HDLLog.I("error:" + e.getMessage());
+ }
+ }
+ HDLLog.I("鎺ユ敹绾跨▼ 鍏抽棴");
+ }
+ }
+
+// /**
+// * 485鏁版嵁鎺ユ敹绾跨▼
+// *
+// * @author 2019骞�06鏈�26鏃�
+// */
+// private static class HDLRead485DatasThread extends Thread {
+//
+// @Override
+// public void run() {
+// super.run();
+// HDLLog.I("485鎺ユ敹绾跨▼ 寮�鍚�");
+// while (bOpenSuccess) {
+// int size = 0;
+// try {
+// Thread.sleep(10);
+// while (0 < mReceive485DatasList.size()) {
+//// HDLLog.I("485arraylist.size():" + mReceive485DatasList.size());
+// if (mReceive485DatasList.size() < 3) break;//2019-07-02
+// if (mReceive485DatasList.size() > 500) { //鏁版嵁缂撳瓨澶閿欒鎯呭喌涓� 娓呯┖涓�娆�
+// mReceive485DatasList.clear();
+// break;//2019-07-24
+// }
+// int len = -1;
+// int startIndex = 0;
+// for (startIndex = 0; startIndex < mReceive485DatasList.size(); startIndex++) {
+// if ((mReceive485DatasList.get(startIndex) & 0xFF) == 0xAA
+// && (mReceive485DatasList.get(startIndex + 1) & 0xFF) == 0xAA) {
+// len = (mReceive485DatasList.get(startIndex + 2) & 0xFF) + 2;//鍙戠幇len浼氬嚭鐜拌礋鏁板鍔� & 0xFF 杩愮畻
+// break;
+// }
+// }
+// if (len == -1 || mReceive485DatasList.size() < len) break;
+//
+//// HDLLog.I("startIndex:" + startIndex + " LEN:" + len);
+// for (int i = 0; i < startIndex; i++) {
+// if (mReceive485DatasList.size() < 1) break;//2019-07-02
+// mReceive485DatasList.remove(0);
+// }
+// byte[] tempBytes = new byte[len];
+// for (int i = 0; i < tempBytes.length; i++) {
+// if (mReceive485DatasList.size() < 1) break;//2019-07-02
+//
+// tempBytes[i] = mReceive485DatasList.get(0);
+// mReceive485DatasList.remove(0);
+// }
+// HandleHDLdata(tempBytes);
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// HDLLog.I("error:" + e.getMessage());
+// }
+// }
+// HDLLog.I("485鎺ユ敹绾跨▼ 鍏抽棴");
+// }
+// }
+
+
+ /**
+ * 涓插彛鍙戦�佺嚎绋�
+ */
+ private static class HDLSendDatasThread extends Thread {
+ @Override
+ public void run() {
+ super.run();
+ HDLLog.I("鍙戦�佺嚎绋� 寮�鍚�");
+ while (bOpenSuccess) {
+ try {
+ Thread.sleep(100);
+ } catch (Exception e) {
+ e.getMessage();
+ }
+ for (int i = 0; i < mSendDatasList.size(); i++) {
+ try {
+ Thread.sleep(50);
+ } catch (Exception e) {
+
+ }
+ try {
+ byte[] sendBytes = mSendDatasList.get(i);
+ try {
+ mOutputStream.flush();
+ mOutputStream.write(sendBytes);
+// HDLLog.I(
+// "sendBytes锛�" + HDLStringUtils.ByteArrToHex(sendBytes, 0, sendBytes.length));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ mSendDatasList.remove(i);
+ i--;
+ } catch (Exception ex) {
+ ex.getMessage();
+ }
+ }
+ }
+ HDLLog.I("鍙戦�佺嚎绋� 鍏抽棴");
+ }
+ }
+
+// /**
+// * 鍙戦�丮UC涓插彛鍗忚鏁版嵁鍖�
+// * @param mcuDataList
+// * @param bPassThrough 鏄惁涓洪�忎紶
+// */
+// public static void sendMCUData(final MCUCrc mcuDataList, Boolean bPassThrough) {
+// if(HDLSerialPortCore.bPassThrough != bPassThrough ){
+// HDLSerialPortCore.bPassThrough = bPassThrough;
+// }
+// //鎵撳嵃鎺ュ彈鏁版嵁
+// HDLLog.I("HHHHHsendMCUData锛� "+ HDLStringUtils.ByteArrToHex(mcuDataList.getMCUSendBytes(),0, mcuDataList.getMCUSendBytes().length));
+// if (!bOpenSuccess) return;
+// mSendDatasList.add(mcuDataList.getMCUSendBytes());
+// }
+
+ /**
+ * 鍙戦�丮UC涓插彛鍗忚鏁版嵁鍖�
+ *
+ * @param mcuDataList
+ */
+ public static void sendMCUData(final MCUCrc mcuDataList) {
+ //鎵撳嵃鎺ュ彈鏁版嵁
+// HDLLog.I("HHHHHsendMCUData锛� "+ HDLStringUtils.ByteArrToHex(mcuDataList.getMCUSendBytes(),0, mcuDataList.getMCUSendBytes().length));
+ if (!bOpenSuccess) return;
+ mSendDatasList.add(mcuDataList.getMCUSendBytes());
+ }
+
+
+ /**
+ * 鍙戦�佹暟鎹寘
+ * 鐐瑰鐐规垨骞挎挱
+ *
+ * @param sendDatas
+ */
+ public static void sendData(final Crc sendDatas) {
+ if (!bOpenSuccess) return;
+ mSendDatasList.add(sendDatas.GetSendBytes());
+ }
+
+ /**
+ * 鍙戦�佺粍鎾�
+ *
+ * @param sendDatas
+ */
+ public static void sendMulticastData(final Crc sendDatas) {
+ if (!bOpenSuccess) return;
+ mSendDatasList.add(sendDatas.GetSendBytes());
+ }
+
+
+ /**
+ * 鍒ゆ柇鏄惁涓篐DL AA AA 寮�澶存暟鎹�
+ *
+ * @param bytes
+ * @return
+ */
+ private static boolean isHDLDataWithHead(byte[] bytes) {
+ boolean isWant = true;
+ if ((bytes[0] & 0xFF) != 0xAA) {
+ isWant = false;
+ }
+ if ((bytes[1] & 0xFF) != 0xAA) {
+ isWant = false;
+ }
+ return isWant;
+ }
+
+
+ /**
+ * 澶勭悊HDL Data
+ *
+ * @param receiveBytes
+ */
+ private synchronized static void HandleHDLdata(byte[] receiveBytes) {
+ if (receiveBytes.length < 14) {
+ return;
+ }
+// 鎵撳嵃鎺ユ敹鏁版嵁
+// HDLLog.I("receiveBytes HandleHDLdata: " + HDLStringUtils.ByteArrToHex(receiveBytes, 0, receiveBytes.length));
+
+ //2019-8-21 鏍¢獙Crc
+ if (!Crc.checkCRC(receiveBytes)) {
+ HDLLog.I("checkCRC锛氭楠屽け璐�");
+ return;
+ }
+// HDLLog.I("checkCRC锛氭楠屾垚鍔�");
+
+// //鏍¢獙鏄惁涓�0xAA 0xAA 寮�澶存暟鎹暟鎹�
+// if (!isHDLDataWithHead(receiveBytes)) {
+// return;
+// }
+
+ //鎵撳嵃鎺ユ敹鏁版嵁
+// HDLLog.I("receiveBytes HandleHDLdata: " + HDLStringUtils.ByteArrToHex(receiveBytes, 0, receiveBytes.length));
+
+ //鏁版嵁闀垮害
+ int addDataLength = (receiveBytes[2] & 0xFF) - 11;
+ //闄勫姞鏁版嵁
+ byte[] usefulBytes = new byte[addDataLength];
+ //澶嶅埗闄勫姞鏁版嵁
+ System.arraycopy(receiveBytes, 11, usefulBytes, 0, addDataLength);
+
+ //鎿嶄綔鐮�
+ int command = (receiveBytes[7] & 0xFF) * 256 + (receiveBytes[8] & 0xFF);
+ //婧愬瓙缃戝彿
+ int sourceSubnetID = receiveBytes[3] & 0xFF;
+ //婧愯澶囧彿
+ int sourceDeviceID = receiveBytes[4] & 0xFF;
+ //鐩爣瀛愮綉鍙�
+ int targetSubnetID = receiveBytes[9] & 0xFF;
+ //鐩爣璁惧鍙�
+ int targetDeviceID = receiveBytes[10] & 0xFF;
+// //鍙傛暟
+// UdpDataBean udpDataBean = new UdpDataBean();
+// udpDataBean.sourceSubnetID = sourceSubnetID;
+// udpDataBean.sourceDeviceID = sourceDeviceID;
+// udpDataBean.desSubnetID = targetSubnetID;
+// udpDataBean.desDeviceID = targetDeviceID;
+// udpDataBean.command = command;
+//
+// udpDataBean.addBytes = usefulBytes;
+//// HandleOutsideData(targetSubnetID, targetDeviceID, command, usefulBytes, receiveBytes, udpDataBean);
+// HandleInsideData(udpDataBean);
+
+ //s2019-8-20 澧炲姞鐩爣瀛愮綉鍙疯澶囧彿鍒ゆ柇
+ if ((targetSubnetID == 0xFF && targetDeviceID == 0xFF)
+ || (targetSubnetID == Crc.localSubnetID && targetDeviceID == Crc.localDeviceID)) {
+ //鍙傛暟
+ UdpDataBean udpDataBean = new UdpDataBean();
+ udpDataBean.sourceSubnetID = sourceSubnetID;
+ udpDataBean.sourceDeviceID = sourceDeviceID;
+ udpDataBean.desSubnetID = targetSubnetID;
+ udpDataBean.desDeviceID = targetDeviceID;
+ udpDataBean.command = command;
+
+ udpDataBean.addBytes = usefulBytes;
+ HandleInsideData(udpDataBean);
+
+ }
+
+ }
+
+
+ /**
+ * 澶勭悊鍐呴儴鍛戒护鏁版嵁
+ *
+ * @param sendDatas
+ */
+ private static void HandleInsideData(UdpDataBean sendDatas) {
+ switch (sendDatas.command) {
+ case Configuration.DEVICES_SEARCH_BACK_COMMAND:
+// 鍏堝垽鏂悳绱㈡ā寮忥紝瀹跺眳鎼滅储鍒欏彧闇�瑕佸垽鏂袱涓殢鏈烘暟銆傞厭搴楁悳绱㈠垯闇�瑕佸垽鏂袱涓殢鏈烘暟鍜宨p鍦板潃
+ if (HandleSearch.curSearchMode == HandleSearch.GET_BUS_DEVICES) {
+ if (sendDatas.addBytes[0] == HandleSearch.random1
+ && sendDatas.addBytes[1] == HandleSearch.random2) {
+ HDLDeviceManager.handle(sendDatas, sendDatas.command);
+ }
+ } else {
+// if (sendDatas.addBytes[0] == HandleSearch.random1
+// && sendDatas.addBytes[1] == HandleSearch.random2
+// && HandleSearch.rcuIp.equals(sendDatas.ipAddress)
+// ) {
+// HDLDeviceManager.handle(sendDatas, sendDatas.command);
+//
+// }
+ if (sendDatas.addBytes[0] == HandleSearch.random1
+ && sendDatas.addBytes[1] == HandleSearch.random2
+ ) {
+ HDLDeviceManager.handle(sendDatas, sendDatas.command);
+ }
+ }
+
+ break;
+
+ /***2020-04-01 鏂板閫氱敤寮�鍏�**/
+ case Configuration.COMMON_SWITCH_CTRL_BACK_COMMAND:
+ case Configuration.COMMON_SWITCH_STATE_BACK_COMMAND:
+ case Configuration.LIGHT_CTRL_BACK_COMMAND:
+ case Configuration.CURTAIN_CTRL_BACK_COMMAND:
+ case Configuration.AIR_CTRL_BACK_COMMAND:
+ case Configuration.LOGIC_CTRL_BACK_COMMAND:
+ case Configuration.LOGIC_STATE_BACK_COMMAND:
+ case Configuration.LIGHT_STATE_BACK_COMMAND:
+ case Configuration.SECURITY_ARMING_CTRL_BACK_COMMAND://20190729瀹夐槻妯″潡 甯冮槻璁剧疆鍙嶉
+ case Configuration.SECURITY_STATE_BACK_COMMAND://20190729 璇诲彇瀹夐槻璁剧疆鍙嶉
+ case Configuration.SECURITY_ALARM_CTRL_BACK_COMMAND://20190729 鎶ヨ璁剧疆鍙嶉
+ case Configuration.CURTAIN_STATE_BACK_COMMAND:
+ case Configuration.CURTAIN_STATE_BROADCAST_BACK_COMMAND://2019-12-16 鏂板骞挎挱鐘舵�佺洃鍚�
+ case Configuration.AIR_STATE_BACK_COMMAND:
+ case Configuration.AIR_HVAC_CTRL_BACK_COMMAND:
+ case Configuration.AIR_HVAC_STATE_BACK_COMMAND:
+// case Configuration.RCU_ROOM_CAST_COMMAND:
+// case Configuration.RCU_CURTAIN_CAST_COMMAND:
+ case Configuration.DEVICES_READ_BACK_COMMAND://璇诲彇澶囨敞鍛戒护
+ case Configuration.DEVICES_MODIFY_BACK_COMMAND://淇敼鍩烘湰淇℃伅鍥炲
+ case Configuration.MODULE_UPDATE_REMARK_BACK_COMMAND://淇敼妯″潡澶囨敞鍥炲
+ case Configuration.WARNING_COMMAND:
+ case Configuration.SENSOR_STATE_BACK_COMMAND:
+ case Configuration.SENSOR_BROADCAST_STATE_BACK_COMMAND://2019-11-1 澧炲姞
+ case Configuration.DRY_CONTACT_STATE_BACK_COMMAND:
+ case Configuration.DRY_CONTACT_BROADCAST_STATE_COMMAND://2019-11-5 澧炲姞骞叉帴鐐圭姸鎬佸洖澶�
+// case Configuration.AUDIO_CTRL_READ_COMMAND:
+ case Configuration.AUDIO_CTRL_READ_BACK_COMMAND:
+// case Configuration.AUDIO_MenuPlay_INSTRUCTION_COMMAND:
+ case Configuration.AUDIO_MenuPlay_INSTRUCTION_BACK_COMMAND:
+
+ HDLDeviceManager.handle(sendDatas, sendDatas.command);
+ break;
+
+
+// case Configuration.RCU_SEARCH_COMMAND:
+//// if (sendDatas.port == Configuration.RCU_SEND_PORT) {
+// HDLLog.I( "鏀跺埌鎼滅储RCU鍛戒护");
+// HDLDeviceManager.handle(sendDatas, sendDatas.command);
+//// }
+//
+// break;
+// case Configuration.RCU_READ_SDK_INFO_COMMAND:
+//// if (sendDatas.desSubnetID == Crc.localSubnetID && sendDatas.desDeviceID == Crc.localDeviceID
+//// ) {
+//// HDLLog.I( "E508鏀跺埌");
+//// HDLDeviceManager.handle(sendDatas, Configuration.RCU_READ);
+//// }
+//// if (sendDatas.port == Configuration.RCU_SEND_PORT) {
+// HDLLog.I( "鏀跺埌璇诲彇SDK淇℃伅鍛戒护");
+// HDLDeviceManager.handle(sendDatas, sendDatas.command);
+//// }
+
+// break;
+ case Configuration.MANUAL_ADD_DEVICE_COMMAND:
+ //鍥哄畾闅忔満鏁�181銆�250
+ if (sendDatas.addBytes[0] == ((byte) 181)
+ && sendDatas.addBytes[1] == ((byte) 250)) {
+ HDLDeviceManager.handle(sendDatas, sendDatas.command);
+ }
+ break;
+ case Configuration.MANUAL_ADD_REMARK_COMMAND:
+ HDLDeviceManager.handle(sendDatas, sendDatas.command);
+ break;
+ default:
+ break;
+ }
+ }
+
+
+// /**
+// * 鍒ゆ柇鏄惁涓篐DL鏁版嵁
+// * @param bytes
+// * @return
+// */
+// private static boolean isHDLData(byte[] bytes) {
+//
+// boolean isWant = true;
+// for (int index = 0; index < bytes.length; index++) {
+// switch (index) {
+// case 0:
+// if (bytes[index] != 0x48) {
+// isWant = false;
+// }
+// break;
+// case 1:
+// if (bytes[index] != 0x44) {
+// isWant = false;
+// }
+// break;
+// case 2:
+// if (bytes[index] != 0x4C) {
+// isWant = false;
+// }
+// break;
+// case 3:
+// if (bytes[index] != 0x4D) {
+// isWant = false;
+// }
+// break;
+// case 4:
+// if (bytes[index] != 0x49) {
+// isWant = false;
+// }
+// break;
+// case 5:
+// if (bytes[index] != 0x52) {
+// isWant = false;
+// }
+// break;
+// case 6:
+// if (bytes[index] != 0x41) {
+// isWant = false;
+// }
+// break;
+// case 7:
+// if (bytes[index] != 0x43) {
+// isWant = false;
+// }
+// break;
+// case 8:
+// if (bytes[index] != 0x4C) {
+// isWant = false;
+// }
+// break;
+// case 9:
+// if (bytes[index] != 0x45) {
+// isWant = false;
+// }
+// break;
+//
+// default:
+// break;
+// }
+// }
+// return isWant;
+// }
+//
+// /**
+// * 澶勭悊HDL Data
+// *
+// * @param receiveBytes
+// */
+// private synchronized static void HandleMCUdata(byte[] receiveBytes) {
+// if (receiveBytes.length < 5) {
+// return;
+// }
+//
+// //鎵撳嵃鎺ュ彈鏁版嵁
+// HDLLog.I("receiveBytes HandleMCUdata: " + HDLStringUtils.ByteArrToHex(receiveBytes, 0, receiveBytes.length));
+// //鎿嶄綔鐮�
+// int command = receiveBytes[1] & 0xFF;
+// //鏁版嵁闀垮害
+// int addDataLength = (receiveBytes[2] & 0xFF) * 256 + (receiveBytes[3] & 0xFF);
+// //闄勫姞鏁版嵁
+// byte[] usefulBytes = new byte[addDataLength];
+// //澶嶅埗闄勫姞鏁版嵁
+// System.arraycopy(receiveBytes, 4, usefulBytes, 0, addDataLength);
+//
+// //鍙傛暟
+// MCUDataBean mMCUDataBean = new MCUDataBean();
+// mMCUDataBean.command = command;
+// mMCUDataBean.receiveBytes = usefulBytes;
+//
+// HandleMCUData(mMCUDataBean);
+//
+// }
+
+//
+// /**
+// * 澶勭悊MCU杩斿洖鐨勫懡浠ゆ暟鎹�
+// *
+// * @param mMCUDataBean
+// */
+// private static void HandleMCUData(MCUDataBean mMCUDataBean) {
+// switch (mMCUDataBean.command) {
+// case MCUConstants.MCU_COMMAND_SEND_BACK: //0x80 涓婃姤鏁版嵁
+// if (!HDLSerialPortCore.bPassThrough) {
+//// HandleHDLdata(mMCUDataBean.receiveBytes); //涓嶆槸閫忎紶鐨勮瘽锛屽鐞�485鏁版嵁
+//
+// AddReceive485DatasList(mMCUDataBean.receiveBytes);
+// } else {
+// HDLDeviceManager.HandleMCUData(mMCUDataBean);
+//
+// }
+// break;
+// case MCUConstants.MCU_SEND_UPGRADE_DATA_BACK: //0x05 鍙戦�佸崌绾ф暟鎹繑鍥� 娉ㄦ剰锛屽綋鏂囦欢鍦板潃涓�0xF5F5F5F5鐨勬椂鍊欙紝浠h〃鍙戠敓閿欒锛屽崌绾у寘涓嶅锛屼細閫�鍑哄崌绾фā寮忋�傚綋鏂囦欢鍦板潃涓�0xF8F8F8F8,浠h〃鎴愬姛锛屾垚鍔熷悗浼氶噸鍚�,鐩戝惉鍒伴噸鍚畬姣曪紝鎵嶄唬琛ㄥ畬鎴愩��
+// handleSendUpgradeDataBack(mMCUDataBean);
+// break;
+// default:
+// HDLDeviceManager.HandleMCUData(mMCUDataBean);
+// break;
+// }
+// }
+//
+//// /**
+//// *
+//// * @param receive485Bytes
+//// */
+//// private static void AddReceive485DatasList(byte[] receive485Bytes) {
+//// for (int i = 0; i < receive485Bytes.length; i++) {
+//// mReceive485DatasList.add(receive485Bytes[i]);
+//// }
+//// }
+//
+//
+// private static void handleSendUpgradeDataBack(MCUDataBean mMCUDataBean) {
+// try {
+// int addressIndex = HDLUtlis.byteArrayToInt(mMCUDataBean.receiveBytes);
+// HDLLog.I("addressIndex锛�" + addressIndex);
+// if (addressIndex == 0xF5F5F5F5) {
+// //褰撴枃浠跺湴鍧�涓�0xF5F5F5F5鐨勬椂鍊欙紝浠h〃鍙戠敓閿欒锛屽崌绾у寘涓嶅锛屼細閫�鍑哄崌绾фā寮�
+// sendIMcuOtaListeneronFailure(EventCode.FAILURE_DATA_ERROR, "鍗囩骇閿欒锛屽崌绾у寘涓嶅");
+// } else if (addressIndex == 0xF8F8F8F8) {
+// //褰撴枃浠跺湴鍧�涓�0xF8F8F8F8,浠h〃鎴愬姛锛屾垚鍔熷悗浼氶噸鍚�,鐩戝惉鍒伴噸鍚畬姣�
+// sendIMcuOtaListenerOnProgress(100);
+// sendIMcuOtaListenerOnSuccess();
+// upgradeFileDatas = null;//鍗囩骇鏂囦欢娓呯┖
+// } else {
+// //缁х画鍗囩骇 杩旈�佷笅涓�涓崌绾у寘 骞惰繑鍥炶繘搴�
+// if (addressIndex > upgradeFileDatas.length) {
+// HDLLog.E("addressIndex 澶т簬鍗囩骇鍖呴暱搴�");
+// return;
+// }
+//
+// HDLCommand.mcuSendUpgradeData(getNextUpgradebytes(mMCUDataBean.receiveBytes, addressIndex));
+// int progress = addressIndex * 100 / (upgradeFileDatas.length - 1);
+// sendIMcuOtaListenerOnProgress(progress);
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// HDLLog.E("handleSendUpgradeDataBack 鍑洪敊");
+// }
+//
+// }
+//
+// /**
+// * 鑾峰彇涓嬩竴娈靛崌绾у寘鏁版嵁
+// *
+// * @param index
+// */
+// private static byte[] getNextUpgradebytes(byte[] addressBytes, int index) {
+// byte[] newBytes = new byte[1030];//1024+6
+// System.arraycopy(addressBytes, 0, newBytes, 0, 4);
+// int sub = upgradeFileDatas.length - 1 - index;
+// if (sub >= 1024) {
+// System.arraycopy(upgradeFileDatas, index, newBytes, 6, 1024);
+// } else {
+// System.arraycopy(upgradeFileDatas, index, newBytes, 6, sub);
+// }
+// newBytes[4] = 0x04;//榛樿鏁版嵁闀垮害涓�1024
+// newBytes[5] = 0x00;
+//
+// return newBytes;
+// }
+//
+//
+// /**
+// * 璁剧疆鐩戝惉浜嬩欢
+// *
+// * @param listener
+// */
+// public static void setIMcuOtaListener(IMcuOtaListener listener) {
+// mIMcuOtaListener = listener;
+// }
+//
+// public static void removeIMcuOtaListener() {
+// mIMcuOtaListener = null;
+// }
+//
+// /**
+// * onProgress
+// *
+// * @param progress
+// */
+// public static void sendIMcuOtaListenerOnProgress(int progress) {
+// if (mIMcuOtaListener != null) {
+// progress = HDLUtlis.getTrueProgressInt(progress);//纭繚progress 鍦�0鍒�100
+// mIMcuOtaListener.onProgress(progress);
+// }
+// }
+//
+// /**
+// * onSuccess
+// */
+// public static void sendIMcuOtaListenerOnSuccess() {
+// if (mIMcuOtaListener != null) {
+// mIMcuOtaListener.onSuccess();
+// }
+// }
+//
+// /**
+// * onFailure
+// *
+// * @param code 閿欒鐮�
+// * @param error 澶辫触鍘熷洜
+// */
+// public static void sendIMcuOtaListeneronFailure(int code, String error) {
+// if (mIMcuOtaListener != null) {
+// mIMcuOtaListener.onFailure(code, error);
+// }
+// }
+//
+
+}
+
+
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLSerialPortCoreOld.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLSerialPortCoreOld.java
new file mode 100644
index 0000000..e4861c4
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLSerialPortCoreOld.java
@@ -0,0 +1,797 @@
+//package com.hdl.sdk.ttl.HDLDeviceManger.Core;
+//
+//
+//import android.serialport.api.SerialPort;
+//
+//import com.hdl.sdk.ttl.Config.Configuration;
+//import com.hdl.sdk.ttl.Config.MCUConstants;
+//import com.hdl.sdk.ttl.HDLDeviceManger.Bean.MCUDataBean;
+//import com.hdl.sdk.ttl.HDLDeviceManger.Bean.UdpDataBean;
+//import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.EventCode;
+//import com.hdl.sdk.ttl.HDLDeviceManger.HDLListener.IMcuOtaListener;
+//import com.hdl.sdk.ttl.Utils.HDLUtlis.HDLStringUtils;
+//import com.hdl.sdk.ttl.Utils.HDLUtlis.HDLUtlis;
+//import com.hdl.sdk.ttl.Utils.LogUtils.HDLLog;
+//
+//import java.io.File;
+//import java.io.IOException;
+//import java.io.InputStream;
+//import java.io.OutputStream;
+//import java.security.InvalidParameterException;
+//import java.util.ArrayList;
+//import java.util.List;
+//
+///**
+// * Created by JLChen on 2019/6/26
+// * 涓插彛绠$悊绫�
+// */
+//public class HDLSerialPortCore {
+// //涓插彛璁惧璺緞鍚�
+// private static String mPathname = "/dev/ttyS1";
+// //娉㈢壒鐜�
+// private static int mBaudrate = 115200;
+//
+// // public static SerialPortFinder mSerialPortFinder = new SerialPortFinder();
+// private static SerialPort mSerialPort = null;
+// private static InputStream mInputStream = null;
+// private static OutputStream mOutputStream = null;
+// // private static HDLReadDatasThread mHDLReadDatasThread = new HDLReadDatasThread();
+// private static HDLReadMCUDatasThread mHDLReadMCUDatasThread = new HDLReadMCUDatasThread();
+// private static HDLSendDatasThread mHDLSendDatasThread = new HDLSendDatasThread();
+// public static List<byte[]> mSendDatasList = new ArrayList<byte[]>();//鍙戦�佹暟鎹槦鍒�
+// private static List<Byte> mReceiveDatasList = new ArrayList<Byte>();//鎺ユ敹鏁版嵁闃熷垪
+//// private static List<Byte> mReceive485DatasList = new ArrayList<Byte>();//485鎺ユ敹鏁版嵁闃熷垪
+//
+// public static Boolean bPassThrough = false; //鍒ゆ柇鏄惁閫忎紶
+// public static IMcuOtaListener mIMcuOtaListener;
+// public static byte[] upgradeFileDatas; //鍗囩骇鏂囦欢鏁版嵁
+//
+// /*** 涓插彛鏄惁鎵撳紑鎴愬姛*/
+// private static boolean bOpenSuccess = false;
+//
+// public static SerialPort getSerialPort() throws SecurityException, IOException, InvalidParameterException {
+// if (mSerialPort == null) {
+// mSerialPort = new SerialPort(new File(mPathname), mBaudrate, 0);
+// mInputStream = mSerialPort.getInputStream();//璋冪敤瀵硅薄SerialPort鏂规硶锛岃幏鍙栦覆鍙d腑"璇诲拰鍐�"鐨勬暟鎹祦
+// mOutputStream = mSerialPort.getOutputStream();
+// bOpenSuccess = true;
+// }
+// return mSerialPort;
+// }
+//
+// /**
+// * 鍒濆鍖栦覆鍙�
+// */
+// public static void initHDLSerialPort(String mmPathname, int mmBaudrate) {
+// openSerialPort(mmPathname, mmBaudrate);
+// }
+//
+// /**
+// * 鍒ゆ柇涓插彛鏄惁鎵撳紑
+// */
+// public static Boolean getIsSerialPortOpen() {
+// return bOpenSuccess;
+// }
+//
+// /**
+// * 鎵撳紑涓插彛锛屾帴鏀舵暟鎹�
+// * 閫氳繃涓插彛锛屾帴鏀跺崟鐗囨満鍙戦�佹潵鐨勬暟鎹�
+// */
+// public static Boolean openSerialPort(String mmPathname, int mmBaudrate) {
+// if (mSerialPort != null) {
+// HDLLog.I("HDLSDK 涓插彛 宸插惎鍔�");
+// } else {
+// HDLLog.I("HDLSDK 涓插彛 init");
+// try {
+// mPathname = mmPathname;
+// mBaudrate = mmBaudrate;
+// mSerialPort = new SerialPort(new File(mPathname), mBaudrate, 0);
+// HDLLog.I("HDLSDK 涓插彛鍚姩鎴愬姛");
+// //璋冪敤瀵硅薄SerialPort鏂规硶锛岃幏鍙栦覆鍙d腑"璇诲拰鍐�"鐨勬暟鎹祦
+// mInputStream = mSerialPort.getInputStream();
+// mOutputStream = mSerialPort.getOutputStream();
+// bOpenSuccess = true;
+// startHDLThread();
+// } catch (IOException e) {
+// e.printStackTrace();
+// bOpenSuccess = false;
+// HDLLog.I("HDLSDK 涓插彛鍚姩澶辫触 IOException");
+// } catch (InvalidParameterException e) {
+// e.printStackTrace();
+// bOpenSuccess = false;
+// HDLLog.I("HDLSDK 涓插彛鍚姩澶辫触 InvalidParameterException");
+// } catch (SecurityException e) {
+// e.printStackTrace();
+// bOpenSuccess = false;
+// HDLLog.I("HDLSDK 涓插彛鍚姩澶辫触 SecurityException");
+// }
+// }
+// return bOpenSuccess;
+// }
+//
+// /**
+// * 鍏抽棴涓插彛
+// * 鍏抽棴涓插彛涓殑杈撳叆杈撳嚭娴�
+// */
+// public static void closeSerialPort() {
+// HDLLog.I("鍏抽棴涓插彛");
+// try {
+// mSendDatasList.clear();//娓呯┖鍙戦�侀槦鍒�
+// mReceiveDatasList.clear();//娓呯┖鎺ユ敹闃熷垪
+// bOpenSuccess = false;
+//// HDLCommand.cancelSearching();
+// if (mHDLReadMCUDatasThread != null) mHDLReadMCUDatasThread.interrupt();
+// if (mHDLSendDatasThread != null) mHDLSendDatasThread.interrupt();
+//
+// if (mInputStream != null) {
+// mInputStream.close();
+// }
+// if (mOutputStream != null) {
+// mOutputStream.close();
+// }
+// if (mSerialPort != null) {
+// mSerialPort.close();
+// mSerialPort = null;
+// }
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+//
+// }
+//
+// /**
+// * 鍚姩涓插彛 鍙戦�佸拰鎺ユ敹绾跨▼
+// */
+// private static void startHDLThread() {
+// mHDLReadMCUDatasThread = new HDLReadMCUDatasThread();
+// mHDLSendDatasThread = new HDLSendDatasThread();
+// mHDLReadMCUDatasThread.start();
+// mHDLSendDatasThread.start();
+// }
+//
+//// /**
+//// * 涓插彛鎺ユ敹绾跨▼
+//// *
+//// * @author 2019骞�06鏈�26鏃�
+//// */
+//// private static class HDLReadDatasThread extends Thread {
+////
+//// @Override
+//// public void run() {
+//// super.run();
+//// HDLLog.I("鎺ユ敹绾跨▼ 寮�鍚�");
+////
+//// while (bOpenSuccess) {
+//// int size = 0;
+//// try {
+//// if (mInputStream == null) return;
+////
+//// byte[] buffer = new byte[64];
+//// size = mInputStream.read(buffer);
+//// for (int i = 0; i < size; i++) {
+//// mReceiveDatasList.add(buffer[i]);
+//// }
+////
+//// while (0 < mReceiveDatasList.size()) {
+//// HDLLog.I("arraylist.size():" + mReceiveDatasList.size());
+//// if (mReceiveDatasList.size() < 3) break;//2019-07-02
+//// int len = -1;
+//// int startIndex = 0;
+//// for (startIndex = 0; startIndex < mReceiveDatasList.size(); startIndex++) {
+//// if ((mReceiveDatasList.get(startIndex) & 0xFF) == 0xAA
+//// && (mReceiveDatasList.get(startIndex + 1) & 0xFF) == 0xAA) {
+//// len = (mReceiveDatasList.get(startIndex + 2) & 0xFF) + 2;//鍙戠幇len浼氬嚭鐜拌礋鏁板鍔� & 0xFF 杩愮畻
+//// break;
+//// }
+//// }
+//// if (len == -1 || mReceiveDatasList.size() < len) break;
+////
+//// HDLLog.I("startIndex:" + startIndex + " LEN:" + len);
+//// for (int i = 0; i < startIndex; i++) {
+//// if (mReceiveDatasList.size() < 1) break;//2019-07-02
+//// mReceiveDatasList.remove(0);
+//// }
+//// byte[] tempBytes = new byte[len];
+//// for (int i = 0; i < tempBytes.length; i++) {
+//// if (mReceiveDatasList.size() < 1) break;//2019-07-02
+////
+//// tempBytes[i] = mReceiveDatasList.get(0);
+//// mReceiveDatasList.remove(0);
+//// }
+//// HandleHDLdata(tempBytes);
+//// }
+//// } catch (Exception e) {
+//// e.printStackTrace();
+//// HDLLog.I("error:" + e.getMessage());
+//// }
+//// }
+//// HDLLog.I("鎺ユ敹绾跨▼ 鍏抽棴");
+//// }
+//// }
+//
+// /**
+// * 涓插彛鎺ユ敹绾跨▼
+// * 瀵规帴MCU鏂板崗璁�
+// * 寮曞澶� 鎺у埗鍩� 鏁版嵁闀垮害 鏁版嵁 鏍¢獙鐮�
+// * 0xA8
+// *
+// * @author 2019骞�07鏈�12鏃�
+// */
+// private static class HDLReadMCUDatasThread extends Thread {
+//
+// @Override
+// public void run() {
+// super.run();
+// HDLLog.I("鎺ユ敹绾跨▼ 寮�鍚�");
+//
+// while (bOpenSuccess) {
+// int size = 0;
+// try {
+// Thread.sleep(1);
+// if (mInputStream == null) return;
+// byte[] buffer = new byte[64];
+// size = mInputStream.read(buffer);
+//
+//// HDLLog.I("mReceiveDatasList锛� " + HDLStringUtils.ByteArrToHex(buffer, 0, buffer.length) );
+// for (int i = 0; i < size; i++) {
+// mReceiveDatasList.add(buffer[i]);
+// }
+//
+// while (0 < mReceiveDatasList.size()) {
+//// HDLLog.I("arraylist.size():" + mReceiveDatasList.size());
+// if (mReceiveDatasList.size() < 3) break;//2019-07-02
+// if (mReceiveDatasList.size() > 3000) { //鏁版嵁缂撳瓨澶閿欒鎯呭喌涓� 娓呯┖涓�娆�
+// mReceiveDatasList.clear();
+// break;//2019-07-24
+// }
+//
+// int len = -1;
+// int startIndex = 0;
+// for (startIndex = 0; startIndex < mReceiveDatasList.size(); startIndex++) {
+// if ((mReceiveDatasList.get(startIndex) & 0xFF) == 0xA8) {
+// len = (mReceiveDatasList.get(startIndex + 2) & 0xFF) * 256 + (mReceiveDatasList.get(startIndex + 3) & 0xFF) + 5;
+// break;
+// }
+//// else{
+//// HDLLog.I("mReceiveDatasList"+ (mReceiveDatasList.get(startIndex) & 0xFF) );
+//// }
+// }
+//
+// if (len == -1 || mReceiveDatasList.size() < len) break;
+//
+//// HDLLog.I("startIndex:" + startIndex + " LEN:" + len);
+// for (int i = 0; i < startIndex; i++) {
+// if (mReceiveDatasList.size() < 1) break;//2019-07-02
+// mReceiveDatasList.remove(0);
+// }
+// byte[] tempBytes = new byte[len];
+// for (int i = 0; i < tempBytes.length; i++) {
+// if (mReceiveDatasList.size() < 1) break;//2019-07-02
+//
+// tempBytes[i] = mReceiveDatasList.get(0);
+// mReceiveDatasList.remove(0);
+// }
+// HandleMCUdata(tempBytes);
+//
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// HDLLog.I("error:" + e.getMessage());
+// }
+// }
+// HDLLog.I("鎺ユ敹绾跨▼ 鍏抽棴");
+// }
+// }
+//
+//
+// /**
+// * 涓插彛鍙戦�佺嚎绋�
+// */
+// private static class HDLSendDatasThread extends Thread {
+// @Override
+// public void run() {
+// super.run();
+// HDLLog.I("鍙戦�佺嚎绋� 寮�鍚�");
+// while (bOpenSuccess) {
+// try {
+// Thread.sleep(100);
+// } catch (Exception e) {
+// e.getMessage();
+// }
+// for (int i = 0; i < mSendDatasList.size(); i++) {
+// try {
+// Thread.sleep(100);
+// } catch (Exception e) {
+//
+// }
+// try {
+// byte[] sendBytes = mSendDatasList.get(i);
+// try {
+// mOutputStream.flush();
+// mOutputStream.write(sendBytes);
+// HDLLog.I(
+// "sendBytes锛�" + HDLStringUtils.ByteArrToHex(sendBytes, 0, sendBytes.length));
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// mSendDatasList.remove(i);
+// i--;
+// } catch (Exception ex) {
+// ex.getMessage();
+// }
+// }
+// }
+// HDLLog.I("鍙戦�佺嚎绋� 鍏抽棴");
+// }
+// }
+//
+//// /**
+//// * 鍙戦�丮UC涓插彛鍗忚鏁版嵁鍖�
+//// * @param mcuDataList
+//// * @param bPassThrough 鏄惁涓洪�忎紶
+//// */
+//// public static void sendMCUData(final MCUCrc mcuDataList, Boolean bPassThrough) {
+//// if(HDLSerialPortCore.bPassThrough != bPassThrough ){
+//// HDLSerialPortCore.bPassThrough = bPassThrough;
+//// }
+//// //鎵撳嵃鎺ュ彈鏁版嵁
+//// HDLLog.I("HHHHHsendMCUData锛� "+ HDLStringUtils.ByteArrToHex(mcuDataList.getMCUSendBytes(),0, mcuDataList.getMCUSendBytes().length));
+//// if (!bOpenSuccess) return;
+//// mSendDatasList.add(mcuDataList.getMCUSendBytes());
+//// }
+//
+// /**
+// * 鍙戦�丮UC涓插彛鍗忚鏁版嵁鍖�
+// *
+// * @param mcuDataList
+// */
+// public static void sendMCUData(final MCUCrc mcuDataList) {
+// //鎵撳嵃鎺ュ彈鏁版嵁
+//// HDLLog.I("HHHHHsendMCUData锛� "+ HDLStringUtils.ByteArrToHex(mcuDataList.getMCUSendBytes(),0, mcuDataList.getMCUSendBytes().length));
+// if (!bOpenSuccess) return;
+// mSendDatasList.add(mcuDataList.getMCUSendBytes());
+// }
+//
+//
+// /**
+// * 鍙戦�佹暟鎹寘
+// * 鐐瑰鐐规垨骞挎挱
+// *
+// * @param sendDatas
+// */
+// public static void sendData(final Crc sendDatas) {
+// if (!bOpenSuccess) return;
+// mSendDatasList.add(sendDatas.GetSendBytes());
+// }
+//
+// /**
+// * 鍙戦�佺粍鎾�
+// *
+// * @param sendDatas
+// */
+// public static void sendMulticastData(final Crc sendDatas) {
+// if (!bOpenSuccess) return;
+// mSendDatasList.add(sendDatas.GetSendBytes());
+// }
+//
+//
+//// /**
+//// * 鍒ゆ柇鏄惁涓�485HDL鏁版嵁
+//// * @param bytes
+//// * @return
+//// */
+//// private static void HandleHDLAAAAdata(byte[] bytes) {
+//// while (0 < mReceiveDatasList.size()) {
+//// HDLLog.I("arraylist.size():" + mReceiveDatasList.size());
+//// if (mReceiveDatasList.size() < 3) break;//2019-07-02
+//// int len = -1;
+//// int startIndex = 0;
+//// for (startIndex = 0; startIndex < mReceiveDatasList.size(); startIndex++) {
+//// if ((mReceiveDatasList.get(startIndex) & 0xFF) == 0xAA
+//// && (mReceiveDatasList.get(startIndex + 1) & 0xFF) == 0xAA) {
+//// len = (mReceiveDatasList.get(startIndex + 2) & 0xFF) + 2;//鍙戠幇len浼氬嚭鐜拌礋鏁板鍔� & 0xFF 杩愮畻
+//// break;
+//// }
+//// }
+//// if (len == -1 || mReceiveDatasList.size() < len) break;
+////
+//// HDLLog.I("startIndex:" + startIndex + " LEN:" + len);
+//// for (int i = 0; i < startIndex; i++) {
+//// if (mReceiveDatasList.size() < 1) break;//2019-07-02
+//// mReceiveDatasList.remove(0);
+//// }
+//// byte[] tempBytes = new byte[len];
+//// for (int i = 0; i < tempBytes.length; i++) {
+//// if (mReceiveDatasList.size() < 1) break;//2019-07-02
+////
+//// tempBytes[i] = mReceiveDatasList.get(0);
+//// mReceiveDatasList.remove(0);
+//// }
+//// HandleHDLdata(tempBytes);
+//// }
+////
+//// }
+//
+// /**
+// * 鍒ゆ柇鏄惁涓篐DL AA AA 寮�澶存暟鎹�
+// * @param bytes
+// * @return
+// */
+// private static boolean isHDLDataWithHead(byte[] bytes) {
+// boolean isWant = true;
+// if ((bytes[0] & 0xFF) != 0xAA) {
+// isWant = false;
+// }
+// if ((bytes[1] & 0xFF) != 0xAA) {
+// isWant = false;
+// }
+// return isWant;
+// }
+//
+//
+// /**
+// * 澶勭悊HDL Data
+// *
+// * @param receiveBytes
+// */
+// private synchronized static void HandleHDLdata(byte[] receiveBytes) {
+// if (receiveBytes.length < 14) {
+// return;
+// }
+//
+// //鏍¢獙鏄惁涓�0xAA 0xAA 寮�澶存暟鎹暟鎹�
+// if (!isHDLDataWithHead(receiveBytes)) {
+// return;
+// }
+//
+// //鎵撳嵃鎺ユ敹鏁版嵁
+// HDLLog.I("receiveBytes HandleHDLdata: " + HDLStringUtils.ByteArrToHex(receiveBytes, 0, receiveBytes.length));
+//
+// //鏁版嵁闀垮害
+// int addDataLength = (receiveBytes[2] & 0xFF) - 11;
+// //闄勫姞鏁版嵁
+// byte[] usefulBytes = new byte[addDataLength];
+// //澶嶅埗闄勫姞鏁版嵁
+// System.arraycopy(receiveBytes, 11, usefulBytes, 0, addDataLength);
+// //鎿嶄綔鐮�
+// int command = (receiveBytes[7] & 0xFF) * 256 + (receiveBytes[8] & 0xFF);
+// //婧愬瓙缃戝彿
+// int sourceSubnetID = receiveBytes[3] & 0xFF;
+// //婧愯澶囧彿
+// int sourceDeviceID = receiveBytes[4] & 0xFF;
+// //鐩爣瀛愮綉鍙�
+// int targetSubnetID = receiveBytes[9] & 0xFF;
+// //鐩爣璁惧鍙�
+// int targetDeviceID = receiveBytes[10] & 0xFF;
+// //鍙傛暟
+// UdpDataBean udpDataBean = new UdpDataBean();
+// udpDataBean.sourceSubnetID = sourceSubnetID;
+// udpDataBean.sourceDeviceID = sourceDeviceID;
+// udpDataBean.desSubnetID = targetSubnetID;
+// udpDataBean.desDeviceID = targetDeviceID;
+// udpDataBean.command = command;
+//
+// udpDataBean.addBytes = usefulBytes;
+//// HandleOutsideData(targetSubnetID, targetDeviceID, command, usefulBytes, receiveBytes, udpDataBean);
+// HandleInsideData(udpDataBean);
+//
+// }
+//
+//
+// /**
+// * 澶勭悊鍐呴儴鍛戒护鏁版嵁
+// *
+// * @param sendDatas
+// */
+// private static void HandleInsideData(UdpDataBean sendDatas) {
+// switch (sendDatas.command) {
+// case Configuration.DEVICES_SEARCH_BACK_COMMAND:
+//// 鍏堝垽鏂悳绱㈡ā寮忥紝瀹跺眳鎼滅储鍒欏彧闇�瑕佸垽鏂袱涓殢鏈烘暟銆傞厭搴楁悳绱㈠垯闇�瑕佸垽鏂袱涓殢鏈烘暟鍜宨p鍦板潃
+// if (HandleSearch.curSearchMode == HandleSearch.GET_BUS_DEVICES) {
+// if (sendDatas.addBytes[0] == HandleSearch.random1
+// && sendDatas.addBytes[1] == HandleSearch.random2) {
+// HDLDeviceManager.handle(sendDatas, sendDatas.command);
+// }
+// } else {
+//// if (sendDatas.addBytes[0] == HandleSearch.random1
+//// && sendDatas.addBytes[1] == HandleSearch.random2
+//// && HandleSearch.rcuIp.equals(sendDatas.ipAddress)
+//// ) {
+//// HDLDeviceManager.handle(sendDatas, sendDatas.command);
+////
+//// }
+// if (sendDatas.addBytes[0] == HandleSearch.random1
+// && sendDatas.addBytes[1] == HandleSearch.random2
+// ) {
+// HDLDeviceManager.handle(sendDatas, sendDatas.command);
+// }
+// }
+//
+// break;
+//
+// case Configuration.LIGHT_CTRL_BACK_COMMAND:
+// case Configuration.CURTAIN_CTRL_BACK_COMMAND:
+// case Configuration.AIR_CTRL_BACK_COMMAND:
+// case Configuration.LOGIC_CTRL_BACK_COMMAND:
+// case Configuration.LIGHT_STATE_BACK_COMMAND:
+// case Configuration.SECURITY_ARMING_CTRL_BACK_COMMAND://20190729瀹夐槻妯″潡 甯冮槻璁剧疆鍙嶉
+// case Configuration.SECURITY_STATE_BACK_COMMAND://20190729 璇诲彇瀹夐槻璁剧疆鍙嶉
+// case Configuration.SECURITY_ALARM_CTRL_BACK_COMMAND://20190729 鎶ヨ璁剧疆鍙嶉
+// case Configuration.CURTAIN_STATE_BACK_COMMAND:
+// case Configuration.AIR_STATE_BACK_COMMAND:
+// case Configuration.AIR_HVAC_CTRL_BACK_COMMAND:
+// case Configuration.AIR_HVAC_STATE_BACK_COMMAND:
+//// case Configuration.RCU_ROOM_CAST_COMMAND:
+//// case Configuration.RCU_CURTAIN_CAST_COMMAND:
+// case Configuration.DEVICES_READ_BACK_COMMAND://璇诲彇澶囨敞鍛戒护
+// case Configuration.DEVICES_MODIFY_BACK_COMMAND://淇敼鍩烘湰淇℃伅鍥炲
+// case Configuration.MODULE_UPDATE_REMARK_BACK_COMMAND://淇敼妯″潡澶囨敞鍥炲
+// case Configuration.WARNING_COMMAND:
+// case Configuration.SENSOR_STATE_BACK_COMMAND:
+//// case Configuration.AUDIO_CTRL_READ_COMMAND:
+// case Configuration.AUDIO_CTRL_READ_BACK_COMMAND:
+//// case Configuration.AUDIO_MenuPlay_INSTRUCTION_COMMAND:
+// case Configuration.AUDIO_MenuPlay_INSTRUCTION_BACK_COMMAND:
+//
+// HDLDeviceManager.handle(sendDatas, sendDatas.command);
+// break;
+//
+//
+//// case Configuration.RCU_SEARCH_COMMAND:
+////// if (sendDatas.port == Configuration.RCU_SEND_PORT) {
+//// HDLLog.I( "鏀跺埌鎼滅储RCU鍛戒护");
+//// HDLDeviceManager.handle(sendDatas, sendDatas.command);
+////// }
+////
+//// break;
+//// case Configuration.RCU_READ_SDK_INFO_COMMAND:
+////// if (sendDatas.desSubnetID == Crc.localSubnetID && sendDatas.desDeviceID == Crc.localDeviceID
+////// ) {
+////// HDLLog.I( "E508鏀跺埌");
+////// HDLDeviceManager.handle(sendDatas, Configuration.RCU_READ);
+////// }
+////// if (sendDatas.port == Configuration.RCU_SEND_PORT) {
+//// HDLLog.I( "鏀跺埌璇诲彇SDK淇℃伅鍛戒护");
+//// HDLDeviceManager.handle(sendDatas, sendDatas.command);
+////// }
+//
+//// break;
+// case Configuration.MANUAL_ADD_DEVICE_COMMAND:
+// //鍥哄畾闅忔満鏁�181銆�250
+// if (sendDatas.addBytes[0] == ((byte) 181)
+// && sendDatas.addBytes[1] == ((byte) 250)) {
+// HDLDeviceManager.handle(sendDatas, sendDatas.command);
+// }
+// break;
+// case Configuration.MANUAL_ADD_REMARK_COMMAND:
+// HDLDeviceManager.handle(sendDatas, sendDatas.command);
+// break;
+// default:
+// break;
+// }
+// }
+//
+//
+//// /**
+//// * 鍒ゆ柇鏄惁涓篐DL鏁版嵁
+//// * @param bytes
+//// * @return
+//// */
+//// private static boolean isHDLData(byte[] bytes) {
+////
+//// boolean isWant = true;
+//// for (int index = 0; index < bytes.length; index++) {
+//// switch (index) {
+//// case 0:
+//// if (bytes[index] != 0x48) {
+//// isWant = false;
+//// }
+//// break;
+//// case 1:
+//// if (bytes[index] != 0x44) {
+//// isWant = false;
+//// }
+//// break;
+//// case 2:
+//// if (bytes[index] != 0x4C) {
+//// isWant = false;
+//// }
+//// break;
+//// case 3:
+//// if (bytes[index] != 0x4D) {
+//// isWant = false;
+//// }
+//// break;
+//// case 4:
+//// if (bytes[index] != 0x49) {
+//// isWant = false;
+//// }
+//// break;
+//// case 5:
+//// if (bytes[index] != 0x52) {
+//// isWant = false;
+//// }
+//// break;
+//// case 6:
+//// if (bytes[index] != 0x41) {
+//// isWant = false;
+//// }
+//// break;
+//// case 7:
+//// if (bytes[index] != 0x43) {
+//// isWant = false;
+//// }
+//// break;
+//// case 8:
+//// if (bytes[index] != 0x4C) {
+//// isWant = false;
+//// }
+//// break;
+//// case 9:
+//// if (bytes[index] != 0x45) {
+//// isWant = false;
+//// }
+//// break;
+////
+//// default:
+//// break;
+//// }
+//// }
+//// return isWant;
+//// }
+//
+// /**
+// * 澶勭悊HDL Data
+// *
+// * @param receiveBytes
+// */
+// private synchronized static void HandleMCUdata(byte[] receiveBytes) {
+// if (receiveBytes.length < 5) {
+// return;
+// }
+// //鎵撳嵃鎺ュ彈鏁版嵁
+// HDLLog.I("receiveBytes HandleMCUdata: " + HDLStringUtils.ByteArrToHex(receiveBytes, 0, receiveBytes.length));
+// //鎿嶄綔鐮�
+// int command = receiveBytes[1] & 0xFF;
+// //鏁版嵁闀垮害
+// int addDataLength = (receiveBytes[2] & 0xFF) * 256 + (receiveBytes[3] & 0xFF);
+// //闄勫姞鏁版嵁
+// byte[] usefulBytes = new byte[addDataLength];
+// //澶嶅埗闄勫姞鏁版嵁
+// System.arraycopy(receiveBytes, 4, usefulBytes, 0, addDataLength);
+//
+// //鍙傛暟
+// MCUDataBean mMCUDataBean = new MCUDataBean();
+// mMCUDataBean.command = command;
+// mMCUDataBean.receiveBytes = usefulBytes;
+//
+// HandleMCUData(mMCUDataBean);
+//
+// }
+//
+//
+// /**
+// * 澶勭悊MCU杩斿洖鐨勫懡浠ゆ暟鎹�
+// *
+// * @param mMCUDataBean
+// */
+// private static void HandleMCUData(MCUDataBean mMCUDataBean) {
+// switch (mMCUDataBean.command) {
+// case MCUConstants.MCU_COMMAND_SEND_BACK: //0x80 涓婃姤鏁版嵁
+// if (!bPassThrough) {
+// HandleHDLdata(mMCUDataBean.receiveBytes); //涓嶆槸閫忎紶鐨勮瘽锛屽鐞�485鏁版嵁
+// } else {
+// HDLDeviceManager.HandleMCUData(mMCUDataBean);
+// }
+// break;
+// case MCUConstants.MCU_SEND_UPGRADE_DATA_BACK: //0x05 鍙戦�佸崌绾ф暟鎹繑鍥� 娉ㄦ剰锛屽綋鏂囦欢鍦板潃涓�0xF5F5F5F5鐨勬椂鍊欙紝浠h〃鍙戠敓閿欒锛屽崌绾у寘涓嶅锛屼細閫�鍑哄崌绾фā寮忋�傚綋鏂囦欢鍦板潃涓�0xF8F8F8F8,浠h〃鎴愬姛锛屾垚鍔熷悗浼氶噸鍚�,鐩戝惉鍒伴噸鍚畬姣曪紝鎵嶄唬琛ㄥ畬鎴愩��
+// handleSendUpgradeDataBack(mMCUDataBean);
+// break;
+// default:
+// HDLDeviceManager.HandleMCUData(mMCUDataBean);
+// break;
+// }
+// }
+//
+//
+// private static void handleSendUpgradeDataBack(MCUDataBean mMCUDataBean) {
+// try {
+// int addressIndex = HDLUtlis.byteArrayToInt(mMCUDataBean.receiveBytes);
+// HDLLog.I("addressIndex锛�" + addressIndex);
+// if (addressIndex == 0xF5F5F5F5) {
+// //褰撴枃浠跺湴鍧�涓�0xF5F5F5F5鐨勬椂鍊欙紝浠h〃鍙戠敓閿欒锛屽崌绾у寘涓嶅锛屼細閫�鍑哄崌绾фā寮�
+// sendIMcuOtaListeneronFailure(EventCode.FAILURE_DATA_ERROR, "鍗囩骇閿欒锛屽崌绾у寘涓嶅");
+// } else if (addressIndex == 0xF8F8F8F8) {
+// //褰撴枃浠跺湴鍧�涓�0xF8F8F8F8,浠h〃鎴愬姛锛屾垚鍔熷悗浼氶噸鍚�,鐩戝惉鍒伴噸鍚畬姣�
+// sendIMcuOtaListenerOnProgress(100);
+// sendIMcuOtaListenerOnSuccess();
+// upgradeFileDatas = null;//鍗囩骇鏂囦欢娓呯┖
+// } else {
+// //缁х画鍗囩骇 杩旈�佷笅涓�涓崌绾у寘 骞惰繑鍥炶繘搴�
+// if (addressIndex > upgradeFileDatas.length) {
+// HDLLog.E("addressIndex 澶т簬鍗囩骇鍖呴暱搴�");
+// return;
+// }
+//
+// HDLCommand.mcuSendUpgradeData(getNextUpgradebytes(mMCUDataBean.receiveBytes, addressIndex));
+// int progress = addressIndex * 100 / (upgradeFileDatas.length - 1);
+// sendIMcuOtaListenerOnProgress(progress);
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// HDLLog.E("handleSendUpgradeDataBack 鍑洪敊");
+// }
+//
+// }
+//
+// /**
+// * 鑾峰彇涓嬩竴娈靛崌绾у寘鏁版嵁
+// *
+// * @param index
+// */
+// private static byte[] getNextUpgradebytes(byte[] addressBytes, int index) {
+// byte[] newBytes = new byte[1030];//1024+6
+// System.arraycopy(addressBytes, 0, newBytes, 0, 4);
+// int sub = upgradeFileDatas.length - 1 - index;
+// if (sub >= 1024) {
+// System.arraycopy(upgradeFileDatas, index, newBytes, 6, 1024);
+// } else {
+// System.arraycopy(upgradeFileDatas, index, newBytes, 6, sub);
+// }
+// newBytes[4] = 0x04;//榛樿鏁版嵁闀垮害涓�1024
+// newBytes[5] = 0x00;
+//
+// return newBytes;
+// }
+//
+//
+// /**
+// * 璁剧疆鐩戝惉浜嬩欢
+// *
+// * @param listener
+// */
+// public static void setIMcuOtaListener(IMcuOtaListener listener) {
+// mIMcuOtaListener = listener;
+// }
+//
+// public static void removeIMcuOtaListener() {
+// mIMcuOtaListener = null;
+// }
+//
+// /**
+// * onProgress
+// *
+// * @param progress
+// */
+// public static void sendIMcuOtaListenerOnProgress(int progress) {
+// if (mIMcuOtaListener != null) {
+// progress = HDLUtlis.getTrueProgressInt(progress);//纭繚progress 鍦�0鍒�100
+// mIMcuOtaListener.onProgress(progress);
+// }
+// }
+//
+// /**
+// * onSuccess
+// */
+// public static void sendIMcuOtaListenerOnSuccess() {
+// if (mIMcuOtaListener != null) {
+// mIMcuOtaListener.onSuccess();
+// }
+// }
+//
+// /**
+// * onFailure
+// *
+// * @param code 閿欒鐮�
+// * @param error 澶辫触鍘熷洜
+// */
+// public static void sendIMcuOtaListeneronFailure(int code, String error) {
+// if (mIMcuOtaListener != null) {
+// mIMcuOtaListener.onFailure(code, error);
+// }
+// }
+//
+//
+//}
+//
+//
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLTtlSdk.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLTtlSdk.java
new file mode 100644
index 0000000..97df209
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HDLTtlSdk.java
@@ -0,0 +1,37 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Core;
+
+import android.content.Context;
+
+import com.hdl.sdk.ttl.Utils.LogUtils.HDLLog;
+
+/**
+ * Created by JLChen on 2019/7/25
+ */
+public class HDLTtlSdk {
+
+ /**
+ * 鍒濆鍖� SDK
+ *
+ * @param context
+ */
+ public static void init(Context context, String mPathname, int mBaudrate) {
+ HDLDeviceManager.init(context);
+ HDLSerialPortCore.initHDLSerialPort(mPathname, mBaudrate);
+ }
+
+ /**
+ * 鏄惁寮�鍚疭DK鏃ュ織鎵撳嵃
+ *
+ * @param bOpen
+ */
+ public static void setHDLLogOpen(boolean bOpen) {
+ HDLLog.setHDLLogOpen(bOpen);
+ }
+
+ /**
+ * 閲婃斁璧勬簮 鍏抽棴涓插彛
+ */
+ public static void release() {
+ HDLDeviceManager.release();
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HandleSearch.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HandleSearch.java
new file mode 100644
index 0000000..84d5095
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/HandleSearch.java
@@ -0,0 +1,560 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Core;
+
+import com.hdl.sdk.ttl.Config.Configuration;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.DevicesData;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.RemarkTimes;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.SearchCountBean;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DevicesInfoEvent;
+import com.hdl.sdk.ttl.Utils.LogUtils.HDLLog;
+
+import org.greenrobot.eventbus.EventBus;
+
+import java.util.List;
+import java.util.Random;
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * Modify by JLChen on 2019/6/27
+ */
+public class HandleSearch {
+ public static boolean isSearching = true;
+ public static int curSearchMode = 0;
+ // public static String rcuIp = "";//涓诲姩浼犲叆鐨剅cu ip鍦板潃
+ // private static Timer getRcuIpTimer = null;//鑾峰彇Rcuip Timer
+// private static Timer getRcuIpFailorSuccessTimer = null;//鑾峰彇Rcuip Timer
+ public static boolean isGetRcuIp = false;
+ private static boolean isRefreshAllDevicesState = false;
+
+ public static Timer searchTimer = null;//鍙戦�佺涓�娆℃悳绱imer
+ public static Timer searchTwiceTimer = null;//鍙戦�佺浜屾鎼滅储Timer
+ public static Timer searchFailTimer = null;//鍙戦�佹悳绱㈠け璐imer
+ public static Timer remarkTimer = null;//鎼滅储澶囨敞Timer
+ private static Timer refreshTimer = null;
+
+ private static int curDevSize;//璁板綍璁惧鎬绘暟銆備綔鐢細姣旇緝鎼滅储鍑烘潵鐨勬�昏澶囨暟
+ public static byte random1 = 0;//闅忔満鏁�1
+ public static byte random2 = 0;//闅忔満鏁�2
+
+ public static final int GET_RCU_DEVICES = 0;//鑾峰彇Rcu妯″潡璁惧
+ public static final int GET_BUS_DEVICES = 1;//鑾峰彇瀹跺眳妯″潡 璁惧
+
+ private static final int SEARCH_POINT_TO_POINT = 100;//鐐瑰鐐�
+ private static final int SEARCH_BROACAST = 101;//骞挎挱
+ private static final int SEARCH_MULTICAST = 102;//缁勬挱
+
+ private static boolean bSearchAll = true; //鏄惁鍏ㄩ儴閲嶆柊鎼滅储锛屾垨鑰呭彂鐜版柊璁惧鎼滅储
+
+ /**
+ * 閰掑簵鎼滅储
+ * <p>
+ * <p>
+ * 杩欐柟娉曟殏鏃朵笉鎻愪緵锛岃幏鍙栧娉ㄥ綋涓篃娌℃湁澶勭悊姝ょ被鍨嬨��
+ * <p>
+ * 鑾峰彇Rcu ip鍦板潃
+ */
+// private static void getRcuIp() {
+// isGetRcuIp = true;
+// HDLSerialPortCore.closeMulticast6000();
+// HDLSerialPortCore.initMulticastSocket6008();
+// if (getRcuIpFailorSuccessTimer != null) {
+// getRcuIpFailorSuccessTimer.cancel();
+// getRcuIpFailorSuccessTimer = null;
+// }
+// if (getRcuIpTimer != null) {
+// getRcuIpTimer.cancel();
+// getRcuIpTimer = null;
+// }
+//
+// getRcuIpTimer = new Timer();
+// getRcuIpFailorSuccessTimer = new Timer();
+// HDLDeviceManager.isGetRcuIpSuccess = false;
+// HDLDeviceManager.rcuIpList.clear();
+//
+// getRcuIpTimer.schedule(new TimerTask() {
+// @Override
+// public void run() {
+//// 姣�400姣鍙戦�佷竴娆�
+// if (!HDLDeviceManager.isGetRcuIpSuccess) {
+// baseSearch(SEARCH_MULTICAST, Configuration.RCU_SEND_PORT);
+// }
+//
+//
+// }
+// }, 1, 200);
+//
+//
+// getRcuIpFailorSuccessTimer.schedule(new TimerTask() {
+// @Override
+// public void run() {
+// isGetRcuIp = false;
+// if (getRcuIpTimer != null) {
+// getRcuIpTimer.cancel();
+// getRcuIpTimer = null;
+// }
+//// 鑻ユ病鏈夊洖澶嶅垯澶辫触锛屽紑濮嬪灞呮悳绱€�傝嫢鏈夊洖澶嶅垯淇濆瓨Rcu ip鍦板潃,寮�濮嬮厭搴楀崗璁悳绱㈢浜屾
+// if (HDLDeviceManager.isGetRcuIpSuccess) {
+// HDLDeviceManager.isGetRcuIpSuccess = false;
+// //杩斿洖ip鍦板潃鍒楄〃锛屽鏋滃彧鏈変竴涓笉杩斿洖锛岀洿鎺ユ悳绱€��
+// switch (HDLDeviceManager.rcuIpList.size()) {
+// case 0:
+// searchDevices(GET_BUS_DEVICES, SEARCH_BROACAST, Configuration.PORT);//瀹跺眳鎼滅储
+// break;
+// case 1:
+// rcuIp = HDLDeviceManager.rcuIpList.get(0);
+// HDLLog.I("鎼滅储鍒扮殑rcu ip鍦板潃锛�" + rcuIp);
+// searchDevices(GET_RCU_DEVICES, SEARCH_POINT_TO_POINT, Configuration.RCU_SEND_PORT);//RCU妯″潡鎼滅储
+// break;
+// default:
+// //杩斿洖鐢ㄦ埛閫夋嫨鍝釜rcuIp
+// EventBus.getDefault().post(new RcuIpListEvent(HDLDeviceManager.rcuIpList));
+// break;
+// }
+//
+// } else {
+// HDLLog.I("寮�濮嬪灞呭崗璁悳绱�");
+// searchDevices(GET_BUS_DEVICES, SEARCH_BROACAST, Configuration.PORT);//瀹跺眳鎼滅储
+// }
+// }
+// }, 1000);
+// }
+
+// /**
+// * 閰掑簵鎼滅储
+// * 鑾峰彇Rcu妯″潡璁惧
+// */
+// public static void getRcuDevices(Context context, String newRcuIp) {
+// curSearchMode = GET_RCU_DEVICES;
+// rcuIp = newRcuIp;
+// SPUtils.setParam(context, SPUtils.KEY_RCU_IP_, newRcuIp);
+// searchDevices(GET_RCU_DEVICES, SEARCH_POINT_TO_POINT, Configuration.RCU_SEND_PORT);
+// }
+
+
+ /**
+ * 鍏ㄩ儴閲嶆柊鎼滅储,娓呯┖鍘熻澶囧垪琛ㄦ暟鎹�
+ */
+ public static void getHomeDevices() {
+ bSearchAll = true;
+ curSearchMode = GET_BUS_DEVICES;
+ searchDevices(GET_BUS_DEVICES, SEARCH_BROACAST, Configuration.PORT);//瀹跺眳鎼滅储
+ }
+
+ /**
+ * 鍙戠幇鏂拌澶囨悳绱�,涓嶄細娓呯┖鍘熻澶囧垪琛ㄦ暟鎹�
+ * 鍙兘鎼滅储鍙戠幇涓嶅瓨鍦╮ealDevicesDataList閲岄潰鐨勬柊璁惧
+ */
+ public static void getNewHomeDevices() {
+ bSearchAll = false;
+ curSearchMode = GET_BUS_DEVICES;
+ searchDevices(GET_BUS_DEVICES, SEARCH_BROACAST, Configuration.PORT);//瀹跺眳鎼滅储
+ }
+
+ /**
+ * 鍒濆鍖栨悳绱�
+ *
+ * @param searchMode 鎼滅储妯″紡
+ * @param baseSearchType 鍩虹鎼滅储绫诲瀷
+ * @param
+ */
+ private static void searchDevices(final int searchMode, final int baseSearchType, final int port) {
+ isSearching = true;
+ isRefreshAllDevicesState = false;
+
+ if (searchTimer != null) {
+ searchTimer.cancel();
+ searchTimer.purge();
+ searchTimer = null;
+ }
+
+ if (searchFailTimer != null) {
+ searchFailTimer.cancel();
+ searchFailTimer.purge();
+ searchFailTimer = null;
+ }
+ if (remarkTimer != null) {
+ remarkTimer.cancel();
+ remarkTimer.purge();
+ remarkTimer = null;
+ }
+
+ searchTimer = new Timer();
+ searchFailTimer = new Timer();
+
+ int max = 254;
+ int min = 1;
+ random1 = (byte) (new Random().nextInt(max + 1) % (max - min + 1) + min);
+ random2 = (byte) (new Random().nextInt(max + 1) % (max - min + 1) + min);
+
+ baseSearch(baseSearchType, port);
+
+// 鍒濆鍖栨悳绱㈣秴鏃讹紝5000姣鍚庯紝鏃犳悳绱㈣澶囨暟鎹繑鍥炲垯鎼滅储瓒呮椂
+ searchFailTimer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ if (HDLDeviceManager.devicesDataList.size() == 0) {
+// 杩斿洖鎼滅储瓒呮椂
+ if (searchTimer != null) {
+ searchTimer.cancel();
+ searchTimer.purge();
+ searchTimer = null;
+ }
+
+ switch (searchMode) {
+ case GET_RCU_DEVICES:
+ HDLLog.I("Rcu璁惧鎼滅储瓒呮椂");
+// searchDevices(GET_BUS_DEVICES, SEARCH_BROACAST, Configuration.PORT);//瀹跺眳鎼滅储
+ EventBus.getDefault().post(new DevicesInfoEvent(false));//涓嶈繘琛屽灞呮悳绱紝鐩存帴鍋滄
+ break;
+ case GET_BUS_DEVICES:
+ //瀹跺眳鍗忚鎼滅储瓒呮椂
+ HDLLog.I("瀹跺眳璁惧鎼滅储瓒呮椂");
+ EventBus.getDefault().post(new DevicesInfoEvent(false));
+ break;
+ }
+ }
+ }
+ }, 5000);
+
+ if (searchTimer == null) {
+ return;
+ }
+
+ //TODO 鍙兘浼氫负绌�
+ searchTimer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+// 姣忛殧500姣鍒ゆ柇褰撳墠鐨勮澶囨暟涓庢悳绱㈠嚭鏉ョ殑璁惧鏁版槸鍚︿竴鑷�
+ if (curDevSize != HDLDeviceManager.realDevicesDataList.size() || HDLDeviceManager.realDevicesDataList.size() == 0) {
+ //鏈夋柊璁惧锛岀户缁瓑寰�500姣
+ if (searchTwiceTimer != null) {
+ searchTwiceTimer.cancel();
+ searchTwiceTimer.purge();
+ searchTwiceTimer = null;
+ HDLLog.I("鏈夋柊璁惧闃绘柇鍙戦�佹悳绱㈠懡浠�");
+ }
+ if (HDLDeviceManager.realDevicesDataList.size() == 0) {
+ baseSearch(baseSearchType, port);
+ } else {
+ curDevSize = HDLDeviceManager.realDevicesDataList.size();
+ HDLLog.I("鏈夋柊璁惧锛岀户缁瓑寰�500姣");
+ }
+
+ } else {
+ if (searchTwiceTimer == null) {
+ searchTwiceTimer = new Timer();
+ final SearchCountBean bean = new SearchCountBean();
+ bean.setCount(0);
+ searchTwiceTimer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ if (bean.getCount() < 3) {
+ HDLLog.I("娌℃湁鏀跺埌鏂拌澶囷紝鍙戦�佺 " + (bean.getCount() + 1) + " 娆℃悳绱㈠懡浠�");
+ secondTimeSearch(random1, random2, HDLDeviceManager.realDevicesDataList);
+ } else {
+ if (searchTimer != null) {
+ searchTimer.cancel();
+ searchTimer.purge();
+ searchTimer = null;
+ }
+ if (searchTwiceTimer != null) {
+ searchTwiceTimer.cancel();
+ searchTwiceTimer.purge();
+ searchTwiceTimer = null;
+ }
+
+ isSearching = false;
+ HDLLog.I("寮�濮嬭幏鍙栨瘡涓ā鍧楃殑鍥炶矾鐘舵�佷笌澶囨敞");
+ getDevRemarks();//寮�濮嬭幏鍙栫涓�澶囨敞锛岄�愪竴鑾峰彇銆�
+ }
+ bean.setCount(bean.getCount() + 1);
+ }
+ }, 1, 800);
+ }
+
+
+ }
+ }
+ }, 500, 500);
+ }
+
+ /**
+ * 鍙戦�佺涓�娆℃悳绱�
+ *
+ * @param type 鎼滅储绫诲瀷
+ * @param port 绔彛鍙�
+ */
+ private static void baseSearch(int type, int port) {
+// 璁惧鍒楄〃銆佽澶囧娉ㄥ垪琛ㄥ垵濮嬪寲娓呯┖
+ if (remarkTimer != null) {
+ remarkTimer.cancel();
+ remarkTimer.purge();
+ remarkTimer = null;
+ }
+ isRefreshAllDevicesState = false;
+ /*** 鍏ㄩ儴閲嶆柊鎼滅储鎵嶆竻绌簂ist鏁扮粍*/
+ if(bSearchAll) {
+ HDLDeviceManager.devicesDataList.clear();
+ HDLDeviceManager.realDevicesDataList.clear();
+ HDLDeviceManager.listRemarks.clear();
+ curDevSize = 0;
+ }
+
+// 鍙戦�佺涓�娆℃悳绱㈠懡浠�
+ switch (type) {
+ case SEARCH_POINT_TO_POINT:
+ HDLLog.I("鍙戦�佺涓�娆CU鎼滅储");
+ HDLCommand.cusSendCommand(Configuration.DEVICES_SEARCH_COMMAND,
+ 255, 255, new byte[]{random1, random2});
+ break;
+ case SEARCH_BROACAST:
+ HDLLog.I("鍙戦�佺涓�娆″灞呮悳绱�");
+ HDLCommand.cusSendCommand(Configuration.DEVICES_SEARCH_COMMAND,
+ 255, 255, new byte[]{random1, random2});
+ break;
+ case SEARCH_MULTICAST:
+ HDLCommand.cusSendMulticastCommand(Configuration.DEVICES_SEARCH_COMMAND,
+ 255, 255
+ , new byte[]{random1, random2});
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * 鍙戦�佺浜屾鎼滅储
+ *
+ * @param arg1 闅忔満鏁�1
+ * @param arg2 闅忔満鏁�2
+ * @param devicesDataList 鎵�鏈夎澶囦俊鎭泦
+ */
+ public static void secondTimeSearch(byte arg1, byte arg2, List<DevicesData> devicesDataList) {
+ if (devicesDataList == null || devicesDataList.size() == 0) {
+ return;
+ }
+ int devicesCount = 32;
+ int count = devicesDataList.size() / devicesCount;
+ int remainder = devicesDataList.size() % devicesCount;
+// HDLLog.I("kkkkcount:"+count+" remainder: "+remainder);
+ if (remainder != 0) {
+ count++;
+ }
+ outter:
+ for (int j = 0; j < count; j++) {
+ byte[] bytes;
+ int remainder2;
+ if (j != count - 1
+ || (count == 1 && remainder == 0)
+ ) {
+ remainder2 = devicesCount;
+ } else {
+ remainder2 = remainder;
+ }
+
+ bytes = new byte[2 + remainder2 * 2];
+ bytes[0] = arg1;
+ bytes[1] = arg2;
+ for (int k = 0; k < remainder2; k++) {
+ if ((devicesCount * j + k >= devicesDataList.size()) || ((2 + 2 * k + 1) >= bytes.length)) {
+ break outter;
+ }
+ bytes[2 + 2 * k] = (byte) devicesDataList.get(devicesCount * j + k).getSourceSubnetID();
+ bytes[2 + 2 * k + 1] = (byte) devicesDataList.get(devicesCount * j + k).getSourceDeviceID();
+ }
+
+ String sendData = "";
+ for (int i = 0; i < bytes.length; i++) {
+ if (i % 2 != 0) {
+ if ((i / 2) == 0) {
+ sendData += (bytes[i] & 0xff) + "(闅忔満鏁�)";
+ } else {
+ sendData += (bytes[i] & 0xff) + "(绗�" + (i / 2) + "涓ā鍧楋級,";
+ }
+ } else {
+ sendData += (bytes[i] & 0xff) + ",";
+ }
+ }
+ HDLLog.I("绗簩娆″彂閫佺殑鎼滅储鏁版嵁锛�" + sendData);
+ HDLCommand.cusSendCommand(Configuration.DEVICES_SEARCH_COMMAND, 255, 255, bytes);
+ }
+ }
+
+//
+// /**
+// * 杩斿洖璁惧鍒楄〃
+// */
+// public static void deviceListCallBack() {
+// byte[] debugBytes = new byte[6 + HDLDeviceManager.devicesDataList.size() * 2];
+// debugBytes[0] = 1;
+// debugBytes[1] = 1;
+// debugBytes[2] = 1;
+// debugBytes[3] = 1;
+// debugBytes[4] = 1;
+// debugBytes[5] = 1;
+//
+// for (int i = 0; i < HDLDeviceManager.devicesDataList.size(); i++) {
+// debugBytes[6 + i + i] = (byte) HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID();
+// debugBytes[6 + i + i + 1] = (byte) HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID();
+// String device = "绗� " + (i + 1) + " 涓ā鍧楋細妯″潡澶囨敞鍚嶇О锛�" + HDLDeviceManager.devicesDataList.get(i).getRemark()
+// + ",瀛愮綉鍙凤細" + HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID()
+// + ",璁惧鍙凤細" + HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID()
+// + ",鍥炶矾鏁帮細" + HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().size() + "\n";
+// HDLLog.I(device);
+// }
+//// HDLSerialPortCore.sendTestCMD(debugBytes, HDLTest.SEND_TEST_PORT);
+// EventBus.getDefault().post(new DevicesInfoEvent(HDLDeviceManager.devicesDataList, true));
+// }
+
+ /**
+ * 杩斿洖璁惧鍒楄〃
+ * 2019-07-01
+ */
+ public static void OnDeviceListGetSuccessCallBack() {
+ EventBus.getDefault().post(new DevicesInfoEvent(HDLDeviceManager.devicesDataList, true));
+ /**鎼滅储璁惧鎴愬姛锛屾墽琛屼竴娆′繚瀛樺埌鏈湴*/
+ HDLDeviceManager.saveDevicesDataList();
+ }
+
+
+ /**
+ * 椹笂鍒锋柊鎵�鏈夎澶囨暟鎹紝鍒锋柊澶囨敞鍚嶅拰鍏跺畠鐘舵�佸弬鏁�
+ *
+ * @param
+ */
+ public static void refreshAllDevicesStateNow() {
+ if (isSearching) {
+ isRefreshAllDevicesState = false;
+ return;
+ }
+ isRefreshAllDevicesState = true;
+ for (int i = 0; i < HDLDeviceManager.listRemarks.size(); i++) {
+ HDLDeviceManager.listRemarks.get(i).setCallBack(false);
+ }
+ getDevRemarks();
+ }
+
+// /**
+// * 寤惰繜30S鍚庯紝鍙戦�佸埛鏂版暟鎹懡浠�
+// *
+// * @param
+// */
+// public static void refreshAllDevicesState() {
+// if (refreshTimer != null) {
+// refreshTimer.cancel();
+// refreshTimer.purge();
+// refreshTimer = null;
+// }
+// if (isSearching) {
+// isRefreshAllDevicesState = false;
+// return;
+// }
+//
+// refreshTimer = new Timer();
+// refreshTimer.schedule(new TimerTask() {
+// @Override
+// public void run() {
+// isRefreshAllDevicesState = true;
+// for (int i = 0; i < HDLDeviceManager.listRemarks.size(); i++) {
+// HDLDeviceManager.listRemarks.get(i).setCallBack(false);
+// }
+// getDevRemarks();
+// }
+// }, 1000 * 30);
+// }
+
+
+ /**
+ * 鑾峰彇澶囨敞
+ *
+ * @param
+ */
+ public static void getDevRemarks() {
+ if (remarkTimer != null) {
+ remarkTimer.cancel();
+// remarkTimer.purge();
+ remarkTimer = null;
+ }
+ if ((HDLDeviceManager.listRemarks != null && HDLDeviceManager.listRemarks.size() == 0) || isSearching) {
+ isRefreshAllDevicesState = false;
+ if(HDLDeviceManager.devicesDataList != null && HDLDeviceManager.devicesDataList.size() > 0){
+ HandleSearch.OnDeviceListGetSuccessCallBack();
+ }
+ return;
+ }
+ int pos = -1;
+ for (int i = 0; i < HDLDeviceManager.listRemarks.size(); i++) {
+ if (!HDLDeviceManager.listRemarks.get(i).isCallBack()) {
+ pos = i;
+ break;
+ }
+ }
+
+ //鍒ゆ柇鏄惁鑾峰彇璁惧澶囨敞瀹屽叏锛岃嫢瀹屽叏鍒欒繑鍥炴墍鏈夎澶囧垪琛ㄣ��
+ if (HDLDeviceManager.listRemarks != null && HDLDeviceManager.listRemarks.size() != 0 && pos == -1) {
+ if (!isRefreshAllDevicesState) {
+ HandleSearch.OnDeviceListGetSuccessCallBack();
+ } else {
+ //鍒锋柊瀹屾瘯
+ // TODO: 2018/12/29 鍒锋柊瀹屾瘯鍙兘瑕佸仛鏌愪簺浜嬫儏
+ HDLLog.I("鍒锋柊璁惧鐘舵�佸畬姣�");
+ isRefreshAllDevicesState = false;
+ HandleSearch.OnDeviceListGetSuccessCallBack();
+ }
+
+ return;
+ }
+ remarkTimer = new Timer();
+ final int newPos = pos;
+ final RemarkTimes remarkTimes = new RemarkTimes();
+ remarkTimes.setCount(0);
+
+ if (remarkTimer == null) {
+ return;
+ }
+ remarkTimer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ if (remarkTimes.getCount() < 3) {
+ remarkTimes.setCount(remarkTimes.getCount() + 1);
+ if (newPos < HDLDeviceManager.listRemarks.size()) {
+// int port = 0;
+// String ipAddress = "";
+ switch (curSearchMode) {
+ case HandleSearch.GET_RCU_DEVICES:
+// ipAddress = rcuIp;
+// port = Configuration.RCU_SEND_PORT;
+ break;
+ case HandleSearch.GET_BUS_DEVICES:
+// ipAddress = NetWorkUtil.getLocalBroadCast();
+// ipAddress = HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getIpAddress();
+// port = Configuration.PORT;
+ break;
+ }
+ HDLLog.I("----->鍙戦�佽幏鍙栧娉ㄥ懡浠ゃ�傚叡" + HDLDeviceManager.listRemarks.size() + "涓ā鍧椼�傜"
+ + newPos + "涓ā鍧椼�傜 " + (HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getChannelNum())
+ + " 鍥炶矾锛屽瓙缃戝彿锛�" + HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getDeviceSubnetID()
+ + "锛岃澶囧彿锛�" + HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getDeviceDeviceID()
+ + " 绗� " + remarkTimes.getCount() + " 娆�");
+ HDLCommand.cusSendCommand(Configuration.DEVICES_READ_COMMAND,
+ HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getDeviceSubnetID()
+ , HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getDeviceDeviceID(),
+ new byte[]{
+ (byte) HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getBigType(),
+ (byte) HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getLittleType(),
+ (byte) HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getChannelNum()});
+ }
+ } else {
+
+ if (HDLDeviceManager.listRemarks != null
+ && HDLDeviceManager.listRemarks.size() != 0
+ && newPos < HDLDeviceManager.listRemarks.size()) {
+ HDLDeviceManager.listRemarks.get(newPos).setCallBack(true);
+ }
+ getDevRemarks();
+ }
+ }
+ }, 1, 1200);
+
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/MCUCrc.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/MCUCrc.java
new file mode 100644
index 0000000..ca56b47
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Core/MCUCrc.java
@@ -0,0 +1,58 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Core;
+
+import com.hdl.sdk.ttl.Config.MCUConstants;
+
+/**
+ * Created by JLChen on 2019/7/12
+ */
+public class MCUCrc {
+
+ public byte[] addBytes;
+ public int mcuCommand = 0;
+
+ public MCUCrc(int command, byte[] addBytes) {
+ this.mcuCommand = command;
+ this.addBytes = addBytes;
+ }
+
+ /**
+ * 榄旈暅MCU鍗忚
+ * @return
+ */
+ public byte[] getMCUSendBytes() {
+
+ byte[] sendBytes = new byte[5 + this.addBytes.length];
+
+ //Boot code
+ sendBytes[0] = (byte) MCUConstants.MCU_BOOT_HEAD;
+ sendBytes[1] = (byte) mcuCommand;
+ sendBytes[2] = (byte) ((this.addBytes.length) / 256); //鏁版嵁闀垮害锛氬幓闄ゅ紩瀵煎ご鐨勯暱搴�
+ sendBytes[3] = (byte) ((this.addBytes.length) % 256); //鏁版嵁闀垮害锛氬幓闄ゅ紩瀵煎ご鐨勯暱搴�
+
+ System.arraycopy(this.addBytes, 0, sendBytes, 4, this.addBytes.length);
+
+ sendBytes[sendBytes.length-1] = getMcuChecksum(sendBytes); //璁剧疆鏍¢獙鐮�
+
+ return sendBytes;
+ }
+
+
+ /**
+ * 鏍¢獙鐮佽绠�
+ * @param packet
+ * @return
+ * 澶村紩瀵肩爜鍜屽熬鏍¢獙鐮佷笉妫�楠� 鎵�浠=1锛屽紑濮� i < (packet.length - 2)
+ */
+ public static byte getMcuChecksum(byte[] packet)
+ {
+ byte mSum = 0;
+ for(int i = 0; i < (packet.length - 1); i++)
+ {
+ mSum += (byte)packet[i];
+ }
+ mSum = (byte) ((~mSum) + 1);
+ return mSum;
+
+ }
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/AirFeedBackEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/AirFeedBackEvent.java
new file mode 100644
index 0000000..5deebe4
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/AirFeedBackEvent.java
@@ -0,0 +1,27 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+
+import com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition.AirCtrlBackInfo;
+
+/**
+ * Created by djl on 2017/4/5.
+ */
+
+public class AirFeedBackEvent {
+ AirCtrlBackInfo airCtrlBackInfo;
+ boolean isSuccess;
+
+ public AirFeedBackEvent( AirCtrlBackInfo airCtrlBackInfo,boolean isSuccess){
+ this.airCtrlBackInfo = airCtrlBackInfo;
+ this.isSuccess = isSuccess;
+ }
+
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public AirCtrlBackInfo getAirCtrlBackInfo() {
+ return airCtrlBackInfo;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/AirHVACFeedBackEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/AirHVACFeedBackEvent.java
new file mode 100644
index 0000000..b4ba171
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/AirHVACFeedBackEvent.java
@@ -0,0 +1,24 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+import com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition.AirHVACBackInfo;
+
+/**
+ * Created by JLChen on 2019/8/6
+ */
+public class AirHVACFeedBackEvent {
+ AirHVACBackInfo mAirHVACBackInfo;
+ boolean isSuccess;
+
+ public AirHVACFeedBackEvent(AirHVACBackInfo airHVACBackInfo, boolean isSuccess){
+ this.mAirHVACBackInfo = airHVACBackInfo;
+ this.isSuccess = isSuccess;
+ }
+
+ public AirHVACBackInfo getAirHVACBackInfo() {
+ return mAirHVACBackInfo;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/AppliancesInfoEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/AppliancesInfoEvent.java
new file mode 100644
index 0000000..558ba13
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/AppliancesInfoEvent.java
@@ -0,0 +1,21 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+
+import java.util.List;
+
+/**
+ * Created by djl on 2017/4/5.
+ */
+
+public class AppliancesInfoEvent {
+ public List<AppliancesInfo> appliancesInfos;
+ public AppliancesInfoEvent(List<AppliancesInfo> appliancesInfos){
+ this.appliancesInfos = appliancesInfos;
+ }
+
+ public List<AppliancesInfo> getAppliancesInfos() {
+ return appliancesInfos;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/AudioInfoEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/AudioInfoEvent.java
new file mode 100644
index 0000000..beabd39
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/AudioInfoEvent.java
@@ -0,0 +1,69 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+
+import java.util.List;
+
+/**
+ * Created by Tommy on 2017/11/2.
+ */
+
+public class AudioInfoEvent {
+ AppliancesInfo appliancesInfo;
+ int type;
+ List<String> songNameList ;
+ int audioInfoInt;
+ int[] audioListInfo ;
+ String audioInfoStr;
+ public AudioInfoEvent(int type, List<String> songNameList, AppliancesInfo appliancesInfo){
+ this.appliancesInfo = appliancesInfo;
+ this.type = type;
+ this.songNameList = songNameList;
+ }
+
+ public AudioInfoEvent(int type, int audioInfoInt, AppliancesInfo appliancesInfo){
+ this.appliancesInfo = appliancesInfo;
+ this.type = type;
+ this.audioInfoInt = audioInfoInt;
+ }
+
+ public AudioInfoEvent(int type, int[] audioListInfo , AppliancesInfo appliancesInfo){
+ this.appliancesInfo = appliancesInfo;
+ this.type = type;
+ this.audioListInfo = audioListInfo;
+ }
+
+ public AudioInfoEvent(int type, String audioInfoStr, AppliancesInfo appliancesInfo){
+ this.appliancesInfo = appliancesInfo;
+ this.type = type;
+ this.audioInfoStr = audioInfoStr;
+ }
+
+ public AppliancesInfo getAppliancesInfo() {
+ return appliancesInfo;
+ }
+
+ public int getAudioInfoInt() {
+ return audioInfoInt;
+ }
+
+ public String getAudioInfoStr() {
+ return audioInfoStr;
+ }
+
+ public int[] getAudioListInfo() {
+ return audioListInfo;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public List<String> getSongNameList() {
+ return songNameList;
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/BgmInfoEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/BgmInfoEvent.java
new file mode 100644
index 0000000..b47f355
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/BgmInfoEvent.java
@@ -0,0 +1,52 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+public class BgmInfoEvent {
+ public static final int PLAY_STOP = 0;//鎾斁鎴栧仠姝€�傚嵆褰撳墠鍋滄灏辨挱鏀撅紝褰撳墠鎾斁灏卞仠姝�
+ public static final int PLAY_PAUSE = 1;//鎾斁鎴栨殏鍋溿�傚嵆褰撳墠鏆傚仠灏辨挱鏀撅紝褰撳墠鎾斁灏辨殏鍋�
+ public static final int PLAY = 2;//鎾斁
+ public static final int STOP = 3;//鍋滄鎾斁
+ public static final int STATUS = 4;//鑾峰彇褰撳墠姝屾洸鐘舵��
+ public static final int LIST_PRE = 5;//鑾峰彇涓婁竴鎾斁鍒楄〃銆�
+ public static final int LIST_NEXT = 6;//鑾峰彇涓嬩竴鎾斁鍒楄〃
+ public static final int SONG_PRE = 7;//涓婁竴鏇�
+ public static final int SONG_NEXT = 8;//涓嬩竴鏇�
+ public static final int SONG_DEMAND = 9;//鐐规挱褰撳墠鎾斁鍒楄〃鐨勭 N 棣栨瓕锛孲DK鎻愪緵N鍊�
+ public static final int VOL_SET = 10;//璁剧疆 N 鍊奸煶閲忋�係DK鎻愪緵N鍊�
+ public static final int MODE_PRE = 11;//涓婁竴鎾斁妯″紡
+ public static final int MODE_NEXT = 12;//涓嬩竴鎾斁妯″紡
+ public static final int MODE_CURRENT = 13;//璇诲彇褰撳墠鎾斁妯″紡
+ public static final int SOURCE_MUSIC = 14;//鎸囧畾闊虫簮
+ public static final int TYPE = 15;//璇诲彇姝屾洸绫诲瀷鐩綍
+
+
+
+
+ private int type;
+ private int value;
+
+ private byte[] addBytes;
+
+ public BgmInfoEvent(int type ){
+
+ }
+
+ public BgmInfoEvent(int type,int value ){
+
+ }
+
+ public BgmInfoEvent(byte[] addBytes ){
+ this.addBytes = addBytes;
+ }
+
+ public byte[] getAddBytes() {
+ return addBytes;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public int getValue() {
+ return value;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/CommonSwitchCtrlBackEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/CommonSwitchCtrlBackEvent.java
new file mode 100644
index 0000000..2d0dca8
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/CommonSwitchCtrlBackEvent.java
@@ -0,0 +1,27 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+
+import com.hdl.sdk.ttl.HDLAppliances.HDLCommonSwitch.CommonSwitchBackInfo;
+
+
+/**
+ * Created by jlchen on 2020-04-01.
+ */
+public class CommonSwitchCtrlBackEvent {
+ CommonSwitchBackInfo mCommonSwitchBackInfo;
+ boolean isSuccess;
+
+ public CommonSwitchCtrlBackEvent(CommonSwitchBackInfo commonSwitchBackInfo, boolean isSuccess){
+ this.isSuccess = isSuccess;
+ this.mCommonSwitchBackInfo = commonSwitchBackInfo;
+ }
+
+ public CommonSwitchBackInfo getCommonSwitchBackInfo() {
+ return mCommonSwitchBackInfo;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/CommonSwitchStateBackEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/CommonSwitchStateBackEvent.java
new file mode 100644
index 0000000..4ba52df
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/CommonSwitchStateBackEvent.java
@@ -0,0 +1,27 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+
+import com.hdl.sdk.ttl.HDLAppliances.HDLCommonSwitch.CommonSwitchBackInfo;
+
+
+/**
+ * Created by jlchen on 2020-04-01.
+ */
+public class CommonSwitchStateBackEvent {
+ CommonSwitchBackInfo mCommonSwitchBackInfo;
+ boolean isSuccess;
+
+ public CommonSwitchStateBackEvent(CommonSwitchBackInfo commonSwitchBackInfo, boolean isSuccess){
+ this.isSuccess = isSuccess;
+ this.mCommonSwitchBackInfo = commonSwitchBackInfo;
+ }
+
+ public CommonSwitchBackInfo getCommonSwitchBackInfo() {
+ return mCommonSwitchBackInfo;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/CurtainFeedBackEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/CurtainFeedBackEvent.java
new file mode 100644
index 0000000..f089c0b
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/CurtainFeedBackEvent.java
@@ -0,0 +1,28 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+
+import com.hdl.sdk.ttl.HDLAppliances.HDLCurtain.CurtainCtrlBackInfo;
+
+/**
+ * Created by djl on 2017/4/5.
+ */
+
+public class CurtainFeedBackEvent {
+ CurtainCtrlBackInfo curtainCtrlBackInfo;
+ boolean isSuccess;
+
+ public CurtainFeedBackEvent(CurtainCtrlBackInfo curtainCtrlBackInfo,boolean isSuccess){
+ this.curtainCtrlBackInfo = curtainCtrlBackInfo;
+ this.isSuccess = isSuccess;
+ }
+
+
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public CurtainCtrlBackInfo getCurtainCtrlBackInfo() {
+ return curtainCtrlBackInfo;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/DeviceFeedbackEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/DeviceFeedbackEvent.java
new file mode 100644
index 0000000..e5c9b8d
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/DeviceFeedbackEvent.java
@@ -0,0 +1,18 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+/**
+ * Created by djl on 2017/3/29.
+ */
+
+public class DeviceFeedbackEvent {
+ public Object obj;
+
+ public DeviceFeedbackEvent(Object obj){
+ this.obj = obj;
+ }
+
+ public Object getObj() {
+ return obj;
+ }
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/DeviceStateEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/DeviceStateEvent.java
new file mode 100644
index 0000000..667d7cb
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/DeviceStateEvent.java
@@ -0,0 +1,28 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+
+/**
+ * Created by djl on 2017/4/6.
+ */
+
+public class DeviceStateEvent {
+ public AppliancesInfo appliancesInfo;
+ boolean isSuccess;
+
+ public DeviceStateEvent(AppliancesInfo appliancesInfo, boolean isSuccess){
+ this.appliancesInfo = appliancesInfo;
+ this.isSuccess = isSuccess;
+ }
+
+
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public AppliancesInfo getAppliancesInfo() {
+ return appliancesInfo;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/DevicesInfoEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/DevicesInfoEvent.java
new file mode 100644
index 0000000..7f23a8c
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/DevicesInfoEvent.java
@@ -0,0 +1,33 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.DevicesData;
+
+import java.util.List;
+
+/**
+ * Created by djl on 2017/3/27.
+ */
+
+public class DevicesInfoEvent {
+ public List<DevicesData> desDataList;
+ public boolean isSuccess;
+
+ public DevicesInfoEvent(List<DevicesData> desDataList,boolean isSuccess){
+ this.desDataList = desDataList;
+ this.isSuccess = isSuccess;
+ }
+
+ public DevicesInfoEvent(boolean isSuccess){
+ this.isSuccess = isSuccess;
+ }
+
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public List<DevicesData> getDesDataList() {
+ return desDataList;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/DiscoverNewDevicesEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/DiscoverNewDevicesEvent.java
new file mode 100644
index 0000000..6428ad3
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/DiscoverNewDevicesEvent.java
@@ -0,0 +1,19 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.DevicesData;
+
+/**
+ * Created by JLChen on 2019/7/3
+ * 鍙戠幇鏂拌澶嘐vent浜嬩欢
+ */
+public class DiscoverNewDevicesEvent {
+
+ public DevicesData newDevicesData;
+
+ public DiscoverNewDevicesEvent(DevicesData mDevicesData){
+ this.newDevicesData = mDevicesData;
+ }
+
+ public DevicesData getnewDevicesData() {
+ return newDevicesData;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/EventCode.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/EventCode.java
new file mode 100644
index 0000000..22e745a
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/EventCode.java
@@ -0,0 +1,17 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+
+/**
+ * Created by JLChen on 2019/7/24
+ */
+public class EventCode {
+ public static final int SUCCESS = 0;
+ public static final int FAILURE_TIMEOUT = -1;//澶辫触瓒呮椂
+ public static final int FAILURE_DATA_ERROR = -2;//鏁版嵁閿欒
+
+// @IntDef({SUCCESS, FAILURE_TIMEOUT, FAILURE_DATAEMPTY, FAILURE_DATA_ERROR})
+// @Retention(RetentionPolicy.SOURCE)
+// public @interface EventCodeID{}
+
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/HetDevicesCtrlEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/HetDevicesCtrlEvent.java
new file mode 100644
index 0000000..2c17677
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/HetDevicesCtrlEvent.java
@@ -0,0 +1,16 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+/**
+ * Created by djl on 2017/4/12.
+ */
+
+public class HetDevicesCtrlEvent {
+ private byte[] bytes;
+ public HetDevicesCtrlEvent(byte[] bytes){
+ this.bytes = bytes;
+ }
+
+ public byte[] getBytes() {
+ return bytes;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/LightFeedBackEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/LightFeedBackEvent.java
new file mode 100644
index 0000000..c70d4ef
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/LightFeedBackEvent.java
@@ -0,0 +1,26 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+
+import com.hdl.sdk.ttl.HDLAppliances.HDLLight.LightCtrlBackInfo;
+
+/**
+ * Created by djl on 2017/4/5.
+ */
+
+public class LightFeedBackEvent {
+ LightCtrlBackInfo lightCtrlBackInfo;
+ boolean isSuccess;
+
+ public LightFeedBackEvent(LightCtrlBackInfo lightCtrlBackInfo,boolean isSuccess){
+ this.isSuccess = isSuccess;
+ this.lightCtrlBackInfo = lightCtrlBackInfo;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public LightCtrlBackInfo getLightCtrlBackInfo() {
+ return lightCtrlBackInfo;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/LogicFeedBackEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/LogicFeedBackEvent.java
new file mode 100644
index 0000000..51a4e7b
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/LogicFeedBackEvent.java
@@ -0,0 +1,28 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+
+import com.hdl.sdk.ttl.HDLAppliances.HDLLogic.LogicCtrlBackInfo;
+
+/**
+ * Created by Tommy on 2017/7/20.
+ */
+
+public class LogicFeedBackEvent {
+ LogicCtrlBackInfo logicCtrlBackInfo;
+ boolean isSuccess;
+
+ public LogicFeedBackEvent( LogicCtrlBackInfo logicCtrlBackInfo,boolean isSuccess){
+ this.isSuccess = isSuccess;
+ this.logicCtrlBackInfo = logicCtrlBackInfo;
+ }
+
+
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public LogicCtrlBackInfo getLogicCtrlBackInfo() {
+ return logicCtrlBackInfo;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/MCUFeedBackEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/MCUFeedBackEvent.java
new file mode 100644
index 0000000..2944846
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/MCUFeedBackEvent.java
@@ -0,0 +1,36 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.MCUDataBean;
+
+/**
+ * Created by JLChen on 2019/7/23
+ */
+public class MCUFeedBackEvent {
+ MCUDataBean mMCUDataBean;
+ int mEventCode;
+ String error;
+
+ public MCUFeedBackEvent( MCUDataBean mcuDataBean, int mEventCode){
+ this.mMCUDataBean = mcuDataBean;
+ this.mEventCode = mEventCode;
+ this.error = "";
+ }
+
+ public MCUFeedBackEvent( MCUDataBean mcuDataBean, int mEventCode, String error){
+ this.mMCUDataBean = mcuDataBean;
+ this.mEventCode = mEventCode;
+ this.error = error;
+ }
+
+ public MCUDataBean getMCUDataBean() {
+ return mMCUDataBean;
+ }
+
+ public int getEventCode() {
+ return mEventCode;
+ }
+
+ public String getError() {
+ return error;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/MideaDevicesCtrlEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/MideaDevicesCtrlEvent.java
new file mode 100644
index 0000000..039d94f
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/MideaDevicesCtrlEvent.java
@@ -0,0 +1,16 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+/**
+ * Created by Tommy on 2017/5/10.
+ */
+
+public class MideaDevicesCtrlEvent {
+ private byte[] bytes;
+ public MideaDevicesCtrlEvent(byte[] bytes){
+ this.bytes = bytes;
+ }
+
+ public byte[] getBytes() {
+ return bytes;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/RCUSaveEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/RCUSaveEvent.java
new file mode 100644
index 0000000..8dedc90
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/RCUSaveEvent.java
@@ -0,0 +1,17 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+/**
+ * Created by Tommy on 2018/2/25.
+ */
+
+public class RCUSaveEvent {
+ String msg ;
+
+ public RCUSaveEvent(String msg){
+ this.msg = msg;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/RcuIpListEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/RcuIpListEvent.java
new file mode 100644
index 0000000..bd3bd08
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/RcuIpListEvent.java
@@ -0,0 +1,16 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+import java.util.List;
+
+public class RcuIpListEvent {
+ List<String> rcuIpList ;
+
+
+ public RcuIpListEvent(List<String> rcuIpList){
+ this.rcuIpList = rcuIpList;
+ }
+
+ public List<String> getRcuIpList() {
+ return rcuIpList;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/SceneInfoEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/SceneInfoEvent.java
new file mode 100644
index 0000000..8db52d2
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/SceneInfoEvent.java
@@ -0,0 +1,33 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.DevicesData;
+
+import java.util.List;
+
+/**
+ * Created by Tommy on 2017/10/16.
+ */
+
+public class SceneInfoEvent {
+ public List<DevicesData> desDataList;
+ public boolean isSuccess;
+
+ public SceneInfoEvent(List<DevicesData> desDataList,boolean isSuccess){
+ this.desDataList = desDataList;
+ this.isSuccess = isSuccess;
+ }
+
+ public SceneInfoEvent(boolean isSuccess){
+ this.isSuccess = isSuccess;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+
+ public List<DevicesData> getDesDataList() {
+ return desDataList;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/SecurityAlarmFeedBackEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/SecurityAlarmFeedBackEvent.java
new file mode 100644
index 0000000..22f7e58
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/SecurityAlarmFeedBackEvent.java
@@ -0,0 +1,24 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+import com.hdl.sdk.ttl.HDLAppliances.HDLSecurity.SecurityBackInfo;
+
+/**
+ * Created by JLChen on 2019/7/29
+ */
+public class SecurityAlarmFeedBackEvent {
+ SecurityBackInfo mSecurityBackInfo;
+ boolean isSuccess;
+
+ public SecurityAlarmFeedBackEvent(SecurityBackInfo securityBackInfo, boolean isSuccess){
+ this.mSecurityBackInfo = securityBackInfo;
+ this.isSuccess = isSuccess;
+ }
+
+ public SecurityBackInfo getSecurityBackInfo() {
+ return mSecurityBackInfo;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/SecurityArmingFeedBackEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/SecurityArmingFeedBackEvent.java
new file mode 100644
index 0000000..7496688
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/SecurityArmingFeedBackEvent.java
@@ -0,0 +1,35 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+import com.hdl.sdk.ttl.HDLAppliances.HDLSecurity.SecurityBackInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+
+/**
+ * Created by JLChen on 2019/7/29
+ */
+public class SecurityArmingFeedBackEvent {
+ AppliancesInfo appliancesInfo;
+ int armingState;
+ boolean isSuccess;
+
+ public SecurityArmingFeedBackEvent(boolean isSuccess){
+ this.isSuccess = isSuccess;
+ }
+
+ public SecurityArmingFeedBackEvent(AppliancesInfo mAppliancesInfo, int armingState, boolean isSuccess){
+ this.appliancesInfo = mAppliancesInfo;
+ this.armingState = armingState;
+ this.isSuccess = isSuccess;
+ }
+
+ public int getArmingState() {
+ return armingState;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public AppliancesInfo getAppliancesInfo() {
+ return appliancesInfo;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/ThirdPartyBgmInfoEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/ThirdPartyBgmInfoEvent.java
new file mode 100644
index 0000000..d34f569
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/ThirdPartyBgmInfoEvent.java
@@ -0,0 +1,14 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+public class ThirdPartyBgmInfoEvent {
+ private byte[] bytes;
+
+ public ThirdPartyBgmInfoEvent(byte[] bytes){
+ this.bytes = bytes;
+ }
+
+
+ public byte[] getBytes() {
+ return bytes;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/UpdateRemarkFeedBackEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/UpdateRemarkFeedBackEvent.java
new file mode 100644
index 0000000..2bd27d0
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/UpdateRemarkFeedBackEvent.java
@@ -0,0 +1,17 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+/**
+ * Created by JLChen on 2019/7/2
+ */
+public class UpdateRemarkFeedBackEvent {
+ boolean isSuccess;
+
+
+ public UpdateRemarkFeedBackEvent(boolean isSuccess) {
+ this.isSuccess = isSuccess;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/WarningInfoEvent.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/WarningInfoEvent.java
new file mode 100644
index 0000000..cbd42e8
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/EventBusEvent/WarningInfoEvent.java
@@ -0,0 +1,17 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent;
+
+/**
+ * Created by Tommy on 2017/10/10.
+ */
+
+public class WarningInfoEvent {
+ int warningTypeId ;
+
+ public WarningInfoEvent(int warningType){
+ this.warningTypeId = warningType;
+ }
+
+ public int getWarningTypeId() {
+ return warningTypeId;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/HDLListener/IMcuOtaListener.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/HDLListener/IMcuOtaListener.java
new file mode 100644
index 0000000..d7035bb
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/HDLListener/IMcuOtaListener.java
@@ -0,0 +1,24 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.HDLListener;
+
+/**
+ * Created by JLChen on 2019/7/24
+ */
+public interface IMcuOtaListener {
+ /**
+ * 鍗囩骇鎴愬姛鍥炶皟
+ */
+ void onSuccess();
+
+ /**
+ * 鍗囩骇澶辫触鍥炶皟
+ * @param code
+ */
+ void onFailure(int code, String error);
+
+ /**
+ * 鍗囩骇杩涘害鍥炶皟
+ * @param progress
+ */
+ void onProgress(int progress);
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Parser/DeviceParser.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Parser/DeviceParser.java
new file mode 100644
index 0000000..abf4465
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/HDLDeviceManger/Parser/DeviceParser.java
@@ -0,0 +1,969 @@
+package com.hdl.sdk.ttl.HDLDeviceManger.Parser;
+
+import com.hdl.sdk.ttl.Config.Configuration;
+import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.DevicesData;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLDeviceManager;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HandleSearch;
+import com.hdl.sdk.ttl.Utils.LogUtils.HDLLog;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLDeviceManager.devicesDataList;
+
+/**
+ * Created by djl on 2017/3/29.
+ */
+
+public class DeviceParser {
+
+ /**
+ * 澶勭悊瑙f瀽銆佽缃煇涓�鍥炶矾鐨勬墍鏈変俊鎭�
+ *
+ * @param addBytes
+ * @param devicesData
+ * @param parentRemarks
+ * @return 172.168.52.51 鍥轰欢鐗堟湰鍙�2018/08/29
+ */
+ public static boolean parse(byte[] addBytes, DevicesData devicesData, String parentRemarks) {
+ boolean isExitData = false;
+ int residue = addBytes.length - 22;
+ int sumCount = residue / 3;//璁板綍鎬诲叡鏈夊灏戠璁惧
+ List<AppliancesInfo> appliancesInfoList = new ArrayList<>();
+ if (sumCount == 0) {
+ AppliancesInfo appliancesInfo = new AppliancesInfo();
+ appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE);
+ appliancesInfoList.add(appliancesInfo);
+ }
+// HDLLog.I("sumCount" + sumCount);
+ int curCount = 0;//寰幆閬嶅巻鎵�鏈夎澶囨鏁�
+ while (curCount < sumCount) {
+ int bigType = addBytes[21 + (2 * curCount) + (curCount + 1)] & 0xFF;
+ int littleType = addBytes[21 + (2 * curCount) + (curCount + 2)] & 0xFF;
+ int channelNum = addBytes[21 + (2 * curCount) + (curCount + 3)] & 0xFF;
+ curCount++;
+ int curChannelNum = 0;
+ while (curChannelNum < channelNum) {
+ curChannelNum++;
+ if (isWantData(bigType, littleType)) {
+ AppliancesInfo appliancesInfo = new AppliancesInfo();
+ /**鏍规嵁绫诲埆锛岃祴鍊兼搷浣滅爜绛変竴浜涢噸瑕佷俊鎭�*/
+ switch (bigType) {
+ case Configuration.LIGTH_BIG_TYPE:
+ parseLightData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+ case Configuration.CURTAIN_BIG_TYPE:
+ parseCurtainData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+ case Configuration.AIR_BIG_TYPE:
+ parseAirData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+ case Configuration.AUDIO_BIG_TYPE:
+ parseAudioData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+ case Configuration.LOGIC_BIG_TYPE:
+ parseLogicData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+ case Configuration.GLOBAL_LOGIC_BIG_TYPE:
+ parseGlobalLogicData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+ case Configuration.SECURITY_BIG_TYPE://2019-7-29 鏂板
+ parseSecurityData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+ case Configuration.SENSOR_BIG_TYPE://2019-07-03 灞忚斀
+ parseSensorData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+ case Configuration.COMMON_SWITCH_BIG_TYPE://2020-04-01 閫氱敤寮�鍏�
+ parseCommonSwitchData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+
+ default:
+// appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE);
+ break;
+ }
+
+ isExitData = true;
+ String key = "K" + appliancesInfo.getBigType()
+ + "-" + appliancesInfo.getLittleType()
+ + "-" + appliancesInfo.getDeviceSubnetID()
+ + "-" + appliancesInfo.getDeviceDeviceID()
+ + "-" + appliancesInfo.getChannelNum();
+
+ appliancesInfo.setDeviceKey(key);//2019-8-2 娣诲姞鍞竴鏍囪瘑key
+ appliancesInfoList.add(appliancesInfo);
+// HDLLog.I( "鍚戞ā鍧楁坊鍔犲洖璺細"+"澶х被锛�" + bigType + " 灏忕被锛�" + littleType +" 妯″潡澶囨敞" + devicesData.getRemark() );
+ } else {
+// HDLLog.I( "涓嶆槸瑕佹坊鍔犵殑璁惧锛氬ぇ绫伙細" + bigType + " 灏忕被锛�" + littleType +" 妯″潡澶囨敞" + devicesData.getRemark() );
+ }
+ }
+ }
+ if (isExitData && devicesData != null) {
+ devicesData.setAppliancesInfoList(appliancesInfoList);
+ }
+ return isExitData;
+ }
+
+
+ /**
+ * 鍒ゆ柇鏄惁鏀寔鐨勮澶囷紝鑻ヤ笉鏄敮鎸佽澶囧垯杩囨护鎺夈��
+ * 閫氳繃鍒ゆ柇澶х被灏忕被锛岄�夋嫨鏄惁杩囨护璁惧
+ *
+ * @param bigType
+ * @param littleType
+ * @return SDK鐩墠鏀寔鐨勫ぇ绫伙細灏忕被
+ * 鐏厜绫�1锛�0 锛�1锛�9锛�10
+ * 绐楀笜绫�2锛�0锛�1锛�2
+ * 浼犳劅鍣�5锛�0~24
+ * 绌鸿皟绫�7锛�0锛�3
+ * 鑳屾櫙闊充箰鍔熻兘9锛�0
+ * 閫昏緫鍔熻兘12锛�0
+ * 鍏ㄥ眬鍦烘櫙17锛�0
+ * 瀹夐槻10锛�0
+ */
+ public static boolean isWantData(int bigType, int littleType) {
+ boolean isWant;
+ switch (bigType) {
+ case Configuration.LIGTH_BIG_TYPE:
+ switch (littleType) {
+ case 0:
+ isWant = true;
+ break;
+ case 1:
+ isWant = true;
+ break;
+ case 9:
+ isWant = true;
+ break;
+ case 10:
+ isWant = true;
+ break;
+ default:
+ isWant = false;
+ break;
+ }
+ break;
+ case Configuration.CURTAIN_BIG_TYPE:
+ switch (littleType) {
+ case 0:
+ isWant = true;
+ break;
+ case 1:
+ isWant = true;
+ break;
+ case 2:
+ isWant = true;
+ break;
+ default:
+ isWant = false;
+ break;
+ }
+ break;
+ case Configuration.AIR_BIG_TYPE:
+ switch (littleType) {
+ case 0:
+ isWant = true;
+ break;
+ case 3:
+ isWant = true;
+ break;
+ default:
+ isWant = false;
+ break;
+ }
+ break;
+ case Configuration.AUDIO_BIG_TYPE:
+ switch (littleType) {
+ case 0:
+ isWant = true;
+ break;
+// case 1:
+// isWant = true;
+// break;
+ case 3://2019-7-29
+ isWant = true;
+ break;
+ default:
+ isWant = false;
+ break;
+ }
+ break;
+ case Configuration.SENSOR_BIG_TYPE: //灞忚斀浼犳劅鍣ㄥぇ绫�
+// if (littleType >= 0 && littleType <= 27) {
+// isWant = true;
+// } else {
+// isWant = false;
+// }
+
+ if (littleType == 1 || littleType == 9 || littleType == 11 || (littleType > 24 && littleType <= 27)) {//2019-11-5 鏀逛负鍙敮鎸�6绉嶆劅搴斿櫒
+ isWant = true;
+ } else {
+ isWant = false;
+ }
+ break;
+ case Configuration.LOGIC_BIG_TYPE:
+ switch (littleType) {
+ case 0:
+ isWant = true;
+ break;
+ default:
+ isWant = false;
+ break;
+ }
+ break;
+ case Configuration.SECURITY_BIG_TYPE:
+ switch (littleType) {
+ case 0:
+ isWant = true;
+ break;
+// case 2:
+// isWant = true;
+// break;
+ default:
+ isWant = false;
+ break;
+ }
+ break;
+ case Configuration.GLOBAL_LOGIC_BIG_TYPE://灞忚斀鍏ㄥ眬鍦烘櫙 2019-9-27
+ switch (littleType) {
+ case 0:
+ isWant = true;
+ break;
+ default:
+ isWant = false;
+ break;
+ }
+ break;
+ case Configuration.COMMON_SWITCH_BIG_TYPE://閫氱敤寮�鍏宠澶�
+ switch (littleType) {
+ case 0:
+ isWant = true;
+ break;
+ default:
+ isWant = false;
+ break;
+ }
+ break;
+ default:
+ isWant = false;
+ break;
+ }
+ return isWant;
+ }
+
+
+ private static void parseLightData(int littleType, AppliancesInfo appliancesInfo, DevicesData devicesData, String parentRemarks, int channelNum, int port, String ipAddress) {
+ switch (littleType) {
+ case 0:
+ appliancesInfo.setDeviceName("璋冨厜鍥炶矾");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_LIGHT_DIMMER);
+ break;
+ case 1:
+ appliancesInfo.setDeviceName("寮�鍏冲洖璺�");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_LIGHT_RELAY);
+ break;
+ case 2:
+ appliancesInfo.setDeviceName("閫昏緫鐏帶鍒�");
+ break;
+ case 3:
+ appliancesInfo.setDeviceName("閫昏緫鐏疪GB");
+ break;
+ case 4:
+ appliancesInfo.setDeviceName("閫昏緫鐏疪GBW");
+ break;
+ case 5:
+ appliancesInfo.setDeviceName("閫昏緫鐏疪GB+CCT");
+ break;
+ case 6:
+ appliancesInfo.setDeviceName("娣峰悎绫� Dimmer+Relay");
+ break;
+ case 7:
+ appliancesInfo.setDeviceName("DALI");
+ break;
+ case 8:
+ appliancesInfo.setDeviceName("鑷畾涔夐�昏緫鐏�");
+ break;
+ case 9:
+ appliancesInfo.setDeviceName("娣峰悎璋冨厜绫�");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_LIGHT_MIX_DIMMER);
+ break;
+ case 10:
+ appliancesInfo.setDeviceName("娣峰悎寮�鍏崇被");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_LIGHT_MIX_RELAY);
+ break;
+ default:
+ appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE);
+ break;
+ }
+ if (devicesData != null) {
+ appliancesInfo.setChannelNum(channelNum);
+ appliancesInfo.setBigType(Configuration.LIGTH_BIG_TYPE);
+ appliancesInfo.setLittleType(littleType);
+ appliancesInfo.setCtrlCommand(Configuration.LIGHT_CTRL_COMMAND);
+ appliancesInfo.setCtrlBackCommand(Configuration.LIGHT_CTRL_BACK_COMMAND);
+ appliancesInfo.setStateCommand(Configuration.LIGHT_STATE_COMMAND);
+ appliancesInfo.setStateBackCommand(Configuration.LIGHT_STATE_BACK_COMMAND);
+ appliancesInfo.setDeviceSubnetID(devicesData.getSourceSubnetID());
+ appliancesInfo.setDeviceDeviceID(devicesData.getSourceDeviceID());
+ appliancesInfo.setParentRemarks(parentRemarks);
+// appliancesInfo.setPort(port);
+// appliancesInfo.setIpAddress(ipAddress);
+ }
+ }
+
+ private static void parseCurtainData(int littleType, AppliancesInfo appliancesInfo, DevicesData devicesData, String parentRemarks, int channelNum, int port, String ipAddress) {
+ switch (littleType) {
+ case 0:
+ appliancesInfo.setDeviceName("寮�鍚堝笜鐢垫満");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_CURTAIN_GLYSTRO);
+ break;
+ case 1:
+ appliancesInfo.setDeviceName("鍗峰笜鐢垫満");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_CURTAIN_ROLLER);
+ break;
+ case 2:
+ appliancesInfo.setDeviceName("绐楀笜妯″潡");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_CURTAIN_MODULE);
+ break;
+ default:
+ appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE);
+ break;
+
+ }
+ if (devicesData != null) {
+ appliancesInfo.setChannelNum(channelNum);
+ appliancesInfo.setBigType(Configuration.CURTAIN_BIG_TYPE);
+ appliancesInfo.setLittleType(littleType);
+ appliancesInfo.setCtrlCommand(Configuration.CURTAIN_CTRL_COMMAND);
+ appliancesInfo.setCtrlBackCommand(Configuration.CURTAIN_CTRL_BACK_COMMAND);
+ appliancesInfo.setStateCommand(Configuration.CURTAIN_STATE_COMMAND);
+ appliancesInfo.setStateBackCommand(Configuration.CURTAIN_STATE_BACK_COMMAND);
+ appliancesInfo.setDeviceSubnetID(devicesData.getSourceSubnetID());
+ appliancesInfo.setDeviceDeviceID(devicesData.getSourceDeviceID());
+ appliancesInfo.setParentRemarks(parentRemarks);
+// appliancesInfo.setPort(port);
+// appliancesInfo.setIpAddress(ipAddress);
+ }
+ }
+
+ private static void parseAirData(int littleType, AppliancesInfo appliancesInfo, DevicesData devicesData, String parentRemarks, int channelNum, int port, String ipAddress) {
+ switch (littleType) {
+ case 0:
+ appliancesInfo.setDeviceName("HVAC 妯″潡");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_AC_HVAC);
+ break;
+ case 1:
+ appliancesInfo.setDeviceName("Coolmaster 鎺у埗妯″潡");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_AC_COOLMASTER);
+ break;
+ case 2:
+ appliancesInfo.setDeviceName("绾㈠绌鸿皟妯″潡");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_AC_INFRARED);
+ break;
+ case 3:
+ appliancesInfo.setDeviceName("閫氱敤绌鸿皟闈㈡澘");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_AC_PANEL);
+ break;
+ default:
+ appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE);
+ break;
+
+ }
+ if (devicesData != null) {
+ appliancesInfo.setChannelNum(channelNum);
+ appliancesInfo.setBigType(Configuration.AIR_BIG_TYPE);
+ appliancesInfo.setLittleType(littleType);
+ appliancesInfo.setDeviceSubnetID(devicesData.getSourceSubnetID());
+ appliancesInfo.setDeviceDeviceID(devicesData.getSourceDeviceID());
+ appliancesInfo.setParentRemarks(parentRemarks);
+// appliancesInfo.setPort(port);
+// appliancesInfo.setIpAddress(ipAddress);
+ if (littleType == 0) {
+ appliancesInfo.setCtrlCommand(Configuration.AIR_HVAC_CTRL_COMMAND);
+ appliancesInfo.setCtrlBackCommand(Configuration.AIR_HVAC_CTRL_BACK_COMMAND);
+ appliancesInfo.setStateCommand(Configuration.AIR_HVAC_STATE_COMMAND);
+ appliancesInfo.setStateBackCommand(Configuration.AIR_HVAC_STATE_BACK_COMMAND);
+ } else {
+ appliancesInfo.setCtrlCommand(Configuration.AIR_CTRL_COMMAND);
+ appliancesInfo.setCtrlBackCommand(Configuration.AIR_CTRL_BACK_COMMAND);
+ appliancesInfo.setStateCommand(Configuration.AIR_STATE_COMMAND);
+ appliancesInfo.setStateBackCommand(Configuration.AIR_STATE_BACK_COMMAND);
+
+ }
+
+
+ }
+ }
+
+ private static void parseAudioData(int littleType, AppliancesInfo appliancesInfo, DevicesData devicesData, String parentRemarks, int channelNum, int port, String ipAddress) {
+ switch (littleType) {
+ case 0:
+ appliancesInfo.setDeviceName("鑳屾櫙闊充箰妯″潡");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_MUSIC_MODULE);
+ break;
+// case 1:
+// appliancesInfo.setDeviceName("绗笁鏂硅儗鏅煶涔愭ā鍧�");
+// appliancesInfo.setDeviceType(HDLApConfig.TYPE_MUSIC_THIRD_PARTY_MODULE);
+// break;
+// case 3:
+// appliancesInfo.setDeviceName("2018鏂拌儗鏅煶涔愭ā鍧�");
+// appliancesInfo.setDeviceType(HDLApConfig.TYPE_MUSIC_NEW_MODULE);
+// break;
+ default:
+ break;
+ }
+
+ if (devicesData != null) {
+ appliancesInfo.setChannelNum(channelNum);
+ appliancesInfo.setBigType(Configuration.AUDIO_BIG_TYPE);
+ appliancesInfo.setLittleType(littleType);
+ appliancesInfo.setCtrlCommand(Configuration.AUDIO_CTRL_READ_COMMAND);
+ appliancesInfo.setCtrlBackCommand(Configuration.AUDIO_CTRL_READ_BACK_COMMAND);
+ appliancesInfo.setStateCommand(Configuration.AUDIO_MenuPlay_INSTRUCTION_COMMAND);
+ appliancesInfo.setStateBackCommand(Configuration.AUDIO_MenuPlay_INSTRUCTION_BACK_COMMAND);
+ appliancesInfo.setDeviceSubnetID(devicesData.getSourceSubnetID());
+ appliancesInfo.setDeviceDeviceID(devicesData.getSourceDeviceID());
+ appliancesInfo.setParentRemarks(parentRemarks);
+// appliancesInfo.setPort(port);
+// appliancesInfo.setIpAddress(ipAddress);
+ }
+ HDLLog.I("闊充箰妯″潡锛�" + parentRemarks);
+ }
+
+ private static void parseLogicData(int littleType, AppliancesInfo appliancesInfo, DevicesData devicesData, String parentRemarks, int channelNum, int port, String ipAddress) {
+ switch (littleType) {
+ case 0:
+ appliancesInfo.setDeviceName("閫昏緫妯″潡");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_LOGIC_MODULE);
+ break;
+ default:
+ appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE);
+ break;
+ }
+
+ if (devicesData != null) {
+ appliancesInfo.setChannelNum(channelNum);
+ appliancesInfo.setBigType(Configuration.LOGIC_BIG_TYPE);
+ appliancesInfo.setLittleType(littleType);
+ appliancesInfo.setCtrlCommand(Configuration.LOGIC_CTRL_COMMAND);
+ appliancesInfo.setCtrlBackCommand(Configuration.LOGIC_CTRL_BACK_COMMAND);
+ appliancesInfo.setStateCommand(Configuration.LOGIC_STATE_COMMAND);
+ appliancesInfo.setStateBackCommand(Configuration.LOGIC_STATE_BACK_COMMAND);
+ appliancesInfo.setDeviceSubnetID(devicesData.getSourceSubnetID());
+ appliancesInfo.setDeviceDeviceID(devicesData.getSourceDeviceID());
+ appliancesInfo.setParentRemarks(parentRemarks);
+// appliancesInfo.setPort(port);
+// appliancesInfo.setIpAddress(ipAddress);
+
+
+ }
+ }
+
+ private static void parseGlobalLogicData(int littleType, AppliancesInfo appliancesInfo, DevicesData devicesData, String parentRemarks, int channelNum, int port, String ipAddress) {
+ switch (littleType) {
+ case 0:
+ appliancesInfo.setDeviceName("鍏ㄥ眬閫昏緫妯″潡");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_GLOBAL_LOGIC_MODULE);
+ break;
+ default:
+ appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE);
+ break;
+ }
+
+ if (devicesData != null) {
+ appliancesInfo.setChannelNum(channelNum);
+ appliancesInfo.setBigType(Configuration.GLOBAL_LOGIC_BIG_TYPE);
+ appliancesInfo.setLittleType(littleType);
+ appliancesInfo.setCtrlCommand(Configuration.LOGIC_CTRL_COMMAND);
+ appliancesInfo.setCtrlBackCommand(Configuration.LOGIC_CTRL_BACK_COMMAND);
+ appliancesInfo.setStateCommand(Configuration.LOGIC_STATE_COMMAND);
+ appliancesInfo.setStateBackCommand(Configuration.LOGIC_STATE_BACK_COMMAND);
+ appliancesInfo.setDeviceSubnetID(devicesData.getSourceSubnetID());
+ appliancesInfo.setDeviceDeviceID(devicesData.getSourceDeviceID());
+ appliancesInfo.setParentRemarks(parentRemarks);
+// appliancesInfo.setPort(port);
+// appliancesInfo.setIpAddress(ipAddress);
+
+
+ }
+ }
+
+ /**
+ * 2019-7-29 鏂板
+ *
+ * @param littleType
+ * @param appliancesInfo
+ * @param devicesData
+ * @param parentRemarks
+ * @param channelNum
+ * @param port
+ * @param ipAddress
+ */
+ private static void parseSecurityData(int littleType, AppliancesInfo appliancesInfo, DevicesData devicesData, String parentRemarks, int channelNum, int port, String ipAddress) {
+ switch (littleType) {
+ case 0:
+ appliancesInfo.setDeviceName("瀹夐槻妯″潡");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SECURITY_MODULE);
+ break;
+// case 2:
+// appliancesInfo.setDeviceName("瀹夐槻鎺у埗闈㈡澘");
+// appliancesInfo.setDeviceType(HDLApConfig.SECURITY_CONTROL_PANEL);
+// break;
+ default:
+ appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE);
+ break;
+
+ }
+ if (devicesData != null) {
+ appliancesInfo.setChannelNum(channelNum);
+ appliancesInfo.setBigType(Configuration.SECURITY_BIG_TYPE);
+ appliancesInfo.setLittleType(littleType);
+ appliancesInfo.setDeviceSubnetID(devicesData.getSourceSubnetID());
+ appliancesInfo.setDeviceDeviceID(devicesData.getSourceDeviceID());
+ appliancesInfo.setParentRemarks(parentRemarks);
+// appliancesInfo.setPort(port);
+// appliancesInfo.setIpAddress(ipAddress);
+ appliancesInfo.setCtrlCommand(Configuration.SECURITY_ARMING_CTRL_COMMAND);//甯冮槻
+ appliancesInfo.setCtrlBackCommand(Configuration.SECURITY_ARMING_CTRL_BACK_COMMAND);//甯冮槻璁剧疆鍙嶉
+ appliancesInfo.setStateCommand(Configuration.SECURITY_STATE_COMMAND);//璇诲彇瀹夐槻璁剧疆
+ appliancesInfo.setStateBackCommand(Configuration.SECURITY_STATE_BACK_COMMAND);//璇诲彇瀹夐槻璁剧疆鍙嶉
+
+
+// if (littleType == 0) {
+// appliancesInfo.setCtrlCommand(Configuration.SECURITY_ARMING_CTRL_COMMAND);//甯冮槻
+// appliancesInfo.setCtrlBackCommand(Configuration.SECURITY_ARMING_CTRL_BACK_COMMAND);
+// appliancesInfo.setStateCommand(Configuration.SECURITY_STATE_COMMAND);
+// appliancesInfo.setStateBackCommand(Configuration.SECURITY_STATE_BACK_COMMAND);
+// } else {
+// appliancesInfo.setCtrlCommand(Configuration.SECURITY_ARMING_CTRL_COMMAND);//甯冮槻
+// appliancesInfo.setCtrlBackCommand(Configuration.SECURITY_ARMING_CTRL_BACK_COMMAND);
+// appliancesInfo.setStateCommand(Configuration.SECURITY_STATE_COMMAND);
+// appliancesInfo.setStateBackCommand(Configuration.SECURITY_STATE_BACK_COMMAND);
+//
+// }
+
+
+ }
+ }
+
+
+ // 2019-07-03 灞忚斀 2019-11-5 浼犳劅鍣ㄩ兘鏀逛负骞叉帴鐐瑰疄鐜�
+ private static void parseSensorData(int littleType, AppliancesInfo appliancesInfo, DevicesData devicesData, String parentRemarks, int curChannelNum, int port, String ipAddress) {
+ switch (littleType) {
+ case 0:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 骞茬粨鐐�");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_DRY_CONTACT);
+ break;
+ case 1:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 绉诲姩鎺㈡祴");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR);
+ break;
+ case 2:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 娓╁害");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_TEMP);
+ break;
+ case 3:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 婀垮害");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_HUMIDITY);
+ break;
+ case 4:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 鐓у害");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_ILLUMINACE);
+ break;
+ case 5:
+ appliancesInfo.setDeviceName("浼犳劅鍣� VOC");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_VOC);
+ break;
+ case 6:
+ appliancesInfo.setDeviceName("浼犳劅鍣� PM2.5");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_PM_2_POINT_5);
+ break;
+ case 7:
+ appliancesInfo.setDeviceName("浼犳劅鍣� CO2");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_C02);
+ break;
+ case 8:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 娑插寲鐭虫补姘�");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_LPG);
+ break;
+ case 9:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 浜哄伐鐓ゆ皵锛圕O锛孒2");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_CO_H2);
+ break;
+ case 10:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 澶╃劧姘旓紙CH4)");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_CH4);
+ break;
+ case 11:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 鐑熼浘");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_SMOG);
+ break;
+ case 12:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 椋庨��");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_WIND_SPEED);
+ break;
+ case 13:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 椋庡帇");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_WIND_PRESSURE);
+ break;
+ case 14:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 娑蹭綋娴侀噺");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_LIQUID_FLOW);
+ break;
+ case 15:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 娑蹭綋鍘嬪姏");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE);
+ break;
+ case 16:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 娑蹭綋娣卞害 ");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH);
+ break;
+ case 17:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 闆ㄩ噺");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_RAIN_FALL);
+ break;
+ case 18:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 閲嶉噺");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_WEIGHT);
+ break;
+ case 19:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 楂樺害/闀垮害");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH);
+ break;
+ case 20:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 鐗╀綋閫熷害");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_OBJECT_SPEED);
+ break;
+ case 21:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 闇囧姩");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_SHAKE);
+ break;
+ case 22:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 鐢靛帇");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_VOLTAGE);
+ break;
+ case 23:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 鐢垫祦");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_ELECTRICITY);
+ break;
+ case 24:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 鍔熺巼");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_POWER);
+ break;
+ case 25:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 姘存蹈");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_FLOODING);
+ break;
+ case 26:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 闂ㄧ绐楃");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_DOOR_MAGNET);
+ break;
+ case 27:
+ appliancesInfo.setDeviceName("浼犳劅鍣� 绱ф�ユ寜閽�");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON);
+ break;
+
+ default:
+ appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE);
+ break;
+ }
+
+
+ if (devicesData != null) {
+ appliancesInfo.setChannelNum(curChannelNum);
+ appliancesInfo.setBigType(Configuration.SENSOR_BIG_TYPE);
+ appliancesInfo.setLittleType(littleType);
+// appliancesInfo.setCtrlCommand(Configuration.LOGIC_CTRL_COMMAND);
+// appliancesInfo.setCtrlBackCommand(Configuration.LOGIC_CTRL_BACK_COMMAND);
+// appliancesInfo.setStateCommand(Configuration.SENSOR_STATE_COMMAND);
+// appliancesInfo.setStateBackCommand(Configuration.SENSOR_STATE_BACK_COMMAND);
+
+ appliancesInfo.setDeviceSubnetID(devicesData.getSourceSubnetID());
+ appliancesInfo.setDeviceDeviceID(devicesData.getSourceDeviceID());
+ appliancesInfo.setParentRemarks(parentRemarks);
+
+ if (littleType == 1) {//鍚搁《绾㈠浼犳劅鍣�
+ appliancesInfo.setStateCommand(Configuration.DRY_CONTACT_STATE_COMMAND);
+ appliancesInfo.setStateBackCommand(Configuration.DRY_CONTACT_STATE_BACK_COMMAND);
+ } else {
+
+ appliancesInfo.setStateCommand(Configuration.DRY_CONTACT_STATE_COMMAND);
+ appliancesInfo.setStateBackCommand(Configuration.DRY_CONTACT_STATE_BACK_COMMAND);
+
+ }
+ }
+
+
+ }
+
+ /**
+ * 2020-04-01
+ * 鏂板閫氱敤寮�鍏�
+ * @param littleType
+ * @param appliancesInfo
+ * @param devicesData
+ * @param parentRemarks
+ * @param channelNum
+ * @param port
+ * @param ipAddress
+ */
+ private static void parseCommonSwitchData(int littleType, AppliancesInfo appliancesInfo, DevicesData devicesData, String parentRemarks, int channelNum, int port, String ipAddress) {
+ switch (littleType) {
+ case 0:
+ appliancesInfo.setDeviceName("閫氱敤寮�鍏�");
+ appliancesInfo.setDeviceType(HDLApConfig.TYPE_COMMON_SWITCH);
+ break;
+ default:
+ appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE);
+ break;
+
+ }
+ if (devicesData != null) {
+ appliancesInfo.setChannelNum(channelNum);
+ appliancesInfo.setBigType(Configuration.COMMON_SWITCH_BIG_TYPE);
+ appliancesInfo.setLittleType(littleType);
+ appliancesInfo.setDeviceSubnetID(devicesData.getSourceSubnetID());
+ appliancesInfo.setDeviceDeviceID(devicesData.getSourceDeviceID());
+ appliancesInfo.setParentRemarks(parentRemarks);
+
+ appliancesInfo.setCtrlCommand(Configuration.COMMON_SWITCH_CTRL_COMMAND);//甯冮槻
+ appliancesInfo.setCtrlBackCommand(Configuration.COMMON_SWITCH_CTRL_BACK_COMMAND);//甯冮槻璁剧疆鍙嶉
+ appliancesInfo.setStateCommand(Configuration.COMMON_SWITCH_STATE_COMMAND);//璇诲彇瀹夐槻璁剧疆
+ appliancesInfo.setStateBackCommand(Configuration.COMMON_SWITCH_STATE_BACK_COMMAND);//璇诲彇瀹夐槻璁剧疆鍙嶉
+
+ }
+ }
+
+
+ /**
+ * @param mBigType
+ * @param mLittleType
+ * @param mSubnetID
+ * @param mDeviceID
+ * @param mChannelNum
+ * @param mRemarks
+ * @return
+ */
+ public static DevicesData addDevicesManuallyWithoutSearching(int mBigType, int mLittleType, int mSubnetID, int mDeviceID, int mChannelNum, String mRemarks) {
+ boolean bWantData = false;
+ DevicesData mDevicesData = new DevicesData();
+ mDevicesData.setSourceSubnetID(mSubnetID);
+ mDevicesData.setSourceDeviceID(mDeviceID);
+ mDevicesData.setRemark(mRemarks);
+
+ List<AppliancesInfo> appliancesInfoList = new ArrayList<>();
+ if (isWantData(mBigType, mLittleType)) {
+ bWantData = true;
+ AppliancesInfo appliancesInfo = getDevicesInfo(mDevicesData, mBigType, mLittleType, mChannelNum, mRemarks, mRemarks);
+
+ appliancesInfoList.add(appliancesInfo);
+// HDLLog.I( "鍚戞ā鍧楁坊鍔犲洖璺細"+"澶х被锛�" + mBigType + " 灏忕被锛�" + mLittleType +" 妯″潡澶囨敞" + mRemarks );
+ } else {
+// HDLLog.I( "涓嶆槸瑕佹坊鍔犵殑璁惧锛氬ぇ绫伙細" + mBigType + " 灏忕被锛�" + mLittleType +" 妯″潡澶囨敞" + mRemarks );
+ }
+
+ if (bWantData) {
+ mDevicesData.setAppliancesInfoList(appliancesInfoList);
+ } else {
+ mDevicesData = null;
+ }
+
+ return mDevicesData;
+ }
+
+ // public static AppliancesInfo GetAppliancesInfo(DevicesData mDevicesData, int mBigType, int mLittleType, int mSubnetID, int mDeviceID, int mChannelNum, String mRemarks) {
+
+
+// public static AppliancesInfo GetAppliancesInfo(DevicesData mDevicesData, int mBigType, int mLittleType, int mSubnetID, int mDeviceID, int mChannelNum, String mRemarks) {
+// AppliancesInfo appliancesInfo = new AppliancesInfo();
+// /**鏍规嵁绫诲埆锛岃祴鍊兼搷浣滅爜绛変竴浜涢噸瑕佷俊鎭�*/
+// switch (mBigType) {
+// case Configuration.LIGTH_BIG_TYPE:
+// parseLightData(mLittleType, appliancesInfo, mDevicesData, mRemarks, mChannelNum, 0, "");
+// break;
+// case Configuration.CURTAIN_BIG_TYPE:
+// parseCurtainData(mLittleType, appliancesInfo, mDevicesData, mRemarks, mChannelNum, 0, "");
+// break;
+// case Configuration.AIR_BIG_TYPE:
+// parseAirData(mLittleType, appliancesInfo, mDevicesData, mRemarks, mChannelNum, 0, "");
+// break;
+// case Configuration.AUDIO_BIG_TYPE:
+// parseAudioData(mLittleType, appliancesInfo, mDevicesData, mRemarks, mChannelNum, 0, "");
+// break;
+// case Configuration.LOGIC_BIG_TYPE:
+// parseLogicData(mLittleType, appliancesInfo, mDevicesData, mRemarks, mChannelNum, 0, "");
+// break;
+// case Configuration.GLOBAL_LOGIC_BIG_TYPE:
+// parseGlobalLogicData(mLittleType, appliancesInfo, mDevicesData, mRemarks, mChannelNum, 0, "");
+// break;
+// case Configuration.SECURITY_BIG_TYPE://2019-7-29 鏂板
+// parseSecurityData(mLittleType, appliancesInfo, mDevicesData, mRemarks, mChannelNum, 0, "");
+// break;
+// case Configuration.SENSOR_BIG_TYPE://2019-07-03 灞忚斀
+// parseSensorData(mLittleType, appliancesInfo, mDevicesData, mRemarks, mChannelNum, 0, "");
+// break;
+// default:
+//// appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE);
+// break;
+// }
+//
+//
+//
+//
+// String key = "K" + appliancesInfo.getBigType()
+// + "-" + appliancesInfo.getLittleType()
+// + "-" + appliancesInfo.getDeviceSubnetID()
+// + "-" + appliancesInfo.getDeviceDeviceID()
+// + "-" + appliancesInfo.getChannelNum();
+// appliancesInfo.setRemarks(mRemarks);
+// appliancesInfo.setDeviceKey(key);//2019-8-2 娣诲姞鍞竴鏍囪瘑key
+// return appliancesInfo;
+// }
+
+
+ /**
+ * @param bigType
+ * @param littleType
+ * @param mSubnetID
+ * @param mDeviceID
+ * @param parentRemarks
+ * @return
+ */
+ public static DevicesData addDevicesManuallyWithoutSearchingAll(int bigType, int littleType, int mSubnetID, int mDeviceID, String parentRemarks, ArrayList<String> parentRemarksList) {
+ boolean bWantData = false;
+ DevicesData devicesData = new DevicesData();
+ devicesData.setSourceSubnetID(mSubnetID);
+ devicesData.setSourceDeviceID(mDeviceID);
+ devicesData.setRemark(parentRemarks);
+
+ List<AppliancesInfo> appliancesInfoList = new ArrayList<>();
+ if (isWantData(bigType, littleType)) {
+ for (int i = 0; i < parentRemarksList.size(); i++) {
+ appliancesInfoList.add(getDevicesInfo(devicesData, bigType, littleType, i + 1, parentRemarks, parentRemarksList.get(i)));
+ }
+ bWantData = true;
+
+// HDLLog.I( "鍚戞ā鍧楁坊鍔犲洖璺細"+"澶х被锛�" + mBigType + " 灏忕被锛�" + mLittleType +" 妯″潡澶囨敞" + mRemarks );
+ } else {
+// HDLLog.I( "涓嶆槸瑕佹坊鍔犵殑璁惧锛氬ぇ绫伙細" + mBigType + " 灏忕被锛�" + mLittleType +" 妯″潡澶囨敞" + mRemarks );
+ }
+
+ if (bWantData) {
+ devicesData.setAppliancesInfoList(appliancesInfoList);
+ devicesDataList.add(devicesData);
+
+ HandleSearch.OnDeviceListGetSuccessCallBack();
+ } else {
+ devicesData = null;
+ }
+
+ return devicesData;
+ }
+
+ public static AppliancesInfo getDevicesInfo(DevicesData devicesData, int bigType, int littleType, int curChannelNum, String parentRemarks, String mRemarks) {
+ AppliancesInfo appliancesInfo = new AppliancesInfo();
+ /**鏍规嵁绫诲埆锛岃祴鍊兼搷浣滅爜绛変竴浜涢噸瑕佷俊鎭�*/
+ switch (bigType) {
+ case Configuration.LIGTH_BIG_TYPE:
+ parseLightData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+ case Configuration.CURTAIN_BIG_TYPE:
+ parseCurtainData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+ case Configuration.AIR_BIG_TYPE:
+ parseAirData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+ case Configuration.AUDIO_BIG_TYPE:
+ parseAudioData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+ case Configuration.LOGIC_BIG_TYPE:
+ parseLogicData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+ case Configuration.GLOBAL_LOGIC_BIG_TYPE:
+ parseGlobalLogicData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+ case Configuration.SECURITY_BIG_TYPE://2019-7-29 鏂板
+ parseSecurityData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+ case Configuration.SENSOR_BIG_TYPE://2019-07-03 灞忚斀
+ parseSensorData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+ case Configuration.COMMON_SWITCH_BIG_TYPE://2020-04-01 閫氱敤寮�鍏�
+ parseCommonSwitchData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, "");
+ break;
+
+ default:
+// appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE);
+ break;
+ }
+
+ String key = "K" + appliancesInfo.getBigType()
+ + "-" + appliancesInfo.getLittleType()
+ + "-" + appliancesInfo.getDeviceSubnetID()
+ + "-" + appliancesInfo.getDeviceDeviceID()
+ + "-" + appliancesInfo.getChannelNum();
+ appliancesInfo.setRemarks(mRemarks);
+ appliancesInfo.setDeviceKey(key);//2019-8-2 娣诲姞鍞竴鏍囪瘑key
+ return appliancesInfo;
+
+ }
+
+
+ /**
+ *
+ * 娣诲姞璁惧鍥炶矾
+ * 濡傛灉瀛樺湪鐩稿悓瀛愮綉鍙� 璁惧鍙凤紝鍒欏綋鎴愭贩鍚堟ā鍧楁坊鍔犲埌璇ュ洖璺笅锛屼笉瀛樺湪鍒欐柊娣诲姞妯″潡
+ * @param bigType
+ * @param littleType
+ * @param mSubnetID
+ * @param mDeviceID
+ * @param parentRemarks
+ * @return
+ */
+ public static DevicesData addDevicesListWithoutSearching(int bigType, int littleType, int mSubnetID, int mDeviceID, int mChannelNum, String mChannelRemark, String parentRemarks) {
+// boolean bWantData = false;
+ if (isWantData(bigType, littleType)) {
+ DevicesData devicesData = new DevicesData();
+ devicesData.setSourceSubnetID(mSubnetID);
+ devicesData.setSourceDeviceID(mDeviceID);
+ devicesData.setRemark(parentRemarks);
+
+ Boolean isFindDevicesData = false;
+ int index = 0;
+ for (int i = 0; i < devicesDataList.size(); i++) {
+ if (devicesDataList.get(i).getSourceSubnetID() == mSubnetID && devicesDataList.get(i).getSourceDeviceID() == mDeviceID) {
+ index = i;
+ isFindDevicesData = true;
+ break;
+ }
+ }
+
+
+ if (isFindDevicesData) {
+ AppliancesInfo mAppliancesInfo = getDevicesInfo(devicesData, bigType, littleType, mChannelNum, parentRemarks, mChannelRemark);
+ devicesDataList.get(index).getAppliancesInfoList().add(mAppliancesInfo);
+ devicesData = devicesDataList.get(index);
+ HandleSearch.OnDeviceListGetSuccessCallBack();
+ } else {
+ List<AppliancesInfo> appliancesInfoList = new ArrayList<>();
+ appliancesInfoList.add(getDevicesInfo(devicesData, bigType, littleType, mChannelNum, parentRemarks, mChannelRemark));
+ devicesData.setAppliancesInfoList(appliancesInfoList);
+ devicesDataList.add(devicesData);
+ HandleSearch.OnDeviceListGetSuccessCallBack();
+
+ }
+
+
+ return devicesData;
+
+ } else {
+ return null;
+
+ }
+
+
+ }
+
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Utils/HDLUtlis/HDLStringUtils.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Utils/HDLUtlis/HDLStringUtils.java
new file mode 100644
index 0000000..d5a3150
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Utils/HDLUtlis/HDLStringUtils.java
@@ -0,0 +1,281 @@
+package com.hdl.sdk.ttl.Utils.HDLUtlis;
+
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+public class HDLStringUtils {
+
+ public static String byte2String(byte[] bytes) {
+ int pos = bytes.length - 1;
+ for (int i = 0; i < bytes.length; i++) {
+
+ if (i != (bytes.length - 1) && (bytes[i] & 0xFF) == 0) {
+ pos = i - 1;
+ break;
+ }
+ }
+ byte[] remarkBytes = new byte[pos + 1];
+ System.arraycopy(bytes, 0, remarkBytes, 0, remarkBytes.length);
+
+ String result = "";
+
+ try {
+ result = new String(remarkBytes, "GB2312");
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ public static byte[] stringtoBytes(String str) {
+ byte[] bytes = new byte[20];
+ try {
+ bytes = str.getBytes("GB2312");
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ return bytes;
+ }
+
+ public static String stringToAscii(String value) {
+
+ StringBuffer sbu = new StringBuffer();
+ char[] chars = value.toCharArray();
+ for (int i = 0; i < chars.length; i++) {
+ if (i != chars.length - 1) {
+ sbu.append((int) chars[i]).append(",");
+ } else {
+ sbu.append((int) chars[i]);
+ }
+ }
+ return sbu.toString();
+ }
+
+ public static String asciiToString(String value) {
+ StringBuffer sbu = new StringBuffer();
+ String[] chars = value.split(",");
+ for (int i = 0; i < chars.length; i++) {
+ sbu.append((char) Integer.parseInt(chars[i]));
+ }
+ return sbu.toString();
+ }
+
+ 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);
+ }
+
+
+
+// //--------------------------20190626鏂板-----------------------------
+// // 鍒ゆ柇濂囨暟鎴栧伓鏁帮紝浣嶈繍绠楋紝鏈�鍚庝竴浣嶆槸1鍒欎负濂囨暟锛屼负0鏄伓鏁�
+// public static int isOdd(int num) {
+// return num & 1;
+// }
+//
+// //-------------------------------------------------------
+// //Hex瀛楃涓茶浆int
+// public static int HexToInt(String inHex) {
+// return Integer.parseInt(inHex, 16);
+// }
+//
+// public static String IntToHex(int intHex){
+// return Integer.toHexString(intHex);
+// }
+//
+// //-------------------------------------------------------
+// //Hex瀛楃涓茶浆byte
+// public static byte HexToByte(String inHex) {
+// return (byte) Integer.parseInt(inHex, 16);
+// }
+//
+ //-------------------------------------------------------
+ //1瀛楄妭杞�2涓狧ex瀛楃
+ public static String Byte2Hex(Byte inByte) {
+ return String.format("%02x", new Object[]{inByte}).toUpperCase();
+ }
+
+ //-------------------------------------------------------
+// //瀛楄妭鏁扮粍杞浆hex瀛楃涓�
+// public static String ByteArrToHex(byte[] inBytArr) {
+// StringBuilder strBuilder = new StringBuilder();
+// for (byte valueOf : inBytArr) {
+// strBuilder.append(Byte2Hex(Byte.valueOf(valueOf)));
+// strBuilder.append(" ");
+// }
+// return strBuilder.toString();
+// }
+
+ //-------------------------------------------------------
+ //瀛楄妭鏁扮粍杞浆hex瀛楃涓诧紝鍙�夐暱搴�
+ public static String ByteArrToHex(byte[] inBytArr, int offset, int byteCount) {
+ StringBuilder strBuilder = new StringBuilder();
+ int j = byteCount;
+ for (int i = offset; i < j; i++) {
+ strBuilder.append(Byte2Hex(Byte.valueOf(inBytArr[i])));
+ }
+ return strBuilder.toString();
+ }
+//
+// //-------------------------------------------------------
+// //杞琱ex瀛楃涓茶浆瀛楄妭鏁扮粍
+// public static byte[] HexToByteArr(String inHex) {
+// byte[] result;
+// int hexlen = inHex.length();
+// if (isOdd(hexlen) == 1) {
+// hexlen++;
+// result = new byte[(hexlen / 2)];
+// inHex = "0" + inHex;
+// } else {
+// result = new byte[(hexlen / 2)];
+// }
+// int j = 0;
+// for (int i = 0; i < hexlen; i += 2) {
+// result[j] = HexToByte(inHex.substring(i, i + 2));
+// j++;
+// }
+// return result;
+// }
+//
+// /**
+// * 鎸夌収鎸囧畾闀垮害鍒囧壊瀛楃涓�
+// *
+// * @param inputString 闇�瑕佸垏鍓茬殑婧愬瓧绗︿覆
+// * @param length 鎸囧畾鐨勯暱搴�
+// * @return
+// */
+// public static List<String> getDivLines(String inputString, int length) {
+// List<String> divList = new ArrayList<>();
+// int remainder = (inputString.length()) % length;
+// // 涓�鍏辫鍒嗗壊鎴愬嚑娈�
+// int number = (int) Math.floor((inputString.length()) / length);
+// for (int index = 0; index < number; index++) {
+// String childStr = inputString.substring(index * length, (index + 1) * length);
+// divList.add(childStr);
+// }
+// if (remainder > 0) {
+// String cStr = inputString.substring(number * length, inputString.length());
+// divList.add(cStr);
+// }
+// return divList;
+// }
+//
+// /**
+// * 璁$畻闀垮害锛屼袱涓瓧鑺傞暱搴�
+// *
+// * @param val value
+// * @return 缁撴灉
+// */
+// public static String twoByte(String val) {
+// if (val.length() > 4) {
+// val = val.substring(0, 4);
+// } else {
+// int l = 4 - val.length();
+// for (int i = 0; i < l; i++) {
+// val = "0" + val;
+// }
+// }
+// return val;
+// }
+//
+// /**
+// * 鏍¢獙鍜�
+// *
+// * @param cmd 鎸囦护
+// * @return 缁撴灉
+// */
+// public static String sum(String cmd) {
+// List<String> cmdList = HDLStringUtils.getDivLines(cmd, 2);
+// int sumInt = 0;
+// for (String c : cmdList) {
+// sumInt += HDLStringUtils.HexToInt(c);
+// }
+// String sum = HDLStringUtils.IntToHex(sumInt);
+// sum = HDLStringUtils.twoByte(sum);
+// cmd += sum;
+// return cmd.toUpperCase();
+// }
+
+
+
+
+// private byte[] formatStyleHDLResponse(String responsePart1, String responsePart2, int maxLen) throws UnsupportedEncodingException {
+// String responsePart3 = HDL_END_STR;
+// byte tmp;
+// byte[] bytePart1 = stringtoBytes(responsePart1);
+// byte[] bytePart2Tmp;
+// byte[] bytePart2;
+// byte[] bytePart3;
+//
+//
+// if(TextUtils.isEmpty(responsePart2)){
+// responsePart2 = " ";
+// }
+//
+// bytePart2Tmp = responsePart2.getBytes("Unicode");
+// bytePart2 = new byte[bytePart2Tmp.length - 2];
+// bytePart3 = stringtoBytes(responsePart3);
+//
+// HDLLog.I( "formatStyle1HDLResponse responsePart1 " + responsePart1 + " responsePart2 " + responsePart2 + " responsePart3 " + responsePart3);
+//
+// System.arraycopy(bytePart2Tmp, 2, bytePart2, 0, bytePart2Tmp.length-2);
+// for(int i=0; i< bytePart2.length; i += 2){
+// tmp = bytePart2[i+1];
+// bytePart2[i+1] = bytePart2[i];
+// bytePart2[i] = tmp;
+// }
+//
+// int copyPart2Len = bytePart2.length;
+// int extUnicodeLen = 2;
+// byte [] byteExtUnicode = new byte[extUnicodeLen];
+// byteExtUnicode[0] = 0x0;
+// byteExtUnicode[1] = 0x3;
+//
+// if((maxLen) < bytePart2.length){
+// copyPart2Len = maxLen;
+// if(copyPart2Len % 2 != 0){
+// copyPart2Len = copyPart2Len/2 * 2;
+// }
+// HDLLog.I( "formatStyle1HDLResponse copyPart2Len=" + copyPart2Len + ", maxLen=" + maxLen);
+// }
+//
+// byte [] byteResponse = new byte[bytePart1.length + copyPart2Len + extUnicodeLen + bytePart3.length];
+//
+//
+// System.arraycopy(bytePart1, 0, byteResponse, 0, bytePart1.length);
+// System.arraycopy(bytePart2, 0, byteResponse, bytePart1.length, copyPart2Len);
+// System.arraycopy(byteExtUnicode, 0, byteResponse, bytePart1.length + copyPart2Len, extUnicodeLen);
+// System.arraycopy(bytePart3, 0, byteResponse, bytePart1.length + copyPart2Len + extUnicodeLen, bytePart3.length);
+//
+// //Utils.printBtyes(bytePart1);
+// //Utils.printBtyes(bytePart2);
+// //Utils.printBtyes(bytePart3);
+// //Utils.printBtyes(byteResponse);
+// return byteResponse;
+// }
+
+// public void sendHDLResponseDISPLINE4() throws UnsupportedEncodingException {
+// //String response = "#S" + 1 + "DISPLINE4,\u0002" + songName + "\u0003" + HDL_END_STR;
+// JDMusicStatus jdMusicStatus = BMClient.getInstance().getJDMusicStatus();
+// String songName = jdMusicStatus.getSong() != null ? jdMusicStatus.getSong().getName(): "No Song";
+//
+// if(mCurHDLDeviceSource == HDL_DEVICE_SRC_BLUETOOTH || mCurHDLDeviceSource == HDL_DEVICE_SRC_LINEIN) {
+// songName = " ";
+// }
+//
+// String unicodeStr = songName;
+// String responsePart1 = "#S" + mCurHDLDeviceSource + "DISPLINE4,\u0002";
+// String responsePart2 = unicodeStr;
+//
+// byte[] byteResponse = formatStyleHDLResponse(responsePart1, responsePart2, HDL_MAX_DISPLINE_2_4_BYTE);
+// sendResponse(byteResponse);
+// return;
+// }
+
+
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Utils/HDLUtlis/HDLUtlis.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Utils/HDLUtlis/HDLUtlis.java
new file mode 100644
index 0000000..8bd411c
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Utils/HDLUtlis/HDLUtlis.java
@@ -0,0 +1,92 @@
+package com.hdl.sdk.ttl.Utils.HDLUtlis;
+
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+
+/**
+ * Created by JLChen on 2019/7/25
+ */
+public class HDLUtlis {
+
+ /**
+ * 灏唎bject杞负Integer绫诲瀷
+ * @param object
+ * @return
+ */
+ public static Integer getIntegerByObject(Object object){
+ Integer in = null;
+ if(object!=null){
+ if(object instanceof Integer){
+ in = (Integer)object;
+ }else if(object instanceof String){
+ in = Integer.parseInt((String)object);
+ }else if(object instanceof Double){
+ in = (int)((double)object);
+ }else if(object instanceof Float){
+ in = (int)((float)object);
+ }else if(object instanceof BigDecimal){
+ in = ((BigDecimal)object).intValue();
+ }else if(object instanceof Long){
+ in = ((Long)object).intValue();
+ }
+ }
+ return in;
+ }
+
+ /**
+ * int绫诲瀷杞�4瀛楄妭byte鏁扮粍
+ * @param mInt
+ * @return 4瀛楄妭byte鏁扮粍
+ */
+ public static byte[] intToByteArray(int mInt) {
+ byte[] result = new byte[4];
+ // 鐢遍珮浣嶅埌浣庝綅
+ result[0] = (byte) ((mInt >> 24) & 0xFF);
+ result[1] = (byte) ((mInt >> 16) & 0xFF);
+ result[2] = (byte) ((mInt >> 8) & 0xFF);
+ result[3] = (byte) (mInt & 0xFF);
+ return result;
+ }
+
+ /**
+ * byte[]杞琲nt
+ * @param bytes
+ * @return
+ */
+ public static int byteArrayToInt(byte[] bytes) {
+ int value = 0;
+ // 鐢遍珮浣嶅埌浣庝綅
+ for (int i = 0; i < 4; i++) {
+ int shift = (4 - 1 - i) * 8;
+ value += (bytes[i] & 0x000000FF) << shift;// 寰�楂樹綅娓�
+ }
+ return value;
+ }
+
+
+ public static float byte2Float(byte[] bytes) {
+ if (bytes.length != 4) {
+ return 0;
+ }
+ byte b[] = bytes;
+ ByteBuffer buf = ByteBuffer.allocateDirect(4);
+// buf=buf.order(ByteOrder.LITTLE_ENDIAN);灏忕鐢ㄨ繖琛屼唬鐮侊紝榛樿澶х杞崲
+ buf.put(b);
+ buf.rewind();
+ float f2 = buf.getFloat();
+ return f2;
+ }
+
+ /**
+ * 璋冩暣int 绫诲瀷鍙傛暟
+ * @return progress
+ */
+ public static int getTrueProgressInt(int progress) {
+ if (progress < 0) {
+ progress = 0;
+ } else if (progress > 100) {
+ progress = 100;
+ }
+ return progress;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Utils/LogUtils/HDLLog.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Utils/LogUtils/HDLLog.java
new file mode 100644
index 0000000..b4bef84
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Utils/LogUtils/HDLLog.java
@@ -0,0 +1,34 @@
+package com.hdl.sdk.ttl.Utils.LogUtils;
+
+import android.util.Log;
+
+public class HDLLog {
+ private static boolean isOpen = true;
+ /**
+ * Info 鎵撳嵃
+ * @param message
+ */
+ public static void I(String message){
+ if(isOpen){
+ Log.i("HDL_TTL",message);
+ }
+ }
+
+ /**
+ * Error 鎵撳嵃绾㈣壊鐨勯敊璇俊鎭�
+ * @param message
+ */
+ public static void E(String message){
+ if(isOpen){
+ Log.e("HDL_TTL",message);
+ }
+ }
+
+ /**
+ * 鏄惁寮�鍚疭DK鏃ュ織鎵撳嵃
+ * @param bOpen
+ */
+ public static void setHDLLogOpen(boolean bOpen){
+ isOpen = bOpen;
+ }
+}
diff --git a/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Utils/SPUtils/SPUtils.java b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Utils/SPUtils/SPUtils.java
new file mode 100644
index 0000000..56d85c0
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/java/com/hdl/sdk/ttl/Utils/SPUtils/SPUtils.java
@@ -0,0 +1,109 @@
+package com.hdl.sdk.ttl.Utils.SPUtils;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+/**
+ * Created by Tommy on 2018/1/19.
+ * <p>
+ * <p>
+ * 淇濆瓨
+ * SPUtils.setParam(this, "String", "xiaanming");
+ * SPUtils.setParam(this, "int", 10);
+ * SPUtils.setParam(this, "boolean", true);
+ * SPUtils.setParam(this, "long", 100L);
+ * SPUtils.setParam(this, "float", 1.1f);
+ * <p>
+ * 鑾峰彇
+ * SPUtils.getParam(this, "String", ""); SPUtils.getParam(TimerActivity.this, "int", 0);
+ * SPUtils.getParam(this, "boolean", false);
+ * SPUtils.getParam(this, "long", 0L);
+ * SPUtils.getParam(this, "float", 0.0f);
+ */
+
+public class SPUtils {
+ /**
+ * 淇濆瓨鍦ㄦ墜鏈洪噷闈㈢殑鏂囦欢鍚�
+ */
+ private static final String FILE_NAME = "sp_sdk_ttl";
+// public static final String KEY_HDL_RCU_IP = "hdlrcuip";
+// public static final String KEY_IS_HDL_RCU = "ishdlrcu";
+// public static final String KEY_LOCAL_REMARK = "localremark";
+// public static final String DEFAULT_REMARK = "榛樿璁惧";
+// public static final String KEY_RCU_IP = "rcuip";
+ public static final String KEY_SUB_ID = "subid";
+ public static final String KEY_DEVICE_ID = "deviceid";
+
+ public static final String KEY_DEVICE_DATA_LIST = "devicedatalist";
+
+ public static final int DEFAULT_SUB_ID = 254;
+ public static final int DEFAULT_DEVICE_ID = 88;
+
+
+ /**
+ * 淇濆瓨鏁版嵁鐨勬柟娉曪紝鎴戜滑闇�瑕佹嬁鍒颁繚瀛樻暟鎹殑鍏蜂綋绫诲瀷锛岀劧鍚庢牴鎹被鍨嬭皟鐢ㄤ笉鍚岀殑淇濆瓨鏂规硶
+ *
+ * @param context
+ * @param key
+ * @param object
+ */
+ public static void setParam(Context context, String key, Object object) {
+
+ String type = object.getClass().getSimpleName();
+ SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
+ SharedPreferences.Editor editor = sp.edit();
+
+ if ("String".equals(type)) {
+ editor.putString(key, (String) object);
+ } else if ("Integer".equals(type)) {
+ editor.putInt(key, (Integer) object);
+ } else if ("Boolean".equals(type)) {
+ editor.putBoolean(key, (Boolean) object);
+ } else if ("Float".equals(type)) {
+ editor.putFloat(key, (Float) object);
+ } else if ("Long".equals(type)) {
+ editor.putLong(key, (Long) object);
+ }
+
+ editor.commit();
+ }
+
+
+ /**
+ * 寰楀埌淇濆瓨鏁版嵁鐨勬柟娉曪紝鎴戜滑鏍规嵁榛樿鍊煎緱鍒颁繚瀛樼殑鏁版嵁鐨勫叿浣撶被鍨嬶紝鐒跺悗璋冪敤鐩稿浜庣殑鏂规硶鑾峰彇鍊�
+ *
+ * @param context
+ * @param key
+ * @param defaultObject
+ * @return
+ */
+ public static Object getParam(Context context, String key, Object defaultObject) {
+ String type = defaultObject.getClass().getSimpleName();
+ SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
+
+ if ("String".equals(type)) {
+ return sp.getString(key, (String) defaultObject);
+ } else if ("Integer".equals(type)) {
+ return sp.getInt(key, (Integer) defaultObject);
+ } else if ("Boolean".equals(type)) {
+ return sp.getBoolean(key, (Boolean) defaultObject);
+ } else if ("Float".equals(type)) {
+ return sp.getFloat(key, (Float) defaultObject);
+ } else if ("Long".equals(type)) {
+ return sp.getLong(key, (Long) defaultObject);
+ }
+
+ return null;
+ }
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/HDL_TTLSDK485/src/main/res/values/strings.xml b/HDL_TTLSDK485/src/main/res/values/strings.xml
new file mode 100644
index 0000000..f40ea25
--- /dev/null
+++ b/HDL_TTLSDK485/src/main/res/values/strings.xml
@@ -0,0 +1,4 @@
+<resources>
+ <string name="app_name">HDL_TTL</string>
+
+</resources>
diff --git a/README.md b/README.md
index 9122b6f..f54660d 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,8 @@
## Android_HDL_SDK_TTL485
-Android_HDL_SDK_TTL485
+HDL TTL485 Android SDK Copyright (c) 2019 HDL Inc.
+榄旈暅SDK椤圭洰
+
+2020-03-25
+1.鍘绘帀MCU灏忔澘鍗忚
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..24ce481
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,66 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 28
+ defaultConfig {
+ applicationId "com.hdl.sdk.ttl_sdk"
+ minSdkVersion 17
+ targetSdkVersion 28
+ versionCode 3
+ versionName "1.0.3"
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+ buildToolsVersion '28.0.3'
+
+ /**
+ * 鎵撳寘鑷姩鍛藉悕
+ */
+ android.applicationVariants.all { variant ->
+ variant.outputs.all {
+ outputFileName = "Android_HDL_SDK_TTL_DEMO_" + buildType.name + "_V" +
+ defaultConfig.versionName + "_B" + defaultConfig.versionCode + "_" + releaseTime() + ".apk"
+ }
+ }
+
+
+// configurations {
+// compile.exclude module: 'gson'
+// }
+
+
+}
+
+
+def releaseTime() {
+ return new Date().format("yyyy-MM-dd")
+}
+
+dependencies {
+// implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
+ implementation 'com.android.support:appcompat-v7:28.0.0'
+ implementation 'com.android.support.constraint:constraint-layout:1.1.3'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+
+ implementation 'com.android.support:recyclerview-v7:28.0.0'
+ implementation project(':HDL_TTLSDK485')
+ implementation 'org.greenrobot:eventbus:3.0.0'
+ implementation 'pub.devrel:easypermissions:2.0.1'
+ implementation 'com.afollestad.material-dialogs:commons:0.9.6.0'
+
+// implementation 'com.afollestad.material-dialogs'
+// implementation 'com.afollestad.material-dialogs:core:3.0.2'
+// implementation 'com.jakewharton:butterknife:9.0.0'
+// annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0'
+
+// api 'com.google.code.gson:gson:2.8.5'
+
+// implementation project(':gson')
+}
diff --git a/app/libs/HDL_TTLSDK-release.aar b/app/libs/HDL_TTLSDK-release.aar
new file mode 100644
index 0000000..6953587
--- /dev/null
+++ b/app/libs/HDL_TTLSDK-release.aar
Binary files differ
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..f1b4245
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# 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
diff --git a/app/src/androidTest/java/com/hdl/sdk/ttl_sdk/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/hdl/sdk/ttl_sdk/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..4208b82
--- /dev/null
+++ b/app/src/androidTest/java/com/hdl/sdk/ttl_sdk/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.hdl.sdk.ttl_sdk;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("com.hdl.sdk.hdl_sdk", appContext.getPackageName());
+ }
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..9075512
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.hdl.sdk.ttl_sdk">
+
+ <uses-permission android:name="android.permission.INTERNET" /> <!-- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> -->
+ <!-- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> -->
+ <!-- <uses-permission android:name="adnroid.permission.CHANGE_WIFI_STATE" /> -->
+ <uses-permission android:name="android.permission.RAISED_THREAD_PRIORITY" /> <!-- <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> -->
+ <!-- <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> -->
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.JDGROUP" />
+
+ <application
+ android:name=".HDLApplication"
+ android:allowBackup="true"
+ android:icon="@mipmap/ic_launcher"
+ android:label="@string/app_name"
+ android:roundIcon="@mipmap/ic_launcher_round"
+ android:supportsRtl="true"
+ android:theme="@style/AppTheme">
+ <activity android:name=".activity.SendTestActivity"></activity>
+ <activity android:name=".activity.CtrlCommonSwitchActivity" />
+ <activity android:name=".activity.AddDevicesManuallyNEWActivity" />
+ <activity android:name=".activity.SensorActivity" /> <!-- <activity android:name=".activity.ZigbeeActivity" /> -->
+ <!-- <activity android:name=".bean.ZigbeeActivity2" /> -->
+ <activity android:name=".activity.AddDevicesManuallyActivity" />
+ <activity android:name=".activity.CtrlSecurityActivity" />
+ <activity android:name=".activity.MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity android:name=".activity.AppliancesListActivity" />
+ <activity android:name=".activity.CtrlActivity" />
+ <activity android:name=".activity.CtrlAudioActivity" />
+ <activity android:name=".activity.SettingActivity" />
+ <activity android:name=".activity.CtrlCurtainActivity" /> <!-- <activity android:name=".activity.MCUActivity" /> -->
+ <activity android:name=".activity.CtrlLogicActivity" />
+ <activity android:name=".activity.CtrlAirActivity" />
+ <activity android:name=".activity.CtrlLightActivity" />
+ <activity android:name=".activity.CtrlAirHVACActivity" />
+
+ <receiver android:name=".activity.BootComplete">
+ <intent-filter>
+ <action android:name="android.intent.action.BOOT_COMPLETED" />
+ <action android:name="com.hdl.action.WARNING" />
+
+ <category android:name="android.intent.category.HOME" />
+ </intent-filter>
+ </receiver>
+ </application>
+
+</manifest>
\ No newline at end of file
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/HDLApplication.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/HDLApplication.java
new file mode 100644
index 0000000..ad18296
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/HDLApplication.java
@@ -0,0 +1,34 @@
+package com.hdl.sdk.ttl_sdk;
+
+import android.app.Application;
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLTtlSdk;
+
+/**
+ * Created by JLChen on 2019/7/26
+ */
+public class HDLApplication extends Application {
+
+ public static final String HDL_UART_PATH = "/dev/ttyS2"; //涓插彛璁惧璺緞鍚�
+ public static final int HDL_BAUDRATE = 115200; //娉㈢壒鐜�
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ initHDLSDK();
+ }
+
+ /**
+ * 鍒濆鍖� HDLSDK
+ */
+ private void initHDLSDK() {
+ /**SDK鍒濆鍖� 閰嶇疆涓插彛 璺緞鍜屾尝鐗圭巼鍙傛暟*/
+ //HDL_PATH_NAME (涓插彛璺緞)
+ //HDL_BAUDRATE (娉㈢壒鐜�)锛屾尝鐗圭巼榛樿115200
+ HDLTtlSdk.init(this, HDL_UART_PATH, HDL_BAUDRATE);
+ //HDLTtlSdk.setHDLLogOpen(false);//閰嶇疆鏄惁寮�鍚疭DK鎵撳嵃鏃ュ織锛岄粯璁や负鎵撳紑
+ }
+
+
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/AddDevicesManuallyActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/AddDevicesManuallyActivity.java
new file mode 100644
index 0000000..461fe27
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/AddDevicesManuallyActivity.java
@@ -0,0 +1,204 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.RelativeLayout;
+import android.widget.Spinner;
+import android.widget.TextView;
+
+import com.afollestad.materialdialogs.DialogAction;
+import com.afollestad.materialdialogs.MaterialDialog;
+import com.hdl.sdk.ttl.Config.Configuration;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLDeviceManager;
+import com.hdl.sdk.ttl_sdk.R;
+import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+
+/**
+ * 鎵嬪姩娣诲姞涓嶆敮鎸佺畝鏄撶紪绋嬫悳绱㈢殑璁惧
+ * 闊充箰妯″潡鍜屽畨闃叉ā鍧�
+ * 闇�瑕佸~鍐欐纭殑瀛愮綉鍙凤紝璁惧鍙凤紝鍥炶矾鍙凤紝澶囨敞鍚�
+ */
+public class AddDevicesManuallyActivity extends BaseActivity {
+ /**
+ * Topbar
+ */
+ private RelativeLayout topBarBack;
+ private TextView topBarTitle;
+ //褰撳墠APP璁惧瀛愮綉鍙峰拰璁惧鍙烽厤缃�
+ private EditText subnetIDEditText;
+ private EditText deviceIDEditText;
+ private EditText channelNumEditText;
+ private EditText remarksEditText;
+ private Button addButton;
+// private String subnetIDStr, deviceIDStr, channelNumStr, remarksStr;
+ private int subnetID, deviceID, channelNum;
+ private String remarksStr;
+
+ private int deviceTypeId = 0;
+ private static final String[] deviceTypeItems = {"瀹夐槻妯″潡", "闊充箰妯″潡", "浼犳劅鍣ㄦā鍧�"};
+ private Spinner spinner_deviceType;
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_add_devices_manually);
+ initToolbar();
+ initView();
+ setOnClick();
+ initData();
+ }
+
+ /**
+ * 鍒濆鍖朤oolbar
+ */
+ private void initToolbar() {
+ topBarBack = findViewById(R.id.ll_top_b_left);
+ setViewVisible(topBarBack);
+ topBarTitle = findViewById(R.id.tv_top_b_header_title);
+ topBarBack.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ });
+ topBarTitle.setText("娣诲姞璁惧");
+ }
+
+ private void initView() {
+ subnetIDEditText = findViewById(R.id.et_subnetID);
+ deviceIDEditText = findViewById(R.id.et_deviceID);
+ channelNumEditText = findViewById(R.id.et_channelNum);
+ remarksEditText = findViewById(R.id.et_remarks);
+
+ addButton = findViewById(R.id.btn_add);
+ spinner_deviceType = findViewById(R.id.spinner_device_type);
+ }
+
+
+ private void setOnClick() {
+ addButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ addButtonAction();
+ }
+ });
+
+
+ ArrayAdapter<String> sp_CheckBitAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, deviceTypeItems);
+ sp_CheckBitAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ spinner_deviceType.setAdapter(sp_CheckBitAdapter);
+ spinner_deviceType.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
+ public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
+ deviceTypeId = arg2;
+ }
+
+ public void onNothingSelected(AdapterView<?> arg0) {
+
+ }
+ });
+ }
+
+ private void initData() {
+
+ }
+
+
+ /**
+ * 鎵嬪姩娣诲姞涓嶆敮鎸佺畝鏄撶紪绋嬫悳绱㈢殑璁惧
+ */
+ private void addDevicesManually() {
+// if (deviceTypeId == 0) {
+// HDLDeviceManager.addSecurityDevicesManually(42, 11, 1, "瀹夐槻妯″潡");
+// } else {
+// HDLDeviceManager.addAudioDevicesManually(1, 17, 1, "闊充箰鎾斁鍣�");
+// }
+
+ boolean isSuccess = false;
+ if (deviceTypeId == 0) {
+
+ isSuccess = HDLDeviceManager.addSecurityDevicesManually(subnetID, deviceID, channelNum, remarksStr);
+ } else if(deviceTypeId == 1) {
+ isSuccess = HDLDeviceManager.addAudioDevicesManually(subnetID, deviceID, channelNum, remarksStr);
+ }else {
+ //鎸囧畾澶х被鍜屽皬绫诲弬鏁� 鍖哄垎妯″潡绫诲瀷
+ isSuccess = HDLDeviceManager.addDevicesManuallyWithoutSearching(Configuration.SENSOR_BIG_TYPE,11 ,subnetID, deviceID, channelNum, remarksStr);
+ }
+
+ if(isSuccess){
+ showToast("娣诲姞鎴愬姛");
+ finish();
+ }else {
+ showToast("娣诲姞澶辫触");
+ }
+ }
+
+ private void addButtonAction(){
+ String subnetIDStr = subnetIDEditText.getText().toString();
+ if (TextUtils.isEmpty(subnetIDStr)) {
+ showToast("瀛愮綉鍙蜂笉鑳戒负绌�");
+ return;
+ }
+
+ String deviceIDStr = deviceIDEditText.getText().toString();
+ if (TextUtils.isEmpty(deviceIDStr)) {
+ showToast("璁惧鍙蜂笉鑳戒负绌�");
+ return;
+ }
+
+ String channelNumStr = channelNumEditText.getText().toString();
+ if (TextUtils.isEmpty(channelNumStr)) {
+ showToast("鍥炶矾鍙蜂笉鑳戒负绌�");
+ return;
+ }
+
+ String remarksString = remarksEditText.getText().toString();
+ if (TextUtils.isEmpty(remarksString)) {
+ showToast("澶囨敞涓嶈兘涓虹┖");
+ return;
+ }
+
+
+ subnetID = Integer.parseInt(subnetIDStr);
+ deviceID = Integer.parseInt(deviceIDStr);
+ channelNum = Integer.parseInt(channelNumStr);
+ remarksStr = remarksString;
+ String mes = "";
+ mes = "璁惧绫诲瀷锛�" + deviceTypeItems[deviceTypeId];
+ mes += "\n瀛愮綉鍙凤細" + subnetIDStr +"\n璁惧鍙凤細" + deviceIDStr +"\n鍥炶矾鍙凤細" + channelNumStr +"\n澶囨敞鍚嶏細" + remarksStr;
+ showTipDialog(mes);
+
+ }
+
+ private void showTipDialog(String message) {
+
+ MaterialDialog mMaterialDialog = new MaterialDialog.Builder(this)
+ .title("鏄惁纭畾娣诲姞璇ヨ澶囷紵")
+ .content(message)
+ .positiveText(R.string.ok)
+ .negativeText(getString(R.string.cancel))
+ .onPositive(new MaterialDialog.SingleButtonCallback() { //鐩戝惉鑲畾鎸夐敭
+ @Override
+ public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
+ addDevicesManually();
+ }
+ })
+ .onNegative(new MaterialDialog.SingleButtonCallback() { //鐩戝惉鍚﹀畾鎸夐敭
+ @Override
+ public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
+ dialog.dismiss();
+ }
+ }).build();
+ mMaterialDialog.show();
+ }
+
+
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/AddDevicesManuallyNEWActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/AddDevicesManuallyNEWActivity.java
new file mode 100644
index 0000000..58b6713
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/AddDevicesManuallyNEWActivity.java
@@ -0,0 +1,131 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Parser.DeviceParser;
+import com.hdl.sdk.ttl_sdk.R;
+
+import java.util.ArrayList;
+
+public class AddDevicesManuallyNEWActivity extends Activity {
+
+ private int bigType;
+ private int littleType;
+ private int mSubnetID;
+ private int mDeviceID;
+ private int port;
+ private String parentRemarks;
+ private ArrayList<String> parentRemarksList = new ArrayList();
+
+ private EditText et_subnetID,et_deviceID, et_bitType, et_littleType, et_remarks,et_remarks_mk;
+ private Button btn_add;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_add_devices_manually_new);
+
+ et_subnetID = findViewById(R.id.et_subnetID);
+ et_deviceID = findViewById(R.id.et_deviceID);
+ et_bitType = findViewById(R.id.et_bitType);
+ et_littleType = findViewById(R.id.et_littleType);
+ et_remarks = findViewById(R.id.et_remarks);
+// et_port = findViewById(R.id.et_port);
+ et_remarks_mk = findViewById(R.id.et_remarks_mk);
+ btn_add = findViewById(R.id.btn_add);
+
+ btn_add.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ addDevicesManuallyWithoutSearchingAll();
+
+ }
+ });
+
+
+ }
+
+
+
+
+ private void addDevicesManuallyWithoutSearchingAll(){
+ parentRemarksList.clear();
+
+
+ String subnetIDStr = et_subnetID.getText().toString();
+ if (TextUtils.isEmpty(subnetIDStr)) {
+ showToast("瀛愮綉鍙蜂笉鑳戒负绌�");
+ return;
+ }
+
+ String deviceIDStr = et_deviceID.getText().toString();
+ if (TextUtils.isEmpty(deviceIDStr)) {
+ showToast("璁惧鍙蜂笉鑳戒负绌�");
+ return;
+ }
+
+ String bitTypeStr = et_bitType.getText().toString();
+ if (TextUtils.isEmpty(bitTypeStr)) {
+ showToast("澶х被涓嶈兘涓虹┖");
+ return;
+ }
+
+ String littleTypeStr= et_littleType.getText().toString();
+ if (TextUtils.isEmpty(littleTypeStr)) {
+ showToast("灏忕被涓嶈兘涓虹┖");
+ return;
+ }
+ String remarksMkString = et_remarks_mk.getText().toString();
+ if (TextUtils.isEmpty(remarksMkString)) {
+ showToast("妯″潡澶囨敞涓嶈兘涓虹┖");
+ return;
+ }
+
+
+
+ String remarksString = et_remarks.getText().toString();
+ if (TextUtils.isEmpty(remarksString)) {
+ showToast("澶囨敞涓嶈兘涓虹┖");
+ return;
+ }
+
+// String et_portString = et_port.getText().toString();
+// if (TextUtils.isEmpty(et_portString)) {
+// showToast("绔彛涓嶈兘涓虹┖");
+// return;
+// }
+
+
+ mSubnetID = Integer.parseInt(subnetIDStr);
+ mDeviceID = Integer.parseInt(deviceIDStr);
+
+ bigType = Integer.parseInt(bitTypeStr);
+ littleType = Integer.parseInt(littleTypeStr);
+ parentRemarks = remarksMkString;
+// port = Integer.parseInt(et_portString);
+
+ String[] arr = remarksString.split("-");
+ if(arr.length >0){
+ for(int i = 0; i< arr.length; i++){
+ parentRemarksList.add(arr[i]);
+ }
+ }else {
+ parentRemarksList.add(remarksString);
+ }
+
+
+ DeviceParser.addDevicesManuallyWithoutSearchingAll( bigType, littleType, mSubnetID, mDeviceID, parentRemarks, parentRemarksList);
+ }
+
+
+ private void showToast(String text) {
+ Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
+ }
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/AppliancesListActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/AppliancesListActivity.java
new file mode 100644
index 0000000..538e49b
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/AppliancesListActivity.java
@@ -0,0 +1,186 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
+
+import android.view.View;
+import android.widget.EditText;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.hdl.sdk.ttl.Config.Configuration;
+import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+import com.hdl.sdk.ttl.Utils.HDLUtlis.HDLStringUtils;
+import com.hdl.sdk.ttl_sdk.R;
+import com.hdl.sdk.ttl_sdk.adapter.HDLAppliancesListAdapter;
+import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+import com.hdl.sdk.ttl_sdk.utlis.HDLLog;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 褰撳墠妯″潡鎵�鏈夊洖璺澶囧垪琛�
+ */
+public class AppliancesListActivity extends BaseActivity {
+
+ private RecyclerView mRecyclerView;
+// private List<String> listString = new ArrayList<>();
+ private List<AppliancesInfo> appliancesInfos = new ArrayList<>();
+
+ private String remarkStr;
+ private HDLAppliancesListAdapter mAppliancesAdapter;
+
+
+ /**Topbar*/
+ private RelativeLayout topBarBack;
+ private TextView topBarTitle;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_appliances_new);
+ initToolbar();
+ appliancesInfos = (List<AppliancesInfo>) getIntent().getSerializableExtra("Appliances");
+ initRecyclerView();
+ topBarTitle.setText(appliancesInfos.get(0).getDeviceName());
+ }
+
+ /**
+ * 鍒濆鍖朤oolbar
+ */
+ private void initToolbar() {
+ topBarBack = findViewById(R.id.ll_top_b_left);
+ setViewVisible(topBarBack);
+ topBarTitle = findViewById(R.id.tv_top_b_header_title);
+ topBarBack.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ });
+ }
+
+ /**
+ * 鍒濆鍖朢ecyclerView
+ */
+ private void initRecyclerView() {
+ mRecyclerView = findViewById(R.id.recyclerView_hl);
+ // 瀹氫箟涓�涓嚎鎬у竷灞�绠$悊鍣�
+ LinearLayoutManager manager = new LinearLayoutManager(this);
+ // 璁剧疆甯冨眬绠$悊鍣�
+ mRecyclerView.setLayoutManager(manager);
+ // 璁剧疆adapter
+ mAppliancesAdapter = new HDLAppliancesListAdapter(this, appliancesInfos);
+ mRecyclerView.setAdapter(mAppliancesAdapter);
+
+ mAppliancesAdapter.setOnItemClickLitener(new HDLAppliancesListAdapter.OnItemClickLitener() {
+ @Override
+ public void onItemClick(int position) {
+ startActivityWithBigType(position);
+ }
+ });
+ }
+
+ private void showInPutView(final int mSubnetID, final int mDeviceID, String mText) {
+ final EditText modifyRemark = new EditText(this);
+ modifyRemark.setText(mText);
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle("淇敼澶囨敞").setIcon(android.R.drawable.ic_dialog_info).setView(modifyRemark)
+ .setNegativeButton("鍙栨秷", null);
+ builder.setPositiveButton("纭", new DialogInterface.OnClickListener() {
+
+ public void onClick(DialogInterface dialog, int which) {
+ remarkStr = modifyRemark.getText().toString();
+ if (TextUtils.isEmpty(remarkStr) || TextUtils.isEmpty(remarkStr)) {
+ showToast("鍐呭涓嶈兘涓虹┖");
+ return;
+ }
+
+ byte[] remarkByte = HDLStringUtils.stringtoBytes(remarkStr);
+ if (remarkByte.length > 20) {
+ showToast("澶囨敞鍚嶄笉鑳借秴杩�20瀛楄妭");
+ } else {
+ //淇敼妯″潡澶囨敞鎺ュ彛锛�
+ HDLCommand.updateModuleRemark(mSubnetID, mDeviceID, remarkByte);
+ HDLLog.Log("kkkkkkkkk:" + remarkStr);
+ }
+ }
+ });
+ builder.show();
+ }
+
+ /**
+ * 鏍规嵁璁惧绫诲瀷璺宠浆鐩稿簲鐨勭晫闈�
+ *
+ * @param position
+ */
+ private void startActivityWithBigType(int position) {
+ int mBigType = appliancesInfos.get(position).getBigType();
+ Intent intent = new Intent();
+
+ switch (mBigType) {
+ case Configuration.LIGTH_BIG_TYPE:
+ //鐏厜妯″潡
+ intent.setClass(AppliancesListActivity.this, CtrlLightActivity.class);
+ break;
+ case Configuration.CURTAIN_BIG_TYPE:
+ //绐楀笜妯″潡
+ intent.setClass(AppliancesListActivity.this, CtrlCurtainActivity.class);
+ break;
+ case Configuration.AIR_BIG_TYPE:
+ //绌鸿皟妯″潡
+ if(appliancesInfos.get(position).getDeviceType() == HDLApConfig.TYPE_AC_HVAC){
+ intent.setClass(AppliancesListActivity.this, CtrlAirHVACActivity.class);
+ }else {
+ intent.setClass(AppliancesListActivity.this, CtrlAirActivity.class);
+ }
+ break;
+ case Configuration.LOGIC_BIG_TYPE:
+ //閫昏緫妯″潡
+ intent.setClass(AppliancesListActivity.this, CtrlLogicActivity.class);
+ break;
+ case Configuration.AUDIO_BIG_TYPE:
+ //澶х被鏄煶涔愮被鍒欒烦杞埌AudioActivity
+ intent.setClass(AppliancesListActivity.this, CtrlAudioActivity.class);
+ break;
+ case Configuration.SECURITY_BIG_TYPE:
+ //澶х被鏄畨闃叉ā鍧楀垯璺宠浆鍒癈trlSecurityActivity
+ intent.setClass(AppliancesListActivity.this, CtrlSecurityActivity.class);
+ break;
+ case Configuration.SENSOR_BIG_TYPE:
+ //澶х被鏄紶鎰熷櫒鍒欒烦杞埌SensorActivity
+ intent.setClass(AppliancesListActivity.this, SensorActivity.class);
+ break;
+ case Configuration.COMMON_SWITCH_BIG_TYPE:
+ //澶х被鏄�氱敤寮�鍏冲垯璺宠浆鍒癈trlCommonSwitchActivity
+ intent.setClass(AppliancesListActivity.this, CtrlCommonSwitchActivity.class);
+ break;
+ default:
+ intent.setClass(AppliancesListActivity.this, CtrlActivity.class);
+
+ break;
+ }
+
+// if (mBigType == Configuration.AUDIO_BIG_TYPE) {
+// //澶х被鏄煶涔愮被鍒欒烦杞埌AudioActivity
+// intent.setClass(AppliancesListActivity.this, CtrlAudioActivity.class);
+// }else{
+// intent.setClass(AppliancesListActivity.this, CtrlActivity.class);
+// }
+
+ Bundle bundle = new Bundle();
+ bundle.putSerializable("hdl", appliancesInfos.get(position));
+ intent.putExtras(bundle);
+ AppliancesListActivity.this.startActivity(intent);
+ }
+
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/BootComplete.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/BootComplete.java
new file mode 100644
index 0000000..8f2a8b1
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/BootComplete.java
@@ -0,0 +1,26 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+import com.hdl.sdk.ttl_sdk.utlis.HDLLog;
+import com.hdl.sdk.ttl_sdk.utlis.HDLWarningType;
+
+public class BootComplete extends BroadcastReceiver {
+ static final String action_boot = "android.intent.action.BOOT_COMPLETED";
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(action_boot)) {
+ HDLLog.Log("boot start");
+ Intent StartIntent = new Intent(context, MainActivity.class); //鎺ユ敹鍒板箍鎾悗锛岃烦杞埌MainActivity
+ StartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(StartIntent);
+ } else if (intent.getAction().equals("com.hdl.action.WARNING")) {
+ int warningType = intent.getIntExtra("HdlWarning",0);
+ HDLLog.Log(HDLWarningType.getWarningType(warningType));
+ }
+
+ }
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlActivity.java
new file mode 100644
index 0000000..134416a
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlActivity.java
@@ -0,0 +1,1478 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig;
+import com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser;
+import com.hdl.sdk.ttl.HDLAppliances.HDLCurtain.Parser.CurtainCtrlParser;
+import com.hdl.sdk.ttl.HDLAppliances.HDLSensor.SensorStateBackInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.DeviceStateBean;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.AirFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.CurtainFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DeviceStateEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.LightFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent;
+import com.hdl.sdk.ttl_sdk.R;
+import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+import com.hdl.sdk.ttl_sdk.utlis.HDLLog;
+import com.hdl.sdk.ttl_sdk.utlis.HDLUtlis;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+import java.util.List;
+
+public class CtrlActivity extends BaseActivity {
+ /**Topbar*/
+ private RelativeLayout topBarBack;
+ private TextView topBarTitle;
+ private Button lightBtn, curtainBtn, curtainBtn2, curtainBtn3, curtainBtn4, curtainBtn5,
+ logicBtn, airBtnSwitch, airBtnMode, airBtnTemp, airBtnSpeed, sensorBtn;
+ private TextView lightText, curText1, curText2, airText, logicText, sensorText;
+ private EditText airTempEd;
+ private LinearLayout airDisplay;
+ private AppliancesInfo appliancesInfo;
+ private int lightState;
+ private int curtainState;
+
+ private int airSwitchState;//Demo浠呬互姝や綔涓烘紨绀猴紝瀹為檯璇锋牴鎹渶姹傚紑鍙戣璁�
+ private int airModeState;
+ private int airTempState;
+ private int airSpeedState;
+
+
+
+
+
+ /**
+ * 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲屽繀椤昏璁剧疆杩斿洖true
+ * @return true
+ */
+ @Override
+ protected boolean isRegisterEventBus() {
+ return true;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_ctrl);
+// 姝ゆ柟娉曚负涓诲姩鑾峰彇鍗曚竴璁惧鐘舵�侊紝閫昏緫妯″潡銆佽儗鏅煶涔愭ā鍧楁病鏈夎繖涓猘pi锛屼粎鏀寔鐏厜锛岀獥甯橈紝绌鸿皟銆備竴鑸笉闇�瑕佺敤鍒般��
+// HDLCommand.getDeviceStateFromLocal(appliancesInfo);
+ initToolbar();
+ initcurState();
+ initView();
+ initOnClick();
+ }
+
+ /**
+ * 鍒濆鍖朤oolbar
+ */
+ private void initToolbar() {
+ topBarBack = findViewById(R.id.ll_top_b_left);
+ setViewVisible(topBarBack);
+ topBarTitle = findViewById(R.id.tv_top_b_header_title);
+ topBarBack.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ });
+ }
+
+ private void initView() {
+ lightBtn = findViewById(R.id.ctrlbtn);
+ curtainBtn = findViewById(R.id.curtainbtn);
+ curtainBtn2 = findViewById(R.id.curtainbtn2);
+ curtainBtn3 = findViewById(R.id.curtainbtn3);
+ curtainBtn4 = findViewById(R.id.curtainbtn4);
+ curtainBtn5 = findViewById(R.id.curtainbtn5);
+ logicBtn = findViewById(R.id.logicbtn);
+ sensorBtn = findViewById(R.id.sensorbtn);
+
+ airDisplay = findViewById(R.id.air);
+ airBtnSwitch = findViewById(R.id.airbtn_switch);
+ airBtnMode = findViewById(R.id.airbtn_mode);
+ airBtnSpeed = findViewById(R.id.airbtn_speed);
+ airBtnTemp = findViewById(R.id.airbtn_tempBtn);
+ airTempEd = findViewById(R.id.airet_tempet);
+
+ lightText = findViewById(R.id.lightText);
+ curText1 = findViewById(R.id.curtainText1);
+ curText2 = findViewById(R.id.curtainText2);
+ airText = findViewById(R.id.airText);
+ logicText = findViewById(R.id.logicText);
+ sensorText = findViewById(R.id.sensorText);
+ //姝ゅ鍒ゆ柇浠�涔堣澶囷紝骞跺皢鍏朵粬璁惧鎺т欢闅愯棌
+ //1锛氳皟鍏夊洖璺紙鐏級 2锛氬紑鍏冲洖璺紙鐏級 3锛氭贩鍚堣皟鍏夌被 锛堢伅锛� 4锛氭贩鍚堝紑鍏崇被锛堢伅锛�
+ // 5锛氬紑鍚堝笜鐢垫満锛堢獥甯橈級6锛氬嵎甯樼數鏈猴紙绐楀笜锛� 7锛氱獥甯樻ā鍧� 锛堢獥甯橈級
+ // 8锛欻VAC 妯″潡(绌鸿皟) 9锛氶�氱敤绌鸿皟闈㈡澘(绌鸿皟)
+ // 10锛氳儗鏅煶涔愭ā鍧楋紙闊充箰锛� 11锛氱涓夋柟鑳屾櫙闊充箰妯″潡锛堥煶涔愶級
+ // 12锛氶�昏緫妯″潡锛堝満鏅級 13锛氬叏灞�閫昏緫妯″潡锛堝満鏅級
+
+ //101銆�102銆�103銆�104 涓虹伅 TYPE_LIGHT_DIMMER銆乀YPE_LIGHT_RELAY銆乀YPE_LIGHT_MIX_DIMMER銆乀YPE_LIGHT_MIX_RELAY
+ //201銆�202銆�203 涓虹獥甯� TYPE_CURTAIN_GLYSTRO銆乀YPE_CURTAIN_ROLLER銆乀YPE_CURTAIN_MODULE
+ //301銆�304 涓虹┖璋� TYPE_AC_HVAC銆乀YPE_AC_PANEL
+ //501銆�502 涓哄満鏅� TYPE_LOGIC_MODULE銆乀YPE_GLOBAL_LOGIC_MODULE
+ //601-625 涓轰紶鎰熷櫒
+// HDLLog.Log("KKKgetDeviceType"+appliancesInfo.getDeviceType());
+
+ switch (appliancesInfo.getDeviceType()) {
+ case HDLApConfig.TYPE_LIGHT_DIMMER:
+ case HDLApConfig.TYPE_LIGHT_RELAY:
+ case HDLApConfig.TYPE_LIGHT_MIX_DIMMER:
+ case HDLApConfig.TYPE_LIGHT_MIX_RELAY:
+ curtainBtn.setVisibility(View.GONE);
+ curtainBtn2.setVisibility(View.GONE);
+ curtainBtn3.setVisibility(View.GONE);
+ curtainBtn4.setVisibility(View.GONE);
+ curtainBtn5.setVisibility(View.GONE);
+ logicBtn.setVisibility(View.GONE);
+ airDisplay.setVisibility(View.GONE);
+
+
+ curText1.setVisibility(View.GONE);
+ curText2.setVisibility(View.GONE);
+ airText.setVisibility(View.GONE);
+ logicText.setVisibility(View.GONE);
+
+ sensorBtn.setVisibility(View.GONE);
+ sensorText.setVisibility(View.GONE);
+
+
+ if (appliancesInfo.getCurState() != null) {
+ int curLightState = HDLUtlis.getIntegerByObject(appliancesInfo.getCurState());
+
+ lightText.setText("褰撳墠鐏厜浜害锛�" + curLightState);
+ lightBtn.setText("褰撳墠鐏厜浜害锛�" + curLightState);
+ if (curLightState == 100) {
+ lightState = 0;
+ } else {
+ lightState = 100;
+ }
+ } else {
+ lightText.setText("鏈幏鍙栧埌鐏厜浜害");
+ lightBtn.setText("鏈幏鍙栧埌鐏厜浜害");
+ }
+
+
+ break;
+ case HDLApConfig.TYPE_CURTAIN_GLYSTRO:
+ case HDLApConfig.TYPE_CURTAIN_ROLLER:
+ case HDLApConfig.TYPE_CURTAIN_MODULE:
+ lightBtn.setVisibility(View.GONE);
+ logicBtn.setVisibility(View.GONE);
+ airDisplay.setVisibility(View.GONE);
+
+ lightText.setVisibility(View.GONE);
+ airText.setVisibility(View.GONE);
+ logicText.setVisibility(View.GONE);
+ sensorBtn.setVisibility(View.GONE);
+ sensorText.setVisibility(View.GONE);
+ if (appliancesInfo.getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) {
+ //绐楀笜妯″潡
+ curText2.setVisibility(View.GONE);
+ curtainBtn2.setVisibility(View.GONE);
+ curtainBtn3.setVisibility(View.GONE);
+ curtainBtn4.setVisibility(View.GONE);
+ curtainBtn5.setVisibility(View.GONE);
+
+ if (appliancesInfo.getCurState() != null) {
+ String stringCurtainState = "";
+ int curCurtainState = HDLUtlis.getIntegerByObject(appliancesInfo.getCurState());
+ HDLLog.Log("curCurtainState = " + curCurtainState);
+ switch (curCurtainState) {
+ case CurtainCtrlParser.TYPE_STATE_PAUSE:
+ stringCurtainState += "绐楀笜妯″潡鍋滄鐘舵��";
+ curtainState = CurtainCtrlParser.curtainOn;//鍒濆鍖栫獥甯樻帶鍒剁姸鎬�
+ break;
+ case CurtainCtrlParser.TYPE_STATE_OPEN:
+ stringCurtainState += "绐楀笜妯″潡寮�鐘舵��";
+ curtainState = CurtainCtrlParser.curtainOff;//鍒濆鍖栫獥甯樻帶鍒剁姸鎬�
+ break;
+ case CurtainCtrlParser.TYPE_STATE_CLOSE:
+ stringCurtainState += "绐楀笜妯″潡鍏崇姸鎬�";
+ curtainState = CurtainCtrlParser.curtainOn;//鍒濆鍖栫獥甯樻帶鍒剁姸鎬�
+ break;
+ default:
+ stringCurtainState = "鏈幏鍙栧埌绐楀笜妯″潡鐘舵��";
+ curtainState = CurtainCtrlParser.curtainOff;//鍒濆鍖栫獥甯樻帶鍒剁姸鎬�
+ break;
+ }
+ curText1.setText(stringCurtainState);
+ curtainBtn.setText(stringCurtainState);
+ } else {
+ curText1.setText("鏈幏鍙栧埌绐楀笜妯″潡鐘舵��");
+ curtainBtn.setText("鏈幏鍙栧埌绐楀笜妯″潡鐘舵��");
+ }
+
+ } else {
+ //寮�鍚堝笜銆佸嵎甯�
+ curText1.setVisibility(View.GONE);
+ curtainBtn.setVisibility(View.GONE);
+
+ if (appliancesInfo.getCurState() != null) {
+ curText2.setText("褰撳墠绐楀笜鐘舵�侊細" + HDLUtlis.getIntegerByObject(appliancesInfo.getCurState()));
+ } else {
+ curText2.setText("鏈幏鍙栧埌绐楀笜妯″潡鐘舵��");
+ }
+
+
+ }
+ break;
+ case HDLApConfig.TYPE_AC_HVAC:
+ case HDLApConfig.TYPE_AC_PANEL:
+ lightBtn.setVisibility(View.GONE);
+ curtainBtn.setVisibility(View.GONE);
+ curtainBtn2.setVisibility(View.GONE);
+ curtainBtn3.setVisibility(View.GONE);
+ curtainBtn4.setVisibility(View.GONE);
+ curtainBtn5.setVisibility(View.GONE);
+ logicBtn.setVisibility(View.GONE);
+
+ curText1.setVisibility(View.GONE);
+ curText2.setVisibility(View.GONE);
+ lightText.setVisibility(View.GONE);
+ logicText.setVisibility(View.GONE);
+ sensorBtn.setVisibility(View.GONE);
+ sensorText.setVisibility(View.GONE);
+
+
+ if (appliancesInfo.getArrCurState() != null) {
+ String stringACState = "";
+ byte[] acCurState = appliancesInfo.getArrCurState();
+ for (int index = 0; index < acCurState.length; index++) {
+ if (index == 0 && acCurState[index] == 0) {
+ airSwitchState = 0;
+ stringACState += "绌鸿皟宸插叧闂�";
+ //濡傛灉绌鸿皟鍏抽棴鐘舵�侊紝鍒欐棤闇�鍐嶉亶鍘�
+ break;
+ }
+ if (index == 0 && acCurState[index] == 1) {
+ airSwitchState = 1;
+ stringACState += "绌鸿皟姝e湪杩愯";
+ }
+
+ switch (index) {
+
+ case 1:
+ switch (acCurState[index]) {
+ case 0:
+ airModeState = 0;
+ stringACState += " 绌鸿皟妯″紡:鍒跺喎";
+ break;
+ case 1:
+ airModeState = 1;
+ stringACState += " 绌鸿皟妯″紡:鍒剁儹";
+ break;
+ case 2:
+ airModeState = 2;
+ stringACState += " 绌鸿皟妯″紡:閫氶";
+ break;
+ case 3:
+ airModeState = 3;
+ stringACState += " 绌鸿皟妯″紡:鑷姩";
+ break;
+ case 4:
+ airModeState = 4;
+ stringACState += " 绌鸿皟妯″紡:鎶芥箍";
+ break;
+ default:
+ airModeState = -1;
+ stringACState += " 鏈煡绌鸿皟妯″紡";
+ break;
+ }
+ break;
+ case 2:
+ switch (acCurState[1]) {
+ case 0:
+ airTempState = acCurState[index] & 0xff;
+ stringACState += " 鍒跺喎娓╁害锛�" + (acCurState[index] & 0xff);
+ break;
+ case 1:
+ airTempState = acCurState[index] & 0xff;
+ stringACState += " 鍒剁儹娓╁害锛�" + (acCurState[index] & 0xff);
+ break;
+ case 2:
+ airTempState = -1;
+ stringACState += " 閫氶鏃犳俯搴︽樉绀�";
+ break;
+ case 3:
+ airTempState = acCurState[index] & 0xff;
+ stringACState += " 鑷姩娓╁害锛�" + (acCurState[index] & 0xff);
+ break;
+ case 4:
+ airTempState = acCurState[index] & 0xff;
+ stringACState += " 鎶芥箍娓╁害锛�" + (acCurState[index] & 0xff);
+ break;
+ default:
+ airTempState = -2;
+ stringACState += " 鏈煡娓╁害";
+ break;
+ }
+ break;
+ case 3:
+ String curSpeed;
+ switch (appliancesInfo.getArrCurState()[index]) {
+ case 0:
+ airSpeedState = 0;
+ curSpeed = " 椋庨�熻嚜鍔�";
+ break;
+ case 1:
+ airSpeedState = 1;
+ curSpeed = " 椋庨�熼珮";
+ break;
+ case 2:
+ airSpeedState = 2;
+ curSpeed = " 椋庨�熶腑";
+ break;
+ case 3:
+ airSpeedState = 3;
+ curSpeed = " 椋庨�熶綆";
+ break;
+ default:
+ airSpeedState = -1;
+ curSpeed = " 鏈煡椋庨��";
+ break;
+ }
+ switch (appliancesInfo.getArrCurState()[1]) {
+ case 0:
+ stringACState += curSpeed;
+ break;
+ case 1:
+ stringACState += curSpeed;
+ break;
+ case 2:
+ stringACState += curSpeed;
+ break;
+ case 3:
+ stringACState += curSpeed;
+ break;
+ case 4:
+ stringACState += " 鎶芥箍鏃犻閫�";
+ break;
+ default:
+ stringACState += " 鏈煡绌鸿皟妯″紡";
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ airText.setText(stringACState);
+ } else {
+ airText.setText("鏈幏鍙栧埌绌鸿皟璁惧鐘舵��");
+ }
+
+
+ break;
+ case HDLApConfig.TYPE_LOGIC_MODULE:
+ case HDLApConfig.TYPE_GLOBAL_LOGIC_MODULE:
+ lightBtn.setVisibility(View.GONE);
+ curtainBtn.setVisibility(View.GONE);
+ curtainBtn2.setVisibility(View.GONE);
+ curtainBtn3.setVisibility(View.GONE);
+ curtainBtn4.setVisibility(View.GONE);
+ curtainBtn5.setVisibility(View.GONE);
+ airDisplay.setVisibility(View.GONE);
+
+ curText1.setVisibility(View.GONE);
+ curText2.setVisibility(View.GONE);
+ lightText.setVisibility(View.GONE);
+ sensorBtn.setVisibility(View.GONE);
+ sensorText.setVisibility(View.GONE);
+
+ break;
+ case HDLApConfig.TYPE_SENSOR_DRY_CONTACT://2019-07-03 灞忚斀
+ case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR:
+ case HDLApConfig.TYPE_SENSOR_TEMP:
+ case HDLApConfig.TYPE_SENSOR_HUMIDITY:
+ case HDLApConfig.TYPE_SENSOR_ILLUMINACE:
+ case HDLApConfig.TYPE_SENSOR_VOC:
+ case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5:
+ case HDLApConfig.TYPE_SENSOR_C02:
+ case HDLApConfig.TYPE_SENSOR_LPG:
+ case HDLApConfig.TYPE_SENSOR_CO_H2:
+ case HDLApConfig.TYPE_SENSOR_CH4:
+ case HDLApConfig.TYPE_SENSOR_SMOG:
+ case HDLApConfig.TYPE_SENSOR_WIND_SPEED:
+ case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE:
+ case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW:
+ case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE:
+ case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH:
+ case HDLApConfig.TYPE_SENSOR_RAIN_FALL:
+ case HDLApConfig.TYPE_SENSOR_WEIGHT:
+ case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH:
+ case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED:
+ case HDLApConfig.TYPE_SENSOR_SHAKE:
+ case HDLApConfig.TYPE_SENSOR_VOLTAGE:
+ case HDLApConfig.TYPE_SENSOR_ELECTRICITY:
+ case HDLApConfig.TYPE_SENSOR_POWER:
+ case HDLApConfig.TYPE_SENSOR_FLOODING:
+ case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET:
+ case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON:
+ lightBtn.setVisibility(View.GONE);
+ curtainBtn.setVisibility(View.GONE);
+ curtainBtn2.setVisibility(View.GONE);
+ curtainBtn3.setVisibility(View.GONE);
+ curtainBtn4.setVisibility(View.GONE);
+ curtainBtn5.setVisibility(View.GONE);
+ airDisplay.setVisibility(View.GONE);
+
+ curText1.setVisibility(View.GONE);
+ curText2.setVisibility(View.GONE);
+ lightText.setVisibility(View.GONE);
+ logicBtn.setVisibility(View.GONE);
+ logicText.setVisibility(View.GONE);
+ if (appliancesInfo.getCurState() != null) {
+ float value = (float) appliancesInfo.getCurState();
+ sensorBtn.setText("浼犳劅鍣ㄦ暟鍊硷細" + value);
+ }
+ break;
+
+ }
+ }
+
+
+ private void initcurState() {
+// lightState = 100;//鍒濆鍖栫伅鍏変寒搴�100
+ curtainState = CurtainCtrlParser.curtainOff;
+ appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl");
+
+
+// 鑾峰彇鎵�鏈夎澶囩殑鐘舵�併�俤eviceStateBeanList涓烘墍鏈夎澶囩殑鐘舵�佸垪琛�
+ List<DeviceStateBean> deviceStateBeanList = HDLCommand.getAllDevicesState();
+// 绗笁鏂瑰彲鏍规嵁鑷繁鐨勯渶姹傚埛鏂拌澶囬〉銆備互涓嬩负绀轰緥浠g爜銆�
+ for (DeviceStateBean deviceStateBean : deviceStateBeanList) {
+ //娉ㄦ剰锛佺涓夋柟搴旇灏嗚澶囬泦鍚堝叏閮ㄥ湪杩欓噷閬嶅巻涓�閬嶄互涓嬫搷浣滐紝骞舵洿鏂扮姸鎬佸�笺�傝繖閲屼粎浣滀负Demo婕旂ず锛屽彧鍒ゆ柇涓�涓��
+
+ //鍏堝垽鏂妯″潡鏄惁涓哄綋鍓嶈澶囩殑妯″潡
+ if (deviceStateBean.getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && deviceStateBean.getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()) {
+// 鍐嶅垽鏂槸浠�涔堢被鍨嬬殑璁惧銆�
+ switch (deviceStateBean.getDeviceType()) {
+ case HDLApConfig.TYPE_LIGHT_DIMMER:
+ //鍒ゆ柇鏄摢涓洖璺殑璁惧
+ if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) {
+ appliancesInfo.setCurState(deviceStateBean.getCurState());
+ }
+ break;
+ case HDLApConfig.TYPE_LIGHT_RELAY:
+ //鍒ゆ柇鏄摢涓洖璺殑璁惧
+ if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) {
+ appliancesInfo.setCurState(deviceStateBean.getCurState());
+ }
+ break;
+ case HDLApConfig.TYPE_LIGHT_MIX_DIMMER:
+ //鍒ゆ柇鏄摢涓洖璺殑璁惧
+ if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) {
+ appliancesInfo.setCurState(deviceStateBean.getCurState());
+ }
+ break;
+ case HDLApConfig.TYPE_LIGHT_MIX_RELAY:
+ //鍒ゆ柇鏄摢涓洖璺殑璁惧
+ if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) {
+ appliancesInfo.setCurState(deviceStateBean.getCurState());
+ }
+ break;
+ case HDLApConfig.TYPE_CURTAIN_GLYSTRO:
+ //鍒ゆ柇鏄摢涓洖璺殑璁惧
+ if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) {
+ appliancesInfo.setCurState(deviceStateBean.getCurState());
+ }
+ break;
+ case HDLApConfig.TYPE_CURTAIN_ROLLER:
+ //鍒ゆ柇鏄摢涓洖璺殑璁惧
+ if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) {
+ appliancesInfo.setCurState(deviceStateBean.getCurState());
+ }
+ break;
+ case HDLApConfig.TYPE_CURTAIN_MODULE:
+ //鍒ゆ柇鏄摢涓洖璺殑璁惧
+ if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) {
+ appliancesInfo.setCurState(deviceStateBean.getCurState());
+ }
+ break;
+ case HDLApConfig.TYPE_AC_HVAC:
+ //鍒ゆ柇鏄摢涓洖璺殑璁惧
+ if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) {
+ appliancesInfo.setArrCurState(deviceStateBean.getArrCurState());
+ }
+ break;
+ case HDLApConfig.TYPE_AC_PANEL:
+ //鍒ゆ柇鏄摢涓洖璺殑璁惧
+ if (deviceStateBean.getChannelNum() == appliancesInfo.getChannelNum()) {
+ appliancesInfo.setArrCurState(deviceStateBean.getArrCurState());
+ }
+ break;
+
+
+ default:
+ break;
+ }
+ }
+
+ }
+ }
+
+ private void initOnClick() {
+ lightBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ HDLCommand.lightCtrl(appliancesInfo, lightState);
+// HDLCommand.lightCtrl(appliancesInfo,50);
+ }
+ });
+
+ curtainBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ //绐楀笜妯″潡绗簩涓弬鏁� 涓篊urtainCtrlParser.curtainOn锛孋urtainCtrlParser.curtainOff锛孋urtainCtrlParser.curtainPause鍏朵腑涓�涓�
+ HDLCommand.curtainCtrl(appliancesInfo, curtainState);
+ if (curtainState == CurtainCtrlParser.curtainOn) {
+ curtainState = CurtainCtrlParser.curtainOff;
+ } else {
+ curtainState = CurtainCtrlParser.curtainOn;
+ }
+
+ }
+ });
+
+ curtainBtn2.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.curtainCtrl(appliancesInfo, CurtainCtrlParser.curtainOn);
+ }
+ });
+
+ curtainBtn3.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.curtainCtrl(appliancesInfo, CurtainCtrlParser.curtainOff);
+ }
+ });
+
+ curtainBtn4.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.curtainCtrl(appliancesInfo, CurtainCtrlParser.curtainPause);
+ }
+ });
+
+ curtainBtn5.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.curtainCtrl(appliancesInfo, 50);
+ }
+ });
+
+ airBtnSwitch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ //婕旂ず褰撳墠鐘舵�佷负鍏筹紝璁剧疆涓哄紑銆傚紑锛岃缃负鍏炽��
+ if (airSwitchState == 0) {
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSwich, AirCtrlParser.airOn);//绌鸿皟寮�
+ } else {
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSwich, AirCtrlParser.airOff);//绌鸿皟鍏�
+ }
+ }
+ });
+
+
+ airBtnMode.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ switch (airModeState) {
+ case 0:
+ //鑻ュ綋鍓嶇┖璋冩ā寮忎负鍒跺喎锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓哄埗鐑�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeHeatTem);//绌鸿皟妯″紡鍒剁儹
+ break;
+ case 1:
+ //鑻ュ綋鍓嶇┖璋冩ā寮忎负鍒剁儹锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓洪�氶
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeVen);//绌鸿皟妯″紡閫氶
+ break;
+ case 2:
+ //鑻ュ綋鍓嶇┖璋冩ā寮忎负閫氶锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓鸿嚜鍔�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeAuto);//绌鸿皟妯″紡鑷姩
+ break;
+ case 3:
+ //鑻ュ綋鍓嶇┖璋冩ā寮忎负鑷姩锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓烘娊婀�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeDehum);//绌鸿皟妯″紡鎶芥箍
+ break;
+ case 4:
+ //鑻ュ綋鍓嶇┖璋冩ā寮忎负鎶芥箍锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓哄埗鍐�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeRefTem);//绌鸿皟妯″紡鍒跺喎
+ break;
+ default:
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeRefTem);//绌鸿皟妯″紡鍒跺喎
+ break;
+
+ }
+
+
+ }
+ });
+
+ airBtnSpeed.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ switch (airSpeedState) {
+ case 0:
+ //鑻ュ綋鍓嶇┖璋冮閫熶负鑷姩锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓洪珮椋�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedHigh);//椋庨�熼珮椋�
+ break;
+ case 1:
+ //鑻ュ綋鍓嶇┖璋冮閫熶负楂橀锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓轰腑椋�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedMid);//椋庨�熶腑椋�
+ break;
+ case 2:
+ //鑻ュ綋鍓嶇┖璋冮閫熶负涓锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓轰綆椋�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedLow);//椋庨�熶綆椋�
+ break;
+ case 3:
+ //鑻ュ綋鍓嶇┖璋冮閫熶负浣庨锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓鸿嚜鍔�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedAuto);//椋庨�熻嚜鍔�
+ break;
+
+
+ }
+ }
+ });
+
+ airBtnTemp.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ String tempStr = airTempEd.getText().toString();
+ if (TextUtils.isEmpty(tempStr) || TextUtils.isEmpty(tempStr)) {
+ showToast("璁剧疆鐨勬俯搴︿笉鑳戒负绌�");
+ return;
+ }
+ int tempInt = Integer.parseInt(tempStr);
+
+ if (tempInt < 16 || tempInt > 30) {
+ showToast("娓╁害璁剧疆鑼冨洿涓猴細16~30鎽勬皬搴�(鈩�)");
+ return;
+ }
+
+ switch (airModeState) {
+ case 0:
+ //褰撳墠绌鸿皟妯″紡涓哄埗鍐�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.refTem, tempInt);//鍒跺喎娓╁害
+ break;
+ case 1:
+ //褰撳墠绌鸿皟妯″紡涓哄埗鐑�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.heatTem, tempInt);//鍒剁儹娓╁害
+ break;
+ case 2:
+ //褰撳墠绌鸿皟妯″紡涓洪�氶
+ showToast("閫氶妯″紡涓嶈兘鎺у埗娓╁害");
+ break;
+ case 3:
+ //褰撳墠绌鸿皟妯″紡涓鸿嚜鍔�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.autoTem, tempInt);//鑷姩娓╁害 鑼冨洿0-84
+ break;
+ case 4:
+ //褰撳墠绌鸿皟妯″紡涓烘娊婀�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.dehumTem, tempInt);//鎶芥箍娓╁害 鑼冨洿0-84
+ break;
+ default:
+ break;
+
+ }
+
+// HDLCommand.airCtrl(appliancesInfo,AirCtrlParser.upTem,1);//涓婂崌娓╁害 鑼冨洿0-5
+// HDLCommand.airCtrl(appliancesInfo,AirCtrlParser.downTem,1);//涓嬮檷娓╁害 鑼冨洿0-5
+ }
+ });
+
+
+ logicBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.logicCtrl(appliancesInfo);
+ }
+ });
+
+ sensorBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.getDeviceStateFromLocal(appliancesInfo);
+ }
+ });
+ }
+
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ }
+
+ /**
+ * 鐏厜鎺у埗鍥炶皟Event
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onLightFeedBackInfoEventMain(LightFeedBackEvent event) {
+
+ if (event.getLightCtrlBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ && event.getLightCtrlBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getLightCtrlBackInfo().getChannelNum() == appliancesInfo.getChannelNum()
+ ) {
+ // 鍏堝垽鏂槸鍚﹁秴鏃�
+ if (!event.isSuccess()) {
+ showToast("鐏厜鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯");
+ lightBtn.setText("鐏厜鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯");
+ return;
+ }
+ int brightness = event.getLightCtrlBackInfo().getBrightness();
+ lightState = brightness == 100 ? 0 : 100;//濡傛灉杩斿洖100閲嶇疆鐘舵�佷负0锛屽弽涔嬮噸缃姸鎬�100
+ lightBtn.setText("褰撳墠浜害 = " + brightness);
+ lightText.setText("褰撳墠浜害 = " + brightness);
+ /*浠ヤ笅涓虹伅鍏夋帹閫佺ず渚嬩唬鐮侊紝鍙互璇嗗埆鍝釜缁х數鍣紝鍝釜璋冨厜鐏紝鍝釜鍥炶矾锛屼篃鍙敤浣滄帶鍒跺洖棣堛��
+ 鎸夐渶姹傝皟鐢�*/
+ String remarks = event.getLightCtrlBackInfo().getRemarks();//鑾峰彇杩斿洖鐨勭伅鍏夊娉ㄣ�傚鏋滄瘡涓伅鍏夊洖璺娉ㄩ兘鍞竴锛屽彲浠ョ洿鎺ラ�氳繃澶囨敞鍒ゆ柇
+ String parentRemarks = event.getLightCtrlBackInfo().getParentRemarks();//鑾峰彇缁х數鍣ㄦ垨璋冨厜鐏娉ㄣ�傝繖閲屽彲浠ョ煡閬撴槸鍝釜璁惧杩斿洖鐨�
+ int num = event.getLightCtrlBackInfo().getChannelNum();//鑾峰彇鍥炶矾鍙枫�傝繖閲屽彲浠ヨ幏鍙栧埌杩欎釜缁х數鍣ㄦ垨璋冨厜鐏殑鍥炶矾鍙�
+ showToast("妯″潡锛�"+ parentRemarks + " 鐨� " + remarks + " 鍥炶矾锛屽洖璺彿涓猴細" + num + " 杩斿洖" + " 浜害涓猴細" + brightness);
+ HDLLog.Log("褰撳墠浜害 = " + brightness);
+ }
+ }
+
+ /**
+ * 绐楀笜妯″潡鎺у埗鍥炶皟Event
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onCurtainFeedBackInfoEventMain(CurtainFeedBackEvent event) {
+// 鍏堝垽鏂槸鍚﹁秴鏃�
+ HDLLog.Log("onCurtainFeedBackInfoEventMain in");
+ if (event.getCurtainCtrlBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getCurtainCtrlBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ && event.getCurtainCtrlBackInfo().getNum() == appliancesInfo.getChannelNum()
+ ) {
+
+ if (!event.isSuccess()) {
+ showToast("绐楀笜鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯");
+ return;
+ }
+
+ int curState = event.getCurtainCtrlBackInfo().getState();
+ //绐楀笜妯″潡锛歝urState:0=鍋滄,1=鎵撳紑,2=鍏抽棴銆�
+ //寮�鍚堝笜鐢垫満锛屽嵎甯樼數鏈猴細curState:1-100寮�鍚堝害銆備篃浼氳繑鍥�0锛�1锛�2鐨勭姸鎬�
+ //寤鸿寮�鍚堝笜鐢垫満锛屽嵎甯樼數鏈烘寜鍋滄鍚庡啀璇诲彇褰撳墠鐘舵�佹潵鑾峰彇褰撳墠鐘舵�佸��
+
+ String remarks = event.getCurtainCtrlBackInfo().getRemarks();
+ String parentRemarks = event.getCurtainCtrlBackInfo().getParentRemarks();
+ int num = event.getCurtainCtrlBackInfo().getNum();
+// showToast(parentRemarks+" 鐨� "+remarks+" 鍥炶矾鍙凤細"+num+" 杩斿洖"+" 鐘舵�佷负锛�"+curState);
+ HDLLog.Log(parentRemarks + " 鐨� " + remarks + " 鍥炶矾鍙凤細" + num + " 杩斿洖" + " 鐘舵�佷负锛�" + curState);
+ if (event.getCurtainCtrlBackInfo().getAppliancesInfo().getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) {
+ //鍒ゆ柇鏄惁涓虹獥甯樻ā鍧�
+ switch (curState) {
+ case CurtainCtrlParser.TYPE_STATE_CLOSE:
+ curtainBtn.setText("绐楀笜鍏�");
+ curText1.setText("绐楀笜鍏�");
+ HDLLog.Log("绐楀笜鎺у埗 锛氱獥甯樺叧" + " 鍥炶矾鍙凤細" + num);
+ break;
+ case CurtainCtrlParser.TYPE_STATE_OPEN:
+ curtainBtn.setText("绐楀笜寮�");
+ curText1.setText("绐楀笜寮�");
+ HDLLog.Log("绐楀笜鎺у埗 锛氱獥甯樺紑" + " 鍥炶矾鍙凤細" + num);
+ break;
+ case CurtainCtrlParser.TYPE_STATE_PAUSE:
+ curtainBtn.setText("绐楀笜鏆傚仠");
+ curText1.setText("绐楀笜鏆傚仠");
+ HDLLog.Log("绐楀笜鎺у埗 锛氱獥甯樻殏鍋�" + " 鍥炶矾鍙凤細" + num);
+ break;
+ }
+ } else {
+ //寮�鍚堝笜鎴栧嵎甯� 鏄剧ず鐧惧垎姣�
+ curtainBtn5.setText("绐楀笜寮�鍒�" + curState + "%");
+ curText2.setText("绐楀笜寮�鍒�" + curState + "%");
+ }
+
+ }
+
+ }
+
+ /**
+ * 绌鸿皟妯″潡鎺у埗鍥炶皟Event
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onAirFeedBackInfoEventMain(AirFeedBackEvent event) {
+ if (event.getAirCtrlBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ && event.getAirCtrlBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getAirCtrlBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum()
+ ) {
+ // 鍏堝垽鏂槸鍚﹁秴鏃�
+ if (!event.isSuccess()) {
+ showToast("绌鸿皟鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯");
+ return;
+ }
+
+ byte[] curState = event.getAirCtrlBackInfo().getCurState();
+ switch (curState[0] & 0xFF) {
+ case AirCtrlParser.airSwich:
+ switch (curState[1] & 0xFF) {
+ case AirCtrlParser.airOff:
+ airSwitchState = 0;
+ airText.setText("绌鸿皟鍏�");
+ showToast("绌鸿皟鍏�");
+ HDLLog.Log("绌鸿皟鍏�");
+ break;
+ case AirCtrlParser.airOn:
+ airSwitchState = 1;
+ airText.setText("绌鸿皟寮�");
+ showToast("绌鸿皟寮�");
+ HDLLog.Log("绌鸿皟寮�");
+ break;
+ default:
+ break;
+ }
+
+ break;
+
+ case AirCtrlParser.airSpeed:
+ switch (curState[1] & 0xFF) {
+ case AirCtrlParser.airSpeedAuto:
+ airSpeedState = 0;
+ airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedAuto鑷姩椋庨��");
+ showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedAuto鑷姩椋庨��");
+ HDLLog.Log("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedAuto鑷姩椋庨��");
+ break;
+ case AirCtrlParser.airSpeedHigh:
+ airSpeedState = 1;
+ airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedHigh椋庨�熼珮");
+ showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedHigh椋庨�熼珮");
+ HDLLog.Log("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedHigh椋庨�熼珮");
+ break;
+ case AirCtrlParser.airSpeedMid:
+ airSpeedState = 2;
+ airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedMid椋庨�熶腑");
+ showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedMid椋庨�熶腑");
+ HDLLog.Log("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedMid椋庨�熶腑");
+ break;
+ case AirCtrlParser.airSpeedLow:
+ airSpeedState = 3;
+ airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedLow椋庨�熶綆");
+ showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedLow椋庨�熶綆");
+ HDLLog.Log("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedLow椋庨�熶綆");
+ break;
+ default:
+ break;
+ }
+ break;
+ case AirCtrlParser.airMode:
+ switch (curState[1] & 0xFF) {
+ case AirCtrlParser.airModeRefTem:
+ airModeState = 0;
+ airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鍐�");
+ showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鍐�");
+ HDLLog.Log("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鍐�");
+ break;
+ case AirCtrlParser.airModeHeatTem:
+ airModeState = 1;
+ airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鐑�");
+ showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鐑�");
+ HDLLog.Log("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鐑�");
+ break;
+ case AirCtrlParser.airModeVen:
+ airModeState = 2;
+ airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氶�氶");
+ showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氶�氶");
+ HDLLog.Log("绌鸿皟妯″紡锛屾ā寮忎负锛氶�氶");
+ break;
+ case AirCtrlParser.airModeAuto:
+ airModeState = 3;
+ airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氳嚜鍔�");
+ showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氳嚜鍔�");
+ HDLLog.Log("绌鸿皟妯″紡锛屾ā寮忎负锛氳嚜鍔�");
+ break;
+ case AirCtrlParser.airModeDehum:
+ airModeState = 4;
+ airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氭娊婀�");
+ showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氭娊婀�");
+ HDLLog.Log("绌鸿皟妯″紡锛屾ā寮忎负锛氭娊婀�");
+ break;
+ default:
+ airModeState = -1;
+ break;
+ }
+ break;
+ case AirCtrlParser.refTem:
+ airTempState = curState[1] & 0xFF;
+ airText.setText("绌鸿皟鍒跺喎锛屾俯搴︿负锛�" + (curState[1] & 0xFF));
+ showToast("绌鸿皟鍒跺喎锛屾俯搴︿负锛�" + (curState[1] & 0xFF));
+ HDLLog.Log("绌鸿皟鍒跺喎锛屾俯搴︿负锛�" + (curState[1] & 0xFF));
+ break;
+ case AirCtrlParser.heatTem:
+ airTempState = curState[1] & 0xFF;
+ airText.setText("绌鸿皟鍒剁儹锛屽埗鐑俯搴︿负" + (curState[1] & 0xFF));
+ showToast("绌鸿皟鍒剁儹锛屽埗鐑俯搴︿负" + (curState[1] & 0xFF));
+ HDLLog.Log("绌鸿皟鍒剁儹锛屽埗鐑俯搴︿负" + (curState[1] & 0xFF));
+ break;
+ case AirCtrlParser.autoTem:
+ airTempState = -1;
+ airText.setText("绌鸿皟鑷姩锛岃嚜鍔ㄦ俯搴︿负" + (curState[1] & 0xFF));
+ showToast("绌鸿皟鑷姩锛岃嚜鍔ㄦ俯搴︿负" + (curState[1] & 0xFF));
+ HDLLog.Log("绌鸿皟鑷姩锛岃嚜鍔ㄦ俯搴︿负" + (curState[1] & 0xFF));
+ break;
+ case AirCtrlParser.dehumTem:
+ airTempState = curState[1] & 0xFF;
+ airText.setText("绌鸿皟鎶芥箍锛屾娊婀挎俯搴︿负" + (curState[1] & 0xFF));
+ showToast("绌鸿皟鎶芥箍锛屾娊婀挎俯搴︿负" + (curState[1] & 0xFF));
+ HDLLog.Log("绌鸿皟鎶芥箍锛屾娊婀挎俯搴︿负" + (curState[1] & 0xFF));
+ break;
+ case AirCtrlParser.upTem:
+ airTempState = curState[1] & 0xFF;
+ airText.setText("绌鸿皟璋冩俯锛屼笂鍗囨俯搴︼細" + (curState[1] & 0xFF));
+ showToast("绌鸿皟璋冩俯锛屼笂鍗囨俯搴︼細" + (curState[1] & 0xFF));
+ HDLLog.Log("绌鸿皟璋冩俯锛屼笂鍗囨俯搴︼細" + (curState[1] & 0xFF));
+ break;
+ case AirCtrlParser.downTem:
+ airTempState = curState[1] & 0xFF;
+ airText.setText("绌鸿皟璋冩俯锛屼笅闄嶆俯搴︼細" + (curState[1] & 0xFF));
+ showToast("绌鸿皟璋冩俯锛屼笅闄嶆俯搴︼細" + (curState[1] & 0xFF));
+ HDLLog.Log("绌鸿皟璋冩俯锛屼笅闄嶆俯搴︼細" + (curState[1] & 0xFF));
+ break;
+
+ }
+ }
+ }
+
+ /**
+ * 閫昏緫妯″潡鎺у埗鍥炶皟Event
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onLogicFeedBackInfoEventMain(LogicFeedBackEvent event) {
+// 鍏堝垽鏂槸鍚﹁秴鏃�
+ if (event.getLogicCtrlBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ && event.getLogicCtrlBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getLogicCtrlBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum()
+ ) {
+ if (!event.isSuccess()) {
+ showToast("鍦烘櫙鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯");
+ return;
+ }
+ showToast("鍦烘櫙鎺у埗鎴愬姛");
+ }
+ }
+
+ /**
+ * 鑾峰彇鍗曚竴璁惧鐘舵�佸洖璋僂vent
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onDeviceStateEventMain(DeviceStateEvent event) {
+ if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ ) {
+ //杩欎釜杩斿洖鐨勪俊鎭槸褰撳墠鐘舵�佺殑
+ switch (event.getAppliancesInfo().getDeviceType()) {
+ case HDLApConfig.TYPE_LIGHT_DIMMER:
+ case HDLApConfig.TYPE_LIGHT_RELAY:
+ case HDLApConfig.TYPE_LIGHT_MIX_DIMMER:
+ case HDLApConfig.TYPE_LIGHT_MIX_RELAY:
+ if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) {
+ if (!event.isSuccess()) {
+ showToast("鑾峰彇鐏厜鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ lightBtn.setText("浜害 = " + HDLUtlis.getIntegerByObject(event.getAppliancesInfo().getCurState()));
+ }
+ break;
+ case HDLApConfig.TYPE_CURTAIN_GLYSTRO:
+ case HDLApConfig.TYPE_CURTAIN_ROLLER:
+ case HDLApConfig.TYPE_CURTAIN_MODULE:
+ if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) {
+ if (!event.isSuccess()) {
+ showToast("鑾峰彇绐楀笜鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ //绐楀笜妯″潡锛歝urState:0=鍋滄,1=鎵撳紑,2=鍏抽棴銆�
+ //寮�鍚堝笜鐢垫満锛屽嵎甯樼數鏈猴細curState:1-100寮�鍚堝害銆�
+ int curState = HDLUtlis.getIntegerByObject(event.getAppliancesInfo().getCurState());
+ if (event.getAppliancesInfo().getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) {//鍒ゆ柇鏄惁涓虹獥甯樻ā鍧�,鍚﹀垯涓哄紑鍚堝笜鎴栧嵎甯樼數鏈�
+ switch (curState) {
+ case CurtainCtrlParser.curtainOff:
+ curtainBtn.setText("绐楀笜鍏�");
+ curText1.setText("绐楀笜鍏�");
+ break;
+ case CurtainCtrlParser.curtainOn:
+ curtainBtn.setText("绐楀笜寮�");
+ curText1.setText("绐楀笜寮�");
+ break;
+ case CurtainCtrlParser.curtainPause:
+ curtainBtn.setText("绐楀笜鏆傚仠");
+ curText1.setText("绐楀笜鏆傚仠");
+ break;
+ }
+ } else {
+ curtainBtn5.setText("绐楀笜寮�鍒�" + curState + "%");
+ }
+ }
+ break;
+ case HDLApConfig.TYPE_AC_HVAC:
+ case HDLApConfig.TYPE_AC_PANEL:
+ if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) {
+ if (!event.isSuccess()) {
+ showToast("鑾峰彇绌鸿皟鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+
+ byte[] curState = event.getAppliancesInfo().getArrCurState();
+ switch (curState[0] & 0xFF) {
+ case AirCtrlParser.airSwich:
+ switch (curState[1] & 0xFF) {
+ case AirCtrlParser.airOff:
+ airSwitchState = 0;
+ airText.setText("绌鸿皟鍏�");
+ showToast("绌鸿皟鍏�");
+ HDLLog.Log("绌鸿皟鍏�");
+ break;
+ case AirCtrlParser.airOn:
+ airSwitchState = 1;
+ airText.setText("绌鸿皟寮�");
+ showToast("绌鸿皟寮�");
+ HDLLog.Log("绌鸿皟寮�");
+ break;
+ default:
+ break;
+ }
+
+ break;
+
+ case AirCtrlParser.airSpeed:
+ switch (curState[1] & 0xFF) {
+ case AirCtrlParser.airSpeedAuto:
+ airSpeedState = 0;
+ airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedAuto鑷姩椋庨��");
+ showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedAuto鑷姩椋庨��");
+ HDLLog.Log("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedAuto鑷姩椋庨��");
+ break;
+ case AirCtrlParser.airSpeedHigh:
+ airSpeedState = 1;
+ airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedHigh椋庨�熼珮");
+ showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedHigh椋庨�熼珮");
+ HDLLog.Log("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedHigh椋庨�熼珮");
+ break;
+ case AirCtrlParser.airSpeedMid:
+ airSpeedState = 2;
+ airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedMid椋庨�熶腑");
+ showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedMid椋庨�熶腑");
+ HDLLog.Log("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedMid椋庨�熶腑");
+ break;
+ case AirCtrlParser.airSpeedLow:
+ airSpeedState = 3;
+ airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedLow椋庨�熶綆");
+ showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedLow椋庨�熶綆");
+ HDLLog.Log("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedLow椋庨�熶綆");
+ break;
+ default:
+ break;
+ }
+ break;
+ case AirCtrlParser.airMode:
+ switch (curState[1] & 0xFF) {
+ case AirCtrlParser.airModeRefTem:
+ airModeState = 0;
+ airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鍐�");
+ showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鍐�");
+ HDLLog.Log("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鍐�");
+ break;
+ case AirCtrlParser.airModeHeatTem:
+ airModeState = 1;
+ airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鐑�");
+ showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鐑�");
+ HDLLog.Log("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鐑�");
+ break;
+ case AirCtrlParser.airModeVen:
+ airModeState = 2;
+ airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氶�氶");
+ showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氶�氶");
+ HDLLog.Log("绌鸿皟妯″紡锛屾ā寮忎负锛氶�氶");
+ break;
+ case AirCtrlParser.airModeAuto:
+ airModeState = 3;
+ airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氳嚜鍔�");
+ showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氳嚜鍔�");
+ HDLLog.Log("绌鸿皟妯″紡锛屾ā寮忎负锛氳嚜鍔�");
+ break;
+ case AirCtrlParser.airModeDehum:
+ airModeState = 4;
+ airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氭娊婀�");
+ showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氭娊婀�");
+ HDLLog.Log("绌鸿皟妯″紡锛屾ā寮忎负锛氭娊婀�");
+ break;
+ default:
+ break;
+ }
+ break;
+ case AirCtrlParser.refTem:
+ airTempState = curState[1] & 0xFF;
+ airText.setText("绌鸿皟鍒跺喎锛屾俯搴︿负锛�" + (curState[1] & 0xFF));
+ showToast("绌鸿皟鍒跺喎锛屾俯搴︿负锛�" + (curState[1] & 0xFF));
+ HDLLog.Log("绌鸿皟鍒跺喎锛屾俯搴︿负锛�" + (curState[1] & 0xFF));
+ break;
+ case AirCtrlParser.heatTem:
+ airTempState = curState[1] & 0xFF;
+ airText.setText("绌鸿皟鍒剁儹锛屽埗鐑俯搴︿负" + (curState[1] & 0xFF));
+ showToast("绌鸿皟鍒剁儹锛屽埗鐑俯搴︿负" + (curState[1] & 0xFF));
+ HDLLog.Log("绌鸿皟鍒剁儹锛屽埗鐑俯搴︿负" + (curState[1] & 0xFF));
+ break;
+ case AirCtrlParser.autoTem:
+ airTempState = curState[1] & 0xFF;
+ airText.setText("绌鸿皟鑷姩锛岃嚜鍔ㄦ俯搴︿负" + (curState[1] & 0xFF));
+ showToast("绌鸿皟鑷姩锛岃嚜鍔ㄦ俯搴︿负" + (curState[1] & 0xFF));
+ HDLLog.Log("绌鸿皟鑷姩锛岃嚜鍔ㄦ俯搴︿负" + (curState[1] & 0xFF));
+ break;
+ case AirCtrlParser.dehumTem:
+ airTempState = curState[1] & 0xFF;
+ airText.setText("绌鸿皟鎶芥箍锛屾娊婀挎俯搴︿负" + (curState[1] & 0xFF));
+ showToast("绌鸿皟鎶芥箍锛屾娊婀挎俯搴︿负" + (curState[1] & 0xFF));
+ HDLLog.Log("绌鸿皟鎶芥箍锛屾娊婀挎俯搴︿负" + (curState[1] & 0xFF));
+ break;
+ case AirCtrlParser.upTem:
+ airTempState = curState[1] & 0xFF;
+ airText.setText("绌鸿皟璋冩俯锛屼笂鍗囨俯搴︼細" + (curState[1] & 0xFF));
+ showToast("绌鸿皟璋冩俯锛屼笂鍗囨俯搴︼細" + (curState[1] & 0xFF));
+ HDLLog.Log("绌鸿皟璋冩俯锛屼笂鍗囨俯搴︼細" + (curState[1] & 0xFF));
+ break;
+ case AirCtrlParser.downTem:
+ airTempState = curState[1] & 0xFF;
+ airText.setText("绌鸿皟璋冩俯锛屼笅闄嶆俯搴︼細" + (curState[1] & 0xFF));
+ showToast("绌鸿皟璋冩俯锛屼笅闄嶆俯搴︼細" + (curState[1] & 0xFF));
+ HDLLog.Log("绌鸿皟璋冩俯锛屼笅闄嶆俯搴︼細" + (curState[1] & 0xFF));
+ break;
+ }
+ }
+ break;
+ case HDLApConfig.TYPE_SENSOR_DRY_CONTACT://2019-07-03 灞忚斀
+ //浼犳劅鍣� 骞叉帴鐐� 銆傚彧鏈夊紑鍏崇姸鎬�
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---骞叉帴鐐圭姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float dryContactValue = (float) event.getAppliancesInfo().getCurState();
+ String dryContactUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---骞叉帴鐐圭姸鎬侊細" + dryContactValue + dryContactUnit);
+ HDLLog.Log("浼犳劅鍣�---骞叉帴鐐圭姸鎬侊細" + dryContactValue + dryContactUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR:
+ //浼犳劅鍣� 绉诲姩鎺㈡祴 銆傜伒鏁忓害
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---绉诲姩鎺㈡祴鐏垫晱搴︾姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float mdValue = (float) event.getAppliancesInfo().getCurState();
+ String mdValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---绉诲姩鎺㈡祴鐏垫晱搴︼細" + mdValue + mdValueUnit);
+ HDLLog.Log("浼犳劅鍣�---绉诲姩鎺㈡祴鐏垫晱搴︼細" + mdValue + mdValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_TEMP:
+ //浼犳劅鍣� 娓╁害
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---娓╁害鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float tempValue = (float) event.getAppliancesInfo().getCurState();
+ String tempValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---娓╁害锛�" + tempValue + tempValueUnit);
+ HDLLog.Log("浼犳劅鍣�---娓╁害锛�" + tempValue + tempValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_HUMIDITY:
+ //浼犳劅鍣� 婀垮害
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---婀垮害鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float humidityValue = (float) event.getAppliancesInfo().getCurState();
+ String humidityValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---婀垮害锛�" + humidityValue + humidityValueUnit);
+ HDLLog.Log("浼犳劅鍣�---婀垮害锛�" + humidityValue + humidityValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_ILLUMINACE:
+ //浼犳劅鍣� 鐓у害
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---鐓у害鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float illuminaceValue = (float) event.getAppliancesInfo().getCurState();
+ String illuminaceValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---鐓у害锛�" + illuminaceValue + illuminaceValueUnit);
+ HDLLog.Log("浼犳劅鍣�---鐓у害锛�" + illuminaceValue + illuminaceValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_VOC:
+ //浼犳劅鍣� 褰撳墠绌烘皵璐ㄩ噺绛夌骇
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---褰撳墠绌烘皵璐ㄩ噺绛夌骇鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float vocValue = (float) event.getAppliancesInfo().getCurState();
+ String vocValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---褰撳墠绌烘皵璐ㄩ噺绛夌骇锛�" + vocValue + vocValueUnit);
+ HDLLog.Log("浼犳劅鍣�---褰撳墠绌烘皵璐ㄩ噺绛夌骇锛�" + vocValue + vocValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5:
+ //浼犳劅鍣� pm2.5
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---pm2.5鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float pm2_5Value = (float) event.getAppliancesInfo().getCurState();
+ String pm2_5ValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---pm2.5锛�" + pm2_5Value + pm2_5ValueUnit);
+ HDLLog.Log("浼犳劅鍣�---pm2.5锛�" + pm2_5Value + pm2_5ValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_C02:
+ //浼犳劅鍣� 浜屾哀鍖栫⒊
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---浜屾哀鍖栫⒊鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float co2Value = (float) event.getAppliancesInfo().getCurState();
+ String co2ValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---浜屾哀鍖栫⒊锛�" + co2Value + co2ValueUnit);
+ HDLLog.Log("浼犳劅鍣�---浜屾哀鍖栫⒊锛�" + co2Value + co2ValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_LPG:
+ //浼犳劅鍣� 娑插寲鐭虫补姘�
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---娑插寲鐭虫补姘旂姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float lpgValue = (float) event.getAppliancesInfo().getCurState();
+ String lpgValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---娑插寲鐭虫补姘旓細" + lpgValue + lpgValueUnit);
+ HDLLog.Log("浼犳劅鍣�---娑插寲鐭虫补姘旓細" + lpgValue + lpgValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_CO_H2:
+ //浼犳劅鍣� 浜哄伐鐓ゆ皵
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---浜哄伐鐓ゆ皵鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float coh2Value = (float) event.getAppliancesInfo().getCurState();
+ String coh2ValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---浜哄伐鐓ゆ皵锛�" + coh2Value + coh2ValueUnit);
+ HDLLog.Log("浼犳劅鍣�---浜哄伐鐓ゆ皵锛�" + coh2Value + coh2ValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_CH4:
+ //浼犳劅鍣� 澶╃劧姘�
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---澶╃劧姘旂姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float ch4Value = (float) event.getAppliancesInfo().getCurState();
+ String ch4ValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---澶╃劧姘旓細" + ch4Value + ch4ValueUnit);
+ HDLLog.Log("浼犳劅鍣�---澶╃劧姘旓細" + ch4Value + ch4ValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_SMOG:
+ //浼犳劅鍣� 鐑熼浘
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---鐑熼浘鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float smogValue = (float) event.getAppliancesInfo().getCurState();
+ String smogValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---鐑熼浘锛�" + smogValue + smogValueUnit);
+ HDLLog.Log("浼犳劅鍣�---鐑熼浘锛�" + smogValue + smogValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_WIND_SPEED:
+ //浼犳劅鍣� 椋庨��
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---椋庨�熺姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float windSpeedValue = (float) event.getAppliancesInfo().getCurState();
+ String windSpeedValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---椋庨�燂細" + windSpeedValue + windSpeedValueUnit);
+ HDLLog.Log("浼犳劅鍣�---椋庨�燂細" + windSpeedValue + windSpeedValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE:
+ //浼犳劅鍣� 椋庡帇
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---椋庡帇鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float windPressureValue = (float) event.getAppliancesInfo().getCurState();
+ String windPressureValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---椋庡帇锛�" + windPressureValue + windPressureValueUnit);
+ HDLLog.Log("浼犳劅鍣�---椋庡帇锛�" + windPressureValue + windPressureValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW:
+ //浼犳劅鍣� 娑蹭綋娴侀噺
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---娑蹭綋娴侀噺鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float liquidFlowValue = (float) event.getAppliancesInfo().getCurState();
+ String liquidFlowValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---娑蹭綋娴侀噺锛�" + liquidFlowValue + liquidFlowValueUnit);
+ HDLLog.Log("浼犳劅鍣�---娑蹭綋娴侀噺锛�" + liquidFlowValue + liquidFlowValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE:
+ //浼犳劅鍣� 娑蹭綋鍘嬪姏
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---娑蹭綋鍘嬪姏鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float liquidPressureValue = (float) event.getAppliancesInfo().getCurState();
+ String liquidPressureValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---娑蹭綋鍘嬪姏锛�" + liquidPressureValue + liquidPressureValueUnit);
+ HDLLog.Log("浼犳劅鍣�---娑蹭綋鍘嬪姏锛�" + liquidPressureValue + liquidPressureValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH:
+ //浼犳劅鍣� 娑蹭綋娣卞害
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---娑蹭綋娣卞害鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float liquidDepthValue = (float) event.getAppliancesInfo().getCurState();
+ String liquidDepthValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---娑蹭綋娣卞害锛�" + liquidDepthValue + liquidDepthValueUnit);
+ HDLLog.Log("浼犳劅鍣�---娑蹭綋娣卞害锛�" + liquidDepthValue + liquidDepthValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_RAIN_FALL:
+ //浼犳劅鍣� 闆ㄩ噺
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---闆ㄩ噺鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float rainFallValue = (float) event.getAppliancesInfo().getCurState();
+ String rainFallValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---闆ㄩ噺锛�" + rainFallValue + rainFallValueUnit);
+ HDLLog.Log("浼犳劅鍣�---闆ㄩ噺锛�" + rainFallValue + rainFallValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_WEIGHT:
+ //浼犳劅鍣� 閲嶉噺
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---閲嶉噺鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float weightValue = (float) event.getAppliancesInfo().getCurState();
+ String weightValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---閲嶉噺锛�" + weightValue + weightValueUnit);
+ HDLLog.Log("浼犳劅鍣�---閲嶉噺锛�" + weightValue + weightValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH:
+ //浼犳劅鍣� 閲嶉噺
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---閲嶉噺鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float height_lengthValue = (float) event.getAppliancesInfo().getCurState();
+ String height_lengthValueUnit = ((SensorStateBackInfo) event).getUnite();
+ showToast("浼犳劅鍣�---閲嶉噺锛�" + height_lengthValue + height_lengthValueUnit);
+ HDLLog.Log("浼犳劅鍣�---閲嶉噺锛�" + height_lengthValue + height_lengthValueUnit);
+ break;
+ case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED:
+ //浼犳劅鍣� 鐗╀綋閫熷害
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---鐗╀綋閫熷害鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float objectSpeedValue = (float) event.getAppliancesInfo().getCurState();
+ String objectSpeedUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣�
+ showToast("浼犳劅鍣�---鐗╀綋閫熷害锛�" + objectSpeedValue + objectSpeedUnite);
+ HDLLog.Log("浼犳劅鍣�---鐗╀綋閫熷害锛�" + objectSpeedValue + objectSpeedUnite);
+ break;
+ case HDLApConfig.TYPE_SENSOR_SHAKE:
+ //浼犳劅鍣� 闇囧姩
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---闇囧姩鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float shakeValue = (float) event.getAppliancesInfo().getCurState();
+ String shakeValueUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣�
+ showToast("浼犳劅鍣�---闇囧姩锛�" + shakeValue + shakeValueUnite);
+ HDLLog.Log("浼犳劅鍣�---闇囧姩锛�" + shakeValue + shakeValueUnite);
+ break;
+ case HDLApConfig.TYPE_SENSOR_VOLTAGE:
+ //浼犳劅鍣� 鐢靛帇
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---鐢靛帇鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float voltageValue = (float) event.getAppliancesInfo().getCurState();
+ String voltageValueUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣�
+ showToast("浼犳劅鍣�---鐢靛帇锛�" + voltageValue + voltageValueUnite);
+ HDLLog.Log("浼犳劅鍣�---鐢靛帇锛�" + voltageValue + voltageValueUnite);
+ break;
+ case HDLApConfig.TYPE_SENSOR_ELECTRICITY:
+ //浼犳劅鍣� 鐢垫祦
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---鐢垫祦鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float electricityValue = (float) event.getAppliancesInfo().getCurState();
+ String electricityValueUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣�
+ showToast("浼犳劅鍣�---鐢垫祦锛�" + electricityValue + electricityValueUnite);
+ HDLLog.Log("浼犳劅鍣�---鐢垫祦锛�" + electricityValue + electricityValueUnite);
+ break;
+ case HDLApConfig.TYPE_SENSOR_POWER:
+ //浼犳劅鍣� 鍔熺巼
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---鍔熺巼鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float powerValue = (float) event.getAppliancesInfo().getCurState();
+ String powerValueUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣�
+ showToast("浼犳劅鍣�---鍔熺巼锛�" + powerValue + powerValueUnite);
+ HDLLog.Log("浼犳劅鍣�---鍔熺巼锛�" + powerValue + powerValueUnite);
+ break;
+ case HDLApConfig.TYPE_SENSOR_FLOODING:
+ //浼犳劅鍣� 姘存蹈
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---姘存蹈鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float floodingValue = (float) event.getAppliancesInfo().getCurState();
+ String floodingValueUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣�
+ showToast("浼犳劅鍣�---姘存蹈锛�" + floodingValue + floodingValueUnite);
+ HDLLog.Log("浼犳劅鍣�---姘存蹈锛�" + floodingValue + floodingValueUnite);
+ break;
+ case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET:
+ //浼犳劅鍣� 闂ㄧ绐楃
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---闂ㄧ绐楃鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float doorMagnetValue = (float) event.getAppliancesInfo().getCurState();
+ String doorMagnetValueUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣�
+ showToast("浼犳劅鍣�---闂ㄧ绐楃锛�" + doorMagnetValue + doorMagnetValueUnite);
+ HDLLog.Log("浼犳劅鍣�---闂ㄧ绐楃锛�" + doorMagnetValue + doorMagnetValueUnite);
+ break;
+ case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON:
+ //浼犳劅鍣� 绱ф�ユ寜閽�
+ if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣�---绱ф�ユ寜閽姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ float emergencyButtonValue = (float) event.getAppliancesInfo().getCurState();
+ String emergencyButtonUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣�
+ showToast("浼犳劅鍣�---绱ф�ユ寜閽細" + emergencyButtonValue + emergencyButtonUnite);
+ HDLLog.Log("浼犳劅鍣�---绱ф�ユ寜閽細" + emergencyButtonValue + emergencyButtonUnite);
+ break;
+
+ }
+ }
+ }
+
+
+
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlAirActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlAirActivity.java
new file mode 100644
index 0000000..9dbe52d
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlAirActivity.java
@@ -0,0 +1,754 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig;
+import com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.AirFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DeviceStateEvent;
+import com.hdl.sdk.ttl_sdk.R;
+import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+import com.hdl.sdk.ttl_sdk.utlis.HDLLog;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+
+/**
+ * Created by JLChen on 2019/7/4
+ * 绌鸿皟绫绘ā鍧楁帶鍒堕〉闈�
+ * PANEL 绫诲瀷绌鸿皟妯″潡
+ * 16~30鎽勬皬搴�(鈩�)
+ */
+public class CtrlAirActivity extends BaseActivity {
+ /**Topbar*/
+ private RelativeLayout topBarBack;
+ private TextView topBarTitle;
+
+ private Button airBtnSwitch, airBtnMode, airBtnTemp, airBtnSpeed;
+ private TextView airText;
+ private TextView tv_switch, tv_mode, tv_speed, tv_tempet;
+ private EditText airTempEd;
+ private AppliancesInfo appliancesInfo;
+
+
+ private int airSwitchState;//Demo浠呬互姝や綔涓烘紨绀猴紝瀹為檯璇锋牴鎹渶姹傚紑鍙戣璁�
+ private int airModeState;
+ private int airTempState;
+ private int airSpeedState;
+// /**
+// * true涓鸿缃憚姘忓害 false涓鸿缃崕姘忓害
+// * 鍙傛暟鑼冨洿 16~30鎽勬皬搴�(鈩�)
+// * ~86鍗庢皬搴�(鈩�)
+// */
+// private boolean bCelsius = true;
+
+ /**
+ * 澶嶅啓isRegisterEventBus() 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true
+ *
+ * @return true
+ */
+ @Override
+ protected boolean isRegisterEventBus() {
+ return true;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_ctrl_air);
+ initToolbar();
+ initView();
+ initOnClick();
+ initcurState();
+ displayStateView();
+
+// if(appliancesInfo.getDeviceType() == HDLApConfig.TYPE_AC_HVAC) {
+// HDLCommand.getHVACDeviceStateFromNetwork(appliancesInfo);
+// }
+ //浠庢湰鍦拌幏鍙栫┖璋冮潰鏉跨姸鎬�
+ HDLCommand.getDeviceStateFromLocal(appliancesInfo);
+ }
+
+
+
+ /**
+ * 鍒濆鍖朤oolbar
+ */
+ private void initToolbar() {
+ topBarBack = findViewById(R.id.ll_top_b_left);
+ setViewVisible(topBarBack);
+ topBarTitle = findViewById(R.id.tv_top_b_header_title);
+ topBarBack.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ });
+ }
+
+ private void initcurState() {
+ appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl");
+ String titleStr = appliancesInfo.getRemarks();
+ topBarTitle.setText(titleStr);
+ }
+
+ private void displayStateView(){
+ switch (appliancesInfo.getDeviceType()) {
+// case HDLApConfig.TYPE_AC_HVAC:
+ case HDLApConfig.TYPE_AC_PANEL:
+ loadDeviceData();
+ break;
+ default:
+ finish();//璁惧绫诲瀷涓嶅缁撴潫椤甸潰
+ break;
+ }
+ /**鏍规嵁闇�姹傛槸鍚﹀彂閫佷竴娆¤幏鍙栧埛鏂扮姸鎬佽姹�*/
+ }
+
+ private void initView() {
+ airBtnSwitch = findViewById(R.id.airbtn_switch);
+ airBtnMode = findViewById(R.id.airbtn_mode);
+ airBtnSpeed = findViewById(R.id.airbtn_speed);
+ airBtnTemp = findViewById(R.id.airbtn_tempBtn);
+ airTempEd = findViewById(R.id.airet_tempet);
+ airText = findViewById(R.id.airText);
+
+ tv_switch = findViewById(R.id.tv_switch);
+ tv_mode = findViewById(R.id.tv_mode);
+ tv_speed = findViewById(R.id.tv_speed);
+ tv_tempet = findViewById(R.id.tv_tempet);
+ }
+
+ private void initOnClick() {
+ airBtnSwitch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ //婕旂ず褰撳墠鐘舵�佷负鍏筹紝璁剧疆涓哄紑銆傚紑锛岃缃负鍏炽��
+ if (airSwitchState == 0) {
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSwich, AirCtrlParser.airOn);//绌鸿皟寮�
+ } else {
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSwich, AirCtrlParser.airOff);//绌鸿皟鍏�
+ }
+ }
+ });
+
+
+ airBtnMode.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ switch (airModeState) {
+ case 0:
+ //鑻ュ綋鍓嶇┖璋冩ā寮忎负鍒跺喎锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓哄埗鐑�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeHeatTem);//绌鸿皟妯″紡鍒剁儹
+ break;
+ case 1:
+ //鑻ュ綋鍓嶇┖璋冩ā寮忎负鍒剁儹锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓洪�氶
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeVen);//绌鸿皟妯″紡閫氶
+ break;
+ case 2:
+ //鑻ュ綋鍓嶇┖璋冩ā寮忎负閫氶锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓鸿嚜鍔�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeAuto);//绌鸿皟妯″紡鑷姩
+ break;
+ case 3:
+ //鑻ュ綋鍓嶇┖璋冩ā寮忎负鑷姩锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓烘娊婀�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeDehum);//绌鸿皟妯″紡鎶芥箍
+ break;
+ case 4:
+ //鑻ュ綋鍓嶇┖璋冩ā寮忎负鎶芥箍锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓哄埗鍐�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeRefTem);//绌鸿皟妯″紡鍒跺喎
+ break;
+ default:
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeRefTem);//绌鸿皟妯″紡鍒跺喎
+ break;
+
+ }
+
+
+ }
+ });
+
+ airBtnSpeed.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ switch (airSpeedState) {
+ case 0:
+ //鑻ュ綋鍓嶇┖璋冮閫熶负鑷姩锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓洪珮椋�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedHigh);//椋庨�熼珮椋�
+ break;
+ case 1:
+ //鑻ュ綋鍓嶇┖璋冮閫熶负楂橀锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓轰腑椋�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedMid);//椋庨�熶腑椋�
+ break;
+ case 2:
+ //鑻ュ綋鍓嶇┖璋冮閫熶负涓锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓轰綆椋�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedLow);//椋庨�熶綆椋�
+ break;
+ case 3:
+ //鑻ュ綋鍓嶇┖璋冮閫熶负浣庨锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓鸿嚜鍔�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedAuto);//椋庨�熻嚜鍔�
+ break;
+
+
+ }
+ }
+ });
+
+ airBtnTemp.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ String tempStr = airTempEd.getText().toString();
+ if (TextUtils.isEmpty(tempStr)) {
+ showToast("璁剧疆鐨勬俯搴︿笉鑳戒负绌�");
+ return;
+ }
+ int tempInt = Integer.parseInt(tempStr);
+
+ if (tempInt < 16 || tempInt > 30) {
+ showToast("娓╁害璁剧疆鑼冨洿涓猴細16~30鎽勬皬搴�(鈩�)");
+ return;
+ }
+
+ switch (airModeState) {
+ case 0:
+ //褰撳墠绌鸿皟妯″紡涓哄埗鍐�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.refTem, tempInt);//鍒跺喎娓╁害
+ break;
+ case 1:
+ //褰撳墠绌鸿皟妯″紡涓哄埗鐑�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.heatTem, tempInt);//鍒剁儹娓╁害
+ break;
+ case 2:
+ //褰撳墠绌鸿皟妯″紡涓洪�氶
+ showToast("閫氶妯″紡涓嶈兘鎺у埗娓╁害");
+ break;
+ case 3:
+ //褰撳墠绌鸿皟妯″紡涓鸿嚜鍔�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.autoTem, tempInt);//鑷姩娓╁害 鑼冨洿16-30
+ break;
+ case 4:
+ //褰撳墠绌鸿皟妯″紡涓烘娊婀�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.dehumTem, tempInt);//鎶芥箍娓╁害 鑼冨洿16-30
+ break;
+ default:
+ break;
+
+ }
+
+// HDLCommand.airCtrl(appliancesInfo,AirCtrlParser.upTem,1);//涓婂崌娓╁害 鑼冨洿0-5
+// HDLCommand.airCtrl(appliancesInfo,AirCtrlParser.downTem,1);//涓嬮檷娓╁害 鑼冨洿0-5
+ }
+ });
+
+
+ }
+
+
+ private void loadDeviceData() {
+ if (appliancesInfo.getArrCurState() != null) {
+ String stringACState = "";
+ byte[] acCurState = appliancesInfo.getArrCurState();
+ for (int index = 0; index < acCurState.length; index++) {
+ if (index == 0 && acCurState[index] == 0) {
+ airSwitchState = 0;
+ stringACState += "绌鸿皟宸插叧闂�";
+ //濡傛灉绌鸿皟鍏抽棴鐘舵�侊紝鍒欐棤闇�鍐嶉亶鍘�
+ break;
+ }
+ if (index == 0 && acCurState[index] == 1) {
+ airSwitchState = 1;
+ stringACState += "绌鸿皟姝e湪杩愯";
+ }
+
+ switch (index) {
+
+ case 1:
+ switch (acCurState[index]) {
+ case 0:
+ airModeState = 0;
+ stringACState += " 绌鸿皟妯″紡:鍒跺喎";
+ break;
+ case 1:
+ airModeState = 1;
+ stringACState += " 绌鸿皟妯″紡:鍒剁儹";
+ break;
+ case 2:
+ airModeState = 2;
+ stringACState += " 绌鸿皟妯″紡:閫氶";
+ break;
+ case 3:
+ airModeState = 3;
+ stringACState += " 绌鸿皟妯″紡:鑷姩";
+ break;
+ case 4:
+ airModeState = 4;
+ stringACState += " 绌鸿皟妯″紡:鎶芥箍";
+ break;
+ default:
+ airModeState = -1;
+ stringACState += " 鏈煡绌鸿皟妯″紡";
+ break;
+ }
+ break;
+ case 2:
+ switch (acCurState[1]) {
+ case 0:
+ airTempState = acCurState[index] & 0xff;
+ stringACState += " 鍒跺喎娓╁害锛�" + (acCurState[index] & 0xff);
+ break;
+ case 1:
+ airTempState = acCurState[index] & 0xff;
+ stringACState += " 鍒剁儹娓╁害锛�" + (acCurState[index] & 0xff);
+ break;
+ case 2:
+ airTempState = -1;
+ stringACState += " 閫氶鏃犳俯搴︽樉绀�";
+ break;
+ case 3:
+ airTempState = acCurState[index] & 0xff;
+ stringACState += " 鑷姩娓╁害锛�" + (acCurState[index] & 0xff);
+ break;
+ case 4:
+ airTempState = acCurState[index] & 0xff;
+ stringACState += " 鎶芥箍娓╁害锛�" + (acCurState[index] & 0xff);
+ break;
+ default:
+ airTempState = -2;
+ stringACState += " 鏈煡娓╁害";
+ break;
+ }
+ break;
+ case 3:
+ String curSpeed;
+ switch (appliancesInfo.getArrCurState()[index]) {
+ case 0:
+ airSpeedState = 0;
+ curSpeed = " 椋庨�熻嚜鍔�";
+ break;
+ case 1:
+ airSpeedState = 1;
+ curSpeed = " 椋庨�熼珮";
+ break;
+ case 2:
+ airSpeedState = 2;
+ curSpeed = " 椋庨�熶腑";
+ break;
+ case 3:
+ airSpeedState = 3;
+ curSpeed = " 椋庨�熶綆";
+ break;
+ default:
+ airSpeedState = -1;
+ curSpeed = " 鏈煡椋庨��";
+ break;
+ }
+ switch (appliancesInfo.getArrCurState()[1]) {
+ case 0:
+ stringACState += curSpeed;
+ break;
+ case 1:
+ stringACState += curSpeed;
+ break;
+ case 2:
+ stringACState += curSpeed;
+ break;
+ case 3:
+ stringACState += curSpeed;
+ break;
+ case 4:
+ stringACState += " 鎶芥箍鏃犻閫�";
+ break;
+ default:
+ stringACState += " 鏈煡绌鸿皟妯″紡";
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ airText.setText(stringACState);
+ } else {
+ airText.setText("鏈幏鍙栧埌绌鸿皟璁惧鐘舵��");
+ }
+
+ }
+
+ /**
+ * 绌鸿皟妯″潡鎺у埗鍥炶皟Event
+ *
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onAirFeedBackInfoEventMain(AirFeedBackEvent event) {
+ if (event.getAirCtrlBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ && event.getAirCtrlBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getAirCtrlBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum()
+ ) {
+ // 鍏堝垽鏂槸鍚﹁秴鏃�
+ if (!event.isSuccess()) {
+ showToast("绌鸿皟鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯");
+ return;
+ }
+ String mes = "";
+ byte[] curState = event.getAirCtrlBackInfo().getCurState();
+ readAirState(curState);
+ }
+ }
+
+ /**
+ * 鑾峰彇鍗曚竴璁惧鐘舵�佸洖璋僂vent
+ *
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onDeviceStateEventMain(DeviceStateEvent event) {
+ if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ ) {
+ //杩欎釜杩斿洖鐨勪俊鎭槸褰撳墠鐘舵�佺殑
+ switch (event.getAppliancesInfo().getDeviceType()) {
+// case HDLApConfig.TYPE_AC_HVAC:
+ case HDLApConfig.TYPE_AC_PANEL:
+ if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) {
+ if (!event.isSuccess()) {
+ showToast("鑾峰彇绌鸿皟鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+
+ byte[] curState = event.getAppliancesInfo().getArrCurState();
+
+ readAirState(curState);
+// switch (curState[0] & 0xFF) {
+// case AirCtrlParser.airSwich:
+// switch (curState[1] & 0xFF) {
+// case AirCtrlParser.airOff:
+// airSwitchState = 0;
+// airText.setText("绌鸿皟鍏�");
+// showToast("绌鸿皟鍏�");
+// HDLLog.Log("绌鸿皟鍏�");
+// break;
+// case AirCtrlParser.airOn:
+// airSwitchState = 1;
+// airText.setText("绌鸿皟寮�");
+// showToast("绌鸿皟寮�");
+// HDLLog.Log("绌鸿皟寮�");
+// break;
+// default:
+// break;
+// }
+//
+// break;
+//
+// case AirCtrlParser.airSpeed:
+// switch (curState[1] & 0xFF) {
+// case AirCtrlParser.airSpeedAuto:
+// airSpeedState = 0;
+// airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedAuto鑷姩椋庨��");
+// showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedAuto鑷姩椋庨��");
+// HDLLog.Log("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedAuto鑷姩椋庨��");
+// break;
+// case AirCtrlParser.airSpeedHigh:
+// airSpeedState = 1;
+// airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedHigh椋庨�熼珮");
+// showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedHigh椋庨�熼珮");
+// HDLLog.Log("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedHigh椋庨�熼珮");
+// break;
+// case AirCtrlParser.airSpeedMid:
+// airSpeedState = 2;
+// airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedMid椋庨�熶腑");
+// showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedMid椋庨�熶腑");
+// HDLLog.Log("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedMid椋庨�熶腑");
+// break;
+// case AirCtrlParser.airSpeedLow:
+// airSpeedState = 3;
+// airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedLow椋庨�熶綆");
+// showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedLow椋庨�熶綆");
+// HDLLog.Log("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedLow椋庨�熶綆");
+// break;
+// default:
+// break;
+// }
+// break;
+// case AirCtrlParser.airMode:
+// switch (curState[1] & 0xFF) {
+// case AirCtrlParser.airModeRefTem:
+// airModeState = 0;
+// airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鍐�");
+// showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鍐�");
+// HDLLog.Log("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鍐�");
+// break;
+// case AirCtrlParser.airModeHeatTem:
+// airModeState = 1;
+// airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鐑�");
+// showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鐑�");
+// HDLLog.Log("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鐑�");
+// break;
+// case AirCtrlParser.airModeVen:
+// airModeState = 2;
+// airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氶�氶");
+// showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氶�氶");
+// HDLLog.Log("绌鸿皟妯″紡锛屾ā寮忎负锛氶�氶");
+// break;
+// case AirCtrlParser.airModeAuto:
+// airModeState = 3;
+// airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氳嚜鍔�");
+// showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氳嚜鍔�");
+// HDLLog.Log("绌鸿皟妯″紡锛屾ā寮忎负锛氳嚜鍔�");
+// break;
+// case AirCtrlParser.airModeDehum:
+// airModeState = 4;
+// airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氭娊婀�");
+// showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氭娊婀�");
+// HDLLog.Log("绌鸿皟妯″紡锛屾ā寮忎负锛氭娊婀�");
+// break;
+// default:
+// break;
+// }
+// break;
+// case AirCtrlParser.refTem:
+// airTempState = curState[1] & 0xFF;
+// airText.setText("绌鸿皟鍒跺喎锛屾俯搴︿负锛�" + (curState[1] & 0xFF));
+// showToast("绌鸿皟鍒跺喎锛屾俯搴︿负锛�" + (curState[1] & 0xFF));
+// HDLLog.Log("绌鸿皟鍒跺喎锛屾俯搴︿负锛�" + (curState[1] & 0xFF));
+// break;
+// case AirCtrlParser.heatTem:
+// airTempState = curState[1] & 0xFF;
+// airText.setText("绌鸿皟鍒剁儹锛屽埗鐑俯搴︿负" + (curState[1] & 0xFF));
+// showToast("绌鸿皟鍒剁儹锛屽埗鐑俯搴︿负" + (curState[1] & 0xFF));
+// HDLLog.Log("绌鸿皟鍒剁儹锛屽埗鐑俯搴︿负" + (curState[1] & 0xFF));
+// break;
+// case AirCtrlParser.autoTem:
+// airTempState = curState[1] & 0xFF;
+// airText.setText("绌鸿皟鑷姩锛岃嚜鍔ㄦ俯搴︿负" + (curState[1] & 0xFF));
+// showToast("绌鸿皟鑷姩锛岃嚜鍔ㄦ俯搴︿负" + (curState[1] & 0xFF));
+// HDLLog.Log("绌鸿皟鑷姩锛岃嚜鍔ㄦ俯搴︿负" + (curState[1] & 0xFF));
+// break;
+// case AirCtrlParser.dehumTem:
+// airTempState = curState[1] & 0xFF;
+// airText.setText("绌鸿皟鎶芥箍锛屾娊婀挎俯搴︿负" + (curState[1] & 0xFF));
+// showToast("绌鸿皟鎶芥箍锛屾娊婀挎俯搴︿负" + (curState[1] & 0xFF));
+// HDLLog.Log("绌鸿皟鎶芥箍锛屾娊婀挎俯搴︿负" + (curState[1] & 0xFF));
+// break;
+// case AirCtrlParser.upTem:
+// airTempState = curState[1] & 0xFF;
+// airText.setText("绌鸿皟璋冩俯锛屼笂鍗囨俯搴︼細" + (curState[1] & 0xFF));
+// showToast("绌鸿皟璋冩俯锛屼笂鍗囨俯搴︼細" + (curState[1] & 0xFF));
+// HDLLog.Log("绌鸿皟璋冩俯锛屼笂鍗囨俯搴︼細" + (curState[1] & 0xFF));
+// break;
+// case AirCtrlParser.downTem:
+// airTempState = curState[1] & 0xFF;
+// airText.setText("绌鸿皟璋冩俯锛屼笅闄嶆俯搴︼細" + (curState[1] & 0xFF));
+// showToast("绌鸿皟璋冩俯锛屼笅闄嶆俯搴︼細" + (curState[1] & 0xFF));
+// HDLLog.Log("绌鸿皟璋冩俯锛屼笅闄嶆俯搴︼細" + (curState[1] & 0xFF));
+// break;
+// }
+ }
+ break;
+ default:
+ //涓嶅鐞�
+ break;
+ }
+ }
+ }
+
+ private void readAirState( byte[] curState ){
+ String mes = "";
+ switch (curState[0] & 0xFF) {
+ case AirCtrlParser.airSwich:
+ switch (curState[1] & 0xFF) {
+ case AirCtrlParser.airOff:
+ airSwitchState = 0;
+
+ tv_switch.setText("鍏�");
+
+ mes = "绌鸿皟鍏�";
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+ break;
+ case AirCtrlParser.airOn:
+ airSwitchState = 1;
+// airText.setText("绌鸿皟寮�");
+// showToast("绌鸿皟寮�");
+// HDLLog.Log("绌鸿皟寮�");
+ tv_switch.setText("寮�");
+
+ mes = "绌鸿皟寮�";
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+ break;
+ default:
+ break;
+ }
+
+ break;
+
+ case AirCtrlParser.airSpeed:
+ switch (curState[1] & 0xFF) {
+ case AirCtrlParser.airSpeedAuto:
+ airSpeedState = 0;
+ tv_speed.setText("鑷姩");
+
+ mes = "鑷姩椋庨��";
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+
+ break;
+ case AirCtrlParser.airSpeedHigh:
+ airSpeedState = 1;
+
+ tv_speed.setText("楂橀��");
+ mes = "椋庨�熼珮";
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+ break;
+ case AirCtrlParser.airSpeedMid:
+ airSpeedState = 2;
+ tv_speed.setText("涓��");
+ mes = "椋庨�熶腑";
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+
+ break;
+ case AirCtrlParser.airSpeedLow:
+ airSpeedState = 3;
+
+ tv_speed.setText("浣庨��");
+ mes = "椋庨�熶綆";
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+
+ break;
+ default:
+ break;
+ }
+ break;
+ case AirCtrlParser.airMode:
+ switch (curState[1] & 0xFF) {
+ case AirCtrlParser.airModeRefTem:
+ airModeState = 0;
+
+ tv_mode.setText("鍒跺喎");
+
+ mes = "妯″紡涓猴細鍒跺喎";
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+
+ break;
+ case AirCtrlParser.airModeHeatTem:
+ airModeState = 1;
+ tv_mode.setText("鍒剁儹");
+
+ mes = "妯″紡涓猴細鍒剁儹";
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+ break;
+ case AirCtrlParser.airModeVen:
+ airModeState = 2;
+ tv_mode.setText("閫氶");
+
+ mes = "妯″紡涓猴細閫氶";
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+ break;
+ case AirCtrlParser.airModeAuto:
+ airModeState = 3;
+ tv_mode.setText("鑷姩");
+
+ mes = "妯″紡涓猴細鑷姩";
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+ break;
+ case AirCtrlParser.airModeDehum:
+ airModeState = 4;
+ tv_mode.setText("鎶芥箍");
+
+ mes = "妯″紡涓猴細鎶芥箍";
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+ break;
+ default:
+ airModeState = -1;
+ break;
+ }
+ break;
+ case AirCtrlParser.refTem:
+ airTempState = curState[1] & 0xFF;
+
+ tv_tempet.setText("" + airTempState);
+ mes = "绌鸿皟鍒跺喎锛屾俯搴︿负锛�" + (airTempState);
+
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+
+ break;
+ case AirCtrlParser.heatTem:
+ airTempState = curState[1] & 0xFF;
+ tv_tempet.setText("" + airTempState);
+ mes = "绌鸿皟鍒剁儹锛屽埗鐑俯搴︿负锛�" + (airTempState);
+
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+
+ break;
+ case AirCtrlParser.autoTem:
+ airTempState = curState[1] & 0xFF;
+
+ tv_tempet.setText(""+airTempState);
+ mes = "绌鸿皟鑷姩锛岃嚜鍔ㄦ俯搴︿负锛�" + (airTempState);
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+ break;
+ case AirCtrlParser.dehumTem:
+ airTempState = curState[1] & 0xFF;
+
+ tv_tempet.setText("" + airTempState);
+ mes = "绌鸿皟鎶芥箍锛屾娊婀挎俯搴︿负锛�" + (airTempState);
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+ break;
+ case AirCtrlParser.upTem:
+ airTempState = curState[1] & 0xFF;
+
+
+ tv_tempet.setText("" + airTempState);
+ mes = "绌鸿皟璋冩俯锛屼笂鍗囨俯搴︼細" + (airTempState);
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+ break;
+ case AirCtrlParser.downTem:
+ airTempState = curState[1] & 0xFF;
+ tv_tempet.setText("" + airTempState);
+ mes = "绌鸿皟璋冩俯锛屼笅闄嶆俯搴︼細" + (airTempState);
+ tv_mesSetText(mes);
+ HDLLog.Log(mes);
+ break;
+
+ }
+
+ }
+
+
+
+
+ /**
+ * TextView 鏄剧ず淇℃伅骞朵笖showToast鎻愮ず
+ *
+ * @param mes
+ */
+ private void tv_mesSetText(String mes) {
+ airText.setText(mes);
+ showToast(mes);
+ }
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlAirHVACActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlAirHVACActivity.java
new file mode 100644
index 0000000..046f9be
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlAirHVACActivity.java
@@ -0,0 +1,429 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig;
+import com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition.AirHVACBackInfo;
+import com.hdl.sdk.ttl.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.AirHVACFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DeviceStateEvent;
+import com.hdl.sdk.ttl_sdk.R;
+import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+import com.hdl.sdk.ttl_sdk.utlis.HDLLog;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+
+/**
+ * Created by JLChen on 2019/7/4
+ * 绌鸿皟绫绘ā鍧楁帶鍒堕〉闈�
+ * HVAC 绫诲瀷绌鸿皟妯″潡
+ * 16~30鎽勬皬搴�(鈩�)
+ */
+public class CtrlAirHVACActivity extends BaseActivity {
+ /**Topbar*/
+ private RelativeLayout topBarBack;
+ private TextView topBarTitle;
+
+ private Button airBtnSwitch, airBtnMode, airBtnTemp, airBtnSpeed;
+ private TextView airText;
+ private EditText airTempEd;
+ private AppliancesInfo appliancesInfo;
+
+
+ private int airSwitchState;//Demo浠呬互姝や綔涓烘紨绀猴紝瀹為檯璇锋牴鎹渶姹傚紑鍙戣璁�
+ private int airModeState;
+ private int airTempState;
+ private int airSpeedState;
+// /**
+// * true涓鸿缃憚姘忓害 false涓鸿缃崕姘忓害
+// * 鍙傛暟鑼冨洿 16~30鎽勬皬搴�(鈩�)
+// * ~86鍗庢皬搴�(鈩�)
+// */
+// private boolean bCelsius = true;
+
+ /**
+ * 澶嶅啓isRegisterEventBus() 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true
+ *
+ * @return true
+ */
+ @Override
+ protected boolean isRegisterEventBus() {
+ return true;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_ctrl_air_hvac);
+ initToolbar();
+ initView();
+ initOnClick();
+ initcurState();
+ showStateView();
+
+// if(appliancesInfo.getDeviceType() == HDLApConfig.TYPE_AC_HVAC) {
+// HDLCommand.getHVACDeviceStateFromNetwork(appliancesInfo);
+// }
+ HDLCommand.getHVACDeviceStateFromNetwork(appliancesInfo);
+ }
+
+
+
+ /**
+ * 鍒濆鍖朤oolbar
+ */
+ private void initToolbar() {
+ topBarBack = findViewById(R.id.ll_top_b_left);
+ setViewVisible(topBarBack);
+ topBarTitle = findViewById(R.id.tv_top_b_header_title);
+ topBarBack.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ });
+ }
+
+ private void initcurState() {
+ appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl");
+ String titleStr = appliancesInfo.getRemarks();
+ topBarTitle.setText(titleStr);
+ }
+
+
+
+ private void initView() {
+ airBtnSwitch = findViewById(R.id.airbtn_switch);
+ airBtnMode = findViewById(R.id.airbtn_mode);
+ airBtnSpeed = findViewById(R.id.airbtn_speed);
+ airBtnTemp = findViewById(R.id.airbtn_tempBtn);
+ airTempEd = findViewById(R.id.airet_tempet);
+ airText = findViewById(R.id.airText);
+
+ }
+
+ private void initOnClick() {
+ airBtnSwitch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ //婕旂ず褰撳墠鐘舵�佷负鍏筹紝璁剧疆涓哄紑銆傚紑锛岃缃负鍏炽��
+ if (airSwitchState == 0) {
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSwich, AirCtrlParser.airOn);//绌鸿皟寮�
+ } else {
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSwich, AirCtrlParser.airOff);//绌鸿皟鍏�
+ }
+ }
+ });
+
+
+ airBtnMode.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ switch (airModeState) {
+ case 0:
+ //鑻ュ綋鍓嶇┖璋冩ā寮忎负鍒跺喎锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓哄埗鐑�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeHeatTem);//绌鸿皟妯″紡鍒剁儹
+ break;
+ case 1:
+ //鑻ュ綋鍓嶇┖璋冩ā寮忎负鍒剁儹锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓洪�氶
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeVen);//绌鸿皟妯″紡閫氶
+ break;
+ case 2:
+ //鑻ュ綋鍓嶇┖璋冩ā寮忎负閫氶锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓鸿嚜鍔�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeAuto);//绌鸿皟妯″紡鑷姩
+ break;
+ case 3:
+ //鑻ュ綋鍓嶇┖璋冩ā寮忎负鑷姩锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓烘娊婀�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeDehum);//绌鸿皟妯″紡鎶芥箍
+ break;
+ case 4:
+ //鑻ュ綋鍓嶇┖璋冩ā寮忎负鎶芥箍锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓哄埗鍐�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeRefTem);//绌鸿皟妯″紡鍒跺喎
+ break;
+ default:
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeRefTem);//绌鸿皟妯″紡鍒跺喎
+ break;
+
+ }
+
+
+ }
+ });
+
+ airBtnSpeed.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ switch (airSpeedState) {
+ case 0:
+ //鑻ュ綋鍓嶇┖璋冮閫熶负鑷姩锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓洪珮椋�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedHigh);//椋庨�熼珮椋�
+ break;
+ case 1:
+ //鑻ュ綋鍓嶇┖璋冮閫熶负楂橀锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓轰腑椋�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedMid);//椋庨�熶腑椋�
+ break;
+ case 2:
+ //鑻ュ綋鍓嶇┖璋冮閫熶负涓锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓轰綆椋�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedLow);//椋庨�熶綆椋�
+ break;
+ case 3:
+ //鑻ュ綋鍓嶇┖璋冮閫熶负浣庨锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓鸿嚜鍔�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedAuto);//椋庨�熻嚜鍔�
+ break;
+
+
+ }
+ }
+ });
+
+ airBtnTemp.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ String tempStr = airTempEd.getText().toString();
+ if (TextUtils.isEmpty(tempStr)) {
+ showToast("璁剧疆鐨勬俯搴︿笉鑳戒负绌�");
+ return;
+ }
+ int tempInt = Integer.parseInt(tempStr);
+
+ if (tempInt < 16 || tempInt > 30) {
+ showToast("娓╁害璁剧疆鑼冨洿涓猴細16~30鎽勬皬搴�(鈩�)");
+ return;
+ }
+
+ switch (airModeState) {
+ case 0:
+ //褰撳墠绌鸿皟妯″紡涓哄埗鍐�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.refTem, tempInt);//鍒跺喎娓╁害
+ break;
+ case 1:
+ //褰撳墠绌鸿皟妯″紡涓哄埗鐑�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.heatTem, tempInt);//鍒剁儹娓╁害
+ break;
+ case 2:
+ //褰撳墠绌鸿皟妯″紡涓洪�氶
+ showToast("閫氶妯″紡涓嶈兘鎺у埗娓╁害");
+ break;
+ case 3:
+ //褰撳墠绌鸿皟妯″紡涓鸿嚜鍔�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.autoTem, tempInt);//鑷姩娓╁害 鑼冨洿16-30
+ break;
+ case 4:
+ //褰撳墠绌鸿皟妯″紡涓烘娊婀�
+ HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.dehumTem, tempInt);//鎶芥箍娓╁害 鑼冨洿16-30
+ break;
+ default:
+ break;
+
+ }
+
+// HDLCommand.airCtrl(appliancesInfo,AirCtrlParser.upTem,1);//涓婂崌娓╁害 鑼冨洿0-5
+// HDLCommand.airCtrl(appliancesInfo,AirCtrlParser.downTem,1);//涓嬮檷娓╁害 鑼冨洿0-5
+ }
+ });
+
+
+ }
+
+
+ private void showStateView() {
+ if (appliancesInfo.getArrCurState() != null) {
+ AirHVACBackInfo mAirHVACBackInfo = new AirHVACBackInfo(appliancesInfo);
+ String stringState = "";
+ if (mAirHVACBackInfo.getIsOn() == AirCtrlParser.airOff) {
+ stringState = "HVAC绌鸿皟妯″潡锛氬叧闂�";
+ } else if (mAirHVACBackInfo.getIsOn() == AirCtrlParser.airOn) {
+ stringState = "HVAC绌鸿皟妯″潡锛氭墦寮�";
+
+ stringState += "\n" + getModeStateString(mAirHVACBackInfo.getAirMode());//妯″紡
+ stringState += "\n" + getSpeedStateString(mAirHVACBackInfo.getAirSpeed());//椋庨��
+ stringState += "\n鍒跺喎妯″紡娓╁害锛�" + mAirHVACBackInfo.getRefTemp();
+ stringState += "\n鍒剁儹妯″紡娓╁害锛�" + mAirHVACBackInfo.getHeatTemp();
+ stringState += "\n鑷姩妯″紡娓╁害锛�" + mAirHVACBackInfo.getAutoTemp();
+ stringState += "\n鎶芥箍妯″紡娓╁害锛�" + mAirHVACBackInfo.getWettedTemp();
+ } else {
+ stringState = "鏈煡寮�鍏崇姸鎬�";
+ }
+ airText.setText(stringState);
+ } else {
+ airText.setText("鏈幏鍙栧埌HVAC绌鸿皟妯″潡鐘舵��");
+ }
+ }
+
+
+ /**
+ * getModeStateString
+ *
+ * @param mState
+ * @return
+ */
+ private String getModeStateString(int mState) {
+ String mStrState = "鏈煡";
+ airModeState = mState; //鏇存柊妯″紡鐘舵��
+ switch (mState) {
+ case AirCtrlParser.airModeRefTem:
+ mStrState = "妯″紡锛氬埗鍐�";
+ break;
+ case AirCtrlParser.airModeVen:
+ mStrState = "妯″紡锛氶�氶";
+ break;
+ case AirCtrlParser.airModeAuto:
+ mStrState = "妯″紡锛氳嚜鍔�";
+ break;
+ case AirCtrlParser.airModeDehum:
+ mStrState = "妯″紡锛氭娊婀�";
+ break;
+ default:
+ mStrState = "鏈煡妯″紡鐘舵��";
+ break;
+ }
+ return mStrState;
+ }
+
+ /**
+ * getSpeedStateString
+ *
+ * @param mState
+ * @return
+ */
+ private String getSpeedStateString(int mState) {
+ String mStrState = "鏈煡";
+ airSpeedState = mState; //鏇存柊褰撳墠椋庨�熺姸鎬�
+ switch (mState) {
+ case AirCtrlParser.airSpeedAuto:
+ mStrState = "椋庨�燂細鑷姩";
+ break;
+ case AirCtrlParser.airSpeedHigh:
+ mStrState = "椋庨�燂細楂�";
+ break;
+ case AirCtrlParser.airSpeedMid:
+ mStrState = "椋庨�燂細涓�";
+ break;
+ case AirCtrlParser.airSpeedLow:
+ mStrState = "椋庨�燂細浣�";
+ break;
+
+ default:
+ mStrState = "鏈煡椋庨�熺姸鎬�";
+ break;
+ }
+ return mStrState;
+ }
+
+
+ /**
+ * getSwichStateString
+ *
+ * @param mState
+ * @return
+ */
+ private String getSwichStateString(int mState) {
+ String mStrState = "鏈煡";
+ airSwitchState = mState; //鏇存柊寮�鍏崇姸鎬�
+ switch (mState) {
+ case AirCtrlParser.airOn:
+ mStrState = "HVAC绌鸿皟妯″潡锛氭墦寮�";
+ break;
+ case AirCtrlParser.airOff:
+ mStrState = "HVAC绌鸿皟妯″潡锛氬叧闂�";
+ break;
+
+ default:
+ mStrState = "鏈煡鐘舵��";
+ break;
+ }
+ return mStrState;
+ }
+
+
+ private void showAirHVACBackInfo(AirHVACBackInfo mAirHVACBackInfo){
+ String message = "";
+ if(mAirHVACBackInfo.getIsOn() == AirCtrlParser.airOn) {
+ message = getSwichStateString(mAirHVACBackInfo.getIsOn());
+ message += "\n" + getModeStateString(mAirHVACBackInfo.getAirMode());//妯″紡
+ message += "\n" + getSpeedStateString(mAirHVACBackInfo.getAirSpeed());//椋庨��
+ message += "\n鍒跺喎妯″紡娓╁害锛�" + mAirHVACBackInfo.getRefTemp();
+ message += "\n鍒剁儹妯″紡娓╁害锛�" + mAirHVACBackInfo.getHeatTemp();
+ message += "\n鑷姩妯″紡娓╁害锛�" + mAirHVACBackInfo.getAutoTemp();
+ message += "\n鎶芥箍妯″紡娓╁害锛�" + mAirHVACBackInfo.getWettedTemp();
+ }else {
+ message = getSwichStateString(mAirHVACBackInfo.getIsOn());
+ }
+ airText.setText(message);
+ showToast(message);
+ HDLLog.Log(message);
+
+ }
+
+
+
+
+ /**
+ * 绌鸿皟妯″潡鎺у埗鍥炶皟Event
+ *
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onAirHVACFeedBackEventMain(AirHVACFeedBackEvent event) {
+ if (event.getAirHVACBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ && event.getAirHVACBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getAirHVACBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum()
+ ) {
+ // 鍏堝垽鏂槸鍚﹁秴鏃�
+ if (!event.isSuccess()) {
+ showToast("绌鸿皟鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯");
+ return;
+ }
+ AirHVACBackInfo mAirHVACBackInfo = event.getAirHVACBackInfo();
+ showAirHVACBackInfo(mAirHVACBackInfo);
+
+ }
+ }
+
+ /**
+ * 鑾峰彇鍗曚竴璁惧鐘舵�佸洖璋僂vent
+ *
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onDeviceStateEventMain(DeviceStateEvent event) {
+ if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ ) {
+ //杩欎釜杩斿洖鐨勪俊鎭槸褰撳墠鐘舵�佺殑
+ switch (event.getAppliancesInfo().getDeviceType()) {
+ case HDLApConfig.TYPE_AC_HVAC:
+ if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) {
+ if (!event.isSuccess()) {
+ showToast("鑾峰彇绌鸿皟鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ AirHVACBackInfo mAirHVACBackInfo = new AirHVACBackInfo(event.getAppliancesInfo());
+ if (mAirHVACBackInfo == null) {
+ showToast("鑾峰彇绌鸿皟鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ showAirHVACBackInfo(mAirHVACBackInfo);
+ }
+ break;
+ default:
+ //涓嶅鐞�
+ break;
+ }
+ }
+ }
+
+
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlAudioActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlAudioActivity.java
new file mode 100644
index 0000000..4214ced
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlAudioActivity.java
@@ -0,0 +1,289 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.ListView;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.hdl.sdk.ttl.HDLAppliances.HDLAudio.HDLAudio;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.AudioInfoEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.BgmInfoEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.ThirdPartyBgmInfoEvent;
+import com.hdl.sdk.ttl_sdk.R;
+import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+import com.hdl.sdk.ttl_sdk.utlis.HDLLog;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CtrlAudioActivity extends BaseActivity {
+ private Button getCurSongInfoBtn, playPauseBtn, playStopBtn, preSongBtn, nextSongBtn, volMinBtn, volMidBtn, volMaxBtn, modeBtn, nextListBtn, preListBtn;
+ private AppliancesInfo appliancesInfo;
+ private List<String> listString = new ArrayList<>();
+ private ArrayAdapter<String> adapter;
+ private ListView listView;
+ private TextView curSongInfoTv, curSongNameTv;
+ private int curListNum;//鐢变簬涓嶅悓鍘傚晢闇�姹傦紝蹇呴』鑷璁板綍褰撳墠鐨勫垪琛ㄥ彿
+ private boolean isInit;//璁板綍鏄惁鍒濆鍖�
+ /**Topbar*/
+ private RelativeLayout topBarBack;
+ private TextView topBarTitle;
+
+ /**
+ * 澶嶅啓isRegisterEventBus() 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true
+ *
+ * @return true
+ */
+ @Override
+ protected boolean isRegisterEventBus() {
+ return true;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_audio);
+ initToolbar();
+ curSongNameTv = (TextView) findViewById(R.id.curSongName);
+ curSongInfoTv = (TextView) findViewById(R.id.curSongInfo);
+ getCurSongInfoBtn = (Button) findViewById(R.id.current);
+ playPauseBtn = (Button) findViewById(R.id.playpause);
+ playStopBtn = (Button) findViewById(R.id.playstop);
+ preSongBtn = (Button) findViewById(R.id.pre);
+ nextSongBtn = (Button) findViewById(R.id.next);
+ volMinBtn = (Button) findViewById(R.id.volmin);
+ volMidBtn = (Button) findViewById(R.id.volmid);
+ volMaxBtn = (Button) findViewById(R.id.volmax);
+ modeBtn = (Button) findViewById(R.id.audiomode);
+ nextListBtn = (Button) findViewById(R.id.nextlist);
+ preListBtn = (Button) findViewById(R.id.prelist);
+ listView = (ListView) findViewById(R.id.audiolist);
+ isInit = true;
+ listString.add("杩欎釜鍒楄〃鏄剧ず姝屾洸");
+ appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl");
+
+ String titleStr = appliancesInfo.getRemarks();
+ topBarTitle.setText(titleStr);
+
+ adapter = new ArrayAdapter<String>(CtrlAudioActivity.this, android.R.layout.simple_list_item_1, listString);
+ listView.setAdapter(adapter);
+ HDLCommand.audioCtrl(appliancesInfo, HDLAudio.GET_AUDIO_CURRRENT_INFO);//鑾峰彇褰撳墠闊充箰淇℃伅銆傝繑鍥炲綋鍓嶆瓕鏇层�佹墍鏈変俊鎭��
+ HDLCommand.audioCtrl(appliancesInfo, HDLAudio.GET_AUDIO_MODE);//鑾峰彇褰撳墠闊充箰鎾斁妯″紡銆備粎杩斿洖鍗曟洸鎾斁绛夋挱鏀炬ā寮忋��
+ listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
+ HDLCommand.audioCtrl(appliancesInfo, HDLAudio.SET_CHOOSE_PLAY_SONG, curListNum, position);
+ }
+ });
+
+ getCurSongInfoBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.audioCtrl(appliancesInfo, HDLAudio.GET_AUDIO_CURRRENT_INFO);
+ }
+ });
+
+ playPauseBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.audioCtrl(appliancesInfo, HDLAudio.SET_AUDIO_PLAYPAUSE);
+ }
+ });
+
+ playStopBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.audioCtrl(appliancesInfo, HDLAudio.SET_AUDIO_PLAYSTOP);
+ }
+ });
+
+ preSongBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.audioCtrl(appliancesInfo, HDLAudio.SET_PRE_SONG);
+ }
+ });
+
+ nextSongBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.audioCtrl(appliancesInfo, HDLAudio.SET_NEXT_SONG);
+ }
+ });
+
+ modeBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.audioCtrl(appliancesInfo, HDLAudio.SET_AUDIO_MODE_UP);//鎾斁妯″紡+
+// HDLCommand.HDLaudioCtrl(CtrlAudioActivity.this,appliancesInfo,HDLAudio.SET_AUDIO_MODE_DOWN);//鎾斁妯″紡-
+ }
+ });
+
+ volMinBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.audioCtrl(appliancesInfo, HDLAudio.SET_AUDIO_VOL, 0);//闊抽噺鏈�灏忥細0銆傚皬浜�0锛孲DK涓嶅鐞�
+ }
+ });
+
+ volMidBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.audioCtrl(appliancesInfo, HDLAudio.SET_AUDIO_VOL, 40);
+ }
+ });
+
+ volMaxBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.audioCtrl(appliancesInfo, HDLAudio.SET_AUDIO_VOL, 79);//闊抽噺鏈�澶э細79銆傝秴杩�79锛孲DK涓嶅鐞�
+ }
+ });
+
+ nextListBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.audioCtrl(appliancesInfo, HDLAudio.SET_NEXT_LIST);//鑾峰彇涓嬩竴鍒楄〃锛屽綋鍓嶉煶涔愪細鍋滄鎾斁
+ }
+ });
+
+ preListBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.audioCtrl(appliancesInfo, HDLAudio.SET_PRE_LIST);//鑾峰彇涓婁竴鍒楄〃锛屽綋鍓嶉煶涔愪細鍋滄鎾斁
+ }
+ });
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ }
+
+ /**
+ * 鍒濆鍖朤oolbar
+ */
+ private void initToolbar() {
+ topBarBack = findViewById(R.id.ll_top_b_left);
+ setViewVisible(topBarBack);
+ topBarTitle = findViewById(R.id.tv_top_b_header_title);
+ topBarBack.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ });
+ }
+
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onAudioEventMain(AudioInfoEvent event) {
+ //鍒ゆ柇鏄惁涓烘湰闊充箰妯″潡鐨勫瓙缃戝彿锛岃澶囧彿
+ if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ ) {
+ HDLLog.Log("onAudioEventMain: " + event.getType());
+ switch (event.getType()) {
+ case HDLAudio.CALLBACK_SONG_NAME_LIST:
+ listString.clear();
+ for (int i = 0; i < event.getSongNameList().size(); i++) {
+ listString.add(event.getSongNameList().get(i));
+ }
+ adapter.notifyDataSetChanged();
+ break;
+ case HDLAudio.CALLBACK_CURRENT_VOLUME:
+ HDLLog.Log("褰撳墠闊抽噺鍊硷細" + event.getAudioInfoInt());
+ break;
+ case HDLAudio.CALLBACK_AUDIO_LIST_NUM:
+ int[] listNum = event.getAudioListInfo();
+ curListNum = listNum[0];
+ HDLLog.Log("褰撳墠鍒楄〃鍙凤細" + listNum[0] + " 褰撳墠鍏辨湁鍒楄〃鏁帮細" + listNum[1]);
+ if (isInit) {
+ isInit = false;//姝ゆ搷浣滀负浠呭垵濮嬪寲鎵嶈姹傝幏鍙栧綋鍓嶉煶涔愬垪琛紝鍘傚晢鍙互鑷鍐冲畾浣曟椂鑾峰彇闊充箰鍒楄〃
+ HDLCommand.audioCtrl(appliancesInfo, HDLAudio.GET_AUDIO_LIST, curListNum);//鑾峰彇褰撳墠鎾斁鍒楄〃锛屾鏂规硶濡傛灉鍦ㄦ瓕鏇叉挱鏀剧姸鎬佹椂璋冪敤鍒欎細瀵艰嚧姝屾洸鍋滄鎾斁锛岀‖浠惰璁″姝�
+ }
+ break;
+ case HDLAudio.CALLBACK_CURRENT_LIST_NAME:
+ HDLLog.Log("褰撳墠鍒楄〃鍚嶏細" + event.getAudioInfoStr());
+ break;
+ case HDLAudio.CALLBACK_CURRENT_SONG_NUM:
+ int[] songNum = event.getAudioListInfo();
+ HDLLog.Log("褰撳墠姝屾洸鍙凤細" + songNum[0] + " 褰撳墠鍏辨湁姝屾洸鏁帮細" + songNum[1]);
+ break;
+ case HDLAudio.CALLBACK_CURRENT_SONG_NAME:
+ HDLLog.Log("褰撳墠姝屾洸鍚嶏細" + event.getAudioInfoStr());
+ curSongNameTv.setText("褰撳墠姝屾洸鍚嶏細" + event.getAudioInfoStr());
+ break;
+ case HDLAudio.CALLBACK_CURRENT_SONG_INFO:
+ int[] songInfo = event.getAudioListInfo();
+ //songInfo[0],songInfo[1]鑾峰緱鐨勫�间负绉掞紝濡俿ongInfo[0]=250锛屽嵆姝屾洸鎬绘椂闀夸负250绉掋�俿ongInfo[2]鑾峰緱鐨勫�间负锛�1銆�2銆�3銆�1锛氬仠姝紝2锛氭挱鏀撅紝3锛氭殏鍋溿��
+ String curStatus;
+ switch (songInfo[2]) {
+ case 1:
+ curStatus = "鍋滄";
+ break;
+ case 2:
+ curStatus = "鎾斁";
+ break;
+ case 3:
+ curStatus = "鏆傚仠";
+ break;
+ default:
+ curStatus = "鏈煡";
+ break;
+ }
+ HDLLog.Log("褰撳墠姝屾洸鎬绘椂闀匡細" + songInfo[0] + "绉� 锛屽綋鍓嶆瓕鏇插凡鎾斁鏃堕暱锛�" + songInfo[1] + "绉掞紝 褰撳墠姝屾洸鐘舵�侊細" + curStatus);
+ curSongInfoTv.setText("褰撳墠姝屾洸鎬绘椂闀匡細" + songInfo[0] + "绉� 锛屽綋鍓嶆瓕鏇插凡鎾斁鏃堕暱锛�" + songInfo[1] + "绉掞紝 褰撳墠姝屾洸鐘舵�侊細" + curStatus);
+ break;
+ case HDLAudio.CALLBACK_CURRENT_MODE:
+ String curMode;
+ switch (event.getAudioInfoInt()) {
+ case 1:
+ curMode = "鍗曟洸鎾斁";
+ break;
+ case 2:
+ curMode = "鍗曟洸寰幆";
+ break;
+ case 3:
+ curMode = "杩炵画鎾斁";
+ break;
+ case 4:
+ curMode = "杩炴挱寰幆";
+ break;
+ default:
+ curMode = "鏈煡";
+ break;
+
+ }
+ modeBtn.setText(curMode);
+ break;
+ default:
+ break;
+ }
+ }
+
+
+ }
+
+
+// @Subscribe(threadMode = ThreadMode.MAIN)
+// public void onBgmInfoEventMain(BgmInfoEvent event) {
+// int eventType = event.getType();
+// }
+//
+//
+// @Subscribe(threadMode = ThreadMode.MAIN)
+// public void onBgmInfoEventMain(ThirdPartyBgmInfoEvent event) {
+// byte[] eventType = event.getBytes();
+// }
+}
+
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlCommonSwitchActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlCommonSwitchActivity.java
new file mode 100644
index 0000000..4eb85ca
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlCommonSwitchActivity.java
@@ -0,0 +1,182 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.CommonSwitchCtrlBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.CommonSwitchStateBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent;
+import com.hdl.sdk.ttl_sdk.R;
+import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+/**
+ * 閫氱敤寮�鍏宠澶囨紨绀�
+ */
+public class CtrlCommonSwitchActivity extends BaseActivity {
+
+ /**Topbar*/
+ private RelativeLayout topBarBack;
+ private TextView topBarTitle;
+ private Button btnOpen,btnClose;
+ private TextView switchText;
+ private AppliancesInfo appliancesInfo;
+ private int switchState = 0;
+
+
+ /**
+ * 澶嶅啓isRegisterEventBus() 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true
+ *
+ * @return true
+ */
+ @Override
+ protected boolean isRegisterEventBus() {
+ return true;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_ctrl_logic);
+ initToolbar();
+ initcurState();
+ initView();
+ initOnClick();
+ displayStateView();
+
+ //浠庣綉缁滀笂鏌ヨ鍒锋柊涓�娆¤澶囩姸鎬侊紝寰呰皟璇�
+ HDLCommand.getCommonSwitchStateFromNetwork(appliancesInfo);
+ }
+
+ /**
+ * 鍒濆鍖朤oolbar
+ */
+ private void initToolbar() {
+ topBarBack = findViewById(R.id.ll_top_b_left);
+ setViewVisible(topBarBack);
+ topBarTitle = findViewById(R.id.tv_top_b_header_title);
+ topBarBack.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ });
+ }
+
+ private void initcurState() {
+ appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl");
+ String titleStr = appliancesInfo.getRemarks();
+ topBarTitle.setText(titleStr);
+
+ }
+
+ private void initView() {
+ btnOpen = findViewById(R.id.btnOpen);
+
+ btnClose = findViewById(R.id.btnClose);
+ switchText = findViewById(R.id.switchText);
+
+
+
+
+
+ }
+
+ private void initOnClick() {
+
+ btnOpen.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ //0=鍏� 255=寮�
+ HDLCommand.commonSwitchCtrl(appliancesInfo, 255);
+ }
+ });
+
+ btnClose.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.commonSwitchCtrl(appliancesInfo,0);
+ }
+ });
+ }
+
+ private void displayStateView(){
+
+ switch (appliancesInfo.getDeviceType()) {
+ case HDLApConfig.TYPE_COMMON_SWITCH:
+ break;
+ default:
+ finish();//璁惧绫诲瀷涓嶅缁撴潫椤甸潰
+ break;
+ }
+ /**鏍规嵁闇�姹傛槸鍚﹀彂閫佷竴娆¤幏鍙栧埛鏂扮姸鎬佽姹�*/
+
+ }
+
+
+ /**
+ * 閫昏緫妯″潡鎺у埗鍥炶皟Event
+ *
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onCommonSwitchCtrlEventMain(CommonSwitchCtrlBackEvent event) {
+ if (event.getCommonSwitchBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ && event.getCommonSwitchBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getCommonSwitchBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum()
+ ) {
+ if (!event.isSuccess()) {
+ showToast("閫氱敤寮�鍏虫帶鍒惰秴鏃讹紝璇烽噸鏂板啀璇�");
+ return;
+ }
+
+ showToast("閫氱敤寮�鍏虫帶鍒舵垚鍔�");
+
+ switchState = event.getCommonSwitchBackInfo().getSwitchState();
+ if(switchState>0){
+ switchText.setText("褰撳墠鐘舵�侊細寮�");
+ }else{
+ switchText.setText("褰撳墠鐘舵�侊細鍏�");
+ }
+ }
+
+ }
+
+ /**
+ * 閫昏緫妯″潡鎺у埗鍥炶皟Event
+ *
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onCommonSwitchStateEventMain(CommonSwitchStateBackEvent event) {
+ if (event.getCommonSwitchBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ && event.getCommonSwitchBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getCommonSwitchBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum()
+ ) {
+ if (!event.isSuccess()) {
+ showToast("閫氱敤寮�鍏宠鍙栫姸鎬佽秴鏃讹紝璇烽噸鏂板啀璇�");
+ return;
+ }
+
+// showToast("閫氱敤寮�鍏虫帶鍒舵垚鍔�");
+
+ switchState = event.getCommonSwitchBackInfo().getSwitchState();
+ if(switchState>0){
+ switchText.setText("褰撳墠鐘舵�侊細寮�");
+ }else{
+ switchText.setText("褰撳墠鐘舵�侊細鍏�");
+ }
+ }
+
+ }
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlCurtainActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlCurtainActivity.java
new file mode 100644
index 0000000..f5f33a5
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlCurtainActivity.java
@@ -0,0 +1,325 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig;
+import com.hdl.sdk.ttl.HDLAppliances.HDLCurtain.Parser.CurtainCtrlParser;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.CurtainFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DeviceStateEvent;
+import com.hdl.sdk.ttl_sdk.R;
+import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+import com.hdl.sdk.ttl_sdk.utlis.HDLLog;
+import com.hdl.sdk.ttl_sdk.utlis.HDLUtlis;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.math.BigDecimal;
+
+/**
+ * Created by JLChen on 2019/7/4
+ * 绐楀笜绫绘ā鍧楁帶鍒堕〉闈�
+ */
+public class CtrlCurtainActivity extends BaseActivity {
+ /**Topbar*/
+ private RelativeLayout topBarBack;
+ private TextView topBarTitle;
+ private Button curtainBtn, curtainBtn2, curtainBtn3, curtainBtn4, curtainBtn5;
+ private TextView curText1, curText2;
+ private AppliancesInfo appliancesInfo;
+ private int curtainState;
+ private String showMessage;
+
+ /**
+ * 澶嶅啓isRegisterEventBus() 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true
+ *
+ * @return true
+ */
+ @Override
+ protected boolean isRegisterEventBus() {
+ return true;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_ctrl_curtain);
+ initToolbar();
+ initView();
+ initOnClick();
+ initcurState();
+ displayStateView();
+ HDLCommand.getCurtainDeviceStateFromNetwork(appliancesInfo);
+ }
+
+ /**
+ * 鍒濆鍖朤oolbar
+ */
+ private void initToolbar() {
+ topBarBack = findViewById(R.id.ll_top_b_left);
+ setViewVisible(topBarBack);
+ topBarTitle = findViewById(R.id.tv_top_b_header_title);
+ topBarBack.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ });
+ }
+
+ private void initcurState() {
+ appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl");
+ String titleStr = appliancesInfo.getRemarks();
+ topBarTitle.setText(titleStr);
+ }
+
+ private void initView() {
+ curtainBtn = findViewById(R.id.curtainbtn);
+ curtainBtn2 = findViewById(R.id.curtainbtn2);
+ curtainBtn3 = findViewById(R.id.curtainbtn3);
+ curtainBtn4 = findViewById(R.id.curtainbtn4);
+ curtainBtn5 = findViewById(R.id.curtainbtn5);
+ curText1 = findViewById(R.id.curtainText1);
+ curText2 = findViewById(R.id.curtainText2);
+ }
+
+ private void initOnClick() {
+ curtainBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ //绐楀笜妯″潡绗簩涓弬鏁� 涓篊urtainCtrlParser.curtainOn锛孋urtainCtrlParser.curtainOff锛孋urtainCtrlParser.curtainPause鍏朵腑涓�涓�
+ if (curtainState == CurtainCtrlParser.curtainOn) {
+ curtainState = CurtainCtrlParser.curtainOff;
+ } else {
+ curtainState = CurtainCtrlParser.curtainOn;
+ }
+ HDLCommand.curtainCtrl(appliancesInfo, curtainState);
+
+ }
+ });
+
+ curtainBtn2.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.curtainCtrl(appliancesInfo, CurtainCtrlParser.curtainOn);
+ }
+ });
+
+ curtainBtn3.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.curtainCtrl(appliancesInfo, CurtainCtrlParser.curtainOff);
+ }
+ });
+
+ curtainBtn4.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.curtainCtrl(appliancesInfo, CurtainCtrlParser.curtainPause);
+ }
+ });
+
+ curtainBtn5.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.curtainCtrl(appliancesInfo, 50);
+ }
+ });
+ }
+
+ private void displayStateView() {
+ if (appliancesInfo.getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) {
+ //绐楀笜妯″潡
+ curText2.setVisibility(View.GONE);
+ curtainBtn2.setVisibility(View.GONE);
+ curtainBtn3.setVisibility(View.GONE);
+ curtainBtn4.setVisibility(View.GONE);
+ curtainBtn5.setVisibility(View.GONE);
+
+ if (appliancesInfo.getCurState() != null) {
+ String stringCurtainState = "";
+ /**娉ㄦ剰绫诲瀷 curState淇濆瓨鏈湴鍐嶈幏鍙栧悗鍚庡彉锛屾垚Double绫诲瀷浜�*/
+ int curCurtainState = HDLUtlis.getIntegerByObject(appliancesInfo.getCurState());
+
+ HDLLog.Log("curCurtainState = " + curCurtainState);
+ switch (curCurtainState) {
+ case CurtainCtrlParser.TYPE_STATE_PAUSE:
+ stringCurtainState += "绐楀笜妯″潡鍋滄鐘舵��";
+ curtainState = CurtainCtrlParser.curtainOn;//鍒濆鍖栫獥甯樻帶鍒剁姸鎬�
+ break;
+ case CurtainCtrlParser.TYPE_STATE_OPEN:
+ stringCurtainState += "绐楀笜妯″潡寮�鐘舵��";
+ curtainState = CurtainCtrlParser.curtainOff;//鍒濆鍖栫獥甯樻帶鍒剁姸鎬�
+ break;
+ case CurtainCtrlParser.TYPE_STATE_CLOSE:
+ stringCurtainState += "绐楀笜妯″潡鍏崇姸鎬�";
+ curtainState = CurtainCtrlParser.curtainOn;//鍒濆鍖栫獥甯樻帶鍒剁姸鎬�
+ break;
+ default:
+ stringCurtainState = "鏈幏鍙栧埌绐楀笜妯″潡鐘舵��";
+ curtainState = CurtainCtrlParser.curtainOff;//鍒濆鍖栫獥甯樻帶鍒剁姸鎬�
+ break;
+ }
+ curText1.setText(stringCurtainState);
+ curtainBtn.setText(stringCurtainState);
+ } else {
+ curText1.setText("鏈幏鍙栧埌绐楀笜妯″潡鐘舵��");
+ curtainBtn.setText("鏈幏鍙栧埌绐楀笜妯″潡鐘舵��");
+ }
+
+ } else if (appliancesInfo.getDeviceType() == HDLApConfig.TYPE_CURTAIN_ROLLER
+ || appliancesInfo.getDeviceType() == HDLApConfig.TYPE_CURTAIN_GLYSTRO) {
+ //寮�鍚堝笜銆佸嵎甯�
+ curText1.setVisibility(View.GONE);
+ curtainBtn.setVisibility(View.GONE);
+ if (appliancesInfo.getCurState() != null) {
+ curText2.setText("褰撳墠绐楀笜鐘舵�侊細" + HDLUtlis.getIntegerByObject(appliancesInfo.getCurState()));
+ } else {
+ curText2.setText("鏈幏鍙栧埌绐楀笜妯″潡鐘舵��");
+ }
+ } else {
+ //璁惧绫诲瀷涓嶅缁撴潫椤甸潰
+ finish();
+ }
+
+ /**鏍规嵁闇�姹傛槸鍚﹀彂閫佷竴娆¤幏鍙栧埛鏂扮姸鎬佽姹�*/
+
+ }
+
+
+ /**
+ * 绐楀笜妯″潡鎺у埗鍥炶皟Event
+ *
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onCurtainFeedBackInfoEventMain(CurtainFeedBackEvent event) {
+// 鍏堝垽鏂槸鍚﹁秴鏃�
+ HDLLog.Log("onCurtainFeedBackInfoEventMain in");
+ if (event.getCurtainCtrlBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getCurtainCtrlBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ && event.getCurtainCtrlBackInfo().getNum() == appliancesInfo.getChannelNum()
+ ) {
+
+ if (!event.isSuccess()) {
+ showToast("绐楀笜鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯");
+ return;
+ }
+
+ int curState = event.getCurtainCtrlBackInfo().getState();
+ //绐楀笜妯″潡锛歝urState:0=鍋滄,1=鎵撳紑,2=鍏抽棴銆�
+ //寮�鍚堝笜鐢垫満锛屽嵎甯樼數鏈猴細curState:1-100寮�鍚堝害銆備篃浼氳繑鍥�0锛�1锛�2鐨勭姸鎬�
+ //寤鸿寮�鍚堝笜鐢垫満锛屽嵎甯樼數鏈烘寜鍋滄鍚庡啀璇诲彇褰撳墠鐘舵�佹潵鑾峰彇褰撳墠鐘舵�佸��
+
+ String remarks = event.getCurtainCtrlBackInfo().getRemarks();
+ String parentRemarks = event.getCurtainCtrlBackInfo().getParentRemarks();
+ int num = event.getCurtainCtrlBackInfo().getNum();
+// showToast(parentRemarks+" 鐨� "+remarks+" 鍥炶矾鍙凤細"+num+" 杩斿洖"+" 鐘舵�佷负锛�"+curState);
+ HDLLog.Log(parentRemarks + " 鐨� " + remarks + " 鍥炶矾鍙凤細" + num + " 杩斿洖" + " 鐘舵�佷负锛�" + curState);
+ if (event.getCurtainCtrlBackInfo().getAppliancesInfo().getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) {
+ showMessage = "";
+ //鍒ゆ柇鏄惁涓虹獥甯樻ā鍧�
+ switch (curState) {
+ case CurtainCtrlParser.curtainOff:
+ showMessage = "绐楀笜鍏�";
+ curtainBtn.setText(showMessage);
+ curText1.setText(showMessage);
+ curtainState = curState;
+ HDLLog.Log("绐楀笜鎺у埗 锛氱獥甯樺叧" + " 鍥炶矾鍙凤細" + num);
+ break;
+ case CurtainCtrlParser.curtainOn:
+ showMessage = "绐楀笜寮�";
+ curtainBtn.setText(showMessage);
+ curText1.setText(showMessage);
+ curtainState = curState;
+ HDLLog.Log("绐楀笜鎺у埗 锛氱獥甯樺紑" + " 鍥炶矾鍙凤細" + num);
+ break;
+ case CurtainCtrlParser.curtainPause:
+ showMessage = "绐楀笜鏆傚仠";
+ curtainBtn.setText(showMessage);
+ curText1.setText(showMessage);
+ curtainState = curState;
+ HDLLog.Log("绐楀笜鎺у埗 锛氱獥甯樻殏鍋�" + " 鍥炶矾鍙凤細" + num);
+ break;
+ }
+ showToast(showMessage);
+ } else {
+ //寮�鍚堝笜鎴栧嵎甯� 鏄剧ず鐧惧垎姣�
+// curtainBtn5.setText("绐楀笜寮�鍒�" + curState + "%");
+ curText2.setText("绐楀笜寮�鍒�" + curState + "%");
+ curtainState = curState;
+ }
+
+ }
+
+ }
+
+ /**
+ * 鑾峰彇鍗曚竴璁惧鐘舵�佸洖璋僂vent
+ *
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onDeviceStateEventMain(DeviceStateEvent event) {
+ if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ ) {
+ //杩欎釜杩斿洖鐨勪俊鎭槸褰撳墠鐘舵�佺殑
+ switch (event.getAppliancesInfo().getDeviceType()) {
+ case HDLApConfig.TYPE_CURTAIN_GLYSTRO:
+ case HDLApConfig.TYPE_CURTAIN_ROLLER:
+ case HDLApConfig.TYPE_CURTAIN_MODULE:
+ if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) {
+ if (!event.isSuccess()) {
+ showToast("鑾峰彇绐楀笜鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ showMessage = "";
+ //绐楀笜妯″潡锛歝urState:0=鍋滄,1=鎵撳紑,2=鍏抽棴銆�
+ //寮�鍚堝笜鐢垫満锛屽嵎甯樼數鏈猴細curState:1-100寮�鍚堝害銆�
+ int curState = HDLUtlis.getIntegerByObject(event.getAppliancesInfo().getCurState());
+ if (event.getAppliancesInfo().getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) {//鍒ゆ柇鏄惁涓虹獥甯樻ā鍧�,鍚﹀垯涓哄紑鍚堝笜鎴栧嵎甯樼數鏈�
+ switch (curState) {
+ case CurtainCtrlParser.curtainOff:
+ showMessage = "绐楀笜鍏�";
+ curtainBtn.setText(showMessage);
+ curText1.setText(showMessage);
+ curtainState = curState;
+ break;
+ case CurtainCtrlParser.curtainOn:
+ showMessage = "绐楀笜寮�";
+ curtainBtn.setText(showMessage);
+ curText1.setText(showMessage);
+ curtainState = curState;
+ break;
+ case CurtainCtrlParser.curtainPause:
+ showMessage = "绐楀笜鏆傚仠";
+ curtainBtn.setText(showMessage);
+ curText1.setText(showMessage);
+ curtainState = curState;
+ break;
+ }
+ } else {
+ showMessage = "绐楀笜寮�鍒�" + curState + "%";
+// curtainBtn5.setText(showMessage);
+ curtainState = curState;
+ }
+
+ showToast("鑾峰彇鎴愬姛锛�" + showMessage);
+ }
+ break;
+ default:
+ //涓嶅鐞�
+ break;
+ }
+ }
+ }
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlLightActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlLightActivity.java
new file mode 100644
index 0000000..dc273ad
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlLightActivity.java
@@ -0,0 +1,197 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DeviceStateEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.LightFeedBackEvent;
+import com.hdl.sdk.ttl_sdk.R;
+import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+import com.hdl.sdk.ttl_sdk.utlis.HDLLog;
+import com.hdl.sdk.ttl_sdk.utlis.HDLUtlis;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+/**
+ * Created by JLChen on 2019/7/4
+ * 璋冨厜妯″潡锛岀户鐢靛櫒妯″潡鎺у埗椤甸潰
+ */
+public class CtrlLightActivity extends BaseActivity {
+ /**Topbar*/
+ private RelativeLayout topBarBack;
+ private TextView topBarTitle;
+ private Button lightBtn;
+ private TextView lightText;
+ private AppliancesInfo appliancesInfo;
+ private int lightState;
+
+ /**
+ * 澶嶅啓isRegisterEventBus() 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true
+ *
+ * @return true
+ */
+ @Override
+ protected boolean isRegisterEventBus() {
+ return true;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_ctrl_light);
+ initToolbar();
+ initView();
+ initOnClick();
+ initcurState();
+ displayStateView();
+
+// //浠嶴DK鏈湴鑾峰彇
+// HDLCommand.getDeviceStateFromLocal(appliancesInfo);
+ //浠庣綉缁滀笂鏌ヨ鍒锋柊涓�娆¤澶囩姸鎬侊紝寰呰皟璇�
+ HDLCommand.getLightDeviceStateFromNetwork(appliancesInfo);
+ }
+
+ /**
+ * 鍒濆鍖朤oolbar
+ */
+ private void initToolbar() {
+ topBarBack = findViewById(R.id.ll_top_b_left);
+ setViewVisible(topBarBack);
+ topBarTitle = findViewById(R.id.tv_top_b_header_title);
+ topBarBack.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ });
+ }
+
+ private void initcurState() {
+ appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl");
+ String titleStr = appliancesInfo.getRemarks();
+ topBarTitle.setText(titleStr);
+ }
+
+ private void initView() {
+ lightBtn = findViewById(R.id.ctrlbtn);
+ lightText = findViewById(R.id.lightText);
+
+ }
+
+ private void initOnClick() {
+
+ lightBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ HDLCommand.lightCtrl(appliancesInfo, lightState);
+ HDLLog.Log("lightBtn: 璁剧疆浜害" + lightState);
+// HDLCommand.lightCtrl(appliancesInfo,50);
+ }
+ });
+ }
+
+ private void displayStateView() {
+ switch (appliancesInfo.getDeviceType()) {
+ case HDLApConfig.TYPE_LIGHT_DIMMER:
+ case HDLApConfig.TYPE_LIGHT_RELAY:
+ case HDLApConfig.TYPE_LIGHT_MIX_DIMMER:
+ case HDLApConfig.TYPE_LIGHT_MIX_RELAY:
+ if (appliancesInfo.getCurState() != null) {
+ int curLightState = HDLUtlis.getIntegerByObject(appliancesInfo.getCurState());
+
+ lightText.setText("褰撳墠鐏厜浜害锛�" + curLightState);
+ lightBtn.setText("褰撳墠鐏厜浜害锛�" + curLightState);
+ if (curLightState == 100) {
+ lightState = 0;
+ } else {
+ lightState = 100;
+ }
+ } else {
+ lightText.setText("鏈幏鍙栧埌鐏厜浜害");
+ lightBtn.setText("鏈幏鍙栧埌鐏厜浜害");
+ }
+ break;
+
+ default:
+ finish();//璁惧绫诲瀷涓嶅缁撴潫椤甸潰
+ break;
+ }
+ /**鏍规嵁闇�姹傛槸鍚﹀彂閫佷竴娆¤幏鍙栧埛鏂扮姸鎬佽姹�*/
+ }
+
+ /**
+ * 鐏厜鎺у埗鍥炶皟Event
+ *
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onLightFeedBackInfoEventMain(LightFeedBackEvent event) {
+
+ if (event.getLightCtrlBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ && event.getLightCtrlBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getLightCtrlBackInfo().getChannelNum() == appliancesInfo.getChannelNum()
+ && event.getLightCtrlBackInfo().getPhysicsChannelNum() == appliancesInfo.getPhysicsChannelNum()
+
+ ) {
+ // 鍏堝垽鏂槸鍚﹁秴鏃�
+ if (!event.isSuccess()) {
+ showToast("鐏厜鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯");
+ lightBtn.setText("鐏厜鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯");
+ return;
+ }
+ int brightness = event.getLightCtrlBackInfo().getBrightness();
+ lightState = brightness == 100 ? 0 : 100;//濡傛灉杩斿洖100閲嶇疆鐘舵�佷负0锛屽弽涔嬮噸缃姸鎬�100
+ lightBtn.setText("褰撳墠浜害 = " + brightness);
+ lightText.setText("褰撳墠浜害 = " + brightness);
+ /*浠ヤ笅涓虹伅鍏夋帹閫佺ず渚嬩唬鐮侊紝鍙互璇嗗埆鍝釜缁х數鍣紝鍝釜璋冨厜鐏紝鍝釜鍥炶矾锛屼篃鍙敤浣滄帶鍒跺洖棣堛��
+ 鎸夐渶姹傝皟鐢�*/
+ String remarks = event.getLightCtrlBackInfo().getRemarks();//鑾峰彇杩斿洖鐨勭伅鍏夊娉ㄣ�傚鏋滄瘡涓伅鍏夊洖璺娉ㄩ兘鍞竴锛屽彲浠ョ洿鎺ラ�氳繃澶囨敞鍒ゆ柇
+ String parentRemarks = event.getLightCtrlBackInfo().getParentRemarks();//鑾峰彇缁х數鍣ㄦ垨璋冨厜鐏娉ㄣ�傝繖閲屽彲浠ョ煡閬撴槸鍝釜璁惧杩斿洖鐨�
+ int num = event.getLightCtrlBackInfo().getChannelNum();//鑾峰彇鍥炶矾鍙枫�傝繖閲屽彲浠ヨ幏鍙栧埌杩欎釜缁х數鍣ㄦ垨璋冨厜鐏殑鍥炶矾鍙�
+ showToast("妯″潡锛�" + parentRemarks + " 鐨� " + remarks + " 鍥炶矾锛屽洖璺彿涓猴細" + num + " 杩斿洖" + " 浜害涓猴細" + brightness);
+ HDLLog.Log("褰撳墠浜害 = " + brightness);
+ }
+ }
+
+ /**
+ * 鑾峰彇鍗曚竴璁惧鐘舵�佸洖璋僂vent
+ *
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onDeviceStateEventMain(DeviceStateEvent event) {
+ if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ ) {
+ //杩欎釜杩斿洖鐨勪俊鎭槸褰撳墠鐘舵�佺殑
+ switch (event.getAppliancesInfo().getDeviceType()) {
+ case HDLApConfig.TYPE_LIGHT_DIMMER:
+ case HDLApConfig.TYPE_LIGHT_RELAY:
+ case HDLApConfig.TYPE_LIGHT_MIX_DIMMER:
+ case HDLApConfig.TYPE_LIGHT_MIX_RELAY:
+ if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) {
+ if (!event.isSuccess()) {
+ showToast("鑾峰彇鐏厜鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ int brightness = HDLUtlis.getIntegerByObject(event.getAppliancesInfo().getCurState());
+ lightBtn.setText("浜害 = " + brightness);
+ lightText.setText("褰撳墠浜害 = " + brightness);
+ showToast("鑾峰彇鐘舵�佽繑鍥烇細浜害 = " + brightness);
+ }
+ break;
+ default:
+ //涓嶅鐞�
+ break;
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlLogicActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlLogicActivity.java
new file mode 100644
index 0000000..f41bdb1
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlLogicActivity.java
@@ -0,0 +1,129 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent;
+import com.hdl.sdk.ttl_sdk.R;
+import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+/**
+ * Created by JLChen on 2019/7/4
+ * 閫昏緫绫绘ā鍧楁帶鍒堕〉闈�
+ */
+public class CtrlLogicActivity extends BaseActivity {
+ /**Topbar*/
+ private RelativeLayout topBarBack;
+ private TextView topBarTitle;
+ private Button logicBtn;
+ private TextView logicText;
+ private AppliancesInfo appliancesInfo;
+
+
+ /**
+ * 澶嶅啓isRegisterEventBus() 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true
+ *
+ * @return true
+ */
+ @Override
+ protected boolean isRegisterEventBus() {
+ return true;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_ctrl_logic);
+ initToolbar();
+ initcurState();
+ initView();
+ initOnClick();
+ displayStateView();
+ }
+
+ /**
+ * 鍒濆鍖朤oolbar
+ */
+ private void initToolbar() {
+ topBarBack = findViewById(R.id.ll_top_b_left);
+ setViewVisible(topBarBack);
+ topBarTitle = findViewById(R.id.tv_top_b_header_title);
+ topBarBack.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ });
+ }
+
+ private void initcurState() {
+ appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl");
+ String titleStr = appliancesInfo.getRemarks();
+ topBarTitle.setText(titleStr);
+
+ }
+
+ private void initView() {
+ logicBtn = findViewById(R.id.logicbtn);
+ logicText = findViewById(R.id.logicText);
+
+
+
+ }
+
+ private void initOnClick() {
+
+ logicBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.logicCtrl(appliancesInfo);
+ }
+ });
+ }
+
+ private void displayStateView(){
+
+ switch (appliancesInfo.getDeviceType()) {
+ case HDLApConfig.TYPE_LOGIC_MODULE:
+ case HDLApConfig.TYPE_GLOBAL_LOGIC_MODULE:
+ break;
+ default:
+ finish();//璁惧绫诲瀷涓嶅缁撴潫椤甸潰
+ break;
+ }
+ /**鏍规嵁闇�姹傛槸鍚﹀彂閫佷竴娆¤幏鍙栧埛鏂扮姸鎬佽姹�*/
+ }
+
+ /**
+ * 閫昏緫妯″潡鎺у埗鍥炶皟Event
+ *
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onLogicFeedBackInfoEventMain(LogicFeedBackEvent event) {
+// 鍏堝垽鏂槸鍚﹁秴鏃�
+ if (event.getLogicCtrlBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ && event.getLogicCtrlBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getLogicCtrlBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum()
+ ) {
+ if (!event.isSuccess()) {
+ showToast("鍦烘櫙鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯");
+ return;
+ }
+
+
+
+ showToast("鍦烘櫙鎺у埗鎴愬姛");
+ }
+ }
+
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlSecurityActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlSecurityActivity.java
new file mode 100644
index 0000000..6e47fae
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/CtrlSecurityActivity.java
@@ -0,0 +1,318 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.RelativeLayout;
+import android.widget.Spinner;
+import android.widget.TextView;
+
+import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig;
+import com.hdl.sdk.ttl.HDLAppliances.HDLSecurity.Parser.SecurityParser;
+import com.hdl.sdk.ttl.HDLAppliances.HDLSecurity.SecurityArmingStateBackInfo;
+import com.hdl.sdk.ttl.HDLAppliances.HDLSecurity.SecurityBackInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.SecurityStateBean;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DeviceStateEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.SecurityAlarmFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.SecurityArmingFeedBackEvent;
+import com.hdl.sdk.ttl_sdk.R;
+import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+import com.hdl.sdk.ttl_sdk.utlis.HDLLog;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+/**
+ * 瀹夐槻妯″潡鎺у埗椤甸潰
+ */
+public class CtrlSecurityActivity extends BaseActivity {
+ /**
+ * Topbar
+ */
+ private RelativeLayout topBarBack;
+ private TextView topBarTitle;
+ private AppliancesInfo appliancesInfo;
+ private Button btn_read_config, btn_set_arming, btn_send_alarm;
+ private Spinner spinner_arming;
+ // private TextView tv_alarmFire, tv_alarmGas, tv_alarmSudden, tv_alarmEmergency, tv_alarmCurrent, tv_alarmSilent, tv_alarmPower, tv_alarmTemperature;
+ private TextView tv_mes;
+ private static final String[] armingTypeItems = {"鍋囨湡甯冮槻", "绂诲紑甯冮槻", "澶滈棿甯冮槻", "鏅氫笂鏈夊甯冮槻", "鐧藉ぉ甯冮槻", "鎾ら槻"};
+ private int armingState;//甯冮槻鐘舵�� 6 = 鎾ら槻 5 = 鐧藉ぉ甯冮槻 4 = 鏅氫笂鏈夊甯冮槻 3 = 澶滈棿甯冮槻 2 = 绂诲紑甯冮槻 1 = 鍋囨湡甯冮槻
+ private SecurityStateBean mSecurityStateBean;
+
+ private int alarmSendState;//鍙戦�佹祴璇曟姤璀�
+
+ /**
+ * 澶嶅啓isRegisterEventBus() 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true
+ *
+ * @return true
+ */
+ @Override
+ protected boolean isRegisterEventBus() {
+ return true;
+ }
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_ctrl_security);
+
+ initToolbar();
+ initView();
+ initOnClick();
+ initcurState();
+ //璇诲竷闃茬姸鎬�
+ HDLCommand.getSecurityStateFromNetwork(appliancesInfo);
+ }
+
+ /**
+ * 鍒濆鍖朤oolbar
+ */
+ private void initToolbar() {
+ topBarBack = findViewById(R.id.ll_top_b_left);
+ setViewVisible(topBarBack);
+ topBarTitle = findViewById(R.id.tv_top_b_header_title);
+ topBarBack.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ });
+// topBarTitle.setText("瀹夐槻妯″潡婕旂ず");
+ }
+
+ /**
+ * initView
+ */
+ private void initView() {
+ btn_read_config = findViewById(R.id.btn_read_config);
+ btn_set_arming = findViewById(R.id.btn_set_arming);
+ btn_send_alarm = findViewById(R.id.btn_send_alarm);
+ spinner_arming = findViewById(R.id.spinner_arming);
+
+// tv_alarmFire = findViewById(R.id.tv_alarmFire);
+// tv_alarmGas = findViewById(R.id.tv_alarmGas);
+// tv_alarmSudden = findViewById(R.id.tv_alarmSudden);
+//
+// tv_alarmEmergency = findViewById(R.id.tv_alarmEmergency);
+// tv_alarmCurrent = findViewById(R.id.tv_alarmCurrent);
+// tv_alarmSilent = findViewById(R.id.tv_alarmSilent);
+// tv_alarmPower = findViewById(R.id.tv_alarmPower);
+// tv_alarmTemperature = findViewById(R.id.tv_alarmTemperature);
+ tv_mes = findViewById(R.id.tv_mes);
+
+ }
+
+ /**
+ * initOnClick
+ */
+ private void initOnClick() {
+ /**
+ * 璇诲竷闃茬姸鎬�
+ */
+ btn_read_config.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLCommand.getSecurityStateFromNetwork(appliancesInfo);
+ }
+ });
+
+ /**
+ * 甯冮槻
+ */
+ btn_set_arming.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ /**
+ * 瑕佸厛鎾ら槻鍚庡竷闃�
+ */
+ HDLCommand.securityArmingCtrl(appliancesInfo, armingState);
+ }
+ });
+
+// btn_send_alarm.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// alarmSendState++;
+// if (alarmSendState > 7) {
+// alarmSendState = 0;
+// }
+// HDLCommand.securitySendAlarm(appliancesInfo, alarmSendState);
+// }
+// });
+
+ ArrayAdapter<String> sp_CheckBitAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, armingTypeItems);
+ sp_CheckBitAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ spinner_arming.setAdapter(sp_CheckBitAdapter);
+ spinner_arming.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
+ public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
+ armingState = arg2 + 1;
+ }
+
+ public void onNothingSelected(AdapterView<?> arg0) {
+
+ }
+ });
+ }
+
+ /**
+ * initcurState
+ */
+ private void initcurState() {
+ appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl");
+
+ String titleStr = "";
+ try {
+ titleStr = appliancesInfo.getRemarks();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if (titleStr != null) {
+ topBarTitle.setText(titleStr);
+ }
+
+ mSecurityStateBean = new SecurityStateBean();
+ }
+
+
+ /**
+ * 甯冮槻璁剧疆鍥炶皟Event
+ *
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onSecurityArmingFeedBackEventMain(SecurityArmingFeedBackEvent event) {
+ if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ && event.getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum()
+ ) {
+ //鍏堝垽鏂槸鍚﹁秴鏃�
+ if (!event.isSuccess()) {
+ tv_mesSetText("甯冮槻璁剧疆瓒呮椂锛岃閲嶆柊鍐嶈瘯");
+ return;
+ }
+
+ int armingStateGet = event.getArmingState();
+ if (armingStateGet >= 1 && armingStateGet <= 6) {
+ armingState = armingStateGet;
+ spinner_arming.setSelection(armingState - 1, true);
+ tv_mesSetText("甯冮槻鎴愬姛锛屽綋鍓嶇姸鎬侊細" + armingTypeItems[armingState - 1]);
+ } else if (armingState == SecurityParser.ARMING_FAIL) {
+ tv_mesSetText("甯冮槻澶辫触");
+ } else {
+ tv_mesSetText("鏈煡甯冮槻鐘舵��");
+ }
+ }
+ }
+
+ /**
+ * 鏌ヨ甯冮槻鐘舵�� 鍥炶皟Event
+ *
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onDeviceStateEventMain(DeviceStateEvent event) {
+
+ if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ ) {
+ //杩欎釜杩斿洖鐨勪俊鎭槸褰撳墠鐘舵�佺殑
+ switch (event.getAppliancesInfo().getDeviceType()) {
+ case HDLApConfig.TYPE_SECURITY_MODULE:
+ if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) {
+ if (!event.isSuccess()) {
+ tv_mesSetText("鑾峰彇甯冮槻鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+
+ SecurityArmingStateBackInfo mSecurityArmingStateBackInfo = new SecurityArmingStateBackInfo(event.getAppliancesInfo().getArrCurState());
+ if (mSecurityArmingStateBackInfo == null) {
+ tv_mesSetText("鑾峰彇甯冮槻鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+
+ int armingStateBack = mSecurityArmingStateBackInfo.getArmingState();
+ if (armingStateBack == 0) { //璇诲彇杩斿洖0涓烘挙闃�
+ armingState = SecurityParser.ARMING_DISARMING;
+ spinner_arming.setSelection(armingState - 1, true);
+ tv_mesSetText("鑾峰彇鎴愬姛锛屽綋鍓嶇姸鎬侊細" + armingTypeItems[armingState - 1]);
+ } else if (armingStateBack >= 1 && armingStateBack <= 6) {
+ armingState = armingStateBack;//鏇存柊鐘舵�佸��
+ spinner_arming.setSelection(armingState - 1, true);
+ tv_mesSetText("鑾峰彇鎴愬姛锛屽綋鍓嶇姸鎬侊細" + armingTypeItems[armingState - 1]);
+ } else {
+ tv_mesSetText("鑾峰彇鎴愬姛锛屾湭鐭ュ竷闃茬姸鎬�");
+ }
+
+ }
+ break;
+ }
+ }
+ }
+
+
+ /**
+ * 鎶ヨ鍥炶皟Event
+ *
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onSecurityAlarmFeedBackEventMain(SecurityAlarmFeedBackEvent event) {
+ if (event.getSecurityBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getSecurityBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ && event.getSecurityBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum()
+ ) {
+// //鍏堝垽鏂槸鍚﹁秴鏃�
+// if (!event.isSuccess()) {
+// tv_mesSetText("鎶ヨ璁剧疆瓒呮椂锛岃閲嶆柊鍐嶈瘯");
+// return;
+// }
+
+ mSecurityStateBean = event.getSecurityBackInfo().getSecurityStateBean();
+ if (mSecurityStateBean != null) {
+ setAllAlarmStateTextView();
+ }
+
+ }
+ }
+
+
+ /**
+ * TextView 鏄剧ず淇℃伅骞朵笖showToast鎻愮ず
+ *
+ * @param mes
+ */
+ private void tv_mesSetText(String mes) {
+ tv_mes.setText(mes);
+ showToast(mes);
+ }
+
+ private String getAlarmStateString(int state, String alarmName) {
+ if (state == 0) {
+ return "姝e父";
+ } else {
+ HDLLog.Log(alarmName + ", 鎶ヨ鐘舵�侊紒");
+ return "璀﹀憡锛屾姤璀︾姸鎬侊紒";
+ }
+ }
+
+
+ private void setAllAlarmStateTextView() {
+// tv_alarmFire.setText(getAlarmStateString(mSecurityStateBean.getAlarmFire(), "鐏"));
+// tv_alarmGas.setText(getAlarmStateString(mSecurityStateBean.getAlarmGas(), "鐓ゆ皵鎶ヨ"));
+// tv_alarmSudden.setText(getAlarmStateString(mSecurityStateBean.getAlarmSudden(), "绐佸彂鎶ヨ"));
+// tv_alarmEmergency.setText(getAlarmStateString(mSecurityStateBean.getAlarmEmergency(), "绱ф�ユ姤璀�"));
+// tv_alarmCurrent.setText(getAlarmStateString(mSecurityStateBean.getAlarmCurrent(), "鐢垫祦鎶ヨ"));
+// tv_alarmSilent.setText(getAlarmStateString(mSecurityStateBean.getAlarmSilent(), "鏃犲0鎶ヨ"));
+// tv_alarmPower.setText(getAlarmStateString(mSecurityStateBean.getAlarmPower(), "鍔熺巼鎶ヨ"));
+// tv_alarmTemperature.setText(getAlarmStateString(mSecurityStateBean.getAlarmTemperature(), "娓╁害鎶ヨ"));
+
+
+ }
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/MCUActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/MCUActivity.java
new file mode 100644
index 0000000..24d63ab
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/MCUActivity.java
@@ -0,0 +1,690 @@
+//package com.hdl.sdk.ttl_sdk.activity;
+//
+//
+//import android.Manifest;
+//import android.app.Activity;
+//import android.content.Intent;
+//import android.net.Uri;
+//import android.os.Bundle;
+//import android.support.annotation.NonNull;
+//import android.text.TextUtils;
+//import android.util.Log;
+//import android.view.View;
+//import android.widget.AdapterView;
+//import android.widget.ArrayAdapter;
+//import android.widget.Button;
+//import android.widget.RelativeLayout;
+//import android.widget.Spinner;
+//import android.widget.TextView;
+//
+//import com.hdl.sdk.ttl.Config.MCUConstants;
+//import com.hdl.sdk.ttl.HDLDeviceManger.Bean.MCUConfigurationBean;
+//import com.hdl.sdk.ttl.HDLDeviceManger.Bean.MCUDataBean;
+//import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+//import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLSerialPortCore;
+//import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.EventCode;
+//import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.MCUFeedBackEvent;
+//import com.hdl.sdk.ttl.HDLDeviceManger.HDLListener.IMcuOtaListener;
+//import com.hdl.sdk.ttl.Utils.HDLUtlis.HDLStringUtils;
+//import com.hdl.sdk.ttl_sdk.R;
+//import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+//import com.hdl.sdk.ttl_sdk.utlis.HDLLog;
+//import com.hdl.sdk.ttl_sdk.utlis.HDLUriUtils;
+//import com.hdl.sdk.ttl_sdk.utlis.HDLUtlis;
+//
+//import org.greenrobot.eventbus.EventBus;
+//import org.greenrobot.eventbus.Subscribe;
+//import org.greenrobot.eventbus.ThreadMode;
+//
+//import java.io.File;
+//import java.io.FileInputStream;
+//import java.io.FileNotFoundException;
+//import java.io.IOException;
+//import java.util.List;
+//import java.util.Timer;
+//import java.util.TimerTask;
+//
+//import pub.devrel.easypermissions.AppSettingsDialog;
+//import pub.devrel.easypermissions.EasyPermissions;
+//
+///**
+// * MCU鍗忚璋冭瘯椤甸潰
+// */
+//public class MCUActivity extends BaseActivity implements EasyPermissions.PermissionCallbacks, IMcuOtaListener {
+// /**
+// * Topbar
+// */
+// private RelativeLayout topBarBack;
+// private TextView topBarTitle;
+// private Button btn_packet_loss, btn_read_config, btn_write_config, btn_update, btn_restart, btn_PassThrough, btn_PassThrough_close;
+// private Spinner sp_type, sp_Baudrate, sp_DataBit, sp_CheckBit, sp_StopBit;
+// private TextView tv_select_bin, tv_config_mes, tv_update_mes, tv_other_mes;
+//
+// private MCUConfigurationBean mMCUConfigurationBean;
+// private static final String[] mcuTypeItems = {"Buspro", "zigbee", "KNX", "Modbus", "绂侀��", "鑷畾涔�"};
+// private static final String[] mcuBaudrateItems = {"1200", "2400", "4800", "9600", "19200", "38400", "57600", "115200", "250000"};
+// private static final String[] mcuDataItems = {"8", "9"};
+// private static final String[] mcuCheckItems = {"鏃�", "濂�", "鍋�"};
+// private static final String[] mcuStopItems = {"0.5bit", "1bit", "2bit", "1.5bit"};
+// private boolean bGetMCUConfiguration = false;
+//
+// private byte[] upgradeFileDatas;//鍗囩骇鏂囦欢鏁版嵁
+// private static final int SELECT_FILE_CODE = 10;
+// private static final int PERMISSION = 101;
+// private boolean bPermission = false;
+// private static IMcuOtaListener mIMcuOtaListener;
+// private boolean bUpdating = false;//鏄惁鏇存柊涓�
+//
+// /**
+// * 澶嶅啓isRegisterEventBus() 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true
+// *
+// * @return true
+// */
+// @Override
+// protected boolean isRegisterEventBus() {
+// return true;
+// }
+//
+// @Override
+// protected void onCreate(Bundle savedInstanceState) {
+// super.onCreate(savedInstanceState);
+// setContentView(R.layout.activity_mcu);
+//
+// initToolbar();
+//
+// initView();
+// initOnClick();
+// getEasyPermissions();
+// initData();
+//
+// HDLSerialPortCore.setIMcuOtaListener(this);//璁剧疆鐩戝惉
+// }
+//
+// @Override
+// protected void onDestroy() {
+// super.onDestroy();
+// HDLSerialPortCore.removeIMcuOtaListener();
+// }
+//
+// /**
+// * 鍒濆鍖朤oolbar
+// */
+// private void initToolbar() {
+// topBarBack = findViewById(R.id.ll_top_b_left);
+// setViewVisible(topBarBack);
+// topBarTitle = findViewById(R.id.tv_top_b_header_title);
+// topBarBack.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// finish();
+// }
+// });
+// topBarTitle.setText("MCU 鍗忚璋冭瘯");
+// }
+//
+// /**
+// * initView
+// */
+// private void initView() {
+// btn_packet_loss = findViewById(R.id.btn_packet_loss);
+// btn_read_config = findViewById(R.id.btn_read_config);
+// btn_write_config = findViewById(R.id.btn_write_config);
+// btn_update = findViewById(R.id.btn_update);
+// btn_restart = findViewById(R.id.btn_restart);
+// tv_other_mes = findViewById(R.id.tv_other_mes);
+// tv_select_bin = findViewById(R.id.tv_select_bin);
+// tv_config_mes = findViewById(R.id.tv_config_mes);
+// tv_update_mes = findViewById(R.id.tv_update_mes);
+//
+// sp_type = findViewById(R.id.spinner_type);
+// sp_Baudrate = findViewById(R.id.spinner_baudrate);
+// sp_DataBit = findViewById(R.id.spinner_dataBit);
+// sp_CheckBit = findViewById(R.id.spinner_checkBit);
+// sp_StopBit = findViewById(R.id.spinner_stopBit);
+//
+// btn_PassThrough = findViewById(R.id.btn_PassThrough);
+// btn_PassThrough_close = findViewById(R.id.btn_PassThrough_close);
+//
+// mMCUConfigurationBean = new MCUConfigurationBean();
+// }
+//
+// /**
+// * initOnClick
+// */
+// private void initOnClick() {
+//
+// btn_read_config.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// HDLCommand.mcuReadConfiguration();
+// }
+// });
+//
+// btn_write_config.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// HDLCommand.mcuWriteConfiguration(mMCUConfigurationBean.getMCUConfigurationSendBytes());
+// }
+// });
+//
+//
+// btn_packet_loss.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// HDLCommand.mcuGetDetectPacketLossStatus();
+// }
+// });
+//
+// tv_select_bin.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// selectBin();
+// }
+// });
+//
+// btn_update.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+//
+// if (upgradeFileDatas == null) {
+// showToast("璇峰厛閫夋嫨鍗囩骇鏂囦欢");
+// return;
+// }
+//
+// HDLCommand.mcuRequestUpgradeWithFile(upgradeFileDatas);//浼犲叆鍗囩骇鏂囦欢骞跺紑濮嬪崌绾�
+// }
+// });
+//
+// btn_restart.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// HDLCommand.mcuSendRestart();
+// }
+// });
+//
+//
+// /**
+// * 鍙戦�侀�忎紶鍙傛暟 锛屼笉璧癰us鍗忚
+// */
+// btn_PassThrough.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// mcuSendTransparentData();
+//
+// }
+// });
+//
+// btn_PassThrough_close.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// setHDLPassThroughOpen(false);
+// tv_other_mes.setText("鍏抽棴閫忎紶");
+//
+// }
+// });
+//
+// ArrayAdapter<String> sp_typeAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mcuTypeItems);
+// sp_typeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+// sp_type.setAdapter(sp_typeAdapter);
+// sp_type.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
+// public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
+// if (arg2 == 4) {
+// //閫夋嫨浜嗙閫�
+// showToast("璇ラ」涓嶈兘閫夋嫨锛�");
+// sp_type.setSelection(mMCUConfigurationBean.getMcuAgreementType());
+// } else {
+// mMCUConfigurationBean.setMcuAgreementType(arg2);
+// }
+//
+// }
+//
+// public void onNothingSelected(AdapterView<?> arg0) {
+// //
+// }
+// });
+//
+//
+// ArrayAdapter<String> sp_BaudrateAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mcuBaudrateItems);
+// sp_BaudrateAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+// sp_Baudrate.setAdapter(sp_BaudrateAdapter);
+// sp_Baudrate.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
+// public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
+// mMCUConfigurationBean.setMcuBaudrate(arg2);
+// }
+//
+// public void onNothingSelected(AdapterView<?> arg0) {
+// //
+// }
+// });
+//
+//
+// ArrayAdapter<String> sp_DataBitAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mcuDataItems);
+// sp_DataBitAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+// sp_DataBit.setAdapter(sp_DataBitAdapter);
+// sp_DataBit.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
+// public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
+// mMCUConfigurationBean.setMcuDataBit(arg2);
+// }
+//
+// public void onNothingSelected(AdapterView<?> arg0) {
+// }
+// });
+//
+//
+// ArrayAdapter<String> sp_CheckBitAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mcuCheckItems);
+// sp_CheckBitAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+// sp_CheckBit.setAdapter(sp_CheckBitAdapter);
+// sp_CheckBit.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
+// public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
+// mMCUConfigurationBean.setMcuCheckBit(arg2);
+// }
+//
+// public void onNothingSelected(AdapterView<?> arg0) {
+//
+// }
+// });
+//
+// ArrayAdapter<String> sp_StopBitAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mcuStopItems);
+// sp_StopBitAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+// sp_StopBit.setAdapter(sp_StopBitAdapter);
+// sp_StopBit.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
+// public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
+// mMCUConfigurationBean.setMcuStopBit(arg2);
+//// showToast("閫夋嫨鐨勬槸" + mcuStopItems[arg2]);
+// }
+//
+// public void onNothingSelected(AdapterView<?> arg0) {
+// //
+// }
+// });
+//
+// }
+//
+//
+//
+//
+// /**
+// * initData
+// */
+// private void initData() {
+// setEnabledConfigBtn();
+//
+// }
+//
+// private void setEnabledConfigBtn() {
+// btn_write_config.setEnabled(bGetMCUConfiguration);
+// }
+//
+// private void updateMCUConfiguration(MCUConfigurationBean mMCUConfigurationBean) {
+// this.mMCUConfigurationBean = mMCUConfigurationBean;
+// sp_type.setSelection(mMCUConfigurationBean.getMcuAgreementType(), true);
+// sp_Baudrate.setSelection(mMCUConfigurationBean.getMcuBaudrate(), true);
+// sp_DataBit.setSelection(mMCUConfigurationBean.getMcuDataBit(), true);
+// sp_CheckBit.setSelection(mMCUConfigurationBean.getMcuCheckBit(), true);
+// sp_StopBit.setSelection(mMCUConfigurationBean.getMcuStopBit(), true);
+//
+// }
+//
+// private void resetMCUConfiguration() {
+// sp_type.setSelection(0, true);
+// sp_Baudrate.setSelection(0, true);
+// sp_DataBit.setSelection(0, true);
+// sp_CheckBit.setSelection(0, true);
+// sp_StopBit.setSelection(0, true);
+//
+// }
+//
+// /**
+// * ***********************************************************澶勭悊MCU鍥炲鏁版嵁***********************************************************
+// */
+// /**
+// * MCU鎺у埗鍥炶皟Event
+// *
+// * @param event
+// */
+// @Subscribe(threadMode = ThreadMode.MAIN)
+// public void onMCUFeedBackEventMain(MCUFeedBackEvent event) {
+// if (event.getEventCode() == EventCode.FAILURE_TIMEOUT) {
+// if (TextUtils.isEmpty(event.getError())) {
+// showToast("MCU璇锋眰瓒呮椂锛岃绋嶅悗鍐嶈瘯");
+// } else {
+// showToast(event.getError());
+// }
+// return;
+// }
+//
+// switch (event.getMCUDataBean().command) {
+// case MCUConstants.MCU_COMMAND_SEND_BACK: //
+// //閫忎紶杩斿洖鐨勬暟鎹�
+// handleMCUPassThroughDataBack(event);
+// break;
+// case MCUConstants.MCU_READ_CONFIGURATION_BACK:// 璇婚厤缃繑鍥�
+// case MCUConstants.MCU_WRITE_CONFIGURATION_BACK:// 鍐欓厤缃俊鎭繑鍥�
+// handleMCUConfigurationBack(event);
+// break;
+// case MCUConstants.MCU_DETECT_PACKET_LOSS_STATUS_BACK:// 妫�娴嬩涪鍖呯姸鎬佽繑鍥�
+// //寰呭鐞�
+// handleDetectPacketLossStatusBack(event);
+// break;
+// case MCUConstants.MCU_REQUEST_UPGRADE_BACK: // 璇锋眰鍗囩骇杩斿洖
+// handleRequestUpgradeBack(event);
+// break;
+//// case MCUConstants.MCU_SEND_UPGRADE_DATA_BACK: // 鍙戦�佸崌绾ф暟鎹繑鍥�
+//// handleSendUpgradeDataBack(event);
+//// break;
+// case MCUConstants.MCU_RESTART_BACK: //0x86 閲嶅惎杩斿洖
+// handleRestartBack(event);
+// break;
+// default:
+// break;
+// }
+// }
+//
+// /**
+// * 澶勭悊MCU閫忎紶鍥炶皟鏁版嵁
+// * 閫忎紶鏁版嵁锛屼笉璧癰us鍗忚锛岀洿鎺ヨ浆鍙戯紝涓嶅仛鏁版嵁鏍煎紡澶勭悊
+// *
+// * @param event
+// */
+// private void handleMCUPassThroughDataBack(MCUFeedBackEvent event) {
+// if (event.getEventCode() != EventCode.SUCCESS) {
+// tv_other_mesSetText("MCU閫忎紶鏁版嵁鍑洪敊锛岃繑鍥炴暟鎹紓甯�");
+// return;
+// }
+// String receiveString = HDLStringUtils.ByteArrToHex(event.getMCUDataBean().receiveBytes, 0, event.getMCUDataBean().receiveBytes.length);
+//
+// tv_other_mes.setText("鏀跺埌鐨勯�忎紶鏁版嵁锛�" + receiveString);
+// HDLLog.Log("鏀跺埌鐨勯�忎紶鏁版嵁锛�" + receiveString);
+// }
+//
+// /**
+// * 澶勭悊MCU璇诲啓閰嶇疆杩斿洖鏁版嵁
+// *
+// * @param event
+// */
+// private void handleMCUConfigurationBack(MCUFeedBackEvent event) {
+// if (event.getEventCode() != EventCode.SUCCESS) {
+// tv_config_mesSetText("MCU璇诲啓閰嶇疆鍑洪敊锛岃繑鍥炴暟鎹紓甯�");
+// return;
+// }
+// tv_config_mesSetText("鎴愬姛鑾峰彇閰嶇疆");
+// bGetMCUConfiguration = true;
+// setEnabledConfigBtn();
+// updateMCUConfiguration(event.getMCUDataBean().getMCUConfigurationBean());
+// }
+//
+// /**
+// * 澶勭悊MCU涓㈠寘妫�娴嬭繑鍥炴暟鎹�
+// *
+// * @param event
+// */
+// private void handleDetectPacketLossStatusBack(MCUFeedBackEvent event) {
+// if (event.getEventCode() != EventCode.SUCCESS) {
+// tv_other_mesSetText("MCU涓㈠寘妫�娴嬪嚭閿欙紝杩斿洖鏁版嵁寮傚父");
+// return;
+// }
+//
+// String receiveString = HDLStringUtils.ByteArrToHex(event.getMCUDataBean().receiveBytes, 0, event.getMCUDataBean().receiveBytes.length);
+// HDLLog.Log("涓㈠寘妫�娴嬭繑鍥炴暟鎹細" + receiveString);
+// tv_other_mesSetText("涓㈠寘妫�娴嬭繑鍥炴暟鎹細" + receiveString);
+// }
+//
+// /**
+// * 澶勭悊MCU璇锋眰閲嶅惎杩斿洖鏁版嵁
+// *
+// * @param event
+// */
+// private void handleRestartBack(MCUFeedBackEvent event) {
+// if (event.getEventCode() != EventCode.SUCCESS) {
+// showToast("MCU璇锋眰閲嶅惎杩斿洖閿欒锛岄噸鍚け璐�");
+// return;
+// }
+// if (bUpdating) {
+// bUpdating = false;
+// tv_update_mes.setText("MCU閲嶅惎鎴愬姛,鍗囩骇瀹屾垚锛�");
+// tv_other_mesSetText("MCU閲嶅惎鎴愬姛,鍗囩骇瀹屾垚锛�");
+// } else {
+// tv_other_mesSetText("MCU閲嶅惎鎴愬姛锛�");
+// }
+// }
+//
+// /**
+// * 澶勭悊MCU璇锋眰鍗囩骇杩斿洖鏁版嵁
+// *
+// * @param event
+// */
+// private void handleRequestUpgradeBack(MCUFeedBackEvent event) {
+// if (event.getEventCode() != EventCode.SUCCESS) {
+// tv_update_mesSetText("MCU璇锋眰鍗囩骇鍑洪敊");
+// return;
+// }
+// bUpdating = true;
+// tv_update_mesSetText("MCU璇锋眰鍗囩骇鎴愬姛锛屽紑濮嬪崌绾�...");
+// }
+//
+////
+//// private void handleSendUpgradeDataBack(MCUFeedBackEvent event) {
+//// if (event.getEventCode() != EventCode.SUCCESS) {
+//// showToast("MCU鍙戦�佸崌绾ф暟鎹嚭閿�");
+//// return;
+//// }
+////// 娉ㄦ剰锛屽綋鏂囦欢鍦板潃涓�0xF5F5F5F5鐨勬椂鍊欙紝浠h〃鍙戠敓閿欒锛�
+////// 鍗囩骇鍖呬笉瀵癸紝浼氶��鍑哄崌绾фā寮忋�傚綋鏂囦欢鍦板潃涓�0xF8F8F8F8,浠h〃鎴愬姛锛屾垚鍔熷悗浼氶噸鍚�,鐩戝惉鍒伴噸鍚畬姣曪紝鎵嶄唬琛ㄥ畬鎴愩��
+////
+//// showToast("鏀跺埌鍥炲锛岀户缁彂閫佹暟鎹�");
+////
+//// }
+//
+// /**
+// * ***********************************************************閫夋嫨鍗囩骇鏂囦欢***********************************************************
+// */
+// private void selectBin() {
+//// {".bin", "application/octet-stream"}
+// Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
+//// intent.setType("*/*");//璁剧疆绫诲瀷锛屾垜杩欓噷鏄换鎰忕被鍨嬶紝浠绘剰鍚庣紑鐨勫彲浠ヨ繖鏍峰啓銆�
+// intent.setType("application/octet-stream");//璁剧疆绫诲瀷锛屾垜杩欓噷鏄换鎰忕被鍨嬶紝浠绘剰鍚庣紑鐨勫彲浠ヨ繖鏍峰啓銆� {".bin", "application/octet-stream"}
+// intent.addCategory(Intent.CATEGORY_OPENABLE);
+// startActivityForResult(intent, SELECT_FILE_CODE);
+// }
+//
+// protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+// if (resultCode == Activity.RESULT_OK) {
+// if (requestCode == SELECT_FILE_CODE) {
+// if (data != null) {
+// Uri fileUri = data.getData();
+// if (fileUri != null) {
+// getFileFromUri(fileUri);
+// }
+// }
+//
+// }
+// }
+// }
+//
+// /**
+// * 鏍规嵁uri 璇诲彇鍗囩骇鍥轰欢
+// *
+// * @param mUri
+// */
+// private void getFileFromUri(Uri mUri) {
+// String path = mUri.toString();
+// if (!HDLUtlis.checkIsBinFile(path)) {
+// tv_select_bin.setText(getString(R.string.select_bin_frist));
+// upgradeFileDatas = null;
+// btn_update.setEnabled(false);
+// showToast("鍗囩骇鍥轰欢鏍煎紡涓嶅锛岃閫夋嫨.bin鍚庣紑鐨勫崌绾ф枃浠�");
+// return;
+// }
+// btn_update.setEnabled(true);
+// tv_select_bin.setText(path);
+// File file = HDLUriUtils.uri2File(this, mUri);
+// FileInputStream fis = null;
+// try {
+// fis = new FileInputStream(file);
+// int length = fis.available();
+// upgradeFileDatas = new byte[length];
+// fis.read(upgradeFileDatas);
+// fis.close();
+// showToast("upgradeFileDatas 闀垮害锛�" + upgradeFileDatas.length);
+//
+//
+// //鎵撳嵃鎺ュ彈鏁版嵁
+// com.hdl.sdk.ttl.Utils.LogUtils.HDLLog.I("receiveBytes HandleMCUdata: " + HDLStringUtils.ByteArrToHex(upgradeFileDatas, 0, upgradeFileDatas.length));
+// } catch (FileNotFoundException e) {
+// e.printStackTrace();
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+// }
+//
+//
+// /**
+// * ***********************************************************鏉冮檺绠$悊***********************************************************
+// */
+// private void getEasyPermissions() {
+// /**
+// * 6.0+绯荤粺鍔ㄦ�佹潈闄愮敵璇烽渶瑕�
+// */
+// String[] params = new String[]{
+// Manifest.permission.WRITE_EXTERNAL_STORAGE,
+// };
+// if (EasyPermissions.hasPermissions(this, params)) {
+// bPermission = true;
+// } else {
+// EasyPermissions.requestPermissions(this, "搴旂敤闇�瑕佹潈闄愭墠鑳藉畨鍏ㄨ繍琛�", PERMISSION, params);
+// }
+// }
+//
+// @Override
+// public void onPermissionsGranted(int requestCode, List<String> perms) {
+// Log.i("hdlll", "onPermissionsGranted permsSize:" + perms.size());
+// if (requestCode == PERMISSION) {
+// if (!perms.isEmpty()) {
+// if (perms.contains(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
+// //鍏ㄩ儴鏉冮檺鎺堟潈閫氳繃鎵嶆甯告墦寮�APP
+// bPermission = true;
+// }
+// }
+// }
+//
+// }
+//
+// @Override
+// public void onPermissionsDenied(int requestCode, List<String> perms) {
+// switch (requestCode) {
+// case PERMISSION:
+// //寮曞鐢ㄦ埛璺宠浆鍒拌缃晫闈�
+// new AppSettingsDialog.Builder(this).setTitle("娓╅Θ鎻愮ず").setRationale("鏃犳硶姝e父鍚姩APP锛屾偍闇�瑕佹巿浜堟潈闄愶紒").build().show();
+// break;
+// }
+// }
+//
+// @Override
+// public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+// super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+// EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
+// }
+//
+//
+// /**
+// * ***********************************************************鍥轰欢鍗囩骇 鍥炶皟***********************************************************
+// */
+// @Override
+// public void onSuccess() {
+// sendRestartTimer();//鍗囩骇10S瓒呮椂鎻愮ず
+// HDLLog.Log("IMcuOtaListener onSuccess");
+// runOnUiThread(new Runnable() { //瑕佸湪涓荤嚎绋嬫洿鏂癠I
+// public void run() {
+// tv_update_mesSetText("鍗囩骇鎴愬姛锛岀瓑寰呴噸鍚�...");
+// }
+// });
+// }
+//
+// @Override
+// public void onFailure(int code, final String error) {
+// HDLLog.Log("IMcuOtaListener onFailure");
+// runOnUiThread(new Runnable() {
+// public void run() {
+// tv_update_mesSetText("鍗囩骇澶辫触锛� " + error);
+// }
+// });
+//
+// }
+//
+// @Override
+// public void onProgress(final int progress) {
+// HDLLog.Log("IMcuOtaListener onProgress锛�" + progress);
+// runOnUiThread(new Runnable() {
+// public void run() {
+// tv_update_mes.setText("鍗囩骇杩涘害锛�" + progress + "%");
+// }
+// });
+//
+// }
+//
+// /**
+// * TextView 鏄剧ず淇℃伅骞朵笖showToast鎻愮ず
+// *
+// * @param mes
+// */
+// private void tv_update_mesSetText(String mes) {
+// tv_update_mes.setText(mes);
+// showToast(mes);
+// }
+//
+// private void tv_other_mesSetText(String mes) {
+// tv_other_mes.setText(mes);
+// showToast(mes);
+// }
+//
+// private void tv_config_mesSetText(String mes) {
+// tv_config_mes.setText(mes);
+// showToast(mes);
+// }
+//
+//
+// /**
+// * 鍗囩骇瀹屾垚鍚庡垽鏂� 鏄惁閲嶅惎鎴愬姛 璁剧疆10S瓒呮椂绛夊緟
+// */
+// private void sendRestartTimer() {
+// Timer restartTimer = new Timer();
+// restartTimer.schedule(new TimerTask() {
+// @Override
+// public void run() {
+// if (bUpdating) {
+// runOnUiThread(new Runnable() {
+// public void run() {
+// tv_update_mesSetText("鍗囩骇瀹屾垚锛孧CU閲嶅惎瓒呮椂锛�");
+// }
+// });
+// }
+// }
+// }, 10000);//10s瓒呮椂闄愬埗
+// }
+//
+//
+//
+//
+// /**
+// * 2019-8-9
+// * 鍙戦�侀�忎紶鍙傛暟
+// * 閫忎紶鏁版嵁锛屼笉璧癰us鍗忚锛岀洿鎺ヨ浆鍙戯紝涓嶅仛鏁版嵁鏍煎紡澶勭悊
+// * mcuSendTransparentData鎺ュ彛璋冪敤涓�娆′互鍚庯紝榛樿鎵�鏈夋帴鏀舵暟鎹蛋閫忎紶
+// * 鍙互璋冪敤setHDLPassThroughOpen鍏抽棴閫忎紶鏁版嵁
+// */
+// private void mcuSendTransparentData() {
+// byte[] sendBytes = new byte[]{(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00};
+// HDLCommand.mcuSendTransparentData(sendBytes);
+// }
+//
+// /**
+// * 璁剧疆鏄惁寮�鍚�忎紶鏁版嵁
+// * 瑕佹兂鐩存帴鎺ユ敹閫忎紶鏁版嵁锛岀洿鎺ヨ皟鐢ㄨ繖涓帴鍙f墦寮�灏卞彲浠ワ紝涓嶈蛋bus鍗忚澶勭悊
+// * 涓嶆兂閫忎紶鐨勮瘽锛岃璁板緱璁剧疆鍥炲叧闂姸鎬�
+// */
+// private void setHDLPassThroughOpen(Boolean bOpen){
+// HDLCommand.setHDLPassThroughOpen(bOpen);
+//
+// }
+//
+//}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/MainActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/MainActivity.java
new file mode 100644
index 0000000..27ba6a5
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/MainActivity.java
@@ -0,0 +1,453 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.hdl.sdk.ttl.Config.Configuration;
+import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.DevicesData;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLDeviceManager;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLSerialPortCore;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLTtlSdk;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.BgmInfoEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DevicesInfoEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.DiscoverNewDevicesEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.UpdateRemarkFeedBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.ThirdPartyBgmInfoEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.WarningInfoEvent;
+import com.hdl.sdk.ttl.Utils.HDLUtlis.HDLStringUtils;
+import com.hdl.sdk.ttl_sdk.R;
+import com.hdl.sdk.ttl_sdk.adapter.HDLMainListAdapter;
+import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+//import com.hdl.sdk.ttl_sdk.bean.ZigbeeActivity2;
+import com.hdl.sdk.ttl_sdk.utlis.HDLLog;
+import com.hdl.sdk.ttl_sdk.utlis.HDLWarningType;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.hdl.sdk.ttl_sdk.HDLApplication.HDL_BAUDRATE;
+import static com.hdl.sdk.ttl_sdk.HDLApplication.HDL_UART_PATH;
+
+/**
+ * Modify by JLChen on 2019/6/27
+ */
+public class MainActivity extends BaseActivity {
+
+// @BindView(R.id.tv_version)
+// TextView tvVersion;
+// @BindView(R.id.btn_search)
+// Button btnSearch;
+// @BindView(R.id.btn_close)
+// Button btnClose;
+// @BindView(R.id.btn_open)
+// Button btnOpen;
+// @BindView(R.id.tv_result)
+// TextView tvResult;
+// @BindView(R.id.listView_devices)
+// ListView listViewDevices;
+
+ /**
+ * Topbar
+ */
+// private RelativeLayout topBarBack;
+ private TextView topBarTitle;
+ private TextView tvVersion;
+ private Button btnSearch;
+ private Button btnGetLocal;
+ private Button btnClose;
+ private Button btnOpen;
+ private Button btnSetting;
+ private Button btnMCU, btn_ZigBee;
+ private Button btnAdd;
+ private Button btn_sendtest;
+
+ private TextView tvResult;
+ private RecyclerView mRecyclerView;
+
+ private List<DevicesData> mDevicesDataList;
+ private List<String> mAllDevicesList = new ArrayList<>();//鎼滅储鍒扮殑璁惧鐨勫娉ㄥ悕
+
+ private ProgressDialog mProgressDialog;
+// private static String HDL_PATH_NAME = "/dev/ttyS2"; //涓插彛璁惧璺緞鍚�
+// private static int HDL_BAUDRATE = 115200; //娉㈢壒鐜�
+ private Boolean bOpen = false;
+ private int remarkId = 0;
+ private String remarkStr = "";
+ private HDLMainListAdapter mHDLMainListAdapter;
+
+
+ /**
+ * 澶嶅啓isRegisterEventBus() 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true
+ *
+ * @return true
+ */
+ @Override
+ protected boolean isRegisterEventBus() {
+ return true;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+// ButterKnife.bind(this);
+
+ initView();
+ initRecyclerView();
+ initOnClick();
+ initData();
+
+ }
+
+
+ private void initView() {
+ topBarTitle = findViewById(R.id.tv_top_b_header_title);
+ tvVersion = findViewById(R.id.tv_version);
+ btnSearch = findViewById(R.id.btn_search);
+ btnGetLocal = findViewById(R.id.btn_getlocal);
+ btnClose = findViewById(R.id.btn_close);
+ btnOpen = findViewById(R.id.btn_open);
+ btnSetting = findViewById(R.id.btn_setting);
+ tvResult = findViewById(R.id.tv_result);
+ btnMCU = findViewById(R.id.btn_mcu);
+ btnAdd = findViewById(R.id.btn_add_device);
+ btn_sendtest = findViewById(R.id.btn_sendtest);
+
+ btn_ZigBee = findViewById(R.id.btn_ZigBee);
+
+ mProgressDialog = new ProgressDialog(MainActivity.this);
+ mProgressDialog.setTitle("姝e湪鑾峰彇鏁版嵁...");
+ mProgressDialog.setMessage("璇疯�愬績绛夊緟");
+ mProgressDialog.onStart();
+
+ }
+
+ /**
+ * 鍒濆鍖朢ecyclerView
+ */
+ private void initRecyclerView() {
+ mRecyclerView = findViewById(R.id.listView_devices);
+ // 瀹氫箟涓�涓嚎鎬у竷灞�绠$悊鍣�
+ LinearLayoutManager manager = new LinearLayoutManager(this);
+ // 璁剧疆甯冨眬绠$悊鍣�
+ mRecyclerView.setLayoutManager(manager);
+ // 璁剧疆adapter
+ mHDLMainListAdapter = new HDLMainListAdapter(this, mAllDevicesList);
+ mRecyclerView.setAdapter(mHDLMainListAdapter);
+
+ mHDLMainListAdapter.setOnItemClickLitener(new HDLMainListAdapter.OnItemClickLitener() {
+ @Override
+ public void onItemClick(int position) {
+ if (!bOpen) {
+ showToast("璇峰厛鎵撳紑涓插彛锛�");
+ return;
+ }
+ Intent intent = new Intent();
+ intent.setClass(MainActivity.this, AppliancesListActivity.class);
+ Bundle bundle = new Bundle();
+ bundle.putSerializable("Appliances", (Serializable) mDevicesDataList.get(position).getAppliancesInfoList());
+ intent.putExtras(bundle);
+ MainActivity.this.startActivity(intent);
+ }
+
+ @Override
+ public void onItemLongClick(int position) {
+ remarkId = position;
+ String mInfo = mDevicesDataList.get(remarkId).getRemark();
+ showInPutView(mDevicesDataList.get(remarkId).getSourceSubnetID(), mDevicesDataList.get(remarkId).getSourceDeviceID(), mInfo);
+
+ }
+ });
+
+
+ }
+
+ private void initOnClick() {
+ btnSearch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ /**鍏ㄩ儴閲嶆柊鎼滅储,娓呯┖鍘熻澶囧垪琛ㄦ暟鎹�*/
+ clearListView();
+ HDLCommand.getHomeDevices();
+ mProgressDialog.show();
+ }
+ });
+
+ btnGetLocal.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ clearListView();
+ getLocalDevicesDataList();
+ }
+ });
+
+ btnClose.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLSerialPortCore.closeSerialPort();
+ updateButtonEnable();
+
+ }
+ });
+
+ btnOpen.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ HDLSerialPortCore.openSerialPort(HDL_UART_PATH, HDL_BAUDRATE);
+ updateButtonEnable();
+
+ }
+ });
+
+ btnSetting.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ startActivity(SettingActivity.class);
+
+
+// addSecurityModuleDevice();
+// HDLDeviceManager.clearAllDeviceList();
+ }
+ });
+
+ btnMCU.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+// startActivity(MCUActivity.class);
+ }
+ });
+
+ btnAdd.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ startActivity(AddDevicesManuallyNEWActivity.class);
+
+// byte[] remarkByte = new byte[]{
+// (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+// (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+// (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+// (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,};
+// String remarkStr = HDLStringUtils.byte2String(remarkByte);
+// HDLLog.Log("remarkStr鍥炶矾锛�" + remarkStr);
+ }
+ });
+
+ btn_ZigBee.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+// startActivity(ZigbeeActivity2.class);
+
+
+ }
+ });
+
+ btn_sendtest.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ startActivity(SendTestActivity.class);
+ }
+ });
+
+ }
+
+ private void initData() {
+ topBarTitle.setText("HDL TTL Demo");
+ updateButtonEnable();
+ }
+
+ /**
+ * 鍒ゆ柇涓插彛鏄惁鎵撳紑鎴愬姛锛屽苟鍒锋柊鎸夐挳鐘舵��
+ */
+ private void updateButtonEnable() {
+ bOpen = HDLSerialPortCore.getIsSerialPortOpen();
+ btnSearch.setEnabled(bOpen);
+ btnGetLocal.setEnabled(bOpen);
+ btnClose.setEnabled(bOpen);
+ btnOpen.setEnabled(!bOpen);
+ btnMCU.setEnabled(bOpen);
+ btnAdd.setEnabled(bOpen);
+ btn_sendtest.setEnabled(bOpen);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ HDLTtlSdk.release(); //鍏抽棴涓插彛
+ }
+
+
+ private void showInPutView(final int mSubnetID, final int mDeviceID, String mText) {
+ final EditText modifyRemark = new EditText(this);
+ modifyRemark.setText(mText);
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle("淇敼澶囨敞").setIcon(android.R.drawable.ic_dialog_info).setView(modifyRemark)
+ .setNegativeButton("鍙栨秷", null);
+ builder.setPositiveButton("纭", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ remarkStr = modifyRemark.getText().toString();
+ updateModuleRemark(mSubnetID, mDeviceID, remarkStr);
+ }
+ });
+ builder.show();
+ }
+
+ private void updateModuleRemark(int mSubnetID, int mDeviceID, String remarkStr) {
+ if (TextUtils.isEmpty(remarkStr) || TextUtils.isEmpty(remarkStr)) {
+ showToast("鍐呭涓嶈兘涓虹┖");
+ return;
+ }
+ byte[] remarkByte = HDLStringUtils.stringtoBytes(remarkStr);
+ if (remarkByte.length > 20) {
+ showToast("澶囨敞鍚嶄笉鑳借秴杩�20瀛楄妭");
+ } else {
+ //淇敼妯″潡澶囨敞鎺ュ彛锛�
+ HDLCommand.updateModuleRemark(mSubnetID, mDeviceID, remarkByte);
+ HDLLog.Log("kkkkkkkkk:" + remarkStr);
+ }
+ }
+
+ /**
+ * 鍒锋柊璁惧鍒楄〃鏁版嵁
+ */
+ private void updateDeviceListView() {
+ int countAll = 0;
+ for (DevicesData devicesData : mDevicesDataList) {
+ countAll += devicesData.getAppliancesInfoList().size();
+ }
+ tvResult.setText("鎬诲叡妯″潡鏁帮細" + mDevicesDataList.size() + " 鎬诲叡鍥炶矾鏁帮細" + countAll);
+ HDLLog.Log("鑾峰彇鏁版嵁鎴愬姛锛氭�诲叡妯″潡鏁帮細" + mDevicesDataList.size() + " 鎬诲叡鍥炶矾鏁帮細" + countAll);
+
+ for (int i = 0; i < mDevicesDataList.size(); i++) {
+ if (TextUtils.isEmpty(mDevicesDataList.get(i).getRemark())) {
+ mAllDevicesList.add("鏆傛棤澶囨敞");
+ } else {
+ mAllDevicesList.add(mDevicesDataList.get(i).getRemark());
+ }
+ }
+ mHDLMainListAdapter.notifyDataSetChanged();
+ }
+
+ /**
+ * 璇诲彇鍜屽姞杞芥湰鍦版暟鎹�
+ */
+ private void getLocalDevicesDataList() {
+ mDevicesDataList = HDLDeviceManager.getLocalDevicesDataList();
+ if (mDevicesDataList.size() > 0) {
+ updateDeviceListView();
+ } else {
+ showToast("鏈湴鏁版嵁涓虹┖");
+ }
+ }
+
+ /**
+ * 娓呯┖鏁版嵁骞跺埛鏂板垪琛�
+ */
+ private void clearListView() {
+ if (mAllDevicesList != null) mAllDevicesList.clear();
+ if (mDevicesDataList != null) mDevicesDataList.clear();
+
+ mHDLMainListAdapter.notifyDataSetChanged();
+ }
+
+ /**
+ * ====================EventBus 璁㈤槄浜嬩欢 ====================
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onDevicesInfoEventMain(DevicesInfoEvent event) {
+ mAllDevicesList.clear();
+ mProgressDialog.dismiss();
+ if (!event.isSuccess()) {
+ Toast.makeText(MainActivity.this, "鎼滅储瓒呮椂锛岃閲嶆柊鍐嶈瘯", Toast.LENGTH_SHORT).show();
+ tvResult.setText("鎼滅储瓒呮椂锛岃閲嶆柊鍐嶈瘯");
+ return;
+ }
+ mDevicesDataList = event.getDesDataList();
+ updateDeviceListView();
+ }
+
+
+// 宸插簾闄わ紝鍦烘櫙鏁版嵁宸茬粡鍜屽父瑙勮澶囧悎骞躲�傝嫢鏈夐渶姹傞渶瑕佸尯鍒嗭紝璇锋牴鎹澶囩被鍨�
+// 12銆�13 涓哄満鏅� TYPE_LOGIC_MODULE銆乀YPE_GLOBAL_LOGIC_MODULE
+// @Subscribe(threadMode = ThreadMode.MAIN)
+// public void onSceneInfoEventMain(SceneInfoEvent event) {
+// proDia.dismiss();
+// listString.clear();
+// if (!event.isSuccess()) {
+// Toast.makeText(MainActivity.this, "鎼滅储瓒呮椂锛岃閲嶆柊鍐嶈瘯", Toast.LENGTH_SHORT).show();
+// tv.setText("鎼滅储瓒呮椂锛岃閲嶆柊鍐嶈瘯");
+// return;
+// }
+// devicesDatas = event.getDesDataList();
+// tv.setText("鎬诲叡妯″潡鏁� 锛� " + event.getDesDataList().size());
+//
+// for (int i = 0; i < devicesDatas.size(); i++) {
+// if (TextUtils.isEmpty(devicesDatas.get(i).getRemark())) {
+// listString.add("鏆傛棤澶囨敞");
+// } else {
+// listString.add(devicesDatas.get(i).getRemark());
+// }
+// }
+// adapter.notifyDataSetChanged();
+// }
+
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onWarningEventMain(WarningInfoEvent event) {
+ String warningType = HDLWarningType.getWarningType(event.getWarningTypeId());
+ Toast.makeText(MainActivity.this, warningType, Toast.LENGTH_SHORT).show();
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onRemarkUpdateFeedBackEventMain(UpdateRemarkFeedBackEvent event) {
+ if (event.isSuccess()) {
+ showToast("淇敼鎴愬姛");
+ mDevicesDataList.get(remarkId).setRemark(remarkStr);
+ mAllDevicesList.set(remarkId, remarkStr);
+ HDLDeviceManager.devicesDataList.get(remarkId).setRemark(remarkStr);
+ mHDLMainListAdapter.notifyDataSetChanged();
+ } else {
+ showToast("淇敼澶辫触");
+ }
+
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onDiscoverNewDevicesEventMain(DiscoverNewDevicesEvent event) {
+ HDLLog.Log("鍙戠幇鏂拌澶囷細" + event.getnewDevicesData().getRemark());
+ }
+
+
+
+
+ @SuppressWarnings("unused")
+ private void closePhone(Context context, String[] shutdown){
+ try {
+ Process process = Runtime.getRuntime().exec(shutdown);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/SendTestActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/SendTestActivity.java
new file mode 100644
index 0000000..74dd686
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/SendTestActivity.java
@@ -0,0 +1,161 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+import android.os.Handler;
+import android.os.Message;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.RemarkTimes;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLSerialPortCore;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLTtlSdk;
+import com.hdl.sdk.ttl.Utils.LogUtils.HDLLog;
+import com.hdl.sdk.ttl.Utils.SPUtils.SPUtils;
+import com.hdl.sdk.ttl_sdk.R;
+import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+
+import java.io.IOException;
+
+import static com.hdl.sdk.ttl.Config.Configuration.LIGHT_CTRL_COMMAND;
+import static com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand.cusSendCommand;
+
+public class SendTestActivity extends BaseActivity {
+ /**Topbar*/
+ private RelativeLayout topBarBack;
+ private TextView topBarTitle;
+ private Button btn_start,btn_end;
+ private TextView tv_message;
+ private EditText et_count;
+
+ private boolean isSend;
+ private SendTestThread sendTestThread = new SendTestThread();
+ private int count = 10000;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_send_test);
+ initToolbar();
+ initView();
+ setOnClick();
+
+ }
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ endHDLThread();
+ }
+ /**
+ * 鍒濆鍖朤oolbar
+ */
+ private void initToolbar() {
+ topBarBack = findViewById(R.id.ll_top_b_left);
+ setViewVisible(topBarBack);
+ topBarTitle = findViewById(R.id.tv_top_b_header_title);
+ topBarBack.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ });
+ topBarTitle.setText("淇敼瀛愮綉鍙峰拰璁惧鍙�");
+ }
+
+ private void initView() {
+ btn_start = findViewById(R.id.btn_start);
+ btn_end = findViewById(R.id.btn_end);
+ tv_message = findViewById(R.id.tv_message);
+ et_count = findViewById(R.id.et_count);
+ }
+
+
+ private void setOnClick() {
+ btn_start.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ String countStr = et_count.getText().toString();
+ if (TextUtils.isEmpty(countStr) ) {
+ count = 10000;
+ }else {
+ count= Integer.parseInt(countStr);
+ }
+
+ startHDLThread();
+ }
+ });
+
+ btn_end.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ endHDLThread();
+ }
+ });
+ }
+
+ /**
+ * 鍚姩涓插彛 鍙戦�佸拰鎺ユ敹绾跨▼
+ */
+ private void startHDLThread() {
+ sendTestThread = new SendTestThread();
+ sendTestThread.start();
+ }
+ public void endHDLThread() {
+ try {
+ isSend = false;
+ if (sendTestThread != null) sendTestThread.interrupt();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ super.handleMessage(msg);
+ if (msg.what == 1){
+ tv_message.setText(msg.obj.toString());
+ }
+ }
+ };
+
+
+ /**
+ * 鍙戦�佹祴璇曠嚎绋�
+ */
+ class SendTestThread extends Thread {
+ int sendCount;
+ @Override
+ public void run() {
+ super.run();
+ HDLLog.I("娴嬭瘯鍙戦�佺嚎绋� 寮�鍚�");
+ sendCount = 0;
+ isSend = true;
+ while (isSend && sendCount<count) {
+ try {
+
+ cusSendCommand(LIGHT_CTRL_COMMAND,
+ 1, 10, new byte[]{0x01, 0x00, 0x00, 0x00});
+
+ sendCount++;
+ Message msg = new Message();
+ msg.what = 1;
+ msg.obj = ""+sendCount;
+ handler.sendMessage(msg);
+ Thread.sleep(100);//闂撮殧10 0ms
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ HDLLog.I("error:" + e.getMessage());
+ }
+ }
+ HDLLog.I("娴嬭瘯鍙戦�佺嚎绋� 鍏抽棴");
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/SensorActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/SensorActivity.java
new file mode 100644
index 0000000..a894570
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/SensorActivity.java
@@ -0,0 +1,502 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.hdl.sdk.ttl.HDLAppliances.Config.HDLApConfig;
+import com.hdl.sdk.ttl.HDLAppliances.HDLSensor.DryContactSensorBackEvent;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+import com.hdl.sdk.ttl_sdk.R;
+import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+import com.hdl.sdk.ttl_sdk.utlis.HDLLog;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+public class SensorActivity extends BaseActivity {
+ /**
+ * Topbar
+ */
+ private RelativeLayout topBarBack;
+ private TextView topBarTitle;
+ private Button sensorbtn;
+ private TextView sensorText;
+ private AppliancesInfo appliancesInfo;
+
+
+ /**
+ * 澶嶅啓isRegisterEventBus() 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true
+ *
+ * @return true
+ */
+ @Override
+ protected boolean isRegisterEventBus() {
+ return true;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_sensor);
+ initToolbar();
+ initcurState();
+ initView();
+ initOnClick();
+ displayStateView();
+ //浠庣綉缁滀笂鏌ヨ鍒锋柊涓�娆¤澶囩姸鎬侊紝寰呰皟璇�
+ HDLCommand.getDryContactSensorStateFromNetwork(appliancesInfo);
+ }
+
+ /**
+ * 鍒濆鍖朤oolbar
+ */
+ private void initToolbar() {
+ topBarBack = findViewById(R.id.ll_top_b_left);
+ setViewVisible(topBarBack);
+ topBarTitle = findViewById(R.id.tv_top_b_header_title);
+ topBarBack.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ });
+ }
+
+ private void initcurState() {
+ appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl");
+ String titleStr = appliancesInfo.getRemarks();
+ topBarTitle.setText(titleStr);
+
+ }
+
+ private void initView() {
+ sensorbtn = findViewById(R.id.sensorbtn);
+ sensorText = findViewById(R.id.sensorText);
+
+
+ }
+
+ private void initOnClick() {
+
+ sensorbtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ //浠庣綉缁滀笂鏌ヨ鍒锋柊涓�娆¤澶囩姸鎬侊紝寰呰皟璇�
+ HDLCommand.getDryContactSensorStateFromNetwork(appliancesInfo);
+ }
+ });
+ }
+
+ private void displayStateView() {
+
+ switch (appliancesInfo.getDeviceType()) {
+// case HDLApConfig.TYPE_SENSOR_DRY_CONTACT://2019-07-03 灞忚斀
+// case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR:
+// case HDLApConfig.TYPE_SENSOR_TEMP:
+// case HDLApConfig.TYPE_SENSOR_HUMIDITY:
+// case HDLApConfig.TYPE_SENSOR_ILLUMINACE:
+// case HDLApConfig.TYPE_SENSOR_VOC:
+// case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5:
+// case HDLApConfig.TYPE_SENSOR_C02:
+// case HDLApConfig.TYPE_SENSOR_LPG:
+// case HDLApConfig.TYPE_SENSOR_CO_H2:
+// case HDLApConfig.TYPE_SENSOR_CH4:
+// case HDLApConfig.TYPE_SENSOR_SMOG:
+// case HDLApConfig.TYPE_SENSOR_WIND_SPEED:
+// case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE:
+// case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW:
+// case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE:
+// case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH:
+// case HDLApConfig.TYPE_SENSOR_RAIN_FALL:
+// case HDLApConfig.TYPE_SENSOR_WEIGHT:
+// case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH:
+// case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED:
+// case HDLApConfig.TYPE_SENSOR_SHAKE:
+// case HDLApConfig.TYPE_SENSOR_VOLTAGE:
+// case HDLApConfig.TYPE_SENSOR_ELECTRICITY:
+// case HDLApConfig.TYPE_SENSOR_POWER:
+// case HDLApConfig.TYPE_SENSOR_FLOODING:
+// case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET:
+// case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON:
+
+
+ case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR: //绾㈠鎰熷簲浼犳劅鍣�
+ case HDLApConfig.TYPE_SENSOR_CO_H2: //鐓ゆ皵浼犳劅鍣�
+ case HDLApConfig.TYPE_SENSOR_SMOG: //鐑熼浘浼犳劅鍣�
+ case HDLApConfig.TYPE_SENSOR_FLOODING: //姘存蹈浼犳劅鍣�
+ case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET: //闂ㄧ浼犳劅鍣�
+ case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON://绱ф�ユ寜閽�
+ break;
+ default:
+ finish();//璁惧绫诲瀷涓嶅缁撴潫椤甸潰
+ break;
+ }
+ /**鏍规嵁闇�姹傛槸鍚﹀彂閫佷竴娆¤幏鍙栧埛鏂扮姸鎬佽姹�*/
+ }
+
+
+ /**
+ * 浼犳劅鍣ㄧ姸鎬佸洖璋� Event
+ * 骞茶妭鐐圭姸鎬佷富鍔ㄥ箍鎾� 鍜� 琚姩鏌ヨ鐘舵�佸弽棣�
+ *
+ * @param event
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onDryContactSensorBackEventMain(DryContactSensorBackEvent event) {
+ if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+ && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+ && event.getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum()
+ ) {
+
+ //浼犳劅鍣� 骞叉帴鐐� 銆傚彧鏈夊紑鍏崇姸鎬�
+ if (!event.isSuccess()) {
+ showToast("鑾峰彇浼犳劅鍣ㄧ姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�");
+ return;
+ }
+ String mData = "";
+ if (appliancesInfo.getDeviceType() == HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR) {
+ mData = event.getState() == 0 ? "鏃犲姩闈�" : "鏈夊姩闈�";
+ } else {
+ mData = event.getState() == 0 ? "闂悎" : "鏂紑";
+ }
+
+ sensorText.setText("浼犳劅鍣�---骞叉帴鐐圭姸鎬侊細" + mData);
+// showToast("浼犳劅鍣�---骞叉帴鐐圭姸鎬侊細" + mData);
+ HDLLog.Log("浼犳劅鍣�---骞叉帴鐐圭姸鎬侊細" + mData);
+ }
+ }
+
+
+// /**
+// * 浼犳劅鍣ㄧ姸鎬佸洖璋� Event
+// *
+// * @param event
+// */
+// @Subscribe(threadMode = ThreadMode.MAIN)
+// public void onSensorStateBackInfoMain(SensorStateBackInfo event) {
+// if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID()
+// && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID()
+// && event.getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum()
+// ) {
+// //杩欎釜杩斿洖鐨勪俊鎭槸褰撳墠鐘舵�佺殑
+// switch (event.getAppliancesInfo().getDeviceType()) {
+// case HDLApConfig.TYPE_SENSOR_DRY_CONTACT://2019-07-03 灞忚斀
+// //浼犳劅鍣� 骞叉帴鐐� 銆傚彧鏈夊紑鍏崇姸鎬�
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---骞叉帴鐐圭姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float dryContactValue = (float) event.getAppliancesInfo().getCurState();
+// String dryContactUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---骞叉帴鐐圭姸鎬侊細" + dryContactValue + dryContactUnit);
+// HDLLog.Log("浼犳劅鍣�---骞叉帴鐐圭姸鎬侊細" + dryContactValue + dryContactUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR:
+// //浼犳劅鍣� 绉诲姩鎺㈡祴 銆傜伒鏁忓害
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---绉诲姩鎺㈡祴鐏垫晱搴︾姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float mdValue = (float) event.getAppliancesInfo().getCurState();
+// String mdValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---绉诲姩鎺㈡祴鐏垫晱搴︼細" + mdValue + mdValueUnit);
+// HDLLog.Log("浼犳劅鍣�---绉诲姩鎺㈡祴鐏垫晱搴︼細" + mdValue + mdValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_TEMP:
+// //浼犳劅鍣� 娓╁害
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---娓╁害鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float tempValue = (float) event.getAppliancesInfo().getCurState();
+// String tempValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---娓╁害锛�" + tempValue + tempValueUnit);
+// HDLLog.Log("浼犳劅鍣�---娓╁害锛�" + tempValue + tempValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_HUMIDITY:
+// //浼犳劅鍣� 婀垮害
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---婀垮害鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float humidityValue = (float) event.getAppliancesInfo().getCurState();
+// String humidityValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---婀垮害锛�" + humidityValue + humidityValueUnit);
+// HDLLog.Log("浼犳劅鍣�---婀垮害锛�" + humidityValue + humidityValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_ILLUMINACE:
+// //浼犳劅鍣� 鐓у害
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---鐓у害鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float illuminaceValue = (float) event.getAppliancesInfo().getCurState();
+// String illuminaceValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---鐓у害锛�" + illuminaceValue + illuminaceValueUnit);
+// HDLLog.Log("浼犳劅鍣�---鐓у害锛�" + illuminaceValue + illuminaceValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_VOC:
+// //浼犳劅鍣� 褰撳墠绌烘皵璐ㄩ噺绛夌骇
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---褰撳墠绌烘皵璐ㄩ噺绛夌骇鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float vocValue = (float) event.getAppliancesInfo().getCurState();
+// String vocValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---褰撳墠绌烘皵璐ㄩ噺绛夌骇锛�" + vocValue + vocValueUnit);
+// HDLLog.Log("浼犳劅鍣�---褰撳墠绌烘皵璐ㄩ噺绛夌骇锛�" + vocValue + vocValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5:
+// //浼犳劅鍣� pm2.5
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---pm2.5鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float pm2_5Value = (float) event.getAppliancesInfo().getCurState();
+// String pm2_5ValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---pm2.5锛�" + pm2_5Value + pm2_5ValueUnit);
+// HDLLog.Log("浼犳劅鍣�---pm2.5锛�" + pm2_5Value + pm2_5ValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_C02:
+// //浼犳劅鍣� 浜屾哀鍖栫⒊
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---浜屾哀鍖栫⒊鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float co2Value = (float) event.getAppliancesInfo().getCurState();
+// String co2ValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---浜屾哀鍖栫⒊锛�" + co2Value + co2ValueUnit);
+// HDLLog.Log("浼犳劅鍣�---浜屾哀鍖栫⒊锛�" + co2Value + co2ValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_LPG:
+// //浼犳劅鍣� 娑插寲鐭虫补姘�
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---娑插寲鐭虫补姘旂姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float lpgValue = (float) event.getAppliancesInfo().getCurState();
+// String lpgValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---娑插寲鐭虫补姘旓細" + lpgValue + lpgValueUnit);
+// HDLLog.Log("浼犳劅鍣�---娑插寲鐭虫补姘旓細" + lpgValue + lpgValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_CO_H2:
+// //浼犳劅鍣� 浜哄伐鐓ゆ皵
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---浜哄伐鐓ゆ皵鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float coh2Value = (float) event.getAppliancesInfo().getCurState();
+// String coh2ValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---浜哄伐鐓ゆ皵锛�" + coh2Value + coh2ValueUnit);
+// HDLLog.Log("浼犳劅鍣�---浜哄伐鐓ゆ皵锛�" + coh2Value + coh2ValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_CH4:
+// //浼犳劅鍣� 澶╃劧姘�
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---澶╃劧姘旂姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float ch4Value = (float) event.getAppliancesInfo().getCurState();
+// String ch4ValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---澶╃劧姘旓細" + ch4Value + ch4ValueUnit);
+// HDLLog.Log("浼犳劅鍣�---澶╃劧姘旓細" + ch4Value + ch4ValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_SMOG:
+// //浼犳劅鍣� 鐑熼浘
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---鐑熼浘鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float smogValue = (float) event.getAppliancesInfo().getCurState();
+// String smogValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---鐑熼浘锛�" + smogValue + smogValueUnit);
+// HDLLog.Log("浼犳劅鍣�---鐑熼浘锛�" + smogValue + smogValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_WIND_SPEED:
+// //浼犳劅鍣� 椋庨��
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---椋庨�熺姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float windSpeedValue = (float) event.getAppliancesInfo().getCurState();
+// String windSpeedValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---椋庨�燂細" + windSpeedValue + windSpeedValueUnit);
+// HDLLog.Log("浼犳劅鍣�---椋庨�燂細" + windSpeedValue + windSpeedValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE:
+// //浼犳劅鍣� 椋庡帇
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---椋庡帇鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float windPressureValue = (float) event.getAppliancesInfo().getCurState();
+// String windPressureValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---椋庡帇锛�" + windPressureValue + windPressureValueUnit);
+// HDLLog.Log("浼犳劅鍣�---椋庡帇锛�" + windPressureValue + windPressureValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW:
+// //浼犳劅鍣� 娑蹭綋娴侀噺
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---娑蹭綋娴侀噺鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float liquidFlowValue = (float) event.getAppliancesInfo().getCurState();
+// String liquidFlowValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---娑蹭綋娴侀噺锛�" + liquidFlowValue + liquidFlowValueUnit);
+// HDLLog.Log("浼犳劅鍣�---娑蹭綋娴侀噺锛�" + liquidFlowValue + liquidFlowValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE:
+// //浼犳劅鍣� 娑蹭綋鍘嬪姏
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---娑蹭綋鍘嬪姏鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float liquidPressureValue = (float) event.getAppliancesInfo().getCurState();
+// String liquidPressureValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---娑蹭綋鍘嬪姏锛�" + liquidPressureValue + liquidPressureValueUnit);
+// HDLLog.Log("浼犳劅鍣�---娑蹭綋鍘嬪姏锛�" + liquidPressureValue + liquidPressureValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH:
+// //浼犳劅鍣� 娑蹭綋娣卞害
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---娑蹭綋娣卞害鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float liquidDepthValue = (float) event.getAppliancesInfo().getCurState();
+// String liquidDepthValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---娑蹭綋娣卞害锛�" + liquidDepthValue + liquidDepthValueUnit);
+// HDLLog.Log("浼犳劅鍣�---娑蹭綋娣卞害锛�" + liquidDepthValue + liquidDepthValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_RAIN_FALL:
+// //浼犳劅鍣� 闆ㄩ噺
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---闆ㄩ噺鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float rainFallValue = (float) event.getAppliancesInfo().getCurState();
+// String rainFallValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---闆ㄩ噺锛�" + rainFallValue + rainFallValueUnit);
+// HDLLog.Log("浼犳劅鍣�---闆ㄩ噺锛�" + rainFallValue + rainFallValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_WEIGHT:
+// //浼犳劅鍣� 閲嶉噺
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---閲嶉噺鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float weightValue = (float) event.getAppliancesInfo().getCurState();
+// String weightValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---閲嶉噺锛�" + weightValue + weightValueUnit);
+// HDLLog.Log("浼犳劅鍣�---閲嶉噺锛�" + weightValue + weightValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_HEIGHT_LENGTH:
+// //浼犳劅鍣� 閲嶉噺
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---閲嶉噺鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float height_lengthValue = (float) event.getAppliancesInfo().getCurState();
+// String height_lengthValueUnit = ((SensorStateBackInfo) event).getUnite();
+// showToast("浼犳劅鍣�---閲嶉噺锛�" + height_lengthValue + height_lengthValueUnit);
+// HDLLog.Log("浼犳劅鍣�---閲嶉噺锛�" + height_lengthValue + height_lengthValueUnit);
+// break;
+// case HDLApConfig.TYPE_SENSOR_OBJECT_SPEED:
+// //浼犳劅鍣� 鐗╀綋閫熷害
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---鐗╀綋閫熷害鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float objectSpeedValue = (float) event.getAppliancesInfo().getCurState();
+// String objectSpeedUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣�
+// showToast("浼犳劅鍣�---鐗╀綋閫熷害锛�" + objectSpeedValue + objectSpeedUnite);
+// HDLLog.Log("浼犳劅鍣�---鐗╀綋閫熷害锛�" + objectSpeedValue + objectSpeedUnite);
+// break;
+// case HDLApConfig.TYPE_SENSOR_SHAKE:
+// //浼犳劅鍣� 闇囧姩
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---闇囧姩鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float shakeValue = (float) event.getAppliancesInfo().getCurState();
+// String shakeValueUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣�
+// showToast("浼犳劅鍣�---闇囧姩锛�" + shakeValue + shakeValueUnite);
+// HDLLog.Log("浼犳劅鍣�---闇囧姩锛�" + shakeValue + shakeValueUnite);
+// break;
+// case HDLApConfig.TYPE_SENSOR_VOLTAGE:
+// //浼犳劅鍣� 鐢靛帇
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---鐢靛帇鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float voltageValue = (float) event.getAppliancesInfo().getCurState();
+// String voltageValueUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣�
+// showToast("浼犳劅鍣�---鐢靛帇锛�" + voltageValue + voltageValueUnite);
+// HDLLog.Log("浼犳劅鍣�---鐢靛帇锛�" + voltageValue + voltageValueUnite);
+// break;
+// case HDLApConfig.TYPE_SENSOR_ELECTRICITY:
+// //浼犳劅鍣� 鐢垫祦
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---鐢垫祦鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float electricityValue = (float) event.getAppliancesInfo().getCurState();
+// String electricityValueUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣�
+// showToast("浼犳劅鍣�---鐢垫祦锛�" + electricityValue + electricityValueUnite);
+// HDLLog.Log("浼犳劅鍣�---鐢垫祦锛�" + electricityValue + electricityValueUnite);
+// break;
+// case HDLApConfig.TYPE_SENSOR_POWER:
+// //浼犳劅鍣� 鍔熺巼
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---鍔熺巼鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float powerValue = (float) event.getAppliancesInfo().getCurState();
+// String powerValueUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣�
+// showToast("浼犳劅鍣�---鍔熺巼锛�" + powerValue + powerValueUnite);
+// HDLLog.Log("浼犳劅鍣�---鍔熺巼锛�" + powerValue + powerValueUnite);
+// break;
+// case HDLApConfig.TYPE_SENSOR_FLOODING:
+// //浼犳劅鍣� 姘存蹈
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---姘存蹈鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float floodingValue = (float) event.getAppliancesInfo().getCurState();
+// String floodingValueUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣�
+// showToast("浼犳劅鍣�---姘存蹈锛�" + floodingValue + floodingValueUnite);
+// HDLLog.Log("浼犳劅鍣�---姘存蹈锛�" + floodingValue + floodingValueUnite);
+// break;
+// case HDLApConfig.TYPE_SENSOR_DOOR_MAGNET:
+// //浼犳劅鍣� 闂ㄧ绐楃
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---闂ㄧ绐楃鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float doorMagnetValue = (float) event.getAppliancesInfo().getCurState();
+// String doorMagnetValueUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣�
+// showToast("浼犳劅鍣�---闂ㄧ绐楃锛�" + doorMagnetValue + doorMagnetValueUnite);
+// HDLLog.Log("浼犳劅鍣�---闂ㄧ绐楃锛�" + doorMagnetValue + doorMagnetValueUnite);
+// break;
+// case HDLApConfig.TYPE_SENSOR_EMERGENCY_BUTTON:
+// //浼犳劅鍣� 绱ф�ユ寜閽�
+// if (!event.isSuccess()) {
+// showToast("鑾峰彇浼犳劅鍣�---绱ф�ユ寜閽姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�");
+// return;
+// }
+// float emergencyButtonValue = (float) event.getAppliancesInfo().getCurState();
+// String emergencyButtonUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣�
+// showToast("浼犳劅鍣�---绱ф�ユ寜閽細" + emergencyButtonValue + emergencyButtonUnite);
+// HDLLog.Log("浼犳劅鍣�---绱ф�ユ寜閽細" + emergencyButtonValue + emergencyButtonUnite);
+// break;
+//
+//
+// }
+// }
+// }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/SettingActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/SettingActivity.java
new file mode 100644
index 0000000..af8f39f
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/SettingActivity.java
@@ -0,0 +1,108 @@
+package com.hdl.sdk.ttl_sdk.activity;
+
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.Crc;
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+import com.hdl.sdk.ttl.Utils.SPUtils.SPUtils;
+import com.hdl.sdk.ttl_sdk.R;
+import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+
+
+/**
+ * Created by JLChen on 2019/6/28
+ * 褰撳墠APP璁惧瀛愮綉鍙峰拰璁惧鍙烽厤缃紝鏍规嵁闇�瑕侀厤缃�
+ */
+public class SettingActivity extends BaseActivity {
+ /**Topbar*/
+ private RelativeLayout topBarBack;
+ private TextView topBarTitle;
+ //褰撳墠APP璁惧瀛愮綉鍙峰拰璁惧鍙烽厤缃�
+ private EditText subnetIDEditText;
+ private EditText deviceIDEditText;
+ private Button saveButton;
+ //褰撳墠APP璁惧璁惧鍙�
+ private String strSubnetID = "254";
+ private String strDeviceID = "88";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_setting);
+ initToolbar();
+ initView();
+ setOnClick();
+ initData();
+ }
+
+ /**
+ * 鍒濆鍖朤oolbar
+ */
+ private void initToolbar() {
+ topBarBack = findViewById(R.id.ll_top_b_left);
+ setViewVisible(topBarBack);
+ topBarTitle = findViewById(R.id.tv_top_b_header_title);
+ topBarBack.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ });
+ topBarTitle.setText("淇敼瀛愮綉鍙峰拰璁惧鍙�");
+ }
+
+ private void initView() {
+ subnetIDEditText = findViewById(R.id.et_subnetID);
+ deviceIDEditText = findViewById(R.id.et_deviceID);
+ saveButton = findViewById(R.id.btn_save);
+ }
+
+
+ private void setOnClick() {
+ saveButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ saveSubnetAndDeviceID();
+ }
+ });
+ }
+
+ private void initData() {
+ strSubnetID = SPUtils.getParam(this, SPUtils.KEY_SUB_ID, SPUtils.DEFAULT_SUB_ID).toString();
+ strDeviceID = SPUtils.getParam(this, SPUtils.KEY_DEVICE_ID, SPUtils.DEFAULT_DEVICE_ID).toString();
+
+ subnetIDEditText.setText(strSubnetID);
+ deviceIDEditText.setText(strDeviceID);
+ }
+
+
+ //鏈湴瀛愮綉鍙枫�佽澶囧彿 鑼冨洿0 - 254
+ private void saveSubnetAndDeviceID() {
+ strSubnetID = subnetIDEditText.getText().toString();
+ strDeviceID = deviceIDEditText.getText().toString();
+ if (TextUtils.isEmpty(strSubnetID) || TextUtils.isEmpty(strDeviceID)) {
+ showToast("ID涓嶈兘涓虹┖");
+ } else {
+ int mSubnetID = Integer.parseInt(strSubnetID);
+ int mDeviceID = Integer.parseInt(strDeviceID);
+
+
+ if (HDLCommand.saveSubnetAndDeviceID(this, mSubnetID, mDeviceID)) {
+ showToast("淇濆瓨鎴愬姛");
+ finish();
+ } else {
+ showToast("淇濆瓨澶辫触");
+ }
+
+ }
+
+ }
+
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/ZigbeeActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/ZigbeeActivity.java
new file mode 100644
index 0000000..b373250
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/activity/ZigbeeActivity.java
@@ -0,0 +1,384 @@
+//package com.hdl.sdk.ttl_sdk.activity;
+//
+//import android.support.v7.app.AppCompatActivity;
+//import android.os.Bundle;
+//import android.text.TextUtils;
+//import android.view.View;
+//import android.widget.Button;
+//import android.widget.RelativeLayout;
+//import android.widget.TextView;
+//
+//import com.hdl.sdk.ttl.Config.MCUConstants;
+//import com.hdl.sdk.ttl.HDLDeviceManger.Core.Crc;
+//import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+//import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.EventCode;
+//import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.MCUFeedBackEvent;
+//import com.hdl.sdk.ttl.Utils.HDLUtlis.HDLStringUtils;
+//import com.hdl.sdk.ttl_sdk.R;
+//import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+//import com.hdl.sdk.ttl_sdk.utlis.HDLLog;
+//
+//import org.greenrobot.eventbus.Subscribe;
+//import org.greenrobot.eventbus.ThreadMode;
+//import org.json.JSONException;
+//import org.json.JSONObject;
+//
+//import java.util.Timer;
+//import java.util.TimerTask;
+//
+//public class ZigbeeActivity extends BaseActivity {
+// /**
+// * Topbar
+// */
+// private RelativeLayout topBarBack;
+// private TextView topBarTitle;
+// private Button btn_PassThrough, btn_PassThrough_close;
+// private TextView tv_other_mes;
+// private Button btn_close;
+// private Button btn_open_switch2;
+//
+//
+// /**
+// * 澶嶅啓isRegisterEventBus() 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true
+// *
+// * @return true
+// */
+// @Override
+// protected boolean isRegisterEventBus() {
+// return true;
+// }
+//
+// @Override
+// protected void onCreate(Bundle savedInstanceState) {
+// super.onCreate(savedInstanceState);
+// setContentView(R.layout.activity_zigbee);
+// initToolbar();
+// initView();
+// initOnClick();
+// getJson();
+// }
+//
+//
+//
+// /**
+// * 鍒濆鍖朤oolbar
+// */
+// private void initToolbar() {
+// topBarBack = findViewById(R.id.ll_top_b_left);
+// setViewVisible(topBarBack);
+// topBarTitle = findViewById(R.id.tv_top_b_header_title);
+// topBarBack.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// finish();
+// }
+// });
+// topBarTitle.setText("Zigbee璋冭瘯");
+// }
+//
+// /**
+// * initView
+// */
+// private void initView() {
+// btn_PassThrough = findViewById(R.id.btn_PassThrough);
+// btn_PassThrough_close = findViewById(R.id.btn_PassThrough_close);
+// tv_other_mes = findViewById(R.id.tv_other_mes);
+//
+// btn_close = findViewById(R.id.btn_close);
+// btn_open_switch2 = findViewById(R.id.btn_close);
+// }
+//
+// /**
+// * initOnClick
+// */
+// private void initOnClick() {
+// btn_PassThrough.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// startSendHeartPacketTimer();
+//
+// }
+// });
+//
+// btn_PassThrough_close.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// setHDLPassThroughOpen(false);
+// tv_other_mes.setText("鍏抽棴閫忎紶");
+//
+// }
+// });
+//
+// btn_close.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// cancelTimer();
+// }
+// });
+//
+// }
+//
+// /**
+// * 2019-8-9
+// * 鍙戦�侀�忎紶鍙傛暟
+// * 閫忎紶鏁版嵁锛屼笉璧癰us鍗忚锛岀洿鎺ヨ浆鍙戯紝涓嶅仛鏁版嵁鏍煎紡澶勭悊
+// * mcuSendTransparentData鎺ュ彛璋冪敤涓�娆′互鍚庯紝榛樿鎵�鏈夋帴鏀舵暟鎹蛋閫忎紶
+// * 鍙互璋冪敤setHDLPassThroughOpen鍏抽棴閫忎紶鏁版嵁
+// */
+// private void mcuSendTransparentData() {
+// startSendHeartPacketTimer();
+// }
+//
+// /**
+// * 璁剧疆鏄惁寮�鍚�忎紶鏁版嵁
+// * 瑕佹兂鐩存帴鎺ユ敹閫忎紶鏁版嵁锛岀洿鎺ヨ皟鐢ㄨ繖涓帴鍙f墦寮�灏卞彲浠ワ紝涓嶈蛋bus鍗忚澶勭悊
+// * 涓嶆兂閫忎紶鐨勮瘽锛岃璁板緱璁剧疆鍥炲叧闂姸鎬�
+// */
+// private void setHDLPassThroughOpen(Boolean bOpen){
+//
+// HDLCommand.setHDLPassThroughOpen(bOpen);
+//
+// }
+//
+//
+// private int DeviceType = 0x6666;
+// private int Command1002 = 0x1002;
+// private int CommandHeartbeat = 0x2000;
+// private int DeviceID = 0x01;
+// private int sendCount = 0;//鍙戦�佸簭鍒楀彿
+// /**
+// * @return
+// */
+// private byte[] GetHeartbeatBytes() {
+// sendCount++;
+// if(sendCount > 254){
+// sendCount = 0;
+// }
+// byte[] crcBytes = new byte[13];
+// byte[] sendBytes = new byte[2 + crcBytes.length];
+// //Boot code
+// sendBytes[0] = (byte) 0xAA;
+// sendBytes[1] = (byte) 0xAA;
+// crcBytes[0] = (byte) (crcBytes.length / 256);
+// crcBytes[1] = (byte) (crcBytes.length % 256);
+// crcBytes[2] = (byte) 0x01;
+// crcBytes[3] = (byte) 0x01;
+// crcBytes[4] = (byte) (DeviceType / 256);
+// crcBytes[5] = (byte) (DeviceType % 256);
+// crcBytes[6] = (byte) (CommandHeartbeat / 256);
+// crcBytes[7] = (byte) (CommandHeartbeat % 256);
+// crcBytes[8] = (byte) 0x02;
+// crcBytes[9] = (byte) 0x02;
+// crcBytes[10] = (byte) sendCount;
+//
+// Crc.ConCRC(crcBytes, crcBytes.length - 2);
+// System.arraycopy(crcBytes, 0, sendBytes, 2, crcBytes.length);
+// return sendBytes;
+// }
+//
+// /**
+// * @return
+// */
+// private byte[] GetSendBytes(byte[] addBytes, int mCommand) {
+// sendCount++;
+// if(sendCount > 254){
+// sendCount = 0;
+// }
+//
+// byte[] crcBytes = new byte[15 + addBytes.length];
+// byte[] sendBytes = new byte[2 + crcBytes.length];
+// //Boot code
+// sendBytes[0] = (byte) 0xAA;
+// sendBytes[1] = (byte) 0xAA;
+// crcBytes[0] = (byte) (crcBytes.length / 256);
+// crcBytes[1] = (byte) (crcBytes.length % 256);
+// crcBytes[2] = (byte) 0x01;
+// crcBytes[3] = (byte) 0x01;
+// crcBytes[4] = (byte) (DeviceType / 256);
+// crcBytes[5] = (byte) (DeviceType % 256);
+// crcBytes[6] = (byte) (mCommand / 256);
+// crcBytes[7] = (byte) (mCommand % 256);
+// crcBytes[8] = (byte) 0x02;
+// crcBytes[9] = (byte) 0x02;
+// crcBytes[10] = (byte) sendCount;
+// crcBytes[11] = (byte) (addBytes.length / 256);
+// crcBytes[12] = (byte) (addBytes.length % 256);
+// System.arraycopy(addBytes, 0, crcBytes, 13, addBytes.length);
+// Crc.ConCRC(crcBytes, crcBytes.length - 2);
+// System.arraycopy(crcBytes, 0, sendBytes, 2, crcBytes.length);
+// return sendBytes;
+// }
+//
+//
+//
+// // private int HeartData = 0x2000;
+//// private byte[] HeartDataBytes = {(byte) (HeartData / 256),(byte) (HeartData % 256) };
+// private String sendDataStr = "";
+//
+//
+// private boolean bFrist = true;
+// private void SendHeartPacket(){
+//// if(sendCount > 4){
+//// cancelTimer();
+//// return;
+//// }
+//
+// byte[] sendBytes = GetHeartbeatBytes();
+// HDLCommand.mcuSendTransparentData(sendBytes);
+// if(bFrist){
+// bFrist = false;
+// bBeginSendData = true;
+// }
+// }
+//
+// private void SendGetDeviceList(){
+// byte[] bytes = sendDataStr.getBytes();
+// byte[] sendBytes = GetSendBytes(bytes, Command1002 );
+// HDLCommand.mcuSendTransparentData(sendBytes);
+//
+// }
+//
+//
+// private boolean bGetData = false;
+// private boolean bBeginSendData = false;
+// // 瀹氭椂鍣�
+// private Timer mTimer = new Timer();
+// // 瀹氭椂浠诲姟
+// private MyTimerTask mTask;
+//
+// class MyTimerTask extends TimerTask{
+// @Override
+// public void run() {
+// // TODO Auto-generated method stub
+// // 瑕佸仛鐨勪簨鎯�
+// if(!bGetData) {
+// if(bBeginSendData){
+// SendGetDeviceList();
+// bBeginSendData = false;
+//
+// }else {
+//
+// SendHeartPacket();
+// }
+// }
+// }
+//
+// }
+//
+// private void startSendHeartPacketTimer(){
+//
+// if(mTimer == null){
+// mTimer = new Timer();
+// }
+// if(mTask != null){
+// mTask.cancel();
+//
+// }
+// mTask = new MyTimerTask();
+// mTimer.schedule(mTask, 200, 500);
+// }
+//
+// private void cancelTimer() {
+// if (mTimer != null) {
+// mTask.cancel();
+// mTimer.cancel();
+// mTimer = null;
+//
+// }
+// }
+//
+// /**
+// * ***********************************************************澶勭悊MCU鍥炲鏁版嵁***********************************************************
+// */
+// /**
+// * MCU鎺у埗鍥炶皟Event
+// *
+// * @param event
+// */
+// @Subscribe(threadMode = ThreadMode.MAIN)
+// public void onMCUFeedBackEventMain(MCUFeedBackEvent event) {
+// if (event.getEventCode() == EventCode.FAILURE_TIMEOUT) {
+// if (TextUtils.isEmpty(event.getError())) {
+// showToast("MCU璇锋眰瓒呮椂锛岃绋嶅悗鍐嶈瘯");
+// } else {
+// showToast(event.getError());
+// }
+// return;
+// }
+//
+// switch (event.getMCUDataBean().command) {
+// case MCUConstants.MCU_COMMAND_SEND_BACK: //
+// //閫忎紶杩斿洖鐨勬暟鎹�
+// handleMCUPassThroughDataBack(event);
+// break;
+// default:
+// break;
+// }
+// }
+//
+//
+// /**
+// * 澶勭悊MCU閫忎紶鍥炶皟鏁版嵁
+// * 閫忎紶鏁版嵁锛屼笉璧癰us鍗忚锛岀洿鎺ヨ浆鍙戯紝涓嶅仛鏁版嵁鏍煎紡澶勭悊
+// *
+// * @param event
+// */
+// private void handleMCUPassThroughDataBack(MCUFeedBackEvent event) {
+// if (event.getEventCode() != EventCode.SUCCESS) {
+// tv_other_mesSetText("MCU閫忎紶鏁版嵁鍑洪敊锛岃繑鍥炴暟鎹紓甯�");
+// return;
+// }
+// String receiveString = HDLStringUtils.ByteArrToHex(event.getMCUDataBean().receiveBytes, 0, event.getMCUDataBean().receiveBytes.length);
+//
+// tv_other_mes.append("GET: "+receiveString + "\n");
+//// tv_other_mes.setText("鏀跺埌鐨勯�忎紶鏁版嵁锛�" + receiveString);
+// HDLLog.Log("鏀跺埌鐨勯�忎紶鏁版嵁锛�" + receiveString);
+// }
+//
+// private void tv_other_mesSetText(String mes) {
+// tv_other_mes.setText(mes);
+// showToast(mes);
+// }
+//
+//
+// @Override
+// protected void onDestroy() {
+// super.onDestroy();
+// cancelTimer();
+// }
+//
+//// private class ZIGBEECommand{
+//// private int Cluster_ID = 0;
+//// private int Command = 93;
+//// private ZIGBEECommand(int Cluster_ID, int Command){
+//// this.Cluster_ID = Cluster_ID;
+//// this.Command = Command;
+//// }
+//// }
+//
+// private void getJson(){
+// try {
+// JSONObject jsonObject = new JSONObject();
+// jsonObject.put("Cluster_ID", 0);
+// jsonObject.put("Command", 93);
+// HDLLog.Log("getJson锛�" + jsonObject.toString());
+// sendDataStr = jsonObject.toString();
+//
+// } catch (JSONException e) {
+// e.printStackTrace();
+// }
+// }
+//
+//
+//// /**
+//// * 澶勭悊HDL Data
+//// *
+//// * @param receiveBytes
+//// */
+//// private void HandleMCUdata(byte[] receiveBytes) {
+//// if (receiveBytes.length < 5) {
+//// return;
+//// }
+////
+//// }
+//}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/adapter/HDLAppliancesListAdapter.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/adapter/HDLAppliancesListAdapter.java
new file mode 100644
index 0000000..215fb63
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/adapter/HDLAppliancesListAdapter.java
@@ -0,0 +1,128 @@
+package com.hdl.sdk.ttl_sdk.adapter;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.hdl.sdk.ttl.Config.Configuration;
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl_sdk.R;
+import com.hdl.sdk.ttl_sdk.activity.AppliancesListActivity;
+import com.hdl.sdk.ttl_sdk.activity.CtrlActivity;
+import com.hdl.sdk.ttl_sdk.activity.CtrlAirActivity;
+import com.hdl.sdk.ttl_sdk.activity.CtrlAudioActivity;
+import com.hdl.sdk.ttl_sdk.activity.CtrlCurtainActivity;
+import com.hdl.sdk.ttl_sdk.activity.CtrlLightActivity;
+import com.hdl.sdk.ttl_sdk.activity.CtrlLogicActivity;
+import com.hdl.sdk.ttl_sdk.utlis.HDLUtlis;
+
+import java.util.List;
+
+/**
+ * Created by JLChen on 2019/7/4
+ */
+public class HDLAppliancesListAdapter extends RecyclerView.Adapter<HDLAppliancesListAdapter.HDLViewHolder> {
+
+ private Context mContext;
+ private List<AppliancesInfo> mAppliancesInfoList;
+ private OnItemClickLitener mOnItemClickLitener;
+
+
+ public HDLAppliancesListAdapter(Context context, List<AppliancesInfo> mmAppliancesInfoList){
+ this.mContext = context;
+ this.mAppliancesInfoList = mmAppliancesInfoList;
+ }
+
+ @NonNull
+ @Override
+ public HDLViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ View view = LayoutInflater.from(mContext).inflate(R.layout.list_item_appliances, parent, false);
+ return new HDLViewHolder(view);
+ }
+
+ @Override
+ public void onBindViewHolder(final HDLViewHolder holder, final int position) {
+ AppliancesInfo mAppliancesInfo = mAppliancesInfoList.get(position);
+ String mName = mAppliancesInfo.getRemarks();
+ if (TextUtils.isEmpty(mName) || mName.equals(HDLUtlis.REMAEK_NULL)) {
+ mName = "澶囨敞涓虹┖";
+ }
+ holder.mTextView.setText(mName);
+ if(mOnItemClickLitener != null){
+ holder.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+// int pos = holder.getLayoutPosition();
+ mOnItemClickLitener.onItemClick( position);
+ }
+ });
+ }
+
+ String mMes = "鍥炶矾鍙凤細" + mAppliancesInfo.getChannelNum();
+ holder.mTextView_mes.setText(mMes);
+
+ holder.mImageView.setVisibility(View.VISIBLE);
+ int mBigType = mAppliancesInfo.getBigType();
+ switch (mBigType) {
+ case Configuration.LIGTH_BIG_TYPE:
+ //鐏厜妯″潡
+ holder.mImageView.setBackgroundResource(R.mipmap.ic_item_light);
+ break;
+ case Configuration.CURTAIN_BIG_TYPE:
+ //绐楀笜妯″潡
+ holder.mImageView.setBackgroundResource(R.mipmap.ic_item_curtain);
+ break;
+ case Configuration.AIR_BIG_TYPE:
+ //绌鸿皟妯″潡
+ holder.mImageView.setBackgroundResource(R.mipmap.ic_item_air);
+ break;
+ case Configuration.LOGIC_BIG_TYPE:
+ //閫昏緫妯″潡
+ holder.mImageView.setBackgroundResource(R.mipmap.ic_item_logic);
+ break;
+ case Configuration.AUDIO_BIG_TYPE:
+ //澶х被鏄煶涔愮被鍒欒烦杞埌AudioActivity
+ holder.mImageView.setBackgroundResource(R.mipmap.ic_item_audio);
+ break;
+ default:
+ holder.mImageView.setVisibility(View.GONE);
+ break;
+ }
+
+
+ }
+
+ @Override
+ public int getItemCount() {
+ return mAppliancesInfoList.size();
+ }
+
+ public static class HDLViewHolder extends RecyclerView.ViewHolder{
+
+ private TextView mTextView;
+ private TextView mTextView_mes;
+ private ImageView mImageView;
+
+ public HDLViewHolder(View itemView) {
+ super(itemView);
+ mTextView = (TextView) itemView.findViewById(R.id.tv_device);
+ mImageView = itemView.findViewById(R.id.im_device);
+ mTextView_mes = itemView.findViewById(R.id.tv_device_message);
+ }
+ }
+
+
+ public interface OnItemClickLitener{
+ void onItemClick(int position);
+ }
+
+ public void setOnItemClickLitener(OnItemClickLitener onItemClickLitener){
+ this.mOnItemClickLitener = onItemClickLitener;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/adapter/HDLMainListAdapter.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/adapter/HDLMainListAdapter.java
new file mode 100644
index 0000000..ef33d06
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/adapter/HDLMainListAdapter.java
@@ -0,0 +1,85 @@
+package com.hdl.sdk.ttl_sdk.adapter;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo;
+import com.hdl.sdk.ttl_sdk.R;
+
+import java.util.List;
+
+/**
+ * Created by JLChen on 2019/7/4
+ */
+public class HDLMainListAdapter extends RecyclerView.Adapter<HDLMainListAdapter.HDLViewHolder> {
+
+ private Context mContext;
+ private List<String> mList;
+ private OnItemClickLitener mOnItemClickLitener;
+
+ public HDLMainListAdapter(Context context, List<String> mmList){
+ this.mContext = context;
+ this.mList = mmList;
+ }
+
+ @NonNull
+ @Override
+ public HDLViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ View view = LayoutInflater.from(mContext).inflate(R.layout.list_item_device_list, parent, false);
+ return new HDLViewHolder(view);
+ }
+
+ @Override
+ public void onBindViewHolder(final HDLViewHolder holder, final int position) {
+
+ holder.mTextView.setText(mList.get(position));
+ if(mOnItemClickLitener != null){
+ holder.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+// int pos = holder.getLayoutPosition();
+ mOnItemClickLitener.onItemClick( position);
+ }
+ });
+
+ holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View view) {
+ mOnItemClickLitener.onItemLongClick( position);
+ return true;
+ }
+ });
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return mList.size();
+ }
+
+ public static class HDLViewHolder extends RecyclerView.ViewHolder{
+
+ private TextView mTextView;
+
+ public HDLViewHolder(View itemView) {
+ super(itemView);
+ mTextView = (TextView) itemView.findViewById(R.id.tv_device);
+ }
+ }
+
+
+ public interface OnItemClickLitener{
+ void onItemClick(int position);
+ void onItemLongClick(int position);
+ }
+
+ public void setOnItemClickLitener(OnItemClickLitener onItemClickLitener){
+ this.mOnItemClickLitener = onItemClickLitener;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/base/BaseActivity.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/base/BaseActivity.java
new file mode 100644
index 0000000..98a8fd7
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/base/BaseActivity.java
@@ -0,0 +1,99 @@
+package com.hdl.sdk.ttl_sdk.base;
+
+import android.content.Intent;
+import android.content.res.TypedArray;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.View;
+import android.widget.Toast;
+
+import com.hdl.sdk.ttl_sdk.R;
+
+import org.greenrobot.eventbus.EventBus;
+
+/**
+ * Created by JLChen on 2019/7/4
+ */
+public class BaseActivity extends AppCompatActivity {
+ private static final String TAG = "BaseActivity";
+// protected Toolbar mToolBar;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ initEventBusRegister();
+
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ unEventBusRegister();
+ }
+
+// // 鎶借薄 - 鍒濆鍖栨柟娉曪紝鍙互瀵规暟鎹繘琛屽垵濮嬪寲
+// protected abstract void initView();
+
+ /**
+ * 鏄惁娉ㄥ唽浜嬩欢鍒嗗彂
+ *
+ * @return true缁戝畾EventBus浜嬩欢鍒嗗彂锛岄粯璁や笉缁戝畾锛屽瓙绫婚渶瑕佺粦瀹氱殑璇濆鍐欐鏂规硶杩斿洖true.
+ */
+ protected boolean isRegisterEventBus() {
+ return false;
+ }
+
+ /**
+ * 娉ㄥ唽浜嬩欢鍒嗗彂鍒濆鍖�
+ */
+ private void initEventBusRegister() {
+ if (isRegisterEventBus()) {
+ if (!EventBus.getDefault().isRegistered(this)) {
+ EventBus.getDefault().register(this);
+ }
+ }
+ }
+
+ /**
+ * 娉ㄥ唽浜嬩欢鍒嗗彂鍙嶅鍖�
+ */
+ private void unEventBusRegister() {
+ if (isRegisterEventBus()) {
+ EventBus.getDefault().unregister(this);
+ }
+ }
+
+// protected void initToolbar() {
+// if (mToolBar == null) {
+// mToolBar = (Toolbar) findViewById(R.id.toolbar_view_b);
+// if (mToolBar == null) {
+//
+// } else {
+//
+// }
+// }
+// }
+
+ public void showToast(String text) {
+ Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
+ }
+
+ public void startActivity(Class<?> clazz) {
+ Intent intent = new Intent(this, clazz);
+ startActivity(intent);
+ }
+
+ public static void setViewVisible(View view) {
+ if (view.getVisibility() != View.VISIBLE) {
+ view.setVisibility(View.VISIBLE);
+ }
+ }
+
+ public static void setViewGone(View view) {
+ if (view.getVisibility() != View.GONE) {
+ view.setVisibility(View.GONE);
+ }
+ }
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeCommand.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeCommand.java
new file mode 100644
index 0000000..2cca419
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeCommand.java
@@ -0,0 +1,109 @@
+package com.hdl.sdk.ttl_sdk.bean;
+
+import com.hdl.sdk.ttl.HDLDeviceManger.Core.Crc;
+
+/**
+ * Created by JLChen on 2019/9/27
+ */
+public class ZigBeeCommand {
+
+ public static final int COMMAND_HEARTBEAT_SEND = 0x2000;
+ public static final int COMMAND_BACK_OPEN_RECEIVING_MODE = 0x2002;//浠h〃鏈夌紦瀛樻暟鎹�
+ public static final int COMMAND_BACK_CLOSE_RECEIVING_MODE = 0x2001;//浠h〃娌$紦瀛樻暟鎹�
+ public static final int COMMAND_SEND_DATA = 0x1002;//鍙戦�佹暟鎹� (榄旈暅->STM32)
+ public static final int COMMAND_SEND_DATA_BACK = 0x2003;//鍙戦�佹暟鎹洖澶� 1byte0XF8鎴愬姛 0XF5澶辫触
+
+ public static final int COMMAND_RECEIVE_DATA = 0x1001;//(STM32->榄旈暅)
+ public static final int COMMAND_RECEIVE_DATA_BACK = 0x2003;//鍙戦�佹暟鎹� 1byte0XF8鎴愬姛 0XF5澶辫触
+
+
+ private static int DeviceType = 0x6666;
+// private int Command1002 = 0x1002;
+// private int CommandHeartbeat = 0x2000;
+// private int DeviceID = 0x01;
+// private static int sendCount = 0;//鍙戦�佸簭鍒楀彿
+
+ /**
+ * @return
+ */
+ public static byte[] GetHeartbeatBytes(int sendCount) {
+ byte[] crcBytes = new byte[13];
+ byte[] sendBytes = new byte[2 + crcBytes.length];
+ //Boot code
+ sendBytes[0] = (byte) 0xAA;
+ sendBytes[1] = (byte) 0xAA;
+ crcBytes[0] = (byte) (crcBytes.length / 256);
+ crcBytes[1] = (byte) (crcBytes.length % 256);
+ crcBytes[2] = (byte) 0x01;
+ crcBytes[3] = (byte) 0x01;
+ crcBytes[4] = (byte) (DeviceType / 256);
+ crcBytes[5] = (byte) (DeviceType % 256);
+ crcBytes[6] = (byte) (COMMAND_HEARTBEAT_SEND / 256);
+ crcBytes[7] = (byte) (COMMAND_HEARTBEAT_SEND % 256);
+ crcBytes[8] = (byte) 0x02;
+ crcBytes[9] = (byte) 0x02;
+ crcBytes[10] = (byte) sendCount;
+
+ Crc.ConCRC(crcBytes, crcBytes.length - 2);
+ System.arraycopy(crcBytes, 0, sendBytes, 2, crcBytes.length);
+ return sendBytes;
+ }
+
+ /**
+ * @return
+ */
+ public static byte[] GetSendBytes(byte[] addBytes, int mCommand, int sendCount) {
+
+ byte[] crcBytes = new byte[15 + addBytes.length];
+ byte[] sendBytes = new byte[2 + crcBytes.length];
+ //Boot code
+ sendBytes[0] = (byte) 0xAA;
+ sendBytes[1] = (byte) 0xAA;
+ crcBytes[0] = (byte) (crcBytes.length / 256);
+ crcBytes[1] = (byte) (crcBytes.length % 256);
+ crcBytes[2] = (byte) 0x01;
+ crcBytes[3] = (byte) 0x01;
+ crcBytes[4] = (byte) (DeviceType / 256);
+ crcBytes[5] = (byte) (DeviceType % 256);
+ crcBytes[6] = (byte) (mCommand / 256);
+ crcBytes[7] = (byte) (mCommand % 256);
+ crcBytes[8] = (byte) 0x02;
+ crcBytes[9] = (byte) 0x02;
+ crcBytes[10] = (byte) sendCount;
+ crcBytes[11] = (byte) (addBytes.length / 256);
+ crcBytes[12] = (byte) (addBytes.length % 256);
+ System.arraycopy(addBytes, 0, crcBytes, 13, addBytes.length);
+ Crc.ConCRC(crcBytes, crcBytes.length - 2);
+ System.arraycopy(crcBytes, 0, sendBytes, 2, crcBytes.length);
+ return sendBytes;
+ }
+
+
+ /**
+ * @return
+ * COMMAND_RECEIVE_DATA_BACK
+ */
+ public static byte[] GetReplyBytes(int sendCount, boolean bSuccess) {
+ byte[] crcBytes = new byte[14];
+ byte[] sendBytes = new byte[2 + crcBytes.length];
+ //Boot code
+ sendBytes[0] = (byte) 0xAA;
+ sendBytes[1] = (byte) 0xAA;
+ crcBytes[0] = (byte) (crcBytes.length / 256);
+ crcBytes[1] = (byte) (crcBytes.length % 256);
+ crcBytes[2] = (byte) 0x01;
+ crcBytes[3] = (byte) 0x01;
+ crcBytes[4] = (byte) (DeviceType / 256);
+ crcBytes[5] = (byte) (DeviceType % 256);
+ crcBytes[6] = (byte) (COMMAND_RECEIVE_DATA_BACK / 256);
+ crcBytes[7] = (byte) (COMMAND_RECEIVE_DATA_BACK % 256);
+ crcBytes[8] = (byte) 0x02;
+ crcBytes[9] = (byte) 0x02;
+ crcBytes[10] = (byte) sendCount;
+ crcBytes[11] = bSuccess ? (byte) 0xF8 : (byte) 0xF5;
+ Crc.ConCRC(crcBytes, crcBytes.length - 2);
+ System.arraycopy(crcBytes, 0, sendBytes, 2, crcBytes.length);
+ return sendBytes;
+ }
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeCroe.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeCroe.java
new file mode 100644
index 0000000..a03e0d5
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeCroe.java
@@ -0,0 +1,14 @@
+package com.hdl.sdk.ttl_sdk.bean;
+
+import com.hdl.sdk.ttl.Utils.LogUtils.HDLLog;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by JLChen on 2019/9/27
+ */
+public class ZigBeeCroe {
+
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeCtrl.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeCtrl.java
new file mode 100644
index 0000000..11b608c
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeCtrl.java
@@ -0,0 +1,14 @@
+package com.hdl.sdk.ttl_sdk.bean;
+
+/**
+ * Created by JLChen on 2019/9/27
+ */
+public class ZigBeeCtrl {
+
+ public String DeviceAddr;
+ public int Epoint;
+ public int Cluster_ID;
+ public int Command;
+ public int SendMode;
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeCtrl2.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeCtrl2.java
new file mode 100644
index 0000000..88d6a52
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeCtrl2.java
@@ -0,0 +1,20 @@
+package com.hdl.sdk.ttl_sdk.bean;
+
+/**
+ * Created by JLChen on 2019/9/27
+ */
+public class ZigBeeCtrl2 {
+
+ public String DeviceAddr;
+ public int Epoint;
+ public int Cluster_ID;
+ public int Command;
+ public int SendMode;
+ public MMData Data = new MMData();
+
+
+ public class MMData {
+ public int Level;
+ public int TransitionTime ;
+ }
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeDataBean.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeDataBean.java
new file mode 100644
index 0000000..329784d
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigBeeDataBean.java
@@ -0,0 +1,11 @@
+package com.hdl.sdk.ttl_sdk.bean;
+
+/**
+ * Created by JLChen on 2019/9/27
+ */
+public class ZigBeeDataBean {
+ public int command;
+ public byte[] receiveBytes;
+ public int mID;//搴忓垪鍙�
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigbeeActivity2.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigbeeActivity2.java
new file mode 100644
index 0000000..899e8a0
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/bean/ZigbeeActivity2.java
@@ -0,0 +1,631 @@
+//package com.hdl.sdk.ttl_sdk.bean;
+//
+//import android.os.Bundle;
+//import android.view.View;
+//import android.widget.Button;
+//import android.widget.RelativeLayout;
+//import android.widget.TextView;
+//
+////import com.google.gson.Gson;
+////import com.google.gson.Gson;
+//import com.google.gson.Gson;
+//import com.hdl.sdk.ttl.Config.MCUConstants;
+//import com.hdl.sdk.ttl.HDLDeviceManger.Core.Crc;
+//import com.hdl.sdk.ttl.HDLDeviceManger.Core.HDLCommand;
+//import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.EventCode;
+//import com.hdl.sdk.ttl.HDLDeviceManger.EventBusEvent.MCUFeedBackEvent;
+//import com.hdl.sdk.ttl.Utils.HDLUtlis.HDLStringUtils;
+//import com.hdl.sdk.ttl_sdk.R;
+//import com.hdl.sdk.ttl_sdk.base.BaseActivity;
+//import com.hdl.sdk.ttl_sdk.bean.ZigBeeCommand;
+//import com.hdl.sdk.ttl_sdk.bean.ZigBeeCtrl;
+//import com.hdl.sdk.ttl_sdk.bean.ZigBeeCtrl2;
+//import com.hdl.sdk.ttl_sdk.bean.ZigBeeDataBean;
+//import com.hdl.sdk.ttl_sdk.utlis.HDLLog;
+//
+//import org.greenrobot.eventbus.Subscribe;
+//import org.greenrobot.eventbus.ThreadMode;
+//import org.json.JSONException;
+//import org.json.JSONObject;
+//
+//import java.util.ArrayList;
+//import java.util.List;
+//import java.util.Timer;
+//import java.util.TimerTask;
+//
+//public class ZigbeeActivity2 extends BaseActivity {
+// /**
+// * Topbar
+// */
+// private RelativeLayout topBarBack;
+// private TextView topBarTitle;
+// private Button btn_PassThrough, btn_PassThrough_close;
+// private Button btn_open_light, btn_open_switch,btn_open_switch2;
+//
+//
+// private TextView tv_other_mes;
+// private Button btn_close;
+// private boolean bReceivingMode = false;//鎺ユ敹鑰呮ā寮�
+//
+//
+//
+//
+//
+// /**
+// * 澶嶅啓isRegisterEventBus() 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true
+// *
+// * @return true
+// */
+// @Override
+// protected boolean isRegisterEventBus() {
+// return true;
+// }
+//
+// @Override
+// protected void onCreate(Bundle savedInstanceState) {
+// super.onCreate(savedInstanceState);
+// setContentView(R.layout.activity_zigbee);
+// initToolbar();
+// initView();
+// initOnClick();
+// getJson();
+// startHDLThread();
+// startSendHeartPacketTimer();
+// }
+//
+//
+//
+// /**
+// * 鍒濆鍖朤oolbar
+// */
+// private void initToolbar() {
+// topBarBack = findViewById(R.id.ll_top_b_left);
+// setViewVisible(topBarBack);
+// topBarTitle = findViewById(R.id.tv_top_b_header_title);
+// topBarBack.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// finish();
+// }
+// });
+// topBarTitle.setText("Zigbee璋冭瘯");
+// }
+//
+// /**
+// * initView
+// */
+// private void initView() {
+// btn_PassThrough = findViewById(R.id.btn_PassThrough);
+// btn_PassThrough_close = findViewById(R.id.btn_PassThrough_close);
+// tv_other_mes = findViewById(R.id.tv_other_mes);
+//
+// btn_close = findViewById(R.id.btn_close);
+//
+// btn_open_light = findViewById(R.id.btn_open_light);
+// btn_open_switch = findViewById(R.id.btn_open_switch);
+//
+// btn_open_switch2= findViewById(R.id.btn_open_switch2);
+//
+// }
+//
+// boolean dd = true;
+// /**
+// * initOnClick
+// */
+// private void initOnClick() {
+// btn_PassThrough.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+////
+//// SendCtrl222();
+//// dd = !dd;
+//// if(dd){
+//// SendGetDeviceList();
+//// }else {
+//// SendCtrl222();
+//// }
+//// SendCtrl();
+// SendGetDeviceList();
+//// SendCtrlLight();
+//// SendCtrl();
+//// SendCtrlLight();
+// }
+// });
+//
+// btn_PassThrough_close.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// setHDLPassThroughOpen(false);
+// tv_other_mes.setText("鍏抽棴閫忎紶");
+//
+// }
+// });
+//
+// btn_close.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// cancelTimer();
+// }
+// });
+//
+// btn_open_light.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// SendCtrlLight();
+// }
+// });
+//
+// btn_open_switch.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// SendCtrl();
+// }
+// });
+//
+//
+// btn_open_switch2.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View view) {
+// SendCtrl222();
+// }
+// });
+//
+// }
+//
+// /**
+// * 2019-8-9
+// * 鍙戦�侀�忎紶鍙傛暟
+// * 閫忎紶鏁版嵁锛屼笉璧癰us鍗忚锛岀洿鎺ヨ浆鍙戯紝涓嶅仛鏁版嵁鏍煎紡澶勭悊
+// * mcuSendTransparentData鎺ュ彛璋冪敤涓�娆′互鍚庯紝榛樿鎵�鏈夋帴鏀舵暟鎹蛋閫忎紶
+// * 鍙互璋冪敤setHDLPassThroughOpen鍏抽棴閫忎紶鏁版嵁
+// */
+// private void mcuSendTransparentData() {
+// startSendHeartPacketTimer();
+// }
+//
+// /**
+// * 璁剧疆鏄惁寮�鍚�忎紶鏁版嵁
+// * 瑕佹兂鐩存帴鎺ユ敹閫忎紶鏁版嵁锛岀洿鎺ヨ皟鐢ㄨ繖涓帴鍙f墦寮�灏卞彲浠ワ紝涓嶈蛋bus鍗忚澶勭悊
+// * 涓嶆兂閫忎紶鐨勮瘽锛岃璁板緱璁剧疆鍥炲叧闂姸鎬�
+// */
+// private void setHDLPassThroughOpen(Boolean bOpen){
+//
+// HDLCommand.setHDLPassThroughOpen(bOpen);
+//
+// }
+//
+//
+//// private int HeartData = 0x2000;
+//// private byte[] HeartDataBytes = {(byte) (HeartData / 256),(byte) (HeartData % 256) };
+// private String sendDataStr = "";
+//
+// private static int sendCount = 0;//鍙戦�佸簭鍒楀彿
+//// private boolean bFrist = true;
+//
+// private void SendHeartPacket(){
+// if(sendCount<255){
+// sendCount++;
+// }else {
+// sendCount = 0;
+// }
+//
+// byte[] sendBytes = ZigBeeCommand.GetHeartbeatBytes(sendCount);
+// HDLCommand.mcuSendTransparentData(sendBytes);
+// }
+//
+// private void SendGetDeviceList(){
+//// if(bReceivingMode) return;
+//
+//
+// byte[] bytes = sendDataStr.getBytes();
+// byte[] sendBytes = ZigBeeCommand.GetSendBytes(bytes, ZigBeeCommand.COMMAND_SEND_DATA, sendCount);
+// HDLCommand.mcuSendTransparentData(sendBytes);
+//
+//// bReceivingMode = true;
+//
+// }
+//
+// int lenght = 1280;
+//
+// private void SendCtrl222(){
+//
+//// byte[] sendBytes = new byte[]{
+//// 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+//// 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+//// 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+//// 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+//// 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+//// 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+//// 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+//// 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+//// 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+//// };
+//
+// lenght ++;
+// HDLLog.Log("KNNN锛歴end" + lenght);
+// byte[] sendBytes = new byte[lenght];
+// for(int i = 0;i <lenght;i++){
+// sendBytes[i] = 0x01;
+//
+// }
+// Crc.ConCRC(sendBytes, sendBytes.length - 2);
+//// byte[] sendBytes = ZigBeeCommand.GetSendBytes(jsonStr.getBytes(), ZigBeeCommand.COMMAND_SEND_DATA, sendCount);
+// HDLCommand.mcuSendTransparentData(sendBytes);
+// bReceivingMode = true;
+// }
+//
+// private boolean kkkk = true;
+//
+// private void SendCtrl(){
+// if(sendCount<255){
+// sendCount++;
+// }else {
+// sendCount = 0;
+// }
+// ZigBeeCtrl send = new ZigBeeCtrl();
+// send.Cluster_ID = 6;
+// send.Command = 2;
+// send.Epoint = 3;
+// send.SendMode = 2;
+// send.DeviceAddr = "000d6ffffe58d64c";
+// Gson gson = new Gson();
+// String jsonStr = gson.toJson(send); //杞崲鎴怞son
+// byte[] sendBytes = ZigBeeCommand.GetSendBytes(jsonStr.getBytes(), ZigBeeCommand.COMMAND_SEND_DATA, sendCount);
+//
+// HDLCommand.mcuSendTransparentData(sendBytes);
+// bReceivingMode = true;
+//
+// }
+//
+// private void SendCtrlLight(){
+// if(sendCount<255){
+// sendCount++;
+// }else {
+// sendCount = 0;
+// }
+// ZigBeeCtrl2 send = new ZigBeeCtrl2();
+// send.Cluster_ID = 8;
+// send.Command = 4;
+// send.Epoint = 8;
+// send.SendMode = 2;
+// send.DeviceAddr = "000d6ffffe58d491";
+// kkkk = !kkkk;
+// if(kkkk) {
+// send.Data.Level = 0;
+// }else {
+// send.Data.Level = 255;
+// }
+// send.Data.TransitionTime = 0;
+// Gson gson = new Gson();
+// String jsonStr = gson.toJson(send); //杞崲鎴怞son
+// byte[] sendBytes = ZigBeeCommand.GetSendBytes(jsonStr.getBytes(), ZigBeeCommand.COMMAND_SEND_DATA, sendCount);
+// HDLCommand.mcuSendTransparentData(sendBytes);
+// bReceivingMode = true;
+//
+//
+// }
+////
+//// private boolean bGetData = false;
+//// private boolean bBeginSendData = false;
+// // 瀹氭椂鍣�
+// private Timer mTimer = new Timer();
+// // 瀹氭椂浠诲姟
+// private MyTimerTask mTask;
+//
+// class MyTimerTask extends TimerTask{
+// @Override
+// public void run() {
+// // TODO Auto-generated method stub
+// // 瑕佸仛鐨勪簨鎯�
+// if(!bReceivingMode) {
+// SendHeartPacket();
+// }
+// }
+//
+// }
+//
+// private void startSendHeartPacketTimer(){
+//
+// if(mTimer == null){
+// mTimer = new Timer();
+// }
+// if(mTask != null){
+// mTask.cancel();
+//
+// }
+// mTask = new MyTimerTask();
+// mTimer.schedule(mTask, 2000, 1500);
+// }
+//
+// private void cancelTimer() {
+// if (mTimer != null) {
+// mTask.cancel();
+// mTimer.cancel();
+// mTimer = null;
+//
+// }
+// }
+//
+// /**
+// * ***********************************************************澶勭悊MCU鍥炲鏁版嵁***********************************************************
+// */
+// /**
+// * MCU鎺у埗鍥炶皟Event
+// *
+// * @param event
+// */
+// @Subscribe(threadMode = ThreadMode.MAIN)
+// public void onMCUFeedBackEventMain(MCUFeedBackEvent event) {
+//// if (event.getEventCode() == EventCode.FAILURE_TIMEOUT) {
+//// if (TextUtils.isEmpty(event.getError())) {
+//// showToast("MCU璇锋眰瓒呮椂锛岃绋嶅悗鍐嶈瘯");
+//// } else {
+//// showToast(event.getError());
+//// }
+//// return;
+//// }
+//
+// switch (event.getMCUDataBean().command) {
+// case MCUConstants.MCU_COMMAND_SEND_BACK: //
+// //閫忎紶杩斿洖鐨勬暟鎹�
+// handleMCUPassThroughDataBack(event);
+// break;
+// default:
+// break;
+// }
+// }
+//
+//
+// /**
+// * 澶勭悊MCU閫忎紶鍥炶皟鏁版嵁
+// * 閫忎紶鏁版嵁锛屼笉璧癰us鍗忚锛岀洿鎺ヨ浆鍙戯紝涓嶅仛鏁版嵁鏍煎紡澶勭悊
+// *
+// * @param event
+// */
+// private void handleMCUPassThroughDataBack(MCUFeedBackEvent event) {
+// if (event.getEventCode() != EventCode.SUCCESS) {
+// tv_other_mesSetText("MCU閫忎紶鏁版嵁鍑洪敊锛岃繑鍥炴暟鎹紓甯�");
+// return;
+// }
+//
+// AddReceiveDatasList(event.getMCUDataBean().receiveBytes);
+// }
+//
+// private void tv_other_mesSetText(String mes) {
+// tv_other_mes.setText(mes);
+// showToast(mes);
+// }
+//
+//
+// @Override
+// protected void onDestroy() {
+// super.onDestroy();
+// cancelTimer();
+// closeThread();
+// }
+//
+//// private class ZIGBEECommand{
+//// private int Cluster_ID = 0;
+//// private int Command = 93;
+//// private ZIGBEECommand(int Cluster_ID, int Command){
+//// this.Cluster_ID = Cluster_ID;
+//// this.Command = Command;
+//// }
+//// }
+//
+// private void getJson(){
+// try {
+// JSONObject jsonObject = new JSONObject();
+// jsonObject.put("Cluster_ID", 0);
+// jsonObject.put("Command", 93);
+// HDLLog.Log("getJson锛�" + jsonObject.toString());
+// sendDataStr = jsonObject.toString();
+//
+// } catch (JSONException e) {
+// e.printStackTrace();
+// }
+// }
+//
+//
+// /**
+// * 澶勭悊HDL Data
+// *
+// * @param receiveBytes
+// */
+// private void HandleMCUdata(byte[] receiveBytes) {
+// if (receiveBytes.length < 15) {
+// return;
+// }
+// //鎿嶄綔鐮�
+// int command = (receiveBytes[8] & 0xFF) * 256 + (receiveBytes[9] & 0xFF);
+// int mId = receiveBytes[12] & 0xFF;
+//
+// HDLLog.Log("KNNN锛歝ommand" + command + " Mid:"+mId);
+// String receiveString = HDLStringUtils.ByteArrToHex(receiveBytes, 0, receiveBytes.length);
+//
+//// tv_other_mes.setText("鏀跺埌鐨勯�忎紶鏁版嵁锛�" + receiveString);
+// HDLLog.Log("鏀跺埌鐨勯�忎紶鏁版嵁锛歭ength锛� "+ receiveBytes.length+" DATA: " + receiveString);
+//
+//
+// switch (command){
+// case ZigBeeCommand.COMMAND_BACK_CLOSE_RECEIVING_MODE:
+// bReceivingMode = false;
+// setTextView("娌�: ");
+// break;
+// case ZigBeeCommand.COMMAND_BACK_OPEN_RECEIVING_MODE:
+// bReceivingMode = true;
+// setTextView("鏈夌紦瀛樻暟鎹�:");
+// break;
+// case ZigBeeCommand.COMMAND_SEND_DATA_BACK:
+//// //鏁版嵁闀垮害
+//// int addDataLength = (receiveBytes[14] & 0xFF) * 256 + (receiveBytes[13] & 0xFF);
+//// //闄勫姞鏁版嵁
+//// byte[] usefulBytes = new byte[addDataLength];
+//// //澶嶅埗闄勫姞鏁版嵁
+//// System.arraycopy(receiveBytes, 15, usefulBytes, 0, addDataLength);
+//// //鍙傛暟
+//// ZigBeeDataBean mZigBeeDataBean = new ZigBeeDataBean();
+//// mZigBeeDataBean.command = command;
+//// mZigBeeDataBean.mID = mId;
+//// mZigBeeDataBean.receiveBytes = usefulBytes;
+//
+// if((receiveBytes[13] & 0xFF) == 0xF8){
+// setTextView("鍙戦�佹暟鎹垚鍔�");
+// }else{
+// setTextView("鍙戦�佹暟鎹け璐�");
+// }
+// break;
+// case ZigBeeCommand.COMMAND_RECEIVE_DATA:
+// //鏁版嵁闀垮害
+// int addDataLength2 = (receiveBytes[14] & 0xFF) * 256 + (receiveBytes[13] & 0xFF);
+// HDLLog.Log("addDataLength2锛� "+ addDataLength2);
+//
+// //闄勫姞鏁版嵁
+// byte[] usefulBytes2 = new byte[addDataLength2];
+// //澶嶅埗闄勫姞鏁版嵁
+// System.arraycopy(receiveBytes, 15, usefulBytes2, 0, addDataLength2);
+// //鍙傛暟
+// ZigBeeDataBean mZigBeeDataBean2 = new ZigBeeDataBean();
+// mZigBeeDataBean2.command = command;
+// mZigBeeDataBean2.mID = mId;
+// mZigBeeDataBean2.receiveBytes = usefulBytes2;
+// sendReceiveDataSuccess(mId);//閫忎紶JSON鏁版嵁杩斿洖(榄旈暅->STM32)
+// getJsonData(mZigBeeDataBean2);
+// break;
+// }
+//
+//
+//
+//
+// }
+//
+// private void getJsonData(ZigBeeDataBean mZigBeeDataBean){
+//// String receiveString = HDLStringUtils.ByteArrToHex(mZigBeeDataBean.receiveBytes, 0, mZigBeeDataBean.receiveBytes.length);
+//// String receiveString =new Gson().toJson(mZigBeeDataBean.receiveBytes);
+//
+// String receiveString = HDLStringUtils.byte2String(mZigBeeDataBean.receiveBytes);
+//
+//// Log.d(TAG,new Gson().toJson(mZigBeeDataBean.receiveBytes));
+//
+// setTextView("GET JSON: "+receiveString );
+// //鍥炲锛氶�忎紶JSON鏁版嵁杩斿洖(榄旈暅->STM32)
+// }
+//
+//
+// /**
+// * 閫忎紶JSON鏁版嵁杩斿洖(榄旈暅->STM32)
+// * 0XF8鎴愬姛 0XF5澶辫触
+// * @param mID
+// */
+// private void sendReceiveDataSuccess(int mID){
+// byte[] sendBytes = ZigBeeCommand.GetReplyBytes(mID, true);
+// HDLCommand.mcuSendTransparentData(sendBytes);
+// }
+//
+//
+//
+// private void setTextView(final String mes){
+//
+//
+// runOnUiThread(new Runnable() {
+// public void run() {
+// tv_other_mes.append(mes + "\n");
+// }
+// });
+//
+// HDLLog.Log("KNNN锛�" + mes);
+// }
+//
+//
+//
+//
+//
+//
+//
+//
+//
+// /**
+// * 鍚姩绾跨▼
+// */
+// private void startHDLThread() {
+// mHDLRead485DatasThread = new HDLRead485DatasThread();
+// mHDLRead485DatasThread.start();
+// }
+// /**
+// * 鍚姩绾跨▼
+// */
+// private void closeThread() {
+// if (mHDLRead485DatasThread != null) mHDLRead485DatasThread.interrupt();
+// }
+//
+// private HDLRead485DatasThread mHDLRead485DatasThread;
+// private boolean bOpenSuccess= true;
+// private List<Byte> mReceiveDatasList = new ArrayList<Byte>();//485鎺ユ敹鏁版嵁闃熷垪
+//
+// /**
+// *
+// * @param receiveBytes
+// */
+// private void AddReceiveDatasList(byte[] receiveBytes) {
+// for (int i = 0; i < receiveBytes.length; i++) {
+// mReceiveDatasList.add(receiveBytes[i]);
+// }
+// }
+//
+// /**
+// * 485鏁版嵁鎺ユ敹绾跨▼
+// *
+// * @author 2019骞�06鏈�26鏃�
+// */
+// private class HDLRead485DatasThread extends Thread {
+//
+// @Override
+// public void run() {
+// super.run();
+// HDLLog.Log("ZigBee鎺ユ敹绾跨▼ 寮�鍚�");
+// while (bOpenSuccess) {
+// int size = 0;
+// try {
+// Thread.sleep(10);
+// while (0 < mReceiveDatasList.size()) {
+//// HDLLog.I("485arraylist.size():" + mReceive485DatasList.size());
+// if (mReceiveDatasList.size() < 3) break;//2019-07-02
+// if (mReceiveDatasList.size() > 3000) { //鏁版嵁缂撳瓨澶閿欒鎯呭喌涓� 娓呯┖涓�娆�
+// mReceiveDatasList.clear();
+// break;//2019-07-24
+// }
+// int len = -1;
+// int startIndex = 0;
+// for (startIndex = 0; startIndex < mReceiveDatasList.size(); startIndex++) {
+// if ((mReceiveDatasList.get(startIndex) & 0xFF) == 0xAA
+// && (mReceiveDatasList.get(startIndex + 1) & 0xFF) == 0xAA) {
+//// len = (mReceiveDatasList.get(startIndex + 2) & 0xFF) * 256 + (mReceiveDatasList.get(startIndex + 3) & 0xFF) + 5;
+// len = (mReceiveDatasList.get(startIndex + 2) & 0xFF) * 256 + (mReceiveDatasList.get(startIndex + 3) & 0xFF) + 2;
+// break;
+// }
+// }
+// if (len == -1 || mReceiveDatasList.size() < len) break;
+//
+//// HDLLog.Log("startIndex:" + startIndex + " LEN:" + len);
+// for (int i = 0; i < startIndex; i++) {
+// if (mReceiveDatasList.size() < 1) break;//2019-07-02
+// mReceiveDatasList.remove(0);
+// }
+// byte[] tempBytes = new byte[len];
+// for (int i = 0; i < tempBytes.length; i++) {
+// if (mReceiveDatasList.size() < 1) break;//2019-07-02
+//
+// tempBytes[i] = mReceiveDatasList.get(0);
+// mReceiveDatasList.remove(0);
+// }
+// HandleMCUdata(tempBytes);
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// HDLLog.Log("error:" + e.getMessage());
+// }
+// }
+// HDLLog.Log("485鎺ユ敹绾跨▼ 鍏抽棴");
+// }
+// }
+//}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/ApkTool.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/ApkTool.java
new file mode 100644
index 0000000..e5dd245
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/ApkTool.java
@@ -0,0 +1,51 @@
+package com.hdl.sdk.ttl_sdk.utlis;
+
+
+/**
+ * Created by jlchen on 11/4/21.
+ */
+
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by gray_dog3 on 16/3/3.
+ * 鎵弿鏈湴瀹夎鐨勫簲鐢�,宸ュ叿绫�
+ */
+public class ApkTool {
+ static String TAG = "ApkTool";
+ public static List<MyAppInfo> mLocalInstallApps = null;
+
+ public static List<MyAppInfo> scanLocalInstallAppList(PackageManager packageManager) {
+ List<MyAppInfo> myAppInfos = new ArrayList<MyAppInfo>();
+ try {
+ List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0);
+ for (int i = 0; i < packageInfos.size(); i++) {
+ PackageInfo packageInfo = packageInfos.get(i);
+ //杩囨护鎺夌郴缁焌pp
+// if ((ApplicationInfo.FLAG_SYSTEM & packageInfo.applicationInfo.flags) != 0) {
+// continue;
+// }
+ MyAppInfo myAppInfo = new MyAppInfo();
+ myAppInfo.setAppName(packageInfo.packageName);
+ if (packageInfo.applicationInfo.loadIcon(packageManager) == null) {
+ continue;
+ }
+ myAppInfo.setImage(packageInfo.applicationInfo.loadIcon(packageManager));
+ myAppInfos.add(myAppInfo);
+ }
+ }catch (Exception e){
+ Log.e(TAG,"===============鑾峰彇搴旂敤鍖呬俊鎭け璐�");
+ }
+ return myAppInfos;
+ }
+
+}
+
+
+
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/HDLLog.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/HDLLog.java
new file mode 100644
index 0000000..4a69fa3
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/HDLLog.java
@@ -0,0 +1,23 @@
+package com.hdl.sdk.ttl_sdk.utlis;
+
+import android.util.Log;
+
+public class HDLLog {
+ private static boolean isOpen = true;
+ public static void Log(String message){
+ if(isOpen){
+ Log.i("HDL_Demo",message);
+ }
+ }
+
+ /**
+ * Error 鎵撳嵃绾㈣壊鐨勯敊璇俊鎭�
+ * @param message
+ */
+ public static void E(String message){
+ if(isOpen){
+ Log.e("HDL_Demo",message);
+ }
+ }
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/HDLUriUtils.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/HDLUriUtils.java
new file mode 100644
index 0000000..87488dc
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/HDLUriUtils.java
@@ -0,0 +1,143 @@
+package com.hdl.sdk.ttl_sdk.utlis;
+
+import android.content.ContentResolver;
+import android.content.ContentUris;
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Environment;
+import android.provider.DocumentsContract;
+import android.provider.MediaStore;
+import android.support.annotation.NonNull;
+import android.support.v4.content.FileProvider;
+
+import java.io.File;
+
+/**
+ * Created by JLChen on 2019/7/25
+ */
+public class HDLUriUtils {
+
+ public static final String AUTHORITY = ".upgrade.fileProvider";
+
+ private HDLUriUtils() {
+ throw new UnsupportedOperationException("u can't instantiate me...");
+ }
+
+ /**
+ * File to uri.
+ *
+ * @param file The file.
+ * @return uri
+ */
+ public static Uri file2Uri(@NonNull final Context context, @NonNull final File file) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ String authority = context.getPackageName() + AUTHORITY;
+ return FileProvider.getUriForFile(context, authority, file);
+ } else {
+ return Uri.fromFile(file);
+ }
+ }
+
+ /**
+ * Uri to file.
+ *
+ * @param uri The uri.
+ * @return file
+ */
+ public static File uri2File(@NonNull final Context context, @NonNull final Uri uri) {
+ HDLLog.Log("UriUtils "+ uri.toString());
+ String authority = uri.getAuthority();
+ String scheme = uri.getScheme();
+ if (ContentResolver.SCHEME_FILE.equals(scheme)) {
+ String path = uri.getPath();
+ if (path != null) return new File(path);
+ HDLLog.Log("UriUtils " + uri.toString() + " parse failed. -> 0");
+ return null;
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
+ && DocumentsContract.isDocumentUri(context, uri)) {
+ if ("com.android.externalstorage.documents".equals(authority)) {
+ final String docId = DocumentsContract.getDocumentId(uri);
+ final String[] split = docId.split(":");
+ final String type = split[0];
+ if ("primary".equalsIgnoreCase(type)) {
+ return new File(Environment.getExternalStorageDirectory() + "/" + split[1]);
+ }
+ HDLLog.Log("UriUtils "+ uri.toString() + " parse failed. -> 1");
+ return null;
+ } else if ("com.android.providers.downloads.documents".equals(authority)) {
+ final String id = DocumentsContract.getDocumentId(uri);
+ final Uri contentUri = ContentUris.withAppendedId(
+ Uri.parse("content://downloads/public_downloads"),
+ Long.valueOf(id)
+ );
+ return getFileFromUri(context, contentUri, 2);
+ } else if ("com.android.providers.media.documents".equals(authority)) {
+ final String docId = DocumentsContract.getDocumentId(uri);
+ final String[] split = docId.split(":");
+ final String type = split[0];
+ Uri contentUri;
+ if ("image".equals(type)) {
+ contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
+ } else if ("video".equals(type)) {
+ contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
+ } else if ("audio".equals(type)) {
+ contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
+ } else {
+ HDLLog.Log("UriUtils " + uri.toString() + " parse failed. -> 3");
+ return null;
+ }
+ final String selection = "_id=?";
+ final String[] selectionArgs = new String[]{split[1]};
+ return getFileFromUri(context, contentUri, selection, selectionArgs, 4);
+ } else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
+ return getFileFromUri(context, uri, 5);
+ } else {
+ HDLLog.Log("UriUtils " + uri.toString() + " parse failed. -> 6");
+ return null;
+ }
+ } else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
+ return getFileFromUri(context, uri, 7);
+ } else {
+ HDLLog.Log("UriUtils "+ uri.toString() + " parse failed. -> 8");
+ return null;
+ }
+ }
+
+ private static File getFileFromUri(final Context context, final Uri uri, final int code) {
+ return getFileFromUri(context, uri, null, null, code);
+ }
+
+ private static File getFileFromUri(final Context context,
+ final Uri uri,
+ final String selection,
+ final String[] selectionArgs,
+ final int code) {
+ final Cursor cursor = context.getContentResolver().query(
+ uri, new String[]{"_data"}, selection, selectionArgs, null);
+ if (cursor == null) {
+ HDLLog.Log("UriUtils "+ uri.toString() + " parse failed(cursor is null). -> " + code);
+ return null;
+ }
+ try {
+ if (cursor.moveToFirst()) {
+ final int columnIndex = cursor.getColumnIndex("_data");
+ if (columnIndex > -1) {
+ return new File(cursor.getString(columnIndex));
+ } else {
+ HDLLog.Log("UriUtils " + uri.toString() + " parse failed(columnIndex: " + columnIndex + " is wrong). -> " + code);
+ return null;
+ }
+ } else {
+ HDLLog.Log("UriUtils "+ uri.toString() + " parse failed(moveToFirst return false). -> " + code);
+ return null;
+ }
+ } catch (Exception e) {
+ HDLLog.Log("UriUtils " + uri.toString() + " parse failed. -> " + code);
+ return null;
+ } finally {
+ cursor.close();
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/HDLUtlis.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/HDLUtlis.java
new file mode 100644
index 0000000..f32ff77
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/HDLUtlis.java
@@ -0,0 +1,107 @@
+package com.hdl.sdk.ttl_sdk.utlis;
+
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.os.Build;
+
+import java.math.BigDecimal;
+
+/**
+ * Created by JLChen on 2019/7/4
+ */
+public class HDLUtlis {
+
+ public static final String REMAEK_NULL = "\uF8F5\uF8F5\uF8F5\uF8F5\uF8F5\uF8F5\uF8F5\uF8F5\uF8F5\uF8F5\uF8F5\uF8F5\uF8F5\uF8F5\uF8F5\uF8F5\uF8F5\uF8F5\uF8F5\uF8F5";
+ /**
+ * 灏唎bject杞负Integer绫诲瀷
+ * @param object
+ * @return
+ */
+ public static Integer getIntegerByObject(Object object){
+ Integer in = null;
+ if(object!=null){
+ if(object instanceof Integer){
+ in = (Integer)object;
+ }else if(object instanceof String){
+ in = Integer.parseInt((String)object);
+ }else if(object instanceof Double){
+ in = (int)((double)object);
+ }else if(object instanceof Float){
+ in = (int)((float)object);
+ }else if(object instanceof BigDecimal){
+ in = ((BigDecimal)object).intValue();
+ }else if(object instanceof Long){
+ in = ((Long)object).intValue();
+ }
+ }
+ return in;
+ }
+
+ /**
+ * getColor
+ * @param context
+ * @param color
+ * @return
+ */
+ public static int getColor(Context context, int color) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ return context.getColor(color);
+ } else {
+ return context.getResources().getColor(color);
+ }
+ }
+
+ /**
+ * int绫诲瀷杞�4瀛楄妭byte鏁扮粍
+ * @param mInt
+ * @return 4瀛楄妭byte鏁扮粍
+ */
+ public static byte[] intToByteArray(int mInt) {
+ byte[] result = new byte[4];
+ // 鐢遍珮浣嶅埌浣庝綅
+ result[0] = (byte) ((mInt >> 24) & 0xFF);
+ result[1] = (byte) ((mInt >> 16) & 0xFF);
+ result[2] = (byte) ((mInt >> 8) & 0xFF);
+ result[3] = (byte) (mInt & 0xFF);
+ return result;
+ }
+
+ public static boolean checkIsBinFile(String path){
+ try {
+ String prefix = path.substring(path.lastIndexOf(".") + 1).toUpperCase();
+ if (!prefix.equals("BIN")) {
+ return false;
+ }
+ } catch (Exception e) {
+ return false;
+ }
+ return true;
+ }
+
+
+ /**
+ * 鑾峰彇鐗堟湰鍙�
+ *
+ * @param context 涓婁笅鏂�
+ *
+ * @return 鐗堟湰鍙�
+ */
+ public static int getVersionCode(Context context) {
+
+ //鑾峰彇鍖呯鐞嗗櫒
+ PackageManager pm = context.getPackageManager();
+ //鑾峰彇鍖呬俊鎭�
+ try {
+ PackageInfo packageInfo = pm.getPackageInfo(context.getPackageName(), 0);
+ //杩斿洖鐗堟湰鍙�
+ return packageInfo.versionCode;
+ } catch (PackageManager.NameNotFoundException e) {
+ e.printStackTrace();
+ }
+
+ return 0;
+
+ }
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/HDLWarningType.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/HDLWarningType.java
new file mode 100644
index 0000000..17bcb1f
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/HDLWarningType.java
@@ -0,0 +1,136 @@
+package com.hdl.sdk.ttl_sdk.utlis;
+
+/**
+ * HDL 璀︽姤
+ */
+
+public class HDLWarningType {
+ public final static int switchWarning = 1;
+ public final static int intrudeWarning = 2;
+ public final static int overTemperatureWarning = 3;
+ public final static int lowTemperatureWarning = 4;
+ public final static int overHumidityWarning = 5;
+ public final static int lowHumidityWarning = 6;
+ public final static int highVoltageWarning = 7;
+ public final static int lowVoltageWarning = 8;
+ public final static int overloadWarning = 9;
+ public final static int highWaterPressureWarning = 10;
+ public final static int lowWaterPressureWarning = 11;
+ public final static int overLiquidLevelWarning = 12;
+ public final static int lowLiquidLevelWarning = 13;
+ public final static int leakingWarning = 14;
+ public final static int overPM2_5Warning = 15;
+ public final static int overPM10Warning = 16;
+ public final static int emergencyAlarm = 17;
+ public final static int glassesBrokenWarning = 18;
+ public final static int COWarning = 19;
+ public final static int gasWarning = 20;
+ public final static int fireWarning = 21;
+ public final static int smokeWarning = 22;
+ public final static int hijackWarning = 23;
+ public final static int passwordWrongWarning = 24;
+ public final static int anti_dismantleWarning = 25;
+ public final static int fingerPrintWrongWarning = 26;
+ public final static int notLockedWarning = 27;
+ public final static int lowBatteryWarning = 28;
+
+
+ /**
+ * 璀︽姤ID瀵瑰簲涓枃鎻忚堪锛屽彲浠ヨ嚜瀹氫箟缈昏瘧澶氳瑷�
+ */
+ public static String getWarningType(int type){
+ String warningType = "";
+ switch (type){
+ case switchWarning:
+ warningType = "寮�鍏虫姤璀�";
+ break;
+ case intrudeWarning:
+ warningType = "闂叆鎶ヨ";
+ break;
+ case overTemperatureWarning:
+ warningType = "娓╁害杩囬珮鎶ヨ";
+ break;
+ case lowTemperatureWarning:
+ warningType = "娓╁害杩囦綆鎶ヨ";
+ break;
+ case overHumidityWarning:
+ warningType = "婀垮害杩囦綆鎶ヨ";
+ break;
+ case lowHumidityWarning:
+ warningType = "婀垮害杩囬珮鎶ヨ";
+ break;
+ case highVoltageWarning:
+ warningType = "楂樼數鍘嬫姤璀�";
+ break;
+ case lowVoltageWarning:
+ warningType = "浣庣數鍘嬫姤璀�";
+ break;
+ case overloadWarning:
+ warningType = "杩囪浇鎶ヨ";
+ break;
+ case highWaterPressureWarning:
+ warningType = "姘村帇杩囬珮";
+ break;
+ case lowWaterPressureWarning:
+ warningType = "姘村帇杩囦綆";
+ break;
+ case overLiquidLevelWarning:
+ warningType = "娑蹭綅瓒呴檺";
+ break;
+ case lowLiquidLevelWarning:
+ warningType = "娑蹭綅杩囦綆";
+ break;
+ case leakingWarning:
+ warningType = "婕忔按鎶ヨ";
+ break;
+ case overPM2_5Warning:
+ warningType = "PM2.5瓒呴檺";
+ break;
+ case overPM10Warning:
+ warningType = "PM10瓒呴檺";
+ break;
+ case emergencyAlarm:
+ warningType = "绱ф�ユ姤璀�";
+ break;
+ case glassesBrokenWarning:
+ warningType = "鐜荤拑鐮寸鎶ヨ";
+ break;
+ case COWarning:
+ warningType = "CO鎶ヨ";
+ break;
+ case gasWarning:
+ warningType = "鐕冩皵鎶ヨ";
+ break;
+ case fireWarning:
+ warningType = "鐏伨鎶ヨ";
+ break;
+ case smokeWarning:
+ warningType = "鐑熼浘鎶ヨ";
+ break;
+ case hijackWarning:
+ warningType = "鍔寔鎶ヨ";
+ break;
+ case passwordWrongWarning:
+ warningType = "瀵嗙爜閿欒璀﹀憡";
+ break;
+ case anti_dismantleWarning:
+ warningType = "闃叉媶銆侀槻鎾姤璀�";
+ break;
+ case fingerPrintWrongWarning:
+ warningType = "鎸囩汗閿欒鎶ヨ";
+ break;
+ case notLockedWarning:
+ warningType = "闂ㄦ湭閿佸ソ";
+ break;
+ case lowBatteryWarning:
+ warningType = "鐢甸噺涓嶈冻鐘舵��";
+ break;
+ default:
+ warningType = "鏈煡璀﹀憡绫诲瀷";
+ break;
+
+ }
+ return warningType;
+ }
+
+}
diff --git a/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/MyAppInfo.java b/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/MyAppInfo.java
new file mode 100644
index 0000000..097a3bb
--- /dev/null
+++ b/app/src/main/java/com/hdl/sdk/ttl_sdk/utlis/MyAppInfo.java
@@ -0,0 +1,37 @@
+package com.hdl.sdk.ttl_sdk.utlis;
+
+
+import android.graphics.drawable.Drawable;
+
+/**
+ * Created by jlchen on 11/4/21.
+ */
+public class MyAppInfo {
+ private Drawable image;
+ private String appName;
+
+ public MyAppInfo(Drawable image, String appName) {
+ this.image = image;
+ this.appName = appName;
+ }
+ public MyAppInfo() {
+
+ }
+
+ public Drawable getImage() {
+ return image;
+ }
+
+ public void setImage(Drawable image) {
+ this.image = image;
+ }
+
+ public String getAppName() {
+ return appName;
+ }
+
+ public void setAppName(String appName) {
+ this.appName = appName;
+ }
+}
+
diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
new file mode 100644
index 0000000..c7bd21d
--- /dev/null
+++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
@@ -0,0 +1,34 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:aapt="http://schemas.android.com/aapt"
+ android:width="108dp"
+ android:height="108dp"
+ android:viewportHeight="108"
+ android:viewportWidth="108">
+ <path
+ android:fillType="evenOdd"
+ android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
+ android:strokeColor="#00000000"
+ android:strokeWidth="1">
+ <aapt:attr name="android:fillColor">
+ <gradient
+ android:endX="78.5885"
+ android:endY="90.9159"
+ android:startX="48.7653"
+ android:startY="61.0927"
+ android:type="linear">
+ <item
+ android:color="#44000000"
+ android:offset="0.0" />
+ <item
+ android:color="#00000000"
+ android:offset="1.0" />
+ </gradient>
+ </aapt:attr>
+ </path>
+ <path
+ android:fillColor="#FFFFFF"
+ android:fillType="nonZero"
+ android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
+ android:strokeColor="#00000000"
+ android:strokeWidth="1" />
+</vector>
diff --git a/app/src/main/res/drawable/hdl_btn_click_effect.xml b/app/src/main/res/drawable/hdl_btn_click_effect.xml
new file mode 100644
index 0000000..7077dc8
--- /dev/null
+++ b/app/src/main/res/drawable/hdl_btn_click_effect.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item android:drawable="@color/transparent" android:state_pressed="false"/>
+ <item android:drawable="@color/transparent02" android:state_pressed="true"/>
+</selector>
\ No newline at end of file
diff --git a/app/src/main/res/drawable/hdl_item_selector_effect.xml b/app/src/main/res/drawable/hdl_item_selector_effect.xml
new file mode 100644
index 0000000..34e36de
--- /dev/null
+++ b/app/src/main/res/drawable/hdl_item_selector_effect.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:drawable="@color/default_bg_2" android:state_pressed="true"/>
+ <item android:drawable="@color/transparent"/>
+</selector>
diff --git a/app/src/main/res/drawable/hdl_shape_item_select.xml b/app/src/main/res/drawable/hdl_shape_item_select.xml
new file mode 100644
index 0000000..050789f
--- /dev/null
+++ b/app/src/main/res/drawable/hdl_shape_item_select.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle" >
+
+ <solid android:color="@color/default_bg_2" />
+
+ <corners android:radius="10dp" />
+
+ <stroke
+ android:width="1dp"
+ android:color="#fff" />
+
+</shape>
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 0000000..d5fccc5
--- /dev/null
+++ b/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="108dp"
+ android:height="108dp"
+ android:viewportHeight="108"
+ android:viewportWidth="108">
+ <path
+ android:fillColor="#26A69A"
+ android:pathData="M0,0h108v108h-108z" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M9,0L9,108"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M19,0L19,108"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M29,0L29,108"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M39,0L39,108"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M49,0L49,108"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M59,0L59,108"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M69,0L69,108"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M79,0L79,108"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M89,0L89,108"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M99,0L99,108"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M0,9L108,9"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M0,19L108,19"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M0,29L108,29"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M0,39L108,39"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M0,49L108,49"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M0,59L108,59"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M0,69L108,69"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M0,79L108,79"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M0,89L108,89"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M0,99L108,99"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M19,29L89,29"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M19,39L89,39"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M19,49L89,49"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M19,59L89,59"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M19,69L89,69"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M19,79L89,79"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M29,19L29,89"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M39,19L39,89"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M49,19L49,89"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M59,19L59,89"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M69,19L69,89"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+ <path
+ android:fillColor="#00000000"
+ android:pathData="M79,19L79,89"
+ android:strokeColor="#33FFFFFF"
+ android:strokeWidth="0.8" />
+</vector>
diff --git a/app/src/main/res/layout/activity_add_devices_manually.xml b/app/src/main/res/layout/activity_add_devices_manually.xml
new file mode 100644
index 0000000..c1905c5
--- /dev/null
+++ b/app/src/main/res/layout/activity_add_devices_manually.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_main"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+
+ tools:context="com.hdl.sdk.ttl_sdk.activity.SettingActivity">
+
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_below="@+id/hdl_top_bar_layout"
+ android:layout_marginLeft="10dp"
+ android:layout_marginRight="10dp"
+ android:layout_marginTop="20dp">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:text="鎵嬪姩娣诲姞涓嶆敮鎸佹悳绱㈢殑璁惧"
+ android:gravity="center|left"
+ android:textSize="@dimen/ts_24"
+ android:textColor="@color/black"
+ />
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <TextView
+ android:layout_width="100dp"
+ android:layout_height="match_parent"
+ android:gravity="center|left"
+ android:textSize="@dimen/ts_18"
+ android:textColor="@color/black"
+ android:text="璁惧绫诲瀷锛�" />
+
+ <Spinner
+ android:id="@+id/spinner_device_type"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:minWidth="120dp"></Spinner>
+ </LinearLayout>
+
+
+ <TextView
+ android:layout_width="100dp"
+ android:layout_height="match_parent"
+ android:gravity="center|left"
+ android:textSize="@dimen/ts_18"
+ android:textColor="@color/black"
+ android:text="璁惧鍙傛暟" />
+
+ <EditText
+ android:id="@+id/et_subnetID"
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:layout_marginTop="10dp"
+ android:inputType="number"
+ android:maxLength="3"
+ android:hint="@string/et_subnetid_hint"
+ />
+
+ <EditText
+ android:id="@+id/et_deviceID"
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:layout_marginTop="10dp"
+ android:inputType="number"
+ android:maxLength="3"
+ android:hint="@string/et_deviceid_hint"
+ />
+ <EditText
+ android:id="@+id/et_channelNum"
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:layout_marginTop="10dp"
+ android:inputType="number"
+ android:maxLength="3"
+ android:text="1"
+ android:hint="鍥炶矾鍙�"
+ />
+ <EditText
+ android:id="@+id/et_remarks"
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:layout_marginTop="10dp"
+ android:hint="璇疯緭鍏ュ娉�"
+ />
+
+ <Button
+ android:id="@+id/btn_add"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:layout_marginTop="10dp"
+ android:text="娣诲姞"/>
+
+ </LinearLayout>
+
+</RelativeLayout>
diff --git a/app/src/main/res/layout/activity_add_devices_manually_new.xml b/app/src/main/res/layout/activity_add_devices_manually_new.xml
new file mode 100644
index 0000000..f220e97
--- /dev/null
+++ b/app/src/main/res/layout/activity_add_devices_manually_new.xml
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_main"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ >
+
+
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_marginLeft="10dp"
+ android:layout_marginRight="10dp"
+ android:layout_marginTop="20dp">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:text="鎵嬪姩娣诲姞"
+ android:gravity="center|left"
+ android:textSize="24sp"
+ android:textColor="@android:color/black"
+ />
+
+
+
+ <TextView
+ android:layout_width="100dp"
+ android:layout_height="match_parent"
+ android:gravity="center|left"
+ android:textSize="18sp"
+ android:textColor="@android:color/black"
+ android:text="璁惧鍙傛暟" />
+
+ <EditText
+ android:id="@+id/et_subnetID"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:layout_marginTop="10dp"
+ android:inputType="number"
+ android:maxLength="3"
+ android:hint="瀛愮綉鍙凤紙鑼冨洿0 - 254锛�"
+ />
+
+ <EditText
+ android:id="@+id/et_deviceID"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:layout_marginTop="10dp"
+ android:inputType="number"
+ android:maxLength="3"
+ android:hint="璁惧鍙凤紙鑼冨洿0 - 254锛�"
+ />
+ <EditText
+ android:id="@+id/et_bitType"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:layout_marginTop="10dp"
+ android:inputType="number"
+ android:maxLength="3"
+ android:hint="澶х被"
+ />
+
+ <EditText
+ android:id="@+id/et_littleType"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:layout_marginTop="10dp"
+ android:inputType="number"
+ android:maxLength="3"
+ android:hint="灏忕被"
+ />
+
+ <EditText
+ android:id="@+id/et_remarks_mk"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:layout_marginTop="10dp"
+ android:hint="璇疯緭鍏ユā鍧楀娉�"
+ />
+
+ <EditText
+ android:id="@+id/et_remarks"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:layout_marginTop="10dp"
+ android:hint="璇疯緭鍏ュ娉紝澶氫釜鍥炶矾澶囨敞鈥�-鈥濆垎鍓�"
+ />
+
+
+ <Button
+ android:id="@+id/btn_add"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:layout_marginTop="10dp"
+ android:text="娣诲姞"/>
+
+ </LinearLayout>
+
+</RelativeLayout>
diff --git a/app/src/main/res/layout/activity_appliances.xml b/app/src/main/res/layout/activity_appliances.xml
new file mode 100644
index 0000000..1d81835
--- /dev/null
+++ b/app/src/main/res/layout/activity_appliances.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_appliances"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="com.hdl.sdk.ttl_sdk.activity.AppliancesListActivity">
+
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_below="@+id/hdl_top_bar_layout">
+
+ <ListView
+ android:id="@+id/lv"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"></ListView>
+ </LinearLayout>
+
+</RelativeLayout>
diff --git a/app/src/main/res/layout/activity_appliances_new.xml b/app/src/main/res/layout/activity_appliances_new.xml
new file mode 100644
index 0000000..16723d5
--- /dev/null
+++ b/app/src/main/res/layout/activity_appliances_new.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_appliances"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="com.hdl.sdk.ttl_sdk.activity.AppliancesListActivity">
+
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_below="@+id/hdl_top_bar_layout">
+
+ <android.support.v7.widget.RecyclerView
+ android:id="@+id/recyclerView_hl"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/transparent">
+
+ </android.support.v7.widget.RecyclerView>
+ </LinearLayout>
+
+</RelativeLayout>
diff --git a/app/src/main/res/layout/activity_audio.xml b/app/src/main/res/layout/activity_audio.xml
new file mode 100644
index 0000000..ac801ae
--- /dev/null
+++ b/app/src/main/res/layout/activity_audio.xml
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_audio"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="com.hdl.sdk.ttl_sdk.activity.CtrlAudioActivity">
+
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b"/>
+
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/hdl_top_bar_layout"
+ android:orientation="vertical">
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/current"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鑾峰彇褰撳墠姝屾洸淇℃伅" />
+
+ <Button
+ android:id="@+id/playpause"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鎾斁/鏆傚仠" />
+
+ <Button
+ android:id="@+id/playstop"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鎾斁/鍋滄" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/pre"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="涓婁竴棣�" />
+
+ <Button
+ android:id="@+id/next"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="涓嬩竴棣�" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鎾斁妯″紡:" />
+
+ <Button
+ android:id="@+id/audiomode"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/volmin"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="闊抽噺璁剧疆锛�0" />
+
+ <Button
+ android:id="@+id/volmid"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="闊抽噺璁剧疆锛�40" />
+
+ <Button
+ android:id="@+id/volmax"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="闊抽噺璁剧疆锛�79" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/prelist"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="涓婁竴鍒楄〃" />
+
+ <Button
+ android:id="@+id/nextlist"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="涓嬩竴鍒楄〃" />
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/curSongName"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鏆傛棤姝屾洸淇℃伅" />
+
+ <TextView
+ android:id="@+id/curSongInfo"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鏆傛棤姝屾洸淇℃伅" />
+
+ <ListView
+ android:id="@+id/audiolist"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ </ListView>
+ </LinearLayout>
+
+
+</RelativeLayout>
diff --git a/app/src/main/res/layout/activity_ctrl.xml b/app/src/main/res/layout/activity_ctrl.xml
new file mode 100644
index 0000000..1b07e99
--- /dev/null
+++ b/app/src/main/res/layout/activity_ctrl.xml
@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_ctrl"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="com.hdl.sdk.ttl_sdk.activity.CtrlActivity">
+
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b"/>
+
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_below="@+id/hdl_top_bar_layout"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/lightText"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="杩欎釜鎸夐挳鍋氱伅鍏夌殑婕旂ず" />
+
+ <Button
+ android:id="@+id/ctrlbtn"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鍏崇伅" />
+
+ <TextView
+ android:id="@+id/curtainText1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="杩欎釜鎸夐挳鍋氱獥甯樻ā鍧楃殑婕旂ず" />
+
+ <Button
+ android:id="@+id/curtainbtn"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绐楀笜宸插叧" />
+
+ <TextView
+ android:id="@+id/curtainText2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="杩欎釜鎸夐挳鍋氱獥甯樼數鏈虹殑婕旂ず銆傚紑鍚堝笜鐢垫満锛屽嵎甯樼數鏈虹被浼�" />
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/curtainbtn2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绐楀笜寮�" />
+
+ <Button
+ android:id="@+id/curtainbtn3"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绐楀笜鍏�" />
+
+ <Button
+ android:id="@+id/curtainbtn4"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绐楀笜鍋�" />
+
+ <Button
+ android:id="@+id/curtainbtn5"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绐楀笜寮�鍒�50%" />
+
+ </LinearLayout>
+
+
+
+ <!--<Button-->
+ <!--android:id="@+id/airbtn"-->
+ <!--android:layout_width="wrap_content"-->
+ <!--android:layout_height="wrap_content"-->
+ <!--android:text="绌鸿皟闈㈡澘" />-->
+
+ <LinearLayout
+ android:id="@+id/air"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <TextView
+ android:id="@+id/airText"
+ android:textSize="25sp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="杩欎釜鎸夐挳鍋氱┖璋冮潰鏉跨殑婕旂ず" />
+ <Button
+ android:id="@+id/airbtn_switch"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绌鸿皟寮�鍏�" />
+ <Button
+ android:id="@+id/airbtn_mode"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绌鸿皟妯″紡" />
+ <Button
+ android:id="@+id/airbtn_speed"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绌鸿皟椋庨��" />
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <Button
+ android:id="@+id/airbtn_tempBtn"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鐐瑰嚮璁剧疆绌鸿皟娓╁害:" />
+ <EditText
+ android:id="@+id/airet_tempet"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:inputType="number"/>
+ </LinearLayout>
+
+
+
+
+ </LinearLayout>
+
+
+ <TextView
+ android:id="@+id/logicText"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="杩欎釜鎸夐挳鍋氶�昏緫妯″潡鐨勬紨绀�" />
+
+ <Button
+ android:id="@+id/logicbtn"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="閫昏緫妯″潡" />
+ <TextView
+ android:id="@+id/sensorText"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="杩欎釜鎸夐挳鍋氫紶鎰熷櫒婕旂ず" />
+
+ <Button
+ android:id="@+id/sensorbtn"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鑾峰彇浼犳劅鍣ㄧ姸鎬�" />
+ </LinearLayout>
+</RelativeLayout>
diff --git a/app/src/main/res/layout/activity_ctrl_air.xml b/app/src/main/res/layout/activity_ctrl_air.xml
new file mode 100644
index 0000000..eb547eb
--- /dev/null
+++ b/app/src/main/res/layout/activity_ctrl_air.xml
@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_ctrl"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="com.hdl.sdk.ttl_sdk.activity.CtrlLightActivity">
+
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_below="@+id/hdl_top_bar_layout"
+ android:layout_marginRight="20dp"
+ android:layout_marginLeft="20dp"
+ android:orientation="vertical">
+
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:text="绌鸿皟闈㈡澘鍔熻兘绫绘ā鍧�"
+ android:gravity="center|left"
+ android:textSize="@dimen/ts_24"
+ android:textColor="@color/black"
+ />
+
+ <LinearLayout
+ android:id="@+id/air"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <TextView
+ android:layout_width="80dp"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:textColor="@color/black"
+ android:text="寮�鍏崇姸鎬侊細" />
+
+ <TextView
+ android:id="@+id/tv_switch"
+ android:layout_width="80dp"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:text="" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <TextView
+ android:layout_width="80dp"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:textColor="@color/black"
+ android:text="绌鸿皟妯″紡锛�" />
+
+ <TextView
+ android:id="@+id/tv_mode"
+ android:layout_width="80dp"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:text="" />
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <TextView
+ android:layout_width="80dp"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:textColor="@color/black"
+ android:text="椋庨�熺姸鎬侊細" />
+
+ <TextView
+ android:id="@+id/tv_speed"
+ android:layout_width="80dp"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:text="" />
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <TextView
+ android:layout_width="80dp"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:textColor="@color/black"
+ android:text="娓╁害鐘舵�侊細" />
+
+ <TextView
+ android:id="@+id/tv_tempet"
+ android:layout_width="80dp"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:text="" />
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/airText"
+ android:textSize="@dimen/ts_20"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="杩欎釜鎸夐挳鍋氱┖璋冮潰鏉跨殑婕旂ず" />
+ <Button
+ android:id="@+id/airbtn_switch"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绌鸿皟寮�鍏�" />
+
+
+ <Button
+ android:id="@+id/airbtn_mode"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绌鸿皟妯″紡" />
+ <Button
+ android:id="@+id/airbtn_speed"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绌鸿皟椋庨��" />
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <Button
+ android:id="@+id/airbtn_tempBtn"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鐐瑰嚮璁剧疆绌鸿皟娓╁害:" />
+ <EditText
+ android:id="@+id/airet_tempet"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:inputType="number"/>
+ </LinearLayout>
+
+
+
+
+ </LinearLayout>
+ </LinearLayout>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_ctrl_air_hvac.xml b/app/src/main/res/layout/activity_ctrl_air_hvac.xml
new file mode 100644
index 0000000..24e50d6
--- /dev/null
+++ b/app/src/main/res/layout/activity_ctrl_air_hvac.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_ctrl"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="com.hdl.sdk.ttl_sdk.activity.CtrlLightActivity">
+
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_below="@+id/hdl_top_bar_layout"
+ android:layout_marginRight="20dp"
+ android:layout_marginLeft="20dp"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:text="HVAC绌鸿皟鍔熻兘绫绘ā鍧�"
+ android:gravity="center|left"
+ android:textSize="@dimen/ts_24"
+ android:textColor="@color/black"
+ />
+
+ <LinearLayout
+ android:id="@+id/air"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <TextView
+ android:id="@+id/airText"
+ android:textSize="@dimen/ts_20"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="杩欎釜鎸夐挳鍋氱┖璋冮潰鏉跨殑婕旂ず" />
+ <Button
+ android:id="@+id/airbtn_switch"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绌鸿皟寮�鍏�" />
+
+
+ <Button
+ android:id="@+id/airbtn_mode"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绌鸿皟妯″紡" />
+ <Button
+ android:id="@+id/airbtn_speed"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绌鸿皟椋庨��" />
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <Button
+ android:id="@+id/airbtn_tempBtn"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鐐瑰嚮璁剧疆绌鸿皟娓╁害:" />
+ <EditText
+ android:id="@+id/airet_tempet"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:inputType="number"/>
+ </LinearLayout>
+
+
+ </LinearLayout>
+ </LinearLayout>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_ctrl_common_switch.xml b/app/src/main/res/layout/activity_ctrl_common_switch.xml
new file mode 100644
index 0000000..634ba97
--- /dev/null
+++ b/app/src/main/res/layout/activity_ctrl_common_switch.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_ctrl"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="com.hdl.sdk.ttl_sdk.activity.CtrlLightActivity">
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginRight="20dp"
+ android:layout_marginLeft="20dp"
+ android:layout_below="@+id/hdl_top_bar_layout"
+ android:orientation="vertical">
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:text="閫氱敤寮�鍏宠澶�"
+ android:gravity="center|left"
+ android:textSize="@dimen/ts_24"
+ android:textColor="@color/black"
+ />
+
+ <TextView
+ android:id="@+id/switchText"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
+ android:textSize="@dimen/ts_20"
+ android:text="杩欎釜鎸夐挳鍋氶�氱敤寮�鍏宠澶囩殑婕旂ず" />
+
+ <Button
+ android:id="@+id/btnOpen"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="寮�" />
+
+
+ <Button
+ android:id="@+id/btnClose"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鍏�" />
+ </LinearLayout>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_ctrl_curtain.xml b/app/src/main/res/layout/activity_ctrl_curtain.xml
new file mode 100644
index 0000000..5c8b8fb
--- /dev/null
+++ b/app/src/main/res/layout/activity_ctrl_curtain.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_ctrl"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="com.hdl.sdk.ttl_sdk.activity.CtrlCurtainActivity">
+
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b"/>
+
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginRight="20dp"
+ android:layout_marginLeft="20dp"
+ android:layout_below="@+id/hdl_top_bar_layout"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:text="绐楀笜绫绘ā鍧�"
+ android:gravity="center|left"
+ android:textSize="@dimen/ts_24"
+ android:textColor="@color/black"
+ />
+
+ <TextView
+ android:id="@+id/curtainText1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
+ android:textSize="@dimen/ts_20"
+ android:text="杩欎釜鎸夐挳鍋氱獥甯樻ā鍧楃殑婕旂ず" />
+
+ <Button
+ android:id="@+id/curtainbtn"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绐楀笜宸插叧" />
+
+ <TextView
+ android:id="@+id/curtainText2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="@dimen/ts_20"
+ android:text="杩欎釜鎸夐挳鍋氱獥甯樼數鏈虹殑婕旂ず銆傚紑鍚堝笜鐢垫満锛屽嵎甯樼數鏈虹被浼�" />
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/curtainbtn2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绐楀笜寮�" />
+
+ <Button
+ android:id="@+id/curtainbtn3"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绐楀笜鍏�" />
+
+ <Button
+ android:id="@+id/curtainbtn4"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绐楀笜鍋�" />
+
+ <Button
+ android:id="@+id/curtainbtn5"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="绐楀笜寮�鍒�50%" />
+
+ </LinearLayout>
+
+ </LinearLayout>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_ctrl_light.xml b/app/src/main/res/layout/activity_ctrl_light.xml
new file mode 100644
index 0000000..41f3336
--- /dev/null
+++ b/app/src/main/res/layout/activity_ctrl_light.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_ctrl"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="com.hdl.sdk.ttl_sdk.activity.CtrlLightActivity">
+
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginRight="20dp"
+ android:layout_marginLeft="20dp"
+ android:layout_below="@+id/hdl_top_bar_layout"
+ android:orientation="vertical">
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:text="鐏厜绫绘ā鍧�"
+ android:gravity="center|left"
+ android:textSize="@dimen/ts_24"
+ android:textColor="@color/black"
+ />
+
+ <TextView
+ android:id="@+id/lightText"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
+ android:textSize="@dimen/ts_20"
+ android:text="杩欎釜鎸夐挳鍋氱伅鍏夌殑婕旂ず" />
+
+ <Button
+ android:id="@+id/ctrlbtn"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鍏崇伅" />
+ </LinearLayout>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_ctrl_logic.xml b/app/src/main/res/layout/activity_ctrl_logic.xml
new file mode 100644
index 0000000..cc4559f
--- /dev/null
+++ b/app/src/main/res/layout/activity_ctrl_logic.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_ctrl"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="com.hdl.sdk.ttl_sdk.activity.CtrlLightActivity">
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginRight="20dp"
+ android:layout_marginLeft="20dp"
+ android:layout_below="@+id/hdl_top_bar_layout"
+ android:orientation="vertical">
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:text="閫昏緫绫绘ā鍧�"
+ android:gravity="center|left"
+ android:textSize="@dimen/ts_24"
+ android:textColor="@color/black"
+ />
+
+ <TextView
+ android:id="@+id/logicText"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
+ android:textSize="@dimen/ts_20"
+ android:text="杩欎釜鎸夐挳鍋氶�昏緫妯″潡鐨勬紨绀�" />
+
+ <Button
+ android:id="@+id/logicbtn"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="閫昏緫妯″潡" />
+ </LinearLayout>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_ctrl_security.xml b/app/src/main/res/layout/activity_ctrl_security.xml
new file mode 100644
index 0000000..ca6477d
--- /dev/null
+++ b/app/src/main/res/layout/activity_ctrl_security.xml
@@ -0,0 +1,262 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_ctrl"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="com.hdl.sdk.ttl_sdk.activity.MCUActivity">
+
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b" />
+
+
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="20dp"
+ android:layout_marginRight="20dp"
+ android:layout_below="@+id/hdl_top_bar_layout"
+ android:orientation="vertical">
+
+ <!--<TextView-->
+ <!--android:layout_width="match_parent"-->
+ <!--android:layout_height="40dp"-->
+ <!--android:gravity="center|left"-->
+ <!--android:text="MCU 鍗忚璋冭瘯"-->
+ <!--android:textColor="@color/black"-->
+ <!--android:textSize="@dimen/ts_24" />-->
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:gravity="center|left"
+ android:text="瀹夐槻妯″潡"
+ android:textColor="@color/black"
+ android:textSize="@dimen/ts_20" />
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="30dp"
+ android:gravity="center|left"
+ android:text="甯冮槻鍓嶏紝瑕佸厛鎾ら槻鍚庡竷闃�"
+ android:textColor="@color/gray_85"
+ android:textSize="@dimen/ts_18" />
+
+ <LinearLayout
+ android:id="@+id/air"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+
+
+ <!--<LinearLayout-->
+ <!--android:layout_width="match_parent"-->
+ <!--android:layout_height="30dp">-->
+ <!--<TextView-->
+ <!--android:layout_width="100dp"-->
+ <!--android:layout_height="match_parent"-->
+ <!--android:gravity="center"-->
+ <!--android:textColor="@color/black"-->
+ <!--android:textSize="@dimen/ts_18"-->
+ <!--android:text="鐏鐘舵�侊細" />-->
+ <!--<TextView-->
+ <!--android:id="@+id/tv_alarmFire"-->
+ <!--android:layout_width="wrap_content"-->
+ <!--android:layout_height="match_parent"-->
+ <!--android:gravity="center|left"-->
+ <!--android:text="姝e父" />-->
+ <!--</LinearLayout>-->
+
+ <!--<LinearLayout-->
+ <!--android:layout_width="match_parent"-->
+ <!--android:layout_height="30dp">-->
+ <!--<TextView-->
+ <!--android:layout_width="100dp"-->
+ <!--android:layout_height="match_parent"-->
+ <!--android:gravity="center"-->
+ <!--android:textColor="@color/black"-->
+ <!--android:textSize="@dimen/ts_18"-->
+ <!--android:text="鐓ゆ皵鎶ヨ锛�" />-->
+ <!--<TextView-->
+ <!--android:id="@+id/tv_alarmGas"-->
+ <!--android:layout_width="wrap_content"-->
+ <!--android:layout_height="match_parent"-->
+ <!--android:gravity="center|left"-->
+ <!--android:text="姝e父" />-->
+ <!--</LinearLayout>-->
+ <!--<LinearLayout-->
+ <!--android:layout_width="match_parent"-->
+ <!--android:layout_height="30dp">-->
+ <!--<TextView-->
+ <!--android:layout_width="100dp"-->
+ <!--android:layout_height="match_parent"-->
+ <!--android:gravity="center"-->
+ <!--android:textColor="@color/black"-->
+ <!--android:textSize="@dimen/ts_18"-->
+ <!--android:text="绐佸彂鎶ヨ锛�" />-->
+ <!--<TextView-->
+ <!--android:id="@+id/tv_alarmSudden"-->
+ <!--android:layout_width="wrap_content"-->
+ <!--android:layout_height="match_parent"-->
+ <!--android:gravity="center|left"-->
+ <!--android:text="姝e父" />-->
+ <!--</LinearLayout>-->
+ <!--<LinearLayout-->
+ <!--android:layout_width="match_parent"-->
+ <!--android:layout_height="30dp">-->
+ <!--<TextView-->
+ <!--android:layout_width="100dp"-->
+ <!--android:layout_height="match_parent"-->
+ <!--android:gravity="center"-->
+ <!--android:textColor="@color/black"-->
+ <!--android:textSize="@dimen/ts_18"-->
+ <!--android:text="绱ф�ユ姤璀︼細" />-->
+ <!--<TextView-->
+ <!--android:id="@+id/tv_alarmEmergency"-->
+ <!--android:layout_width="wrap_content"-->
+ <!--android:layout_height="match_parent"-->
+ <!--android:gravity="center|left"-->
+ <!--android:text="姝e父" />-->
+ <!--</LinearLayout>-->
+ <!--<LinearLayout-->
+ <!--android:layout_width="match_parent"-->
+ <!--android:layout_height="30dp">-->
+ <!--<TextView-->
+ <!--android:layout_width="100dp"-->
+ <!--android:layout_height="match_parent"-->
+ <!--android:gravity="center"-->
+ <!--android:textColor="@color/black"-->
+ <!--android:textSize="@dimen/ts_18"-->
+ <!--android:text="鐢垫祦鎶ヨ锛�" />-->
+ <!--<TextView-->
+ <!--android:id="@+id/tv_alarmCurrent"-->
+ <!--android:layout_width="wrap_content"-->
+ <!--android:layout_height="match_parent"-->
+ <!--android:gravity="center|left"-->
+ <!--android:text="姝e父" />-->
+ <!--</LinearLayout>-->
+ <!--<LinearLayout-->
+ <!--android:layout_width="match_parent"-->
+ <!--android:layout_height="30dp">-->
+ <!--<TextView-->
+ <!--android:layout_width="100dp"-->
+ <!--android:layout_height="match_parent"-->
+ <!--android:gravity="center"-->
+ <!--android:textColor="@color/black"-->
+ <!--android:textSize="@dimen/ts_18"-->
+ <!--android:text="鏃犲0鎶ヨ锛�" />-->
+ <!--<TextView-->
+ <!--android:id="@+id/tv_alarmSilent"-->
+ <!--android:layout_width="wrap_content"-->
+ <!--android:layout_height="match_parent"-->
+ <!--android:gravity="center|left"-->
+ <!--android:text="姝e父" />-->
+ <!--</LinearLayout>-->
+ <!--<LinearLayout-->
+ <!--android:layout_width="match_parent"-->
+ <!--android:layout_height="30dp">-->
+ <!--<TextView-->
+ <!--android:layout_width="100dp"-->
+ <!--android:layout_height="match_parent"-->
+ <!--android:gravity="center"-->
+ <!--android:textColor="@color/black"-->
+ <!--android:textSize="@dimen/ts_18"-->
+ <!--android:text="鍔熺巼鎶ヨ锛�" />-->
+ <!--<TextView-->
+ <!--android:id="@+id/tv_alarmPower"-->
+ <!--android:layout_width="wrap_content"-->
+ <!--android:layout_height="match_parent"-->
+ <!--android:gravity="center|left"-->
+ <!--android:text="姝e父" />-->
+ <!--</LinearLayout>-->
+
+ <!--<LinearLayout-->
+ <!--android:layout_width="match_parent"-->
+ <!--android:layout_height="30dp">-->
+ <!--<TextView-->
+ <!--android:layout_width="100dp"-->
+ <!--android:layout_height="match_parent"-->
+ <!--android:gravity="center"-->
+ <!--android:textColor="@color/black"-->
+ <!--android:textSize="@dimen/ts_18"-->
+ <!--android:text="娓╁害鎶ヨ锛�" />-->
+ <!--<TextView-->
+ <!--android:id="@+id/tv_alarmTemperature"-->
+ <!--android:layout_width="wrap_content"-->
+ <!--android:layout_height="match_parent"-->
+ <!--android:gravity="center|left"-->
+ <!--android:text="姝e父" />-->
+ <!--</LinearLayout>-->
+
+
+
+
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <TextView
+ android:layout_width="100dp"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:textSize="@dimen/ts_18"
+ android:textColor="@color/black"
+ android:text="甯冮槻鐘舵�侊細" />
+
+ <Spinner
+ android:id="@+id/spinner_arming"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:minWidth="120dp"></Spinner>
+ </LinearLayout>
+
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <Button
+ android:id="@+id/btn_read_config"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:textSize="@dimen/ts_18"
+ android:text="璇诲彇瀹夐槻璁剧疆 " />
+
+ <Button
+ android:id="@+id/btn_set_arming"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:textSize="@dimen/ts_18"
+ android:text="淇敼甯冮槻鐘舵��" />
+
+
+
+ </LinearLayout>
+ <Button
+ android:id="@+id/btn_send_alarm"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:textSize="@dimen/ts_18"
+ android:visibility="gone"
+ android:text="鍙戦�佹姤璀︽寚浠�" />
+
+ <TextView
+ android:id="@+id/tv_mes"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="5dp"
+ android:text="瀹夐槻妯″潡甯冮槻婕旂ず"
+ android:textSize="@dimen/ts_20" />
+
+
+
+
+
+
+
+ </LinearLayout>
+ </LinearLayout>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..370ad7f
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_main"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="com.hdl.sdk.ttl_sdk.activity.MainActivity">
+
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/hdl_top_bar_layout"
+ android:orientation="vertical">
+ <TextView
+ android:id="@+id/tv_version"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/app_code"
+ />
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp">
+
+ <Button
+ android:id="@+id/btn_search"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="閲嶆柊鎼滅储璁惧" />
+ <Button
+ android:id="@+id/btn_getlocal"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鍔犺浇鏈湴璁惧" />
+
+ <Button
+ android:id="@+id/btn_open"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="寮�鍚覆鍙�" />
+ <Button
+ android:id="@+id/btn_close"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鍏抽棴涓插彛" />
+
+
+
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp">
+ <Button
+ android:id="@+id/btn_setting"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="淇敼瀛愮綉鍙疯澶囧彿" />
+ <Button
+ android:id="@+id/btn_add_device"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鎵嬪姩娣诲姞璁惧" />
+ <Button
+ android:id="@+id/btn_sendtest"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鍙戦�佹祴璇�" />
+ <Button
+ android:id="@+id/btn_mcu"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="MCU"
+ android:visibility="gone"
+ />
+
+ <Button
+ android:id="@+id/btn_ZigBee"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="ZigBee"
+ android:visibility="gone"
+ />
+ </LinearLayout>
+
+
+ <TextView
+ android:id="@+id/tv_result"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <android.support.v7.widget.RecyclerView
+ android:id="@+id/listView_devices"
+ android:layout_marginTop="20dp"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ </android.support.v7.widget.RecyclerView>
+
+ </LinearLayout>
+
+</RelativeLayout>
diff --git a/app/src/main/res/layout/activity_mcu.xml b/app/src/main/res/layout/activity_mcu.xml
new file mode 100644
index 0000000..fc6ee18
--- /dev/null
+++ b/app/src/main/res/layout/activity_mcu.xml
@@ -0,0 +1,271 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_ctrl"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="com.hdl.sdk.ttl_sdk.activity.MCUActivity">
+
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b" />
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_below="@+id/hdl_top_bar_layout">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+
+ android:layout_marginLeft="20dp"
+ android:layout_marginRight="20dp"
+ android:orientation="vertical">
+
+ <!--<TextView-->
+ <!--android:layout_width="match_parent"-->
+ <!--android:layout_height="40dp"-->
+ <!--android:gravity="center|left"-->
+ <!--android:text="MCU 鍗忚璋冭瘯"-->
+ <!--android:textColor="@color/black"-->
+ <!--android:textSize="@dimen/ts_24" />-->
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:gravity="center|left"
+ android:text="璇诲啓閰嶇疆"
+ android:textColor="@color/black"
+ android:textSize="@dimen/ts_20" />
+
+ <LinearLayout
+ android:id="@+id/air"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <TextView
+ android:layout_width="80dp"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:text="鍗忚绫诲瀷锛�" />
+
+ <Spinner
+ android:id="@+id/spinner_type"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:minWidth="120dp"></Spinner>
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <TextView
+ android:layout_width="80dp"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:text="娉㈢壒鐜囷細" />
+
+ <Spinner
+ android:id="@+id/spinner_baudrate"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:minWidth="120dp"></Spinner>
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <TextView
+ android:layout_width="80dp"
+ android:layout_height="51dp"
+ android:gravity="center"
+ android:text="鏁版嵁浣嶏細" />
+
+ <Spinner
+ android:id="@+id/spinner_dataBit"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:minWidth="120dp"></Spinner>
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <TextView
+ android:layout_width="80dp"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:text="妫�楠屼綅锛�" />
+
+ <Spinner
+ android:id="@+id/spinner_checkBit"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:minWidth="120dp"></Spinner>
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <TextView
+ android:layout_width="80dp"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:text="鍋滄浣嶏細" />
+
+ <Spinner
+ android:id="@+id/spinner_stopBit"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:minWidth="120dp"></Spinner>
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <Button
+ android:id="@+id/btn_read_config"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:text="璇婚厤缃俊鎭�" />
+
+ <Button
+ android:id="@+id/btn_write_config"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:text="鍐欓厤缃俊鎭�" />
+
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/tv_config_mes"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="5dp"
+ android:text="MCU璇诲啓閰嶇疆婕旂ず"
+ android:textSize="@dimen/ts_20" />
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:layout_marginTop="20dp"
+ android:background="@color/black"></View>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:gravity="center|left"
+ android:text="鍗囩骇鍔熻兘"
+ android:textColor="@color/black"
+ android:textSize="@dimen/ts_20" />
+
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <Button
+ android:id="@+id/btn_update"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:enabled="false"
+ android:text="璇锋眰鍗囩骇" />
+
+ <ImageView
+
+ android:layout_width="30dp"
+ android:layout_height="30dp"
+ android:layout_gravity="center"
+ android:layout_marginLeft="5dp"
+ android:gravity="center"
+ android:src="@mipmap/ic_open_bin" />
+
+ <TextView
+ android:id="@+id/tv_select_bin"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:layout_marginLeft="5dp"
+ android:layout_weight="1"
+ android:background="@color/default_bg_2"
+ android:gravity="center|left"
+ android:text="@string/select_bin_frist" />
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/tv_update_mes"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="5dp"
+ android:text="MCU鍗囩骇婕旂ず"
+ android:textSize="@dimen/ts_20" />
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:layout_marginTop="20dp"
+ android:background="@color/black"></View>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:gravity="center|left"
+ android:text="鍏朵粬鎿嶄綔"
+ android:textColor="@color/black"
+ android:textSize="@dimen/ts_20" />
+
+ <Button
+ android:id="@+id/btn_packet_loss"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:text="涓㈠寘鐘舵�佹娴�" />
+
+ <Button
+ android:id="@+id/btn_restart"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:text="閲嶅惎MCU" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <Button
+ android:id="@+id/btn_PassThrough"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:text="鍙戦�侀�忎紶鏁版嵁"
+ android:visibility="visible"/>
+ <Button
+ android:id="@+id/btn_PassThrough_close"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:text="鍏抽棴閫忎紶鏁版嵁"
+ android:visibility="visible"/>
+
+
+
+ </LinearLayout>
+
+
+ <TextView
+ android:id="@+id/tv_other_mes"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="5dp"
+ android:text="MCU鍏朵粬鎿嶄綔婕旂ず"
+ android:textSize="@dimen/ts_20" />
+ </LinearLayout>
+ </LinearLayout>
+ </ScrollView>
+</RelativeLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_send_test.xml b/app/src/main/res/layout/activity_send_test.xml
new file mode 100644
index 0000000..ea9c053
--- /dev/null
+++ b/app/src/main/res/layout/activity_send_test.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_main"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+
+ tools:context="com.hdl.sdk.ttl_sdk.activity.SettingActivity">
+
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/hdl_top_bar_layout"
+ android:layout_marginLeft="10dp"
+ android:layout_marginTop="20dp"
+ android:layout_marginRight="10dp"
+ android:orientation="vertical">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:layout_width="100dp"
+ android:layout_height="40dp"
+ android:gravity="center"
+ android:textSize="@dimen/ts_20"
+ android:text="鍙戦�佹鏁�:"/>
+
+ <EditText
+ android:id="@+id/et_count"
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:gravity="center|left"
+ android:hint="璇疯緭鍏�"
+ android:text="10000"
+ android:inputType="number" />
+ </LinearLayout>
+
+ <Button
+ android:id="@+id/btn_start"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:layout_marginTop="10dp"
+ android:text="鍙戦��" />
+
+ <Button
+ android:id="@+id/btn_end"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:layout_marginTop="10dp"
+ android:text="鏆傚仠" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:layout_marginTop="10dp"
+ android:text="褰撳墠鍙戦�佹鏁帮細"
+ android:textColor="@color/black"
+ android:textSize="@dimen/ts_20" />
+
+ <TextView
+ android:id="@+id/tv_message"
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:layout_marginTop="10dp"
+ android:textColor="@android:color/holo_red_light"
+ android:textSize="@dimen/ts_20" />
+ </LinearLayout>
+
+
+ </LinearLayout>
+
+</RelativeLayout>
diff --git a/app/src/main/res/layout/activity_sensor.xml b/app/src/main/res/layout/activity_sensor.xml
new file mode 100644
index 0000000..e8af678
--- /dev/null
+++ b/app/src/main/res/layout/activity_sensor.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+xmlns:tools="http://schemas.android.com/tools"
+android:id="@+id/activity_ctrl"
+android:layout_width="match_parent"
+android:layout_height="match_parent"
+tools:context="com.hdl.sdk.ttl_sdk.activity.MCUActivity">
+
+<include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b" />
+
+
+
+<LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="20dp"
+ android:layout_marginRight="20dp"
+ android:layout_marginTop="20dp"
+ android:layout_below="@+id/hdl_top_bar_layout"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/sensorText"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="杩欎釜鎸夐挳鍋氫紶鎰熷櫒婕旂ず" />
+
+ <Button
+ android:id="@+id/sensorbtn"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鑾峰彇浼犳劅鍣ㄧ姸鎬�" />
+</LinearLayout>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_setting.xml b/app/src/main/res/layout/activity_setting.xml
new file mode 100644
index 0000000..3ec9a77
--- /dev/null
+++ b/app/src/main/res/layout/activity_setting.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_main"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+
+ tools:context="com.hdl.sdk.ttl_sdk.activity.SettingActivity">
+
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_below="@+id/hdl_top_bar_layout"
+ android:layout_marginLeft="10dp"
+ android:layout_marginRight="10dp"
+ android:layout_marginTop="20dp">
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="30dp"
+ android:text="淇敼鏈湴鐨勫瓙缃戝彿鍜岃澶囧彿"
+ android:gravity="center|left"
+ android:textSize="20dp"
+ android:textColor="#000000"/>
+
+ <EditText
+ android:id="@+id/et_subnetID"
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:layout_marginTop="10dp"
+ android:inputType="number"
+ android:maxLength="3"
+ android:hint="@string/et_subnetid_hint"
+ />
+
+ <EditText
+ android:id="@+id/et_deviceID"
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:layout_marginTop="10dp"
+ android:inputType="number"
+ android:maxLength="3"
+ android:hint="@string/et_deviceid_hint"
+ />
+
+ <Button
+ android:id="@+id/btn_save"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:layout_marginTop="10dp"
+ android:text="@string/btn_save"/>
+
+ </LinearLayout>
+
+</RelativeLayout>
diff --git a/app/src/main/res/layout/activity_zigbee.xml b/app/src/main/res/layout/activity_zigbee.xml
new file mode 100644
index 0000000..2c10794
--- /dev/null
+++ b/app/src/main/res/layout/activity_zigbee.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_ctrl"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="com.hdl.sdk.ttl_sdk.activity.MCUActivity">
+
+ <include
+ android:id="@+id/hdl_top_bar_layout"
+ layout="@layout/hdl_toolbar_top_view_b" />
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_below="@+id/hdl_top_bar_layout">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+
+ android:layout_marginLeft="20dp"
+ android:layout_marginRight="20dp"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:gravity="center|left"
+ android:text="Zigbee娴嬭瘯"
+ android:textColor="@color/black"
+ android:textSize="@dimen/ts_20" />
+
+ <LinearLayout
+ android:id="@+id/ll_zigbee"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+
+
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <Button
+ android:id="@+id/btn_PassThrough"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:text="鍙戦�侀�忎紶鏁版嵁"
+ android:visibility="visible"/>
+ <Button
+ android:id="@+id/btn_PassThrough_close"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:text="鍏抽棴閫忎紶鏁版嵁"
+ android:visibility="visible"/>
+ <Button
+ android:id="@+id/btn_close"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:text="鏆傚仠鍙戦��"
+ android:visibility="visible"/>
+
+
+
+
+ </LinearLayout>
+
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp">
+
+ <Button
+ android:id="@+id/btn_open_light"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:text="寮�鍏崇伅"
+ android:visibility="visible"/>
+ <Button
+ android:id="@+id/btn_open_switch"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:text="閫氱敤寮�鍏�"
+ android:visibility="visible"/>
+ <Button
+ android:id="@+id/btn_open_switch2"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:text="鍙�"
+ android:visibility="visible"/>
+
+
+ </LinearLayout>
+
+
+ <TextView
+ android:id="@+id/tv_other_mes"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginTop="5dp"
+ android:text="MCU鍏朵粬鎿嶄綔婕旂ず"
+ android:textSize="@dimen/ts_20" />
+ </LinearLayout>
+ </LinearLayout>
+ </ScrollView>
+</RelativeLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/hdl_toolbar_top_view_b.xml b/app/src/main/res/layout/hdl_toolbar_top_view_b.xml
new file mode 100644
index 0000000..5241726
--- /dev/null
+++ b/app/src/main/res/layout/hdl_toolbar_top_view_b.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar_view_b"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/toolbar_height"
+ android:background="@color/app_background">
+
+
+ <RelativeLayout
+ android:id="@+id/rel_toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="50dp">
+ <RelativeLayout
+ android:id="@+id/ll_top_b_left"
+ android:layout_width="60dp"
+ android:layout_height="match_parent"
+ android:layout_alignParentStart="true"
+ android:layout_centerVertical="true"
+ android:visibility="gone"
+ android:background="@drawable/hdl_btn_click_effect"
+ >
+
+ <ImageView
+ android:id="@+id/iv_menu"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
+ android:layout_marginStart="10dp"
+ android:layout_alignParentStart="true"
+ android:layout_centerVertical="true"
+ android:src="@mipmap/ic_top_back"
+ />
+ </RelativeLayout>
+
+ <TextView
+ android:id="@+id/tv_top_b_header_title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_centerHorizontal="true"
+ android:layout_centerVertical="true"
+ android:text=""
+ android:gravity="center"
+ android:layout_marginRight="60dp"
+ android:layout_marginLeft="60dp"
+ android:textColor="@color/white"
+ android:textSize="@dimen/textSize_title"
+
+ android:textStyle="bold"
+ />
+
+ <!--榛樿闅愯棌-->
+ <RelativeLayout
+ android:id="@+id/ll_top_b_right"
+ android:layout_width="60dp"
+ android:layout_height="match_parent"
+ android:layout_alignParentEnd="true"
+ android:layout_centerVertical="true"
+ android:background="@drawable/hdl_btn_click_effect"
+ android:visibility="gone"
+ >
+
+ <ImageView
+ android:id="@+id/ll_top_b_select"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
+ android:layout_alignParentEnd="true"
+ android:layout_centerVertical="true"
+ android:layout_marginEnd="10dp"
+ />
+ </RelativeLayout>
+
+
+ </RelativeLayout>
+
+ </android.support.v7.widget.Toolbar>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/list_item_appliances.xml b/app/src/main/res/layout/list_item_appliances.xml
new file mode 100644
index 0000000..106c1a7
--- /dev/null
+++ b/app/src/main/res/layout/list_item_appliances.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="70dp"
+ android:minHeight="70dp"
+ android:orientation="vertical"
+ android:background="@drawable/hdl_item_selector_effect"
+ >
+
+
+ <LinearLayout
+ android:id="@+id/ll_device"
+ android:layout_width="55dp"
+ android:layout_height="55dp"
+ android:background="@drawable/hdl_shape_item_select"
+ android:layout_marginLeft="10dp"
+
+ android:layout_centerVertical="true">
+
+ <ImageView
+ android:id="@+id/im_device"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="visible"
+ />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_toRightOf="@+id/ll_device"
+ android:layout_toLeftOf="@+id/iv_device_arrow"
+ android:layout_marginLeft="10dp"
+ android:orientation="vertical">
+ <TextView
+ android:id="@+id/tv_device"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="鍥炶矾"
+ android:gravity="center|left"
+ android:textColor="@color/black"
+ android:textSize="@dimen/ts_16"/>
+ <TextView
+ android:id="@+id/tv_device_message"
+ android:layout_width="match_parent"
+ android:layout_height="35dp"
+ android:gravity="top|left"
+ android:textColor="@color/gray_85"
+ android:textSize="@dimen/ts_14"
+ android:text=""/>
+
+
+ </LinearLayout>
+
+
+ <ImageView
+ android:id="@+id/iv_device_arrow"
+ android:layout_width="15dp"
+ android:layout_height="15dp"
+ android:layout_alignParentRight="true"
+ android:layout_centerVertical="true"
+ android:src="@mipmap/arrow_more"
+ android:layout_marginRight="10dp"/>
+
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:layout_alignParentBottom="true"
+ android:background="@color/default_bg_2"
+ />
+</RelativeLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/list_item_device_list.xml b/app/src/main/res/layout/list_item_device_list.xml
new file mode 100644
index 0000000..2e2079c
--- /dev/null
+++ b/app/src/main/res/layout/list_item_device_list.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="44dp"
+ android:minHeight="44dp"
+ android:layout_marginLeft="10dp"
+ android:layout_marginRight="10dp"
+ android:orientation="vertical"
+ android:background="@drawable/hdl_item_selector_effect"
+ >
+
+ <ImageView
+ android:id="@+id/im_device"
+ android:layout_width="44dp"
+ android:layout_height="44dp"
+ android:visibility="gone"
+ />
+
+ <TextView
+ android:id="@+id/tv_device"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginBottom="2dp"
+ android:layout_marginTop="2dp"
+ android:layout_toRightOf="@+id/im_device"
+ android:layout_toLeftOf="@+id/iv_device_arrow"
+ android:text="鍥炶矾"
+ android:gravity="center|left"
+ android:textColor="@color/black"
+ android:textSize="@dimen/ts_16"/>
+
+
+ <ImageView
+ android:id="@+id/iv_device_arrow"
+ android:layout_width="15dp"
+ android:layout_height="15dp"
+ android:layout_alignParentRight="true"
+ android:layout_centerVertical="true"
+ android:src="@mipmap/arrow_more"/>
+
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:layout_alignParentBottom="true"
+ android:background="@color/default_bg_2"
+ />
+</RelativeLayout>
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+ <background android:drawable="@drawable/ic_launcher_background" />
+ <foreground android:drawable="@drawable/ic_launcher_foreground" />
+</adaptive-icon>
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+ <background android:drawable="@drawable/ic_launcher_background" />
+ <foreground android:drawable="@drawable/ic_launcher_foreground" />
+</adaptive-icon>
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..273bd98
--- /dev/null
+++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png
Binary files differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 0000000..273bd98
--- /dev/null
+++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/arrow_more.png b/app/src/main/res/mipmap-mdpi/arrow_more.png
new file mode 100644
index 0000000..0b11d8c
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/arrow_more.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_item_air.png b/app/src/main/res/mipmap-mdpi/ic_item_air.png
new file mode 100644
index 0000000..79bbfce
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_item_air.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_item_air_w.png b/app/src/main/res/mipmap-mdpi/ic_item_air_w.png
new file mode 100644
index 0000000..2e6ef86
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_item_air_w.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_item_audio.png b/app/src/main/res/mipmap-mdpi/ic_item_audio.png
new file mode 100644
index 0000000..82a718d
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_item_audio.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_item_audio_w.png b/app/src/main/res/mipmap-mdpi/ic_item_audio_w.png
new file mode 100644
index 0000000..738b456
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_item_audio_w.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_item_curtain.png b/app/src/main/res/mipmap-mdpi/ic_item_curtain.png
new file mode 100644
index 0000000..fbabe32
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_item_curtain.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_item_curtain_w.png b/app/src/main/res/mipmap-mdpi/ic_item_curtain_w.png
new file mode 100644
index 0000000..bce3c85
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_item_curtain_w.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_item_light.png b/app/src/main/res/mipmap-mdpi/ic_item_light.png
new file mode 100644
index 0000000..49a373a
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_item_light.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_item_light_w.png b/app/src/main/res/mipmap-mdpi/ic_item_light_w.png
new file mode 100644
index 0000000..64f0502
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_item_light_w.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_item_logic.png b/app/src/main/res/mipmap-mdpi/ic_item_logic.png
new file mode 100644
index 0000000..72843e0
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_item_logic.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_item_logic_w.png b/app/src/main/res/mipmap-mdpi/ic_item_logic_w.png
new file mode 100644
index 0000000..05a32ad
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_item_logic_w.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..273bd98
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 0000000..273bd98
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_open_bin.png b/app/src/main/res/mipmap-mdpi/ic_open_bin.png
new file mode 100644
index 0000000..eb0023e
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_open_bin.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_search.png b/app/src/main/res/mipmap-mdpi/ic_search.png
new file mode 100644
index 0000000..da5df12
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_search.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_top_back.png b/app/src/main/res/mipmap-mdpi/ic_top_back.png
new file mode 100644
index 0000000..f379f33
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_top_back.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..273bd98
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..273bd98
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..273bd98
--- /dev/null
+++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..273bd98
--- /dev/null
+++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..273bd98
--- /dev/null
+++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..273bd98
--- /dev/null
+++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Binary files differ
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..1e730bf
--- /dev/null
+++ b/app/src/main/res/values/colors.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <!--涓婚棰滆壊-->
+ <color name="app_background">#3F51B5</color>
+ <!--榛樿鑳屾櫙棰滆壊-->
+ <color name="backgroundColor">#F0F0F0</color>
+ <color name="default_bg">#F0F0F0</color>
+ <color name="default_bg_2">#DCDCDC</color>
+
+
+ <color name="transparent">#00000000</color>
+ <color name="transparent02">#30000000</color>
+ <color name="black">#ff000000</color>
+ <color name="white">#ffffffff</color>
+ <color name="gray_85">#D9adb1b6</color>
+ <color name="gray_c">#c1c1c2</color>
+ <color name="colorPrimary">#3F51B5</color>
+ <color name="colorPrimaryDark">#303F9F</color>
+ <color name="colorAccent">#FF4081</color>
+
+</resources>
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..662d34a
--- /dev/null
+++ b/app/src/main/res/values/dimens.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+
+ <!-- 榛樿瀛椾綋澶у皬 -->
+ <dimen name="textSize_title">20sp</dimen>
+ <dimen name="ts_44">44sp</dimen>
+ <dimen name="ts_40">40sp</dimen>
+ <dimen name="ts_32">32sp</dimen>
+ <dimen name="ts_24">24sp</dimen>
+ <dimen name="ts_22">22sp</dimen>
+ <dimen name="ts_20">20sp</dimen>
+ <dimen name="ts_18">18sp</dimen>
+ <dimen name="ts_16">16sp</dimen>
+ <dimen name="ts_15">15sp</dimen>
+ <dimen name="ts_14">14sp</dimen>
+ <dimen name="ts_13">13sp</dimen>
+ <dimen name="ts_12">12sp</dimen>
+ <dimen name="ts_11">11sp</dimen>
+ <dimen name="ts_10">10sp</dimen>
+
+ <dimen name="toolbar_height">56dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..01fe704
--- /dev/null
+++ b/app/src/main/res/values/strings.xml
@@ -0,0 +1,17 @@
+<resources>
+ <string name="app_name">HDL TTL SDK</string>
+ <string name="app_code">HDL_TTLSDK-V1.0.1-2020-03-25</string>
+
+ <string name="btn_save">淇濆瓨</string>
+ <string name="et_subnetid_hint">瀛愮綉鍙凤紙鑼冨洿0 - 254锛�</string>
+ <string name="et_deviceid_hint">璁惧鍙峰彿锛堣寖鍥�0 - 254锛�</string>
+
+
+ <string name="select_bin_frist">璇峰厛閫夋嫨鍗囩骇鏂囦欢...</string>
+
+ <string name="title_tips">娓╅Θ鎻愮ず.</string>
+ <string name="ok">纭</string>
+ <string name="cancel">鍙栨秷</string>
+
+
+</resources>
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..7844666
--- /dev/null
+++ b/app/src/main/res/values/styles.xml
@@ -0,0 +1,19 @@
+<resources>
+
+ <!-- Base application theme. -->
+ <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
+ <!-- Customize your theme here. -->
+ <item name="colorPrimary">@color/app_background</item>
+ <item name="colorPrimaryDark">@color/app_background</item>
+ <item name="colorAccent">@color/colorAccent</item>
+ <item name="toolbarStyle">@style/HDLToolbar</item>
+
+ </style>
+
+ <style name="HDLToolbar" parent="Widget.AppCompat.Toolbar">
+ <item name="contentInsetStart">0dp</item><!-- 璁剧疆璇ュ睘鎬цВ鍐崇┖鐧介儴鍒�-->
+ <item name="android:paddingLeft">0dp</item><!-- 璁剧疆璇ュ睘鎬цВ鍐崇┖鐧介儴鍒�-->
+ <item name="android:paddingRight">0dp</item><!-- 璁剧疆璇ュ睘鎬цВ鍐崇┖鐧介儴鍒�-->
+ </style>
+
+</resources>
diff --git a/app/src/test/java/com/hdl/sdk/ttl_sdk/ExampleUnitTest.java b/app/src/test/java/com/hdl/sdk/ttl_sdk/ExampleUnitTest.java
new file mode 100644
index 0000000..4e2f837
--- /dev/null
+++ b/app/src/test/java/com/hdl/sdk/ttl_sdk/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.hdl.sdk.ttl_sdk;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..a6885b9
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,27 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+
+ repositories {
+ google()
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.4.1'
+// classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0'
+// classpath 'com.novoda:bintray-release:+'
+
+
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ jcenter()
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..743d692
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,13 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx1536m
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..f6b961f
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..502402a
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Tue Jul 02 15:30:58 GMT+08:00 2019
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
diff --git a/gradlew b/gradlew
new file mode 100644
index 0000000..cccdd3d
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..f955316
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..1d45b1c
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include ':app', ':HDL_TTLSDK485'
--
Gitblit v1.8.0