From cb1d79a28d0148762486930df073c966ada45e9a Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期三, 20 五月 2020 09:36:59 +0800 Subject: [PATCH] 2020-05-20 1.备份 --- Android_HDL_SDK_XW/app/src/main/res/layout/activity_audio.xml | 131 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/RCUSaveEvent.java | 17 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/DataConverseUtil.java | 32 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/UdpDataBean.java | 12 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/RcuLight.java | 31 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/DevicesInfoEvent.java | 33 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLight/LightCtrlBackInfo.java | 98 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeThermostatCtrlBean.java | 82 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HandleSearch.java | 817 ++ Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeSceneCtrlBackBean.java | 56 Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/TextUdpActivity.java | 187 Android_HDL_SDK_XW/app/src/main/res/mipmap-hdpi/ic_launcher_round.png | 0 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ListRemarks.java | 26 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmSourceBean.java | 7 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeCtrlBean.java | 87 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/BgmInfoEvent.java | 52 Android_HDL_SDK_XW/README.md | 67 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/HetDevicesCtrlEvent.java | 16 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/LightFeedBackEvent.java | 28 Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlActivity.java | 1418 ++++ Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java | 1466 ++++ Android_HDL_SDK_XW/hdl_core/libs/org.eclipse.paho.client.mqttv3-1.2.0.jar | 0 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/RcuCurtain.java | 31 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/LogicFeedBackEvent.java | 28 Android_HDL_SDK_XW/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png | 0 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/FreshAirBackInfo.java | 182 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeSceneListBean.java | 87 Android_HDL_SDK_XW/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png | 0 Android_HDL_SDK_XW/app/src/main/res/layout/activity_setting.xml | 161 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLogic/LogicCtrlBackInfo.java | 48 Android_HDL_SDK_XW/hdl_core/.gitignore | 1 Android_HDL_SDK_XW/app/src/test/java/com/hdl/sdk/hdl_sdk/ExampleUnitTest.java | 17 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeSceneCtrlBean.java | 70 Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/FreshAirActivity.java | 402 + Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeDeviceListBean.java | 353 + Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/SPUtil/SPUtils.java | 156 Android_HDL_SDK_XW/hdl_core/proguard-rules.pro | 21 Android_HDL_SDK_XW/app/src/main/res/layout/activity_main.xml | 137 Android_HDL_SDK_XW/hdl_core/libs/gson-2.8.5.jar | 0 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/gatewaybeans/GatewayCurtainBean.java | 39 Android_HDL_SDK_XW/.idea/misc.xml | 4 Android_HDL_SDK_XW/app/src/main/res/mipmap-xhdpi/ic_launcher.png | 0 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/FreshAirFeedBackEvent.java | 27 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/LogUtil/HDLLog.java | 36 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Callback/StateListener.java | 5 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/Crc.java | 163 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/DeviceStateEvent.java | 28 Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java | 75 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmCtrlListBean.java | 20 Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/SettingActivity.java | 138 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLSensor/SensorCtrlBackInfo.java | 26 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeReportBean.java | 165 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java | 233 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Callback/PushCallback.java | 70 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/HDLUtlis.java | 106 Android_HDL_SDK_XW/.idea/codeStyles/Project.xml | 116 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/ZigbeeDeviceID.java | 122 Android_HDL_SDK_XW/gradlew | 172 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmCtrlBean.java | 15 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/WarningInfoEvent.java | 17 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/Parser/FreshAirParser.java | 99 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/CommonErrorBean.java | 25 Android_HDL_SDK_XW/app/src/main/res/layout/activity_fresh_air.xml | 46 Android_HDL_SDK_XW/hdl_core/src/main/AndroidManifest.xml | 21 Android_HDL_SDK_XW/gradle/wrapper/gradle-wrapper.properties | 6 Android_HDL_SDK_XW/app/src/main/res/layout/activity_appliances.xml | 19 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/AirCtrlBackInfo.java | 113 Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AddDevicesManuallyActivity.java | 130 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeSceneSaveBean.java | 74 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/HDLTest.java | 15 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeReadBean.java | 102 Android_HDL_SDK_XW/hdl_core/src/androidTest/java/com/hdl/sdk/hdl_core/ExampleInstrumentedTest.java | 26 Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/BootComplete.java | 24 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/SearchCountBean.java | 13 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/CurtainFeedBackEvent.java | 28 Android_HDL_SDK_XW/app/src/main/res/mipmap-hdpi/ic_launcher.png | 0 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/RemarkTimes.java | 13 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/AppliancesInfoEvent.java | 21 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/Config/HDLApConfig.java | 71 Android_HDL_SDK_XW/app/src/main/res/mipmap-mdpi/ic_launcher.png | 0 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/Parser/GeothermalParser.java | 198 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/AudioInfoEvent.java | 69 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/EventCode.java | 10 Android_HDL_SDK_XW/app/src/main/res/layout/activity_ctrl.xml | 155 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/SearchZigbeeGateway.java | 166 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java | 2618 +++++++ Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeWriteCtrlBean.java | 91 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/GeothermalFeedBackEvent.java | 41 Android_HDL_SDK_XW/app/src/main/res/layout/activity_geothermal.xml | 59 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLogic/LogicMode.java | 29 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/DeviceStateBean.java | 83 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/gatewaybeans/StatusReadBackBean.java | 23 Android_HDL_SDK_XW/hdl_core/build.gradle | 66 Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/utlis/HDLLog.java | 20 Android_HDL_SDK_XW/gradlew.bat | 84 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmStatusBean.java | 10 Android_HDL_SDK_XW/app/src/main/AndroidManifest.xml | 49 Android_HDL_SDK_XW/hdl_core/src/main/res/values/strings.xml | 3 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/gatewaybeans/GatewayCommondBean.java | 31 Android_HDL_SDK_XW/app/proguard-rules.pro | 21 Android_HDL_SDK_XW/gradle/wrapper/gradle-wrapper.jar | 0 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/NetUtil/NetWorkUtil.java | 239 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Callback/StateEvent.java | 15 Android_HDL_SDK_XW/app/src/main/res/drawable/ic_launcher_background.xml | 170 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/SceneInfoEvent.java | 33 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java | 960 ++ Android_HDL_SDK_XW/gradle.properties | 13 Android_HDL_SDK_XW/app/src/main/res/layout/activity_text_udp.xml | 12 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLZigbeeMqtt.java | 76 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmTypeBean.java | 10 Android_HDL_SDK_XW/app/build.gradle | 32 Android_HDL_SDK_XW/app/src/main/res/mipmap-mdpi/ic_launcher_round.png | 0 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmCtrlSongBean.java | 11 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/gatewaybeans/StatusThermostatReadBean.java | 52 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java | 752 ++ Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/AirFeedBackEvent.java | 27 Android_HDL_SDK_XW/app/src/main/res/layout/activity_add_devices_manually.xml | 113 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeDeviceSaveBean.java | 116 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/DeviceFeedbackEvent.java | 18 Android_HDL_SDK_XW/app/.gitignore | 1 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmModeBean.java | 26 Android_HDL_SDK_XW/settings.gradle | 1 Android_HDL_SDK_XW/app/src/androidTest/java/com/hdl/sdk/hdl_sdk/ExampleInstrumentedTest.java | 26 Android_HDL_SDK_XW/app/src/main/res/values/strings.xml | 7 Android_HDL_SDK_XW/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png | 0 .gitignore | 71 Android_HDL_SDK_XW/build.gradle | 30 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/ZigbeeDeviceInfoEvent.java | 28 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmVolBean.java | 12 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/GeothermalBackInfo.java | 166 Android_HDL_SDK_XW/app/src/main/res/values/styles.xml | 11 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeGatewayInfoBean.java | 57 Android_HDL_SDK_XW/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml | 5 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/JsonUtil.java | 55 Android_HDL_SDK_XW/hdl_core/src/test/java/com/hdl/sdk/hdl_core/ExampleUnitTest.java | 17 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLCurtain/Parser/CurtainCtrlParser.java | 36 Android_HDL_SDK_XW/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png | 0 Android_HDL_SDK_XW/app/src/main/res/mipmap-xxhdpi/ic_launcher.png | 0 Android_HDL_SDK_XW/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml | 5 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java | 476 + Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/StringUtil.java | 236 Android_HDL_SDK_XW/.gitignore | 93 Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/MainActivity.java | 411 + Android_HDL_SDK_XW/app/src/main/res/drawable-v24/ic_launcher_foreground.xml | 36 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommandText.java | 742 ++ Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeDimmableCtrlBean.java | 85 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/ThirdPartyBgmInfoEvent.java | 14 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLWarning/WarningType.java | 139 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/DevicesData.java | 59 Android_HDL_SDK_XW/.idea/runConfigurations.xml | 12 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLCurtain/CurtainCtrlBackInfo.java | 75 Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java | 431 + Zigbee2BusSDK说明文档V1.0.docx | 0 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/MideaDevicesCtrlEvent.java | 16 Android_HDL_SDK_XW/.idea/encodings.xml | 4 Android_HDL_SDK_XW/app/src/main/res/values/colors.xml | 6 Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/base/BaseActivity.java | 88 Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AudioActivity.java | 243 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/HDLAudio.java | 377 + Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/RcuIpListEvent.java | 16 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/AppliancesInfo.java | 256 Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLSensor/SensorStateBackInfo.java | 21 162 files changed, 19,643 insertions(+), 2 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/Android_HDL_SDK_XW/.gitignore b/Android_HDL_SDK_XW/.gitignore new file mode 100644 index 0000000..cce944c --- /dev/null +++ b/Android_HDL_SDK_XW/.gitignore @@ -0,0 +1,93 @@ + +# 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 ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# 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/Android_HDL_SDK_XW/.idea/codeStyles/Project.xml b/Android_HDL_SDK_XW/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..681f41a --- /dev/null +++ b/Android_HDL_SDK_XW/.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/Android_HDL_SDK_XW/.idea/encodings.xml b/Android_HDL_SDK_XW/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/Android_HDL_SDK_XW/.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/Android_HDL_SDK_XW/.idea/misc.xml b/Android_HDL_SDK_XW/.idea/misc.xml new file mode 100644 index 0000000..317a96c --- /dev/null +++ b/Android_HDL_SDK_XW/.idea/misc.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="JDK" project-jdk-type="JavaSDK" /> +</project> \ No newline at end of file diff --git a/Android_HDL_SDK_XW/.idea/runConfigurations.xml b/Android_HDL_SDK_XW/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/Android_HDL_SDK_XW/.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/Android_HDL_SDK_XW/README.md b/Android_HDL_SDK_XW/README.md new file mode 100644 index 0000000..1e3026a --- /dev/null +++ b/Android_HDL_SDK_XW/README.md @@ -0,0 +1,67 @@ +## Android_HDL_SDK_XW + +HDL XW Android SDK Copyright (c) 2019 HDL Inc. + +SDK 鐗堟湰锛歨dl_lib_v1.6.9.20200316_beta +1.澧炲姞灏忕被鏄�3鐨勯煶涔愭挱鏀惧櫒鏀寔; +2.鍔犲湴鐑ā鍧楀崟鐙帶鍒舵俯搴︽帴鍙o紝鎺ュ彛鑷姩鏍规嵁褰撳墠妯″紡璁剧疆褰撳墠妯″紡鐨勬俯搴﹀弬鏁帮紝涓嶉渶瑕佷笂灞傝嚜宸卞垽鏂�;(HDLCommand.geothermalCtrlTemp()) +3.澧炲姞绠�鏄撶紪绋嬫悳绱㈠洖澶�,閫氳繃閰嶇疆澶х被灏忕被锛岃澹板繀鍙澶囨ā鎷熸垚绗笁鏂归煶涔愭挱鏀惧櫒琚悳绱� ; +//閰嶇疆绠�鏄撶紪绋嬫悳绱㈢殑鍙傛暟 (SDK 鍒濆鍖栫殑鏃跺�欓厤缃竴娆�) +/** + * 閰嶇疆绠�鏄撶紪绋嬫悳绱㈣繑鍥炵殑榛樿鍙傛暟 + * @param mSDKLocalBigClass 澶х被ID + * @param mSDKLocalSmallClass 灏忕被ID + * @param mSDKLocalRemark 澶囨敞 + */ +public static void setEasyProgrammingSearchLocalData(int mSDKLocalBigClass, int mSDKLocalSmallClass, String mSDKLocalRemark); +澹板繀鍙澶噑etEasyProgrammingSearchLocalData(9,1,"澹板繀鍙煶涔�"); + +鍘熷湴鐑搴斿叧绯� +HDL 澹板繀鍙� +鏅�� 鑷姩 +鐧藉ぉ 鎵嬪姩 +绂诲紑 浼戠湢 +2020-03-15 淇敼涓� +HDL 澹板繀鍙� +鏅�� 鎵嬪姩 +鐧藉ぉ 鑷姩 +绂诲紑 浼戠湢 + +SDK 鐗堟湰锛歨dl_lib_v1.6.9.20200118_beta +1.淇RCU娣峰悎璋冨厜娣峰悎寮�鍏� 绫绘ā鍧楋紝浣跨敤鐗╃悊鍥炶矾闂; +2.澧炲姞榛樿鑾峰彇WiFi杩炴帴鐨勫箍鎾厤缃柟娉�; + + +SDK 鐗堟湰锛歨dl_lib_v1.6.8.20191016_beta +1.鎺у埗閮芥敼鎴愬箍鎾舰寮忎簡锛屼笉璁板綍涓�绔彛鐨処P銆� + + +SDK 鐗堟湰锛歨dl_lib_v1.6.4.20191015_beta +1.澧炲姞鎼滅储瀹岃澶囨垨鑰呭娉ㄥ埛鏂板畬锛岃嚜鍔ㄤ繚瀛樹竴娆℃暟鎹埌鏈湴銆� +2.澧炲姞璇诲彇鏈湴鏁版嵁鎺ュ彛锛� +3.澧炲姞鍒锋柊鎵�鏈夎澶囩殑澶囨敞鍜岀姸鎬佹帴鍙o紱 + +鎺ュ彛璇存槑锛� + /** + * 璇诲彇鍜屽姞杞芥湰鍦版暟鎹� + */ + private void getLocalDevicesDataList() { + devicesDatas = HDLDeviceManager.getLocalDevicesDataList(); + if (devicesDatas.size() > 0) { + updateDeviceListView(); + HandleSearch.refreshAllDevicesStateAndRemarks();//濡傛灉鏈湴鏈夋暟鎹紝鍙互璋冪敤璇ユ柟娉曪紝閬嶅巻鍙戦�佹寚浠わ紝鍒锋柊鎵�鏈夎澶囩殑澶囨敞鍜岀姸鎬� + } else { + //showToast("鏈湴鏁版嵁涓虹┖"); + } + } + +/**淇濆瓨鏁版嵁鍒版湰鍦版帴鍙o紝闄DK鑷姩淇濆瓨鍚庯紝涓婂眰鍙互閫夋嫨鎵嬪姩璋冪敤淇濆瓨*/ +HDLDeviceManager.saveDevicesDataList(); + + +鎻愪緵澹板繀鍙疭DK椤圭洰 + +##Version 1.0.2 +1.鏂板鍦扮儹妯″潡鍜屾柊椋庣郴缁熸帶鍒跺拰璇诲彇鐘舵�佹帴鍙o紱 +2.鏂板鍦扮儹妯″潡鍜屾柊椋庣郴缁熸帶鍒舵紨绀洪〉闈紱 +3.targetSdkVersion 28锛� diff --git a/Android_HDL_SDK_XW/app/.gitignore b/Android_HDL_SDK_XW/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/Android_HDL_SDK_XW/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/Android_HDL_SDK_XW/app/build.gradle b/Android_HDL_SDK_XW/app/build.gradle new file mode 100644 index 0000000..7e631d3 --- /dev/null +++ b/Android_HDL_SDK_XW/app/build.gradle @@ -0,0 +1,32 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + buildToolsVersion '28.0.3' + defaultConfig { + applicationId "com.hdl.sdk.hdl_sdk" + minSdkVersion 17 + targetSdkVersion 28 + versionCode 1 + versionName "1.0.1" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation 'com.android.support:appcompat-v7:28+' + implementation 'com.android.support.constraint:constraint-layout:1.1.0' + 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 project(':hdl_core') + implementation 'org.greenrobot:eventbus:3.0.0' +} diff --git a/Android_HDL_SDK_XW/app/proguard-rules.pro b/Android_HDL_SDK_XW/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/Android_HDL_SDK_XW/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/Android_HDL_SDK_XW/app/src/androidTest/java/com/hdl/sdk/hdl_sdk/ExampleInstrumentedTest.java b/Android_HDL_SDK_XW/app/src/androidTest/java/com/hdl/sdk/hdl_sdk/ExampleInstrumentedTest.java new file mode 100644 index 0000000..c97d350 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/androidTest/java/com/hdl/sdk/hdl_sdk/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.hdl.sdk.hdl_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/Android_HDL_SDK_XW/app/src/main/AndroidManifest.xml b/Android_HDL_SDK_XW/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..75ce6d3 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/AndroidManifest.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.hdl.sdk.hdl_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.WAKE_LOCK" /> + <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> + <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> + + <application + 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.TextUdpActivity"> + + </activity> + <activity android:name=".activity.SettingActivity" /> + <activity android:name=".activity.AddDevicesManuallyActivity" /> + <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.AppliancesActivity" /> + <activity android:name=".activity.CtrlActivity" /> + <activity android:name=".activity.AudioActivity" /> + <activity android:name=".activity.FreshAirActivity" /> + <activity android:name=".activity.GeothermalActivity" /> + + <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/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AddDevicesManuallyActivity.java b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AddDevicesManuallyActivity.java new file mode 100644 index 0000000..a9e41ae --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AddDevicesManuallyActivity.java @@ -0,0 +1,130 @@ +package com.hdl.sdk.hdl_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.hdl_core.HDLDeviceManger.Parser.DeviceParser; +import com.hdl.sdk.hdl_sdk.R; + +import java.util.ArrayList; + +public class AddDevicesManuallyActivity 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_port,et_remarks_mk; + private Button btn_add; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_add_devices_manually); + + 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, port, parentRemarks, parentRemarksList); + } + + + private void showToast(String text) { + Toast.makeText(this, text, Toast.LENGTH_SHORT).show(); + } +} diff --git a/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java new file mode 100644 index 0000000..465fd13 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java @@ -0,0 +1,75 @@ +package com.hdl.sdk.hdl_sdk.activity; + +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.text.TextUtils; +import android.util.Log; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.ListView; + +import com.hdl.sdk.hdl_core.Config.Configuration; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeDeviceSaveBean; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +public class AppliancesActivity extends AppCompatActivity { + private ListView listView; + private ArrayAdapter<String> adapter; + private List<String> listString = new ArrayList<>(); + private List<AppliancesInfo> appliancesInfos = new ArrayList<>(); + private boolean isZigbee = false; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(com.hdl.sdk.hdl_sdk.R.layout.activity_appliances); + + listView = (ListView) findViewById(com.hdl.sdk.hdl_sdk.R.id.lv); + appliancesInfos = (List<AppliancesInfo>) getIntent().getSerializableExtra("Appliances"); + isZigbee = getIntent().getExtras().getBoolean("izZigbee"); + for (int i = 0; i < appliancesInfos.size(); i++) { + if (TextUtils.isEmpty(appliancesInfos.get(i).getRemarks())) { + listString.add(appliancesInfos.get(i).getDeviceSubnetID() + + "-" + appliancesInfos.get(i).getDeviceDeviceID() + + ",绫诲瀷" + appliancesInfos.get(i).getBigType() + + "-" + appliancesInfos.get(i).getLittleType() + + "鍥炶矾:" + appliancesInfos.get(i).getChannelNum() + + " 鑾峰彇澶囨敞澶辫触鎴栦负绌�"); + } else { + listString.add(appliancesInfos.get(i).getRemarks()); + } + } + + adapter = new ArrayAdapter<String>(AppliancesActivity.this, android.R.layout.simple_list_item_1, listString); + listView.setAdapter(adapter); + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { + Intent intent = new Intent(); + if (appliancesInfos.get(position).getBigType() == Configuration.AUDIO_BIG_TYPE) { + //澶х被鏄煶涔愮被鍒欒烦杞埌AudioActivity + intent.setClass(AppliancesActivity.this, AudioActivity.class); + }else if (appliancesInfos.get(position).getBigType() == Configuration.FRESH_AIR_BIG_TYPE) { + //澶х被鏄柊椋庣郴缁熷垯璺宠浆鍒癋reshAirActivity + intent.setClass(AppliancesActivity.this, FreshAirActivity.class); + }else if (appliancesInfos.get(position).getBigType() == Configuration.GEOTHERMAL_BIG_TYPE) { + //澶х被鏄湴鐑ā鍧楀垯璺宠浆鍒癎eothermalActivity + intent.setClass(AppliancesActivity.this, GeothermalActivity.class); + }else { + intent.setClass(AppliancesActivity.this, CtrlActivity.class); + } + Bundle bundle = new Bundle(); + bundle.putSerializable("hdl", appliancesInfos.get(position)); + intent.putExtras(bundle); + intent.putExtra("isZigbee2Item",isZigbee); + AppliancesActivity.this.startActivity(intent); + } + }); + } +} diff --git a/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AudioActivity.java b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AudioActivity.java new file mode 100644 index 0000000..a5428a8 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AudioActivity.java @@ -0,0 +1,243 @@ +package com.hdl.sdk.hdl_sdk.activity; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.ListView; +import android.widget.TextView; + +import com.hdl.sdk.hdl_core.HDLAppliances.HDLAudio.HDLAudio; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommand; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AudioInfoEvent; +import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.ArrayList; +import java.util.List; + +public class AudioActivity extends AppCompatActivity { + 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;//璁板綍鏄惁鍒濆鍖� + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(com.hdl.sdk.hdl_sdk.R.layout.activity_audio); + curSongNameTv = (TextView) findViewById(com.hdl.sdk.hdl_sdk.R.id.curSongName); + curSongInfoTv = (TextView) findViewById(com.hdl.sdk.hdl_sdk.R.id.curSongInfo); + getCurSongInfoBtn = (Button) findViewById(com.hdl.sdk.hdl_sdk.R.id.current); + playPauseBtn = (Button) findViewById(com.hdl.sdk.hdl_sdk.R.id.playpause); + playStopBtn = (Button) findViewById(com.hdl.sdk.hdl_sdk.R.id.playstop); + preSongBtn = (Button) findViewById(com.hdl.sdk.hdl_sdk.R.id.pre); + nextSongBtn = (Button) findViewById(com.hdl.sdk.hdl_sdk.R.id.next); + volMinBtn = (Button) findViewById(com.hdl.sdk.hdl_sdk.R.id.volmin); + volMidBtn = (Button) findViewById(com.hdl.sdk.hdl_sdk.R.id.volmid); + volMaxBtn = (Button) findViewById(com.hdl.sdk.hdl_sdk.R.id.volmax); + modeBtn = (Button) findViewById(com.hdl.sdk.hdl_sdk.R.id.audiomode); + nextListBtn = (Button) findViewById(com.hdl.sdk.hdl_sdk.R.id.nextlist); + preListBtn = (Button) findViewById(com.hdl.sdk.hdl_sdk.R.id.prelist); + listView = (ListView) findViewById(com.hdl.sdk.hdl_sdk.R.id.audiolist); + isInit = true; + listString.add("杩欎釜鍒楄〃鏄剧ず姝屾洸"); + appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl"); + if (!EventBus.getDefault().isRegistered(this)) { + EventBus.getDefault().register(this); + } + adapter = new ArrayAdapter<String>(AudioActivity.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(AudioActivity.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(); + EventBus.getDefault().unregister(this); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onAudioEventMain(AudioInfoEvent event) { + //鍒ゆ柇鏄惁涓烘湰闊充箰妯″潡鐨勫瓙缃戝彿锛岃澶囧彿 + if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() + && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() + ) { + 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.info( "褰撳墠闊抽噺鍊硷細" + event.getAudioInfoInt()); + break; + case HDLAudio.CALLBACK_AUDIO_LIST_NUM: + int[] listNum = event.getAudioListInfo(); + curListNum = listNum[0]; + HDLLog.info( "褰撳墠鍒楄〃鍙凤細" + listNum[0] + " 褰撳墠鍏辨湁鍒楄〃鏁帮細" + listNum[1]); + if (isInit) { + isInit = false;//姝ゆ搷浣滀负浠呭垵濮嬪寲鎵嶈姹傝幏鍙栧綋鍓嶉煶涔愬垪琛紝鍘傚晢鍙互鑷鍐冲畾浣曟椂鑾峰彇闊充箰鍒楄〃 + HDLCommand.audioCtrl(appliancesInfo, HDLAudio.GET_AUDIO_LIST, curListNum);//鑾峰彇褰撳墠鎾斁鍒楄〃锛屾鏂规硶濡傛灉鍦ㄦ瓕鏇叉挱鏀剧姸鎬佹椂璋冪敤鍒欎細瀵艰嚧姝屾洸鍋滄鎾斁锛岀‖浠惰璁″姝� + } + break; + case HDLAudio.CALLBACK_CURRENT_LIST_NAME: + HDLLog.info( "褰撳墠鍒楄〃鍚嶏細" + event.getAudioInfoStr()); + break; + case HDLAudio.CALLBACK_CURRENT_SONG_NUM: + int[] songNum = event.getAudioListInfo(); + HDLLog.info( "褰撳墠姝屾洸鍙凤細" + songNum[0] + " 褰撳墠鍏辨湁姝屾洸鏁帮細" + songNum[1]); + break; + case HDLAudio.CALLBACK_CURRENT_SONG_NAME: + HDLLog.info( "褰撳墠姝屾洸鍚嶏細" + 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.info( "褰撳墠姝屾洸鎬绘椂闀匡細" + 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; + } + } + + + } +} + diff --git a/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/BootComplete.java b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/BootComplete.java new file mode 100644 index 0000000..c0ae566 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/BootComplete.java @@ -0,0 +1,24 @@ +package com.hdl.sdk.hdl_sdk.activity; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +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)) { + Log.i("djl", "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")) { + String warningType = intent.getStringExtra("HdlWarning"); + Log.i("djl", warningType); + } + + } +} diff --git a/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlActivity.java b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlActivity.java new file mode 100644 index 0000000..c20bfca --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlActivity.java @@ -0,0 +1,1418 @@ +package com.hdl.sdk.hdl_sdk.activity; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.text.TextUtils; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.TextView; +import android.widget.Toast; + +import com.hdl.sdk.hdl_core.Config.Configuration; +import com.hdl.sdk.hdl_core.Config.ZigbeeDeviceID; +import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLCurtain.Parser.CurtainCtrlParser; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.LightCtrlBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLSensor.SensorStateBackInfo; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.DeviceStateBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeDeviceSaveBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.gatewaybeans.StatusReadBackBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Callback.StateEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Callback.StateListener; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommand; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommandText; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLZigbeeMqtt; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AirFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CurtainFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DeviceStateEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LightFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent; +import com.hdl.sdk.hdl_core.Util.TransformUtil.HDLUtlis; +import com.hdl.sdk.hdl_core.Util.TransformUtil.JsonUtil; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.List; + +public class CtrlActivity extends AppCompatActivity { + + 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 List<ZigbeeDeviceSaveBean> zigbeeDeviceDatas; + private int lightState; + private int curtainState; + + private int airSwitchState;//Demo浠呬互姝や綔涓烘紨绀猴紝瀹為檯璇锋牴鎹渶姹傚紑鍙戣璁� + private int airModeState; + private int airTempState; + private int airSpeedState; + private boolean isZigbee = false; + + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(com.hdl.sdk.hdl_sdk.R.layout.activity_ctrl); + if (!EventBus.getDefault().isRegistered(this)) { + EventBus.getDefault().register(this); + } + + +// 姝ゆ柟娉曚负涓诲姩鑾峰彇鍗曚竴璁惧鐘舵�侊紝閫昏緫妯″潡銆佽儗鏅煶涔愭ā鍧楁病鏈夎繖涓猘pi锛屼粎鏀寔鐏厜锛岀獥甯橈紝绌鸿皟銆備竴鑸笉闇�瑕佺敤鍒般�� + // HDLCommand.getDeviceState(appliancesInfo); + + + initcurState(); + initView(); + initClickOnEvent(); + + + + } + + private void initView() { + lightBtn = findViewById(com.hdl.sdk.hdl_sdk.R.id.ctrlbtn); + curtainBtn = findViewById(com.hdl.sdk.hdl_sdk.R.id.curtainbtn); + curtainBtn2 = findViewById(com.hdl.sdk.hdl_sdk.R.id.curtainbtn2); + curtainBtn3 = findViewById(com.hdl.sdk.hdl_sdk.R.id.curtainbtn3); + curtainBtn4 = findViewById(com.hdl.sdk.hdl_sdk.R.id.curtainbtn4); + curtainBtn5 = findViewById(com.hdl.sdk.hdl_sdk.R.id.curtainbtn5); + logicBtn = findViewById(com.hdl.sdk.hdl_sdk.R.id.logicbtn); + sensorBtn = findViewById(com.hdl.sdk.hdl_sdk.R.id.sensorbtn); + + airDisplay = findViewById(com.hdl.sdk.hdl_sdk.R.id.air); + airBtnSwitch = findViewById(com.hdl.sdk.hdl_sdk.R.id.airbtn_switch); + airBtnMode = findViewById(com.hdl.sdk.hdl_sdk.R.id.airbtn_mode); + airBtnSpeed = findViewById(com.hdl.sdk.hdl_sdk.R.id.airbtn_speed); + airBtnTemp = findViewById(com.hdl.sdk.hdl_sdk.R.id.airbtn_tempBtn); + airTempEd = findViewById(com.hdl.sdk.hdl_sdk.R.id.airet_tempet); + + lightText = findViewById(com.hdl.sdk.hdl_sdk.R.id.lightText); + curText1 = findViewById(com.hdl.sdk.hdl_sdk.R.id.curtainText1); + curText2 = findViewById(com.hdl.sdk.hdl_sdk.R.id.curtainText2); + airText = findViewById(com.hdl.sdk.hdl_sdk.R.id.airText); + logicText = findViewById(com.hdl.sdk.hdl_sdk.R.id.logicText); + sensorText = findViewById(com.hdl.sdk.hdl_sdk.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 涓轰紶鎰熷櫒 + + 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.getCurStateObject() != null) { + + int curLightState = HDLUtlis.getIntegerByObject(appliancesInfo.getCurStateObject()); + + 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.getCurStateObject() != null) { + String stringCurtainState = ""; + int curCurtainState = HDLUtlis.getIntegerByObject(appliancesInfo.getCurStateObject()); + Log.i("djl", "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 { + curtainBtn.setText("鏈幏鍙栧埌绐楀笜妯″潡鐘舵��"); + } + + } else { + //寮�鍚堝笜銆佸嵎甯� + curText1.setVisibility(View.GONE); + curtainBtn.setVisibility(View.GONE); + if (appliancesInfo.getCurStateObject() != null) { + curText2.setText("褰撳墠绐楀笜鐘舵�侊細" + HDLUtlis.getIntegerByObject(appliancesInfo.getCurStateObject())); + } 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: + 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: + 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.getCurStateObject() != null) { + float value = (float) appliancesInfo.getCurStateObject(); + sensorBtn.setText("浼犳劅鍣ㄦ暟鍊硷細" + value); + } + break; + + } + } + + + private void initcurState() { + appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl"); + isZigbee = getIntent().getExtras().getBoolean("isZigbee2Item"); + if (isZigbee){ + HDLCommand.getDeviceState(CtrlActivity.this,appliancesInfo,isZigbee);//濡傛灉鏄痾igbee鐨勯渶瑕佽皟鐢ㄥ崟涓�鐘舵�佸洖澶� + }else { + // lightState = 100;//鍒濆鍖栫伅鍏変寒搴�100 + curtainState = CurtainCtrlParser.curtainOff; +// 鑾峰彇鎵�鏈夎澶囩殑鐘舵�併�俤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 initClickOnEvent() { + lightBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + HDLCommand.lightCtrl(appliancesInfo, 50,isZigbee);//state鍊间唬琛ㄨ皟鍏夊ぇ灏�0-100 +// HDLCommand.lightCtrl(appliancesInfo,50,isZigbee); + } + }); + + curtainBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + //绐楀笜妯″潡绗簩涓弬鏁� 涓篊urtainCtrlParser.curtainOn锛孋urtainCtrlParser.curtainOff锛孋urtainCtrlParser.curtainPause鍏朵腑涓�涓� + HDLCommand.curtainCtrl(appliancesInfo, curtainState,isZigbee); + 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,isZigbee); + } + }); + + curtainBtn3.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + HDLCommand.curtainCtrl(appliancesInfo, CurtainCtrlParser.curtainOff,isZigbee); + + } + }); + + curtainBtn4.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + HDLCommand.curtainCtrl(appliancesInfo, CurtainCtrlParser.curtainPause,isZigbee); + } + }); + + curtainBtn5.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + HDLCommand.curtainCtrl(appliancesInfo, 20,isZigbee); + } + }); + + airBtnSwitch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + //婕旂ず褰撳墠鐘舵�佷负鍏筹紝璁剧疆涓哄紑銆傚紑锛岃缃负鍏炽�� + if (airSwitchState == 0) { + HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSwich, AirCtrlParser.airOn,isZigbee);//绌鸿皟寮� + } else { + HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSwich, AirCtrlParser.airOff,isZigbee);//绌鸿皟鍏� + } + } + }); + + + airBtnMode.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + switch (airModeState) { + case 0: + //鑻ュ綋鍓嶇┖璋冩ā寮忎负鍒跺喎锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓哄埗鐑� + HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeHeatTem,isZigbee);//绌鸿皟妯″紡鍒剁儹 + break; + case 1: + //鑻ュ綋鍓嶇┖璋冩ā寮忎负鍒剁儹锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓洪�氶 + HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeVen,isZigbee);//绌鸿皟妯″紡閫氶 + break; + case 2: + //鑻ュ綋鍓嶇┖璋冩ā寮忎负閫氶锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓鸿嚜鍔� + HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeAuto,isZigbee);//绌鸿皟妯″紡鑷姩 + break; + case 3: + //鑻ュ綋鍓嶇┖璋冩ā寮忎负鑷姩锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓烘娊婀� + HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeDehum,isZigbee);//绌鸿皟妯″紡鎶芥箍 + break; + case 4: + //鑻ュ綋鍓嶇┖璋冩ā寮忎负鎶芥箍锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓哄埗鍐� + HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeRefTem,isZigbee);//绌鸿皟妯″紡鍒跺喎 + break; + default: + HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeRefTem,isZigbee);//绌鸿皟妯″紡鍒跺喎 + break; + + } + + + } + }); + + airBtnSpeed.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + switch (airSpeedState) { + case 0: + //鑻ュ綋鍓嶇┖璋冮閫熶负鑷姩锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓洪珮椋� + HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedHigh,isZigbee);//椋庨�熼珮椋� + break; + case 1: + //鑻ュ綋鍓嶇┖璋冮閫熶负楂橀锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓轰腑椋� + HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedMid,isZigbee);//椋庨�熶腑椋� + break; + case 2: + //鑻ュ綋鍓嶇┖璋冮閫熶负涓锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓轰綆椋� + HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedLow,isZigbee);//椋庨�熶綆椋� + break; + case 3: + //鑻ュ綋鍓嶇┖璋冮閫熶负浣庨锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓鸿嚜鍔� + HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedAuto,isZigbee);//椋庨�熻嚜鍔� + 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,isZigbee);//鍒跺喎娓╁害 + break; + case 1: + //褰撳墠绌鸿皟妯″紡涓哄埗鐑� + HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.heatTem, tempInt,isZigbee);//鍒剁儹娓╁害 + break; + case 2: + //褰撳墠绌鸿皟妯″紡涓洪�氶 + showToast("閫氶妯″紡涓嶈兘鎺у埗娓╁害"); + break; + case 3: + //褰撳墠绌鸿皟妯″紡涓鸿嚜鍔� + HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.autoTem, tempInt,isZigbee);//鑷姩娓╁害 + break; + case 4: + //褰撳墠绌鸿皟妯″紡涓烘娊婀� + HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.dehumTem, tempInt,isZigbee);//鎶芥箍娓╁害 + 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,isZigbee); + } + }); + + sensorBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + HDLCommand.getDeviceState(CtrlActivity.this,appliancesInfo,isZigbee); + } + }); + } + + + @Override + protected void onDestroy() { + super.onDestroy(); + EventBus.getDefault().unregister(this); + } + + @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() + && event.getLightCtrlBackInfo().getAppliancesInfo().getDeviceType() == appliancesInfo.getDeviceType() + ) { + // 鍏堝垽鏂槸鍚﹁秴鏃� + 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); + } + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onCurtainFeedBackInfoEventMain(CurtainFeedBackEvent event) { +// 鍏堝垽鏂槸鍚﹁秴鏃� + Log.i("djl", "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); + Log.i("djl", parentRemarks + " 鐨� " + remarks + " 鍥炶矾鍙凤細" + num + " 杩斿洖" + " 鐘舵�佷负锛�" + curState); + if (event.getCurtainCtrlBackInfo().getAppliancesInfo().getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) { + //鍒ゆ柇鏄惁涓虹獥甯樻ā鍧� + switch (curState) { + case CurtainCtrlParser.TYPE_STATE_CLOSE: + curtainBtn.setText("绐楀笜鍏�"); + curText1.setText("绐楀笜鍏�"); + Log.i("djl", "绐楀笜鎺у埗 锛氱獥甯樺叧" + " 鍥炶矾鍙凤細" + num); + break; + case CurtainCtrlParser.TYPE_STATE_OPEN: + curtainBtn.setText("绐楀笜寮�"); + curText1.setText("绐楀笜寮�"); + Log.i("djl", "绐楀笜鎺у埗 锛氱獥甯樺紑" + " 鍥炶矾鍙凤細" + num); + break; + case CurtainCtrlParser.TYPE_STATE_PAUSE: + curtainBtn.setText("绐楀笜鏆傚仠"); + curText1.setText("绐楀笜鏆傚仠"); + Log.i("djl", "绐楀笜鎺у埗 锛氱獥甯樻殏鍋�" + " 鍥炶矾鍙凤細" + num); + break; + } + } else { + //寮�鍚堝笜鎴栧嵎甯� 鏄剧ず鐧惧垎姣� + curtainBtn5.setText("绐楀笜寮�鍒�" + curState + "%"); + curText2.setText("绐楀笜寮�鍒�" + curState + "%"); + } + + } + + } + + @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("绌鸿皟鍏�"); + Log.i("djl", "绌鸿皟鍏�"); + break; + case AirCtrlParser.airOn: + airSwitchState = 1; + airText.setText("绌鸿皟寮�"); + showToast("绌鸿皟寮�"); + Log.i("djl", "绌鸿皟寮�"); + break; + default: + break; + } + + break; + + case AirCtrlParser.airSpeed: + switch (curState[1] & 0xFF) { + case AirCtrlParser.airSpeedAuto: + airSpeedState = 0; + airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedAuto鑷姩椋庨��"); + showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedAuto鑷姩椋庨��"); + Log.i("djl", "绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedAuto鑷姩椋庨��"); + break; + case AirCtrlParser.airSpeedHigh: + airSpeedState = 1; + airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedHigh椋庨�熼珮"); + showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedHigh椋庨�熼珮"); + Log.i("djl", "绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedHigh椋庨�熼珮"); + break; + case AirCtrlParser.airSpeedMid: + airSpeedState = 2; + airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedMid椋庨�熶腑"); + showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedMid椋庨�熶腑"); + Log.i("djl", "绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedMid椋庨�熶腑"); + break; + case AirCtrlParser.airSpeedLow: + airSpeedState = 3; + airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedLow椋庨�熶綆"); + showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedLow椋庨�熶綆"); + Log.i("djl", "绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedLow椋庨�熶綆"); + break; + default: + break; + } + break; + case AirCtrlParser.airMode: + switch (curState[1] & 0xFF) { + case AirCtrlParser.airModeRefTem: + airModeState = 0; + airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鍐�"); + showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鍐�"); + Log.i("djl", "绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鍐�"); + break; + case AirCtrlParser.airModeHeatTem: + airModeState = 1; + airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鐑�"); + showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鐑�"); + Log.i("djl", "绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鐑�"); + break; + case AirCtrlParser.airModeVen: + airModeState = 2; + airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氶�氶"); + showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氶�氶"); + Log.i("djl", "绌鸿皟妯″紡锛屾ā寮忎负锛氶�氶"); + break; + case AirCtrlParser.airModeAuto: + airModeState = 3; + airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氳嚜鍔�"); + showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氳嚜鍔�"); + Log.i("djl", "绌鸿皟妯″紡锛屾ā寮忎负锛氳嚜鍔�"); + break; + case AirCtrlParser.airModeDehum: + airModeState = 4; + airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氭娊婀�"); + showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氭娊婀�"); + Log.i("djl", "绌鸿皟妯″紡锛屾ā寮忎负锛氭娊婀�"); + break; + default: + airModeState = -1; + break; + } + break; + case AirCtrlParser.refTem: + airTempState = curState[1] & 0xFF; + airText.setText("绌鸿皟鍒跺喎锛屾俯搴︿负锛�" + (curState[1] & 0xFF)); + showToast("绌鸿皟鍒跺喎锛屾俯搴︿负锛�" + (curState[1] & 0xFF)); + Log.i("djl", "绌鸿皟鍒跺喎锛屾俯搴︿负锛�" + (curState[1] & 0xFF)); + break; + case AirCtrlParser.heatTem: + airTempState = curState[1] & 0xFF; + airText.setText("绌鸿皟鍒剁儹锛屽埗鐑俯搴︿负" + (curState[1] & 0xFF)); + showToast("绌鸿皟鍒剁儹锛屽埗鐑俯搴︿负" + (curState[1] & 0xFF)); + Log.i("djl", "绌鸿皟鍒剁儹锛屽埗鐑俯搴︿负" + (curState[1] & 0xFF)); + break; + case AirCtrlParser.autoTem: + airTempState = -1; + airText.setText("绌鸿皟鑷姩锛岃嚜鍔ㄦ俯搴︿负" + (curState[1] & 0xFF)); + showToast("绌鸿皟鑷姩锛岃嚜鍔ㄦ俯搴︿负" + (curState[1] & 0xFF)); + Log.i("djl", "绌鸿皟鑷姩锛岃嚜鍔ㄦ俯搴︿负" + (curState[1] & 0xFF)); + break; + case AirCtrlParser.dehumTem: + airTempState = curState[1] & 0xFF; + airText.setText("绌鸿皟鎶芥箍锛屾娊婀挎俯搴︿负" + (curState[1] & 0xFF)); + showToast("绌鸿皟鎶芥箍锛屾娊婀挎俯搴︿负" + (curState[1] & 0xFF)); + Log.i("djl", "绌鸿皟鎶芥箍锛屾娊婀挎俯搴︿负" + (curState[1] & 0xFF)); + break; + case AirCtrlParser.upTem: + airTempState = curState[1] & 0xFF; + airText.setText("绌鸿皟璋冩俯锛屼笂鍗囨俯搴︼細" + (curState[1] & 0xFF)); + showToast("绌鸿皟璋冩俯锛屼笂鍗囨俯搴︼細" + (curState[1] & 0xFF)); + Log.i("djl", "绌鸿皟璋冩俯锛屼笂鍗囨俯搴︼細" + (curState[1] & 0xFF)); + break; + case AirCtrlParser.downTem: + airTempState = curState[1] & 0xFF; + airText.setText("绌鸿皟璋冩俯锛屼笅闄嶆俯搴︼細" + (curState[1] & 0xFF)); + showToast("绌鸿皟璋冩俯锛屼笅闄嶆俯搴︼細" + (curState[1] & 0xFF)); + Log.i("djl", "绌鸿皟璋冩俯锛屼笅闄嶆俯搴︼細" + (curState[1] & 0xFF)); + break; + + } + } + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onLogicFeedBackInfoEventMain(LogicFeedBackEvent event) { +// 鍏堝垽鏂槸鍚﹁秴鏃� + if (event.getLogicCtrlBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() + && event.getLogicCtrlBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() + ) { + if (!event.isSuccess()) { + showToast("鍦烘櫙鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯"); + return; + } + showToast("鍦烘櫙鎺у埗鎴愬姛"); + } + } + + + @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() && appliancesInfo.getPhysicsChannelNum() == event.getAppliancesInfo().getPhysicsChannelNum()) { + if (!event.isSuccess()) { + showToast("鑾峰彇鐏厜鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + lightText.setText("褰撳墠浜害 = " + HDLUtlis.getIntegerByObject(event.getAppliancesInfo().getCurStateObject())); + lightBtn.setText("浜害 = " + HDLUtlis.getIntegerByObject(event.getAppliancesInfo().getCurStateObject())); + } + 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().getCurStateObject()); + 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 + "%"); + curText1.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("绌鸿皟鍏�"); + Log.i("djl", "绌鸿皟鍏�"); + break; + case AirCtrlParser.airOn: + airSwitchState = 1; + airText.setText("绌鸿皟寮�"); + showToast("绌鸿皟寮�"); + Log.i("djl", "绌鸿皟寮�"); + break; + default: + break; + } + + break; + + case AirCtrlParser.airSpeed: + switch (curState[1] & 0xFF) { + case AirCtrlParser.airSpeedAuto: + airSpeedState = 0; + airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedAuto鑷姩椋庨��"); + showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedAuto鑷姩椋庨��"); + Log.i("djl", "绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedAuto鑷姩椋庨��"); + break; + case AirCtrlParser.airSpeedHigh: + airSpeedState = 1; + airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedHigh椋庨�熼珮"); + showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedHigh椋庨�熼珮"); + Log.i("djl", "绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedHigh椋庨�熼珮"); + break; + case AirCtrlParser.airSpeedMid: + airSpeedState = 2; + airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedMid椋庨�熶腑"); + showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedMid椋庨�熶腑"); + Log.i("djl", "绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedMid椋庨�熶腑"); + break; + case AirCtrlParser.airSpeedLow: + airSpeedState = 3; + airText.setText("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedLow椋庨�熶綆"); + showToast("绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedLow椋庨�熶綆"); + Log.i("djl", "绌鸿皟椋庨�燂紝椋庨�熸ā寮忎负锛歛irSpeedLow椋庨�熶綆"); + break; + default: + break; + } + break; + case AirCtrlParser.airMode: + switch (curState[1] & 0xFF) { + case AirCtrlParser.airModeRefTem: + airModeState = 0; + airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鍐�"); + showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鍐�"); + Log.i("djl", "绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鍐�"); + break; + case AirCtrlParser.airModeHeatTem: + airModeState = 1; + airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鐑�"); + showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鐑�"); + Log.i("djl", "绌鸿皟妯″紡锛屾ā寮忎负锛氬埗鐑�"); + break; + case AirCtrlParser.airModeVen: + airModeState = 2; + airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氶�氶"); + showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氶�氶"); + Log.i("djl", "绌鸿皟妯″紡锛屾ā寮忎负锛氶�氶"); + break; + case AirCtrlParser.airModeAuto: + airModeState = 3; + airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氳嚜鍔�"); + showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氳嚜鍔�"); + Log.i("djl", "绌鸿皟妯″紡锛屾ā寮忎负锛氳嚜鍔�"); + break; + case AirCtrlParser.airModeDehum: + airModeState = 4; + airText.setText("绌鸿皟妯″紡锛屾ā寮忎负锛氭娊婀�"); + showToast("绌鸿皟妯″紡锛屾ā寮忎负锛氭娊婀�"); + Log.i("djl", "绌鸿皟妯″紡锛屾ā寮忎负锛氭娊婀�"); + break; + default: + break; + } + break; + case AirCtrlParser.refTem: + airTempState = curState[1] & 0xFF; + airText.setText("绌鸿皟鍒跺喎锛屾俯搴︿负锛�" + (curState[1] & 0xFF)); + showToast("绌鸿皟鍒跺喎锛屾俯搴︿负锛�" + (curState[1] & 0xFF)); + Log.i("djl", "绌鸿皟鍒跺喎锛屾俯搴︿负锛�" + (curState[1] & 0xFF)); + break; + case AirCtrlParser.heatTem: + airTempState = curState[1] & 0xFF; + airText.setText("绌鸿皟鍒剁儹锛屽埗鐑俯搴︿负" + (curState[1] & 0xFF)); + showToast("绌鸿皟鍒剁儹锛屽埗鐑俯搴︿负" + (curState[1] & 0xFF)); + Log.i("djl", "绌鸿皟鍒剁儹锛屽埗鐑俯搴︿负" + (curState[1] & 0xFF)); + break; + case AirCtrlParser.autoTem: + airTempState = curState[1] & 0xFF; + airText.setText("绌鸿皟鑷姩锛岃嚜鍔ㄦ俯搴︿负" + (curState[1] & 0xFF)); + showToast("绌鸿皟鑷姩锛岃嚜鍔ㄦ俯搴︿负" + (curState[1] & 0xFF)); + Log.i("djl", "绌鸿皟鑷姩锛岃嚜鍔ㄦ俯搴︿负" + (curState[1] & 0xFF)); + break; + case AirCtrlParser.dehumTem: + airTempState = curState[1] & 0xFF; + airText.setText("绌鸿皟鎶芥箍锛屾娊婀挎俯搴︿负" + (curState[1] & 0xFF)); + showToast("绌鸿皟鎶芥箍锛屾娊婀挎俯搴︿负" + (curState[1] & 0xFF)); + Log.i("djl", "绌鸿皟鎶芥箍锛屾娊婀挎俯搴︿负" + (curState[1] & 0xFF)); + break; + case AirCtrlParser.upTem: + airTempState = curState[1] & 0xFF; + airText.setText("绌鸿皟璋冩俯锛屼笂鍗囨俯搴︼細" + (curState[1] & 0xFF)); + showToast("绌鸿皟璋冩俯锛屼笂鍗囨俯搴︼細" + (curState[1] & 0xFF)); + Log.i("djl", "绌鸿皟璋冩俯锛屼笂鍗囨俯搴︼細" + (curState[1] & 0xFF)); + break; + case AirCtrlParser.downTem: + airTempState = curState[1] & 0xFF; + airText.setText("绌鸿皟璋冩俯锛屼笅闄嶆俯搴︼細" + (curState[1] & 0xFF)); + showToast("绌鸿皟璋冩俯锛屼笅闄嶆俯搴︼細" + (curState[1] & 0xFF)); + Log.i("djl", "绌鸿皟璋冩俯锛屼笅闄嶆俯搴︼細" + (curState[1] & 0xFF)); + break; + } + } + break; + case HDLApConfig.TYPE_SENSOR_DRY_CONTACT: + //浼犳劅鍣� 骞叉帴鐐� 銆傚彧鏈夊紑鍏崇姸鎬� + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---骞叉帴鐐圭姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float dryContactValue = (float) event.getAppliancesInfo().getCurStateObject(); + String dryContactUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---骞叉帴鐐圭姸鎬侊細" + dryContactValue + dryContactUnit); + Log.i("djl", "浼犳劅鍣�---骞叉帴鐐圭姸鎬侊細" + dryContactValue + dryContactUnit); + break; + case HDLApConfig.TYPE_SENSOR_MOVEMENT_DETECTOR: + //浼犳劅鍣� 绉诲姩鎺㈡祴 銆傜伒鏁忓害 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---绉诲姩鎺㈡祴鐏垫晱搴︾姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float mdValue = (float) event.getAppliancesInfo().getCurStateObject(); + String mdValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---绉诲姩鎺㈡祴鐏垫晱搴︼細" + mdValue + mdValueUnit); + Log.i("djl", "浼犳劅鍣�---绉诲姩鎺㈡祴鐏垫晱搴︼細" + mdValue + mdValueUnit); + break; + case HDLApConfig.TYPE_SENSOR_TEMP: + //浼犳劅鍣� 娓╁害 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---娓╁害鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float tempValue = (float) event.getAppliancesInfo().getCurStateObject(); + String tempValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---娓╁害锛�" + tempValue + tempValueUnit); + Log.i("djl", "浼犳劅鍣�---娓╁害锛�" + tempValue + tempValueUnit); + break; + case HDLApConfig.TYPE_SENSOR_HUMIDITY: + //浼犳劅鍣� 婀垮害 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---婀垮害鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float humidityValue = (float) event.getAppliancesInfo().getCurStateObject(); + String humidityValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---婀垮害锛�" + humidityValue + humidityValueUnit); + Log.i("djl", "浼犳劅鍣�---婀垮害锛�" + humidityValue + humidityValueUnit); + break; + case HDLApConfig.TYPE_SENSOR_ILLUMINACE: + //浼犳劅鍣� 鐓у害 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---鐓у害鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float illuminaceValue = (float) event.getAppliancesInfo().getCurStateObject(); + String illuminaceValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---鐓у害锛�" + illuminaceValue + illuminaceValueUnit); + Log.i("djl", "浼犳劅鍣�---鐓у害锛�" + illuminaceValue + illuminaceValueUnit); + break; + case HDLApConfig.TYPE_SENSOR_VOC: + //浼犳劅鍣� 褰撳墠绌烘皵璐ㄩ噺绛夌骇 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---褰撳墠绌烘皵璐ㄩ噺绛夌骇鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float vocValue = (float) event.getAppliancesInfo().getCurStateObject(); + String vocValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---褰撳墠绌烘皵璐ㄩ噺绛夌骇锛�" + vocValue + vocValueUnit); + Log.i("djl", "浼犳劅鍣�---褰撳墠绌烘皵璐ㄩ噺绛夌骇锛�" + 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().getCurStateObject(); + String pm2_5ValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---pm2.5锛�" + pm2_5Value + pm2_5ValueUnit); + Log.i("djl", "浼犳劅鍣�---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().getCurStateObject(); + String co2ValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---浜屾哀鍖栫⒊锛�" + co2Value + co2ValueUnit); + Log.i("djl", "浼犳劅鍣�---浜屾哀鍖栫⒊锛�" + co2Value + co2ValueUnit); + break; + case HDLApConfig.TYPE_SENSOR_LPG: + //浼犳劅鍣� 娑插寲鐭虫补姘� + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---娑插寲鐭虫补姘旂姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float lpgValue = (float) event.getAppliancesInfo().getCurStateObject(); + String lpgValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---娑插寲鐭虫补姘旓細" + lpgValue + lpgValueUnit); + Log.i("djl", "浼犳劅鍣�---娑插寲鐭虫补姘旓細" + lpgValue + lpgValueUnit); + break; + case HDLApConfig.TYPE_SENSOR_CO_H2: + //浼犳劅鍣� 浜哄伐鐓ゆ皵 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---浜哄伐鐓ゆ皵鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float coh2Value = (float) event.getAppliancesInfo().getCurStateObject(); + String coh2ValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---浜哄伐鐓ゆ皵锛�" + coh2Value + coh2ValueUnit); + Log.i("djl", "浼犳劅鍣�---浜哄伐鐓ゆ皵锛�" + coh2Value + coh2ValueUnit); + break; + case HDLApConfig.TYPE_SENSOR_CH4: + //浼犳劅鍣� 澶╃劧姘� + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---澶╃劧姘旂姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float ch4Value = (float) event.getAppliancesInfo().getCurStateObject(); + String ch4ValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---澶╃劧姘旓細" + ch4Value + ch4ValueUnit); + Log.i("djl", "浼犳劅鍣�---澶╃劧姘旓細" + ch4Value + ch4ValueUnit); + break; + case HDLApConfig.TYPE_SENSOR_SMOG: + //浼犳劅鍣� 鐑熼浘 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---鐑熼浘鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float smogValue = (float) event.getAppliancesInfo().getCurStateObject(); + String smogValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---鐑熼浘锛�" + smogValue + smogValueUnit); + Log.i("djl", "浼犳劅鍣�---鐑熼浘锛�" + smogValue + smogValueUnit); + break; + case HDLApConfig.TYPE_SENSOR_WIND_SPEED: + //浼犳劅鍣� 椋庨�� + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---椋庨�熺姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float windSpeedValue = (float) event.getAppliancesInfo().getCurStateObject(); + String windSpeedValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---椋庨�燂細" + windSpeedValue + windSpeedValueUnit); + Log.i("djl", "浼犳劅鍣�---椋庨�燂細" + windSpeedValue + windSpeedValueUnit); + break; + case HDLApConfig.TYPE_SENSOR_WIND_PRESSURE: + //浼犳劅鍣� 椋庡帇 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---椋庡帇鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float windPressureValue = (float) event.getAppliancesInfo().getCurStateObject(); + String windPressureValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---椋庡帇锛�" + windPressureValue + windPressureValueUnit); + Log.i("djl", "浼犳劅鍣�---椋庡帇锛�" + windPressureValue + windPressureValueUnit); + break; + case HDLApConfig.TYPE_SENSOR_LIQUID_FLOW: + //浼犳劅鍣� 娑蹭綋娴侀噺 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---娑蹭綋娴侀噺鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float liquidFlowValue = (float) event.getAppliancesInfo().getCurStateObject(); + String liquidFlowValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---娑蹭綋娴侀噺锛�" + liquidFlowValue + liquidFlowValueUnit); + Log.i("djl", "浼犳劅鍣�---娑蹭綋娴侀噺锛�" + liquidFlowValue + liquidFlowValueUnit); + break; + case HDLApConfig.TYPE_SENSOR_LIQUID_PRESSURE: + //浼犳劅鍣� 娑蹭綋鍘嬪姏 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---娑蹭綋鍘嬪姏鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float liquidPressureValue = (float) event.getAppliancesInfo().getCurStateObject(); + String liquidPressureValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---娑蹭綋鍘嬪姏锛�" + liquidPressureValue + liquidPressureValueUnit); + Log.i("djl", "浼犳劅鍣�---娑蹭綋鍘嬪姏锛�" + liquidPressureValue + liquidPressureValueUnit); + break; + case HDLApConfig.TYPE_SENSOR_LIQUID_DEPTH: + //浼犳劅鍣� 娑蹭綋娣卞害 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---娑蹭綋娣卞害鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float liquidDepthValue = (float) event.getAppliancesInfo().getCurStateObject(); + String liquidDepthValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---娑蹭綋娣卞害锛�" + liquidDepthValue + liquidDepthValueUnit); + Log.i("djl", "浼犳劅鍣�---娑蹭綋娣卞害锛�" + liquidDepthValue + liquidDepthValueUnit); + break; + case HDLApConfig.TYPE_SENSOR_RAIN_FALL: + //浼犳劅鍣� 闆ㄩ噺 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---闆ㄩ噺鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float rainFallValue = (float) event.getAppliancesInfo().getCurStateObject(); + String rainFallValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---闆ㄩ噺锛�" + rainFallValue + rainFallValueUnit); + Log.i("djl", "浼犳劅鍣�---闆ㄩ噺锛�" + rainFallValue + rainFallValueUnit); + break; + case HDLApConfig.TYPE_SENSOR_WEIGHT: + //浼犳劅鍣� 閲嶉噺 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---閲嶉噺鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float weightValue = (float) event.getAppliancesInfo().getCurStateObject(); + String weightValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---閲嶉噺锛�" + weightValue + weightValueUnit); + Log.i("djl", "浼犳劅鍣�---閲嶉噺锛�" + 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().getCurStateObject(); + String height_lengthValueUnit = ((SensorStateBackInfo) event).getUnite(); + showToast("浼犳劅鍣�---閲嶉噺锛�" + height_lengthValue + height_lengthValueUnit); + Log.i("djl", "浼犳劅鍣�---閲嶉噺锛�" + 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().getCurStateObject(); + String objectSpeedUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣� + showToast("浼犳劅鍣�---鐗╀綋閫熷害锛�" + objectSpeedValue + objectSpeedUnite); + Log.i("djl", "浼犳劅鍣�---鐗╀綋閫熷害锛�" + objectSpeedValue + objectSpeedUnite); + break; + case HDLApConfig.TYPE_SENSOR_SHAKE: + //浼犳劅鍣� 闇囧姩 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---闇囧姩鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float shakeValue = (float) event.getAppliancesInfo().getCurStateObject(); + String shakeValueUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣� + showToast("浼犳劅鍣�---闇囧姩锛�" + shakeValue + shakeValueUnite); + Log.i("djl", "浼犳劅鍣�---闇囧姩锛�" + shakeValue + shakeValueUnite); + break; + case HDLApConfig.TYPE_SENSOR_VOLTAGE: + //浼犳劅鍣� 鐢靛帇 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---鐢靛帇鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float voltageValue = (float) event.getAppliancesInfo().getCurStateObject(); + String voltageValueUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣� + showToast("浼犳劅鍣�---鐢靛帇锛�" + voltageValue + voltageValueUnite); + Log.i("djl", "浼犳劅鍣�---鐢靛帇锛�" + voltageValue + voltageValueUnite); + break; + case HDLApConfig.TYPE_SENSOR_ELECTRICITY: + //浼犳劅鍣� 鐢垫祦 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---鐢垫祦鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float electricityValue = (float) event.getAppliancesInfo().getCurStateObject(); + String electricityValueUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣� + showToast("浼犳劅鍣�---鐢垫祦锛�" + electricityValue + electricityValueUnite); + Log.i("djl", "浼犳劅鍣�---鐢垫祦锛�" + electricityValue + electricityValueUnite); + break; + case HDLApConfig.TYPE_SENSOR_POWER: + //浼犳劅鍣� 鍔熺巼 + if (appliancesInfo.getChannelNum() != event.getAppliancesInfo().getChannelNum() || !event.isSuccess()) { + showToast("鑾峰彇浼犳劅鍣�---鍔熺巼鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + float powerValue = (float) event.getAppliancesInfo().getCurStateObject(); + String powerValueUnite = ((SensorStateBackInfo) event).getUnite();//鏁板�煎崟浣� + showToast("浼犳劅鍣�---鍔熺巼锛�" + powerValue + powerValueUnite); + Log.i("djl", "浼犳劅鍣�---鍔熺巼锛�" + powerValue + powerValueUnite); + break; + + + } + } + } + + + + public void showToast(String text) { + Toast.makeText(this, text, Toast.LENGTH_SHORT).show(); + } +} diff --git a/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/FreshAirActivity.java b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/FreshAirActivity.java new file mode 100644 index 0000000..ade0506 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/FreshAirActivity.java @@ -0,0 +1,402 @@ +package com.hdl.sdk.hdl_sdk.activity; + + +import android.app.ProgressDialog; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLFreshAir.FreshAirBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLFreshAir.Parser.FreshAirParser; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommand; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DeviceStateEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.FreshAirFeedBackEvent; +import com.hdl.sdk.hdl_sdk.base.BaseActivity; +import com.hdl.sdk.hdl_sdk.utlis.HDLLog; + +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + + +/** + * 鏂伴绯荤粺鎺у埗鐣岄潰 + */ +public class FreshAirActivity extends BaseActivity { + + private Button btn_switch, btn_mode, btn_speed; + private TextView mTextView; + private AppliancesInfo appliancesInfo; + + private int airSwitchState;//Demo浠呬互姝や綔涓烘紨绀猴紝瀹為檯璇锋牴鎹渶姹傚紑鍙戣璁� + private int airModeState; + private int airSpeedState; + private int ctrlId; + private boolean isZigbee = false; + private ProgressDialog proDialog; + + /** + * 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true + * + * @return true + */ + @Override + protected boolean isRegisterEventBus() { + return true; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(com.hdl.sdk.hdl_sdk.R.layout.activity_fresh_air); + initcurState(); + initView(); + initClickOnEvent(); + showStateView(); + //姝ゆ柟娉曚负涓诲姩鑾峰彇鍗曚竴璁惧鐘舵�侊紝閫昏緫妯″潡銆佽儗鏅煶涔愭ā鍧楁病鏈夎繖涓猘pi + //鐩墠浠呮敮鎸佺伅鍏夛紝绐楀笜锛岀┖璋冧笉鍙戦�佽幏鍙栫姸鎬佸懡浠ゅ彧浠嶴DK鏈湴鑾峰彇锛屼紶鎰熷櫒锛屽湴鐑ā鍧楋紝鏂伴绯荤粺鏄彂閫佽幏鍙栫姸鎬佸懡浠や粠缃戠粶涓婅幏鍙栥�� + HDLCommand.getDeviceState(FreshAirActivity.this,appliancesInfo,isZigbee); + } + + + @Override + protected void onDestroy() { + super.onDestroy(); + proDialog.dismiss(); + HDLLog.I("onDestroy: FreshAirActivity"); + } + + private void initcurState() { + appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl"); + isZigbee = getIntent().getExtras().getBoolean("isZigbee2Item"); + } + + private void initView() { + mTextView = findViewById(com.hdl.sdk.hdl_sdk.R.id.tv_fresh_air); + btn_switch = findViewById(com.hdl.sdk.hdl_sdk.R.id.btn_switch); + btn_speed = findViewById(com.hdl.sdk.hdl_sdk.R.id.btn_speed); + btn_mode = findViewById(com.hdl.sdk.hdl_sdk.R.id.btn_mode); + + proDialog = new ProgressDialog(this); + proDialog.setTitle("姝e湪鍙戦�佹帶鍒跺懡浠�..."); + proDialog.setMessage("璇疯�愬績绛夊緟"); + proDialog.onStart(); + } + + private void initClickOnEvent() { + + btn_switch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + proDialog.show(); + ctrlId = FreshAirParser.freshAirSwich; + //婕旂ず褰撳墠鐘舵�佷负鍏筹紝璁剧疆涓哄紑銆傚紑锛岃缃负鍏炽�� + if (airSwitchState == 0) { + //鏂伴寮� + HDLCommand.freshAirCtrl(appliancesInfo, FreshAirParser.freshAirSwich, FreshAirParser.freshAirOn,isZigbee); + } else { + //鏂伴鍏� + HDLCommand.freshAirCtrl(appliancesInfo, FreshAirParser.freshAirSwich, FreshAirParser.freshAirOff,isZigbee); + } + } + }); + + // 0 鍏筹紝1浣庯紝2涓紝3楂� + btn_speed.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + proDialog.show(); + ctrlId = FreshAirParser.freshAirSpeed; + switch (airSpeedState) { + case 0: + //鑻ュ綋鍓嶉閫熶负鍏筹紝鍒欑偣鍑绘寜閽缃负浣庨�� + HDLCommand.freshAirCtrl(appliancesInfo, FreshAirParser.freshAirSpeed, FreshAirParser.freshAirSpeedLow,isZigbee); + break; + case 1: + //鑻ュ綋鍓嶉閫熶负浣庨�燂紝鍒欑偣鍑绘寜閽缃负涓�� + HDLCommand.freshAirCtrl(appliancesInfo, FreshAirParser.freshAirSpeed, FreshAirParser.freshAirSpeedMid,isZigbee); + break; + case 2: + //鑻ュ綋鍓嶉閫熶负涓�燂紝鍒欑偣鍑绘寜閽缃负楂橀�� + HDLCommand.freshAirCtrl(appliancesInfo, FreshAirParser.freshAirSpeed, FreshAirParser.freshAirSpeedHigh,isZigbee); + break; + case 3: + //鑻ュ綋鍓嶉閫熶负楂橀�燂紝鍒欑偣鍑绘寜閽缃负鍏� + HDLCommand.freshAirCtrl(appliancesInfo, FreshAirParser.freshAirSpeed, FreshAirParser.freshAirSpeedOff,isZigbee); + break; + default: + //璁剧疆涓哄叧 + HDLCommand.freshAirCtrl(appliancesInfo, FreshAirParser.freshAirSpeed, FreshAirParser.freshAirSpeedOff,isZigbee); + break; + + + } + } + }); + + +// 0鎵嬪姩锛�1 鑷姩,2 鏅鸿兘锛�3 瀹氭椂 + btn_mode.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + proDialog.show(); + ctrlId = FreshAirParser.freshAirMode; + switch (airModeState) { + case 0: + //鑻ュ綋鍓嶆ā寮忎负鎵嬪姩锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓鸿嚜鍔� + HDLCommand.freshAirCtrl(appliancesInfo, FreshAirParser.freshAirMode, FreshAirParser.freshAirModeAuto,isZigbee); + break; + case 1: + //鑻ュ綋鍓嶆ā寮忎负鑷姩锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓烘櫤鑳� + HDLCommand.freshAirCtrl(appliancesInfo, FreshAirParser.freshAirMode, FreshAirParser.freshAirModeIntelligent,isZigbee); + break; + case 2: + //鑻ュ綋鍓嶆ā寮忔櫤鑳斤紝鍒欑偣鍑绘寜閽缃负瀹氭椂 + HDLCommand.freshAirCtrl(appliancesInfo, FreshAirParser.freshAirMode, FreshAirParser.freshAirModeTiming,isZigbee); + break; + case 3: + //鑻ュ綋鍓嶆ā寮忓畾鏃讹紝鍒欑偣鍑绘寜閽缃负鎵嬪姩 + HDLCommand.freshAirCtrl(appliancesInfo, FreshAirParser.freshAirMode, FreshAirParser.freshAirModeManual,isZigbee); + break; + default: +// 鎵嬪姩 + HDLCommand.freshAirCtrl(appliancesInfo, FreshAirParser.freshAirMode, FreshAirParser.freshAirModeManual,isZigbee); + break; + + } + } + }); + } + + /** + * mTextView 涓婃樉绀哄綋鍓嶇姸鎬� + */ + private void showStateView() { + if (appliancesInfo.getFeedbackState() != null) { + String stringFAState = ""; +// //鏂规硶1锛� +// byte[] freshAirCurState = appliancesInfo.getFeedbackState(); +// for (int index = 0; index < freshAirCurState.length; index++) { +// if (index == 1 && (freshAirCurState[index] & 0xFF) == 0) { +// airSwitchState = 0; +// stringFAState += " 鏂伴绯荤粺锛氬叧闂�"; +// //濡傛灉绌鸿皟鍏抽棴鐘舵�侊紝鍒欐棤闇�鍐嶉亶鍘� +// break; +// } +// if (index == 1 && (freshAirCurState[index] & 0xFF) == 1) { +// airSwitchState = 1; +// stringFAState += " 鏂伴绯荤粺锛氭墦寮�"; +// } +// +// switch (index) { +// case 2: +// stringFAState += "\n" + getSpeedStateString(freshAirCurState[index] & 0xFF); +// case 3: +// //妯″紡锛�0鎵嬪姩锛�1 鑷姩,2 鏅鸿兘锛�3 瀹氭椂锛� +// stringFAState += "\n" + getModeStateString(freshAirCurState[index] & 0xFF); +// default: +// break; +// } +// } + //鏂规硶2锛� + FreshAirBackInfo mFreshAirBackInfo = new FreshAirBackInfo(appliancesInfo); + if (mFreshAirBackInfo == null) { + stringFAState = "鏈幏鍙栧埌鏂伴绯荤粺鐘舵��"; + } else { + + if (mFreshAirBackInfo.getIsOn() == 0) { + stringFAState = "鏂伴绯荤粺锛氬叧闂�"; + } else if (mFreshAirBackInfo.getIsOn() == 1) { + stringFAState = "鏂伴绯荤粺锛氭墦寮�"; + stringFAState += "\n" + getSpeedStateString(mFreshAirBackInfo.getFreshAirSpeed()); + stringFAState += "\n" + getModeStateString(mFreshAirBackInfo.getFreshAirMode()); + } else { + stringFAState = "鏈煡寮�鍏崇姸鎬�"; + } + + } + mTextView.setText(stringFAState); + } else { + mTextView.setText("鏈幏鍙栧埌鏂伴璁惧鐘舵��"); + } + + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onFreshAirFeedBackEventMain(FreshAirFeedBackEvent event) { + proDialog.dismiss(); + if (event.getFreshAirBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() + && event.getFreshAirBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() + && event.getFreshAirBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum() + ) { + //鍏堝垽鏂槸鍚﹁秴鏃� + if (!event.isSuccess()) { + showToast("鏂伴鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯"); + return; + } + + String message = ""; + FreshAirBackInfo mFreshAirBackInfo = event.getFreshAirBackInfo(); + switch (ctrlId) { //ctrlId 褰撳墠鎺у埗绫诲瀷 + case FreshAirParser.freshAirSwich: + message = getSwichStateString(mFreshAirBackInfo.getIsOn()); + break; + case FreshAirParser.freshAirSpeed: + message = getSpeedStateString(mFreshAirBackInfo.getFreshAirSpeed()); + break; + case FreshAirParser.freshAirMode: + message = getModeStateString(mFreshAirBackInfo.getFreshAirMode()); + break; + default: + break; + + } + + /*********鏍规嵁闇�姹傛樉绀�********* + message += "\n" + "瀹ゅ唴娓╁害锛�" + mFreshAirBackInfo.getInTemp(); + message += "\n" + "瀹ゅ娓╁害锛�" + mFreshAirBackInfo.getOutTemp(); + message += "\n" + "瀹ゅ唴婀垮害锛�" + mFreshAirBackInfo.getHumidty(); + message += "\n" + "PM2.5锛�" + mFreshAirBackInfo.getInTemp(); + message += "\n" + "TVOC锛�" + mFreshAirBackInfo.getInTemp(); + message += "\n" + "CO2锛�" + mFreshAirBackInfo.getInTemp(); + *********鏍规嵁闇�姹傛樉绀�*********/ + + mTextView.setText(message); + showToast(message); + HDLLog.I(message); + } + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onDeviceStateEventMain(DeviceStateEvent event) { + proDialog.dismiss(); + if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() + && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() + ) { + //杩欎釜杩斿洖鐨勪俊鎭槸褰撳墠鐘舵�佺殑 + switch (event.getAppliancesInfo().getDeviceType()) { + case HDLApConfig.TYPE_FRESH_AIR: + if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) { + if (!event.isSuccess()) { + showToast("鑾峰彇鏂伴鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + String message = ""; + FreshAirBackInfo mFreshAirBackInfo = new FreshAirBackInfo(event.getAppliancesInfo()); + if (mFreshAirBackInfo == null) { + showToast("鑾峰彇鏂伴鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + + if(mFreshAirBackInfo.getIsOn() == FreshAirParser.freshAirOn) { + message = getSwichStateString(mFreshAirBackInfo.getIsOn()); + message += "\n" + getSpeedStateString(mFreshAirBackInfo.getFreshAirSpeed()); + message += "\n" + getModeStateString(mFreshAirBackInfo.getFreshAirMode()); + message += "\n" + "瀹ゅ唴娓╁害锛�" + mFreshAirBackInfo.getInTemp(); + message += "\n" + "瀹ゅ娓╁害锛�" + mFreshAirBackInfo.getOutTemp(); + message += "\n" + "瀹ゅ唴婀垮害锛�" + mFreshAirBackInfo.getHumidty(); + message += "\n" + "PM2.5锛�" + mFreshAirBackInfo.getInTemp(); + message += "\n" + "TVOC锛�" + mFreshAirBackInfo.getInTemp(); + message += "\n" + "CO2锛�" + mFreshAirBackInfo.getInTemp(); + }else { + message = getSwichStateString(mFreshAirBackInfo.getIsOn()); + } + + mTextView.setText(message); + showToast(message); + HDLLog.I(message); + + } + break; + } + } + } + + + /** + * getSwichStateString + * + * @param mState + * @return + */ + private String getSwichStateString(int mState) { + String mStrState = "鏈煡"; + airSwitchState = mState; //鏇存柊寮�鍏崇姸鎬� + + switch (mState) { + case FreshAirParser.freshAirOn: + mStrState = "鏂伴绯荤粺锛氭墦寮�"; + break; + case FreshAirParser.freshAirOff: + mStrState = "鏂伴绯荤粺锛氬叧闂�"; + break; + + default: + mStrState = "鏈煡鐘舵��"; + break; + } + return mStrState; + } + + /** + * getSpeedStateString + * + * @param mState + * @return + */ + private String getSpeedStateString(int mState) { + String mStrState = "鏈煡"; + airSpeedState = mState; //鏇存柊褰撳墠椋庨�熺姸鎬� + switch (mState) { + case FreshAirParser.freshAirSpeedOff: + mStrState = "椋庨�燂細鍏�"; + break; + case FreshAirParser.freshAirSpeedLow: + mStrState = "椋庨�燂細浣�"; + break; + case FreshAirParser.freshAirSpeedMid: + mStrState = "椋庨�燂細涓�"; + break; + case FreshAirParser.freshAirSpeedHigh: + mStrState = "椋庨�燂細楂�"; + break; + + default: + mStrState = "鏈煡椋庨�熺姸鎬�"; + break; + } + return mStrState; + } + + /** + * getModeStateString + * + * @param mState + * @return + */ + private String getModeStateString(int mState) { + String mStrState = "鏈煡"; + airModeState = mState; //鏇存柊妯″紡鐘舵�� + switch (mState) { + case FreshAirParser.freshAirModeManual: + mStrState = "妯″紡锛氭墜鍔�"; + break; + case FreshAirParser.freshAirModeAuto: + mStrState = "妯″紡锛氳嚜鍔�"; + break; + case FreshAirParser.freshAirModeIntelligent: + mStrState = "妯″紡锛氭櫤鑳�"; + break; + case FreshAirParser.freshAirModeTiming: + mStrState = "妯″紡锛氬畾鏃�"; + break; + + default: + mStrState = "鏈煡妯″紡鐘舵��"; + break; + } + return mStrState; + } +} diff --git a/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java new file mode 100644 index 0000000..e64f7bb --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java @@ -0,0 +1,431 @@ +package com.hdl.sdk.hdl_sdk.activity; + + +import android.app.ProgressDialog; +import android.os.Bundle; +import android.text.TextUtils; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; + +import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.GeothermalBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.Parser.GeothermalParser; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommand; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DeviceStateEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.EventCode; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.GeothermalFeedBackEvent; +import com.hdl.sdk.hdl_sdk.R; +import com.hdl.sdk.hdl_sdk.base.BaseActivity; +import com.hdl.sdk.hdl_sdk.utlis.HDLLog; + +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +/** + * 鍦扮儹妯″潡鎺у埗鐣岄潰 + */ +public class GeothermalActivity extends BaseActivity { + + private Button btn_switch, btn_mode, btn_temp; + private TextView mTextView; + private EditText tempEditText; + private AppliancesInfo appliancesInfo; + + private int gSwitchState;//Demo浠呬互姝や綔涓烘紨绀猴紝瀹為檯璇锋牴鎹渶姹傚紑鍙戣璁� + private int gModeState; + private int gTempState; + private int ctrlId; + private ProgressDialog proDialog; + private boolean isZigbee = false; + /** + * 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true + * + * @return true + */ + @Override + protected boolean isRegisterEventBus() { + return true; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_geothermal); + + initcurState(); + initView(); + initClickOnEvent(); + showStateView(); + + //姝ゆ柟娉曚负涓诲姩鑾峰彇鍗曚竴璁惧鐘舵�侊紝閫昏緫妯″潡銆佽儗鏅煶涔愭ā鍧楁病鏈夎繖涓猘pi + //鐩墠浠呮敮鎸佺伅鍏夛紝绐楀笜锛岀┖璋冧笉鍙戦�佽幏鍙栫姸鎬佸懡浠ゅ彧浠嶴DK鏈湴鑾峰彇锛屼紶鎰熷櫒锛屽湴鐑ā鍧楋紝鏂伴绯荤粺鏄彂閫佽幏鍙栫姸鎬佸懡浠や粠缃戠粶涓婅幏鍙栥�� + HDLCommand.getDeviceState(GeothermalActivity.this,appliancesInfo,isZigbee); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + proDialog.dismiss(); + HDLLog.I("onDestroy: GeothermalActivity"); + } + + private void initcurState() { + appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl"); + isZigbee = getIntent().getExtras().getBoolean("isZigbee2Item"); + + } + + private void initView() { + mTextView = findViewById(R.id.tv_geothermal); + btn_switch = findViewById(R.id.btn_switch); + btn_mode = findViewById(R.id.btn_mode); + btn_temp = findViewById(R.id.btn_temp); + tempEditText = findViewById(R.id.et_temp); + + proDialog = new ProgressDialog(this); + proDialog.setTitle("姝e湪鍙戦�佹帶鍒跺懡浠�..."); + proDialog.setMessage("璇疯�愬績绛夊緟"); + proDialog.onStart(); + } + + private void initClickOnEvent() { + btn_switch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + proDialog.show(); + ctrlId = GeothermalParser.gSwich; + //婕旂ず褰撳墠鐘舵�佷负鍏筹紝璁剧疆涓哄紑銆傚紑锛岃缃负鍏炽�� + if (gSwitchState == 0) { + //鍦扮儹寮� + HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gSwich, GeothermalParser.gSwichOn); + } else { + //鍦扮儹鍏� + HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gSwich, GeothermalParser.gSwichOff); + } + } + }); + + +// 0鎵嬪姩锛�1 鑷姩,2 鏅鸿兘锛�3 瀹氭椂 + btn_mode.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + proDialog.show(); + ctrlId = GeothermalParser.gMode; + switch (gModeState) { + case 1: + //鑻ュ綋鍓嶆ā寮忎负鏅�氾紝鍒欑偣鍑绘寜閽缃负鐧藉ぉ妯″紡 + HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gMode, GeothermalParser.gModeDay); + break; + case 2: + //鑻ュ綋鍓嶆ā寮忕櫧澶╋紝鍒欑偣鍑绘寜閽缃负澶滈棿妯″紡 + HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gMode, GeothermalParser.gModeNight); + break; + case 3: + //鑻ュ綋鍓嶆ā寮忓闂达紝鍒欑偣鍑绘寜閽缃负绂诲紑妯″紡 + HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gMode, GeothermalParser.gModeLeave); + break; + case 4: + //鑻ュ綋鍓嶆ā寮忕寮�锛屽垯鐐瑰嚮鎸夐挳璁剧疆涓鸿嚜鍔ㄦā寮� + HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gMode, GeothermalParser.gModeAuto); + break; + case 5: + //鑻ュ綋鍓嶆ā寮忚嚜鍔ㄦā寮忥紝鍒欑偣鍑绘寜閽缃负鏅�氭ā寮� + HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gMode, GeothermalParser.gModeNormal); + break; + default: +// 鏅�氭ā寮� + HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gMode, GeothermalParser.gModeNormal); + break; + + } + + + + } + }); + + + btn_temp.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + String tempStr = tempEditText.getText().toString(); + if (TextUtils.isEmpty(tempStr)) { + showToast("璁剧疆鐨勬俯搴︿笉鑳戒负绌�"); + return; + } + int tempInt = Integer.parseInt(tempStr); + + if (tempInt < 16 || tempInt > 35) { + showToast("娓╁害璁剧疆鑼冨洿涓猴細16~35鎽勬皬搴�(鈩�)"); + return; + } + proDialog.show(); +// HDLCommand.geothermalCtrlTemp(appliancesInfo, tempInt);//鑷姩鏍规嵁褰撳墠妯″紡璁剧疆褰撳墠妯″紡鐨勬俯搴︺�� + + switch (gModeState) { + case 1: + case 2: + case 3: + case 4: + HDLCommand.geothermalCtrlTemp(appliancesInfo, tempInt);//鑷姩鏍规嵁褰撳墠妯″紡璁剧疆褰撳墠妯″紡鐨勬俯搴︺�� + break; + case 5: + proDialog.dismiss(); + //褰撳墠鍦扮儹妯″紡涓鸿嚜鍔� + showToast("鑷姩妯″紡锛屼笉鑳芥帶鍒舵俯搴�"); + break; + default: + proDialog.dismiss(); + //褰撳墠鍦扮儹妯″紡涓鸿嚜鍔� + showToast("鏈煡妯″紡锛屼笉鑳芥帶鍒舵俯搴�"); + break; + + } + +// switch (gModeState) { +// +// case 1: +// //褰撳墠鍦扮儹妯″紡涓烘櫘閫� +// HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gNormalTemp, tempInt);//鏅�氭俯搴� +// ctrlId = GeothermalParser.gNormalTemp; +// break; +// case 2: +// //褰撳墠鍦扮儹妯″紡涓虹櫧澶� +// HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gDayTemp, tempInt);//鐧藉ぉ娓╁害 +// ctrlId = GeothermalParser.gDayTemp; +// break; +// case 3: +// //褰撳墠鍦扮儹妯″紡涓哄闂� +// HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gNightTemp, tempInt);//澶滈棿娓╁害 +// ctrlId = GeothermalParser.gNightTemp; +// break; +// case 4: +// //褰撳墠鍦扮儹妯″紡涓虹寮� +// HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gLeaveTemp, tempInt);//绂诲紑娓╁害 +// ctrlId = GeothermalParser.gLeaveTemp; +// break; +// case 5: +// proDialog.dismiss(); +// //褰撳墠鍦扮儹妯″紡涓鸿嚜鍔� +// showToast("鑷姩妯″紡锛屼笉鑳芥帶鍒舵俯搴�"); +// break; +// default: +// proDialog.dismiss(); +// //褰撳墠鍦扮儹妯″紡涓鸿嚜鍔� +// showToast("鏈煡妯″紡锛屼笉鑳芥帶鍒舵俯搴�"); +// break; +// +// } + + + } + }); + + + } + + private void showStateView() { + if (appliancesInfo.getFeedbackState() != null) { + GeothermalBackInfo mGeothermalBackInfo = new GeothermalBackInfo(appliancesInfo, false); + + String stringState = ""; + if (mGeothermalBackInfo.getIsOn() == GeothermalParser.gSwichOff) { + stringState = "鍦扮儹妯″潡锛氬叧闂�"; + } else if (mGeothermalBackInfo.getIsOn() == GeothermalParser.gSwichOn) { + stringState = "鍦扮儹妯″潡锛氭墦寮�"; + + stringState += "\n" + getModeStateString(mGeothermalBackInfo.getgMode()); + + stringState += "\n鏅�氭ā寮忔俯搴︼細" + mGeothermalBackInfo.getgNormalTemp(); + + stringState += "\n鐧藉ぉ妯″紡娓╁害锛�" + mGeothermalBackInfo.getgDayTemp(); + + stringState += "\n澶滈棿妯″紡娓╁害锛�" + mGeothermalBackInfo.getgNightTemp(); + + stringState += "\n绂诲紑妯″紡娓╁害锛�" + mGeothermalBackInfo.getgLeaveTemp(); + } else { + stringState = "鏈煡寮�鍏崇姸鎬�"; + } + + mTextView.setText(stringState); + } else { + mTextView.setText("鏈幏鍙栧埌鍦扮儹妯″潡鐘舵��"); + } + + } + + + /** + * getSwichStateString + * + * @param mState + * @return + */ + private String getSwichStateString(int mState) { + String mStrState = "鏈煡"; + gSwitchState = mState; //鏇存柊寮�鍏崇姸鎬� + switch (mState) { + case GeothermalParser.gSwichOn: + mStrState = "鍦扮儹妯″潡锛氭墦寮�"; + break; + case GeothermalParser.gSwichOff: + mStrState = "鍦扮儹妯″潡锛氬叧闂�"; + break; + + default: + mStrState = "鏈煡鐘舵��"; + break; + } + return mStrState; + } + + + /** + * getModeStateString + * + * @param mState + * @return + */ + private String getModeStateString(int mState) { + String mStrState = "鏈煡"; + gModeState = mState; //鏇存柊妯″紡鐘舵�� + switch (mState) { + case GeothermalParser.gModeNormal: + mStrState = "妯″紡锛氭櫘閫�"; + break; + case GeothermalParser.gModeDay: + mStrState = "妯″紡锛氱櫧澶�"; + break; + case GeothermalParser.gModeNight: + mStrState = "妯″紡锛氬闂�"; + break; + case GeothermalParser.gModeLeave: + mStrState = "妯″紡锛氱寮�"; + break; + case GeothermalParser.gModeAuto: + mStrState = "妯″紡锛氳嚜鍔�"; + break; + + default: + mStrState = "鏈煡妯″紡鐘舵��"; + break; + } + return mStrState; + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onGeothermalFeedBackEventMain(GeothermalFeedBackEvent event) { + proDialog.dismiss(); + if (event.getGeothermalBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() + && event.getGeothermalBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() + && event.getGeothermalBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum() + ) { + //鍏堝垽鏂槸鍚﹁秴鏃� + if (event.getStatusID() == EventCode.FAILURE) { + showToast("鍦扮儹妯″潡鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯"); + return; + } + + if (event.getStatusID() == EventCode.DATAEMPTY) { + showToast("鍦扮儹妯″潡,杩斿洖鏁版嵁涓虹┖"); + return; + } + GeothermalBackInfo mGeothermalBackInfo = event.getGeothermalBackInfo(); + showGeothermalBackInfo(mGeothermalBackInfo); + +// String message = ""; +// GeothermalBackInfo mGeothermalBackInfo = event.getGeothermalBackInfo(); + +// switch (ctrlId) { //ctrlId 褰撳墠鎺у埗绫诲瀷,鍙弽棣堟帶鍒剁殑鐘舵�� +// case GeothermalParser.gSwich: +// message = getSwichStateString(mGeothermalBackInfo.getIsOn()); +// break; +// case GeothermalParser.gMode: +// message = getModeStateString(mGeothermalBackInfo.getgMode()); +// break; +// case GeothermalParser.gNormalTemp: +//// gTempState = mGeothermalBackInfo.getgNormalTemp(); +// message = "鏅�氭ā寮忔俯搴︼細" + mGeothermalBackInfo.getgNormalTemp(); +// break; +// +// +// case GeothermalParser.gDayTemp: +// message = "鐧藉ぉ妯″紡娓╁害锛�" + mGeothermalBackInfo.getgDayTemp(); +// break; +// case GeothermalParser.gNightTemp: +// message = "澶滈棿妯″紡娓╁害锛�" + mGeothermalBackInfo.getgNightTemp(); +// break; +// case GeothermalParser.gLeaveTemp: +// message = "绂诲紑妯″紡娓╁害锛�" + mGeothermalBackInfo.getgLeaveTemp(); +// break; +// default: +// break; +// +// } +// +// +// mTextView.setText(message); +// showToast(message); +// HDLLog.I(message); + } + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onDeviceStateEventMain(DeviceStateEvent event) { + proDialog.dismiss(); + if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() + && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() + ) { + //杩欎釜杩斿洖鐨勪俊鎭槸褰撳墠鐘舵�佺殑 + switch (event.getAppliancesInfo().getDeviceType()) { + case HDLApConfig.TYPE_GEOTHERMAL_MODULE: + if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) { + if (!event.isSuccess()) { + showToast("鑾峰彇鍦扮儹鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + String message = ""; + GeothermalBackInfo mGeothermalBackInfo = new GeothermalBackInfo(event.appliancesInfo, false); + + if (mGeothermalBackInfo == null) { + showToast("鑾峰彇鍦扮儹鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + + showGeothermalBackInfo(mGeothermalBackInfo); + + } + break; + } + } + } + + /** + * showGeothermalBackInfo + * @param mGeothermalBackInfo + */ + private void showGeothermalBackInfo(GeothermalBackInfo mGeothermalBackInfo){ + String message = ""; + if(mGeothermalBackInfo.getIsOn() == GeothermalParser.gSwichOn) { + message = getSwichStateString(mGeothermalBackInfo.getIsOn()); + + message += "\n" + getModeStateString(mGeothermalBackInfo.getgMode()); + message += "\n" + "鏅�氭ā寮忔俯搴︼細" + mGeothermalBackInfo.getgNormalTemp(); + message += "\n" + "鐧藉ぉ妯″紡娓╁害锛�" + mGeothermalBackInfo.getgDayTemp(); + message += "\n" + "澶滈棿妯″紡娓╁害锛�" + mGeothermalBackInfo.getgNightTemp(); + message += "\n" + "绂诲紑妯″紡娓╁害锛�" + mGeothermalBackInfo.getgLeaveTemp(); + }else { + message = getSwichStateString(mGeothermalBackInfo.getIsOn()); + } + + + mTextView.setText(message); + showToast(message); + HDLLog.I(message); + } +} diff --git a/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/MainActivity.java b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/MainActivity.java new file mode 100644 index 0000000..bc0313e --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/MainActivity.java @@ -0,0 +1,411 @@ +package com.hdl.sdk.hdl_sdk.activity; + +import android.app.ProgressDialog; +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +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.CheckBox; +import android.widget.CompoundButton; +import android.widget.EditText; +import android.widget.ListView; +import android.widget.TextView; +import android.widget.Toast; + +import com.hdl.sdk.hdl_core.Config.Configuration; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.DevicesData; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeDeviceSaveBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeGatewayInfoBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommand; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLDeviceManager; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HandleSearch; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.BgmInfoEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DevicesInfoEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.ThirdPartyBgmInfoEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.WarningInfoEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.ZigbeeDeviceInfoEvent; +import com.hdl.sdk.hdl_core.Util.NetUtil.NetWorkUtil; +import com.hdl.sdk.hdl_core.Util.TransformUtil.StringUtil; +import com.hdl.sdk.hdl_sdk.R; +import com.hdl.sdk.hdl_sdk.utlis.HDLLog; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Pattern; + +public class MainActivity extends AppCompatActivity { + + private CheckBox checkBox; + private Button btn, btn2; + private Button btn_get_all,btn_on_all, btn_off_all,btn_getlocal,btn_getlocal_add; + private Button btn_setting; + private TextView tv; + private EditText editText; + private List<DevicesData> devicesDatas; + private List<String> listString = new ArrayList<>(); + private ArrayAdapter<String> adapter; + private ProgressDialog proDia; + private ListView listView; + private List<AppliancesInfo> airList = new ArrayList<>(); + private boolean isZigbee = false; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + NetWorkUtil.setIsGetWifiBroadCast(true); + HDLCommand.init(this); +// /**閰嶇疆鏄惁寮�鍚疭DK鎵撳嵃鏃ュ織锛岄粯璁や负鎵撳紑*/ +// HDLCommand.setHDLLogOpen(false);// + + if (!EventBus.getDefault().isRegistered(this)) { + EventBus.getDefault().register(this); + } + + initView(); + setOnClick(); + +// hideTestButton(); + } + + + + private void initView() { + checkBox = findViewById(R.id.checkbox_is_zigbee); + + btn = findViewById(R.id.btn); + btn2 = findViewById(R.id.get); + + btn_get_all = findViewById(R.id.btn_get_all); + btn_on_all = findViewById(R.id.btn_on_all); + btn_off_all = findViewById(R.id.btn_off_all); + btn_getlocal = findViewById(R.id.btn_getlocal); + + btn_getlocal_add = findViewById(R.id.btn_getlocal_add); + + btn_setting = findViewById(R.id.btn_setting); + tv = findViewById(R.id.tv); + editText = findViewById(R.id.edt); + editText.setText("172.168.188.100"); + adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, listString); + listView = findViewById(R.id.listView1); + proDia = new ProgressDialog(MainActivity.this); + proDia.setTitle("姝e湪鑾峰彇鏁版嵁..."); + proDia.setMessage("璇疯�愬績绛夊緟"); + proDia.onStart(); + listView.setAdapter(adapter); + } + + private void setOnClick() { + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { + Intent intent = new Intent(); + intent.setClass(MainActivity.this, AppliancesActivity.class); + Bundle bundle = new Bundle(); + bundle.putSerializable("Appliances", (Serializable) devicesDatas.get(position).getAppliancesInfoList()); + intent.putExtras(bundle); + intent.putExtra("izZigbee",isZigbee); + MainActivity.this.startActivity(intent); + } + }); + checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + if (checked){ + isZigbee = true; + + }else { + isZigbee = false; + + } + } + }); + + btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + HDLCommand.getHomeDevices(MainActivity.this,isZigbee); + proDia.show(); + + } + }); + + btn2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (isIP(editText.getText().toString().trim())) { + HDLCommand.getRcuDevices(MainActivity.this, editText.getText().toString().trim()); + proDia.show(); + } else { + Toast.makeText(MainActivity.this, "璇疯緭鍏ユ纭牸寮廔p鍦板潃", Toast.LENGTH_SHORT).show(); + } + + + } + }); + + btn_get_all.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getAllAirList(); + } + }); + + btn_on_all.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + sendAll(true); + } + }); + + btn_off_all.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + sendAll(false); + } + }); + + + btn_getlocal.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + clearListView(); + getLocalDevicesDataList(); + } + }); + + + + + btn_getlocal_add.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(AddDevicesManuallyActivity.class); + + } + }); + + btn_setting.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(SettingActivity.class); + } + }); + } + + public void startActivity(Class<?> clazz) { + Intent intent = new Intent(this, clazz); + startActivity(intent); + } + /** + * 璇诲彇鍜屽姞杞芥湰鍦版暟鎹� + */ + private void getLocalDevicesDataList() { + devicesDatas = HDLDeviceManager.getLocalDevicesDataList(); + if (devicesDatas.size() > 0) { + updateDeviceListView(); + HandleSearch.refreshAllDevicesStateAndRemarks();//濡傛灉鏈湴鏈夋暟鎹紝鍙互璋冪敤璇ユ柟娉曪紝閬嶅巻鍙戦�佹寚浠わ紝鍒锋柊鎵�鏈夎澶囩殑澶囨敞鍜岀姸鎬� + } else { + showToast("鏈湴鏁版嵁涓虹┖"); + } + } + + /** + * 鍒锋柊璁惧鍒楄〃鏁版嵁 + */ + private void updateDeviceListView() { + int countAll = 0; + for (DevicesData devicesData : devicesDatas) { + countAll += devicesData.getAppliancesInfoList().size(); + } + tv.setText("鎬诲叡妯″潡鏁帮細" + devicesDatas.size() + " 鎬诲叡鍥炶矾鏁帮細" + countAll); + HDLLog.I("鑾峰彇鏁版嵁鎴愬姛锛氭�诲叡妯″潡鏁帮細" + devicesDatas.size() + " 鎬诲叡鍥炶矾鏁帮細" + countAll); + + 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(); + } + + + /** + * 娓呯┖鏁版嵁骞跺埛鏂板垪琛� + */ + private void clearListView() { + if (devicesDatas != null) devicesDatas.clear(); + if (listString != null) listString.clear(); + + adapter.notifyDataSetChanged(); + } + + @Override + protected void onDestroy() { + //鍏抽棴Socket鎺ユ敹 + super.onDestroy(); + HDLCommand.release(); + EventBus.getDefault().unregister(this); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onDevicesInfoEventMain(DevicesInfoEvent event) { + listString.clear(); + proDia.dismiss(); + if (!event.isSuccess()) { + Toast.makeText(MainActivity.this, "鎼滅储瓒呮椂锛岃閲嶆柊鍐嶈瘯", Toast.LENGTH_SHORT).show(); + tv.setText("鎼滅储瓒呮椂锛岃閲嶆柊鍐嶈瘯"); + return; + } + devicesDatas = event.getDesDataList(); + + int countAll = 0; + for (DevicesData devicesData : devicesDatas) { + countAll += devicesData.getAppliancesInfoList().size(); + } + tv.setText("鎬诲叡妯″潡鏁帮細" + event.getDesDataList().size() + " 鎬诲叡鍥炶矾鏁帮細" + countAll); + 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(); + } + + +// 宸插簾闄わ紝鍦烘櫙鏁版嵁宸茬粡鍜屽父瑙勮澶囧悎骞躲�傝嫢鏈夐渶姹傞渶瑕佸尯鍒嗭紝璇锋牴鎹澶囩被鍨� +// 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 onRcuIpListEventMain(RcuIpListEvent event) { +// for (int i = 0; i < event.getRcuIpList().size(); i++) { +// Log.i("djl", "鐢ㄦ埛鏀跺埌rcuIp" + event.getRcuIpList().get(i)); +// } +// //璋冪敤 +//// HDLCommand.getRcuDevices(String rcuIp); +// } + + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onWarningEventMain(WarningInfoEvent event) { + String warningType = event.getWarningType(); + Toast.makeText(MainActivity.this, warningType, Toast.LENGTH_SHORT).show(); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onBgmInfoEventMain(BgmInfoEvent event) { + int eventType = event.getType(); + + + } + + public static boolean isIP(String str) { + + // 鍖归厤 1 + // String regex = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"; + // 鍖归厤 2 + String regex = "[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}"; + + // 鍖归厤1 鍜屽尮閰�2鍧囧彲瀹炵幇Ip鍒ゆ柇鐨勬晥鏋� + Pattern pattern = Pattern.compile(regex); + + return pattern.matcher(str).matches(); + + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onBgmInfoEventMain(ThirdPartyBgmInfoEvent event) { + byte[] eventType = event.getBytes(); + + + } + + + private void hideTestButton(){ + btn_get_all.setVisibility(View.GONE); + btn_on_all.setVisibility(View.GONE); + btn_off_all.setVisibility(View.GONE); + } + + private void getAllAirList(){ + airList.clear(); + if(devicesDatas == null || devicesDatas.size() == 0) { + showToast("娌℃湁璁惧"); + return; + } + for (int j = 0; j < devicesDatas.size(); j++) { + DevicesData mDevicesData = devicesDatas.get(j); + List<AppliancesInfo> appliancesInfos = mDevicesData.getAppliancesInfoList(); + for (int i = 0; i < appliancesInfos.size(); i++) { + if (appliancesInfos.get(i).getBigType() == Configuration.AIR_BIG_TYPE) { + airList.add(appliancesInfos.get(i)); + } + } + } + + String mes = "鍏辫幏寰楋細" + airList.size() + " 鍙扮┖璋�"; + showToast(mes); + } + + private void sendAll(Boolean bOn){ + if(airList == null || airList.size() == 0) { + showToast("娌℃湁璁惧"); + return; + } + for (int j = 0; j < airList.size(); j++) { + AppliancesInfo info = airList.get(j); + if(bOn){ + HDLCommand.airCtrl(info, AirCtrlParser.airSwich, AirCtrlParser.airOn,isZigbee); + }else { + HDLCommand.airCtrl(info, AirCtrlParser.airSwich, AirCtrlParser.airOff,isZigbee); + } + + } + + } + + private void showToast(String text) { + Toast.makeText(this, text, Toast.LENGTH_SHORT).show(); + } +} diff --git a/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/SettingActivity.java b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/SettingActivity.java new file mode 100644 index 0000000..d1b5357 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/SettingActivity.java @@ -0,0 +1,138 @@ +package com.hdl.sdk.hdl_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.RelativeLayout; +import android.widget.TextView; +import android.widget.Toast; + +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommand; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLDeviceManager; +import com.hdl.sdk.hdl_core.Util.SPUtil.SPUtils; +import com.hdl.sdk.hdl_sdk.R; + + +/** + * Created by JLChen on 2020-03-02 + * 褰撳墠APP璁惧瀛愮綉鍙峰拰璁惧鍙烽厤缃紝鏍规嵁闇�瑕侀厤缃� + */ +public class SettingActivity extends Activity { + /**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 = "80"; + + private EditText bigIDEditText; + private EditText smallIDEditText; + private EditText remarkIDEditText; + + private Button btn_save_allow; + private Button btn_save_close; + private String strBigClassID = "9"; + private String strSmallClassID = "1";//绗笁鏂硅儗鏅煶涔愭ā鍧� + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_setting); + initView(); + setOnClick(); + initData(); + } + + + private void initView() { + subnetIDEditText = findViewById(R.id.et_subnetID); + deviceIDEditText = findViewById(R.id.et_deviceID); + saveButton = findViewById(R.id.btn_save); + + bigIDEditText = findViewById(R.id.et_bigclass); + smallIDEditText = findViewById(R.id.et_smallclass); + remarkIDEditText = findViewById(R.id.et_remark); + btn_save_allow = findViewById(R.id.btn_save_allow); + btn_save_close = findViewById(R.id.btn_save_close); + } + + + private void setOnClick() { + saveButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + saveSubnetAndDeviceID(); + } + }); + + btn_save_allow.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + saveSEasyProgrammingSearchInfo(); + } + }); + + btn_save_close.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + HDLDeviceManager.setIsAllowEasyProgrammingSearch(false); + } + }); + } + + 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); + + //閰嶇疆绠�鏄撶紪绋嬫悳绱㈢殑鍙傛暟 + HDLDeviceManager.setEasyProgrammingSearchLocalData(9, 1); + } + + + //鏈湴瀛愮綉鍙枫�佽澶囧彿 鑼冨洿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); + + HDLCommand.setLocalId(this, mSubnetID, mDeviceID); + + + } + + } + + private void saveSEasyProgrammingSearchInfo(){ + strBigClassID = bigIDEditText.getText().toString(); + strSmallClassID = smallIDEditText.getText().toString(); + String remarkStr = remarkIDEditText.getText().toString(); + if (TextUtils.isEmpty(strSmallClassID) || TextUtils.isEmpty(strBigClassID)) { + showToast("澶х被鎴栬�呭皬绫籌D涓嶈兘涓虹┖"); + } else { + int mBigID = Integer.parseInt(strBigClassID); + int mSmallID = Integer.parseInt(strSmallClassID); + HDLDeviceManager.setEasyProgrammingSearchLocalData(mBigID, mSmallID, remarkStr); + } + + } + + + public void showToast(String text) { + Toast.makeText(this, text, Toast.LENGTH_SHORT).show(); + } + +} diff --git a/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/TextUdpActivity.java b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/TextUdpActivity.java new file mode 100644 index 0000000..1620438 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/TextUdpActivity.java @@ -0,0 +1,187 @@ +package com.hdl.sdk.hdl_sdk.activity; + +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; + +import com.hdl.sdk.hdl_core.Config.Configuration; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeGatewayInfoBean; +import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; +import com.hdl.sdk.hdl_core.Util.NetUtil.NetWorkUtil; +import com.hdl.sdk.hdl_core.Util.TransformUtil.StringUtil; +import com.hdl.sdk.hdl_sdk.R; + +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.Socket; +import java.net.SocketException; +import java.util.ArrayList; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; + +public class TextUdpActivity extends AppCompatActivity { + private static DatagramSocket datagramSocket7624 = null; + public static List<ZigbeeGatewayInfoBean> zigbeeGatewayInfoBeanList = new ArrayList<>(); + public static Timer searchTimer = null; + private static boolean isStop = false; + Button button; + public static void release() { + isStop = true; + datagramSocket7624.disconnect(); + datagramSocket7624 = null; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_text_udp); + button = findViewById(R.id.button1); + init7624(); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + SearchGateWay(); + } + }); + } + + private static void SearchGateWay() { + new Thread(new Runnable() { + @Override + public void run() { + try { + byte[] sendBytes = new byte[44]; + sendBytes[0] = (byte) 0xFE; + sendBytes[1] = 0x29; + sendBytes[2] = 0; + sendBytes[3] = 0; + sendBytes[4] = 0; + sendBytes[5] = 0; + sendBytes[6] = 0; + //鑾峰彇鎵�鏈夌綉鍏筹紙鏃犻渶houseID妯″紡锛夛紝鍚庨潰瑕佹敼 + sendBytes[7] = 0x67; + sendBytes[8] = 0x65; + sendBytes[9] = 0x74; + sendBytes[10] = 0x61; + sendBytes[11] = 0x6c; + sendBytes[12] = 0x6c; + sendBytes[13] = 0x67; + sendBytes[14] = 0x77; + for (int i = 15; i<sendBytes.length-1;i++){ + sendBytes[i] = 0; + } + sendBytes[sendBytes.length - 1] = 0x02; + DatagramSocket socket = new DatagramSocket(); + InetAddress address = InetAddress.getByName(NetWorkUtil.getLocalBroadCast()); + DatagramPacket packet = new DatagramPacket( + sendBytes, + sendBytes.length, + address, Configuration.ZIGBEE_PORT); + socket.send(packet); + socket.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }).start(); + + } + + /** + * 鍒濆鍖�7624绔彛 + */ + public static void init7624(){ + if (datagramSocket7624 != null){ + HDLLog.info( "HDL SDK 7624 宸插惎鍔�"); + }else { + HDLLog.info( "HDLSocket 7624 init"); + new Thread(new Runnable() { + @Override + public void run() { + try { + datagramSocket7624 = new DatagramSocket(Configuration.ZIGBEE_PORT); + while (!isStop && datagramSocket7624 != null) { + datagramSocket7624.setReceiveBufferSize(1024 * 20); + datagramSocket7624.setReuseAddress(true); + while (datagramSocket7624 != null){ + byte[] receiveBytes = new byte[1024]; + DatagramPacket dataPacket = new DatagramPacket(receiveBytes, receiveBytes.length); + if (datagramSocket7624 != null || (!datagramSocket7624.isClosed())) { + datagramSocket7624.receive(dataPacket); + } + Log.d("11114", "鍒濆鍖栫鍙f帴鏀剁殑鏁版嵁涓簉eceiveBytes锛� "+StringUtil.ByteArrToHex(receiveBytes,0,receiveBytes.length)); + handleData(receiveBytes,dataPacket); + } + } + } catch (Exception e) { + datagramSocket7624 = null; + return; + } + } + }).start(); + } + } + + private static void handleData(byte[] receiveBytes,DatagramPacket dataPacket) { + if (receiveBytes[45] ==0){ + return; + } + Log.d("11114", "澶勭悊鐨勬暟鎹负receiveBytes锛� "+StringUtil.ByteArrToHex(receiveBytes,0,receiveBytes.length)); + //鏄惁涓荤綉鍏�-01涓轰富缃戝叧-00涓轰粠缃戝叧 + String IsDomain = StringUtil.Byte2Hex(dataPacket.getData()[44]); + int headLength = 49; + if (receiveBytes.length > headLength) { + //缃戝叧鍚嶇О闀垮害 + String str = StringUtil.Byte2Hex(dataPacket.getData()[49]); + int GwNameLength = Integer.parseInt(str, 16); + + //缃戝叧鍚嶇О + byte[] gwnamebyte = new byte[GwNameLength]; + for (int i = 0; i < GwNameLength; i++) { + gwnamebyte[i] = dataPacket.getData()[i + 50]; + } + String GwName = new String(gwnamebyte, 0, gwnamebyte.length); + + //缃戝叧id闀垮害 + String str1 = StringUtil.Byte2Hex(dataPacket.getData()[50 + GwNameLength]); + int GwIdLength = Integer.parseInt(str1, 16); + + //鑾峰彇缃戝叧id + byte[] gatewayId = new byte[GwIdLength]; + for (int i = 0; i < GwIdLength; i++) { + gatewayId[i] = dataPacket.getData()[i + 51 + GwNameLength]; + } + + if (gatewayId.length > 1) { + String stringGateWayId = new String(gatewayId, 0, gatewayId.length); + Log.d("11114", "缃戝叧id: " + stringGateWayId); + + ZigbeeGatewayInfoBean zigbeeGatewayInfoBean = new ZigbeeGatewayInfoBean(); + zigbeeGatewayInfoBean.setGatewayId(stringGateWayId); + zigbeeGatewayInfoBean.setIpAddress(dataPacket.getAddress().getHostAddress()); + if (IsDomain.equals("01")){ + zigbeeGatewayInfoBean.setDomain(true); + }else { + zigbeeGatewayInfoBean.setDomain(false); + } + zigbeeGatewayInfoBean.setGatewayName(GwName); + boolean isExit = false; + for (int i = 0; i < zigbeeGatewayInfoBeanList.size(); i++) { + if (zigbeeGatewayInfoBeanList.get(i).getGatewayId() + .equals(zigbeeGatewayInfoBean.getGatewayId())) { + isExit = true; + break; + } + } + if (!isExit) { + zigbeeGatewayInfoBeanList.add(zigbeeGatewayInfoBean); + Log.d("11114", "addList:鎴愬姛娣诲姞 "); + } + } + } + } +} diff --git a/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/base/BaseActivity.java b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/base/BaseActivity.java new file mode 100644 index 0000000..12746e6 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/base/BaseActivity.java @@ -0,0 +1,88 @@ +package com.hdl.sdk.hdl_sdk.base; + +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.Toast; + +import org.greenrobot.eventbus.EventBus; + + +public class BaseActivity extends AppCompatActivity { + private static final String TAG = "BaseActivity"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + initEventBusRegister(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + unEventBusRegister(); + } + + + /** + * 鏄惁娉ㄥ唽浜嬩欢鍒嗗彂 + * + * @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/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/utlis/HDLLog.java b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/utlis/HDLLog.java new file mode 100644 index 0000000..a042b43 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/java/com/hdl/sdk/hdl_sdk/utlis/HDLLog.java @@ -0,0 +1,20 @@ +package com.hdl.sdk.hdl_sdk.utlis; + +import android.util.Log; + +public class HDLLog { + private static boolean isOpen = true; + public static void I(String message){ + if(isOpen){ + Log.i("HDL_Demo",message); + } + } + + public static void E(String info){ + if(isOpen){ + Log.e("HDL_Demo",info); + } + + } + +} diff --git a/Android_HDL_SDK_XW/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/Android_HDL_SDK_XW/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..62e9292 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,36 @@ +<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/Android_HDL_SDK_XW/app/src/main/res/drawable/ic_launcher_background.xml b/Android_HDL_SDK_XW/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..d5fccc5 --- /dev/null +++ b/Android_HDL_SDK_XW/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/Android_HDL_SDK_XW/app/src/main/res/layout/activity_add_devices_manually.xml b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_add_devices_manually.xml new file mode 100644 index 0000000..9033f3d --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_add_devices_manually.xml @@ -0,0 +1,113 @@ +<?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="璇疯緭鍏ュ娉紝澶氫釜鍥炶矾澶囨敞鈥�-鈥濆垎鍓�" + /> + + <EditText + android:id="@+id/et_port" + android:layout_width="match_parent" + android:layout_height="50dp" + android:layout_marginTop="10dp" + android:inputType="number" + android:maxLength="4" + android:text="6000" + 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/Android_HDL_SDK_XW/app/src/main/res/layout/activity_appliances.xml b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_appliances.xml new file mode 100644 index 0000000..33a3d00 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_appliances.xml @@ -0,0 +1,19 @@ +<?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.hdl_sdk.activity.AppliancesActivity"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <ListView + android:id="@+id/lv" + android:layout_width="match_parent" + android:layout_height="match_parent"></ListView> + </LinearLayout> + +</RelativeLayout> diff --git a/Android_HDL_SDK_XW/app/src/main/res/layout/activity_audio.xml b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_audio.xml new file mode 100644 index 0000000..2fd6adb --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_audio.xml @@ -0,0 +1,131 @@ +<?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.hdl_sdk.activity.AudioActivity"> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + 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/Android_HDL_SDK_XW/app/src/main/res/layout/activity_ctrl.xml b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_ctrl.xml new file mode 100644 index 0000000..8e3dfc7 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_ctrl.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.hdl_sdk.activity.CtrlActivity"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + 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/Android_HDL_SDK_XW/app/src/main/res/layout/activity_fresh_air.xml b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_fresh_air.xml new file mode 100644 index 0000000..9573a09 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_fresh_air.xml @@ -0,0 +1,46 @@ +<?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:layout_width="match_parent" + android:layout_height="match_parent" + tools:context="com.hdl.sdk.hdl_sdk.activity.FreshAirActivity"> + + <LinearLayout + android:id="@+id/ll_fresh_air" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <Button + android:id="@+id/btn_switch" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="鏂伴绯荤粺寮�鍏�" /> + + <Button + android:id="@+id/btn_speed" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="鏂伴绯荤粺椋庨��" /> + + <Button + android:id="@+id/btn_mode" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="鏂伴绯荤粺妯″紡" /> + + <TextView + android:id="@+id/tv_fresh_air" + android:textSize="25sp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="杩欎釜鎸夐挳鍋氱┖璋冮潰鏉跨殑婕旂ず" + + /> + + + + + </LinearLayout> + +</RelativeLayout> \ No newline at end of file diff --git a/Android_HDL_SDK_XW/app/src/main/res/layout/activity_geothermal.xml b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_geothermal.xml new file mode 100644 index 0000000..1ea914d --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_geothermal.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:layout_width="match_parent" + android:layout_height="match_parent" + tools:context="com.hdl.sdk.hdl_sdk.activity.FreshAirActivity"> + + <LinearLayout + android:id="@+id/ll_geothermal" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <Button + android:id="@+id/btn_switch" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="鍦扮儹寮�鍏�" /> + <Button + android:id="@+id/btn_mode" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="鍦扮儹妯″紡" /> + + + <LinearLayout + android:orientation="horizontal" + android:layout_width="match_parent" + android:layout_height="50dp" + android:focusable="true" + android:focusableInTouchMode="true"> + <Button + android:id="@+id/btn_temp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="鐐瑰嚮璁剧疆鍦扮儹娓╁害:" /> + <EditText + android:id="@+id/et_temp" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:inputType="number" + /> + + + </LinearLayout> + <TextView + android:id="@+id/tv_geothermal" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="10dp" + android:textSize="25sp" + android:text="杩欎釜鎸夐挳鍋氬湴鐑ā鍧楃殑婕旂ず" /> + + + + </LinearLayout> + + +</RelativeLayout> \ No newline at end of file diff --git a/Android_HDL_SDK_XW/app/src/main/res/layout/activity_main.xml b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..01b0916 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_main.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_main" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context="com.hdl.sdk.hdl_sdk.activity.MainActivity"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + <TextView + android:id="@+id/version" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/app_version" + /> + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + + <Button + android:id="@+id/btn" + 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_getlocal_add" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="娣诲姞鏁版嵁" /> + + + <Button + android:id="@+id/btn_get_all" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:visibility="gone" + android:text="鑾峰彇鎵�鏈夌┖璋�" /> + <Button + android:id="@+id/btn_on_all" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:visibility="gone" + android:text="寮�鍚墍鏈夌┖璋�" /> + + <Button + android:id="@+id/btn_off_all" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:visibility="gone" + android:text="鍏抽棴鎵�鏈夌┖璋�" /> + + </LinearLayout> + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + <CheckBox + android:id="@+id/checkbox_is_zigbee" + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> + <TextView + android:text="Zigbee璁惧" + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> + </LinearLayout> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + + <Button + android:id="@+id/btn_setting" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="璁剧疆" /> + + + + + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:focusable="true" + + android:focusableInTouchMode="true"> + + <EditText + android:id="@+id/edt" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:visibility="gone" + android:hint="鑻ヤ娇鐢ㄩ厭搴楁悳绱紝璇疯緭鍏ラ厭搴梚p鍦板潃" /> + + <Button + android:id="@+id/get" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:visibility="gone" + android:text="鎼滅储閰掑簵璁惧" /> + </LinearLayout> + + + <TextView + android:id="@+id/tv" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + + <TextView + android:id="@+id/tv1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + + <TextView + android:id="@+id/tv2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + + <ListView + android:id="@+id/listView1" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + </ListView> + </LinearLayout> + +</RelativeLayout> diff --git a/Android_HDL_SDK_XW/app/src/main/res/layout/activity_setting.xml b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_setting.xml new file mode 100644 index 0000000..6c98ddb --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_setting.xml @@ -0,0 +1,161 @@ +<?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:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".activity.SettingActivity"> + + + + <LinearLayout + android:id="@+id/mLinearLayout1" + 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="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> + + <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" + android:layout_below="@+id/mLinearLayout1"> + <TextView + android:layout_width="match_parent" + android:layout_height="30dp" + android:text="淇敼鏄惁鍏佽绠�鏄撶紪绋嬫悳绱�" + android:gravity="center|left" + android:textSize="20dp" + android:textColor="#000000"/> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="50dp"> + <TextView + android:layout_width="60dp" + android:layout_height="match_parent" + android:text="澶х被锛�" + android:gravity="center" + android:textSize="16dp" + ></TextView> + + <EditText + android:id="@+id/et_bigclass" + android:layout_width="120dp" + android:layout_height="match_parent" + android:layout_marginTop="10dp" + android:gravity="center|left" + android:hint="澶х被ID绫诲瀷" + android:inputType="number" + android:maxLength="3" + android:text="9" + android:textSize="16dp" /> + + <TextView + android:layout_width="60dp" + android:layout_height="match_parent" + android:text="灏忕被锛�" + android:gravity="center" + android:textSize="16dp" + android:layout_marginLeft="20dp" + ></TextView> + + <EditText + android:id="@+id/et_smallclass" + android:layout_width="120dp" + android:layout_height="match_parent" + android:layout_marginTop="10dp" + android:gravity="center|left" + android:inputType="number" + android:maxLength="3" + android:textSize="16dp" + android:text="1" + /> + + + + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="50dp"> + <TextView + android:layout_width="60dp" + android:layout_height="match_parent" + android:text="澶囨敞锛�" + android:gravity="center" + android:textSize="16dp" + ></TextView> + + <EditText + android:id="@+id/et_remark" + android:layout_width="200dp" + android:layout_height="match_parent" + android:layout_marginTop="10dp" + android:gravity="center|left" + android:hint="SDK澶囨敞" + android:textSize="16dp" + android:text="SDK鐗规畩璁惧" + /> + + <Button + android:id="@+id/btn_save_allow" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center" + android:text="鍏佽"/> + + + + </LinearLayout> + + + <Button + android:id="@+id/btn_save_close" + android:layout_width="match_parent" + android:layout_height="50dp" + android:layout_marginTop="10dp" + android:text="绂佹"/> + + </LinearLayout> +</RelativeLayout> \ No newline at end of file diff --git a/Android_HDL_SDK_XW/app/src/main/res/layout/activity_text_udp.xml b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_text_udp.xml new file mode 100644 index 0000000..e3e2f02 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/layout/activity_text_udp.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".activity.TextUdpActivity"> + <Button + android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> +</LinearLayout> \ No newline at end of file diff --git a/Android_HDL_SDK_XW/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/Android_HDL_SDK_XW/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/Android_HDL_SDK_XW/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/Android_HDL_SDK_XW/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/Android_HDL_SDK_XW/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/Android_HDL_SDK_XW/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/Android_HDL_SDK_XW/app/src/main/res/mipmap-hdpi/ic_launcher.png b/Android_HDL_SDK_XW/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a2f5908 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/Android_HDL_SDK_XW/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/Android_HDL_SDK_XW/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..1b52399 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/Android_HDL_SDK_XW/app/src/main/res/mipmap-mdpi/ic_launcher.png b/Android_HDL_SDK_XW/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..ff10afd --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/Android_HDL_SDK_XW/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/Android_HDL_SDK_XW/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..115a4c7 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/Android_HDL_SDK_XW/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/Android_HDL_SDK_XW/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..dcd3cd8 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/Android_HDL_SDK_XW/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/Android_HDL_SDK_XW/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..459ca60 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/Android_HDL_SDK_XW/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/Android_HDL_SDK_XW/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..8ca12fe --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/Android_HDL_SDK_XW/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/Android_HDL_SDK_XW/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..8e19b41 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differ diff --git a/Android_HDL_SDK_XW/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/Android_HDL_SDK_XW/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..b824ebd --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differ diff --git a/Android_HDL_SDK_XW/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/Android_HDL_SDK_XW/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..4c19a13 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differ diff --git a/Android_HDL_SDK_XW/app/src/main/res/values/colors.xml b/Android_HDL_SDK_XW/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..3ab3e9c --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="colorPrimary">#3F51B5</color> + <color name="colorPrimaryDark">#303F9F</color> + <color name="colorAccent">#FF4081</color> +</resources> diff --git a/Android_HDL_SDK_XW/app/src/main/res/values/strings.xml b/Android_HDL_SDK_XW/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..1024b92 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/values/strings.xml @@ -0,0 +1,7 @@ +<resources> + <string name="app_name">HDL_SDK</string> + <string name="app_version">hdl_lib_v1.6.6.20200305_beta</string> + <string name="btn_save">淇濆瓨</string> + <string name="et_subnetid_hint">瀛愮綉鍙凤紙鑼冨洿0 - 254锛�</string> + <string name="et_deviceid_hint">璁惧鍙峰彿锛堣寖鍥�0 - 254锛�</string> +</resources> diff --git a/Android_HDL_SDK_XW/app/src/main/res/values/styles.xml b/Android_HDL_SDK_XW/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..5885930 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ +<resources> + + <!-- Base application theme. --> + <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> + <!-- Customize your theme here. --> + <item name="colorPrimary">@color/colorPrimary</item> + <item name="colorPrimaryDark">@color/colorPrimaryDark</item> + <item name="colorAccent">@color/colorAccent</item> + </style> + +</resources> diff --git a/Android_HDL_SDK_XW/app/src/test/java/com/hdl/sdk/hdl_sdk/ExampleUnitTest.java b/Android_HDL_SDK_XW/app/src/test/java/com/hdl/sdk/hdl_sdk/ExampleUnitTest.java new file mode 100644 index 0000000..9e73ce4 --- /dev/null +++ b/Android_HDL_SDK_XW/app/src/test/java/com/hdl/sdk/hdl_sdk/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.hdl.sdk.hdl_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/Android_HDL_SDK_XW/build.gradle b/Android_HDL_SDK_XW/build.gradle new file mode 100644 index 0000000..0f1c794 --- /dev/null +++ b/Android_HDL_SDK_XW/build.gradle @@ -0,0 +1,30 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + + repositories { + google() + mavenCentral() + maven { url 'https://maven.google.com' } + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.3.0' +// classpath 'com.novoda:bintray-release:+' + + + } +} + +allprojects { + repositories { + google() + mavenCentral() + maven { url 'https://maven.google.com' } + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/Android_HDL_SDK_XW/gradle.properties b/Android_HDL_SDK_XW/gradle.properties new file mode 100644 index 0000000..743d692 --- /dev/null +++ b/Android_HDL_SDK_XW/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/Android_HDL_SDK_XW/gradle/wrapper/gradle-wrapper.jar b/Android_HDL_SDK_XW/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..7a3265e --- /dev/null +++ b/Android_HDL_SDK_XW/gradle/wrapper/gradle-wrapper.jar Binary files differ diff --git a/Android_HDL_SDK_XW/gradle/wrapper/gradle-wrapper.properties b/Android_HDL_SDK_XW/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..8cc2e36 --- /dev/null +++ b/Android_HDL_SDK_XW/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Jul 08 17:08:19 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-4.10.1-all.zip \ No newline at end of file diff --git a/Android_HDL_SDK_XW/gradlew b/Android_HDL_SDK_XW/gradlew new file mode 100644 index 0000000..cccdd3d --- /dev/null +++ b/Android_HDL_SDK_XW/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/Android_HDL_SDK_XW/gradlew.bat b/Android_HDL_SDK_XW/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/Android_HDL_SDK_XW/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/Android_HDL_SDK_XW/hdl_core/.gitignore b/Android_HDL_SDK_XW/hdl_core/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/.gitignore @@ -0,0 +1 @@ +/build diff --git a/Android_HDL_SDK_XW/hdl_core/build.gradle b/Android_HDL_SDK_XW/hdl_core/build.gradle new file mode 100644 index 0000000..211ac48 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/build.gradle @@ -0,0 +1,66 @@ +apply plugin: 'com.android.library' +//apply plugin: 'com.novoda.bintray-release' + +android { + compileSdkVersion 28 + defaultConfig { + minSdkVersion 17 + targetSdkVersion 28 + versionCode 1 + versionName "1.0.7" + + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + buildToolsVersion '28.0.3' + +// lintOptions { +// abortOnError false +// warning 'InvalidPackage' +// } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation 'com.android.support:appcompat-v7:28+' + api 'org.greenrobot:eventbus:3.0.0' + 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 files('libs/org.eclipse.paho.client.mqttv3-1.2.0.jar') +} + + +//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/Android_HDL_SDK_XW/hdl_core/libs/gson-2.8.5.jar b/Android_HDL_SDK_XW/hdl_core/libs/gson-2.8.5.jar new file mode 100644 index 0000000..0d5baf3 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/libs/gson-2.8.5.jar Binary files differ diff --git a/Android_HDL_SDK_XW/hdl_core/libs/org.eclipse.paho.client.mqttv3-1.2.0.jar b/Android_HDL_SDK_XW/hdl_core/libs/org.eclipse.paho.client.mqttv3-1.2.0.jar new file mode 100644 index 0000000..dc4b1ea --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/libs/org.eclipse.paho.client.mqttv3-1.2.0.jar Binary files differ diff --git a/Android_HDL_SDK_XW/hdl_core/proguard-rules.pro b/Android_HDL_SDK_XW/hdl_core/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/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/Android_HDL_SDK_XW/hdl_core/src/androidTest/java/com/hdl/sdk/hdl_core/ExampleInstrumentedTest.java b/Android_HDL_SDK_XW/hdl_core/src/androidTest/java/com/hdl/sdk/hdl_core/ExampleInstrumentedTest.java new file mode 100644 index 0000000..6fbc106 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/androidTest/java/com/hdl/sdk/hdl_core/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.hdl.sdk.hdl_core; + +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_core.test", appContext.getPackageName()); + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/AndroidManifest.xml b/Android_HDL_SDK_XW/hdl_core/src/main/AndroidManifest.xml new file mode 100644 index 0000000..af1bf84 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.hdl.libr.hdl_lib"> + + <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> + <uses-permission android:name="android.permission.WAKE_LOCK" /> + <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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java new file mode 100644 index 0000000..1db0e62 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java @@ -0,0 +1,233 @@ +package com.hdl.sdk.hdl_core.Config; + +public class Configuration { + //Zigbee + public static final String UNKNOW_TYPE = "Unknow Type"; + public static final String SEARCH_DEVICE = "GetDeviceInfo"; + public static final String SEARCH_SCENE = "Scene/GetInfo"; + public static final String SEARVH_JSON = "{ \"Cluster_ID\":0, \"Command\":93 }"; + public static final String SCENE_JSON = "{ \"Cluster_ID\":0, \"Command\":805 }"; + public static final int RELAY_ON = 0; + public static final int RELAY_OFF = 1; + //鍥哄畾Zigbee绔彛鍙� + public static final int ZIGBEE_PORT = 7624; + + + + 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; + /** + * 鍦扮儹妯″潡 + */ + public static final int GEOTHERMAL_BIG_TYPE = 8; + public static final int AIR_BIG_TYPE = 7; + public static final int AUDIO_BIG_TYPE = 9; + public static final int LOGIC_BIG_TYPE = 12; + public static final int GLOBAL_LOGIC_BIG_TYPE = 17; + /** + * 鏂伴绯荤粺 + */ + public static final int FRESH_AIR_BIG_TYPE = 19; + + //鏀寔鐨勫皬绫� + public static final int FRESH_AIR_LITTLE_TYPE_0 = 0; + public static final int GEOTHERMAL_LITTLE_TYPE_0 = 0; + + + //灏忕被 鍏堜笉鍋氬垎绫� +// public static final int AIR_LITTLE_TYPE = 0; + + //鎿嶄綔鍒嗙被鐮� +// 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; + + //鎵嬪姩娣诲姞璁惧鐩稿叧鎿嶄綔鐮� + 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 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 = 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; + + + //鍏鍙d氦鎹㈡満浼犳劅鍣� 浼犳劅鍣ㄦ搷浣滅爜 + public static final int SENSOR_STATE_COMMAND = 0xE4F9; + public static final int SENSOR_STATE_BACK_COMMAND = 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; + + + /** + * 2019-07-08 鍦扮儹 + */ + //鍦扮儹妯″潡 + public static final int GEOTHERMAL_MODULE_CTRL_COMMAND = 0x1C5C; + public static final int GEOTHERMAL_MODULE_CTRL_BACK_COMMAND = 0x1C5D; + public static final int GEOTHERMAL_MODULE_STATE_COMMAND = 0x1C5E; + public static final int GEOTHERMAL_MODULE_STATE_BACK_COMMAND = 0x1C5F; +// //甯歌鍦扮儹闈㈡澘 +// public static final int GEOTHERMAL_MODULE_PANEL_CTRL_COMMAND = 0x1946; +// public static final int GEOTHERMAL_MODULE_PANEL_CTRL_BACK_COMMAND = 0x1947; +// public static final int GEOTHERMAL_MODULE_PANEL_STATE_COMMAND = 0x1944; +// public static final int GEOTHERMAL_MODULE_PANEL_STATE_BACK_COMMAND = 0x1945; +// //甯I杩愮畻鐨勫湴鐑潰鏉� +// public static final int GEOTHERMAL_MODULE_PI_CTRL_COMMAND = 0x1942; +// public static final int GEOTHERMAL_MODULE_PI_CTRL_BACK_COMMAND = 0x1943; +// public static final int GEOTHERMAL_MODULE_PI_STATE_COMMAND = 0x1940; +// public static final int GEOTHERMAL_MODULE_PI_STATE_BACK_COMMAND = 0x1941; + + + /** + * 2019-07-08 鏂伴绯荤粺 + */ + public static final int FRESH_AIR_CTRL_COMMAND = 0x144A; + public static final int FRESH_AIR_CTRL_BACK_COMMAND = 0x144B; + public static final int FRESH_AIR_STATE_COMMAND = 0x144C; + public static final int FRESH_AIR_STATE_BACK_COMMAND = 0x144D; + + + /** + * 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; + + + /** + * 1.XWSDK 鏂板鍦扮儹鍜屾柊椋庢帴鍙� + * 08 鍦扮儹鍔熻兘 锛�0锛夊湴鐑ā鍧� 锛�1锛夊父瑙勫湴鐑潰鏉� + * 锛�2锛夊甫PI杩愮畻鐨勫湴鐑潰鏉� + * <p> + * 19 鏂伴绯荤粺 + * <p> + * #region 鏂伴鍗忚 + * //鏂伴鍗忚鎺у埗 + * //闄勫姞鏁版嵁锛� 鏂伴閫氶亾鍙凤紙1 - 200锛� + 寮�鍏筹紙0锛�1锛� + 椋庨�燂紙0 鍏筹紝1浣庯紝2涓紝3楂橈級 + 妯″紡锛�0鎵嬪姩锛�1 鑷姩,2 鏅鸿兘锛�3 瀹氭椂锛� + * FreshAirControl = 0x144A, + * //杩斿洖锛氭柊椋庨�氶亾鍙凤紙1 - 200锛� + 寮�鍏筹紙0锛�1锛� + 椋庨�燂紙0 鍏筹紝1浣庯紝2涓紝3楂橈級 + 妯″紡锛�0鎵嬪姩锛�1 鑷姩,2 鏅鸿兘锛�3 瀹氭椂锛�+ 妯℃嫙閲忥紙2byte==16bit锛�+ + * //瀹ゅ唴娓╁害(4byte) + 瀹ゅ娓╁害(4byte) + 瀹ゅ唴婀垮害(4byte)+ PM2.5(4byte) + TVOC(4byte) + CO2(4byte) + * FreshAirControlACK = 0x144B, + * <p> + * <p> + * //2.鏂伴鍗忚璇荤姸鎬� + * //闄勫姞鏁版嵁锛� 鏂伴閫氶亾鍙凤紙1 - 200锛� + * FreshAirRead = 0x144C, + * //杩斿洖锛氭柊椋庨�氶亾鍙凤紙1 - 200锛� + 寮�鍏筹紙0锛�1锛� + 椋庨�燂紙0 鍏筹紝1浣庯紝2涓紝3楂橈級 + 妯″紡锛�0鎵嬪姩锛�1 鑷姩,2 鏅鸿兘锛�3 瀹氭椂锛� + 妯℃嫙閲忥紙2byte==16bit锛�+ + * //瀹ゅ唴娓╁害(4byte) + 瀹ゅ娓╁害(4byte) + 瀹ゅ唴婀垮害(4byte)+ PM2.5(4byte) + TVOC(4byte) + CO2(4byte) + * FreshAirReadACK = 0x144D, + * #endregion + */ + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/HDLTest.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/HDLTest.java new file mode 100644 index 0000000..0463ab4 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/HDLTest.java @@ -0,0 +1,15 @@ +package com.hdl.sdk.hdl_core.Config; + +public class HDLTest { + public static final int SEND_TEST_PORT = 8638; + public static final int REC_TEST_PORT = 8639; + public static final int EXCEPTION_TEST_PORT = 8640; + public static final int TCP_PORT = 8641; + + + public static final byte[] CODE_LOGIC_MODE_NULL = new byte[]{77,0,1}; + public static final byte[] CODE_LIGHT_CHANNEL_NULL = new byte[]{77,0,2}; + + + public static final String testDeviceInfo = "{\"gatewaysInfo\":[{\"gatewayIpAddress\":\"172.16.8.200\",\"gatewayId\":\"0cefafd27133\",\"module\":\"zigbee\",\"name\":\"娣峰悎妯″潡\",\"uid\":268915456,\"objects\":[{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000001\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe044e8a\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":1,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000002\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe044e99\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":1,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000003\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe044eaa\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":1,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000004\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe04514d\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":1,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000005\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe045114\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":1,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000006\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe044e96\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":1,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000007\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe0450f8\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":1,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000008\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe045125\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":1,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000009\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe045108\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":1,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000010\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe044e91\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":1,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000011\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe045112\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":1,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000012\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe044e87\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":1,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]}]},{\"gatewayIpAddress\":\"172.16.8.247\",\"gatewayId\":\"0cefafd193bf\",\"module\":\"zigbee\",\"name\":\"娣峰悎妯″潡\",\"uid\":268915456,\"objects\":[{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000013\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe045149\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":8,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000014\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe045149\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":7,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000015\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe045149\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":6,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000016\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe045149\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":5,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000017\",\"type\":null,\"attr\":{\"DeviceAddr\":\"d0cf5efffefc1273\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":8,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000018\",\"type\":null,\"attr\":{\"DeviceAddr\":\"d0cf5efffefc1273\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":7,\"IsOnline\":0,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000019\",\"type\":null,\"attr\":{\"DeviceAddr\":\"d0cf5efffefc1273\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":6,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000020\",\"type\":null,\"attr\":{\"DeviceAddr\":\"d0cf5efffefc1273\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":5,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]}]},{\"gatewayIpAddress\":\"172.16.8.242\",\"gatewayId\":\"0cefafd19357\",\"module\":\"zigbee\",\"name\":\"娣峰悎妯″潡\",\"uid\":268915456,\"objects\":[]},{\"gatewayIpAddress\":\"172.16.8.175\",\"gatewayId\":\"0cefafd17baf\",\"module\":\"zigbee\",\"name\":\"娣峰悎妯″潡\",\"uid\":268915456,\"objects\":[{\"name\":\"\",\"type\":\"light\",\"function\":[{\"sid\":\"1007530006000021\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe0450ef\",\"Device_ID\":2,\"DeviceName\":null,\"Epoint\":1,\"IsOnline\":1,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]},{\"name\":\"\",\"type\":\"curtain\",\"function\":[{\"sid\":\"1007530005000001\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe045127\",\"Device_ID\":514,\"DeviceName\":null,\"Epoint\":1,\"IsOnline\":0,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}},{\"sid\":\"1007530005010001\",\"type\":null,\"attr\":{\"DeviceAddr\":\"000d6ffffe045127\",\"Device_ID\":514,\"DeviceName\":null,\"Epoint\":1,\"IsOnline\":0,\"type\":null,\"maxValue\":0,\"minValue\":0,\"readOnly\":false}}]}]}],\"homeId\":\"hdl-zigbeeGW-001\"}"; + } diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/ZigbeeDeviceID.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/ZigbeeDeviceID.java new file mode 100644 index 0000000..1562435 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/ZigbeeDeviceID.java @@ -0,0 +1,122 @@ +package com.hdl.sdk.hdl_core.Config; + +public class ZigbeeDeviceID { + public static final int UnKown = 0x9999; + public static final int ZbGateway = 0x9998; + /** + * 鍦烘櫙 + */ + public static final int SceneMark = 13; + /** + * 骞叉帴鐐� + * 璁惧ID锛�0 + */ + public static final int OnOffSwitch = 0; + /** + *缁х數鍣� + * 璁惧ID锛�2 + */ + public static final int OnOffOutput = 2; + /** + * 闂ㄩ攣 + * 璁惧ID锛�10 + */ + public static final int DoorLock = 10; + /** + * 璋冨厜璁惧 + * 璁惧ID锛�257 + */ + public static final int DimmableLight = 257; + /** + * 绐楀笜璁惧 + * 璁惧ID锛�514 + */ + public static final int WindowCoveringDevice = 514; + /** + * 棰滆壊璋冨厜璁惧 + * 璁惧ID锛�528 + */ + public static final int ColorDimmableLight = 528; + /** + * 鎭掓俯鍣紙绌鸿皟锛� + * 璁惧ID锛�769 + */ + public static final int Thermostat = 769; + /** + * 瀹夐槻璁惧 + * 璁惧ID锛�1026 + */ + public static final int IASZone = 1026; + /** + * 绌烘皵寮�鍏� + * 璁惧ID锛�53249 + */ + public static final int AirSwitch = 53249; + /** + *鏂伴闈㈡澘 + * 璁惧ID锛�53504 + */ + public static final int AirPanel = 53504; + /** + * 涓户鍣� + * 璁惧ID锛�53250 + */ + public static final int Repeater = 53250; + /** + * 鎺у埗婧愯澶� + * 璁惧ID锛�49152 + */ + public static final int OtaPanelDevice = 49152; + /** + * 鎺у埗婧愯澶� + * 璁惧ID锛�49153 + */ + public static final int OtaDevice = 49153; + /** + * 杞崲鍣� + * 璁惧ID锛�53251 + */ + public static final int Transverter = 53251; + /** + * 娓╂箍搴︿紶鎰熷櫒 + * 璁惧ID锛�770 + */ + public static final int TemperatureSensor = 770; + + + + + + + + + + + + + /** + * 璁惧鐨勫姛鑳界被鍨�(姝ょ被鍨嬬洰鍓嶅彧閽堝缁х數鍣ㄥ洖璺湁鏁�) + */ + public class DeviceFunctionType { + /** + * 娌℃湁鎸囧畾涓轰粈涔堢被鍨� + */ + public static final int undefinedType = 0; + /** + * 寮�鍏� + */ + public static final int onOffType = 1; + /** + * 鐏厜 + */ + public static final int lightType = 2; + /** + * 鎻掑骇 + */ + public static final int outletType = 3; + + } +} + + + diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/Config/HDLApConfig.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/Config/HDLApConfig.java new file mode 100644 index 0000000..97580f2 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/Config/HDLApConfig.java @@ -0,0 +1,71 @@ +package com.hdl.sdk.hdl_core.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; + + public static final int TYPE_SENSOR_DRY_CONTACT = 601; + 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; + + + + //2019-07 + public static final int TYPE_GEOTHERMAL_MODULE = 801; //鍦扮儹妯″潡锛�0锛� 鍥炶矾鍙凤紝澶囨敞锛屽湴鐑姸鎬� +// public static final int TYPE_GEOTHERMAL_MODULE_PANEL = 802; //甯歌鍦扮儹闈㈡澘锛�1锛� 闈㈡澘鍙凤紝澶囨敞锛屾湇鍔″櫒妯″紡锛屽湴鐑姸鎬� +// public static final int TYPE_GEOTHERMAL_MODULE_PI = 803; //甯I杩愮畻鐨勫湴鐑潰鏉匡紙2锛� 闈㈡澘鍙凤紝澶囨敞锛屽湴鐑姸鎬� + + public static final int TYPE_FRESH_AIR = 1901; //鏂伴绯荤粺 + + + + + + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/AirCtrlBackInfo.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/AirCtrlBackInfo.java new file mode 100644 index 0000000..a14670a --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/AirCtrlBackInfo.java @@ -0,0 +1,113 @@ +package com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition; + + +import com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java new file mode 100644 index 0000000..b31e4db --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java @@ -0,0 +1,476 @@ +package com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.Parser; + + +import com.hdl.sdk.hdl_core.Config.Configuration; +import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; +import com.hdl.sdk.hdl_core.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; + } + + /** + * 鐢熸垚榛樿鏁版嵁 + * + * @return + */ + public static byte[] getNewAcByte() { + byte[] airBytes = new byte[6]; + airBytes[0] = (byte) 0; + airBytes[1] = (byte) 0; + airBytes[2] = (byte) 28; + airBytes[3] = (byte) 0; + airBytes[4] = (byte) 28; + airBytes[5] = (byte) 0; + return airBytes; + } + + 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.getArrCurState().length != 6) { + newInfo.setArrCurState(getNewAcByte()); + } + airBytes = newInfo.getArrCurState(); + break outter; + } + + } + } + } + + byte[] addBytes = new byte[13]; + if (airBytes != null && airBytes.length >= 6) { + addBytes[0] = (byte) newInfo.getChannelNum(); + addBytes[1] = 0; + addBytes[2] = airBytes[4]; + addBytes[3] = airBytes[2]; + addBytes[4] = airBytes[2]; + addBytes[5] = airBytes[2]; + addBytes[6] = airBytes[2]; + addBytes[7] = (byte) ((airBytes[1] & 0xff) * 16 + (airBytes[3] & 0xff)); + addBytes[8] = airBytes[0]; + addBytes[9] = airBytes[1]; + addBytes[10] = airBytes[3]; + addBytes[11] = airBytes[2]; + addBytes[12] = airBytes[5]; + + 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; + } + return addBytes; + } 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 info,int type, int arg2){ +// byte[] addBytes = new byte[9]; +// addBytes[4] = 1; +// byte[] curAirInfo = info.getArrCurState(); +// switch (info.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) info.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/HDLAudio.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/HDLAudio.java new file mode 100644 index 0000000..19c9d39 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/HDLAudio.java @@ -0,0 +1,377 @@ +package com.hdl.sdk.hdl_core.HDLAppliances.HDLAudio; + +import android.util.Log; + +import com.hdl.sdk.hdl_core.Config.Configuration; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.UdpDataBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommand; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AudioInfoEvent; +import com.hdl.sdk.hdl_core.Util.NetUtil.NetWorkUtil; +import com.hdl.sdk.hdl_core.Util.TransformUtil.StringUtil; + +import org.greenrobot.eventbus.EventBus; + +import java.util.ArrayList; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; + +import static com.hdl.sdk.hdl_core.Util.TransformUtil.StringUtil.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 = StringUtil.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)); + } 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 = StringUtil.asciiToString(sendData); +// Log.i("djl","鍙戝嚭鏁版嵁锛�"+sendData); + HDLCommand.cusSendCommand(Configuration.AUDIO_MenuPlay_INSTRUCTION_COMMAND, + getDatas.sourceSubnetID, getDatas.sourceDeviceID, musicBytes, Configuration.PORT, NetWorkUtil.getLocalBroadCast()); + } + + 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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmCtrlBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmCtrlBean.java new file mode 100644 index 0000000..786f7d0 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmCtrlBean.java @@ -0,0 +1,15 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmCtrlListBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmCtrlListBean.java new file mode 100644 index 0000000..b12499a --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmCtrlListBean.java @@ -0,0 +1,20 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmCtrlSongBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmCtrlSongBean.java new file mode 100644 index 0000000..1225934 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmCtrlSongBean.java @@ -0,0 +1,11 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmModeBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmModeBean.java new file mode 100644 index 0000000..1965271 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmModeBean.java @@ -0,0 +1,26 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmSourceBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmSourceBean.java new file mode 100644 index 0000000..cd9062c --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmSourceBean.java @@ -0,0 +1,7 @@ +package com.hdl.sdk.hdl_core.HDLAppliances.HDLAudio.bean; + +public class HDLBgmSourceBean { + private int areaNum;//鍖哄彿 + private int sourceNum;//婧愬彿 + private int curVol;//褰撳墠闊抽噺銆傝寖鍥�0-79銆傚绗笁鏂规湁100闊抽噺鍊硷紝搴旇鍥炲79 +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmStatusBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmStatusBean.java new file mode 100644 index 0000000..43b5817 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmStatusBean.java @@ -0,0 +1,10 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmTypeBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmTypeBean.java new file mode 100644 index 0000000..b6842ec --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmTypeBean.java @@ -0,0 +1,10 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmVolBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmVolBean.java new file mode 100644 index 0000000..39080d1 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAudio/bean/HDLBgmVolBean.java @@ -0,0 +1,12 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLCurtain/CurtainCtrlBackInfo.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLCurtain/CurtainCtrlBackInfo.java new file mode 100644 index 0000000..31e63f1 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLCurtain/CurtainCtrlBackInfo.java @@ -0,0 +1,75 @@ +package com.hdl.sdk.hdl_core.HDLAppliances.HDLCurtain; + + +import com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLCurtain/Parser/CurtainCtrlParser.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLCurtain/Parser/CurtainCtrlParser.java new file mode 100644 index 0000000..2b0cd7b --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLCurtain/Parser/CurtainCtrlParser.java @@ -0,0 +1,36 @@ +package com.hdl.sdk.hdl_core.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; + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/FreshAirBackInfo.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/FreshAirBackInfo.java new file mode 100644 index 0000000..6e986f5 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/FreshAirBackInfo.java @@ -0,0 +1,182 @@ +package com.hdl.sdk.hdl_core.HDLAppliances.HDLFreshAir; + +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; +import com.hdl.sdk.hdl_core.Util.TransformUtil.HDLUtlis; + +import java.io.Serializable; + +/** + * Created by JLChen on 2019/7/9 + * 闄勫姞鏁版嵁锛� 鏂伴閫氶亾鍙凤紙1 - 200锛� + 寮�鍏筹紙0锛�1锛� + 椋庨�燂紙0 鍏筹紝1浣庯紝2涓紝3楂橈級 + 妯″紡锛�0鎵嬪姩锛�1 鑷姩,2 鏅鸿兘锛�3 瀹氭椂锛� + */ +public class +FreshAirBackInfo implements Serializable { + private AppliancesInfo appliancesInfo; + private String remarks; + private int channelNum;//鍥炶矾鍙� + private int isOn;//0=鍏筹紝1=寮� + private int freshAirSpeed;//椋庨�� 0 鍏筹紝1浣庯紝2涓紝3楂� + private int freshAirMode;//鏂伴妯″紡 0鎵嬪姩锛�1 鑷姩,2 鏅鸿兘锛�3 瀹氭椂 + + private int enableValue1; + private int enableValue2; + private float mInTemp;//瀹ゅ唴娓╁害 + private float mOutTemp;//瀹ゅ娓╁害 + private float mHumidty;//瀹ゅ唴婀垮害 + private float mPM25;//PM2.5 + private float mTVOC;//TVOC + private float mCO2;//CO2 + + private byte[] curState;//鎺у埗鍥為淇℃伅 + + public FreshAirBackInfo() { + + } + + public FreshAirBackInfo(AppliancesInfo mAppliancesInfo) { + this.appliancesInfo = mAppliancesInfo; + this.curState = mAppliancesInfo.getFeedbackState(); + this.remarks = mAppliancesInfo.getRemarks(); + + if (this.curState == null) return; + + if (this.curState.length >= 30) { + this.channelNum = this.curState[0] & 0xFF; + this.isOn = this.curState[1] & 0xFF; + this.freshAirSpeed = this.curState[2] & 0xFF; + this.freshAirMode = this.curState[3] & 0xFF; + this.enableValue1 = this.curState[4] & 0xFF; + this.enableValue2 = this.curState[5] & 0xFF; + this.mInTemp = HDLUtlis.byteToFloat(this.curState[6], this.curState[7], this.curState[8], this.curState[9]); + this.mOutTemp = HDLUtlis.byteToFloat(this.curState[10], this.curState[11], this.curState[12], this.curState[13]); + this.mHumidty = HDLUtlis.byteToFloat(this.curState[14], this.curState[15], this.curState[16], this.curState[17]); + this.mPM25 = HDLUtlis.byteToFloat(this.curState[18], this.curState[19], this.curState[20], this.curState[21]); + this.mTVOC = HDLUtlis.byteToFloat(this.curState[22], this.curState[23], this.curState[24], this.curState[25]); + this.mCO2 = HDLUtlis.byteToFloat(this.curState[26], this.curState[27], this.curState[28], this.curState[29]); + } + + } + + + 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 getFreshAirSpeed() { + return freshAirSpeed; + } + + public void setFreshAirSpeed(int freshAirSpeed) { + this.freshAirSpeed = freshAirSpeed; + } + + public int getFreshAirMode() { + return freshAirMode; + } + + public void setFreshAirMode(int freshAirMode) { + this.freshAirMode = freshAirMode; + } + + public byte[] getCurState() { + return curState; + } + + public void setCurState(byte[] curState) { + this.curState = curState; + } + + public int getEnableValue1() { + return enableValue1; + } + + public void setEnableValue1(int enableValue1) { + this.enableValue1 = enableValue1; + } + + public int getEnableValue2() { + return enableValue2; + } + + public void setEnableValue2(int enableValue2) { + this.enableValue2 = enableValue2; + } + + public float getInTemp() { + return mInTemp; + } + + public void setInTemp(float inTemp) { + mInTemp = inTemp; + } + + public float getOutTemp() { + return mOutTemp; + } + + public void setOutTemp(float outTemp) { + mOutTemp = outTemp; + } + + public float getHumidty() { + return mHumidty; + } + + public void setHumidty(float humidty) { + mHumidty = humidty; + } + + public float getPM25() { + return mPM25; + } + + public void setPM25(float PM25) { + mPM25 = PM25; + } + + public float getTVOC() { + return mTVOC; + } + + public void setTVOC(float TVOC) { + mTVOC = TVOC; + } + + public float getCO2() { + return mCO2; + } + + public void setCO2(float CO2) { + mCO2 = CO2; + } + + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/Parser/FreshAirParser.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/Parser/FreshAirParser.java new file mode 100644 index 0000000..88e7b29 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/Parser/FreshAirParser.java @@ -0,0 +1,99 @@ +package com.hdl.sdk.hdl_core.HDLAppliances.HDLFreshAir.Parser; + +import com.hdl.sdk.hdl_core.Config.Configuration; +import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLDeviceManager; + +/** + * Created by JLChen on 2019/7/9 + */ +public class FreshAirParser { + // 闄勫姞鏁版嵁锛� 鏂伴閫氶亾鍙凤紙1 - 200锛� + 寮�鍏筹紙0锛�1锛� + 椋庨�燂紙0 鍏筹紝1浣庯紝2涓紝3楂橈級 + 妯″紡锛�0鎵嬪姩锛�1 鑷姩,2 鏅鸿兘锛�3 瀹氭椂锛� + public static final int fail = 0; + + public static final int freshAirSwich = 0; + public static final int freshAirOn = 1;//鏂伴寮� + public static final int freshAirOff = 0;//鏂伴鍏� + + public static final int freshAirSpeed = 1;//椋庨�� + public static final int freshAirSpeedOff = 0;//椋庨�熷叧 + public static final int freshAirSpeedLow = 1;//椋庨�熶綆 + public static final int freshAirSpeedMid = 2;//椋庨�熶腑 + public static final int freshAirSpeedHigh = 3;//椋庨�熼珮 + + public static final int freshAirMode = 2;//妯″紡 + public static final int freshAirModeManual = 0;//鎵嬪姩 + public static final int freshAirModeAuto = 1;//鑷姩 + public static final int freshAirModeIntelligent = 2;//鏅鸿兘 + public static final int freshAirModeTiming = 3;//瀹氭椂 + + public static byte[] getFreshAirAddByte(AppliancesInfo appliancesInfo, int type, int state) { + if (state > 3) { + return new byte[]{fail}; + } + + try { + AppliancesInfo newInfo = null; + byte[] freshAirBytes = 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.FRESH_AIR_BIG_TYPE + && HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType() == HDLApConfig.TYPE_FRESH_AIR + && appliancesInfo.getChannelNum() == HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum()) { + newInfo = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j); + if (newInfo.getFeedbackState() == null) { + newInfo.setFeedbackState(new byte[30]); + } + freshAirBytes = newInfo.getFeedbackState(); + break outter; + } + + } + } + } + + byte[] addBytes = new byte[4]; + if (freshAirBytes != null && freshAirBytes.length >= 4) { + addBytes[0] = (byte) appliancesInfo.getChannelNum(); + addBytes[1] = freshAirBytes[1]; + addBytes[2] = freshAirBytes[2]; + addBytes[3] = freshAirBytes[3]; + + } else { + addBytes[0] = (byte) appliancesInfo.getChannelNum(); + addBytes[1] = 0;//鍙戦�侀粯璁ゅ弬鏁� + addBytes[2] = 0; + addBytes[3] = 0; + } + + switch (type) { + case freshAirSwich: + if (state == freshAirOff) { + addBytes[1] = 0; + } else { + addBytes[1] = 1; + } + break; + case freshAirSpeed: + addBytes[1] = 1;//鎵撳紑鎿嶄綔 + addBytes[2] = (byte) state; + break; + case freshAirMode: + addBytes[1] = 1;//鎵撳紑鎿嶄綔 + addBytes[3] = (byte) state; + break; + } + return addBytes; + } catch (Exception e) { + e.printStackTrace(); + return new byte[]{fail}; + } + + } + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/GeothermalBackInfo.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/GeothermalBackInfo.java new file mode 100644 index 0000000..4a97001 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/GeothermalBackInfo.java @@ -0,0 +1,166 @@ +package com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal; + +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; + +/** + * Created by JLChen on 2019/7/10 + */ +public class GeothermalBackInfo { + + private AppliancesInfo appliancesInfo; + private String remarks; + private int channelNum; //鍥炶矾鍙� + private int isOn; //0=鍏筹紝1=寮� + private int gMode; //鍦扮儹 1 = 鏅�氭ā寮�, 2 = 鐧藉ぉ妯″紡 , 3 = 澶滈棿妯″紡, 4 = 绂诲紑妯″紡, 5 = 鑷姩妯″紡 + + private int gNormalTemp;//鏅�氭ā寮忔俯搴� + private int gDayTemp; //鐧藉ぉ妯″紡娓╁害 + private int gNightTemp; //澶滈棿妯″紡娓╁害 + private int gLeaveTemp; //绂诲紑妯″紡娓╁害 + + private int gAutoTemp; //鑷姩妯″紡妯″紡娓╁害 + private int gCurrentTemp;//褰撳墠娓╁害 + private byte[] curState;//鎺у埗鍥為淇℃伅 + private boolean bCtrlFeedback; + + public GeothermalBackInfo() { + + } + + /** + * GeothermalBackInfo + * @param mAppliancesInfo + * @param bCtrlFeedback 鏄惁鎺у埗鐘舵�佺殑鍙嶉 + */ + public GeothermalBackInfo(AppliancesInfo mAppliancesInfo , boolean bCtrlFeedback) { + this.bCtrlFeedback = bCtrlFeedback; + this.appliancesInfo = mAppliancesInfo; + this.curState = mAppliancesInfo.getFeedbackState(); + this.remarks = mAppliancesInfo.getRemarks(); + + if (this.curState == null) return; + + if (this.curState.length >= 10) { + this.channelNum = this.curState[0] & 0xFF; + this.isOn = this.curState[1] & 0x0F;//鍙彇浣�4浣� + this.gMode = this.curState[3] & 0xFF; + this.gNormalTemp = this.curState[4] & 0xFF; + this.gDayTemp = this.curState[5] & 0xFF; + this.gNightTemp = this.curState[6] & 0xFF; + this.gLeaveTemp = this.curState[7] & 0xFF; + this.gAutoTemp = this.curState[8] & 0xFF; + this.gCurrentTemp = this.curState[9] & 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 getgMode() { + return gMode; + } + + public void setgMode(int gMode) { + this.gMode = gMode; + } + + public int getgNormalTemp() { + return gNormalTemp; + } + + public void setgNormalTemp(int gNormalTemp) { + this.gNormalTemp = gNormalTemp; + } + + public int getgDayTemp() { + return gDayTemp; + } + + public void setgDayTemp(int gDayTemp) { + this.gDayTemp = gDayTemp; + } + + public int getgNightTemp() { + return gNightTemp; + } + + public void setgNightTemp(int gNightTemp) { + this.gNightTemp = gNightTemp; + } + + public int getgLeaveTemp() { + return gLeaveTemp; + } + + public void setgLeaveTemp(int gLeaveTemp) { + this.gLeaveTemp = gLeaveTemp; + } + + public byte[] getCurState() { + return curState; + } + + public void setCurState(byte[] curState) { + this.curState = curState; + } + + public int getgAutoTemp() { + return gAutoTemp; + } + + public void setgAutoTemp(int gAutoTemp) { + this.gAutoTemp = gAutoTemp; + } + + public int getgCurrentTemp() { + return gCurrentTemp; + } + + public void setgCurrentTemp(int gCurrentTemp) { + this.gCurrentTemp = gCurrentTemp; + } + + public boolean isbCtrlFeedback() { + return bCtrlFeedback; + } + + public void setbCtrlFeedback(boolean bCtrlFeedback) { + this.bCtrlFeedback = bCtrlFeedback; + } + + + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/Parser/GeothermalParser.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/Parser/GeothermalParser.java new file mode 100644 index 0000000..75b6587 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/Parser/GeothermalParser.java @@ -0,0 +1,198 @@ +package com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.Parser; + +import com.hdl.sdk.hdl_core.Config.Configuration; +import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLDeviceManager; + +/** + * Created by JLChen on 2019/7/10 + */ +public class GeothermalParser { + + public static final int fail = 0; + + public static final int gSwich = 2; + public static final int gSwichOn = 1;//鍦扮儹妯″潡寮� + public static final int gSwichOff = 0;//鍦扮儹妯″潡鍏� + + + public static final int gMode = 4; //妯″紡 + public static final int gModeNormal = 1;//鏅�氭ā寮� + public static final int gModeDay = 2;//鐧藉ぉ妯″紡 + public static final int gModeNight = 3;//澶滈棿妯″紡 + public static final int gModeLeave = 4;//绂诲紑妯″紡 + public static final int gModeAuto = 5;//鑷姩妯″紡 + + public static final int gNormalTemp = 5;//鏅�氭ā寮忔俯搴� + public static final int gDayTemp = 6;//鐧藉ぉ妯″紡娓╁害 + public static final int gNightTemp = 7;//澶滈棿妯″紡娓╁害 + public static final int gLeaveTemp = 8;//绂诲紑妯″紡娓╁害 + + // feedbackState [鍥炶矾锛屽紑鍏崇姸鎬侊紝娓╁害绫诲瀷锛屾ā寮忥紝鏅�氭俯搴︼紝鐧藉ぉ娓╁害锛屽闂存俯搴︼紝绂诲紑娓╁害锛岃嚜鍔ㄦ俯搴︼紝褰撳墠娓╁害] + public static byte[] getGeothermalAddByte(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.GEOTHERMAL_BIG_TYPE + && HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType() == HDLApConfig.TYPE_GEOTHERMAL_MODULE + && appliancesInfo.getChannelNum() == HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum()) { + newInfo = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j); + if (newInfo.getFeedbackState() == null) { + newInfo.setFeedbackState(new byte[10]); + } + airBytes = newInfo.getFeedbackState(); + break outter; + } + + } + } + } + + byte[] addBytes = new byte[10]; + if (airBytes != null && airBytes.length >= 10) { + addBytes[0] = (byte) newInfo.getChannelNum(); + addBytes[1] = airBytes[1]; + addBytes[2] = 0; + addBytes[3] = airBytes[3]; + addBytes[4] = airBytes[4]; + addBytes[5] = airBytes[5]; + addBytes[6] = airBytes[6]; + addBytes[7] = airBytes[7]; + addBytes[8] = 0; + addBytes[9] = 0; + } else { + addBytes[0] = (byte) newInfo.getChannelNum(); + addBytes[1] = 0; + addBytes[2] = 0; + addBytes[3] = 1; + addBytes[4] = 30; + addBytes[5] = 30; + addBytes[6] = 30; + addBytes[7] = 30; + addBytes[8] = 0; + addBytes[9] = 0; + } + + switch (type) { + case gSwich: + if (state == gSwichOff) { + addBytes[1] = 0; + } else { + addBytes[1] = 1; + } + break; + case gMode: + addBytes[1] = 1; + addBytes[3] = (byte) state; + break; + case gNormalTemp: + addBytes[1] = 1;//鎵撳紑 + addBytes[4] = (byte) state; + break; + case gDayTemp: + addBytes[1] = 1;//鎵撳紑 + addBytes[5] = (byte) state; + break; + case gNightTemp: + addBytes[1] = 1;//鎵撳紑 + addBytes[6] = (byte) state; + break; + case gLeaveTemp: + addBytes[1] = 1;//鎵撳紑 + addBytes[7] = (byte) state; + break; + } + return addBytes; + + + } catch (Exception e) { + e.printStackTrace(); + return new byte[]{fail}; + } + + } + + //鏍规嵁褰撳墠妯″紡璁剧疆娓╁害 + public static byte[] getGeothermalAddByteTemp(AppliancesInfo appliancesInfo, 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.GEOTHERMAL_BIG_TYPE + && HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType() == HDLApConfig.TYPE_GEOTHERMAL_MODULE + && appliancesInfo.getChannelNum() == HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum()) { + newInfo = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j); + if (newInfo.getFeedbackState() == null) { + newInfo.setFeedbackState(new byte[10]); + } + airBytes = newInfo.getFeedbackState(); + break outter; + } + + } + } + } + + byte[] addBytes = new byte[10]; + if (airBytes != null && airBytes.length >= 10) { + addBytes[0] = (byte) newInfo.getChannelNum(); + addBytes[1] = airBytes[1]; + addBytes[2] = 0; + addBytes[3] = airBytes[3]; + addBytes[4] = airBytes[4]; + addBytes[5] = airBytes[5]; + addBytes[6] = airBytes[6]; + addBytes[7] = airBytes[7]; + addBytes[8] = 0; + addBytes[9] = 0; + } else { + addBytes[0] = (byte) newInfo.getChannelNum(); + addBytes[1] = 0; + addBytes[2] = 0; + addBytes[3] = 1; + addBytes[4] = 30; + addBytes[5] = 30; + addBytes[6] = 30; + addBytes[7] = 30; + addBytes[8] = 0; + addBytes[9] = 0; + } + + switch (addBytes[3]) { + case gModeNormal: + addBytes[1] = 1;//鎵撳紑 + addBytes[4] = (byte) state; + break; + case gModeDay: + addBytes[1] = 1;//鎵撳紑 + addBytes[5] = (byte) state; + break; + case gModeNight: + addBytes[1] = 1;//鎵撳紑 + addBytes[6] = (byte) state; + break; + case gModeLeave: + addBytes[1] = 1;//鎵撳紑 + addBytes[7] = (byte) state; + break; + } + return addBytes; + + + } catch (Exception e) { + e.printStackTrace(); + return new byte[]{fail}; + } + + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLight/LightCtrlBackInfo.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLight/LightCtrlBackInfo.java new file mode 100644 index 0000000..ca3402e --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLight/LightCtrlBackInfo.java @@ -0,0 +1,98 @@ +package com.hdl.sdk.hdl_core.HDLAppliances.HDLLight; + + +import com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLogic/LogicCtrlBackInfo.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLogic/LogicCtrlBackInfo.java new file mode 100644 index 0000000..359dc42 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLogic/LogicCtrlBackInfo.java @@ -0,0 +1,48 @@ +package com.hdl.sdk.hdl_core.HDLAppliances.HDLLogic; + + +import com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLogic/LogicMode.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLogic/LogicMode.java new file mode 100644 index 0000000..24e1d8b --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLogic/LogicMode.java @@ -0,0 +1,29 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLSensor/SensorCtrlBackInfo.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLSensor/SensorCtrlBackInfo.java new file mode 100644 index 0000000..b6cb387 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLSensor/SensorCtrlBackInfo.java @@ -0,0 +1,26 @@ +package com.hdl.sdk.hdl_core.HDLAppliances.HDLSensor; + +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; +import com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLSensor/SensorStateBackInfo.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLSensor/SensorStateBackInfo.java new file mode 100644 index 0000000..7b0c2b8 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLSensor/SensorStateBackInfo.java @@ -0,0 +1,21 @@ +package com.hdl.sdk.hdl_core.HDLAppliances.HDLSensor; + +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; +import com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLWarning/WarningType.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLWarning/WarningType.java new file mode 100644 index 0000000..58af54b --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLWarning/WarningType.java @@ -0,0 +1,139 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/AppliancesInfo.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/AppliancesInfo.java new file mode 100644 index 0000000..512dc5a --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/AppliancesInfo.java @@ -0,0 +1,256 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean; + +import com.hdl.sdk.hdl_core.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;//鐘舵�佸弽棣堣褰曟暟鎹� 20190709鏂板 + private int intCurState; + private String deviceKey; + + public int getIntCurState() { + return intCurState; + } + + public void setIntCurState(int intCurState) { + this.intCurState = intCurState; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getIpAddressDevice() { + 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 Object getCurStateObject() { + return curState; + } +// public int getCurStateToInt() { +// return HDLUtlis.getIntegerByObject(curState); +// } +// +// public float getCurStateToFloat() { +// return HDLUtlis.getFloatByObject(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 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 + + ", feedbackState=" + Arrays.toString(feedbackState) + + ", intCurState=" + intCurState + + '}'; + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/DeviceStateBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/DeviceStateBean.java new file mode 100644 index 0000000..674c723 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/DeviceStateBean.java @@ -0,0 +1,83 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean; + +import java.io.Serializable; + +/** + * 姝ょ被涓昏鐢ㄤ簬鎻愪緵缁欑涓夋柟浣跨敤 + */ +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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/DevicesData.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/DevicesData.java new file mode 100644 index 0000000..37725c2 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/DevicesData.java @@ -0,0 +1,59 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ListRemarks.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ListRemarks.java new file mode 100644 index 0000000..1331e13 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ListRemarks.java @@ -0,0 +1,26 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/RcuCurtain.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/RcuCurtain.java new file mode 100644 index 0000000..679f8c2 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/RcuCurtain.java @@ -0,0 +1,31 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/RcuLight.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/RcuLight.java new file mode 100644 index 0000000..dd3e9c9 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/RcuLight.java @@ -0,0 +1,31 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/RemarkTimes.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/RemarkTimes.java new file mode 100644 index 0000000..0ef101f --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/RemarkTimes.java @@ -0,0 +1,13 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean; + +public class RemarkTimes { + int count; + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/SearchCountBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/SearchCountBean.java new file mode 100644 index 0000000..5a2f5bd --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/SearchCountBean.java @@ -0,0 +1,13 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean; + +public class SearchCountBean { + private int count ; + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/UdpDataBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/UdpDataBean.java new file mode 100644 index 0000000..d66897f --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/UdpDataBean.java @@ -0,0 +1,12 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/CommonErrorBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/CommonErrorBean.java new file mode 100644 index 0000000..7f86615 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/CommonErrorBean.java @@ -0,0 +1,25 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean; + +/** + * 閿欒淇℃伅 + */ +public class CommonErrorBean { + private String cmd ; + private String reason; + + public String getCmd() { + return cmd; + } + + public void setCmd(String cmd) { + this.cmd = cmd; + } + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeDeviceListBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeDeviceListBean.java new file mode 100644 index 0000000..dd17d9e --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeDeviceListBean.java @@ -0,0 +1,353 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean; + +import org.eclipse.paho.client.mqttv3.MqttClient; + +import java.io.Serializable; +import java.util.List; + +/** + * 鎼滅储鐨勮澶囧垪琛� + */ +public class ZigbeeDeviceListBean implements Serializable{ + + //鏁版嵁澶� + private int Time; + private int Device_ID; + private String DeviceAddr; + private int Epoint; + private int Data_ID; + private Data Data; + + + public int getTime() { + return Time; + } + + public void setTime(int time) { + Time = time; + } + + public int getDevice_ID() { + return Device_ID; + } + + public void setDevice_ID(int device_ID) { + Device_ID = device_ID; + } + + public String getDeviceAddr() { + return DeviceAddr; + } + + public void setDeviceAddr(String deviceAddr) { + DeviceAddr = deviceAddr; + } + + public int getEpoint() { + return Epoint; + } + + public void setEpoint(int epoint) { + Epoint = epoint; + } + + public int getData_ID() { + return Data_ID; + } + + public void setData_ID(int data_ID) { + Data_ID = data_ID; + } + + public ZigbeeDeviceListBean.Data getData() { + return Data; + } + + public void setData(ZigbeeDeviceListBean.Data data) { + Data = data; + } + + public class Data implements Serializable{ + private int TotalNum; + private int DeviceNum; + private int JoinTime; + private int ZigbeeType; + private int NwkAddr; + private int DeviceType; + private int Profile; + private String MacName; + private String DeviceName; + private int isOline; + private List<InClusterList> InClusterList; + private List<OutClusterList> OutClusterList; + private List<AttributeStatus> AttributeStatus; + private int ImgVersion; + private int ImgTypeId; + private int HwVersion; + private int DriveCode; + private String GwId; + private int ClusterBindZbSuccess; + private int IsGetAllDefaultBind; + private String ManufacturerName; + private String ModelIdentifier; + private String ProductCode; + private int FunctionType; + + public int getTotalNum() { + return TotalNum; + } + + public void setTotalNum(int totalNum) { + TotalNum = totalNum; + } + + public int getDeviceNum() { + return DeviceNum; + } + + public void setDeviceNum(int deviceNum) { + DeviceNum = deviceNum; + } + + public int getJoinTime() { + return JoinTime; + } + + public void setJoinTime(int joinTime) { + JoinTime = joinTime; + } + + public int getZigbeeType() { + return ZigbeeType; + } + + public void setZigbeeType(int zigbeeType) { + ZigbeeType = zigbeeType; + } + + public int getNwkAddr() { + return NwkAddr; + } + + public void setNwkAddr(int nwkAddr) { + NwkAddr = nwkAddr; + } + + public int getDeviceType() { + return DeviceType; + } + + public void setDeviceType(int deviceType) { + DeviceType = deviceType; + } + + public int getProfile() { + return Profile; + } + + public void setProfile(int profile) { + Profile = profile; + } + + public String getMacName() { + return MacName; + } + + public void setMacName(String macName) { + MacName = macName; + } + + public String getDeviceName() { + return DeviceName; + } + + public void setDeviceName(String deviceName) { + DeviceName = deviceName; + } + + public int getIsOline() { + return isOline; + } + + public void setIsOline(int isOline) { + this.isOline = isOline; + } + + public List<ZigbeeDeviceListBean.Data.InClusterList> getInClusterList() { + return InClusterList; + } + + public void setInClusterList(List<ZigbeeDeviceListBean.Data.InClusterList> inClusterList) { + InClusterList = inClusterList; + } + + public List<ZigbeeDeviceListBean.Data.OutClusterList> getOutClusterList() { + return OutClusterList; + } + + public void setOutClusterList(List<ZigbeeDeviceListBean.Data.OutClusterList> outClusterList) { + OutClusterList = outClusterList; + } + + public List<ZigbeeDeviceListBean.Data.AttributeStatus> getAttributeStatus() { + return AttributeStatus; + } + + public void setAttributeStatus(List<ZigbeeDeviceListBean.Data.AttributeStatus> attributeStatus) { + AttributeStatus = attributeStatus; + } + + public int getImgVersion() { + return ImgVersion; + } + + public void setImgVersion(int imgVersion) { + ImgVersion = imgVersion; + } + + public int getImgTypeId() { + return ImgTypeId; + } + + public void setImgTypeId(int imgTypeId) { + ImgTypeId = imgTypeId; + } + + public int getHwVersion() { + return HwVersion; + } + + public void setHwVersion(int hwVersion) { + HwVersion = hwVersion; + } + + public int getDriveCode() { + return DriveCode; + } + + public void setDriveCode(int driveCode) { + DriveCode = driveCode; + } + + public String getGwId() { + return GwId; + } + + public void setGwId(String gwId) { + GwId = gwId; + } + + public int getClusterBindZbSuccess() { + return ClusterBindZbSuccess; + } + + public void setClusterBindZbSuccess(int clusterBindZbSuccess) { + ClusterBindZbSuccess = clusterBindZbSuccess; + } + + public int getIsGetAllDefaultBind() { + return IsGetAllDefaultBind; + } + + public void setIsGetAllDefaultBind(int isGetAllDefaultBind) { + IsGetAllDefaultBind = isGetAllDefaultBind; + } + + public String getManufacturerName() { + return ManufacturerName; + } + + public void setManufacturerName(String manufacturerName) { + ManufacturerName = manufacturerName; + } + + public String getModelIdentifier() { + return ModelIdentifier; + } + + public void setModelIdentifier(String modelIdentifier) { + ModelIdentifier = modelIdentifier; + } + + public String getProductCode() { + return ProductCode; + } + + public void setProductCode(String productCode) { + ProductCode = productCode; + } + + public int getFunctionType() { + return FunctionType; + } + + public void setFunctionType(int functionType) { + FunctionType = functionType; + } + + public class InClusterList implements Serializable{ + private int InCluster; + + public int getInCluster() { + return InCluster; + } + + public void setInCluster(int inCluster) { + InCluster = inCluster; + } + + } + public class OutClusterList implements Serializable{ + private int OutClusterList; + + public int getOutClusterList() { + return OutClusterList; + } + + public void setOutClusterList(int outClusterList) { + OutClusterList = outClusterList; + } + + } + public class AttributeStatus implements Serializable{ + private int ClusterId; + private int AttributeId; + private int AttributeData; + private int ReportTime; + + public int getClusterId() { + return ClusterId; + } + + public void setClusterId(int clusterId) { + ClusterId = clusterId; + } + + public int getAttributeId() { + return AttributeId; + } + + public void setAttributeId(int attributeId) { + AttributeId = attributeId; + } + + public int getAttributeData() { + return AttributeData; + } + + public void setAttributeData(int attributeData) { + AttributeData = attributeData; + } + + public int getReportTime() { + return ReportTime; + } + + public void setReportTime(int reportTime) { + ReportTime = reportTime; + } + + } + + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeDeviceSaveBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeDeviceSaveBean.java new file mode 100644 index 0000000..92cc3ad --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeDeviceSaveBean.java @@ -0,0 +1,116 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean; + +import java.io.Serializable; +import java.util.List; + +/** + * 鍌ㄥ瓨鐨勮澶囧垪琛� + */ +public class ZigbeeDeviceSaveBean { + private String ipAddress;//缃戝叧ip鍦板潃 + private String gatewayId;//缃戝叧id + int mSubnetID;//瀵圭綉鍏宠繘琛屾爣璁� + private int Device_ID;//璁惧id锛堟爣璇嗘槸鍝釜璁惧锛� + private int deviceMark; + private String DeviceAddr;//璁惧mac鍦板潃锛堝悓涓�涓澶囷紙涓嶅悓鍥炶矾锛夊彧鏈変竴涓猰ac鍦板潃锛� + private int Epoint;//璁惧绔彛鍙凤紙鍥炶矾鍙凤級ChannelNum + private String MacName;//璁惧鍚嶇О + private String DeviceName;//璁惧鍥炶矾鍚嶇О + private List<ZigbeeDeviceListBean.Data.InClusterList> InClusterList;//杈撳叆鏃忓垪琛紙淇濈暀锛� + + public int getDeviceMark() { + return deviceMark; + } + + public void setDeviceMark(int deviceMark) { + this.deviceMark = deviceMark; + } + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + + public List<ZigbeeDeviceListBean.Data.InClusterList> getInClusterList() { + return InClusterList; + } + + public void setInClusterList(List<ZigbeeDeviceListBean.Data.InClusterList> inClusterList) { + InClusterList = inClusterList; + } + + public int getmSubnetID() { + return mSubnetID; + } + + public void setmSubnetID(int mSubnetID) { + this.mSubnetID = mSubnetID; + } + + public int getDevice_ID() { + return Device_ID; + } + + public void setDevice_ID(int device_ID) { + Device_ID = device_ID; + } + + public String getDeviceAddr() { + return DeviceAddr; + } + + public void setDeviceAddr(String deviceAddr) { + DeviceAddr = deviceAddr; + } + + public int getEpoint() { + return Epoint; + } + + public void setEpoint(int epoint) { + Epoint = epoint; + } + + public String getMacName() { + return MacName; + } + + public void setMacName(String macName) { + MacName = macName; + } + + public String getDeviceName() { + return DeviceName; + } + + public void setDeviceName(String deviceName) { + DeviceName = deviceName; + } + + + + public static class inClusterList{ + private int InCluster; + + public int getInCluster() { + return InCluster; + } + + public void setInCluster(int inCluster) { + InCluster = inCluster; + } + } +} + diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeGatewayInfoBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeGatewayInfoBean.java new file mode 100644 index 0000000..5f36f92 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeGatewayInfoBean.java @@ -0,0 +1,57 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean; + +import java.util.List; + +/** + * 缃戝叧淇℃伅 + */ +public class ZigbeeGatewayInfoBean { + + + + private boolean IsDomain; + private String gatewayName; + private String ipAddress; + private String gatewayId; + private int count; + + + public boolean isDomain() { + return IsDomain; + } + + public void setDomain(boolean domain) { + IsDomain = domain; + } + + public String getGatewayName() { + return gatewayName; + } + + public void setGatewayName(String gatewayName) { + this.gatewayName = gatewayName; + } + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeSceneListBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeSceneListBean.java new file mode 100644 index 0000000..9e7593a --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeSceneListBean.java @@ -0,0 +1,87 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean; +import java.util.ArrayList; +import java.util.List; + +/** + * 鍦烘櫙鍒楄〃 + */ +public class ZigbeeSceneListBean { + private int Time; + private int Data_ID;//鑾峰彇鎵�鏈夊満鏅俊鎭洖澶� + private Data Data ; + + public int getTime() { + return Time; + } + + public void setTime(int time) { + Time = time; + } + + public int getData_ID() { + return Data_ID; + } + + public void setData_ID(int data_ID) { + Data_ID = data_ID; + } + + public Data getData() { + return Data; + } + + public void setData(Data data) { + this.Data = data; + } + + public static class Data { + public int ScenesSum;//鍦烘櫙鎬绘暟 + private List<ScenesList> ScenesList ;//鍦烘櫙鍒楄〃 + + public int getScenesSum() { + return ScenesSum; + } + + public void setScenesSum(int scenesSum) { + ScenesSum = scenesSum; + } + + public List<ScenesList> getScenesLists() { + return ScenesList; + } + + public void setScenesLists(List<ScenesList> scenesLists) { + this.ScenesList = scenesLists; + } + + public static class ScenesList { + private int ScenesId;//鍦烘櫙ID + private String ScenesName;//鍦烘櫙鍚嶇О + private int IsOpen;//鏄惁澶勪簬寮�鍚姸鎬� + + public int getScenesId() { + return ScenesId; + } + + public void setScenesId(int scenesId) { + ScenesId = scenesId; + } + + public String getScenesName() { + return ScenesName; + } + + public void setScenesName(String scenesName) { + ScenesName = scenesName; + } + + public int getIsOpen() { + return IsOpen; + } + + public void setIsOpen(int isOpen) { + IsOpen = isOpen; + } + } + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeSceneSaveBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeSceneSaveBean.java new file mode 100644 index 0000000..af3f59c --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/ZigbeeSceneSaveBean.java @@ -0,0 +1,74 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean; + +/** + * 鍦烘櫙瀛樺偍鍒楄〃 + */ +public class ZigbeeSceneSaveBean { + private String IpAddr; + private int subnetId; + private int deviceid; + private int ScenesId;//鍦烘櫙ID + private String ScenesName;//鍦烘櫙鍚嶇О + private int IsOpen;//鏄惁澶勪簬寮�鍚姸鎬� + private ZigbeeSceneListBean zigbeeSceneListBean; + + public ZigbeeSceneListBean getZigbeeSceneListBean() { + return zigbeeSceneListBean; + } + + public void setZigbeeSceneListBean(ZigbeeSceneListBean zigbeeSceneListBean) { + this.zigbeeSceneListBean = zigbeeSceneListBean; + } + + public int getScenesId() { + return ScenesId; + } + + public void setScenesId(int scenesId) { + ScenesId = scenesId; + } + + public String getScenesName() { + return ScenesName; + } + + public void setScenesName(String scenesName) { + ScenesName = scenesName; + } + + public int getIsOpen() { + return IsOpen; + } + + public void setIsOpen(int isOpen) { + IsOpen = isOpen; + } + + public int getDeviceid() { + return deviceid; + } + + public void setDeviceid(int deviceid) { + this.deviceid = deviceid; + } + + public int getSubnetId() { + return subnetId; + } + + public void setSubnetId(int subnetId) { + this.subnetId = subnetId; + } + + public String getIpAddr() { + return IpAddr; + } + + public void setIpAddr(String ipAddr) { + IpAddr = ipAddr; + } + + + + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/gatewaybeans/GatewayCommondBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/gatewaybeans/GatewayCommondBean.java new file mode 100644 index 0000000..1db3b85 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/gatewaybeans/GatewayCommondBean.java @@ -0,0 +1,31 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.gatewaybeans; + +/** + * 璇诲彇Bean涓庢櫘閫氭帶鍒禕ean + */ +public class GatewayCommondBean { + /** + * cmd : read銆亀rite鏍囪 + * value : 鏁板�� + */ + private String cmd; + private int value; + + public String getCmd() { + return cmd; + } + + public void setCmd(String cmd) { + this.cmd = cmd; + } + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/gatewaybeans/GatewayCurtainBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/gatewaybeans/GatewayCurtainBean.java new file mode 100644 index 0000000..c38edbc --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/gatewaybeans/GatewayCurtainBean.java @@ -0,0 +1,39 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.gatewaybeans; + +/** + * 绐楀笜鎺у埗绫� + */ +public class GatewayCurtainBean { + /** + * cmd :read銆亀rite鏍囪 + * tag :0琛ㄧず浠呮帶鍒躲��1琛ㄧず鐧惧垎姣旀帶鍒� + * value : 鏁板�� + */ + private String cmd; + private int tag; + private int value; + + public String getCmd() { + return cmd; + } + + public void setCmd(String cmd) { + this.cmd = cmd; + } + + public int getTag() { + return tag; + } + + public void setTag(int tag) { + this.tag = tag; + } + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/gatewaybeans/StatusReadBackBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/gatewaybeans/StatusReadBackBean.java new file mode 100644 index 0000000..0fc797c --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/gatewaybeans/StatusReadBackBean.java @@ -0,0 +1,23 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.gatewaybeans; + +import java.util.List; + +/** + * 鐘舵�佸洖璋冪被 + */ +public class StatusReadBackBean { + + private int value; + + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/gatewaybeans/StatusThermostatReadBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/gatewaybeans/StatusThermostatReadBean.java new file mode 100644 index 0000000..3ec89be --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/gatewaybeans/StatusThermostatReadBean.java @@ -0,0 +1,52 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.gatewaybeans; + +/** + * 鎭掓俯鍣ㄧ姸鎬佽繑鍥炵被 + */ +public class StatusThermostatReadBean { + private int tag;//鏍囧織杩斿洖浠�涔堟暟鎹� + private int thermostatmode;//鎭掓俯鍣ㄦā寮� + private int fanmode;//鏂伴妯″紡 + private int coolingSetpoint;//鍒跺喎娓╁害 + private int heatingSetpoint;//鍒剁儹娓╁害 + + public int getTag() { + return tag; + } + + public void setTag(int tag) { + this.tag = tag; + } + + public int getCoolingSetpoint() { + return coolingSetpoint; + } + + public void setCoolingSetpoint(int coolingSetpoint) { + this.coolingSetpoint = coolingSetpoint; + } + + public int getHeatingSetpoint() { + return heatingSetpoint; + } + + public void setHeatingSetpoint(int heatingSetpoint) { + this.heatingSetpoint = heatingSetpoint; + } + + public int getThermostatmode() { + return thermostatmode; + } + + public void setThermostatmode(int thermostatmode) { + this.thermostatmode = thermostatmode; + } + + public int getFanmode() { + return fanmode; + } + + public void setFanmode(int fanmode) { + this.fanmode = fanmode; + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeCtrlBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeCtrlBean.java new file mode 100644 index 0000000..1907ffb --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeCtrlBean.java @@ -0,0 +1,87 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.mqttbeans; + +/** + * 鎺у埗绫� + */ +public class ZigbeeCtrlBean { + + /** + * DeviceAddr : 000d6ffffe044e91 + * Epoint : 1 + * Cluster_ID : 6 + * Command : 2 + * SendMode : 2 + * Data : {"Value":20} + */ + + private String DeviceAddr; + private int Epoint; + private int Cluster_ID; + private int Command; + private int SendMode; + private DataBean Data; + + public String getDeviceAddr() { + return DeviceAddr; + } + + public void setDeviceAddr(String DeviceAddr) { + this.DeviceAddr = DeviceAddr; + } + + public int getEpoint() { + return Epoint; + } + + public void setEpoint(int Epoint) { + this.Epoint = Epoint; + } + + public int getCluster_ID() { + return Cluster_ID; + } + + public void setCluster_ID(int Cluster_ID) { + this.Cluster_ID = Cluster_ID; + } + + public int getCommand() { + return Command; + } + + public void setCommand(int Command) { + this.Command = Command; + } + + public int getSendMode() { + return SendMode; + } + + public void setSendMode(int SendMode) { + this.SendMode = SendMode; + } + + public DataBean getData() { + return Data; + } + + public void setData(DataBean Data) { + this.Data = Data; + } + + public static class DataBean { + /** + * Value : 20 + */ + + private int Value; + + public int getValue() { + return Value; + } + + public void setValue(int Value) { + this.Value = Value; + } + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeDimmableCtrlBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeDimmableCtrlBean.java new file mode 100644 index 0000000..ace22e5 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeDimmableCtrlBean.java @@ -0,0 +1,85 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.mqttbeans; + +/** + * 璋冨厜鍣ㄦ帶鍒剁被 + */ +public class ZigbeeDimmableCtrlBean { + /** + * 璋冨厜鍣ㄧ洿鎺ユ帶鍒剁被 + */ + private String DeviceAddr; + private int Epoint; + private int Cluster_ID; + private int Command; + private int SendMode; + private Data data; + + public String getDeviceAddr() { + return DeviceAddr; + } + + public void setDeviceAddr(String deviceAddr) { + DeviceAddr = deviceAddr; + } + + public int getEpoint() { + return Epoint; + } + + public void setEpoint(int epoint) { + Epoint = epoint; + } + + public int getCluster_ID() { + return Cluster_ID; + } + + public void setCluster_ID(int cluster_ID) { + Cluster_ID = cluster_ID; + } + + public int getCommand() { + return Command; + } + + public void setCommand(int command) { + Command = command; + } + + public int getSendMode() { + return SendMode; + } + + public void setSendMode(int sendMode) { + SendMode = sendMode; + } + + public Data getData() { + return data; + } + + public void setData(Data data) { + this.data = data; + } + + public static class Data{ + private int Level;//浜害鍊� + private int TransitionTime;//杞崲鏃堕棿 + + public int getLevel() { + return Level; + } + + public void setLevel(int level) { + Level = level; + } + + public int getTransitionTime() { + return TransitionTime; + } + + public void setTransitionTime(int transitionTime) { + TransitionTime = transitionTime; + } + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeReadBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeReadBean.java new file mode 100644 index 0000000..dd3df11 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeReadBean.java @@ -0,0 +1,102 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.mqttbeans; + +import java.util.List; + +/** + * 璁惧鐘舵�佽鍙栬〃 + */ +public class ZigbeeReadBean { + + + /** + * DeviceAddr : 000d6ffffe044e91 + * Epoint : 1 + * Cluster_ID : 6 + * Command : 2 + * SendMode : 2 + * Data : {"AttriBute":[{"AttriButeId":0}]} + */ + + private String DeviceAddr; + private int Epoint; + private int Cluster_ID; + private int Command; + private int SendMode; + private DataBean Data; + + public String getDeviceAddr() { + return DeviceAddr; + } + + public void setDeviceAddr(String DeviceAddr) { + this.DeviceAddr = DeviceAddr; + } + + public int getEpoint() { + return Epoint; + } + + public void setEpoint(int Epoint) { + this.Epoint = Epoint; + } + + public int getCluster_ID() { + return Cluster_ID; + } + + public void setCluster_ID(int Cluster_ID) { + this.Cluster_ID = Cluster_ID; + } + + public int getCommand() { + return Command; + } + + public void setCommand(int Command) { + this.Command = Command; + } + + public int getSendMode() { + return SendMode; + } + + public void setSendMode(int SendMode) { + this.SendMode = SendMode; + } + + public DataBean getData() { + return Data; + } + + public void setData(DataBean Data) { + this.Data = Data; + } + + public static class DataBean { + private List<AttriButeBean> AttriBute; + + public List<AttriButeBean> getAttriBute() { + return AttriBute; + } + + public void setAttriBute(List<AttriButeBean> AttriBute) { + this.AttriBute = AttriBute; + } + + public static class AttriButeBean { + /** + * AttriButeId : 0 + */ + + private int AttriButeId; + + public int getAttriButeId() { + return AttriButeId; + } + + public void setAttriButeId(int AttriButeId) { + this.AttriButeId = AttriButeId; + } + } + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeReportBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeReportBean.java new file mode 100644 index 0000000..0227095 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeReportBean.java @@ -0,0 +1,165 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.mqttbeans; + +import java.util.List; + +/** + * 鎺у埗鍥炶皟淇℃伅琛� + */ +public class ZigbeeReportBean { + + /** + * Time : 1547703297 + * Device_ID : 2 + * DeviceAddr : 000d6ffffe044e91 + * Epoint : 1 + * Data_ID : 108 + * Data : {"CluterID":6,"NumAttr":1,"AttriBute":[{"AttriButeDataType":16,"AttriButeDataLength":1,"AttriButeId":0,"AttriButeData":1,"AttriButeDataHex":"01"}]} + */ + + private int Time; + private int Device_ID; + private String DeviceAddr; + private int Epoint; + private int Data_ID; + private DataBean Data; + + public int getTime() { + return Time; + } + + public void setTime(int Time) { + this.Time = Time; + } + + public int getDevice_ID() { + return Device_ID; + } + + public void setDevice_ID(int Device_ID) { + this.Device_ID = Device_ID; + } + + public String getDeviceAddr() { + return DeviceAddr; + } + + public void setDeviceAddr(String DeviceAddr) { + this.DeviceAddr = DeviceAddr; + } + + public int getEpoint() { + return Epoint; + } + + public void setEpoint(int Epoint) { + this.Epoint = Epoint; + } + + public int getData_ID() { + return Data_ID; + } + + public void setData_ID(int Data_ID) { + this.Data_ID = Data_ID; + } + + public DataBean getData() { + return Data; + } + + public void setData(DataBean Data) { + this.Data = Data; + } + + public static class DataBean { + /** + * CluterID : 6 + * NumAttr : 1 + * AttriBute : [{"AttriButeDataType":16,"AttriButeDataLength":1,"AttriButeId":0,"AttriButeData":1,"AttriButeDataHex":"01"}] + */ + + private int CluterID; + private int NumAttr; + private List<AttriButeBean> AttriBute; + + public int getCluterID() { + return CluterID; + } + + public void setCluterID(int CluterID) { + this.CluterID = CluterID; + } + + public int getNumAttr() { + return NumAttr; + } + + public void setNumAttr(int NumAttr) { + this.NumAttr = NumAttr; + } + + public List<AttriButeBean> getAttriBute() { + return AttriBute; + } + + public void setAttriBute(List<AttriButeBean> AttriBute) { + this.AttriBute = AttriBute; + } + + public static class AttriButeBean { + /** + * AttriButeDataType : 16 + * AttriButeDataLength : 1 + * AttriButeId : 0 + * AttriButeData : 1 + * AttriButeDataHex : 01 + */ + + private int AttriButeDataType; + private int AttriButeDataLength; + private int AttriButeId; + private int AttriButeData; + private String AttriButeDataHex; + + public int getAttriButeDataType() { + return AttriButeDataType; + } + + public void setAttriButeDataType(int AttriButeDataType) { + this.AttriButeDataType = AttriButeDataType; + } + + public int getAttriButeDataLength() { + return AttriButeDataLength; + } + + public void setAttriButeDataLength(int AttriButeDataLength) { + this.AttriButeDataLength = AttriButeDataLength; + } + + public int getAttriButeId() { + return AttriButeId; + } + + public void setAttriButeId(int AttriButeId) { + this.AttriButeId = AttriButeId; + } + + public int getAttriButeData() { + return AttriButeData; + } + + public void setAttriButeData(int AttriButeData) { + this.AttriButeData = AttriButeData; + } + + public String getAttriButeDataHex() { + return AttriButeDataHex; + } + + public void setAttriButeDataHex(String AttriButeDataHex) { + this.AttriButeDataHex = AttriButeDataHex; + } + } + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeSceneCtrlBackBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeSceneCtrlBackBean.java new file mode 100644 index 0000000..dccce39 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeSceneCtrlBackBean.java @@ -0,0 +1,56 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.mqttbeans; + +/** + * 鍦烘櫙鎺у埗鍥炶皟琛� + */ +public class ZigbeeSceneCtrlBackBean { + private int Data_ID; + private DataBean Data; + + public int getData_ID() { + return Data_ID; + } + + public void setData_ID(int data_ID) { + Data_ID = data_ID; + } + + public DataBean getData() { + return Data; + } + + public void setData(DataBean data) { + Data = data; + } + + public static class DataBean { + private int ScenesId; + private int DelayTime; + private int Result; + + public int getScenesId() { + return ScenesId; + } + + public void setScenesId(int scenesId) { + ScenesId = scenesId; + } + + public int getDelayTime() { + return DelayTime; + } + + public void setDelayTime(int delayTime) { + DelayTime = delayTime; + } + + public int getResult() { + return Result; + } + + public void setResult(int result) { + Result = result; + } + + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeSceneCtrlBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeSceneCtrlBean.java new file mode 100644 index 0000000..ea9e967 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeSceneCtrlBean.java @@ -0,0 +1,70 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.mqttbeans; + + +/** + * 鍦烘櫙鎺у埗琛� + */ +public class ZigbeeSceneCtrlBean { + private int Cluster_ID; + private int Command; + private DataBean Data; + + + + public int getCluster_ID() { + return Cluster_ID; + } + + + + public void setCluster_ID(int cluster_ID) { + Cluster_ID = cluster_ID; + } + + + + public int getCommand() { + return Command; + } + + + + public void setCommand(int command) { + Command = command; + } + + + + public DataBean getData() { + return Data; + } + + + + public void setData(DataBean data) { + Data = data; + } + + + + public static class DataBean { + private int ScenesId; + private int DelayTime; + + public int getScenesId() { + return ScenesId; + } + public void setScenesId(int scenesId) { + ScenesId = scenesId; + } + public int getDelayTime() { + return DelayTime; + } + public void setDelayTime(int delayTime) { + DelayTime = delayTime; + } + + + + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeThermostatCtrlBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeThermostatCtrlBean.java new file mode 100644 index 0000000..364ac39 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeThermostatCtrlBean.java @@ -0,0 +1,82 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.mqttbeans; + +/** + * 鎭掓俯鍣ㄦ俯搴︽帶鍒惰〃 + */ +public class ZigbeeThermostatCtrlBean { + private String DeviceAddr; + private int Epoint; + private int Cluster_ID; + private int Command; + private int SendMode; + private Data Data; + + public String getDeviceAddr() { + return DeviceAddr; + } + + public void setDeviceAddr(String deviceAddr) { + DeviceAddr = deviceAddr; + } + + public int getEpoint() { + return Epoint; + } + + public void setEpoint(int epoint) { + Epoint = epoint; + } + + public int getCluster_ID() { + return Cluster_ID; + } + + public void setCluster_ID(int cluster_ID) { + Cluster_ID = cluster_ID; + } + + public int getCommand() { + return Command; + } + + public void setCommand(int command) { + Command = command; + } + + public int getSendMode() { + return SendMode; + } + + public void setSendMode(int sendMode) { + SendMode = sendMode; + } + + public Data getData() { + return Data; + } + + public void setData(Data data) { + this.Data = data; + } + + public static class Data{ + private int Mode;//瑕佽皟鑺傜殑妯″紡 + private int Amount;//瑕佸彉鍖栫殑搴︽暟 + + public int getMode() { + return Mode; + } + + public void setMode(int mode) { + Mode = mode; + } + + public int getAmount() { + return Amount; + } + + public void setAmount(int amount) { + Amount = amount; + } + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeWriteCtrlBean.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeWriteCtrlBean.java new file mode 100644 index 0000000..03df09c --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/ZigbeeBean/mqttbeans/ZigbeeWriteCtrlBean.java @@ -0,0 +1,91 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.mqttbeans; + +/** + * 鎭掓俯鍣ㄦ垨鏂伴鎺у埗绫� + */ +public class ZigbeeWriteCtrlBean { + private String DeviceAddr; + private int Epoint; + private int Cluster_ID; + private int Command; + private Data data; + + public String getDeviceAddr() { + return DeviceAddr; + } + + public void setDeviceAddr(String deviceAddr) { + DeviceAddr = deviceAddr; + } + + public int getEpoint() { + return Epoint; + } + + public void setEpoint(int epoint) { + Epoint = epoint; + } + + public int getCluster_ID() { + return Cluster_ID; + } + + public void setCluster_ID(int cluster_ID) { + Cluster_ID = cluster_ID; + } + + public int getCommand() { + return Command; + } + + public void setCommand(int command) { + Command = command; + } + + public Data getData() { + return data; + } + + public void setData(Data data) { + this.data = data; + } + + public static class Data{ + private int Undivided; + private int AttributeId; + private int AttributeDataType; + private int AttributeData; + + public int getUndivided() { + return Undivided; + } + + public void setUndivided(int undivided) { + Undivided = undivided; + } + + public int getAttributeId() { + return AttributeId; + } + + public void setAttributeId(int attributeId) { + AttributeId = attributeId; + } + + public int getAttributeDataType() { + return AttributeDataType; + } + + public void setAttributeDataType(int attributeDataType) { + AttributeDataType = attributeDataType; + } + + public int getAttributeData() { + return AttributeData; + } + + public void setAttributeData(int attributeData) { + AttributeData = attributeData; + } + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Callback/PushCallback.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Callback/PushCallback.java new file mode 100644 index 0000000..0cdb4b2 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Callback/PushCallback.java @@ -0,0 +1,70 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Callback; + + +import android.util.Log; + +import java.util.Timer; +import java.util.TimerTask; + +import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; +import org.eclipse.paho.client.mqttv3.MqttCallbackExtended; +import org.eclipse.paho.client.mqttv3.MqttMessage; + +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommandText; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLZigbeeMqtt; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HandleSearch; +import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; + + +public class PushCallback implements MqttCallbackExtended { + private String host; + public void setHost(String host) { + this.host = host; + } + private static boolean isGateway = false; + public static void setIsGateway(boolean isGateway) { + PushCallback.isGateway = isGateway; + } + + @Override + public void connectComplete(boolean reconnect, String serverURI) { + if (reconnect){ + //褰撳彂鐢熸柇绾夸箣鍚庡張閲嶆柊杩炴帴鐨勬儏鍐碉紝reconnect浼氳繑鍥瀟rue锛屽垵娆¤繛鎺ユ垚鍔熻繑鍥炵殑鏄痜alse + } + } + @Override + public void connectionLost(Throwable cause) { + // 杩炴帴涓㈠け鍚庯紝涓�鑸湪杩欓噷闈㈣繘琛岄噸杩� + HDLCommandText.reportError("Connection is broken,Trying to reconnect"); + if (isGateway){//鎼滅储缃戝叧鏃跺�欐柇绾匡紝缃戝叧閲嶆柊鎼滅储 + HandleSearch.reSearch(); + isGateway = false; + }else {//鎼滅储璁惧鏂嚎锛岃澶囬噸鏂拌繛鎺� + new Timer().schedule(new TimerTask() { + @Override + public void run() { + // TODO Auto-generated method stub + HDLZigbeeMqtt.connect1(host); + Log.d("1111", "姝e湪閲嶈繛 "); + } + }, 2000); + } + } + + @Override + public void deliveryComplete(IMqttDeliveryToken token) { + HDLLog.info("deliveryComplete---------" + token.isComplete()); + } + + @Override + public void messageArrived(String topic, MqttMessage message) { + String messageJson = new String(message.getPayload()); + HDLLog.info("鎺ユ敹娑堟伅涓婚 : " + topic); + HDLLog.info("鎺ユ敹娑堟伅Qos : " + message.getQos()); + HDLLog.info("鎺ユ敹娑堟伅鍐呭 : " + messageJson); + HDLCommandText.handleDeviceInfoReportData(topic, messageJson); + } + + + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Callback/StateEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Callback/StateEvent.java new file mode 100644 index 0000000..80c4c6a --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Callback/StateEvent.java @@ -0,0 +1,15 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Callback; + +public class StateEvent { + + private String json; + + public StateEvent(String json) { + super(); + this.json = json; + } + + public String getJson() { + return json; + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Callback/StateListener.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Callback/StateListener.java new file mode 100644 index 0000000..136e99c --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Callback/StateListener.java @@ -0,0 +1,5 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Callback; + +public interface StateListener { + void onData(StateEvent event); +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/Crc.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/Crc.java new file mode 100644 index 0000000..22e07c5 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/Crc.java @@ -0,0 +1,163 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Core; + +import com.hdl.sdk.hdl_core.Config.Configuration; +import com.hdl.sdk.hdl_core.Util.NetUtil.NetWorkUtil; + +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; + public static int localSubnetID = 254; + public static int localDeviceID = 80; + public int desSubnetID = 0; + public int desDeviceID = 0; + public int port = 0; + public String ipAddress = ""; + public int count = 0;//鏉冨疁涔嬭锛屽悗缁垹鎺� + public boolean isCtrlSuccess;//鏉冨疁涔嬭锛屽悗缁垹鎺� + + public Crc(int command, int desSubnetID, int desDeviceID, byte[] addBytes, int port, String ipAddress) { + this.command = command; + this.desSubnetID = desSubnetID; + this.desDeviceID = desDeviceID; + this.addBytes = addBytes; + this.port = port; + this.ipAddress = ipAddress; + } + + public Crc(int command, int sourceSubID, int sourceDeviceID, int desSubnetID, int desDeviceID, byte[] addBytes, int port, String ipAddress) { + localSubnetID = sourceSubID; + localDeviceID = sourceDeviceID; + this.command = command; + this.desSubnetID = desSubnetID; + this.desDeviceID = desDeviceID; + this.addBytes = addBytes; + this.port = port; + this.ipAddress = ipAddress; + } + + 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; + } + + private static void ConCRC(byte[] bufin, int n) { + int crc16 = 0; + byte i; + for (i = 0; i < n; i++) { + crc16 = xcrc(crc16, bufin[i]); + } + bufin[i] = (byte) (crc16 >> 8); + bufin[i + 1] = (byte) (crc16 & 0xff); + } + + public byte[] GetSendBytes() { + + byte[] crcBytes = new byte[9 + this.addBytes.length + 2]; + + byte[] sendBytes = new byte[16 + crcBytes.length]; + +// byte[] localIp = new byte[]{127, 0, 0, 1}; +// try { +// localIp = InetAddress.getLocalHost().getAddress(); +// } catch (UnknownHostException e) { +// e.printStackTrace(); +// } +// sendBytes[0] = localIp[0]; +// sendBytes[1] = localIp[1]; +// sendBytes[2] = localIp[2]; +// sendBytes[3] = localIp[3]; + + byte[] ipAddress = new byte[]{127, 0, 0, 1}; + try { + byte[] localIp = NetWorkUtil.getLocalHostLANAddress().getAddress(); + if (localIp.length == 4) { + ipAddress = localIp; + } + + } catch (Exception e) { + e.printStackTrace(); + } + +// Log.i("djl","瑕佸彂閫佺殑ip鍦板潃锛�"+ipAddress); +// String[] ip = ipAddress.split("\\."); + + sendBytes[0] = ipAddress[0]; + sendBytes[1] = ipAddress[1]; + sendBytes[2] = ipAddress[2]; + sendBytes[3] = ipAddress[3]; + + // HDLMIRACLE +// sendBytes[4] = (byte) 0x48; + sendBytes[4] = 'H'; + sendBytes[5] = (byte) 0x44; + sendBytes[6] = (byte) 0x4c; + sendBytes[7] = (byte) 0x4d; + sendBytes[8] = (byte) 0x49; + sendBytes[9] = (byte) 0x52; + sendBytes[10] = (byte) 0x41; + sendBytes[11] = (byte) 0x43; + sendBytes[12] = (byte) 0x4c; + sendBytes[13] = (byte) 0x45; + + sendBytes[14] = (byte) 0xAA; + sendBytes[15] = (byte) 0xAA; + + crcBytes[0] = (byte) crcBytes.length; + crcBytes[1] = (byte) localSubnetID; + crcBytes[2] = (byte) localDeviceID; + crcBytes[3] = (byte) (Configuration.HDL_SDK_DEV_TYPE / 256); + crcBytes[4] = (byte) (Configuration.HDL_SDK_DEV_TYPE % 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, 16, crcBytes.length); + + return sendBytes; + } + + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java new file mode 100644 index 0000000..5420b7b --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java @@ -0,0 +1,1466 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Core; + +import android.content.Context; +import android.util.Log; + +import com.hdl.sdk.hdl_core.Config.Configuration; +import com.hdl.sdk.hdl_core.Config.ZigbeeDeviceID; +import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.AirCtrlBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLAudio.HDLAudio; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLCurtain.CurtainCtrlBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLCurtain.Parser.CurtainCtrlParser; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLFreshAir.FreshAirBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLFreshAir.Parser.FreshAirParser; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.GeothermalBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.Parser.GeothermalParser; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.LightCtrlBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLLogic.LogicCtrlBackInfo; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.DeviceStateBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeDeviceSaveBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeSceneSaveBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.gatewaybeans.StatusReadBackBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.gatewaybeans.StatusThermostatReadBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Callback.StateEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Callback.StateListener; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AirFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CurtainFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DeviceStateEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.EventCode; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.FreshAirFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.GeothermalFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LightFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.ZigbeeDeviceInfoEvent; +import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; +import com.hdl.sdk.hdl_core.Util.NetUtil.NetWorkUtil; +import com.hdl.sdk.hdl_core.Util.SPUtil.SPUtils; +import com.hdl.sdk.hdl_core.Util.TransformUtil.HDLUtlis; +import com.hdl.sdk.hdl_core.Util.TransformUtil.JsonUtil; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.ArrayList; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; + + +/** + * Created by djl on 2017/3/17. + */ + +public class HDLCommand { + + 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 freshAirCtrlFailTimer = null;//鎺у埗鏂伴澶辫触Timer 2019-07-09 + private static Timer geothermalCtrlFailTimer = null;//鎺у埗鍦扮儹澶辫触Timer 2019-07-10 + + private static List<ZigbeeDeviceSaveBean> zigbeeDeviceDatas;//zigbee鏄犲皠鏁版嵁鍥炶皟 + private static List<ZigbeeSceneSaveBean> zigbeeSceneDatas;//zigbeeScene鏄犲皠鏁版嵁鍥炶皟 + private static StatusReadBackBean statusReadBackBean;//鐘舵�佸洖璋� + private static StatusThermostatReadBean thermostatReadBean;//鎭掓俯鍣ㄧ姸鎬佸洖璋� + private static ZigbeeDeviceSaveBean zigbeeDeviceBean;//璁惧鏁版嵁 + private static ZigbeeSceneSaveBean zigbeeSceneBean;//璁惧鍦烘櫙鏁版嵁 + private static int type = 0; + + + /** + * 鍒濆鍖� + * + * @param context + */ + public static void init(Context context) { + HDLDeviceManager.init(context); + } + + + +// /** +// * 鑾峰彇鏈湴骞挎挱IP +// * @return +// */ +// public static String getLocalBroadCastIp(){ +// return NetWorkUtil.getLocalBroadCast(); +// } + + /** + * 鑾峰彇鏈湴骞挎挱IP + * @return + */ + public static String getLocalBroadCastIp(){ + return NetWorkUtil.getLocalBroadCast(); + } + + /** + * 鏄惁寮�鍚疭DK鏃ュ織鎵撳嵃 + * 2019-07-10鏂板 + * @param bOpen + */ + public static void setHDLLogOpen(boolean bOpen) { + HDLLog.setHDLLogOpen(bOpen); + } + + /** + * 閲婃斁璧勬簮 + */ + public static void release() { + HDLDeviceManager.release(); + } + + +// private static void devicesSearch() { +// HandleSearch.getRcuIp(); +// } + + + + /** + * 鑾峰彇RCU妯″潡鐨勮澶� + * + * @param context + * @param rcuIp + */ + public static void getRcuDevices(Context context, String rcuIp) { + if (rcuIp == null) { + return; + } + HandleSearch.getRcuDevices(context, rcuIp); + } + + + + /** + * 鑾峰彇瀹跺眳璁惧 + * + * @param context + */ + public static void getHomeDevices(Context context ,Boolean isZigbee) { + HandleSearch.getHomeDevices(context,isZigbee); + } + +// 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; +// } +// } + + + /** + * 鎺у埗鐏厜 + * + * @param info + * @param state + */ + public static void lightCtrl(final AppliancesInfo info, int state,boolean isZigbee) { + if (isZigbee){ + if (statusReadBackBean != null){ + if (info.getBigType() == Configuration.LIGTH_BIG_TYPE && info.getLittleType() == 1){//缁х數鍣� 寮�鍏� + if (statusReadBackBean.getValue() == Configuration.RELAY_ON){ + HDLCommandText.sendStatus(zigbeeDeviceBean, ZigbeeDeviceID.OnOffOutput,Configuration.RELAY_OFF); + }else { + HDLCommandText.sendStatus(zigbeeDeviceBean,ZigbeeDeviceID.OnOffOutput,Configuration.RELAY_ON); + } + } + if (info.getBigType() == Configuration.LIGTH_BIG_TYPE && info.getLittleType() == 0){//璋冨厜鍣� 寮�鍒板浐瀹氱殑鍊兼垨鑰呭紑鍒�0 + int value = (int) (state * 2.55); + if (statusReadBackBean.getValue()!=0){ + //lightStatus = 0; + HDLCommandText.sendStatus(zigbeeDeviceBean,ZigbeeDeviceID.DimmableLight,0); + }else { + //lightStatus = value; + HDLCommandText.sendStatus(zigbeeDeviceBean,ZigbeeDeviceID.DimmableLight,value); + } + } + }else { + HDLLog.info("涓鸿幏鍙栧埌璁惧鐘舵��"); + } + + }else { + // 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 + ) { + Log.d("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 = info.getDeviceType(); +// byte[] bytes = new byte[]{(byte) info.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)); + } + } + }, 5000); + } + } + + + /** + * 鎺у埗绐楀笜 + * + * @param info + * @param state 璋冩暣鐨勫�� + */ + public static void curtainCtrl(final AppliancesInfo info, int state,boolean isZigbee) { + if (isZigbee){ + switch (state){ + case CurtainCtrlParser.curtainOn: + HDLCommandText.sendCurtainStatus(zigbeeDeviceBean,ZigbeeDeviceID.WindowCoveringDevice,0,0);//value = 0涓哄紑锛宼ag = 0涓烘爣璁版帶鍒� + break; + case CurtainCtrlParser.curtainOff: + HDLCommandText.sendCurtainStatus(zigbeeDeviceBean,ZigbeeDeviceID.WindowCoveringDevice,1,0);//value = 1涓哄叧锛宼ag = 0涓烘爣璁版帶鍒� + break; + case CurtainCtrlParser.curtainPause: + HDLCommandText.sendCurtainStatus(zigbeeDeviceBean,ZigbeeDeviceID.WindowCoveringDevice,2,0);//value = 2涓烘殏鍋滐紝tag = 0涓烘爣璁版帶鍒� + break; + default: + HDLCommandText.sendCurtainStatus(zigbeeDeviceBean,ZigbeeDeviceID.WindowCoveringDevice,state,1);//value = state涓鸿皟鏁存暟鍊硷紝tag = 1涓烘爣璁版暟鍊兼帶鍒� + break; + } + }else { + 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)); + } + } + }, 5000); + + + } else { + Log.d("djlCtrl", "涓嶆槸绐楀笜璁惧" + + " \nstate = " + state + + " \nLittleType = " + info.getLittleType() + + " \nBigType = " + info.getBigType() + ); + } + } + } + + + /** + * 鎺у埗绌鸿皟 + * + * @param info + * @param type + * @param state + */ + public static void airCtrl(final AppliancesInfo info, int type, int state , boolean isZigbee) { + if (isZigbee){ + switch (type){ + case AirCtrlParser.airSwich: + //寮�鍏抽�夋嫨 + switch (state){ + case AirCtrlParser.airOn://绌鸿皟寮� + HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,1,0,0);//value = 1涓虹┖璋冨紑 tag = 0涓烘爣蹇椾负寮�鍏虫帶鍒� mode蹇界暐 + break; + case AirCtrlParser.airOff://绌鸿皟鍏� + HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,0,0,0);//value = 0涓虹┖璋冨紑 tag = 0涓烘爣蹇椾负寮�鍏虫帶鍒� mode蹇界暐 + break; + } + break; + case AirCtrlParser.airMode: + //鎭掓俯鍣ㄦā寮忛�夋嫨 + switch (state){ + case AirCtrlParser.airModeHeatTem://绌鸿皟妯″紡鍒剁儹 + HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,4,1,0);//value = 4涓烘亽娓╁櫒鍒剁儹 tag = 1涓烘爣蹇椾负鎭掓俯鍣ㄦ帶鍒� mode蹇界暐 + break; + case AirCtrlParser.airModeVen://绌鸿皟妯″紡閫氶 + HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,7,1,0);//value = 7涓烘亽娓╁櫒閫氶 tag = 1涓烘爣蹇椾负鎭掓俯鍣ㄦ帶鍒� mode蹇界暐 + break; + case AirCtrlParser.airModeAuto://绌鸿皟妯″紡鑷姩 + HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,1,1,0);//value = 1涓烘亽娓╁櫒鑷姩 tag = 1涓烘爣蹇椾负鎭掓俯鍣ㄦ帶鍒� mode蹇界暐 + break; + case AirCtrlParser.airModeDehum://绌鸿皟妯″紡鎶芥箍 + HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,8,1,0);//value = 8涓烘亽娓╁櫒鎶芥箍 tag = 1涓烘爣蹇椾负鎭掓俯鍣ㄦ帶鍒� mode蹇界暐 + break; + case AirCtrlParser.airModeRefTem://绌鸿皟妯″紡鍒跺喎 + HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,3,1,0);//value = 3涓烘亽娓╁櫒鍒跺喎 tag = 1涓烘爣蹇椾负鎭掓俯鍣ㄦ帶鍒� mode蹇界暐 + break; + } + break; + case AirCtrlParser.airSpeed: + //椋庨�熸ā寮忛�夋嫨 + switch (state){ + case AirCtrlParser.airSpeedHigh://椋庨�熼珮椋� + HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,3,2,0);//value = 3涓洪閫熼珮椋� tag = 2涓烘爣蹇椾负椋庨�熸帶鍒� mode蹇界暐 + break; + case AirCtrlParser.airSpeedMid://椋庨�熶腑椋� + HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,2,2,0);//value = 2涓洪閫熶腑椋� tag = 2涓烘爣蹇椾负椋庨�熸帶鍒� mode蹇界暐 + break; + case AirCtrlParser.airSpeedLow://椋庨�熶綆椋� + HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,1,2,0);//value = 1涓洪閫熶綆椋� tag = 2涓烘爣蹇椾负椋庨�熸帶鍒� mode蹇界暐 + break; + case AirCtrlParser.airSpeedAuto://椋庨�熻嚜鍔� + HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,5,2,0);//value = 5涓洪閫熻嚜鍔� tag = 2涓烘爣蹇椾负椋庨�熸帶鍒� mode蹇界暐 + break; + } + break; + case AirCtrlParser.dehumTem://褰撳墠绌鸿皟妯″紡涓烘娊婀� + case AirCtrlParser.refTem: //褰撳墠绌鸿皟妯″紡涓哄埗鍐� + HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,state,3,1);//value = state涓烘俯搴﹀�� tag = 3涓烘爣蹇椾负娓╁害鎺у埗 mode = 1涓哄埗鍐� + break; + case AirCtrlParser.heatTem://褰撳墠绌鸿皟妯″紡涓哄埗鐑� + HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,state,3,0);//value = state涓烘俯搴﹀�� tag = 3涓烘爣蹇椾负娓╁害鎺у埗 mode = 0涓哄埗鐑� + break; + case AirCtrlParser.autoTem://褰撳墠绌鸿皟妯″紡涓鸿嚜鍔� + HDLCommandText.sendAirStatus(zigbeeDeviceBean,ZigbeeDeviceID.Thermostat,state,3,2);//value = state涓烘俯搴﹀�� tag = 3涓烘爣蹇椾负娓╁害鎺у埗 mode = 2涓鸿嚜鍔� + break; + } + }else { + // 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 { + if (AirCtrlParser.getAcAddByte(info, type, state) != null) { + byte[] airbytes = AirCtrlParser.getAcAddByte(info, type, state); +// String airString = "鍙戦�佺殑HVAC bytes:"; +// for(int i = 0;i<airbytes.length;i++){ +// airString += (airbytes[i] & 0xff) +","; +// } +// HDLLog.info(airString); + 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)); + } + } + }, 5000); + + + } else { + HDLLog.info("绌鸿皟璁惧鎺у埗涓嶅湪鑼冨洿鍐�" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + } + } + + + /** + * 鎺у埗鏂伴绯荤粺 + * + * @param info + * @param type + * @param state 2019-07-09 + */ + public static void freshAirCtrl(final AppliancesInfo info, int type, int state,boolean isZigbee) { + if (isZigbee){ + switch (type){ + case FreshAirParser.freshAirSwich: + switch (state){ + case FreshAirParser.freshAirOn: + HDLCommandText.sendStatus(zigbeeDeviceBean,ZigbeeDeviceID.AirPanel,1);//value = 1涓烘柊椋庡紑 + break; + case FreshAirParser.freshAirOff: + HDLCommandText.sendStatus(zigbeeDeviceBean,ZigbeeDeviceID.AirPanel,0);//value = 0涓烘柊椋庡叧 + break; + } + break; + case FreshAirParser.freshAirSpeed://楂橀銆佷綆椋� + switch (state){ + case FreshAirParser.freshAirSpeedMid://鎺у埗鎴愰珮椋� + HDLCommandText.sendStatus(zigbeeDeviceBean,ZigbeeDeviceID.AirPanel,3);//value = 3涓烘柊椋庨珮椋� + break; + case FreshAirParser.freshAirSpeedLow://鎺у埗鎴愪綆閫� + case FreshAirParser.freshAirSpeedOff: + HDLCommandText.sendStatus(zigbeeDeviceBean,ZigbeeDeviceID.AirPanel,1);//value = 1涓烘柊椋庝綆椋� + break; + } + break; + } + }else { + // HDLDeviceManager.isFreshAirCtrlSuccess = false; + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); + if (freshAirCtrlFailTimer != null) { + freshAirCtrlFailTimer.cancel(); + freshAirCtrlFailTimer = null; + } + if (info.getBigType() == Configuration.FRESH_AIR_BIG_TYPE) { + byte[] freshAirbytes = FreshAirParser.getFreshAirAddByte(info, type, state); + addSendData(info, freshAirbytes, Configuration.CONTROL); + freshAirCtrlFailTimer = new Timer(); + freshAirCtrlFailTimer.schedule(new TimerTask() { + @Override + public void run() { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { + FreshAirBackInfo mFreshAirBackInfo = new FreshAirBackInfo(); + mFreshAirBackInfo.setAppliancesInfo(info); + EventBus.getDefault().post(new FreshAirFeedBackEvent(mFreshAirBackInfo, false)); + } + } + }, 5000); + + + } else { + HDLLog.info("鏂伴璁惧鎺у埗涓嶅湪鑼冨洿鍐�" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + } + } + + /** + * 鎺у埗閫昏緫妯″潡 + * + * @param info + */ + public static void logicCtrl(final AppliancesInfo info,final boolean isZigbee) { + if (isZigbee){ + HDLCommandText.sendSceneStatus(zigbeeSceneBean.getScenesId(),0);//鎺у埗鍦烘櫙鐨刬d锛屽欢鏃舵椂闂翠负0 + }else { + // 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) { +// HDLUdpCore.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.info("閫昏緫鎺у埗澶辫触"); + LogicCtrlBackInfo logicCtrlBackInfo = new LogicCtrlBackInfo(); + logicCtrlBackInfo.setAppliancesInfo(info); + EventBus.getDefault().post(new LogicFeedBackEvent(logicCtrlBackInfo, false)); + } + } + }, 5000); + } else { + Log.d("djlCtrl", "閫昏緫妯″潡璁惧鎺у埗涓嶅湪鑼冨洿鍐�" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + + } + } + + + /** + * 鎺у埗鍦扮儹妯″潡娓╁害 + * + * @param info + * @param tempInt 2020-03-15 + */ + public static void geothermalCtrlTemp(final AppliancesInfo info, int tempInt) { +// HDLDeviceManager.isGeothermalCtrlSuccess = false; + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); + if (geothermalCtrlFailTimer != null) { + geothermalCtrlFailTimer.cancel(); + geothermalCtrlFailTimer = null; + } + if (info.getBigType() == Configuration.GEOTHERMAL_BIG_TYPE) { + byte[] sendbytes = GeothermalParser.getGeothermalAddByteTemp(info, tempInt); + addSendData(info, sendbytes, Configuration.CONTROL); + + geothermalCtrlFailTimer = new Timer(); + geothermalCtrlFailTimer.schedule(new TimerTask() { + @Override + public void run() { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { + GeothermalBackInfo mGeothermalBackInfo = new GeothermalBackInfo(); + mGeothermalBackInfo.setAppliancesInfo(info); + EventBus.getDefault().post(new GeothermalFeedBackEvent(mGeothermalBackInfo, EventCode.FAILURE)); + } + } + }, 5000); + + + } else { + HDLLog.info("鍦扮儹妯″潡鎺у埗涓嶅湪鑼冨洿鍐�" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + } + + /** + * 鎺у埗鍦扮儹妯″潡 + * + * @param info + * @param type + * @param state 2019-07-10 + */ + public static void geothermalCtrl(final AppliancesInfo info, int type, int state) { +// HDLDeviceManager.isGeothermalCtrlSuccess = false; + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); + if (geothermalCtrlFailTimer != null) { + geothermalCtrlFailTimer.cancel(); + geothermalCtrlFailTimer = null; + } + if (info.getBigType() == Configuration.GEOTHERMAL_BIG_TYPE) { + byte[] sendbytes = GeothermalParser.getGeothermalAddByte(info, type, state); + addSendData(info, sendbytes, Configuration.CONTROL); + + geothermalCtrlFailTimer = new Timer(); + geothermalCtrlFailTimer.schedule(new TimerTask() { + @Override + public void run() { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { + GeothermalBackInfo mGeothermalBackInfo = new GeothermalBackInfo(); + mGeothermalBackInfo.setAppliancesInfo(info); + EventBus.getDefault().post(new GeothermalFeedBackEvent(mGeothermalBackInfo, EventCode.FAILURE)); + } + } + }, 5000); + + + } else { + HDLLog.info("鍦扮儹妯″潡鎺у埗涓嶅湪鑼冨洿鍐�" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + } + + // 鑾峰彇鍗曚竴鍥炶矾璁惧鐘舵�� + // 璇诲彇璁惧鐘舵�� +// public static void getDeviceState(final AppliancesInfo info) { +// HDLDeviceManager.isGetDeviceStateSuccess = false; +// switch (info.getBigType()) { +// case Configuration.LIGTH_BIG_TYPE: +// addSendData(info, new byte[]{}, Configuration.STATE); +// break; +// case Configuration.CURTAIN_BIG_TYPE: +// if (info.getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) { +// addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); +// } else { +// addSendData(info, new byte[]{(byte) (info.getChannelNum() + 16)}, Configuration.STATE); +// } +// break; +// case Configuration.AIR_BIG_TYPE: +// addSendData(info, new byte[]{AirCtrlParser.airSwich}, Configuration.STATE); +//// addSendData(info,new byte[]{AirCtrlParser.refTem},Configuration.STATE); +// addSendData(info, new byte[]{AirCtrlParser.airSpeed}, Configuration.STATE); +// addSendData(info, new byte[]{AirCtrlParser.airMode}, Configuration.STATE); +//// addSendData(info,new byte[]{AirCtrlParser.heatTem},Configuration.STATE); +//// addSendData(info,new byte[]{AirCtrlParser.autoTem},Configuration.STATE); +// break; +// } +// +// if (info.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(info, false)); +// } +// } +// }, 5000); +// +// } + /** + * 鑾峰彇鍗曚竴璁惧鐘舵�� + */ + public static void getDeviceState(Context context,final AppliancesInfo appliancesInfo,boolean isZigbee) { + if (isZigbee){ + zigbeeDeviceDatas = SPUtils.getZigbeeDeviceSaveBean(context,SPUtils.KEY_ZIGBEE_IP); + zigbeeSceneDatas = SPUtils.getZigbeeSceneSaveBean(context,SPUtils.KEY_ZIGBEE_SCENE_IP); + HDLCommandText hdlCommandText = new HDLCommandText(); + for (ZigbeeDeviceSaveBean zigbeeDeviceSaveBean : zigbeeDeviceDatas){ + if (appliancesInfo.getBigType() == Configuration.LIGTH_BIG_TYPE && appliancesInfo.getLittleType() == 1){ + //缁х數鍣� + type = ZigbeeDeviceID.OnOffOutput; + if (zigbeeDeviceSaveBean.getmSubnetID() == appliancesInfo.getDeviceSubnetID() && + zigbeeDeviceSaveBean.getEpoint() == appliancesInfo.getChannelNum() && + zigbeeDeviceSaveBean.getDeviceMark() == appliancesInfo.getDeviceDeviceID())//鍒ゆ柇bus鏁版嵁瀵瑰簲鐨剒igbee鏁版嵁 + { + HDLLog.info("缁х數鍣ㄥ尮閰嶆垚鍔�"); + zigbeeDeviceBean = zigbeeDeviceSaveBean; + hdlCommandText.setIpAddr(zigbeeDeviceSaveBean.getIpAddress()); + HDLCommandText.initStatus(zigbeeDeviceSaveBean, ZigbeeDeviceID.OnOffOutput); + } + } + + if (appliancesInfo.getBigType() == Configuration.LIGTH_BIG_TYPE && appliancesInfo.getLittleType() == 0){ + //璋冨厜鍣� + type = ZigbeeDeviceID.DimmableLight; + if (zigbeeDeviceSaveBean.getmSubnetID() == appliancesInfo.getDeviceSubnetID() && + zigbeeDeviceSaveBean.getEpoint() == appliancesInfo.getChannelNum() && + zigbeeDeviceSaveBean.getDeviceMark() == appliancesInfo.getDeviceDeviceID())//鍒ゆ柇bus鏁版嵁瀵瑰簲鐨剒igbee鏁版嵁 + { + HDLLog.info("璋冨厜鍣ㄥ尮閰嶆垚鍔�"); + zigbeeDeviceBean = zigbeeDeviceSaveBean; + hdlCommandText.setIpAddr(zigbeeDeviceSaveBean.getIpAddress()); + HDLCommandText.initStatus(zigbeeDeviceSaveBean, ZigbeeDeviceID.DimmableLight); + } + } + if (appliancesInfo.getBigType() == Configuration.CURTAIN_BIG_TYPE && appliancesInfo.getLittleType() == 0){ + //绐楀笜 + type = ZigbeeDeviceID.WindowCoveringDevice; + if (zigbeeDeviceSaveBean.getmSubnetID() == appliancesInfo.getDeviceSubnetID() && + zigbeeDeviceSaveBean.getEpoint() == appliancesInfo.getChannelNum() && + zigbeeDeviceSaveBean.getDeviceMark() == appliancesInfo.getDeviceDeviceID())//鍒ゆ柇bus鏁版嵁瀵瑰簲鐨剒igbee鏁版嵁 + { + HDLLog.info("绐楀笜鍖归厤鎴愬姛"); + zigbeeDeviceBean = zigbeeDeviceSaveBean; + hdlCommandText.setIpAddr(zigbeeDeviceSaveBean.getIpAddress()); + HDLCommandText.initStatus(zigbeeDeviceSaveBean, ZigbeeDeviceID.WindowCoveringDevice); + } + } + if (appliancesInfo.getBigType() ==Configuration.AIR_BIG_TYPE && appliancesInfo.getLittleType() == 0){ + //绌鸿皟 + type = ZigbeeDeviceID.Thermostat; + if (zigbeeDeviceSaveBean.getmSubnetID() == appliancesInfo.getDeviceSubnetID() && + zigbeeDeviceSaveBean.getEpoint() == appliancesInfo.getChannelNum() && + zigbeeDeviceSaveBean.getDeviceMark() == appliancesInfo.getDeviceDeviceID())//鍒ゆ柇bus鏁版嵁瀵瑰簲鐨剒igbee鏁版嵁 + { + HDLLog.info("绌鸿皟鍖归厤鎴愬姛"); + zigbeeDeviceBean = zigbeeDeviceSaveBean; + hdlCommandText.setIpAddr(zigbeeDeviceSaveBean.getIpAddress()); + HDLCommandText.initStatus(zigbeeDeviceSaveBean, ZigbeeDeviceID.Thermostat); + } + } + if (appliancesInfo.getBigType() ==Configuration.FRESH_AIR_BIG_TYPE && appliancesInfo.getLittleType() == 0){ + //鏂伴 + type = ZigbeeDeviceID.AirPanel; + if (zigbeeDeviceSaveBean.getmSubnetID() == appliancesInfo.getDeviceSubnetID() && + zigbeeDeviceSaveBean.getEpoint() == appliancesInfo.getChannelNum() && + zigbeeDeviceSaveBean.getDeviceMark() == appliancesInfo.getDeviceDeviceID())//鍒ゆ柇bus鏁版嵁瀵瑰簲鐨剒igbee鏁版嵁 + { + HDLLog.info("鏂伴鍖归厤鎴愬姛"); + zigbeeDeviceBean = zigbeeDeviceSaveBean; + hdlCommandText.setIpAddr(zigbeeDeviceSaveBean.getIpAddress()); + HDLCommandText.initStatus(zigbeeDeviceSaveBean, ZigbeeDeviceID.AirPanel); + } + } + } + for (ZigbeeSceneSaveBean zigbeeSceneSaveBean : zigbeeSceneDatas){ + if (appliancesInfo.getBigType() == Configuration.GLOBAL_LOGIC_BIG_TYPE && appliancesInfo.getLittleType() == 0){ + //鍦烘櫙 + type = ZigbeeDeviceID.SceneMark; + if (zigbeeSceneSaveBean.getSubnetId() == appliancesInfo.getDeviceSubnetID() && + zigbeeSceneSaveBean.getDeviceid() == appliancesInfo.getDeviceDeviceID())//鍒ゆ柇bus鏁版嵁瀵瑰簲鐨剒igbee鏁版嵁 + { + HDLLog.info("鍦烘櫙鍖归厤鎴愬姛"); + zigbeeSceneBean = zigbeeSceneSaveBean; + hdlCommandText.setIpAddr(zigbeeSceneSaveBean.getIpAddr()); + } + } + } + Log.d("11113", "type: "+type); + //璇诲啓鐘舵�佷俊鎭洖璋� + HDLCommandText.setStateListener(new StateListener() { + @Override + public void onData(final StateEvent event) { + //涓婃姤zigbee鍥為淇℃伅 + Log.d("11113", "zigbee 鍥為json:" + event.getJson()); + switch (type){ + case ZigbeeDeviceID.OnOffOutput: + //缁х數鍣ㄨ澶囧洖璋� + statusReadBackBean = JsonUtil.parseJsonWithGson(event.getJson(), StatusReadBackBean.class); + if (statusReadBackBean.getValue() == Configuration.RELAY_ON){ + //缁х數鍣ㄥ叧 + appliancesInfo.setCurState(0); + EventBus.getDefault().post(new DeviceStateEvent(appliancesInfo, true)); + }else { + //缁х數鍣ㄥ紑 + appliancesInfo.setCurState(100); + EventBus.getDefault().post(new DeviceStateEvent(appliancesInfo, true)); + } + break; + case ZigbeeDeviceID.WindowCoveringDevice: + //绐楀笜璁惧鍥炶皟 + statusReadBackBean = JsonUtil.parseJsonWithGson(event.getJson(), StatusReadBackBean.class); + appliancesInfo.setCurState(statusReadBackBean.getValue()); + EventBus.getDefault().post(new DeviceStateEvent(appliancesInfo,true)); + break; + case ZigbeeDeviceID.DimmableLight: + //璋冨厜鍣ㄨ澶� + statusReadBackBean = JsonUtil.parseJsonWithGson(event.getJson(), StatusReadBackBean.class); + Log.d("2222", "鍥炶皟鏁版嵁: "+statusReadBackBean.getValue()); + appliancesInfo.setCurState(statusReadBackBean.getValue()); + EventBus.getDefault().post(new DeviceStateEvent(appliancesInfo,true)); + break; + case ZigbeeDeviceID.Thermostat: + //娓╁害璁惧 + thermostatReadBean = JsonUtil.parseJsonWithGson(event.getJson(),StatusThermostatReadBean.class); + int fanMode = thermostatReadBean.getFanmode(); //鏂伴妯″紡 0锛歄ff銆�1锛歀ow銆�2锛歁edium銆�3锛欻igh銆�4锛歄n銆�5锛欰uto銆�6锛歋mart + int thermostatMode = thermostatReadBean.getThermostatmode();//鎭掓俯妯″紡 0锛歄ff銆�1锛欰uto銆�3锛欳ool銆�4锛欻eat銆�5锛欵mergency heating銆�6锛歅recooling銆�7锛欶an only銆�8锛欴ry銆�9锛歋leep锛� + int coolingSetpoint = thermostatReadBean.getCoolingSetpoint();//鍒跺喎娓╁害 + int heatingSetpoint = thermostatReadBean.getHeatingSetpoint();//鍒剁儹娓╁害 + int tag = thermostatReadBean.getTag(); + switch (tag){ + case 0://寮�鍏虫ā寮忚繑鍥� + if (fanMode == 0 && thermostatMode == 0){ + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSwich,AirCtrlParser.airOff)); //绌鸿皟鍏� + }else { + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSwich,AirCtrlParser.airOn));//绌鸿皟寮� + } + break; + case 1://鎭掓俯鍣ㄦā寮忚繑鍥� + if (fanMode ==0 && thermostatMode == 0){ + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSwich,AirCtrlParser.airOff));//绌鸿皟鍏� + }else { + switch (thermostatMode){ + case 1://鑷姩妯″紡 + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airMode,AirCtrlParser.airModeAuto)); + break; + case 3://鍒跺喎妯″紡 + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airMode,AirCtrlParser.airModeRefTem)); + break; + case 4://鍒剁儹妯″紡 + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airMode,AirCtrlParser.airModeHeatTem)); + break; + case 7://閫氶妯″紡 + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airMode,AirCtrlParser.airModeVen)); + break; + case 8://鎶芥箍妯″紡 + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airMode,AirCtrlParser.airModeDehum)); + break; + } + } + + break; + case 2://閫氶鍣ㄦā寮忚繑鍥� + if (fanMode == 0 && thermostatMode == 0){ + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSwich,AirCtrlParser.airOff)); //绌鸿皟鍏� + }else { + switch (fanMode){ + case 1://浣庨 + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSpeed,AirCtrlParser.airSpeedLow)); + break; + case 2://涓 + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSpeed,AirCtrlParser.airSpeedMid)); + break; + case 3://楂橀 + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSpeed,AirCtrlParser.airSpeedHigh)); + break; + case 5://鑷姩 + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSpeed,AirCtrlParser.airSpeedAuto)); + break; + } + } + break; + case 3://璁剧疆娓╁害妯″紡杩斿洖 + if (fanMode == 0 && thermostatMode == 0){ + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.airSwich,AirCtrlParser.airOff)); //绌鸿皟鍏� + }else { + switch (thermostatMode){ + case 1://TODO 鑷姩妯″紡娓╁害杩斿洖闇�瑕佸崗璁笂鐨� + if (coolingSetpoint !=0 && heatingSetpoint ==0 ){ + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.autoTem,coolingSetpoint)); + }else { + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.autoTem,heatingSetpoint)); + } + break; + case 3://鍒跺喎妯″紡 + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.refTem,coolingSetpoint)); + break; + case 4://鍒剁儹妯″紡 + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.heatTem,heatingSetpoint)); + break; + case 8://鎶芥箍妯″紡 + appliancesInfo.setArrCurState(AirCtrlParser.getAirPanelAddByte(AirCtrlParser.dehumTem,coolingSetpoint)); + break; + } + } + break; + } + EventBus.getDefault().post(new DeviceStateEvent(appliancesInfo,true)); + break; + case ZigbeeDeviceID.AirPanel: + //鏂伴璁惧鍥炶皟 + statusReadBackBean = JsonUtil.parseJsonWithGson(event.getJson(), StatusReadBackBean.class); + FreshAirBackInfo freshAirBackInfo = new FreshAirBackInfo(); + freshAirBackInfo.setAppliancesInfo(appliancesInfo); + switch (statusReadBackBean.getValue()){ + case 0://椋庢墖鍏� + freshAirBackInfo.setIsOn(0); + freshAirBackInfo.setFreshAirSpeed(0); + break; + case 1://浣庨 + freshAirBackInfo.setIsOn(1); + freshAirBackInfo.setFreshAirSpeed(1); + break; + case 3://楂橀 + freshAirBackInfo.setIsOn(1); + freshAirBackInfo.setFreshAirSpeed(3); + break; + case 255: + break; + } + EventBus.getDefault().post(new FreshAirFeedBackEvent(freshAirBackInfo,true)); + break; + case ZigbeeDeviceID.SceneMark: + //鍦烘櫙鍥炶皟 + statusReadBackBean = JsonUtil.parseJsonWithGson(event.getJson(),StatusReadBackBean.class); + if (statusReadBackBean.getValue() == 1){ + LogicCtrlBackInfo logicCtrlBackInfo = new LogicCtrlBackInfo(); + logicCtrlBackInfo.setAppliancesInfo(appliancesInfo); + EventBus.getDefault().post(new LogicFeedBackEvent(logicCtrlBackInfo, true)); + } + break; + } + } + }); + }else { + if (appliancesInfo == null) { + return; + } + HDLDeviceManager.isGetDeviceStateSuccess = false; + 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: + AppliancesInfo lightInfo = appliancesInfo; + int lightState = getLightState(appliancesInfo); + lightInfo.setCurState(lightState); + EventBus.getDefault().post(new DeviceStateEvent(lightInfo, true)); + break; + + case HDLApConfig.TYPE_CURTAIN_GLYSTRO: + case HDLApConfig.TYPE_CURTAIN_ROLLER: + case HDLApConfig.TYPE_CURTAIN_MODULE: + AppliancesInfo curtainInfo = appliancesInfo; + int curtainState = getCurtainState(appliancesInfo); + curtainInfo.setCurState(curtainState); + EventBus.getDefault().post(new DeviceStateEvent(curtainInfo, true)); + break; + + case HDLApConfig.TYPE_AC_HVAC: + case HDLApConfig.TYPE_AC_COOLMASTER: + case HDLApConfig.TYPE_AC_INFRARED: + case HDLApConfig.TYPE_AC_PANEL: + if (getACState(appliancesInfo).length >= 4) { + AppliancesInfo acInfo = appliancesInfo; + byte[] acState = getACState(appliancesInfo); + + acInfo.setArrCurState(new byte[]{AirCtrlParser.airSwich, acState[0]}); + EventBus.getDefault().post(new DeviceStateEvent(acInfo, true)); + + acInfo.setArrCurState(new byte[]{AirCtrlParser.airMode, acState[1]}); + EventBus.getDefault().post(new DeviceStateEvent(acInfo, true)); + + switch (acState[1] & 0xff) { + case AirCtrlParser.airModeRefTem: + acInfo.setArrCurState(new byte[]{AirCtrlParser.refTem, acState[2]}); + EventBus.getDefault().post(new DeviceStateEvent(acInfo, true)); + break; + case AirCtrlParser.airModeHeatTem: + acInfo.setArrCurState(new byte[]{AirCtrlParser.heatTem, acState[2]}); + EventBus.getDefault().post(new DeviceStateEvent(acInfo, true)); + break; + case AirCtrlParser.airModeAuto: + acInfo.setArrCurState(new byte[]{AirCtrlParser.autoTem, acState[2]}); + EventBus.getDefault().post(new DeviceStateEvent(acInfo, true)); + break; + case AirCtrlParser.airModeDehum: + acInfo.setArrCurState(new byte[]{AirCtrlParser.autoTem, acState[2]}); + EventBus.getDefault().post(new DeviceStateEvent(acInfo, true)); + break; + default: + break; + } + + if ((acState[1] & 0xff) != AirCtrlParser.airModeDehum) { + acInfo.setArrCurState(new byte[]{AirCtrlParser.airSpeed, acState[3]}); + EventBus.getDefault().post(new DeviceStateEvent(acInfo, true)); + } + } + break; + + 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: + //鍙戦�佽幏鍙栦紶鎰熷櫒鎵�鏈夋暟鎹� + addSendData(appliancesInfo, new byte[]{(byte) appliancesInfo.getBigType(), (byte) appliancesInfo.getLittleType(), (byte) appliancesInfo.getChannelNum()}, Configuration.STATE); + break; + case HDLApConfig.TYPE_GEOTHERMAL_MODULE: //20190710 鏂板 + //鍙戦�佽幏鍙栧湴鐑ā鍧楁墍鏈夋暟鎹� + addSendData(appliancesInfo, new byte[]{(byte) appliancesInfo.getChannelNum()}, Configuration.STATE); + break; + case HDLApConfig.TYPE_FRESH_AIR: //20190710 鏂板 + //鍙戦�佽幏鍙栨柊椋庣郴缁熸墍鏈夋暟鎹� + addSendData(appliancesInfo, new byte[]{(byte) appliancesInfo.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); + } + + } + } + //鏇存柊鎵�鏈夎澶囩姸鎬� +// HandleSearch.refreshAllDevicesState(30); + 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 = (int) infos.get(j).getCurState();//鏃� + //20190712瑙e喅寮哄埗杞崲int绫诲瀷闂�� + curState = HDLUtlis.getIntegerByObject(infos.get(j).getCurStateObject()); + 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() + ) { + //杩欓噷搴旇鏄淇鐨勶紝鏆傛椂鏈壘鍒般�� + //20190712瑙e喅寮哄埗杞崲int绫诲瀷闂�� + int state = HDLUtlis.getIntegerByObject(infos.get(j).getCurStateObject()); + switch (state) { + case -1: + curState = 0; + break; + case -2: + curState = 1; + break; + case -3: + curState = 2; + break; + default: +// curState = (int) infos.get(j).getCurState(); + curState = state; + break; + + } + + break outter; + } + + } + } + } + return curState; + } + + /** + * 鑾峰彇绌鸿皟鐘舵�� + * + * @param info + * @return + */ + private static byte[] getACState(final AppliancesInfo info) { + byte[] curState = new byte[]{}; + 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 + * @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 = StringUtil.asciiToString(sendData); +// HDLLog.info("鍙戝嚭鏁版嵁锛�"+sendData+"瀛愮綉id:"+info.getDeviceSubnetID()+" 璁惧id锛�"+info.getDeviceDeviceID()); + cusSendCommand(command, + info.getDeviceSubnetID(), info.getDeviceDeviceID(), musicBytes, + info.getPort(), getLocalBroadCastIp()); + } + + } + + /** + * 鑳屾櫙闊充箰鎺у埗 + * + * @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 = StringUtil.asciiToString(sendData); +// HDLLog.info("鍙戝嚭鏁版嵁锛�"+sendData+"瀛愮綉id:"+info.getDeviceSubnetID()+" 璁惧id锛�"+info.getDeviceDeviceID()); + cusSendCommand(command, + info.getDeviceSubnetID(), info.getDeviceDeviceID(), musicBytes, + info.getPort(), getLocalBroadCastIp()); + } + } + + /** + * @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 = StringUtil.asciiToString(sendData); +// HDLLog.info("鍙戝嚭鏁版嵁锛�"+sendData+"瀛愮綉id:"+info.getDeviceSubnetID()+" 璁惧id锛�"+info.getDeviceDeviceID()); + cusSendCommand(command, + info.getDeviceSubnetID(), info.getDeviceDeviceID(), musicBytes, + info.getPort(), getLocalBroadCastIp()); + } + + } + + + /** + * 鎻愪緵绗笁鏂硅皟鐢ㄨ缃湰鍦板瓙缃戝彿銆佽澶囧彿 + * + * @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); + } + + /** + * 鍗曡澶囧彂閫佸懡浠� + * + * @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, info.getPort(), getLocalBroadCastIp()); + sendDatas.count = 0; + + + final Timer sendCycleTimer = new Timer(); + sendCycleTimer.schedule(new TimerTask() { + @Override + public void run() { + if (sendDatas.count >= 4) { + sendCycleTimer.cancel(); + } else { +// HDLLog.info("鎺у埗鍙戦�佺"+sendDatas.count+ "娆�"); + sendDatas.count++; + if (type == Configuration.STATE) { + sendDatas.command = info.getStateCommand(); + sendDatas.isCtrlSuccess = HDLDeviceManager.isGetDeviceStateSuccess; + } else if (type == Configuration.CONTROL) { + sendDatas.command = info.getCtrlCommand(); + HDLLog.info("getDeviceKey锛� " + info.getDeviceKey()); + 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.GEOTHERMAL_BIG_TYPE://20190710鏂板 +// sendDatas.isCtrlSuccess = HDLDeviceManager.isGeothermalCtrlSuccess; +// break; +// case Configuration.FRESH_AIR_BIG_TYPE://20190710鏂板 +// sendDatas.isCtrlSuccess = HDLDeviceManager.isFreshAirCtrlSuccess; +// break; +// +// default: +// sendDatas.isCtrlSuccess = false; +// } + } + if (!sendDatas.isCtrlSuccess) { + cusSendCommand(sendDatas.command, info.getDeviceSubnetID(), info.getDeviceDeviceID(), sendDatas.addBytes, info.getPort(), getLocalBroadCastIp()); + } else { +// HDLLog.info("鎺у埗宸叉垚鍔燂紝鍋滄"); + sendCycleTimer.cancel(); + } + } + } + }, 1, 500); //2019-07-23 鍙戜竴娆¤ˉ鍙�3娆★紝闂撮殧500ms + + + } + + + /** + * 鍙戦�佸箍鎾垨鐐瑰鐐瑰懡浠� + * + * @param command 鎿嶄綔鐮� + * @param subnetID 瀛愮綉鍙� + * @param deviceID 璁惧鍙� + * @param addBytes 闄勫姞鏁版嵁 + * @param port 绔彛鍙� + * @param ipAddress ip鍦板潃 + */ + public static void cusSendCommand(int command, int subnetID, int deviceID, byte[] addBytes, int port, String ipAddress) { + Crc sendDatas = new Crc(command, subnetID, deviceID, addBytes, port, ipAddress); + HDLUdpCore.sendData(sendDatas); + } + + + /** + * 鍙戦�佺粍鎾懡浠� + * 杩欎釜鏂规硶鐩墠浠呯敤鍦ㄦ嬁鍒癛cu ip鍦板潃 + * + * @param command 鎿嶄綔鐮� + * @param subnetID 瀛愮綉鍙� + * @param deviceID 璁惧鍙� + * @param addBytes 闄勫姞鏁版嵁 + * @param port 绔彛鍙� + */ + public static void cusSendMulticastCommand(int command, int subnetID, int deviceID, byte[] addBytes, int port) { + + Crc sendDatas = new Crc(command, subnetID, deviceID, addBytes, port, Configuration.RCU_MULTI_IP); + HDLUdpCore.sendMulticastData(sendDatas); + } + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommandText.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommandText.java new file mode 100644 index 0000000..ab4e1fb --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommandText.java @@ -0,0 +1,742 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Core; + +import android.util.Log; +import com.google.gson.Gson; +import com.hdl.sdk.hdl_core.Config.ZigbeeDeviceID; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.CommonErrorBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeDeviceListBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeDeviceSaveBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeSceneListBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.gatewaybeans.GatewayCommondBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.gatewaybeans.GatewayCurtainBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.gatewaybeans.StatusReadBackBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.gatewaybeans.StatusThermostatReadBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.mqttbeans.ZigbeeCtrlBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.mqttbeans.ZigbeeDimmableCtrlBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.mqttbeans.ZigbeeReadBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.mqttbeans.ZigbeeReportBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.mqttbeans.ZigbeeSceneCtrlBackBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.mqttbeans.ZigbeeSceneCtrlBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.mqttbeans.ZigbeeThermostatCtrlBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.mqttbeans.ZigbeeWriteCtrlBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Callback.StateEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Callback.StateListener; +import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; +import com.hdl.sdk.hdl_core.Util.TransformUtil.JsonUtil; + + +import java.util.ArrayList; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; + + +public class HDLCommandText { + private static List<ZigbeeDeviceListBean> zigbeeDeviceListBeans;//璁惧鍒楄〃 + private static ZigbeeSceneListBean zigbeeSceneListBean;//鍦烘櫙鍒楄〃 + private static StatusThermostatReadBean thermostatReadBackBean = new StatusThermostatReadBean();//鎭掓俯鍣ㄧ姸鎬佽繑鍥� + private static StateListener stateListener;//璁惧鐘舵�佸洖璋� + private static boolean isFinished = false;//鏍囪鍥炶皟鍜屽満鏅澶囨暟鎹� + public static Timer timer = null;//璁剧疆璁惧鍜屽満鏅洖璋� + private static String ipAddr;//璁惧畾鎺у埗鏃剁殑ip鍦板潃 + private static boolean is1 = false,is2 = false;//鏍囪鑾峰彇鐨勬俯搴﹀拰椋庢墖寮哄害 + private static int airTag = 0;//鏍囪浼犺繘鏉ユ帶鍒剁┖璋冪殑鏄粈涔堟柟寮忥紙寮�鍏炽�佹ā寮忋�侀閫熴�佽瀹氭俯搴︼級 + private static int airMode = 1;//鏍囨敞鏇存敼娓╁害鏃讹紝鎺у埗鐨勬ā寮� + private static int scenesId = 0;//鍙戝満鏅椂浼犲叆锛屾柟渚挎敹鍦烘櫙 + + + public static void setStateListener(StateListener newStateListener) { + stateListener = newStateListener; + } + + public void setIpAddr(String ipAddr) { + this.ipAddr = ipAddr; + } + + public static void initData(){ + zigbeeDeviceListBeans = new ArrayList<>();//鎼滅储鎴栨帶鍒舵椂鍊欓渶鍒濆鍖� + } + + public interface DataCallBack{ + void onSuccess( List<ZigbeeDeviceListBean> zigbeeDeviceListBeans,ZigbeeSceneListBean zigbeeSceneListBeans); + } + + //澶勭悊鎺ユ敹鐨勬暟鎹� + public static void handleDeviceInfoReportData(String topic, String message) { + // 杩囨护鏄惁鏈夌綉鍏砳d涓巘opic + String[] arrTopic = topic.split("/"); + String gatewayId = arrTopic[0]; + String topicString = arrTopic[1]; + //鎵�鏈変俊鎭幏鍙栧畬澶勭悊 + //閫夋嫨缃戝叧鐨勮瘽瑕佸湪鍒ゆ柇涓姞) + + if (topic.contains("Scene/GetInfo_Respon")){ + //澶勭悊鎼滅储鍒扮殑鍦烘櫙 + handleSceneList(message); + } + + if (topic.contains("DeviceInfoRespon")){ + //澶勭悊鑾峰彇鍒扮殑璁惧 + handleDeviceList(message); + } + + if (topic.contains("Scene/Open_Respon")){ + //杩斿洖鍦烘櫙琚墽琛� + reportSceneStatus(message); + return; + } + + if (topic.contains("DeviceInfoResponEnd")&& + zigbeeDeviceListBeans.get(0).getData().getGwId().equals(gatewayId)){ + Log.d("11113", "绋嬪簭鎺ュ彈瀹岃繘鏉ュ鐞�: "); + isFinished = true; + } + + if (!(topicString.equalsIgnoreCase("DeviceStatusReport"))) { + HDLLog.info("涓嶅鐞嗙殑topic:" + topicString); + return; + } + + ZigbeeReportBean zigbeeReportBean =JsonUtil.parseJsonWithGson(message, ZigbeeReportBean.class); + int cluterId = zigbeeReportBean.getData().getCluterID(); + if (!(cluterId == 6 || cluterId==8 || cluterId == 258 || cluterId == 513 || cluterId == 514)) { + HDLLog.info("涓嶅鐞嗙殑cluterId:" + cluterId); + return; + } + int deviceID = zigbeeReportBean.getDevice_ID(); + switch (deviceID){ + case ZigbeeDeviceID.OnOffOutput: + //鐏厜璁惧 + StatusReadBackBean lightReadBackBean = new StatusReadBackBean(); + for (ZigbeeReportBean.DataBean.AttriButeBean attriButeBean : zigbeeReportBean.getData() + .getAttriBute()) { + if (attriButeBean.getAttriButeId() == 0) { + lightReadBackBean.setValue(attriButeBean.getAttriButeData()); + } + } + String lightReadBackJson = JsonUtil.toJson(lightReadBackBean); + if (stateListener != null) { + StateEvent event = new StateEvent(lightReadBackJson); + stateListener.onData(event); + } + break; + case ZigbeeDeviceID.WindowCoveringDevice: + //绐楀笜璁惧 + StatusReadBackBean curtainReadBackBean = new StatusReadBackBean(); + for (ZigbeeReportBean.DataBean.AttriButeBean attriButeBean : zigbeeReportBean.getData() + .getAttriBute()){ + if (attriButeBean.getAttriButeId() == 8){ + curtainReadBackBean.setValue(attriButeBean.getAttriButeData()); + } + } + String curtainReadBackJson = JsonUtil.toJson(curtainReadBackBean); + if (stateListener != null) { + StateEvent event = new StateEvent(curtainReadBackJson); + stateListener.onData(event); + } + break; + case ZigbeeDeviceID.DimmableLight: + //璋冨厜鍣ㄨ澶� + StatusReadBackBean dimmableLightReadBackBean = new StatusReadBackBean(); + for (ZigbeeReportBean.DataBean.AttriButeBean attriButeBean : zigbeeReportBean.getData() + .getAttriBute()) { + if (attriButeBean.getAttriButeId() == 0 && cluterId==8 ) { + Log.d("2222", "璋冨厜鍣ㄦ暟鎹�: "+attriButeBean.getAttriButeData()); + dimmableLightReadBackBean.setValue((int) (attriButeBean.getAttriButeData()/2.55)); + } + } + String dimmableLightReadBackJson = JsonUtil.toJson(dimmableLightReadBackBean); + if (stateListener != null) { + StateEvent event = new StateEvent(dimmableLightReadBackJson); + stateListener.onData(event); + } + break; + case ZigbeeDeviceID.Thermostat: + //绌鸿皟璁惧 + for (ZigbeeReportBean.DataBean.AttriButeBean attriButeBean:zigbeeReportBean.getData().getAttriBute()){ + + if (attriButeBean.getAttriButeId() == 28 && attriButeBean.getAttriButeDataType() == 48){ + //褰撳墠鐨勭┖璋冩ā寮� + int thermostatmode = attriButeBean.getAttriButeData(); + thermostatReadBackBean.setThermostatmode(thermostatmode); + is1 = true; + } + + if (attriButeBean.getAttriButeId() == 0 && attriButeBean.getAttriButeDataType() == 0x30){ + //褰撳墠鐨勬柊椋庢ā寮� + int fanmode = attriButeBean.getAttriButeData(); + thermostatReadBackBean.setFanmode(fanmode); + is2 = true; + } + if (attriButeBean.getAttriButeId() == 17 && attriButeBean.getAttriButeDataType() == 41){ + //鍒跺喎娓╁害 + int coolingSetpoint = attriButeBean.getAttriButeData()/100; + thermostatReadBackBean.setCoolingSetpoint(coolingSetpoint); + //Log.d("11113", "鍒跺喎娓╁害涓�: "+coolingSetpoint); + + } + if (attriButeBean.getAttriButeId() == 18 && attriButeBean.getAttriButeDataType() == 41){ + //鍒剁儹娓╁害 + int heatingSetpoint = attriButeBean.getAttriButeData()/100; + thermostatReadBackBean.setHeatingSetpoint(heatingSetpoint); + //Log.d("11113", "鍒剁儹娓╁害涓�: "+heatingSetpoint); + + } + } + if (is1 && is2 ){ //浠h〃鑾峰彇鎭掓俯鍣ㄥ拰椋庢墖鐨勭姸鎬佸悗鐨勫洖璋� + is1 = false;is2 = false; + thermostatReadBackBean.setTag(airTag); + String thermostatReadJson = JsonUtil.toJson(thermostatReadBackBean); + //Log.d("11113", "鏁版嵁鏁版嵁鏁版嵁"+thermostatReadJson); + if (stateListener != null ){ + StateEvent event = new StateEvent(thermostatReadJson); + stateListener.onData(event); + } + } + break; + case ZigbeeDeviceID.AirPanel: + //鏂伴璁惧 + StatusReadBackBean airPanelReadBackBean = new StatusReadBackBean(); + for (ZigbeeReportBean.DataBean.AttriButeBean attriButeBean : zigbeeReportBean.getData().getAttriBute()){ + if (attriButeBean.getAttriButeId() == 0 && attriButeBean.getAttriButeDataType() == 0x30){ + //褰撳墠鐨勬柊椋庢ā寮� + int fanmode = attriButeBean.getAttriButeData(); + airPanelReadBackBean.setValue(fanmode); + } + } + String airPanelReadBackJson = JsonUtil.toJson(airPanelReadBackBean); + if (stateListener != null) { + StateEvent event = new StateEvent(airPanelReadBackJson); + stateListener.onData(event); + } + break; + } + } + + public static void sendThirdPartyJson(final ZigbeeDeviceSaveBean zigbeeJson, String statusJson, int type){ + HDLZigbeeMqtt.connect1(ipAddr); + // 鍒ゆ柇鏄痺rite 杩樻槸 read锛屾帶鍒舵椂鍒ゆ柇浼犻�掑弬鏁� + switch (type){ + case ZigbeeDeviceID.OnOffOutput: + //缁х數鍣� + GatewayCommondBean gatewayCommondBean = JsonUtil.parseJsonWithGson(statusJson, GatewayCommondBean.class); + if (gatewayCommondBean.getCmd() == null) { + reportError("cmd parameter error, please check it out"); + return; + } + switch (gatewayCommondBean.getCmd()){ + case "write": + // 鐏厜鎺у埗锛�0鍏� 1寮� + if (!(gatewayCommondBean.getValue()==1||gatewayCommondBean.getValue()==0)){ + reportError("Wrong lighting control parameters"); + return; + } + ZigbeeCtrlBean light = new ZigbeeCtrlBean(); + light.setCluster_ID(6); + light.setSendMode(2); + light.setDeviceAddr(zigbeeJson.getDeviceAddr()); + light.setEpoint(zigbeeJson.getEpoint()); + light.setCommand(gatewayCommondBean.getValue()); + final String ctrlLightjson = JsonUtil.toJson(light); + new Thread(new Runnable() { + @Override + public void run() { + HDLZigbeeMqtt.sendMqttData1( "DeviceControl", ctrlLightjson); + } + }).start(); + break; + case "read": + ZigbeeReadBean lightReadBean = new ZigbeeReadBean(); + lightReadBean.setDeviceAddr(zigbeeJson.getDeviceAddr()); + lightReadBean.setEpoint(zigbeeJson.getEpoint()); + lightReadBean.setCluster_ID(6); + lightReadBean.setCommand(108); + lightReadBean.setSendMode(2); + + ZigbeeReadBean.DataBean lightBean = new ZigbeeReadBean.DataBean(); + List<ZigbeeReadBean.DataBean.AttriButeBean> lightAttriButeBeanList = new ArrayList<>(); + ZigbeeReadBean.DataBean.AttriButeBean lightAttriButeBean = new ZigbeeReadBean.DataBean.AttriButeBean(); + lightAttriButeBean.setAttriButeId(0); + lightAttriButeBeanList.add(lightAttriButeBean); + lightBean.setAttriBute(lightAttriButeBeanList); + lightReadBean.setData(lightBean); + String lightReadJson = JsonUtil.toJson(lightReadBean); + HDLZigbeeMqtt.sendMqttData1("GetDeviceStatus", lightReadJson); + break; + } + break; + case ZigbeeDeviceID.WindowCoveringDevice: + GatewayCurtainBean gatewayCurtainBean = JsonUtil.parseJsonWithGson(statusJson, GatewayCurtainBean.class); + if (gatewayCurtainBean.getCmd() == null) { + reportError("cmd parameter error, please check it out"); + return; + } + //绐楀笜鎺у埗 + switch (gatewayCurtainBean.getCmd()){ + case "write": + ZigbeeCtrlBean curtainCtrl = new ZigbeeCtrlBean(); + curtainCtrl.setCluster_ID(258); + int curtainCmd; + switch (gatewayCurtainBean.getTag()){ + case 0: + switch (gatewayCurtainBean.getValue()){ + case 0: + curtainCmd = 0; + break; + case 1: + curtainCmd = 1; + break; + case 2: + curtainCmd = 2; + break; + default: + curtainCmd = 1; + break; + } + break; + case 1: + curtainCmd = 5; + ZigbeeCtrlBean.DataBean dataBean = new ZigbeeCtrlBean.DataBean(); + dataBean.setValue(gatewayCurtainBean.getValue()); + curtainCtrl.setData(dataBean); + break; + default: + curtainCmd = 0; + break; + } + + curtainCtrl.setCommand(curtainCmd); + curtainCtrl.setSendMode(2); + curtainCtrl.setDeviceAddr(zigbeeJson.getDeviceAddr()); + curtainCtrl.setEpoint(zigbeeJson.getEpoint()); + String curtainCtrlJson = JsonUtil.toJson(curtainCtrl); + HDLZigbeeMqtt.sendMqttData1("DeviceControl", curtainCtrlJson); + break; + case "read": + ZigbeeReadBean curtainReadBean = new ZigbeeReadBean(); + curtainReadBean.setDeviceAddr(zigbeeJson.getDeviceAddr()); + curtainReadBean.setEpoint(zigbeeJson.getEpoint()); + curtainReadBean.setCluster_ID(258); + curtainReadBean.setCommand(108); + curtainReadBean.setSendMode(2); + + ZigbeeReadBean.DataBean curtainBean = new ZigbeeReadBean.DataBean(); + List<ZigbeeReadBean.DataBean.AttriButeBean> curtainAttriButeBeanList = new ArrayList<>(); + ZigbeeReadBean.DataBean.AttriButeBean curtainAttriButeBean = new ZigbeeReadBean.DataBean.AttriButeBean(); + curtainAttriButeBean.setAttriButeId(8); + curtainAttriButeBeanList.add(curtainAttriButeBean); + curtainBean.setAttriBute(curtainAttriButeBeanList); + curtainReadBean.setData(curtainBean); + String curtainReadJson = JsonUtil.toJson(curtainReadBean); + HDLZigbeeMqtt.sendMqttData1("GetDeviceStatus",curtainReadJson); + break; + } + break; + case ZigbeeDeviceID.DimmableLight: + //璋冨厜鐏� + GatewayCommondBean dimmableLightBean = JsonUtil.parseJsonWithGson(statusJson, GatewayCommondBean.class); + if (dimmableLightBean.getCmd() == null) { + reportError("cmd parameter error, please check it out"); + return; + } + switch (dimmableLightBean.getCmd()){ + case "write": + // 璋冨厜鎺у埗 + ZigbeeDimmableCtrlBean light = new ZigbeeDimmableCtrlBean(); + ZigbeeDimmableCtrlBean.Data data = new ZigbeeDimmableCtrlBean.Data(); + light.setCluster_ID(8); + light.setSendMode(2); + light.setCommand(4); + light.setDeviceAddr(zigbeeJson.getDeviceAddr()); + light.setEpoint(zigbeeJson.getEpoint()); + data.setLevel(dimmableLightBean.getValue()); + data.setTransitionTime(2); + light.setData(data); + String ctrlLightjson = JsonUtil.toJson(light); + HDLZigbeeMqtt.sendMqttData1( "DeviceControl", ctrlLightjson); + break; + case "read": + ZigbeeReadBean lightReadBean = new ZigbeeReadBean(); + lightReadBean.setDeviceAddr(zigbeeJson.getDeviceAddr()); + lightReadBean.setEpoint(zigbeeJson.getEpoint()); + lightReadBean.setCluster_ID(8); + lightReadBean.setCommand(108); + lightReadBean.setSendMode(2); + + ZigbeeReadBean.DataBean lightBean = new ZigbeeReadBean.DataBean(); + List<ZigbeeReadBean.DataBean.AttriButeBean> lightAttriButeBeanList = new ArrayList<>(); + ZigbeeReadBean.DataBean.AttriButeBean lightAttriButeBean = new ZigbeeReadBean.DataBean.AttriButeBean(); + lightAttriButeBean.setAttriButeId(0); + lightAttriButeBeanList.add(lightAttriButeBean); + lightBean.setAttriBute(lightAttriButeBeanList); + lightReadBean.setData(lightBean); + String lightReadJson = JsonUtil.toJson(lightReadBean); + HDLZigbeeMqtt.sendMqttData1("GetDeviceStatus", lightReadJson); + break; + } + break; + case ZigbeeDeviceID.Thermostat: + //绌鸿皟 + final GatewayCommondBean thermostatBean = JsonUtil.parseJsonWithGson(statusJson, GatewayCommondBean.class); + if (thermostatBean.getCmd() == null) { + reportError("cmd parameter error, please check it out"); + return; + } + switch (thermostatBean.getCmd()){ + case "write": + switch (airTag){ + case 0://寮�鍏�,寮�鍏充紶鍏ュ紑鍏�01 + switch (thermostatBean.getValue()){ + case 0://绌鸿皟鍏� + new Thread(new Runnable() { + @Override + public void run() { + sendFan(zigbeeJson,0);//鍙戦�侀鎵囨帶鍒� + sendThermostat(zigbeeJson,0);//鍙戦�佹亽娓╁櫒 + } + }).start(); + break; + case 1://绌鸿皟寮� + new Thread(new Runnable() { + @Override + public void run() { + sendThermostat(zigbeeJson,1); + sendFan(zigbeeJson,4); + } + }).start(); + + break; + } + break; + case 1://鎺у埗鎭掓俯鍣� + new Thread(new Runnable() { + @Override + public void run() { + sendThermostat(zigbeeJson,thermostatBean.getValue()); + } + }).start(); + break; + case 2://鎺у埗閫氶鍣� + new Thread(new Runnable() { + @Override + public void run() { + sendFan(zigbeeJson,thermostatBean.getValue()); + } + }).start(); + break; + case 3://鎺у埗娓╁害 + switch (airMode){ + case 0://鍒剁儹 + new Thread(new Runnable() { + @Override + public void run() { + contrlThermostat(zigbeeJson,thermostatBean.getValue(),0); + } + }).start(); + break; + case 1://鍒跺喎 + new Thread(new Runnable() { + @Override + public void run() { + contrlThermostat(zigbeeJson,thermostatBean.getValue(),1); + } + }).start(); + break; + case 2://鑷姩 + new Thread(new Runnable() { + @Override + public void run() { + contrlThermostat(zigbeeJson,thermostatBean.getValue(),2); + } + }).start(); + break; + } + break; + } + break; + case "read": + //鑾峰彇褰撳墠鎭掓俯鍣ㄤ俊鎭� + ZigbeeReadBean thermostatReadBean = new ZigbeeReadBean(); + ZigbeeReadBean.DataBean thermostat = new ZigbeeReadBean.DataBean(); + List<ZigbeeReadBean.DataBean.AttriButeBean> thermostats = new ArrayList<>(); + ZigbeeReadBean.DataBean.AttriButeBean thermostatAttr = new ZigbeeReadBean.DataBean.AttriButeBean(); + ZigbeeReadBean.DataBean.AttriButeBean thermostatAttr1 = new ZigbeeReadBean.DataBean.AttriButeBean(); + ZigbeeReadBean.DataBean.AttriButeBean thermostatAttr2 = new ZigbeeReadBean.DataBean.AttriButeBean(); + thermostatReadBean.setDeviceAddr(zigbeeJson.getDeviceAddr()); + thermostatReadBean.setEpoint(zigbeeJson.getEpoint()); + thermostatReadBean.setCluster_ID(513); + thermostatReadBean.setCommand(108); + thermostatReadBean.setSendMode(2); + thermostatAttr.setAttriButeId(28); + thermostats.add(thermostatAttr); + thermostatAttr1.setAttriButeId(17); + thermostats.add(thermostatAttr1); + thermostatAttr2.setAttriButeId(18); + thermostats.add(thermostatAttr2); + thermostat.setAttriBute(thermostats); + thermostatReadBean.setData(thermostat); + final String thermostatReadJson = JsonUtil.toJson(thermostatReadBean); + new Thread(new Runnable() { + @Override + public void run() { + HDLZigbeeMqtt.sendMqttData1("GetDeviceStatus", thermostatReadJson); + readFan(zigbeeJson); + } + }).start(); + //鑾峰彇椋庨�熺姸鎬� + break; + } + break; + case ZigbeeDeviceID.AirPanel: + GatewayCommondBean airpanelBean = JsonUtil.parseJsonWithGson(statusJson, GatewayCommondBean.class); + if (airpanelBean.getCmd() == null) { + reportError("cmd parameter error, please check it out"); + return; + } + switch (airpanelBean.getCmd()){ + case "write": + sendNewFan(zigbeeJson,airpanelBean.getValue()); + break; + case "read": + readFan(zigbeeJson); + break; + } + break; + + } + } + + //鍒濆鍖栫姸鎬佷俊鎭� + public static void initStatus(final ZigbeeDeviceSaveBean zigbeeDevice, final int type){ + initData(); + airTag = 0; + new Thread(new Runnable() { + @Override + public void run() { + String sendStatus = HDLCommandText.setSendStatus("read",0);//璇讳笉闇�瑕佺煡閬撶姸鎬侊紝闅忎究濉竴涓� + HDLCommandText.sendThirdPartyJson(zigbeeDevice,sendStatus, type); + } + }).start(); + } + + //鏇存柊绌鸿皟鐘舵�� + public static void initAirStatus(final ZigbeeDeviceSaveBean zigbeeDevice,final int type ,int tag){ + airTag = tag; + String sendStatus = HDLCommandText.setSendStatus("read",0);//璇讳笉闇�瑕佺煡閬撶姸鎬侊紝闅忎究濉竴涓� + HDLCommandText.sendThirdPartyJson(zigbeeDevice,sendStatus, type); + } + + + //鍙戦�佺┖璋冩帶鍒� + public static void sendAirStatus(final ZigbeeDeviceSaveBean zigbeeDevice,final int type ,final int value, + int tag,int mode){ + airTag = tag; airMode = mode; + String sendStatus = HDLCommandText.setSendStatus("write",value); + HDLCommandText.sendThirdPartyJson(zigbeeDevice,sendStatus,type); + } + + //鍙戦�佸紑鍏虫帶鍒舵帶鍒� + public static void sendStatus(final ZigbeeDeviceSaveBean zigbeeDevice,final int type,final int value){ + String sendStatus = HDLCommandText.setSendStatus("write",value); + HDLCommandText.sendThirdPartyJson(zigbeeDevice,sendStatus,type); + } + + //鍒濆鍖栫獥甯樻帶鍒� + public static void sendCurtainStatus(final ZigbeeDeviceSaveBean zigbeeDevice,final int type, + final int value,final int tag){ + String sendStatus = HDLCommandText.setSendCurtainStatus("write",value,tag); + HDLCommandText.sendThirdPartyJson(zigbeeDevice,sendStatus,type); + } + + //璁剧疆缁х數鍣ㄧ殑鐘舵�� + private static String setSendStatus(String status,int value){ + GatewayCommondBean gatewayCommondBean = new GatewayCommondBean(); + gatewayCommondBean.setCmd(status); + gatewayCommondBean.setValue(value); + String jsonObjext = JsonUtil.toJson(gatewayCommondBean); + return jsonObjext; + } + + //璁剧疆绐楀笜鐨勭姸鎬� + private static String setSendCurtainStatus(String status,int value,int tag){ + GatewayCurtainBean gatewayCurtainBean = new GatewayCurtainBean(); + gatewayCurtainBean.setCmd(status); + gatewayCurtainBean.setValue(value); + gatewayCurtainBean.setTag(tag); + String jsonObject = JsonUtil.toJson(gatewayCurtainBean); + return jsonObject; + } + + //鍙戦�佹亽娓╁櫒妯″紡 + private static void sendThermostat(ZigbeeDeviceSaveBean zigbeeJson,int value){ + ZigbeeWriteCtrlBean zigbeeOffBean = new ZigbeeWriteCtrlBean(); + zigbeeOffBean.setDeviceAddr(zigbeeJson.getDeviceAddr()); + zigbeeOffBean.setEpoint(zigbeeJson.getEpoint()); + zigbeeOffBean.setCluster_ID(513); + zigbeeOffBean.setCommand(120); + ZigbeeWriteCtrlBean.Data zigbeeOffDataBean = new ZigbeeWriteCtrlBean.Data(); + zigbeeOffDataBean.setAttributeId(28); + zigbeeOffDataBean.setAttributeDataType(48); + zigbeeOffDataBean.setAttributeData(value); + zigbeeOffBean.setData(zigbeeOffDataBean); + String zigbeeoffJson = JsonUtil.toJson(zigbeeOffBean); + HDLZigbeeMqtt.sendMqttData1("SetWritableValue",zigbeeoffJson); + initAirStatus(zigbeeJson,ZigbeeDeviceID.Thermostat,airTag); + } + + //鍙戦�侀妯″紡 + private static void sendFan(final ZigbeeDeviceSaveBean zigbeeJson, int value){ + ZigbeeWriteCtrlBean zigbeeOffBean = new ZigbeeWriteCtrlBean(); + zigbeeOffBean.setDeviceAddr(zigbeeJson.getDeviceAddr()); + zigbeeOffBean.setEpoint(zigbeeJson.getEpoint()); + zigbeeOffBean.setCluster_ID(514); + zigbeeOffBean.setCommand(120); + ZigbeeWriteCtrlBean.Data zigbeeOffDataBean = new ZigbeeWriteCtrlBean.Data(); + zigbeeOffDataBean.setAttributeId(0); + zigbeeOffDataBean.setAttributeDataType(0x30); + zigbeeOffDataBean.setAttributeData(value); + zigbeeOffBean.setData(zigbeeOffDataBean); + String zigbeeoffJson = JsonUtil.toJson(zigbeeOffBean); + HDLZigbeeMqtt.sendMqttData1("SetWritableValue",zigbeeoffJson); + initAirStatus(zigbeeJson,ZigbeeDeviceID.Thermostat,airTag); + } + + //鏂伴鐘舵�佷笅鍙戦�佹柊椋庢ā寮� + private static void sendNewFan(final ZigbeeDeviceSaveBean zigbeeJson, int value){ + ZigbeeWriteCtrlBean zigbeeOffBean = new ZigbeeWriteCtrlBean(); + zigbeeOffBean.setDeviceAddr(zigbeeJson.getDeviceAddr()); + zigbeeOffBean.setEpoint(zigbeeJson.getEpoint()); + zigbeeOffBean.setCluster_ID(514); + zigbeeOffBean.setCommand(120); + ZigbeeWriteCtrlBean.Data zigbeeOffDataBean = new ZigbeeWriteCtrlBean.Data(); + zigbeeOffDataBean.setAttributeId(0); + zigbeeOffDataBean.setAttributeDataType(0x30); + zigbeeOffDataBean.setAttributeData(value); + zigbeeOffBean.setData(zigbeeOffDataBean); + String zigbeeoffJson = JsonUtil.toJson(zigbeeOffBean); + HDLZigbeeMqtt.sendMqttData1("SetWritableValue",zigbeeoffJson); + initStatus(zigbeeJson,ZigbeeDeviceID.AirPanel); + } + + //娓╁害鎺у埗 + private static void contrlThermostat(ZigbeeDeviceSaveBean zigbeeJson,int value, int mode){ + ZigbeeThermostatCtrlBean zigbeeThermostatCtrlBean = new ZigbeeThermostatCtrlBean(); + zigbeeThermostatCtrlBean.setDeviceAddr(zigbeeJson.getDeviceAddr()); + zigbeeThermostatCtrlBean.setEpoint(zigbeeJson.getEpoint()); + zigbeeThermostatCtrlBean.setCluster_ID(513); + zigbeeThermostatCtrlBean.setCommand(0); + zigbeeThermostatCtrlBean.setSendMode(2); + ZigbeeThermostatCtrlBean.Data zigbeeData = new ZigbeeThermostatCtrlBean.Data(); + zigbeeData.setMode(mode);//妯″紡0锛氬姞鐑��1锛氬埗鍐枫��2锛氳嚜鍔╄皟鑺� + zigbeeData.setAmount(value); + zigbeeThermostatCtrlBean.setData(zigbeeData); + String zigbeeCtrlJson = JsonUtil.toJson(zigbeeThermostatCtrlBean); + HDLZigbeeMqtt.sendMqttData1("DeviceControl",zigbeeCtrlJson); + initAirStatus(zigbeeJson,ZigbeeDeviceID.Thermostat,airTag); + } + + //鏌ョ湅椋庨�� + private static void readFan(ZigbeeDeviceSaveBean zigbeeJson){ + + //鑾峰彇褰撳墠閫氶淇℃伅 + ZigbeeReadBean fanBean = new ZigbeeReadBean(); + ZigbeeReadBean.DataBean fanDataBean = new ZigbeeReadBean.DataBean(); + List<ZigbeeReadBean.DataBean.AttriButeBean> fanDataBeanList = new ArrayList<>(); + ZigbeeReadBean.DataBean.AttriButeBean fanDataBeanAttr = new ZigbeeReadBean.DataBean.AttriButeBean(); + fanBean.setDeviceAddr(zigbeeJson.getDeviceAddr()); + fanBean.setEpoint(zigbeeJson.getEpoint()); + fanBean.setCluster_ID(514); + fanBean.setCommand(108); + fanBean.setSendMode(2); + fanDataBeanAttr.setAttriButeId(0); + fanDataBeanList.add(fanDataBeanAttr); + fanDataBean.setAttriBute(fanDataBeanList); + fanBean.setData(fanDataBean); + String fanReadJson = JsonUtil.toJson(fanBean); + HDLZigbeeMqtt.sendMqttData1("GetDeviceStatus", fanReadJson); + } + + //鍙戦�佸満鏅暟鎹� + public static void sendSceneStatus(int ScenesId,int DelayTime){ + scenesId = ScenesId; + ZigbeeSceneCtrlBean zigbeeSceneCtrlBean = new ZigbeeSceneCtrlBean(); + zigbeeSceneCtrlBean.setCluster_ID(0); + zigbeeSceneCtrlBean.setCommand(808); + ZigbeeSceneCtrlBean.DataBean dataBean = new ZigbeeSceneCtrlBean.DataBean(); + dataBean.setScenesId(ScenesId); + dataBean.setDelayTime(DelayTime); + zigbeeSceneCtrlBean.setData(dataBean); + String json = JsonUtil.toJson(zigbeeSceneCtrlBean); + HDLZigbeeMqtt.sendMqttData1("Scene/Open",json); + } + + //澶勭悊璁惧淇℃伅 + private static void handleDeviceList(String message) { + ZigbeeDeviceListBean zigbeeDeviceListBean = JsonUtil.parseJsonWithGson(message,ZigbeeDeviceListBean.class); + zigbeeDeviceListBeans.add(zigbeeDeviceListBean); + } + + //澶勭悊鍦烘櫙淇℃伅 + private static void handleSceneList(String message) { + Gson gson = new Gson(); + zigbeeSceneListBean = gson.fromJson(message,ZigbeeSceneListBean.class); + } + + //澶勭悊鍦烘櫙鐨勬暟鎹� + private static void reportSceneStatus(String message) { + ZigbeeSceneCtrlBackBean sceneCtrlBackBean = JsonUtil.parseJsonWithGson(message, ZigbeeSceneCtrlBackBean.class); + if (sceneCtrlBackBean.getData() == null) { + reportError("scene status error"); + return; + } + StatusReadBackBean statusReadBackBean = new StatusReadBackBean(); + if (sceneCtrlBackBean.getData().getScenesId() == scenesId){ + statusReadBackBean.setValue(sceneCtrlBackBean.getData().getResult()); + } + String Json = JsonUtil.toJson(statusReadBackBean); + Log.d("11114", "澶勭悊鏁版嵁鍥炶皟: "+Json); + if (stateListener != null) { + StateEvent event = new StateEvent(Json); + stateListener.onData(event); + } + } + + //鍥炶皟鑾峰彇鍒扮殑璁惧淇℃伅 + public static void handleDeviceData(final DataCallBack dataCallBack){ + timer = new Timer(); + timer.schedule(new TimerTask() { + @Override + public void run() { + if (!isFinished){ + Log.d("11112", "run: 绋嬪簭鎵ц涓�"); + }else { + timer.cancel(); + timer.purge(); + timer = null; + isFinished = false; + dataCallBack.onSuccess(zigbeeDeviceListBeans,zigbeeSceneListBean); + } + } + },1,500); + } + public static void reSearch(){ + if (timer != null){ + timer.cancel(); + timer.purge(); + timer = null; + } + } + + //閿欒鎶ュ憡 + public static void reportError(String reason) { + HDLLog.info(reason); + if (stateListener != null) { + CommonErrorBean errorBean = new CommonErrorBean(); + errorBean.setCmd("error"); + errorBean.setReason(reason); + String errorJson =JsonUtil.toJson(errorBean); + StateEvent event = new StateEvent(errorJson); + stateListener.onData(event); + } + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java new file mode 100644 index 0000000..ba218f3 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java @@ -0,0 +1,2618 @@ +package com.hdl.sdk.hdl_core.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.hdl_core.Config.Configuration; +import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.AirCtrlBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLAudio.HDLAudio; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLCurtain.CurtainCtrlBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLCurtain.Parser.CurtainCtrlParser; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLFreshAir.FreshAirBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.GeothermalBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.LightCtrlBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLLogic.LogicCtrlBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLLogic.LogicMode; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLSensor.SensorStateBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLWarning.WarningType; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.DevicesData; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ListRemarks; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.RcuCurtain; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.RcuLight; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.UdpDataBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AirFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CurtainFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DeviceStateEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.EventCode; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.FreshAirFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.GeothermalFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LightFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.WarningInfoEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Parser.DeviceParser; +import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; +import com.hdl.sdk.hdl_core.Util.NetUtil.NetWorkUtil; +import com.hdl.sdk.hdl_core.Util.SPUtil.SPUtils; +import com.hdl.sdk.hdl_core.Util.TransformUtil.DataConverseUtil; +import com.hdl.sdk.hdl_core.Util.TransformUtil.StringUtil; + +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.hdl_core.Util.TransformUtil.StringUtil.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 boolean isGetRcuIpSuccess = false; + public static boolean isGetDeviceStateSuccess = false; //鍒ゆ柇鑾峰彇璁惧鐘舵�佹槸鍚︽帶鍒舵垚鍔� + //鏄惁鍏佽琚畝鏄撶紪绋嬫悳绱㈤儴鍒� + private static boolean isAllowEasyProgrammingSearch = false;//鏄惁鍏佽琚畝鏄撶紪绋嬫悳绱� + private static int SDKLocalBigClass = 9; //SDK 褰撳墠閰嶇疆妯℃嫙璁惧鐨勫ぇ绫伙紝榛樿涓洪煶涔愩�佽儗鏅煶涔愬姛鑳� + private static int SDKLocalSmallClass = 1; //SDK 褰撳墠閰嶇疆妯℃嫙璁惧鐨勫皬绫伙紝绗笁鏂硅儗鏅煶涔愭ā鍧� + private static String SDKLocalRemark = "鐗规畩璁惧"; //SDK 褰撳墠閰嶇疆妯℃嫙璁惧澶囨敞 + + + /** + * 鍒濆鍖朣DK + * + * @param context 涓婁笅鏂� + */ + public static void init(Context context) { + viewContext = context; +// HDLUdpCore.initMulticastSocket(); + HandleSearch.rcuIp = (String) SPUtils.getParam(context, SPUtils.KEY_RCU_IP_, ""); + Crc.localSubnetID = (int) SPUtils.getParam(context, SPUtils.KEY_SUB_ID_, 254); + Crc.localDeviceID = (int) SPUtils.getParam(context, SPUtils.KEY_DEVICE_ID, 80); + SDKLocalRemark = (String) SPUtils.getParam(viewContext, SPUtils.KEY_LOCAL_REMARK, SPUtils.DEFAULT_REMARK); +// HandleSearch.curSearchMode = HandleSearch.GET_BUS_DEVICES; +// HDLUdpCore.initMulticastSocket6000(); + } + + public static Context getViewContext() { + return viewContext; + } + + /** + * 閲婃斁Socket + */ + public static void release() { + HDLUdpCore.closeSocket6008(); + HDLUdpCore.closeSocket6000(); + } + + /** + * 閰嶇疆绠�鏄撶紪绋嬫悳绱㈣繑鍥炵殑榛樿鍙傛暟 + * @param mSDKLocalBigClass 澶х被ID + * @param mSDKLocalSmallClass 灏忕被ID + * @param mSDKLocalRemark 澶囨敞 + */ + public static void setEasyProgrammingSearchLocalData(int mSDKLocalBigClass, int mSDKLocalSmallClass, String mSDKLocalRemark){ + SDKLocalBigClass = mSDKLocalBigClass; + SDKLocalSmallClass = mSDKLocalSmallClass; + if(mSDKLocalRemark != null){ + SDKLocalRemark = mSDKLocalRemark; + } + isAllowEasyProgrammingSearch = true; + } + + public static void setEasyProgrammingSearchLocalData(int mSDKLocalBigClass, int mSDKLocalSmallClass){ + setEasyProgrammingSearchLocalData(mSDKLocalBigClass, mSDKLocalSmallClass,null); + } + + /** + * 璁剧疆鏄惁鍏佽琚畝鏄撶紪绋嬫悳绱� + * @param isAllow + */ + public static void setIsAllowEasyProgrammingSearch(boolean isAllow){ + isAllowEasyProgrammingSearch = isAllow; + } + + /** + * 澶勭悊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) { + isExit = true; + break; + } + } + if (!isExit) { + handleSearchData(getDatas); + } + } + break; + //绠�鏄撶紪绋嬭澶囨悳绱㈡搷浣滅爜銆佽澶囪鍙栨搷浣滅爜 鍥炲 + case Configuration.DEVICES_SEARCH_COMMAND: + handleDeviceSearchBackData(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: + case Configuration.AIR_HVAC_CTRL_BACK_COMMAND: + case Configuration.FRESH_AIR_CTRL_BACK_COMMAND: //20190709鏂板 + handleCtrlData(getDatas); + break; + case Configuration.GEOTHERMAL_MODULE_CTRL_BACK_COMMAND://20190709鏂板 + handleGeothermalCtrlData(getDatas); + break; + +// 鑾峰彇璁惧澶囨敞 + case Configuration.DEVICES_READ_BACK_COMMAND: + + if (isLogicCtrl) { + isLogicCtrl = false; + handleLogicAir(getDatas); + } else { + handleRemarkCurStateData(getDatas); + } + break; + +// 鑾峰彇璁惧鐘舵�� + case Configuration.LIGHT_STATE_BACK_COMMAND: + case Configuration.CURTAIN_STATE_BACK_COMMAND: + case Configuration.AIR_STATE_BACK_COMMAND: + case Configuration.SENSOR_STATE_BACK_COMMAND: + handleStateData(getDatas); + break; + //鑾峰彇鏂伴璁惧鐘舵�� 20190709鏂板 + case Configuration.FRESH_AIR_STATE_BACK_COMMAND: + handleFreshAirStateData(getDatas); + break; + //鑾峰彇鍦扮儹璁惧鐘舵�� + case Configuration.GEOTHERMAL_MODULE_STATE_BACK_COMMAND: + handleGeothermalStateData(getDatas); + break; + + case Configuration.AIR_HVAC_STATE_BACK_COMMAND: + handleRcuAirCastData(getDatas); + 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) { + if (getDatas.port == Configuration.RCU_SEND_PORT) { + SPUtils.setParam(viewContext, SPUtils.KEY_HDL_RCU_IP, getDatas.ipAddress); + } + handleSearchData(getDatas); + HandleSearch.OnDeviceListGetSuccessCallBack();//鎵嬪姩娣诲姞璁惧鎴愬姛绔嬪埢杩斿洖 + HDLCommand.cusSendCommand(Configuration.MANUAL_ADD_DEVICE_BACK_COMMAND, + Crc.localSubnetID, + Crc.localDeviceID, + new byte[]{1}, + getDatas.port, getDatas.ipAddress); + } else { + //娣诲姞澶辫触锛屽凡缁忓瓨鍦ㄤ簡鐩稿悓鐨勫瓙缃慽d銆佽澶噄d + HDLCommand.cusSendCommand(Configuration.MANUAL_ADD_DEVICE_BACK_COMMAND, + Crc.localSubnetID, + Crc.localDeviceID, + new byte[]{0}, + getDatas.port, getDatas.ipAddress); + } + 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}, + getDatas.port, getDatas.ipAddress); + 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; + } + } + + + /** + * 鍥炲绠�鏄撶紪绋嬫悳绱㈤潪缃戠粶璁惧锛岃繑鍥炲綋鍓峉DK淇℃伅 + * + * @param getDatas + */ + private static void sendDeviceSearchBackInfo(UdpDataBean getDatas) { + byte[] remarkByte = StringUtil.stringtoBytes(SDKLocalRemark); + byte[] addBytes = new byte[25]; + addBytes[0] = getDatas.addBytes[0]; + addBytes[1] = getDatas.addBytes[1]; + System.arraycopy(remarkByte, 0, addBytes, 2, remarkByte.length > 20 ? 20 : remarkByte.length); + addBytes[22] = (byte) SDKLocalBigClass; + addBytes[23] = (byte) SDKLocalSmallClass; + addBytes[24] = (byte) 1; + + HDLCommand.cusSendCommand(Configuration.DEVICES_SEARCH_BACK_COMMAND, + getDatas.sourceSubnetID, + getDatas.sourceDeviceID, + addBytes, + getDatas.port, getDatas.ipAddress); + + +// HDLCommand.cusSendCommand(Configuration.DEVICES_SEARCH_BACK_COMMAND, +// getDatas.sourceSubnetID, +// getDatas.sourceDeviceID, +// addBytes, +// getDatas.port, NetWorkUtil.getLocalBroadCast()); + + } + + /** + * 鏀跺埌绠�鏄撶紪绋嬫悳绱㈤潪缃戠粶璁惧 + * @param getDatas + */ + public static void handleDeviceSearchBackData(UdpDataBean getDatas){ + //鍒ゆ柇鏄惁鍏佽琚畝鏄撶紪绋嬫悳绱㈠拰鍥炲 + if(!isAllowEasyProgrammingSearch) return; + + if (getDatas.addBytes.length == 2) { + sendDeviceSearchBackInfo(getDatas); + } else { + + for (int i = 2, len = getDatas.addBytes.length; i < len; i++) { + if (i % 2 == 0) { + if ((getDatas.addBytes[i] & 0xFF) == Crc.localSubnetID + && (getDatas.addBytes[i + 1] & 0xFF) == Crc.localDeviceID + ) { + sendDeviceSearchBackInfo(getDatas); + break; + } + } + } + } + + } + + + + /** + * 澶勭悊RCU鎼滅储鏁版嵁 + * + * @param getDatas + */ + private static void handleRcuSearchData(UdpDataBean getDatas) { + if (getDatas.addBytes.length == 2) { + sendRCULocalInfo(getDatas); + } else { + //RCU榛樿鏅�氱綉缁滆澶囩殑璁惧id涓�0 + for (int i = 2, len = getDatas.addBytes.length; i < len; i++) { + if (i % 2 == 0) { + if ((getDatas.addBytes[i] & 0xFF) == Crc.localSubnetID + && (getDatas.addBytes[i + 1] & 0xFF) == 0 + ) { + sendRCULocalInfo(getDatas); + break; + } + } + } + } + } + + /** + * 杩斿洖缁橰CU鐨勬湰鍦癝DK淇℃伅 + * + * @param getDatas + */ + private static void sendRCULocalInfo(UdpDataBean getDatas) { + boolean isGetIp; + byte[] localIp = null; + try { + localIp = NetWorkUtil.getLocalHostLANAddress().getAddress(); + } catch (Exception e) { + e.printStackTrace(); + } + if (localIp == null) { + isGetIp = false; + localIp = new byte[]{(byte) 0, (byte) 0, 0, 0}; + } else { + isGetIp = true; + } + + byte[] routeIp = NetWorkUtil.getWifiInfoByte(viewContext, NetWorkUtil.GET_GATEWAY); + if (routeIp == null) { + routeIp = new byte[]{0, 0, 0, 0}; + } + + byte[] ipMac = NetWorkUtil.getWifiInfoByte(viewContext, NetWorkUtil.GET_MAC_ADDRESS); + if (ipMac == null) { + ipMac = new byte[]{0, 0, 0, 0, 0, 0}; + } + + byte[] netMask = NetWorkUtil.getWifiInfoByte(viewContext, NetWorkUtil.GET_NETMASK); + if (netMask == null) { + netMask = new byte[]{0, 0, 0, 0}; + } + + byte dchp = 0; + if (isGetIp) { + dchp = 1; + } + + byte[] remarkByte; +// String remarkString = (String) SPUtils.getParam(viewContext, SPUtils.KEY_LOCAL_REMARK, SPUtils.DEFAULT_REMARK); + + remarkByte = StringUtil.stringtoBytes(SDKLocalRemark); + + byte[] addBytes = new byte[53]; + addBytes[0] = getDatas.addBytes[0]; + addBytes[1] = getDatas.addBytes[1]; + addBytes[2] = (byte) 254; + addBytes[3] = 3; + addBytes[4] = 1; + addBytes[addBytes.length - 1] = (byte) Crc.localSubnetID; + addBytes[addBytes.length - 2] = dchp; + System.arraycopy(remarkByte, 0, addBytes, 13, remarkByte.length); + System.arraycopy(localIp, 0, addBytes, 33, 4); + System.arraycopy(routeIp, 0, addBytes, 37, 4); + System.arraycopy(ipMac, 0, addBytes, 41, 6); + System.arraycopy(netMask, 0, addBytes, 47, 4); + + HDLCommand.cusSendCommand(Configuration.RCU_SEARCH_BACK_COMMAND, + getDatas.sourceSubnetID, + getDatas.sourceDeviceID, + addBytes, + getDatas.port, getDatas.ipAddress); + } + + /** + * 澶勭悊RCU璇绘湰鍦癝DK淇℃伅 + * + * @param getDatas + */ + private static void handleRcuReadInfo(UdpDataBean getDatas) { + byte[] addByte = new byte[6]; + addByte[0] = 1; + + String localRcuIp = (String) SPUtils.getParam(viewContext, SPUtils.KEY_HDL_RCU_IP, "0.0.0.0"); + if (localRcuIp.equals("0.0.0.0")) { + addByte[1] = 1; + } else { + addByte[1] = 2; + } + String[] ip = localRcuIp.split("\\."); + + addByte[2] = (byte) Integer.parseInt(ip[0]); + addByte[3] = (byte) Integer.parseInt(ip[1]); + addByte[4] = (byte) Integer.parseInt(ip[2]); + addByte[5] = (byte) Integer.parseInt(ip[3]); + + + HDLCommand.cusSendCommand(Configuration.RCU_READ_SDK_INFO_BACK_COMMAND, + getDatas.sourceSubnetID, + getDatas.sourceDeviceID, + addByte, + getDatas.port, getDatas.ipAddress); + } + + /** + * 澶勭悊RCU璇绘湰鍦癝DK鐨刬p鍦板潃 + * + * @param getDatas + */ + private static void handleRcuIp(UdpDataBean getDatas) { + isGetRcuIpSuccess = true; + if (rcuIpList.size() == 0 || !rcuIpList.contains(getDatas.ipAddress)) { + HDLLog.info("rcuIp = " + getDatas.ipAddress); + rcuIpList.add(getDatas.ipAddress); + } + } + + /** + * 澶勭悊鎼滅储璁惧鏁版嵁 + * + * @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 = byte2String(remarkByte); + devicesData.setRemark(remarkStr); + boolean isExitData = DeviceParser.parse(getDatas.addBytes, getDatas.port, getDatas.ipAddress, devicesData, remarkStr); + String addData = ""; + for (int i = 22, len = getDatas.addBytes.length; i < len; i++) { + addData += " arr" + i + " = " + (getDatas.addBytes[i] & 0xFF) + ","; + } + realDevicesDataList.add(devicesData);//璁板綍鎵�鏈夌殑鎺ユ敹鍒拌澶囷紝鍖呮嫭SDK涓嶆敮鎸佺殑璁惧绉嶇被銆備綔鐢細浣滀负鍙戦�佺浜屾鎼滅储鍛戒护鏃剁敤鍒� + HDLLog.info("鎵�鏈夎澶囧垪琛� 绗� " + realDevicesDataList.size() + " 涓ā鍧� " + + " \n婧愬瓙缃戝彿 = " + (getDatas.sourceSubnetID) + + " \n婧愯澶囧彿 = " + (getDatas.sourceDeviceID) + + " \n妯″潡澶囨敞 = " + devicesData.getRemark() + + " \n闄勫姞鏁版嵁 = " + addData + + ); + +// 鍒ゆ柇鏄惁宸茬粡瀛樺湪鍦ㄨ澶囧垪琛紝鑻ュ瓨鍦ㄥ垯杩囨护 + if (isExitData) { + devicesDataList.add(devicesData);//璁板綍鎵�鏈夌殑鎺ユ敹鍒拌澶囷紝涓嶅寘鎷琒DK涓嶆敮鎸佺殑璁惧绉嶇被 +// 杩囨护鎺夎儗鏅煶涔愶紝鑳屾櫙闊充箰娌℃湁澶囨敞杩斿洖 + 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 addData = ""; +// for(int i = 0,len = getDatas.AddBytes.length;i<len;i++){ +// addData += " arr"+i+" = "+(getDatas.AddBytes[i] & 0xFF)+","; +// } + String deviceName = ""; + for (int i = 0, len = devicesData.getAppliancesInfoList().size(); i < len; i++) { + deviceName += " " + devicesData.getAppliancesInfoList().get(i).getDeviceName() + " "; + } + + + HDLLog.info("\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){ + + if (TextUtils.isEmpty(HandleSearch.rcuIp)) { + 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; + } + } + + } + } + } + + + } else { + if (getDatas.addBytes.length != 0) { + 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).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); + for (int k = 0; k < rcuLightList.size(); k++) { + if (devicesDataList.get(i).getAppliancesInfoList().get(j).getPhysicsChannelNum() == rcuLightList.get(k).getPhysicsChanelNum() + ) { + rcuLightList.get(k).setCurState(getDatas.addBytes[2] & 0xFF); + break; + } + } + 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.setIsSuccess(getDatas.AddBytes[1] & 0xFF); + info1.setBrightness(getDatas.addBytes[2] & 0xFF); + info1.setChannelCount(getDatas.addBytes[3] & 0xFF); + info1.setDeviceChannelCount(getDatas.addBytes[4] & 0xFF); +// isLightCtrlSuccess = true; + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); + EventBus.getDefault().post(new LightFeedBackEvent(info1, 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.info("鎺у埗 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++) { + if(infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_GLYSTRO + || infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_ROLLER + || infos.get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE + ) { + + 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) { + curtainCtrlBackInfo.setState(getDatas.addBytes[1] & 0xFF); + curtainCtrlBackInfo.setNum(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); + 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: + 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.info( airbytes); + AppliancesInfo airInfo = infos.get(appIndex); + int indexI = devIndex; + int indexJ = appIndex; + + byte[] oldAirInfo = airInfo.getArrCurState(); +// 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) { + oldAirInfo = AirCtrlParser.getNewAcByte(); + + } + setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true); + for (int oldAirInedx = 0; oldAirInedx < oldAirInfo.length; oldAirInedx++) { + if (oldAirInedx == 0) { + if (oldAirInfo[0] != newAirInfo[8]) {//2019 鍘绘帀鐩稿悓寮�鍏崇姸鎬佸垽鏂�,瑙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; + if (oldAirInfo[1] != (byte) mode) { + isModeChange = true; + oldAirInfo[1] = (byte) mode; + curAirInfo = new byte[]{AirCtrlParser.airMode, (byte) mode}; + 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 == 2) { + int mode = newAirInfo[9] & 0xff; + byte newAirTem = newAirInfo[11]; + + + 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]; + if (oldAirInfo[3] != (byte) speed) { + oldAirInfo[3] = (byte) speed; + curAirInfo = new byte[]{AirCtrlParser.airSpeed, (byte) speed}; + 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)); + + } + } + } + } + + +// 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)); +// +// } + + + 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; + } + } + } + } + + //2019-07-09 鏂板鏂伴绯荤粺鎺у埗鍥炶皟 + case Configuration.FRESH_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).getBigType() == Configuration.FRESH_AIR_BIG_TYPE + && infos.get(j).getDeviceType() == HDLApConfig.TYPE_FRESH_AIR + && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { + + devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes); + AppliancesInfo mFreshAirInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); + FreshAirBackInfo info = new FreshAirBackInfo(mFreshAirInfo); +// isFreshAirCtrlSuccess = true; + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); + EventBus.getDefault().post(new FreshAirFeedBackEvent(info, true)); + break outter; + } + + } + } + } + + break; + } + } + + /** + * 澶勭悊鍦扮儹璁惧鎺у埗鏁版嵁 + * 20190710 + * + * @param getDatas + */ + private static void handleGeothermalCtrlData(UdpDataBean getDatas) { + switch (getDatas.command) { + //2019-07-09 鍦扮儹妯″潡 + case Configuration.GEOTHERMAL_MODULE_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.GEOTHERMAL_BIG_TYPE + && infos.get(j).getDeviceType() == HDLApConfig.TYPE_GEOTHERMAL_MODULE + && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { + if (getDatas.addBytes.length >= 8) { + byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getFeedbackState(); + if (getBytes == null || getBytes.length < 10) { + getBytes = new byte[10]; + } + System.arraycopy(getDatas.addBytes, 0, getBytes, 0, 8);//鎺у埗鍦扮儹鐘舵�佸弽棣堬紝鍙彇鍓�8浣嶆暟鎹� + devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getBytes); + AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); + + GeothermalBackInfo info = new GeothermalBackInfo(mInfo, true); +// isGeothermalCtrlSuccess = true; + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); + EventBus.getDefault().post(new GeothermalFeedBackEvent(info, EventCode.SUCCESS)); + } else { + +// AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); +// GeothermalBackInfo info = new GeothermalBackInfo(mInfo, true); +// isGeothermalCtrlSuccess = true; +// EventBus.getDefault().post(new GeothermalFeedBackEvent(info, EventCode.DATAEMPTY)); + + HDLLog.E("鎺у埗鍦扮儹鐘舵�佸弽棣堟暟鎹紓甯�"); + } + break outter; + } + } + } + } + } + + break; + } + } + + /** + * 澶勭悊RCU鐏厜骞挎挱娑堟伅 + * + * @param getDatas + */ + private static void handleRcuLightCastData(UdpDataBean getDatas) { + for (int i = 0; i < devicesDataList.size(); i++) { + if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID + && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID + ) { + for (int j = 0; j < devicesDataList.get(i).getAppliancesInfoList().size(); j++) { + switch (getDatas.command) { + case Configuration.RCU_ROOM_CAST_COMMAND: + if (devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType() == Configuration.LIGTH_BIG_TYPE + ) { + for (int m = 13; m < getDatas.addBytes.length; m++) { + for (int n = 0; n < rcuLightList.size(); n++) { + if (rcuLightList.get(n).getPhysicsChanelNum() == (m - 12) + && rcuLightList.get(n).getCurState() != getDatas.addBytes[m] + && rcuLightList.get(n).getPhysicsChanelNum() == devicesDataList.get(i).getAppliancesInfoList().get(j).getPhysicsChannelNum() + ) { + rcuLightList.get(n).setCurState(getDatas.addBytes[m]); +// HDLLog.info( "鐏厜鐗╃悊鍥炶矾锛�" + rcuLightList.get(n).getPhysicsChanelNum() + " 鐘舵�侊細" + rcuLightList.get(n).getCurState()); + AppliancesInfo info = devicesDataList.get(i).getAppliancesInfoList().get(j); + info.setCurState(getDatas.addBytes[m]); + devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[m]); + devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[m] & 0xff); + EventBus.getDefault().post(new DeviceStateEvent(info, true)); + } + } + } + } + break; +// case Configuration.RCU_CURTAIN_CAST_COMMAND: +// if (devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType() == Configuration.CURTAIN_BIG_TYPE +// ) { +// for (int l = 6; l < getDatas.addBytes.length; l++) { +// for (int k = 0; k < rcuCurtainList.size(); k++) { +// if (rcuCurtainList.get(k).getLittleType() == devicesDataList.get(i).getAppliancesInfoList().get(j).getLittleType() +// && rcuCurtainList.get(k).getChanelNum() == devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum() +// && rcuCurtainList.get(k).getChanelNum() == (l - 5) +// ) { +// int state = 0; +// switch (getDatas.addBytes[l]) { +// case 0: +// state = CurtainCtrlParser.curtainPause; +// break; +// case 1: +// state = CurtainCtrlParser.curtainOn; +// break; +// case 2: +// state = CurtainCtrlParser.curtainOff; +// break; +// } +// if (rcuCurtainList.get(k).getCurState() != state && state != CurtainCtrlParser.curtainPause) { +// rcuCurtainList.get(k).setCurState(state); +// HDLLog.info( "骞挎挱 rcuCurtainList鍥炶矾鍙凤細" + rcuCurtainList.get(k).getChanelNum() +// + " state = " + rcuCurtainList.get(k).getCurState()); +// AppliancesInfo info = devicesDataList.get(i).getAppliancesInfoList().get(j); +// info.setCurState(state); +// EventBus.getDefault().post(new DeviceStateEvent(info, true)); +// } +// } +// } +// } +// +// +// } +// break; + + default: + break; + } + } + } + } + } + + /** + * 澶勭悊RCU绐楀笜骞挎挱娑堟伅 + * + * @param getDatas + */ + private static void handleRcuCurtainCastData(UdpDataBean getDatas) { + outter: + for (int i = 0; i < devicesDataList.size(); i++) { + if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID + && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID + ) { + for (int j = 0; j < devicesDataList.get(i).getAppliancesInfoList().size(); j++) { + + if (devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType() == Configuration.CURTAIN_BIG_TYPE) { + for (int k = 0; k < 6; k++) { + if (devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum() == (k + 1)) { + devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(getDatas.addBytes[k] & 0xff); + devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState(getDatas.addBytes[k] & 0xff); + AppliancesInfo info = devicesDataList.get(i).getAppliancesInfoList().get(j); + int state = 0; + switch (getDatas.addBytes[k]) { + case 0: + state = CurtainCtrlParser.curtainPause; + break; + case 1: + state = CurtainCtrlParser.curtainOn; + break; + case 2: + state = CurtainCtrlParser.curtainOff; + break; + } + info.setCurState(state); +// HDLLog.info( "2099 闄勫姞鏁版嵁锛�" + Arrays.toString(getDatas.addBytes)); + EventBus.getDefault().post(new DeviceStateEvent(info, true)); + } + } + } + } + break outter; + } + } + } + + /** + * 澶勭悊RCU绌鸿皟骞挎挱娑堟伅 + * + * @param getDatas + */ + private static void handleRcuAirCastData(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); + if (appliancesInfo.getPort() != 0) { + byte[] oldAirInfo = appliancesInfo.getArrCurState(); + + if (oldAirInfo == null || oldAirInfo.length == 0) { + oldAirInfo = AirCtrlParser.getNewAcByte(); + } + + + handleAirCastData(getDatas, oldAirInfo, airIndex, appliancesInfo); + + oldAirInfo[0] = getDatas.addBytes[1 + 0 * 11]; + + oldAirInfo[1] = (byte) ((getDatas.addBytes[3 + 0 * 11] & 0xf0) >> 4); + + + switch (oldAirInfo[0] & 0xff) { + case 0: + oldAirInfo[2] = getDatas.addBytes[2 + 0 * 11]; + break; + case 1: + oldAirInfo[2] = getDatas.addBytes[6 + 0 * 11]; + break; + case 3: + oldAirInfo[2] = getDatas.addBytes[8 + 0 * 11]; + break; + case 4: + oldAirInfo[2] = getDatas.addBytes[9 + 0 * 11]; + break; + + } + + oldAirInfo[3] = (byte) (getDatas.addBytes[3 + 0 * 11] & 0x0f); + oldAirInfo[4] = getDatas.addBytes[5 + 0 * 11]; + oldAirInfo[5] = getDatas.addBytes[10 + 0 * 11]; + devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(oldAirInfo); + + +// 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]; + } + } + +// 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); +// switch (getDatas.addBytes[2] & 0xFF) { +// case 1: +// air1Info = airInfo; +// break; +// case 2: +// air2Info = airInfo; +// break; +// case 3: +// air3Info = airInfo; +// break; +// case 4: +// air4Info = airInfo; +// break; +// +// } + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setArrCurState(airInfo); + newInfo1 = devicesDataList.get(devPos).getAppliancesInfoList().get(appPos); + break; + } + break; + } + } + } + } + +// getAppInfo(newInfo); + final AppliancesInfo newInfo = newInfo1; + if (newInfo == null) { + return; + } + final byte[] airCurInfo = newInfo1.getArrCurState(); +// switch (newInfo.getChannelNum()) { +// case 1: +// airCurInfo = air1Info; +// break; +// case 2: +// airCurInfo = air2Info; +// break; +// case 3: +// airCurInfo = air3Info; +// break; +// case 4: +// airCurInfo = air4Info; +// break; +// default: +// airCurInfo = new byte[]{0, 0}; +// break; +// } + + 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)) + ) { + 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); + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setRemarks(byte2String(remark)); + + 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]; + } + + HDLLog.info("鑾峰彇澶囨敞Configuration.AIR_BIG_TYPE锛� "+ StringUtil.ByteArrToHex(hvacBytes,0, hvacBytes.length)); + + 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: +// String aa = "浼犳劅鍣ㄥ娉細"; +// for (int i = 0; i < getDatas.addBytes.length; i++) { +// aa += (getDatas.addBytes[i] & 0xff) + ","; +// } +// HDLLog.info( aa); + float curState; + if (getDatas.addBytes.length >= 28) { + curState = DataConverseUtil.byte2Float(Arrays.copyOfRange(getDatas.addBytes, 24, 27)); + + } else { + curState = (float) (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; + case Configuration.FRESH_AIR_BIG_TYPE://20190711鏂板 + switch (infos.get(appPos).getLittleType()) { + case Configuration.FRESH_AIR_LITTLE_TYPE_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).setFeedbackState(hvacBytes); + break; + } + break; + case Configuration.GEOTHERMAL_BIG_TYPE://20190711鏂板 + switch (infos.get(appPos).getLittleType()) { + case Configuration.GEOTHERMAL_LITTLE_TYPE_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).setFeedbackState(hvacBytes); + break; + } + break; + default: + HDLLog.info("鏈壘鍒版绫诲瀷璁惧锛�" + 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.info("鏀跺埌澶囨敞鍛戒护锛屽凡瀛樺湪姝よ澶囧娉紝杩囨护"); + break listRemarksOutter; + } + } else { +// HDLLog.info("涓嶅瓨鍦ㄧ殑璁惧澶囨敞锛屽啀娆℃悳绱㈠娉ㄣ�傝澶囷細瀛愮綉鍙凤細" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceSubnetID() +// + "璁惧鍙凤細" + listRemarks.get(lRPos).getAppliancesInfo().getDeviceDeviceID() +// + "鍥炶矾鍙�" + listRemarks.get(lRPos).getAppliancesInfo().getChannelNum() +// + "澶囨敞锛�" + listRemarks.get(lRPos).getAppliancesInfo().getRemarks()); + + HDLLog.info("涓嶅瓨鍦ㄧ殑璁惧澶囨敞锛屽啀娆℃悳绱㈠娉ㄣ�傚啀娆℃悳绱㈣澶囷細瀛愮綉鍙凤細" + listRemarks.get(lR2Pos).getAppliancesInfo().getDeviceSubnetID() + + "璁惧鍙凤細" + listRemarks.get(lR2Pos).getAppliancesInfo().getDeviceDeviceID() + + "鍥炶矾鍙�" + listRemarks.get(lR2Pos).getAppliancesInfo().getChannelNum()); +// + "澶囨敞锛�" + listRemarks.get(lR2Pos).getAppliancesInfo().getRemarks()); + + HandleSearch.getDevRemarks(); + break listRemarksOutter; + } + } + } else { + HDLLog.info("杩斿洖澶囨敞璁惧锛氬瓙缃戝彿锛�" + 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 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++) { +// HDLLog.info("HDL big:锛�" + devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType()); + switch (devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType()) { + case Configuration.LIGTH_BIG_TYPE: + 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.info("djllightState",devicesDataList.get(i).getAppliancesInfoList().get(j).toString()); + break; + case Configuration.CURTAIN_BIG_TYPE: + int state; + if (devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) { + 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)); + } + } else { + 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)); + } + } + + +// HDLLog.info("djlcurtainState",devicesDataList.get(i).getAppliancesInfoList().get(j).toString()); + break; + case Configuration.AIR_BIG_TYPE: + 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)); + } + + break; + case Configuration.SENSOR_BIG_TYPE: + isGetDeviceStateSuccess = true; + AppliancesInfo sensorInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); + float value = DataConverseUtil.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; + default: + unite = "鏈煡鍗曚綅"; + break; + } + + +// EventBus.getDefault().post(new DeviceStateEvent(sensorInfo, true)); + HDLLog.info("鍙戦�佷紶鎰熷櫒閫氱煡鏇存柊"); + EventBus.getDefault().post(new SensorStateBackInfo(sensorInfo, true, unite)); + break; + default: + HDLLog.info("handle state 娌℃湁鎵惧埌鍖归厤绫诲瀷"); + break; + } + + } + break outter; + } + } + } + + /** + * 澶勭悊鏂伴璁惧鐘舵�佹暟鎹� + * 20190710鏂板 + * + * @param getDatas + */ + private static void handleFreshAirStateData(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.FRESH_AIR_BIG_TYPE + && infos.get(j).getDeviceType() == HDLApConfig.TYPE_FRESH_AIR + && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-07-17 + + isGetDeviceStateSuccess = true; + devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes); + EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); + break outter; + }else { + HDLLog.info("handleFreshAirStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷"); + } + } + break outter; + } + } + } + + + /** + * 澶勭悊鍦扮儹璁惧鐘舵�佹暟鎹� + * 20190710鏂板 + * + * @param getDatas + */ + private static void handleGeothermalStateData(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.GEOTHERMAL_BIG_TYPE + && infos.get(j).getDeviceType() == HDLApConfig.TYPE_GEOTHERMAL_MODULE + && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-07-17 + if (getDatas.addBytes.length >= 10) { + byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getFeedbackState(); + if (getBytes == null || getBytes.length < 10) { + getBytes = new byte[10]; + } + System.arraycopy(getDatas.addBytes, 0, getBytes, 0, 10);//20190710鏌ヨ鍦扮儹鐘舵�佸弽棣堬紝鍙彇鍓�10浣嶆暟鎹� + devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getBytes); + isGetDeviceStateSuccess = true; + EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); + } else { + HDLLog.E("鍦扮儹鐘舵�佸弽棣堟暟鎹紓甯�"); + } + + break outter; + }else { + HDLLog.info("handleFreshAirStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷"); + } + } + break outter; + } + } + } + + + + /** + * 姝ゆ柟娉曞熀鏈病鐢ㄥ埌锛岄�昏緫妯″潡鐨勬帶鍒朵俊鎭凡缁忓湪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(byte2String(remark)); + devicesDataList.get(i).getAppliancesInfoList().get(j).setLogicMode(logicMode); + break; + } + } + } + } + } + + /** + * 澶勭悊璀︽姤鏁版嵁 + * + * @param getDatas + */ + private static void handleWarningData(UdpDataBean getDatas) { + if (getDatas.addBytes.length == 4) { + EventBus.getDefault().post( + new WarningInfoEvent( + WarningType.getWarningType( + (getDatas.addBytes[2] & 0xFF) * 256 + (getDatas.addBytes[3] & 0xFF)) + )); + Intent warningIntent = new Intent(); + warningIntent.setAction("com.hdl.action.WARNING"); + warningIntent.putExtra("HdlWarning", + WarningType.getWarningType((getDatas.addBytes[2] & 0xFF) * 256 + (getDatas.addBytes[3] & 0xFF))); + viewContext.sendBroadcast(warningIntent); + } else { + EventBus.getDefault().post( + new WarningInfoEvent( + WarningType.getWarningType(getDatas.addBytes[2] & 0xFF))); + Intent warningIntent = new Intent(); + warningIntent.setAction("com.hdl.action.WARNING"); + warningIntent.putExtra("HdlWarning", + WarningType.getWarningType(getDatas.addBytes[3] & 0xFF)); + 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; + } + } + } + } + } + + /** + * 璁剧疆鎺у埗鏄惁鎴愬姛鐘舵�� + * @param info + * @param success + */ + public static void setDeviceCtrlSuccessStateWithInfo(AppliancesInfo info, Boolean success){ + ctrlSuccessStateHashMap.put(info.getDeviceKey(), success); + } + + /** + * 鑾峰彇鏄惁鎺у埗鎴愬姛 + * @param info + * @return 缁撴灉 + */ + public static Boolean getDeviceCtrlSuccessStateWithInfo(AppliancesInfo info){ + Boolean success = ctrlSuccessStateHashMap.get(info.getDeviceKey()); + if(success == null) success = false; + return success; + } + + /** + * 淇濆瓨璁惧鏁版嵁鍒楄〃 + * 鏍规嵁闇�瑕侊紝瀹炴椂淇濆瓨褰撳墠鏁版嵁 + * 2019-10-14 + * @return boolean + */ + public static boolean saveDevicesDataList() { + try { + Gson gson = new Gson(); + String jsonStr = gson.toJson(devicesDataList); //灏哃ist杞崲鎴怞son +// HDLLog.info("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 + + if (!TextUtils.isEmpty(HandleSearch.rcuIp)) {//鍒ゆ柇涔嬪墠鏄惁涓篟UC妯″紡 + HandleSearch.curSearchMode = HandleSearch.GET_RCU_DEVICES; + HDLUdpCore.closeSocket6000(); + HDLUdpCore.init6008(); + }else { + HandleSearch.curSearchMode = HandleSearch.GET_BUS_DEVICES; + HDLUdpCore.closeSocket6008(); + HDLUdpCore.init6000(); + } + + 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); + } + } + } + } + + + + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java new file mode 100644 index 0000000..e776c9b --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java @@ -0,0 +1,752 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Core; + + +import android.text.TextUtils; + +import com.hdl.sdk.hdl_core.Config.Configuration; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.UdpDataBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.ThirdPartyBgmInfoEvent; +import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; +import com.hdl.sdk.hdl_core.Util.TransformUtil.StringUtil; + +import org.greenrobot.eventbus.EventBus; + +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.MulticastSocket; +import java.net.SocketException; + +/** + * Created by djl on 2017/3/17. + */ + +public class HDLUdpCore { +// private static MulticastSocket msr6000 = null; +// private static MulticastSocket msr6008 = null; +// private static boolean isMsr6008Stop = true; +// private static boolean isMsr6000Stop = true; + + private static DatagramSocket datagramSocket6008 = null; + private static DatagramSocket datagramSocket6000 = null; + private static DatagramSocket datagramSocket7624 = null; + + + + + /** + * 鍙戦�佹暟鎹寘 + * 鐐瑰鐐规垨骞挎挱 + * + * @param sendDatas + */ + public static void sendData(final Crc sendDatas) { + HDLLog.info("HDLsendData锛� "+ StringUtil.ByteArrToHex(sendDatas.GetSendBytes(),0, sendDatas.GetSendBytes().length)); + +// sendTestCMD(sendDatas.GetSendBytes(), HDLTest.SEND_TEST_PORT); + new Thread(new Runnable() { + @Override + public void run() { + try { + DatagramSocket sendSocket = new DatagramSocket(); + HDLLog.info( " 瀛愮綉鍙�:"+sendDatas.desSubnetID + +" 璁惧鍙凤細"+sendDatas.desDeviceID + +" 鎿嶄綔鐮�"+Integer.toHexString(sendDatas.command) + +" 鍙戦�佺殑ip:" + sendDatas.ipAddress); + java.net.InetAddress address = InetAddress.getByName(sendDatas.ipAddress); + DatagramPacket packet = new DatagramPacket( + sendDatas.GetSendBytes(), + sendDatas.GetSendBytes().length, address + , sendDatas.port); + + +// String aa = ""; +// for(int i = 0;i<sendDatas.GetSendBytes().length;i++){ +// aa += Integer.toHexString((sendDatas.GetSendBytes()[i] &0xff)) +","; +// } +// HDLLog.info("鍙戦�佺殑鏁版嵁锛�"+aa); + + + sendSocket.send(packet); + sendSocket.close(); + } catch (Exception e) { + HDLLog.info( "HDL 鍙戦�佹搷浣滃懡浠ゅけ璐�:" + e); + } + } + }).start(); + } + + + + /** + * 鍙戦�佺粍鎾� + * + * @param sendDatas + */ + public static void sendMulticastData(final Crc sendDatas) { +// sendTestCMD(sendDatas.GetSendBytes(), HDLTest.SEND_TEST_PORT); + new Thread(new Runnable() { + @Override + public void run() { + try { + InetAddress group = InetAddress.getByName(Configuration.RCU_MULTI_IP); + MulticastSocket mss; + mss = new MulticastSocket(sendDatas.port); + mss.joinGroup(group); + DatagramPacket dp = new DatagramPacket(sendDatas.GetSendBytes(), sendDatas.GetSendBytes().length, + group, sendDatas.port); + mss.send(dp); + mss.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + }).start(); + } + + +// public static void initMulticastSocket6000() { +// if (isMsr6000Stop) { +// HDLLog.info( "HDL SDK 6000 init"); +// sdkHeartBeat(); +// isMsr6000Stop = false; +// new Thread(new Runnable() { +// @Override +// public void run() { +// +// try { +// InetAddress group = InetAddress.getByName(Configuration.RCU_MULTI_IP); +// +// while (!isMsr6000Stop) { +// msr6000 = new MulticastSocket(Configuration.PORT); +// msr6000.joinGroup(group); +// byte[] receiveBytes = new byte[1024]; +// DatagramPacket dataPacket = new DatagramPacket(receiveBytes, receiveBytes.length); +// msr6000.receive(dataPacket); +// sendTestCMD(receiveBytes, HDLTest.REC_TEST_PORT); +// HandleHDLdata(receiveBytes, dataPacket, Configuration.PORT); +// } +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// }).start(); +// } else { +// HDLLog.info( "HDL SDK 6000 宸插惎鍔�"); +// } +// +// +// } + + +// public static void initMulticastSocket6008() { +// if (isMsr6008Stop) { +// HDLLog.info( "HDL SDK 6008 init"); +// isMsr6008Stop = false; +// new Thread(new Runnable() { +// @Override +// public void run() { +// +// try { +// InetAddress group = InetAddress.getByName(Configuration.RCU_MULTI_IP); +// +// while (!isMsr6008Stop) { +// msr6008 = new MulticastSocket(Configuration.RCU_RECEIVE_PORT); +//// msr6008.setBroadcast(true); +//// msr6008.setReceiveBufferSize(1024 * 20); +//// msr6008.setReuseAddress(true); +// msr6008.joinGroup(group); +// byte[] receiveBytes = new byte[1024]; +// DatagramPacket dataPacket = new DatagramPacket(receiveBytes, receiveBytes.length); +// msr6008.receive(dataPacket); +// sendTestCMD(receiveBytes, HDLTest.REC_TEST_PORT); +// HandleHDLdata(receiveBytes, dataPacket, Configuration.RCU_SEND_PORT); +// } +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// }).start(); +// } else { +// HDLLog.info( "HDL SDK 6008 宸插惎鍔�"); +// } +// } + + /** + * 鍒濆鍖朥DP 6008绔彛 + */ + public static void init6008() { + if (datagramSocket6008 != null) { + HDLLog.info( "HDL SDK 6008 宸插惎鍔�"); + } else { + HDLLog.info( "HDLSocket 6008 init"); +// sdkHeartBeat(); + new Thread(new Runnable() { + @Override + public void run() { + try { + datagramSocket6008 = new DatagramSocket(Configuration.RCU_RECEIVE_PORT); + datagramSocket6008.setBroadcast(true); + datagramSocket6008.setReceiveBufferSize(1024 * 20); + datagramSocket6008.setReuseAddress(true); + + byte[] receiveBytes = new byte[512]; + DatagramPacket dataPacket = new DatagramPacket(receiveBytes, receiveBytes.length); + + while (datagramSocket6008 != null) { + try { + if (datagramSocket6008 != null || (!datagramSocket6008.isClosed())) { + datagramSocket6008.receive(dataPacket); + } +// sendTestCMD(receiveBytes, HDLTest.REC_TEST_PORT); + + HandleHDLdata(receiveBytes, dataPacket, Configuration.RCU_SEND_PORT); + } catch (Exception e) { + e.printStackTrace(); + } + } + } catch (Exception e) { + datagramSocket6008 = null; + return; + } + + } + }).start(); + } + } + + /** + * 鍒濆鍖�6000绔彛 + */ + public static void init6000() { + if (datagramSocket6000 != null) { + HDLLog.info( "HDL SDK 6000 宸插惎鍔�"); + } else { + HDLLog.info( "HDLSocket 6000 init"); +// sdkHeartBeat(); + new Thread(new Runnable() { + @Override + public void run() { + try { + datagramSocket6000 = new DatagramSocket(Configuration.PORT); + datagramSocket6000.setBroadcast(true); + datagramSocket6000.setReceiveBufferSize(1024 * 20); + datagramSocket6000.setReuseAddress(true); + + + while (datagramSocket6000 != null) { + try { + byte[] receiveBytes = new byte[1024]; + DatagramPacket dataPacket = new DatagramPacket(receiveBytes, receiveBytes.length); + if (datagramSocket6000 != null || (!datagramSocket6000.isClosed())) { + datagramSocket6000.receive(dataPacket); + } + + + HDLLog.info("HDL ReceiveBytes22锛� "+ StringUtil.ByteArrToHex(receiveBytes,0, receiveBytes.length)); + HandleHDLdata(receiveBytes, dataPacket, Configuration.PORT); + } catch (Exception e) { + e.printStackTrace(); + } + } + } catch (Exception e) { + datagramSocket6000 = null; + return; + } + + } + }).start(); + } + } + + /** + * 鍒濆鍖�7624绔彛 + */ + public static void init7624(){ + if (datagramSocket7624 != null){ + HDLLog.info( "HDL SDK 7624 宸插惎鍔�"); + }else { + HDLLog.info( "HDLSocket 7624 init"); + new Thread(new Runnable() { + @Override + public void run() { + try { + datagramSocket7624 = new DatagramSocket(Configuration.ZIGBEE_PORT); + datagramSocket7624.setBroadcast(true); + datagramSocket7624.setReceiveBufferSize(1024 * 20); + datagramSocket7624.setReuseAddress(true); + while (datagramSocket7624 != null){ + byte[] receiveBytes = new byte[1024]; + DatagramPacket dataPacket = new DatagramPacket(receiveBytes, receiveBytes.length); + if (datagramSocket7624 != null || (!datagramSocket7624.isClosed())) { + datagramSocket7624.receive(dataPacket); + } + } + } catch (Exception e) { + datagramSocket7624 = null; + return; + } + } + }).start(); + } + } + +// private static void sdkHeartBeat() { +// new Thread(new Runnable() { +// @Override +// public void run() { +// while (true) { +// try { +// Thread.sleep(5000); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// if (TextUtils.isEmpty(HandleSearch.rcuIp)) { +// if (datagramSocket6000 != null) { +// sendTestCMD(new byte[]{6, 0, 0, 0}, HDLTest.SEND_TEST_PORT); +// } else { +// sendTestCMD(new byte[]{1, 1, 1, 1}, HDLTest.SEND_TEST_PORT); +// } +// } else { +// if (datagramSocket6008 != null) { +// sendTestCMD(new byte[]{6, 0, 0, 8}, HDLTest.SEND_TEST_PORT); +// } else { +// sendTestCMD(new byte[]{0, 0, 0, 0}, HDLTest.SEND_TEST_PORT); +// } +// } +// +// } +// } +// }).start(); +// } + + /** + * 鍏抽棴6008 + */ + public static void closeSocket6008() { +// isMsr6008Stop = true; +// if (msr6008 != null) { +// msr6008.close(); +// msr6008.disconnect(); +// msr6008 = null; +// } + if (datagramSocket6008 != null) { + datagramSocket6008.close(); + datagramSocket6008.disconnect(); + datagramSocket6008 = null; + } + } + + /** + * 鍏抽棴6000 + */ + public static void closeSocket6000() { +// isMsr6000Stop = true; +// if (msr6000 != null) { +// msr6000.close(); +// msr6000.disconnect(); +// msr6000 = null; +// } + if (datagramSocket6000 != null) { + datagramSocket6000.close(); + datagramSocket6000.disconnect(); + datagramSocket6000 = null; + } + } + + /** + * 鍏抽棴7624 + */ + public static void closeSocket7624() { +// isMsr7624Stop = true; +// if (msr7624 != null) { +// msr7624.close(); +// msr7624.disconnect(); +// msr7624 = null; +// } + if (datagramSocket7624 != null) { + datagramSocket7624.close(); + datagramSocket7624.disconnect(); + datagramSocket7624 = null; + } + } + + /** + * 澶勭悊HDL Data + * + * @param receiveBytes + * @param dataPacket + */ + private synchronized static void HandleHDLdata(byte[] receiveBytes, DatagramPacket dataPacket, int port) { + if (receiveBytes.length < 28) { + return; + } + + HDLLog.info("HDL ReceiveBytes锛� "+ StringUtil.ByteArrToHex(receiveBytes,0, receiveBytes.length)); + + //鏍¢獙鏄惁涓篐DL 鏁版嵁 + byte[] hdlDataVerify = new byte[10]; + System.arraycopy(receiveBytes, 4, hdlDataVerify, 0, 10); + if (!isHDLData(hdlDataVerify)) { + return; + } + + //鏁版嵁闀垮害 + int addDataLength = (receiveBytes[16] & 0xFF) - 11; + //闄勫姞鏁版嵁 + byte[] usefulBytes = new byte[addDataLength]; + //澶嶅埗闄勫姞鏁版嵁 + System.arraycopy(receiveBytes, 25, usefulBytes, 0, addDataLength); + + //鎿嶄綔鐮� + int command = (receiveBytes[21] & 0xFF) * 256 + (receiveBytes[22] & 0xFF); + //婧愬瓙缃戝彿 + int sourceSubnetID = receiveBytes[17] & 0xFF; + //婧愯澶囧彿 + int sourceDeviceID = receiveBytes[18] & 0xFF; + //鐩爣瀛愮綉鍙� + int targetSubnetID = receiveBytes[23] & 0xFF; + //鐩爣璁惧鍙� + int targetDeviceID = receiveBytes[24] & 0xFF; + + + UdpDataBean udpDataBean = new UdpDataBean(); + udpDataBean.sourceSubnetID = sourceSubnetID; + udpDataBean.sourceDeviceID = sourceDeviceID; + udpDataBean.desSubnetID = targetSubnetID; + udpDataBean.desDeviceID = targetDeviceID; + udpDataBean.command = command; + + udpDataBean.addBytes = usefulBytes; + udpDataBean.port = port; + udpDataBean.ipAddress = dataPacket.getAddress().getHostAddress(); +// HDLLog.info("澶勭悊鐨勫瓙缃戝彿锛�"+sourceSubnetID+" 璁惧鍙凤細"+sourceDeviceID); +// HDLLog.info( "ipAddress = " + udpDataBean.ipAddress + "绔彛鍙凤細" + port); + +// String hex = new Integer(command).toHexString(new Integer(command)); +// String add = ""; +// for(int i = 0;i<usefulBytes.length;i++){ +// add += "add"+i+" = "+(usefulBytes[i]& 0xff)+","; +// } +// HDLLog.info("鎿嶄綔鐮� = "+hex+" 闄勫姞鏁版嵁锛�"+add); + +// if(udpDataBean.command == Configuration.RCU_ROOM_CAST_COMMAND){ +// HDLLog.info("20d2 in "+" ip = "+udpDataBean.ipAddress); +// } + + //2019-10-8 鐩爣瀛愮綉鍙疯澶囧彿杩囨护鍒ゆ柇 + if((targetSubnetID == 0xFF && targetDeviceID == 0xFF) || (targetSubnetID == Crc.localSubnetID && targetDeviceID == Crc.localDeviceID)) { + 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); + } + } + break; + case Configuration.DEVICES_SEARCH_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.LIGHT_STATE_BACK_COMMAND: + case Configuration.FRESH_AIR_CTRL_BACK_COMMAND://20190709鏂板 鏂伴绯荤粺 + case Configuration.FRESH_AIR_STATE_BACK_COMMAND://20190709鏂板 + case Configuration.GEOTHERMAL_MODULE_CTRL_BACK_COMMAND://20190709鏂板 鍦扮儹妯″潡 + case Configuration.GEOTHERMAL_MODULE_STATE_BACK_COMMAND://20190709鏂板 + 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.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: + + if (TextUtils.isEmpty(HandleSearch.rcuIp)) { + HDLDeviceManager.handle(sendDatas, sendDatas.command); + } else { + if (HandleSearch.rcuIp.equals(sendDatas.ipAddress)) { +// HDLLog.info("sendDatas.command = "+sendDatas.command); + HDLDeviceManager.handle(sendDatas, sendDatas.command); + } + } + break; + + + case Configuration.RCU_SEARCH_COMMAND: + if (sendDatas.port == Configuration.RCU_SEND_PORT) { + HDLLog.info( "鏀跺埌鎼滅储RCU鍛戒护"); + HDLDeviceManager.handle(sendDatas, sendDatas.command); + } + + break; + case Configuration.RCU_READ_SDK_INFO_COMMAND: +// if (sendDatas.desSubnetID == Crc.localSubnetID && sendDatas.desDeviceID == Crc.localDeviceID +// ) { +// HDLLog.info( "E508鏀跺埌"); +// HDLDeviceManager.handle(sendDatas, Configuration.RCU_READ); +// } + if (sendDatas.port == Configuration.RCU_SEND_PORT) { + HDLLog.info( "鏀跺埌璇诲彇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; + } + } + + /** + * 杩欐柟娉曞熀鏈笂涓嶇敤锛岀粰鍚戝線鐢ㄧ殑 + * <p> + * 澶勭悊澶栭儴鍛戒护鏁版嵁 + * + * @param targetSubnetID + * @param targetDeviceID + * @param command + * @param usefulBytes + * @param receiveBytes + * @param sendDatas + */ + private static void HandleOutsideData(int targetSubnetID, int targetDeviceID, + int command, byte[] usefulBytes, final byte[] receiveBytes, + UdpDataBean sendDatas) { +// if(targetSubnetID == 254 && targetDeviceID == 6 && command == 0xE01C){ +// HDLDeviceManager.handle(sendDatas,Configuration.HET_DEVICES); +// }else if(targetSubnetID == 254 && targetDeviceID == 2){ +// if(command==0xE01C){ +// HDLDeviceManager.handle(sendDatas,Configuration.Midea_DEVICES); +// }else if(command == 0x3026){ +// +// } +// }else if(targetSubnetID == 254 && targetDeviceID == 8 && command == 0xE01C){ +// HDLDeviceManager.handle(sendDatas,Configuration.JAV_DEVICES); +// } +// else if(command==Configuration.DEVICES_SEARCH_COMMAND ){ +// HDLLog.info("e548 in"); +// byte[] addBytes = new byte[25]; +// int addDataLenght = (receiveBytes[16]&0xFF) - 11; +// byte[] searchBytes = new byte[addDataLenght]; +// System.arraycopy(receiveBytes, 25, searchBytes, 0,addDataLenght); +// recordRam1 = searchBytes[0]; +// recordRam2 = searchBytes[1]; +// byte[] rams = new byte[]{recordRam1,recordRam2}; +// System.arraycopy(rams,0,addBytes,0,rams.length); +// +// byte[] remark = new byte[20]; +// byte[] strBytes = StringUtil.stringtoBytes("Hope"); +// System.arraycopy(strBytes,0,remark,0,strBytes.length); +// +// System.arraycopy(remark,0,addBytes,2,remark.length); +// +// byte[] typeByte = new byte[]{9,1,1}; +// System.arraycopy(typeByte,0,addBytes,remark.length+2,typeByte.length); +// if(searchBytes.length<3){ +// isTwiceSend = false; +// HDLCommand.cusSendCommand(context, +// Configuration.DEVICES_SEARCH_BACK_COMMAND, +// recordSubId, +// recordDevId, +// addBytes, +// recordPort, +// -1); +// }else{ +// //杩欓噷杩橀渶瑕佸垽鏂瓙缃慖D锛岃澶嘔D, +// int count = (searchBytes.length-2)/2; +// for(int i=0;i<count;i++){ +// if(searchBytes[1+2*i]==recordSubId +// && searchBytes[2+2*i] == recordDevId +// && !isTwiceSend +// ){ +// isTwiceSend = true; +// HDLCommand.cusSendCommand(context, +// Configuration.DEVICES_SEARCH_BACK_COMMAND, +// recordSubId, +// recordDevId, +// addBytes, +// recordPort, +// -1); +// } +// } +// } +// } +// else if(command == Configuration.LOGIC_GET_BACK_INFO +// && (usefulBytes[0] & 0xFF) == Configuration.LOGIC_BIG_TYPE +// && ((usefulBytes[1] & 0xFF)==0)){ +// HDLDeviceManager.handle(sendDatas,Configuration.GET_LOGIC_INFO); +// } + + + + if (command == Configuration.AUDIO_CTRL_READ_COMMAND + || command == Configuration.AUDIO_CTRL_READ_BACK_COMMAND + || command == Configuration.MUSIC2_COMMAND + || command == Configuration.MUSIC3_COMMAND + || command == Configuration.AUDIO_MenuPlay_INSTRUCTION_COMMAND + || command == Configuration.AUDIO_MenuPlay_INSTRUCTION_BACK_COMMAND + ) { + //澶勭悊鍚戝線鐨勯煶涔愭ā鍧� + new Thread(new Runnable() { + @Override + public void run() { + EventBus.getDefault().post(new ThirdPartyBgmInfoEvent(receiveBytes)); + try { + DatagramSocket socket6001 = new DatagramSocket(); + java.net.InetAddress inetAddress = InetAddress.getByName("127.0.0.1"); + DatagramPacket packet = new DatagramPacket( + receiveBytes, + receiveBytes.length, inetAddress + , 6001); + socket6001.send(packet); + socket6001.close(); + } catch (Exception e) { + HDLLog.info( "HDL 鍙戦�佸懡浠ゅけ璐�:" + e); + } + } + }).start(); + } + } + +// public static void sendTestCMD(final byte[] sendBytes, final int port) { +// +// +// new Thread(new Runnable() { +// +// @Override +// public void run() { +// +// try { +// java.net.InetAddress address = InetAddress.getByName(NetWorkUtil.getLocalBroadCast()); +// DatagramPacket packet = new DatagramPacket( +// sendBytes, +// sendBytes.length, +// address, port); +// DatagramSocket socket = new DatagramSocket(); +// socket.send(packet); +// String command = ""; +// for(int i = 0;i<sendBytes.length;i++){ +// command += (sendBytes[i]& 0xff)+","; +// } +//// HDLLog.info( "HDL Debug----> 鍙戦�佸懡浠わ細"+command); +// } catch (IOException e) { +// HDLLog.info( "HDL Debug---->娴嬭瘯鍙戦�佸懡浠ゅけ璐�"); +// } +// } +// }).start(); +// } + + /** + * 鍒ゆ柇鏄惁涓篐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; + } + +} + + diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLZigbeeMqtt.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLZigbeeMqtt.java new file mode 100644 index 0000000..2495919 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLZigbeeMqtt.java @@ -0,0 +1,76 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Core; + +import android.util.Log; + + +import org.eclipse.paho.client.mqttv3.MqttClient; +import org.eclipse.paho.client.mqttv3.MqttConnectOptions; +import org.eclipse.paho.client.mqttv3.MqttDeliveryToken; +import org.eclipse.paho.client.mqttv3.MqttException; +import org.eclipse.paho.client.mqttv3.MqttMessage; +import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Callback.PushCallback; +import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; + + +public class HDLZigbeeMqtt { + + private static final String clientid = "HDLZigbeeDriver"; + private static MqttClient client; + private static boolean isCancel = false; + public static void setIsCancel(boolean isCancel) { + HDLZigbeeMqtt.isCancel = isCancel; + } + + + /** + * 杩炴帴mqtt + */ + public static void connect1(String host) { + try { + client = new MqttClient("tcp://"+host+":1883", clientid, new MemoryPersistence()); + MqttConnectOptions options = new MqttConnectOptions(); + options.setCleanSession(false); + options.setUserName("admin"); + options.setPassword("password".toCharArray()); + //璁剧疆鑷姩閲嶈繛 + options.setAutomaticReconnect(true); + // 璁剧疆瓒呮椂鏃堕棿 + options.setConnectionTimeout(10); + // 璁剧疆浼氳瘽蹇冭烦鏃堕棿 + options.setKeepAliveInterval(20); + PushCallback pushCallback = new PushCallback(); + pushCallback.setHost(host); + client.setCallback(pushCallback); + client.connect(options); + if (isCancel){ + client.close(); + isCancel = false; + } + } catch (MqttException e) { + e.printStackTrace(); + } + } + + /** + * 鍙戦�乵qtt淇℃伅 + */ + public static void sendMqttData1(String topic, String json) { + HDLLog.info("send Mqtt to gateway:"+json); + Log.d("111133", "sendMqttData1: "+json); + try { + MqttMessage message = new MqttMessage(); + message.setQos(2); + message.setRetained(false); + message.setPayload(json.getBytes()); + MqttDeliveryToken token = client.getTopic(topic).publish(message); + token.waitForCompletion(); + Log.d("111133", "宸茬粡鍙戦��"); + HDLLog.info("message is published completely!"); + } catch (MqttException e) { + Log.d("111133", "sendMqttData1: "+e.getMessage()); + HDLLog.info("鍙戦�乵qtt淇℃伅鍑洪敊"); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HandleSearch.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HandleSearch.java new file mode 100644 index 0000000..04c7bab --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HandleSearch.java @@ -0,0 +1,817 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Core; + +import android.content.Context; +import android.util.Log; +import android.widget.Toast; + +import com.hdl.sdk.hdl_core.Config.Configuration; +import com.hdl.sdk.hdl_core.Config.ZigbeeDeviceID; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.DevicesData; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.RemarkTimes; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.SearchCountBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeDeviceListBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeDeviceSaveBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeGatewayInfoBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeSceneListBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeSceneSaveBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Callback.PushCallback; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DevicesInfoEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.ZigbeeDeviceInfoEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Parser.DeviceParser; +import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; +import com.hdl.sdk.hdl_core.Util.NetUtil.NetWorkUtil; +import com.hdl.sdk.hdl_core.Util.SPUtil.SPUtils; + +import org.greenrobot.eventbus.EventBus; + +import java.sql.Time; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.Timer; +import java.util.TimerTask; + + +public class HandleSearch { + public static boolean isSearching = false; + 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 + private static Timer remarkTimer = null;//鎼滅储澶囨敞Timer + private static Timer refreshTimer = null; + private boolean isZigbee;//寮�鏀緕igbee瀹跺眳閫夋嫨 + + 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 List<ZigbeeDeviceSaveBean> zigbeeDeviceSaveBeans = new ArrayList<>();//璁惧鍒楄〃 + private static List<ZigbeeSceneSaveBean> zigbeeSceneSaveBeans = new ArrayList<>();//璁惧鍦烘櫙鍒楄〃 + private static Context mContext; + + /** + * 閰掑簵鎼滅储 + * <p> + * <p> + * 杩欐柟娉曟殏鏃朵笉鎻愪緵锛岃幏鍙栧娉ㄥ綋涓篃娌℃湁澶勭悊姝ょ被鍨嬨�� + * <p> + * 鑾峰彇Rcu ip鍦板潃 + */ +// private static void getRcuIp() { +// isGetRcuIp = true; +// HDLUdpCore.closeMulticast6000(); +// HDLUdpCore.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.info("鎼滅储鍒扮殑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.info("寮�濮嬪灞呭崗璁悳绱�"); +// 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); + } + + /** + * 瀹跺眳鎼滅储 + * 鑾峰彇Bus妯″潡璁惧 isZigbee鏍囨敞杩涘叆zigbee妯″紡 + */ + public static void getHomeDevices(final Context context, boolean isZigbee) { + if (isZigbee){ + HDLUdpCore.closeSocket6008(); + HDLUdpCore.closeSocket6000(); + if (HDLDeviceManager.devicesDataList != null){ + HDLDeviceManager.devicesDataList.clear(); + } + mContext = context; + HDLZigbeeMqtt.setIsCancel(true); + PushCallback.setIsGateway(true); + //SearchZigbeeGateway.release(); + HDLCommandText.reSearch(); + searchGateways(context); + }else { + SPUtils.setParam(context, SPUtils.KEY_RCU_IP_, ""); + curSearchMode = GET_BUS_DEVICES; + rcuIp = ""; + searchDevices(GET_BUS_DEVICES, SEARCH_BROACAST, Configuration.PORT);//瀹跺眳鎼滅储 + } + } + + public static void reSearch(){ + HDLZigbeeMqtt.setIsCancel(true); + HDLCommandText.reSearch(); + searchGateways(mContext); + } + + /** + * 鎼滅储zigbee缃戝叧 + */ + private static void searchGateways(final Context context){ + new Thread(new Runnable() { + @Override + public void run() { + SearchZigbeeGateway.sendSearchGateway(new SearchZigbeeGateway.OnSearchListener() { + @Override + public void onSuccess(final List<ZigbeeGatewayInfoBean> zigbeeGatewayInfoBeanList) { + final int size = zigbeeGatewayInfoBeanList.size(); + Log.d("11113", "缃戝叧鏁伴噺涓�: "+size); + if (zigbeeDeviceSaveBeans != null){ + zigbeeDeviceSaveBeans.clear(); + } + if (zigbeeSceneSaveBeans != null){ + zigbeeSceneSaveBeans.clear(); + } + if (zigbeeGatewayInfoBeanList.size() != 0){ + searchZigbeeDevices(context,zigbeeGatewayInfoBeanList, zigbeeGatewayInfoBeanList.get(0).getIpAddress(), + zigbeeGatewayInfoBeanList.get(0).getGatewayId(),0,size); + + }else { + HDLLog.info("鎼滀笉鍒扮綉鍏宠锛屽啀鎼滅储"); + } + } + + @Override + public void onEorror(Exception e) { + HDLLog.info("鎼滅储缃戝叧澶辫触"+e.toString()); + } + + }); + } + }).start(); + } + + /** + * 鎼滅储鎵�鏈夌綉鍏崇殑璁惧 + */ + private static void searchZigbeeDevices(Context context,final List<ZigbeeGatewayInfoBean> zigbeeGatewayInfoBeanList,final String ipAddr,final String gatewayId,final int subnetId,final int gatewaySize){ + HDLCommandText.initData(); + HDLZigbeeMqtt.connect1(ipAddr); + HDLCommandText hdlCommandText = new HDLCommandText(); + hdlCommandText.setIpAddr(ipAddr); + HDLZigbeeMqtt.sendMqttData1(Configuration.SEARCH_SCENE,Configuration.SCENE_JSON);//鎼滅储璇ョ綉鍏充笅鎵�鏈夌殑鍦� + new Thread(new Runnable() { + @Override + public void run() { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }).start(); + HDLZigbeeMqtt.sendMqttData1(Configuration.SEARCH_DEVICE,Configuration.SEARVH_JSON);//鎼滅储璇ョ綉鍏充笅鎵�鏈夎澶� + handleDeviceCallbackData(context,zigbeeGatewayInfoBeanList, ipAddr, gatewayId,subnetId,gatewaySize); + } + + private static void handleDeviceCallbackData(final Context context, final List<ZigbeeGatewayInfoBean> zigbeeGatewayInfoBeanList, final String ipAddr, final String gatewayId, final int subnetId, final int gatewaySize) { + HDLCommandText.handleDeviceData(new HDLCommandText.DataCallBack() { + @Override + public void onSuccess(List<ZigbeeDeviceListBean> zigbeeDeviceListBeans, ZigbeeSceneListBean zigbeeSceneListBean) { + Log.d("11113", "浼犺緭鐨勬暟鎹暟閲�: "+zigbeeDeviceListBeans.size()); + Log.d("11113", "subnetId: "+subnetId); + Log.d("11113", "gatewaySize: "+gatewaySize); + Log.d("11113", "浼犺緭杩囨潵鍦烘櫙鐨勬暟閲�: "+zigbeeSceneListBean.getData().getScenesSum()); + //澶勭悊璁惧鏁版嵁 + for (int i = 0; i < zigbeeDeviceListBeans.size(); i++){ + Log.d("11113", "handleDeviceCallbackData: 鎵ц鍒拌繖"+i); + ZigbeeDeviceSaveBean objectBeans = new ZigbeeDeviceSaveBean() ; + objectBeans.setIpAddress(ipAddr); + objectBeans.setGatewayId(gatewayId); + Log.d("11113", "setGatewayId: "+gatewayId); + objectBeans.setmSubnetID(subnetId);//鏍囨敞瀛愮綉鍙凤紝涔熷氨鏄綉鍏� + objectBeans.setDevice_ID(zigbeeDeviceListBeans.get(i).getDevice_ID()); + objectBeans.setDeviceAddr(zigbeeDeviceListBeans.get(i).getDeviceAddr()); + objectBeans.setDeviceName(zigbeeDeviceListBeans.get(i).getData().getDeviceName()); + objectBeans.setEpoint(zigbeeDeviceListBeans.get(i).getEpoint()); + objectBeans.setMacName(zigbeeDeviceListBeans.get(i).getData().getMacName()); + objectBeans.setInClusterList(zigbeeDeviceListBeans.get(i).getData().getInClusterList()); + zigbeeDeviceSaveBeans.add(objectBeans); + } + //澶勭悊鍦烘櫙鏁版嵁 + if (zigbeeSceneListBean.getData().getScenesSum() != 0){ + for (int i = 0 ; i < zigbeeSceneListBean.getData().getScenesSum(); i++){ + ZigbeeSceneSaveBean zigbeeSceneSaveBean = new ZigbeeSceneSaveBean(); + zigbeeSceneSaveBean.setIpAddr(ipAddr); + zigbeeSceneSaveBean.setSubnetId(subnetId); + zigbeeSceneSaveBean.setScenesId(zigbeeSceneListBean.getData().getScenesLists().get(i).getScenesId()); + zigbeeSceneSaveBean.setScenesName(zigbeeSceneListBean.getData().getScenesLists().get(i).getScenesName()); + zigbeeSceneSaveBean.setIsOpen(zigbeeSceneListBean.getData().getScenesLists().get(i).getIsOpen()); + zigbeeSceneSaveBeans.add(zigbeeSceneSaveBean); + } + } + //閬嶅巻瀹屽啀娆″彂璧锋悳绱� + if (gatewaySize > 1 && subnetId != gatewaySize-1){//缃戝叧涓轰袱涓� + searchZigbeeDevices(context,zigbeeGatewayInfoBeanList, zigbeeGatewayInfoBeanList.get(1).getIpAddress(), + zigbeeGatewayInfoBeanList.get(1).getGatewayId(),1,gatewaySize); + } +// else if (gatewaySize > 2 && subnetId != gatewaySize-1 && subnetId != 1){//缃戝叧涓轰笁涓� +// searchZigbeeDevices(context,zigbeeGatewayInfoBeanList, zigbeeGatewayInfoBeanList.get(2).getIpAddress(), +// zigbeeGatewayInfoBeanList.get(2).getGatewayId(),2,gatewaySize); +// } + else { + handleZigbee2Bus(context,zigbeeSceneSaveBeans); + } + } + }); + } + //鏂板缓瀵瑰簲鐨凚US鏁版嵁 + private static void handleZigbee2Bus( Context context,List<ZigbeeSceneSaveBean> zigbeeSceneSaveBeans){ + for (int i = 0; i < zigbeeDeviceSaveBeans.size(); i++){ + Log.d("11113", "handleZigbee2Bus: "+i); + int deviceId = zigbeeDeviceSaveBeans.get(i).getDevice_ID(); + int mSubnetID = zigbeeDeviceSaveBeans.get(i).getmSubnetID(); + int mChannelNum = zigbeeDeviceSaveBeans.get(i).getEpoint(); + String mChannelRamark = zigbeeDeviceSaveBeans.get(i).getDeviceName(); + String mparentRemarks = zigbeeDeviceSaveBeans.get(i).getMacName(); + if (deviceId == ZigbeeDeviceID.OnOffOutput){ + //缁х數鍣� + DeviceParser.addDevicesListWithoutSearching(Configuration.LIGTH_BIG_TYPE, 1, + mSubnetID, i, mChannelNum, mChannelRamark,"缁х數鍣�("+ mparentRemarks+")",false); + zigbeeDeviceSaveBeans.get(i).setDeviceMark(i); + } + if (deviceId == ZigbeeDeviceID.DimmableLight){ + //璋冨厜璁惧 + DeviceParser.addDevicesListWithoutSearching(Configuration.LIGTH_BIG_TYPE, 0, + mSubnetID, i, mChannelNum, mChannelRamark, "璋冨厜璁惧锛�"+mparentRemarks+")",false); + zigbeeDeviceSaveBeans.get(i).setDeviceMark(i); + } + if (deviceId == ZigbeeDeviceID.WindowCoveringDevice){ + //绐楀笜璁惧 + DeviceParser.addDevicesListWithoutSearching(Configuration.CURTAIN_BIG_TYPE,0, + mSubnetID, i, mChannelNum, mChannelRamark, "绐楀笜璁惧("+mparentRemarks+")",false); + zigbeeDeviceSaveBeans.get(i).setDeviceMark(i); + } + if (deviceId == ZigbeeDeviceID.Thermostat){ + //鎭掓俯鍣紙绌鸿皟锛� + DeviceParser.addDevicesListWithoutSearching(Configuration.AIR_BIG_TYPE,0, + mSubnetID,i,mChannelNum,mChannelRamark,"绌鸿皟璁惧("+mparentRemarks+")",false); + zigbeeDeviceSaveBeans.get(i).setDeviceMark(i); + } + if (deviceId == ZigbeeDeviceID.AirPanel){ + //鏂伴 + DeviceParser.addDevicesListWithoutSearching(Configuration.FRESH_AIR_BIG_TYPE,0, + mSubnetID,i,mChannelNum,mChannelRamark,"鏂伴璁惧("+mparentRemarks+")",false); + zigbeeDeviceSaveBeans.get(i).setDeviceMark(i); + } + } + //鐢熸垚鍦烘櫙鏁版嵁 + if (zigbeeSceneSaveBeans.size()!=0){ + for (int i = 0 , k = 200; i < zigbeeSceneSaveBeans.size(); i++,k++){ + zigbeeSceneSaveBeans.get(i).setDeviceid(k); + DeviceParser.addScenesDevicesListWithoutSearching(zigbeeSceneSaveBeans.get(i).getSubnetId(), k, + zigbeeSceneSaveBeans.get(i).getScenesId(), zigbeeSceneSaveBeans.get(i).getScenesId(), + zigbeeSceneSaveBeans.get(i).getScenesName(), zigbeeSceneSaveBeans.get(i).getScenesName(), + false); + } + } + DeviceParser.addDevicesListWithoutSearching(Configuration.GLOBAL_LOGIC_BIG_TYPE,0, + 30,254,20,"缁撴潫鏍囧織锛堟棤浣滅敤锛�","缁撴潫鏍囧織锛堟棤浣滅敤锛�",true); + //瀛樺偍鍦烘櫙鏁版嵁 + Log.d("11115", "鏁版嵁澶у皬涓�: "+zigbeeSceneSaveBeans.size()); + SPUtils.setZigbeeSceneSaveBean(context,SPUtils.KEY_ZIGBEE_SCENE_IP,zigbeeSceneSaveBeans); + //瀛樺偍璁惧鏁版嵁 + SPUtils.setZigbeeDeviceSaveBean(context,SPUtils.KEY_ZIGBEE_IP,zigbeeDeviceSaveBeans); + EventBus.getDefault().post(new ZigbeeDeviceInfoEvent(zigbeeDeviceSaveBeans, true)); + if (zigbeeDeviceSaveBeans != null){ + zigbeeDeviceSaveBeans.clear(); + } + } + + + + + + + /** + * 鍒濆鍖栨悳绱� + * @param searchMode 鎼滅储妯″紡 + * @param baseSearchType 鍩虹鎼滅储绫诲瀷 + * @param port + * @param + */ + private static void searchDevices(final int searchMode, final int baseSearchType, final int port ) { + isSearching = true; + isRefreshAllDevicesState = false; + String newIpAddress = ""; + switch (searchMode) { + case GET_BUS_DEVICES: + HDLUdpCore.closeSocket6008(); + HDLUdpCore.init6000(); + newIpAddress = NetWorkUtil.getLocalBroadCast(); + break; + case GET_RCU_DEVICES: + HDLUdpCore.closeSocket6000(); + HDLUdpCore.init6008(); + newIpAddress = rcuIp; + break; + default: + break; + } + + final String secondSearchAddress = newIpAddress;//浠呬綔涓哄唴閮ㄧ被闇�瑕佸畾涔変负final + + 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.info("Rcu璁惧鎼滅储瓒呮椂"); +// searchDevices(GET_BUS_DEVICES, SEARCH_BROACAST, Configuration.PORT);//瀹跺眳鎼滅储 + EventBus.getDefault().post(new DevicesInfoEvent(false));//涓嶈繘琛屽灞呮悳绱紝鐩存帴鍋滄 + break; + case GET_BUS_DEVICES: + //瀹跺眳鍗忚鎼滅储瓒呮椂 + HDLLog.info("瀹跺眳璁惧鎼滅储瓒呮椂"); + 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.info("鏈夋柊璁惧闃绘柇鍙戦�佹悳绱㈠懡浠�"); + } + if (HDLDeviceManager.realDevicesDataList.size() == 0) { + baseSearch(baseSearchType, port); + } else { + curDevSize = HDLDeviceManager.realDevicesDataList.size(); + + HDLLog.info("鏈夋柊璁惧锛岀户缁瓑寰�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.info("娌℃湁鏀跺埌鏂拌澶囷紝鍙戦�佺 " + (bean.getCount() + 1) + " 娆℃悳绱㈠懡浠�"); + secondTimeSearch(random1, random2, HDLDeviceManager.realDevicesDataList, secondSearchAddress, port); + } else { + if (searchTimer != null) { + searchTimer.cancel(); + searchTimer.purge(); + searchTimer = null; + } + if (searchTwiceTimer != null) { + searchTwiceTimer.cancel(); + searchTwiceTimer.purge(); + searchTwiceTimer = null; + } + + isSearching = false; + HDLLog.info("寮�濮嬭幏鍙栨瘡涓ā鍧楃殑鍥炶矾鐘舵�佷笌澶囨敞"); + 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; + HDLDeviceManager.devicesDataList.clear(); + HDLDeviceManager.realDevicesDataList.clear(); + HDLDeviceManager.listRemarks.clear(); + curDevSize = 0; + +// 鍙戦�佺涓�娆℃悳绱㈠懡浠� + switch (type) { + case SEARCH_POINT_TO_POINT: + HDLLog.info("鍙戦�佺涓�娆CU鎼滅储"); + HDLCommand.cusSendCommand(Configuration.DEVICES_SEARCH_COMMAND, + 255, 255, new byte[]{random1, random2}, port, rcuIp); + break; + case SEARCH_BROACAST: + HDLLog.info("鍙戦�佺涓�娆″灞呮悳绱�"); + HDLCommand.cusSendCommand(Configuration.DEVICES_SEARCH_COMMAND, + 255, 255, new byte[]{random1, random2}, + port, NetWorkUtil.getLocalBroadCast()); + break; + case SEARCH_MULTICAST: + HDLCommand.cusSendMulticastCommand(Configuration.DEVICES_SEARCH_COMMAND, + 255, 255 + , new byte[]{random1, random2}, port); + break; + default: + break; + } + + + } + + /** + * 鍙戦�佺浜屾鎼滅储 + * + * @param arg1 闅忔満鏁�1 + * @param arg2 闅忔満鏁�2 + * @param devicesDataList 鎵�鏈夎澶囦俊鎭泦 + * @param port 绔彛鍙� + */ + public static void secondTimeSearch(byte arg1, byte arg2, List<DevicesData> devicesDataList, String ipAddress, int port) { + if (devicesDataList == null || devicesDataList.size() == 0) { + return; + } + int devicesCount = 32; + int count = devicesDataList.size() / devicesCount; + int remainder = devicesDataList.size() % devicesCount; + 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.info("绗簩娆″彂閫佺殑鎼滅储鏁版嵁锛�" + sendData); + HDLCommand.cusSendCommand(Configuration.DEVICES_SEARCH_COMMAND, 255, 255, bytes, port, ipAddress); + } + } + + /** + * 杩斿洖璁惧鍒楄〃 + * 2019-10-14 + */ + public static void OnDeviceListGetSuccessCallBack() { +// 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.info(device); +// } + + EventBus.getDefault().post(new DevicesInfoEvent(HDLDeviceManager.devicesDataList, true)); + /**鎼滅储璁惧鎴愬姛锛屾墽琛屼竴娆′繚瀛樺埌鏈湴*/ + HDLDeviceManager.saveDevicesDataList(); + } + + +// /** +// * 杩斿洖璁惧鍒楄〃 +// */ +// 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.info(device); +// } +// +//// HDLUdpCore.sendTestCMD(debugBytes, HDLTest.SEND_TEST_PORT); +// EventBus.getDefault().post(new DevicesInfoEvent(HDLDeviceManager.devicesDataList, true)); +// +// +// } + + /** + * 鍒锋柊鎵�鏈夎澶囩姸鎬佸拰澶囨敞 + * 2019-10-15 + */ + public static void refreshAllDevicesStateAndRemarks() { + + if (isSearching) { + isRefreshAllDevicesState = false; + return; + } + isRefreshAllDevicesState = true; + for (int i = 0; i < HDLDeviceManager.listRemarks.size(); i++) { + HDLDeviceManager.listRemarks.get(i).setCallBack(false); + } + getDevRemarks(); + } + + /** + * 1S + * @param delayTime 鍗曚綅绉� + */ + public static void refreshAllDevicesState(int delayTime) { + 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 * delayTime); + } + + + /** + * 鑾峰彇澶囨敞 + * + * @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: 鍒锋柊瀹屾瘯鍙兘瑕佸仛鏌愪簺浜嬫儏 + HDLLog.info("鍒锋柊璁惧鐘舵�佸畬姣�"); + isRefreshAllDevicesState = false; + HandleSearch.OnDeviceListGetSuccessCallBack(); +// /**鍒锋柊璁惧鐘舵�佸畬姣曪紝鎵ц涓�娆′繚瀛樺埌鏈湴*/ +// HDLDeviceManager.saveDevicesDataList(); + } + + 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 = HDLCommand.getLocalBroadCastIp();//2019-10-16 +// ipAddress = HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getIpAddress(); + port = Configuration.PORT; + break; + } + HDLLog.info("----->鍙戦�佽幏鍙栧娉ㄥ懡浠ゃ�傚叡" + HDLDeviceManager.listRemarks.size() + "涓ā鍧椼�傜" + + newPos + "涓ā鍧椼�傜 " + (HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getChannelNum()) + + " 鍥炶矾锛屽瓙缃戝彿锛�" + HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getDeviceSubnetID() + + "锛岃澶囧彿锛�" + HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getDeviceDeviceID() + + " 绗� " + remarkTimes.getCount() + " 娆�" + " ip = " + ipAddress); + 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()}, + port, ipAddress); + } + } 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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/SearchZigbeeGateway.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/SearchZigbeeGateway.java new file mode 100644 index 0000000..c7c367d --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/SearchZigbeeGateway.java @@ -0,0 +1,166 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Core; + +import android.util.Log; + +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.util.ArrayList; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; + + + +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeGatewayInfoBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Callback.PushCallback; +import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; +import com.hdl.sdk.hdl_core.Util.NetUtil.NetWorkUtil; +import com.hdl.sdk.hdl_core.Util.TransformUtil.StringUtil; + +import org.eclipse.paho.client.mqttv3.MqttClient; +import org.eclipse.paho.client.mqttv3.MqttConnectOptions; +import org.eclipse.paho.client.mqttv3.MqttException; +import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; + +public class SearchZigbeeGateway { + private static final String TAG = "SearchZigbeeGateway"; + public static List<ZigbeeGatewayInfoBean> zigbeeGatewayInfoBeanList = new ArrayList<>(); + public static Timer searchTimer = null; + private static DatagramSocket datagramSocket; // 鏁版嵁鎶ュ鎺ュ瓧 + private static boolean isStop = false; + public interface OnSearchListener{ + void onSuccess( List<ZigbeeGatewayInfoBean> zigbeeGatewayInfoBeanList); + void onEorror(Exception e); + } + + public static void release() { + if (datagramSocket != null){ + isStop = true; + datagramSocket.disconnect(); + datagramSocket = null; + } + } + + public static void sendSearchGateway(final OnSearchListener onSearchListener) { + if (searchTimer != null) { + searchTimer.cancel(); + searchTimer.purge(); + searchTimer = null; + } + zigbeeGatewayInfoBeanList.clear(); + final ZigbeeGatewayInfoBean zigbeeGatewayInfoBean = new ZigbeeGatewayInfoBean(); + zigbeeGatewayInfoBean.setCount(0); + searchTimer = new Timer(); + searchTimer.schedule(new TimerTask() { + @Override + public void run() { + if (zigbeeGatewayInfoBean.getCount() < 20) { + zigbeeGatewayInfoBean.setCount(zigbeeGatewayInfoBean.getCount() + 1); + try { + byte[] sendBytes = new byte[44]; + sendBytes[0] = (byte) 0xFE; + sendBytes[1] = 0x29; + sendBytes[2] = 0; + sendBytes[3] = 0; + sendBytes[4] = 0; + sendBytes[5] = 0; + sendBytes[6] = 0; + //鑾峰彇鎵�鏈夌綉鍏筹紙鏃犻渶houseID妯″紡锛夛紝鍚庨潰瑕佹敼 + sendBytes[7] = 0x67; + sendBytes[8] = 0x65; + sendBytes[9] = 0x74; + sendBytes[10] = 0x61; + sendBytes[11] = 0x6c; + sendBytes[12] = 0x6c; + sendBytes[13] = 0x67; + sendBytes[14] = 0x77; + for (int i = 15; i<sendBytes.length-1;i++){ + sendBytes[i] = 0; + } + sendBytes[sendBytes.length - 1] = 0x02; + //Log.d(TAG, "sendBytes: "+StringUtil.ByteArrToHex(sendBytes,0,sendBytes.length)); + InetAddress address = InetAddress.getByName(NetWorkUtil.getLocalBroadCast()); + DatagramPacket packet = new DatagramPacket( + sendBytes, + sendBytes.length, + address, 7624); + datagramSocket= new DatagramSocket(); + datagramSocket.send(packet); + + byte[] receiveBytes = new byte[1024]; + DatagramPacket dataPacket = new DatagramPacket(receiveBytes, receiveBytes.length); + datagramSocket.receive(dataPacket); + //鏄惁涓荤綉鍏�-01涓轰富缃戝叧-00涓轰粠缃戝叧 + String IsDomain = StringUtil.Byte2Hex(dataPacket.getData()[44]); + int headLength = 1 + 2 + 4 + 36 + 1 + 1 + 4 ; + if (receiveBytes.length > headLength) { + //缃戝叧鍚嶇О闀垮害 + String str = StringUtil.Byte2Hex(dataPacket.getData()[49]); + int GwNameLength = Integer.parseInt(str,16); + + //缃戝叧鍚嶇О + byte[] gwnamebyte = new byte[GwNameLength]; + for (int i = 0 ;i< GwNameLength ; i++){ + gwnamebyte[i] = dataPacket.getData()[i+50]; + } + String GwName =new String(gwnamebyte,0,gwnamebyte.length); + + //缃戝叧id闀垮害 + String str1 = StringUtil.Byte2Hex(dataPacket.getData()[50+GwNameLength]); + int GwIdLength = Integer.parseInt(str1,16); + + //鑾峰彇缃戝叧id + byte[] gatewayId = new byte[GwIdLength]; + for (int i = 0 ;i< GwIdLength ; i++){ + gatewayId[i] = dataPacket.getData()[i+51+GwNameLength]; + } + + if (gatewayId.length > 1) { + String stringGateWayId = new String(gatewayId,0,gatewayId.length); + Log.d(TAG, "缃戝叧id: "+stringGateWayId); + + ZigbeeGatewayInfoBean zigbeeGatewayInfoBean = new ZigbeeGatewayInfoBean(); + zigbeeGatewayInfoBean.setGatewayId(stringGateWayId); + zigbeeGatewayInfoBean.setIpAddress(dataPacket.getAddress().getHostAddress()); + if (IsDomain.equals("01")){ + zigbeeGatewayInfoBean.setDomain(true); + }else { + zigbeeGatewayInfoBean.setDomain(false); + } + zigbeeGatewayInfoBean.setGatewayName(GwName); + boolean isExit = false; + for (int i = 0; i < zigbeeGatewayInfoBeanList.size(); i++) { + if (zigbeeGatewayInfoBeanList.get(i).getGatewayId() + .equals(zigbeeGatewayInfoBean.getGatewayId())) { + isExit = true; + break; + } + } + if (!isExit) { + zigbeeGatewayInfoBeanList.add(zigbeeGatewayInfoBean); + Log.d(TAG, "addList:鎴愬姛娣诲姞 "); + } + } + } + datagramSocket.close(); + } catch (Exception e) { + Log.d(TAG, "run: "+e.toString()); + e.printStackTrace(); + datagramSocket.close(); + onSearchListener.onEorror(e); + } + } else { + if (searchTimer != null) { + //鎵ц瀹屾悳绱㈠悗鍒拌繖 + searchTimer.cancel(); + searchTimer.purge(); + searchTimer = null; + onSearchListener.onSuccess(SearchZigbeeGateway.zigbeeGatewayInfoBeanList); + } + } + } + }, 1, 500); + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/AirFeedBackEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/AirFeedBackEvent.java new file mode 100644 index 0000000..7440dae --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/AirFeedBackEvent.java @@ -0,0 +1,27 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + + +import com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/AppliancesInfoEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/AppliancesInfoEvent.java new file mode 100644 index 0000000..98be8f2 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/AppliancesInfoEvent.java @@ -0,0 +1,21 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + + +import com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/AudioInfoEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/AudioInfoEvent.java new file mode 100644 index 0000000..70419ae --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/AudioInfoEvent.java @@ -0,0 +1,69 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + + +import com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/BgmInfoEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/BgmInfoEvent.java new file mode 100644 index 0000000..db01741 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/BgmInfoEvent.java @@ -0,0 +1,52 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/CurtainFeedBackEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/CurtainFeedBackEvent.java new file mode 100644 index 0000000..8c41c58 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/CurtainFeedBackEvent.java @@ -0,0 +1,28 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + + +import com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/DeviceFeedbackEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/DeviceFeedbackEvent.java new file mode 100644 index 0000000..e17cd37 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/DeviceFeedbackEvent.java @@ -0,0 +1,18 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/DeviceStateEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/DeviceStateEvent.java new file mode 100644 index 0000000..403a280 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/DeviceStateEvent.java @@ -0,0 +1,28 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + + +import com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/DevicesInfoEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/DevicesInfoEvent.java new file mode 100644 index 0000000..d8000dc --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/DevicesInfoEvent.java @@ -0,0 +1,33 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + + +import com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/EventCode.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/EventCode.java new file mode 100644 index 0000000..568171d --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/EventCode.java @@ -0,0 +1,10 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + +/** + * Created by JLChen on 2019/7/15 + */ +public class EventCode { + public static final int SUCCESS = 0; + public static final int FAILURE = -1;//澶辫触瓒呮椂 + public static final int DATAEMPTY = -2;//鏁版嵁涓虹┖ +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/FreshAirFeedBackEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/FreshAirFeedBackEvent.java new file mode 100644 index 0000000..1f978c0 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/FreshAirFeedBackEvent.java @@ -0,0 +1,27 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + +import com.hdl.sdk.hdl_core.HDLAppliances.HDLFreshAir.FreshAirBackInfo; + +/** + * Created by JLChen on 2019/7/9 + */ +public class FreshAirFeedBackEvent { + FreshAirBackInfo mFreshAirBackInfo; + + boolean isSuccess; + + public FreshAirFeedBackEvent( FreshAirBackInfo freshAirBackInfo, boolean isSuccess){ + this.mFreshAirBackInfo = freshAirBackInfo; + this.isSuccess = isSuccess; + } + + public FreshAirBackInfo getFreshAirBackInfo() { + return mFreshAirBackInfo; + } + + public boolean isSuccess() { + return isSuccess; + } + + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/GeothermalFeedBackEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/GeothermalFeedBackEvent.java new file mode 100644 index 0000000..a372f6c --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/GeothermalFeedBackEvent.java @@ -0,0 +1,41 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + +import com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.GeothermalBackInfo; + +/** + * Created by JLChen on 2019/7/10 + * 鍦扮儹妯″潡 + */ +public class GeothermalFeedBackEvent { + GeothermalBackInfo mGeothermalBackInfo; +// boolean isSuccess; + + int mStatusID; + + public GeothermalFeedBackEvent( GeothermalBackInfo geothermalBackInfo, int mStatusID){ + this.mGeothermalBackInfo = geothermalBackInfo; + this.mStatusID = mStatusID; + } + + public GeothermalBackInfo getGeothermalBackInfo() { + return mGeothermalBackInfo; + } + + public int getStatusID() { + return mStatusID; + } + + +// public GeothermalFeedBackEvent( GeothermalBackInfo geothermalBackInfo, boolean isSuccess){ +// this.mGeothermalBackInfo = geothermalBackInfo; +// this.isSuccess = isSuccess; +// } +// +// public GeothermalBackInfo getGeothermalBackInfo() { +// return mGeothermalBackInfo; +// } +// +// public boolean isSuccess() { +// return isSuccess; +// } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/HetDevicesCtrlEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/HetDevicesCtrlEvent.java new file mode 100644 index 0000000..7111fd0 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/HetDevicesCtrlEvent.java @@ -0,0 +1,16 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/LightFeedBackEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/LightFeedBackEvent.java new file mode 100644 index 0000000..309ca36 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/LightFeedBackEvent.java @@ -0,0 +1,28 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + + +import com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/LogicFeedBackEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/LogicFeedBackEvent.java new file mode 100644 index 0000000..67e6d49 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/LogicFeedBackEvent.java @@ -0,0 +1,28 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + + +import com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/MideaDevicesCtrlEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/MideaDevicesCtrlEvent.java new file mode 100644 index 0000000..a45a092 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/MideaDevicesCtrlEvent.java @@ -0,0 +1,16 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/RCUSaveEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/RCUSaveEvent.java new file mode 100644 index 0000000..cd6a09a --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/RCUSaveEvent.java @@ -0,0 +1,17 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/RcuIpListEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/RcuIpListEvent.java new file mode 100644 index 0000000..290636e --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/RcuIpListEvent.java @@ -0,0 +1,16 @@ +package com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/SceneInfoEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/SceneInfoEvent.java new file mode 100644 index 0000000..f4614ba --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/SceneInfoEvent.java @@ -0,0 +1,33 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + + +import com.hdl.sdk.hdl_core.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/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/ThirdPartyBgmInfoEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/ThirdPartyBgmInfoEvent.java new file mode 100644 index 0000000..ed67c0c --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/ThirdPartyBgmInfoEvent.java @@ -0,0 +1,14 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + +public class ThirdPartyBgmInfoEvent { + private byte[] bytes; + + public ThirdPartyBgmInfoEvent(byte[] bytes){ + this.bytes = bytes; + } + + + public byte[] getBytes() { + return bytes; + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/WarningInfoEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/WarningInfoEvent.java new file mode 100644 index 0000000..dffde70 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/WarningInfoEvent.java @@ -0,0 +1,17 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + +/** + * Created by Tommy on 2017/10/10. + */ + +public class WarningInfoEvent { + String warningType ; + + public WarningInfoEvent(String warningType){ + this.warningType = warningType; + } + + public String getWarningType() { + return warningType; + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/ZigbeeDeviceInfoEvent.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/ZigbeeDeviceInfoEvent.java new file mode 100644 index 0000000..5f918f6 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/ZigbeeDeviceInfoEvent.java @@ -0,0 +1,28 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeDeviceSaveBean; + +import java.util.List; + +public class ZigbeeDeviceInfoEvent { + public List<ZigbeeDeviceSaveBean> zigbeeDeviceSaveBeans; + public boolean isSuccess; + + + public ZigbeeDeviceInfoEvent(List<ZigbeeDeviceSaveBean> zigbeeDeviceSaveBeans,boolean isSuccess) { + this.zigbeeDeviceSaveBeans = zigbeeDeviceSaveBeans; + this.isSuccess = isSuccess; + } + public ZigbeeDeviceInfoEvent(boolean isSuccess){ + this.isSuccess = isSuccess; + } + + public boolean isSuccess() { + return isSuccess; + } + + public List<ZigbeeDeviceSaveBean> getZigbeeDeviceSaveBeans() { + return zigbeeDeviceSaveBeans; + } + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java new file mode 100644 index 0000000..91bc41d --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java @@ -0,0 +1,960 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.Parser; + +import com.hdl.sdk.hdl_core.Config.Configuration; +import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLLogic.LogicMode; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.DevicesData; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLDeviceManager; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HandleSearch; +import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; + +import java.util.ArrayList; +import java.util.List; + +import static com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLDeviceManager.devicesDataList; + +/** + * Created by djl on 2017/3/29. + */ + +public class DeviceParser { + + /** + * 澶勭悊瑙f瀽銆佽缃煇涓�鍥炶矾鐨勬墍鏈変俊鎭� + * + * @param addBytes + * @param port + * @param ipAddress + * @param devicesData + * @param parentRemarks + * @return 172.168.52.51 鍥轰欢鐗堟湰鍙�2018/08/29 + */ + public static boolean parse(byte[] addBytes, int port, String ipAddress, 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); + } + 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, port, ipAddress); + break; + case Configuration.CURTAIN_BIG_TYPE: + parseCurtainData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ipAddress); + break; + case Configuration.AIR_BIG_TYPE: + parseAirData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ipAddress); + break; + case Configuration.AUDIO_BIG_TYPE: + parseAudioData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ipAddress); + break; + case Configuration.LOGIC_BIG_TYPE: + parseLogicData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ipAddress); + break; + case Configuration.GLOBAL_LOGIC_BIG_TYPE: + parseGlobalLogicData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ipAddress); + break; + case Configuration.SENSOR_BIG_TYPE: + parseSensorData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ipAddress); + break; + //2019-07-08 鏂板鍦扮儹鍜屾柊椋庣被 + case Configuration.GEOTHERMAL_BIG_TYPE://鍦扮儹 + parseGeothermalData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ipAddress); + break; + case Configuration.FRESH_AIR_BIG_TYPE: + parseFreshAirData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ipAddress); + 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); + + } else { + HDLLog.info( "涓嶆槸瑕佹坊鍔犵殑璁惧锛氬ぇ绫伙細" + bigType + " 灏忕被锛�" + littleType); + } + } + } + if (isExitData && devicesData != null) { + devicesData.setAppliancesInfoList(appliancesInfoList); + } + return isExitData; + } + + + /** + * 鍒ゆ柇鏄惁鏀寔鐨勮澶囷紝鑻ヤ笉鏄敮鎸佽澶囧垯杩囨护鎺夈�� + * + * @param bigType + * @param littleType + * @return + */ + private static boolean isWantData(int bigType, int littleType) { +// HDLLog.info("isWantData锛歜igType锛�" + bigType + "littleType锛�" + 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: + isWant = true; + break; + default: + isWant = false; + break; + } + break; + case Configuration.SENSOR_BIG_TYPE: + if (littleType >= 0 && littleType <= 24) { + 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.GLOBAL_LOGIC_BIG_TYPE: + switch (littleType) { + case 0: + isWant = true; + break; + default: + isWant = false; + break; + } + break; + case Configuration.GEOTHERMAL_BIG_TYPE://20190711 鏂板 + switch (littleType) { + case Configuration.GEOTHERMAL_LITTLE_TYPE_0: + isWant = true; + break; + default: + isWant = false; + break; + } + break; + case Configuration.FRESH_AIR_BIG_TYPE: + switch (littleType) { + case Configuration.FRESH_AIR_LITTLE_TYPE_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); + } + } + + 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); + + + } + } + + + 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; + + + 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); + appliancesInfo.setPort(port); + appliancesInfo.setIpAddress(ipAddress); + + + } + + + } + + + /** + *鍦扮儹 + */ + private static void parseGeothermalData(int littleType, AppliancesInfo appliancesInfo, DevicesData devicesData, String parentRemarks, int channelNum, int port, String ipAddress) { + switch (littleType) { + case Configuration.GEOTHERMAL_LITTLE_TYPE_0: + appliancesInfo.setDeviceName("鍦扮儹妯″潡"); + appliancesInfo.setDeviceType(HDLApConfig.TYPE_GEOTHERMAL_MODULE); + break; +// case 1: +// appliancesInfo.setDeviceName("甯歌鍦扮儹闈㈡澘"); +// appliancesInfo.setDeviceType(HDLApConfig.TYPE_GEOTHERMAL_MODULE_PANEL); +// break; +// case 2: +// appliancesInfo.setDeviceName("甯I杩愮畻鐨勫湴鐑潰鏉�"); +// appliancesInfo.setDeviceType(HDLApConfig.TYPE_GEOTHERMAL_MODULE_PI); +// break; + default: + appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE); + break; + + } + if (devicesData != null) { + appliancesInfo.setChannelNum(channelNum); + appliancesInfo.setBigType(Configuration.GEOTHERMAL_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.GEOTHERMAL_MODULE_CTRL_COMMAND); + appliancesInfo.setCtrlBackCommand(Configuration.GEOTHERMAL_MODULE_CTRL_BACK_COMMAND); + appliancesInfo.setStateCommand(Configuration.GEOTHERMAL_MODULE_STATE_COMMAND); + appliancesInfo.setStateBackCommand(Configuration.GEOTHERMAL_MODULE_STATE_BACK_COMMAND); + +// if (littleType == 1) { +// appliancesInfo.setCtrlCommand(Configuration.GEOTHERMAL_MODULE_PANEL_CTRL_COMMAND); +// appliancesInfo.setCtrlBackCommand(Configuration.GEOTHERMAL_MODULE_PANEL_CTRL_BACK_COMMAND); +// appliancesInfo.setStateCommand(Configuration.GEOTHERMAL_MODULE_PANEL_STATE_COMMAND); +// appliancesInfo.setStateBackCommand(Configuration.GEOTHERMAL_MODULE_PANEL_STATE_BACK_COMMAND); +// } else if(littleType == 2) { +// appliancesInfo.setCtrlCommand(Configuration.GEOTHERMAL_MODULE_PI_CTRL_COMMAND); +// appliancesInfo.setCtrlBackCommand(Configuration.GEOTHERMAL_MODULE_PI_CTRL_BACK_COMMAND); +// appliancesInfo.setStateCommand(Configuration.GEOTHERMAL_MODULE_PI_STATE_COMMAND); +// appliancesInfo.setStateBackCommand(Configuration.GEOTHERMAL_MODULE_PI_STATE_BACK_COMMAND); +// +// } else { +// appliancesInfo.setCtrlCommand(Configuration.GEOTHERMAL_MODULE_CTRL_COMMAND); +// appliancesInfo.setCtrlBackCommand(Configuration.GEOTHERMAL_MODULE_CTRL_BACK_COMMAND); +// appliancesInfo.setStateCommand(Configuration.GEOTHERMAL_MODULE_STATE_COMMAND); +// appliancesInfo.setStateBackCommand(Configuration.GEOTHERMAL_MODULE_STATE_BACK_COMMAND); +// +// } + + + } + } + + /** + * 鏂伴绯荤粺 + */ + private static void parseFreshAirData(int littleType, AppliancesInfo appliancesInfo, DevicesData devicesData, String parentRemarks, int channelNum, int port, String ipAddress) { + switch (littleType) { + case 0: + appliancesInfo.setDeviceName("鏂伴绯荤粺妯″潡"); + appliancesInfo.setDeviceType(HDLApConfig.TYPE_FRESH_AIR); + break; + default: + appliancesInfo.setDeviceName(Configuration.UNKNOW_TYPE); + break; + } + + if (devicesData != null) { + appliancesInfo.setChannelNum(channelNum); + appliancesInfo.setBigType(Configuration.FRESH_AIR_BIG_TYPE); + appliancesInfo.setLittleType(littleType); + appliancesInfo.setCtrlCommand(Configuration.FRESH_AIR_CTRL_COMMAND); + appliancesInfo.setCtrlBackCommand(Configuration.FRESH_AIR_CTRL_BACK_COMMAND); + appliancesInfo.setStateCommand(Configuration.FRESH_AIR_STATE_COMMAND); + appliancesInfo.setStateBackCommand(Configuration.FRESH_AIR_STATE_BACK_COMMAND); + appliancesInfo.setDeviceSubnetID(devicesData.getSourceSubnetID()); + appliancesInfo.setDeviceDeviceID(devicesData.getSourceDeviceID()); + appliancesInfo.setParentRemarks(parentRemarks); + appliancesInfo.setPort(port); + appliancesInfo.setIpAddress(ipAddress); + + + } + } + + + /** + * + * @param bigType + * @param littleType + * @param mSubnetID + * @param mDeviceID + * @param parentRemarks + * @return + */ + public static DevicesData addDevicesManuallyWithoutSearchingAll(int bigType, int littleType, int mSubnetID, int mDeviceID, int port, 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, port, 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; + } + + private static AppliancesInfo getDevicesInfo(DevicesData devicesData, int bigType, int littleType, int curChannelNum, int port, String parentRemarks, String mRemarks){ + AppliancesInfo appliancesInfo = new AppliancesInfo(); + /**鏍规嵁绫诲埆锛岃祴鍊兼搷浣滅爜绛変竴浜涢噸瑕佷俊鎭�*/ + switch (bigType) { + case Configuration.LIGTH_BIG_TYPE: + parseLightData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ""); + break; + case Configuration.CURTAIN_BIG_TYPE: + parseCurtainData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ""); + break; + case Configuration.AIR_BIG_TYPE: + parseAirData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ""); + break; + case Configuration.AUDIO_BIG_TYPE: + parseAudioData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ""); + break; + case Configuration.LOGIC_BIG_TYPE: + parseLogicData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ""); + break; + case Configuration.GLOBAL_LOGIC_BIG_TYPE: + parseGlobalLogicData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ""); + break; + case Configuration.SENSOR_BIG_TYPE: + parseSensorData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ""); + break; + //2019-07-08 鏂板鍦扮儹鍜屾柊椋庣被 + case Configuration.GEOTHERMAL_BIG_TYPE://鍦扮儹 + parseGeothermalData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ""); + break; + case Configuration.FRESH_AIR_BIG_TYPE: + parseFreshAirData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, port, ""); + 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; + + } + + /**********************************************************浠ヤ笅浠g爜涓簔igbee璁惧鎴栧満鏅繑鍥炲搴擝us鐨勮浆鎹�*************************************************/ + /** + * 鑾峰彇鍒皕igbee璁惧鍚庣敓鎴愬搴旂殑bus璁惧 + * 娣诲姞璁惧鍥炶矾 + * 濡傛灉瀛樺湪鐩稿悓瀛愮綉鍙� 璁惧鍙凤紝鍒欏綋鎴愭贩鍚堟ā鍧楁坊鍔犲埌璇ュ洖璺笅锛屼笉瀛樺湪鍒欐柊娣诲姞妯″潡 + * @param bigType 澶х被 + * @param littleType 灏忕被 + * @param mSubnetID 瀛愮綉鍙� + * @param mDeviceID 璁惧鍙� + * @param mChannelNum 鍥炶矾鍙� + * @param mChannelRemark 鍥炶矾璁惧鍚嶇О + * @param parentRemarks 璁惧鍚嶇О + * @param bSaveAndCallBack 鏄惁椹笂淇濆瓨鏈湴骞朵笖鎺ㄩ�丏evicesInfoEvent 浜嬩欢 + * @return + */ + public static DevicesData addDevicesListWithoutSearching(int bigType, int littleType, int mSubnetID, int mDeviceID, int mChannelNum, String mChannelRemark, String parentRemarks, boolean bSaveAndCallBack) { +// 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 = getDevicesInfo1(devicesData, bigType, littleType, mChannelNum, parentRemarks, mChannelRemark); + devicesDataList.get(index).getAppliancesInfoList().add(mAppliancesInfo); + devicesData = devicesDataList.get(index);*/ + if(bSaveAndCallBack){ + HandleSearch.OnDeviceListGetSuccessCallBack();} + } else { + List<AppliancesInfo> appliancesInfoList = new ArrayList<>(); + appliancesInfoList.add(getDevicesInfo1(devicesData, bigType, littleType, mChannelNum, parentRemarks, mChannelRemark)); + devicesData.setAppliancesInfoList(appliancesInfoList); + devicesDataList.add(devicesData); + if(bSaveAndCallBack){ + HandleSearch.OnDeviceListGetSuccessCallBack();} + + } + + return devicesData; + + } else { + return null; + + } + + + } + + + /** + * 鑾峰彇鍒皕igbee鍦烘櫙鍚庣敓鎴愬搴旂殑bus鍦烘櫙 + * 娣诲姞鍦烘櫙璁惧鍥炶矾 + * 濡傛灉瀛樺湪鐩稿悓瀛愮綉鍙� 璁惧鍙凤紝鍒欏綋鎴愭贩鍚堟ā鍧楁坊鍔犲埌璇ュ洖璺笅锛屼笉瀛樺湪鍒欐柊娣诲姞妯″潡 + * @param mSubnetID + * @param mDeviceID + * @param mAreaNum //鍦烘櫙 鍖哄煙鍙� + * @param mAreaSceneNum //鍦烘櫙 褰撳墠鍖哄煙鍦烘櫙鍙� + * @param mChannelRemark + * @param parentRemarks + * @param bSaveAndCallBack 鏄惁椹笂淇濆瓨鏈湴骞朵笖鎺ㄩ�丏evicesInfoEvent 浜嬩欢 + * @return + */ + public static DevicesData addScenesDevicesListWithoutSearching(int mSubnetID, int mDeviceID, int mAreaNum, int mAreaSceneNum, String mChannelRemark, String parentRemarks, boolean bSaveAndCallBack) { +// boolean bWantData = false; + + int bigType = Configuration.GLOBAL_LOGIC_BIG_TYPE; + int littleType = 0; + 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 = getDevicesInfo1(devicesData, bigType, littleType, mAreaNum, parentRemarks, mChannelRemark); + LogicMode mLogicMode = new LogicMode(); + mLogicMode.setAreaNum(mAreaNum); + mLogicMode.setAreaSceneNum(mAreaSceneNum); + mAppliancesInfo.setLogicMode(mLogicMode); + devicesDataList.get(index).getAppliancesInfoList().add(mAppliancesInfo); + devicesData = devicesDataList.get(index);*/ + if(bSaveAndCallBack){ + HandleSearch.OnDeviceListGetSuccessCallBack();} + } else { + List<AppliancesInfo> appliancesInfoList = new ArrayList<>(); + AppliancesInfo mAppliancesInfo = getDevicesInfo1(devicesData, bigType, littleType, mAreaNum, parentRemarks, mChannelRemark); + LogicMode mLogicMode = new LogicMode(); + mLogicMode.setAreaNum(mAreaNum); + mLogicMode.setAreaSceneNum(mAreaSceneNum); + mAppliancesInfo.setLogicMode(mLogicMode); + appliancesInfoList.add(mAppliancesInfo); + devicesData.setAppliancesInfoList(appliancesInfoList); + devicesDataList.add(devicesData); + if(bSaveAndCallBack){ + HandleSearch.OnDeviceListGetSuccessCallBack();} + } + return devicesData; + + } else { + return null; + + } + } + + public static AppliancesInfo getDevicesInfo1(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.SENSOR_BIG_TYPE://2019-07-03 灞忚斀 + parseSensorData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, ""); + break; + case Configuration.GEOTHERMAL_BIG_TYPE://鍦扮儹 + parseGeothermalData(littleType, appliancesInfo, devicesData, parentRemarks, curChannelNum, 0, ""); + break; + case Configuration.FRESH_AIR_BIG_TYPE: + parseFreshAirData(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; + + } + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/LogUtil/HDLLog.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/LogUtil/HDLLog.java new file mode 100644 index 0000000..b352386 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/LogUtil/HDLLog.java @@ -0,0 +1,36 @@ +package com.hdl.sdk.hdl_core.Util.LogUtil; + +import android.util.Log; + +public class HDLLog { + private static boolean isOpen = true; + public static void info(String info){ + if(isOpen){ + Log.i("HDL_SDK",info); + } + + } + + + public static void E(String info){ + if(isOpen){ + Log.e("HDL_SDK",info); + } + + } + + /** + * 鏄惁寮�鍚疭DK鏃ュ織鎵撳嵃 + * @param bOpen + */ + public static void setHDLLogOpen(boolean bOpen){ + isOpen = bOpen; + } + +// public static void info(String info,boolean isOpen){ +// if(isOpen){ +// Log.i("djl",info); +// } +// +// } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/NetUtil/NetWorkUtil.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/NetUtil/NetWorkUtil.java new file mode 100644 index 0000000..861f24c --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/NetUtil/NetWorkUtil.java @@ -0,0 +1,239 @@ +package com.hdl.sdk.hdl_core.Util.NetUtil; + +import android.content.Context; +import android.net.ConnectivityManager; +import android.net.DhcpInfo; +import android.net.NetworkInfo; +import android.net.wifi.WifiInfo; +import android.net.wifi.WifiManager; + +import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLDeviceManager; +import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; + +import java.net.InetAddress; +import java.net.InterfaceAddress; +import java.net.NetworkInterface; +import java.util.Enumeration; +import java.util.List; +import java.util.regex.Pattern; + +/** + * Created by Tommy on 2017/9/4. + */ + +public class NetWorkUtil { + + private static boolean isGetWifiBroadCast = false; + + public static boolean isIsGetWifiBroadCast() { + return isGetWifiBroadCast; + } + + public static void setIsGetWifiBroadCast(boolean isGetWifiBroadCast) { + NetWorkUtil.isGetWifiBroadCast = isGetWifiBroadCast; + } + + public static final int GET_LOCAL_IP = 1; + public static final int GET_MAC_ADDRESS = 2; + public static final int GET_NETMASK = 3; + public static final int GET_GATEWAY = 4; + + public static boolean checkNetworkAvailable(Context context) { + ConnectivityManager connectivity = (ConnectivityManager) context + .getSystemService(Context.CONNECTIVITY_SERVICE); + if (connectivity == null) { + return false; + } else { + NetworkInfo[] info = connectivity.getAllNetworkInfo(); + if (info != null) { + for (int i = 0; i < info.length; i++) { + if (info[i].getState() == NetworkInfo.State.CONNECTED) { + NetworkInfo netWorkInfo = info[i]; + if (netWorkInfo.getType() == ConnectivityManager.TYPE_WIFI) { + return true; + } else if (netWorkInfo.getType() == ConnectivityManager.TYPE_MOBILE) { + return true; + } else if (netWorkInfo.getType() == ConnectivityManager.TYPE_ETHERNET) { + return true; + } + } + } + } + } + + return false; + } + + public static String getLocalIpString(Context context) { + String ip = ""; + ConnectivityManager conMann = (ConnectivityManager) + context.getSystemService(Context.CONNECTIVITY_SERVICE); +// NetworkInfo mobileNetworkInfo = conMann.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); + NetworkInfo wifiNetworkInfo = conMann.getNetworkInfo(ConnectivityManager.TYPE_WIFI); + if (wifiNetworkInfo.isConnected()) { + WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); + WifiInfo wifiInfo = wifiManager.getConnectionInfo(); + int ipAddress = wifiInfo.getIpAddress(); + ip = intToIp(ipAddress); + } + return ip; + } + + public static byte[] getWifiInfoByte(Context context, int type) { + byte[] address = null; + ConnectivityManager conMann = (ConnectivityManager) + context.getSystemService(Context.CONNECTIVITY_SERVICE); +// NetworkInfo mobileNetworkInfo = conMann.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); + NetworkInfo wifiNetworkInfo = conMann.getNetworkInfo(ConnectivityManager.TYPE_WIFI); + if (wifiNetworkInfo.isConnected()) { + WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); + WifiInfo wifiInfo = wifiManager.getConnectionInfo(); + DhcpInfo dhcpInfo = wifiManager.getDhcpInfo(); + switch (type) { + case GET_LOCAL_IP: + address = bytesToIp(dhcpInfo.ipAddress); +// address = bytesToIp(wifiInfo.getIpAddress()); + break; + case GET_MAC_ADDRESS: + String[] macArr = wifiInfo.getMacAddress().split(":"); + address = new byte[]{(byte) Integer.parseInt(macArr[0], 16) + , (byte) Integer.parseInt(macArr[1], 16) + , (byte) Integer.parseInt(macArr[2], 16) + , (byte) Integer.parseInt(macArr[3], 16) + , (byte) Integer.parseInt(macArr[4], 16) + , (byte) Integer.parseInt(macArr[5], 16) + }; + break; + case GET_NETMASK: + address = bytesToIp(dhcpInfo.netmask); + break; + case GET_GATEWAY: + address = bytesToIp(dhcpInfo.gateway); + break; + } + + } + return address; + } + + + public static String intToIp(int ipInt) { + StringBuilder sb = new StringBuilder(); + sb.append(ipInt & 0xFF).append("."); + sb.append((ipInt >> 8) & 0xFF).append("."); + sb.append((ipInt >> 16) & 0xFF).append("."); + sb.append((ipInt >> 24) & 0xFF); + return sb.toString(); + } + + private static byte[] bytesToIp(int ipInt) { + return new byte[]{(byte) ipInt, (byte) (ipInt >> 8), (byte) (ipInt >> 16), (byte) (ipInt >> 24)}; + } + + public static String getLocalBroadCast() { + String broadCastIp = "255.255.255.255"; + try { + //2020-1-17 鏂版垨鑰匢P鍦板潃鏂规硶 + if (isGetWifiBroadCast) { + broadCastIp = getWifiBroadAddress(); + } else { + broadCastIp = getLocalBroadCastOld(); + } + } catch (Exception e) { + e.printStackTrace(); + } + + if (broadCastIp == null) { + HDLLog.E("getLocalBroadCast error ip null"); + } + return broadCastIp; + } + + public static String getLocalBroadCastOld() { + String broadCastIp = null; + try { + Enumeration<?> netInterfaces = (Enumeration<?>) NetworkInterface.getNetworkInterfaces(); + while (netInterfaces.hasMoreElements()) { + NetworkInterface netInterface = (NetworkInterface) netInterfaces.nextElement(); + if (!netInterface.isLoopback() && netInterface.isUp()) { + List<InterfaceAddress> interfaceAddresses = netInterface.getInterfaceAddresses(); + for (InterfaceAddress interfaceAddress : interfaceAddresses) { + //鍙湁 IPv4 缃戠粶鍏锋湁骞挎挱鍦板潃锛屽洜姝ゅ浜� IPv6 缃戠粶灏嗚繑鍥� null銆� + if (interfaceAddress.getBroadcast() != null) { + broadCastIp = interfaceAddress.getBroadcast().getHostAddress(); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + + } + + if(broadCastIp == null){ + HDLLog.E("getLocalBroadCast error ip null"); + } + return broadCastIp; + } + + public static String getWifiBroadAddress() { + + String ipaddress = "255.255.255.255"; + try { + WifiManager wifimanage = (WifiManager) HDLDeviceManager.getViewContext().getApplicationContext().getSystemService(Context.WIFI_SERVICE);// 鑾峰彇WifiManager + DhcpInfo dhcpInfo = wifimanage.getDhcpInfo(); + ipaddress = intToIp((dhcpInfo.ipAddress) | (~dhcpInfo.netmask)); + + } catch (Exception ex) { + ipaddress = "255.255.255.255"; + } + return ipaddress; + } + + + public static InetAddress getLocalHostLANAddress() throws Exception { + try { + InetAddress candidateAddress = null; + // 閬嶅巻鎵�鏈夌殑缃戠粶鎺ュ彛 + for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces(); ifaces.hasMoreElements(); ) { + NetworkInterface iface = (NetworkInterface) ifaces.nextElement(); + // 鍦ㄦ墍鏈夌殑鎺ュ彛涓嬪啀閬嶅巻IP + for (Enumeration inetAddrs = iface.getInetAddresses(); inetAddrs.hasMoreElements(); ) { + InetAddress inetAddr = (InetAddress) inetAddrs.nextElement(); + if (!inetAddr.isLoopbackAddress()) {// 鎺掗櫎loopback绫诲瀷鍦板潃 + if (inetAddr.isSiteLocalAddress()) { + // 濡傛灉鏄痵ite-local鍦板潃锛屽氨鏄畠浜� + return inetAddr; + } else if (candidateAddress == null) { + // site-local绫诲瀷鐨勫湴鍧�鏈鍙戠幇锛屽厛璁板綍鍊欓�夊湴鍧� + candidateAddress = inetAddr; + } + } + } + } + if (candidateAddress != null) { + return candidateAddress; + } + // 濡傛灉娌℃湁鍙戠幇 non-loopback鍦板潃.鍙兘鐢ㄦ渶娆¢�夌殑鏂规 + InetAddress jdkSuppliedAddress = InetAddress.getLocalHost(); + return jdkSuppliedAddress; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static boolean isIP(String str) { + + // 鍖归厤 1 + // String regex = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"; + // 鍖归厤 2 + String regex = "[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}"; + + // 鍖归厤1 鍜屽尮閰�2鍧囧彲瀹炵幇Ip鍒ゆ柇鐨勬晥鏋� + Pattern pattern = Pattern.compile(regex); + + return pattern.matcher(str).matches(); + + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/SPUtil/SPUtils.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/SPUtil/SPUtils.java new file mode 100644 index 0000000..85c4ca6 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/SPUtil/SPUtils.java @@ -0,0 +1,156 @@ +package com.hdl.sdk.hdl_core.Util.SPUtil; + +import android.content.Context; +import android.content.SharedPreferences; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeDeviceSaveBean; +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.ZigbeeBean.ZigbeeSceneSaveBean; +import com.hdl.sdk.hdl_core.Util.TransformUtil.JsonUtil; + +import java.lang.reflect.Type; +import java.util.List; + +/** + * 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 = "share_rcu"; + 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_ZIGBEE_SCENE_IP = "zigbeesceneip"; + public static final String KEY_ZIGBEE_IP = "zigbeeip"; + 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 = "hdldevicedatalist"; + + public static final String KEY_LOCAL_BIG_CLASS_ = "local_big_class"; + public static final String KEY_LOCAL_Small_CLASS_ = "local_Small_class"; + public static final int DEFAULT_SUB_ID = 254; + public static final int DEFAULT_DEVICE_ID = 80; + + /** + * 淇濆瓨鏁版嵁鐨勬柟娉曪紝鎴戜滑闇�瑕佹嬁鍒颁繚瀛樻暟鎹殑鍏蜂綋绫诲瀷锛岀劧鍚庢牴鎹被鍨嬭皟鐢ㄤ笉鍚岀殑淇濆瓨鏂规硶 + * + * @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; + } + + /** + * 瀛樺偍璁惧鏁版嵁瀵硅薄 + * @param ctx + * @param key + * @param bookList + */ + public static void setZigbeeDeviceSaveBean(Context ctx,String key, List<ZigbeeDeviceSaveBean> bookList) { + SharedPreferences sp = ctx.getSharedPreferences("config", Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sp.edit(); + String json = JsonUtil.toJson(bookList); + editor.putString(key, json); + editor.commit(); + } + public static List<ZigbeeDeviceSaveBean> getZigbeeDeviceSaveBean(Context ctx,String key) { + SharedPreferences sp = ctx.getSharedPreferences("config", Context.MODE_PRIVATE); + Gson gson = new Gson(); + String json = sp.getString(key, null); + Type type = new TypeToken<List<ZigbeeDeviceSaveBean>>() { + }.getType(); + List<ZigbeeDeviceSaveBean> arrayList = gson.fromJson(json, type); + return arrayList; + } + + /** + * 瀛樺偍鍦烘櫙鏁版嵁瀵硅薄 + * @param ctx + * @param key + * @param bookList + */ + public static void setZigbeeSceneSaveBean(Context ctx,String key, List<ZigbeeSceneSaveBean> bookList) { + SharedPreferences sp = ctx.getSharedPreferences("config", Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sp.edit(); + String json = JsonUtil.toJson(bookList); + editor.putString(key, json); + editor.commit(); + } + public static List<ZigbeeSceneSaveBean> getZigbeeSceneSaveBean(Context ctx,String key) { + SharedPreferences sp = ctx.getSharedPreferences("config", Context.MODE_PRIVATE); + Gson gson = new Gson(); + String json = sp.getString(key, null); + Type type = new TypeToken<List<ZigbeeSceneSaveBean>>() { + }.getType(); + List<ZigbeeSceneSaveBean> arrayList = gson.fromJson(json, type); + return arrayList; + } + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/DataConverseUtil.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/DataConverseUtil.java new file mode 100644 index 0000000..e2f78dc --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/DataConverseUtil.java @@ -0,0 +1,32 @@ +package com.hdl.sdk.hdl_core.Util.TransformUtil; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +public class DataConverseUtil { + 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; + } + //灏忕妯″紡 + public static float byte2LittleFloat(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; + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/HDLUtlis.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/HDLUtlis.java new file mode 100644 index 0000000..4f23557 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/HDLUtlis.java @@ -0,0 +1,106 @@ +package com.hdl.sdk.hdl_core.Util.TransformUtil; + +import java.math.BigDecimal; + +/** + * Created by JLChen on 2019/7/4 + */ +public class HDLUtlis { + + /** + * 灏唎bject杞负Integer绫诲瀷 + * + * @param object + * @return + */ + public static Integer getIntegerByObject(Object object) { + Integer in = 0; + 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; + } + + public static float getFloatByObject(Object object) { + float f = 0f; + try { + f = (float)object; + } catch (Exception e) { + e.printStackTrace(); + } + return f; + + } + + + /** + * 4 byte 杞崲涓篺loat绫诲瀷 + * + * @param b1 + * @param b2 + * @param b3 + * @param b4 + * @return + */ + public static float byteToFloat(byte b1, byte b2, byte b3, byte b4) { + byte[] mByte = new byte[4]; + mByte[0] = b1; + mByte[1] = b2; + mByte[2] = b3; + mByte[3] = b4; + return byteArrayToFloat(mByte); + } + + /** + * byte[4]鏁扮粍 杞崲涓篺loat绫诲瀷 + * + * @param arr 闀垮害涓�4 + * @return + */ + public static float byteArrayToFloat(byte[] arr) { + try { + return Float.intBitsToFloat(getInt(arr)); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 杩炵画4涓瓧鑺傝幏寰椾竴涓猧nt + * + * @param arr + * @return int + */ + public static int getInt(byte[] arr) { + return (0xff000000 & (arr[0] << 24)) | + (0x00ff0000 & (arr[1] << 16)) | + (0x0000ff00 & (arr[2] << 8)) | + (0x000000ff & arr[3]); + } + + /** + * float杞崲涓篵yte[4]鏁扮粍 + * + * @param f + * @return + */ + public static byte[] getByteArray(float f) { + int intbits = Float.floatToIntBits(f);//灏唂loat閲岄潰鐨勪簩杩涘埗涓茶В閲婁负int鏁存暟 + return getByteArray(intbits); + } + + +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/JsonUtil.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/JsonUtil.java new file mode 100644 index 0000000..5236506 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/JsonUtil.java @@ -0,0 +1,55 @@ +package com.hdl.sdk.hdl_core.Util.TransformUtil; + + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; +import com.google.gson.reflect.TypeToken; + +import java.util.List; + +public class JsonUtil { + + public static String toJson(Object object) { + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.setPrettyPrinting(); + Gson gson = gsonBuilder.create(); + return gson.toJson(object); + } + /** + *瑙f瀽瀛楃涓插瓧鍏� + */ + public static <T> T parseJsonWithGson(String json, Class<T> type) { + + T result = new Gson().fromJson(json, type); + return result; + } + + /** + * 瑙f瀽鏁扮粍 + */ + public static <T> List<T> parseArrayJsonWithGson(String json, Class<T> type) { + List<T> list = new Gson().fromJson(json, new TypeToken<List<T>>(){}.getType()); + return list; + } + + /** + *json鍒ゆ柇 + */ + public static boolean isJson(String content) { + JsonElement jsonElement; + try { + jsonElement = new JsonParser().parse(content); + } catch (Exception e) { + return false; + } + if (jsonElement == null) { + return false; + } + if (!jsonElement.isJsonObject()) { + return false; + } + return true; + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/StringUtil.java b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/StringUtil.java new file mode 100644 index 0000000..5f6c532 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/StringUtil.java @@ -0,0 +1,236 @@ +package com.hdl.sdk.hdl_core.Util.TransformUtil; + +import java.io.UnsupportedEncodingException; + +/** + * Created by Tommy on 2017/7/21. + */ + +public class StringUtil { + public static String byte2String(byte[] bytes) { +// String remarkStr = "澶囨敞鏁版嵁锛�"; +// for(int k = 0;k < bytes.length;k++){ +// remarkStr +=(bytes[k]& 0xFF)+" "; +// } +// HDLLog.info(remarkStr); + + int pos = bytes.length - 1; +// for(int i=0;i<bytes.length;i++){ +// +// if(i!=(bytes.length-1) && (bytes[i]&0xFF)==0 && (bytes[i+1]&0xFF)==0){ +// pos = i-1; +// break; +// } +// } + 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) { +// stringToAscii("S1PLAYSTOP"); +// 83,49,80,76,65,89,83,84,79,80 + 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); + } + /** + *涓ゅ瓧鑺�16杩涘埗杞�10杩涘埗 + */ + public static int byte2length(byte arg1,byte arg2){ + byte[] bytes = new byte[2]; + bytes[0] = arg2; + bytes[1] = arg1; + String hex = StringUtil.ByteArrToHex(bytes,0,bytes.length); + int result = Integer.parseInt(hex,16); + return result; + } + + /** + *鍗佸叚杩涘埗涓茶浆鍖栦负IP鍦板潃 + */ + public static String splitKey(byte arg1,byte arg2,byte arg3,byte arg4){ + byte[] bytes = new byte[4]; + bytes[0] = arg1; + bytes[1] = arg2; + bytes[2] = arg3; + bytes[3] = arg4; + String hex = StringUtil.ByteArrToHex(bytes,0,bytes.length); + long numb=Long.parseLong(hex, 16); + String IpAddress = ""; + long temp = 0; + for (int i = 3; i >= 0; i--) { + temp = numb / (long) Math.pow(256, i) % 256; + if (i == 3) { + IpAddress = IpAddress + temp; + } else { + IpAddress = IpAddress + "." + temp; + } + } + return IpAddress; + } + + /** + * 灏嗗瓧绗︿覆褰㈠紡琛ㄧず鐨勫崄鍏繘鍒舵暟杞崲涓篵yte鏁扮粍 + */ + public static byte[] hexStringToBytes(String hexString) + { + hexString = hexString.toLowerCase(); + String[] hexStrings = hexString.split(" "); + byte[] bytes = new byte[hexStrings.length]; + for (int i = 0; i < hexStrings.length; i++) + { + char[] hexChars = hexStrings[i].toCharArray(); + bytes[i] = (byte) (charToByte(hexChars[0]) << 4 | charToByte(hexChars[1])); + } + return bytes; + } + + private static byte charToByte(char c) + { + return (byte) "0123456789abcdef".indexOf(c); + // 涓汉鍠滃ソ,鎴戝枩娆㈢敤灏忓啓鐨� return (byte) "0123456789ABCDEF".indexOf(c); + } + + + + +// 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.info( "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.info( "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; +// } + + //------------------------------------------------------- + //瀛楄妭鏁扮粍杞浆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(); + } + + //------------------------------------------------------- + //1瀛楄妭杞�2涓狧ex瀛楃 + public static String Byte2Hex(Byte inByte) { + return String.format("%02x", new Object[]{inByte}).toUpperCase(); + } +} diff --git a/Android_HDL_SDK_XW/hdl_core/src/main/res/values/strings.xml b/Android_HDL_SDK_XW/hdl_core/src/main/res/values/strings.xml new file mode 100644 index 0000000..e8d1f33 --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ +<resources> + <string name="app_name">HDL_core</string> +</resources> diff --git a/Android_HDL_SDK_XW/hdl_core/src/test/java/com/hdl/sdk/hdl_core/ExampleUnitTest.java b/Android_HDL_SDK_XW/hdl_core/src/test/java/com/hdl/sdk/hdl_core/ExampleUnitTest.java new file mode 100644 index 0000000..1ac296d --- /dev/null +++ b/Android_HDL_SDK_XW/hdl_core/src/test/java/com/hdl/sdk/hdl_core/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.hdl.sdk.hdl_core; + +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/Android_HDL_SDK_XW/settings.gradle b/Android_HDL_SDK_XW/settings.gradle new file mode 100644 index 0000000..b2e8819 --- /dev/null +++ b/Android_HDL_SDK_XW/settings.gradle @@ -0,0 +1 @@ +include ':app', ':hdl_core' diff --git "a/Zigbee2BusSDK\350\257\264\346\230\216\346\226\207\346\241\243V1.0.docx" "b/Zigbee2BusSDK\350\257\264\346\230\216\346\226\207\346\241\243V1.0.docx" new file mode 100644 index 0000000..5068652 --- /dev/null +++ "b/Zigbee2BusSDK\350\257\264\346\230\216\346\226\207\346\241\243V1.0.docx" Binary files differ -- Gitblit v1.8.0