From c9978ac37e3e9817ab07b25dbb499b28918403fd Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期二, 20 十月 2020 15:49:54 +0800 Subject: [PATCH] 2020-10-20 1.增加RGB和CCT灯控制协议 --- app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlRGBLightActivity.java | 247 ++++++++ .idea/jarRepositories.xml | 25 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/Config/HDLApConfig.java | 4 app/src/main/res/layout/activity_ctrl_cct_light.xml | 181 ++++++ hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/LightRGBCtrlBackEvent.java | 23 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java | 25 hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java | 14 app/src/main/AndroidManifest.xml | 4 app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java | 12 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLight/CCTBackInfo.java | 76 ++ hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java | 34 app/src/main/java/com/hdl/sdk/hdl_sdk/base/RGBLightBean.java | 53 + .idea/misc.xml | 2 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java | 172 +++++- hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/LightCCTCtrlBackEvent.java | 24 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLight/RGBBackInfo.java | 113 ++++ app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlCCTLightActivity.java | 320 +++++++++++ hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java | 147 +++++ .idea/compiler.xml | 6 app/src/main/res/layout/activity_ctrl_r_g_b_light.xml | 139 ++++ 20 files changed, 1,567 insertions(+), 54 deletions(-) diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="CompilerConfiguration"> + <bytecodeTargetLevel target="1.8" /> + </component> +</project> \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..a5f05cd --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="RemoteRepositoriesConfiguration"> + <remote-repository> + <option name="id" value="central" /> + <option name="name" value="Maven Central repository" /> + <option name="url" value="https://repo1.maven.org/maven2" /> + </remote-repository> + <remote-repository> + <option name="id" value="jboss.community" /> + <option name="name" value="JBoss Community repository" /> + <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" /> + </remote-repository> + <remote-repository> + <option name="id" value="BintrayJCenter" /> + <option name="name" value="BintrayJCenter" /> + <option name="url" value="https://jcenter.bintray.com/" /> + </remote-repository> + <remote-repository> + <option name="id" value="Google" /> + <option name="name" value="Google" /> + <option name="url" value="https://dl.google.com/dl/android/maven2/" /> + </remote-repository> + </component> +</project> \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 0d45e8d..58918f5 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK" /> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" /> </project> \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6d37330..c33c0b0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -18,7 +18,9 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - <activity android:name=".activity.AddDevicesActivity"></activity> + <activity android:name=".activity.CtrlCCTLightActivity"></activity> + <activity android:name=".activity.CtrlRGBLightActivity" /> + <activity android:name=".activity.AddDevicesActivity" /> <activity android:name=".activity.SettingActivity" /> <activity android:name=".activity.AddDevicesManuallyActivity" /> <activity android:name=".activity.MainActivity"> diff --git a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java index 9484120..a645dfc 100644 --- a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java +++ b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java @@ -10,6 +10,7 @@ import android.widget.ListView; 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 java.util.ArrayList; @@ -66,6 +67,17 @@ }else if (appliancesInfos.get(position).getBigType() == Configuration.SENSOR_BIG_TYPE) { //澶х被鏄紶鎰熷櫒 鍒欒烦杞埌SensorActivity 骞茶妭鐐规寚浠ょ被鍨� intent.setClass(AppliancesActivity.this, SensorActivity.class); + }else if (appliancesInfos.get(position).getBigType() == Configuration.LIGTH_BIG_TYPE) { + //澶х被鏄伅鍏� + if(appliancesInfos.get(position).getDeviceType() == HDLApConfig.TYPE_LIGHT_RGB){ + intent.setClass(AppliancesActivity.this, CtrlRGBLightActivity.class); + }else if(appliancesInfos.get(position).getDeviceType() == HDLApConfig.TYPE_LIGHT_CCT){ + intent.setClass(AppliancesActivity.this, CtrlCCTLightActivity.class); + }else { + //鏅�氱伅 + intent.setClass(AppliancesActivity.this, CtrlActivity.class); + } + } diff --git a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlCCTLightActivity.java b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlCCTLightActivity.java new file mode 100644 index 0000000..855ceed --- /dev/null +++ b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlCCTLightActivity.java @@ -0,0 +1,320 @@ +package com.hdl.sdk.hdl_sdk.activity; + +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.RelativeLayout; +import android.widget.SeekBar; +import android.widget.TextView; + +import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.CCTBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.RGBBackInfo; +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.LightCCTCtrlBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LightRGBCtrlBackEvent; +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 CtrlCCTLightActivity extends BaseActivity { + /** + * Topbar + */ + private RelativeLayout topBarBack; + private TextView topBarTitle; + private Button btnOpen, btnClose; + // private EditText etR,etG,etB; + private SeekBar seekBar, seekBarCCT; + private TextView switchText; + private AppliancesInfo appliancesInfo; + private int settingBrightness = 0; + private int settingCCT = 2000; + private CCTBackInfo mCCTBackInfo; + + //榛樿鑹叉俯鑼冨洿鍊� 2000K 鍒�7000K锛屼笉涓�瀹氭墍鏈夎澶囬兘鏄繖涓寖鍥� + private int MIN_CCT = 2000; + private int MAX_CCT = 7000; + + + /** + * 澶嶅啓isRegisterEventBus() 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true + * + * @return true + */ + @Override + protected boolean isRegisterEventBus() { + return true; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_ctrl_cct_light); + + initToolbar(); + initcurState(); + initView(); + initOnClick(); + displayStateView(); + mCCTBackInfo = new CCTBackInfo(appliancesInfo); + + //璇诲彇鐘舵�� + HDLCommand.getRGBCCTStateFromNetwork(appliancesInfo); + + } + + /** + * 鍒濆鍖朤oolbar + */ + private void initToolbar() { +// topBarBack = findViewById(R.id.ll_top_b_left); +// setViewVisible(topBarBack); +// topBarTitle = findViewById(R.id.tv_top_b_header_title); +// topBarBack.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// finish(); +// } +// }); + } + + private void initcurState() { + appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl"); + + } + + private void initView() { + btnOpen = findViewById(R.id.btnOpen); + btnClose = findViewById(R.id.btnClose); + seekBar = findViewById(R.id.sb_brightness); + seekBarCCT = findViewById(R.id.sb_cct); + switchText = findViewById(R.id.switchText); + } + + private void initOnClick() { + + + btnOpen.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + int brightness = settingBrightness == 0 ? 100 : settingBrightness; + if (settingCCT > MAX_CCT) { + settingCCT = MAX_CCT; + } else if (settingCCT < MIN_CCT) { + settingCCT = MIN_CCT; + } + HDLCommand.lightCCTCtrl(appliancesInfo, brightness, settingCCT); + } + }); + + btnClose.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (settingCCT > MAX_CCT) { + settingCCT = MAX_CCT; + } else if (settingCCT < MIN_CCT) { + settingCCT = MIN_CCT; + } + HDLCommand.lightCCTCtrl(appliancesInfo, 0, settingCCT); + } + }); + + seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + if (seekBar.getProgress() > 0) { + settingBrightness = seekBar.getProgress(); + } + if (settingCCT > MAX_CCT) { + settingCCT = MAX_CCT; + } else if (settingCCT < MIN_CCT) { + settingCCT = MIN_CCT; + } + HDLCommand.lightCCTCtrl(appliancesInfo, seekBar.getProgress(), settingCCT); + } + }); + + seekBarCCT.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + settingCCT = seekBarProgressToValue(MIN_CCT, MAX_CCT, seekBar.getProgress()); + if (settingCCT > MAX_CCT) { + settingCCT = MAX_CCT; + } else if (settingCCT < MIN_CCT) { + settingCCT = MIN_CCT; + } + + HDLLog.I("鑹叉俯璁剧疆锛�" + settingCCT + "K"); + int brightness = settingBrightness == 0 ? 100 : settingBrightness; + HDLCommand.lightCCTCtrl(appliancesInfo, brightness, settingCCT); + } + }); + + } + + private void displayStateView() { + + switch (appliancesInfo.getDeviceType()) { + case HDLApConfig.TYPE_LIGHT_CCT: + break; + default: + finish();//璁惧绫诲瀷涓嶅缁撴潫椤甸潰 + break; + } + /**鏍规嵁闇�姹傛槸鍚﹀彂閫佷竴娆¤幏鍙栧埛鏂扮姸鎬佽姹�*/ + + } + + + /** + * showCCTBackInfo + * + * @param mCCTBackInfo + */ + private void showCCTBackInfo(CCTBackInfo mCCTBackInfo) { + String message = ""; + if (mCCTBackInfo.getBrightness() > 0) { + //濡傛灉澶т簬0鎵嶈浣忓綋鍓嶈缃殑浜害鍊硷紝涓嬫鎵撳紑鏃剁户缁繖涓寒搴﹀�� + settingBrightness = mCCTBackInfo.getBrightness(); + + message = "褰撳墠鐘舵�侊細寮�"; + message += "\n" + "浜害锛�" + mCCTBackInfo.getBrightness(); + message += "\n" + "鑹叉俯鍊硷細" + mCCTBackInfo.getCctValue() + "K"; + + } else { + message = "褰撳墠鐘舵�侊細鍏�"; + } + + settingCCT = mCCTBackInfo.getCctValue(); + seekBar.setProgress(mCCTBackInfo.getBrightness()); + int cctProgress = seekBarValueToProgress(MIN_CCT, MAX_CCT, mCCTBackInfo.getCctValue()); + seekBarCCT.setProgress(cctProgress); + switchText.setText(message); + showToast(message); + HDLLog.I(message); + } + + /** + * RGB鎺у埗鍥炶皟Event + * + * @param event + */ + @Subscribe(threadMode = ThreadMode.MAIN) + public void onLightCCTCtrlBackEventMain(LightCCTCtrlBackEvent event) { + if (event.getCCTBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() + && event.getCCTBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() + && event.getCCTBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum() + ) { + if (!event.isSuccess()) { + showToast("RGB鐏帶鍒惰秴鏃讹紝璇烽噸鏂板啀璇�"); + return; + } + +// showToast("RGB鐏帶鍒舵垚鍔�"); + mCCTBackInfo = event.getCCTBackInfo(); + showCCTBackInfo(mCCTBackInfo); + } + } + + + @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_LIGHT_CCT: + if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) { + if (!event.isSuccess()) { + showToast("鑾峰彇CCT鐏姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + String message = ""; + CCTBackInfo cctBackInfo = new CCTBackInfo(event.appliancesInfo); + if (cctBackInfo == null) { + showToast("鑾峰彇CCT鐏姸鎬佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + mCCTBackInfo = cctBackInfo; + showCCTBackInfo(mCCTBackInfo); + } + break; + } + } + } + + + /** + * 鏍规嵁婊戞潯鍒诲害鍊硷紝缁欏畾鏈�澶ф渶灏忓�� 璁$畻鍑哄搴旀樉绀哄�� + * 婊戞潯鍒诲害鍊艰寖鍥�0~100 + * + * @param maxValue 鏈�澶у�� + * @param minValue 鏈�灏忓�� + * @param mProgress 婊戞潯鍊� + * @return 璁$畻鍚庣殑鏄剧ず鍊� + */ + private int seekBarProgressToValue(int minValue, int maxValue, int mProgress) { + int progress = mProgress; + + if (progress < 0) { + progress = 0; + } else if (progress > 100) { + progress = 100; + } + int intValue = 0; + intValue = (maxValue - minValue) * progress / 100 + minValue; + return intValue; + } + + /** + * 鏍规嵁鏄剧ず鍊硷紝缁欏畾鏈�澶ф渶灏忓�� 璁$畻鍑哄婊戞潯鍒诲害 + * 婊戞潯鍒诲害鍊艰寖鍥�0~100 + * + * @param maxValue 鏈�澶у�� + * @param minValue 鏈�灏忓�� + * @param mIntValue 鏄剧ず鍊� + * @return 璁$畻鍚庣殑婊戞潯鍊� + */ + private int seekBarValueToProgress(int minValue, int maxValue, int mIntValue) { + int intValue = mIntValue; + + if (intValue < minValue) { + intValue = minValue; + } else if (intValue > maxValue) { + intValue = maxValue; + } + int progress = 0; + progress = (intValue - minValue) * 100 / (maxValue - minValue); + return progress; + + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlRGBLightActivity.java b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlRGBLightActivity.java new file mode 100644 index 0000000..2301288 --- /dev/null +++ b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlRGBLightActivity.java @@ -0,0 +1,247 @@ +package com.hdl.sdk.hdl_sdk.activity; + +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.RelativeLayout; +import android.widget.SeekBar; +import android.widget.TextView; + +import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.RGBBackInfo; +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.LightRGBCtrlBackEvent; +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 CtrlRGBLightActivity extends BaseActivity { + /** + * Topbar + */ + private RelativeLayout topBarBack; + private TextView topBarTitle; + private Button btnOpen, btnClose, btnRGB; + private EditText etR, etG, etB; + private SeekBar seekBar; + private TextView switchText; + private AppliancesInfo appliancesInfo; + private int settingBrightness = 0; + private RGBBackInfo mRGBBackInfo; + +// private RGBLightBean mRGBLightBean; + + + /** + * 澶嶅啓isRegisterEventBus() 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true + * + * @return true + */ + @Override + protected boolean isRegisterEventBus() { + return true; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_ctrl_r_g_b_light); + + initToolbar(); + initcurState(); + initView(); + initOnClick(); + displayStateView(); + mRGBBackInfo = new RGBBackInfo(appliancesInfo); + + //璇诲彇鐘舵�� + HDLCommand.getRGBCCTStateFromNetwork(appliancesInfo); + + } + + /** + * 鍒濆鍖朤oolbar + */ + private void initToolbar() { +// topBarBack = findViewById(R.id.ll_top_b_left); +// setViewVisible(topBarBack); +// topBarTitle = findViewById(R.id.tv_top_b_header_title); +// topBarBack.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// finish(); +// } +// }); + } + + private void initcurState() { + appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl"); + + } + + private void initView() { + btnOpen = findViewById(R.id.btnOpen); + btnClose = findViewById(R.id.btnClose); + btnRGB = findViewById(R.id.btnRGB); + seekBar = findViewById(R.id.sb_brightness); + etR = findViewById(R.id.et_r); + etG = findViewById(R.id.et_g); + etB = findViewById(R.id.et_b); + + switchText = findViewById(R.id.switchText); + } + + private void initOnClick() { + btnRGB.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + int rStatus = Integer.parseInt(etR.getText().toString()); + int gStatus = Integer.parseInt(etG.getText().toString()); + int bStatus = Integer.parseInt(etB.getText().toString()); + if (rStatus < 0 || rStatus > 255 || gStatus < 0 || gStatus > 255 || bStatus < 0 || bStatus > 255) { + showToast("RGB鍊艰寖鍥� 0~255"); + return; + } + + int brightness = settingBrightness == 0 ? 100 : settingBrightness; + HDLCommand.lightRGBCtrl(appliancesInfo, brightness, rStatus, gStatus, bStatus); + } + }); + + btnOpen.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + int brightness = settingBrightness == 0 ? 100 : settingBrightness; + HDLCommand.lightRGBCtrl(appliancesInfo, brightness, mRGBBackInfo.getrStatus(), mRGBBackInfo.getgStatus(), mRGBBackInfo.getbStatus()); + } + }); + + btnClose.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + HDLCommand.lightRGBCtrl(appliancesInfo, 0, mRGBBackInfo.getrStatus(), mRGBBackInfo.getgStatus(), mRGBBackInfo.getbStatus()); + } + }); + + seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + if (seekBar.getProgress() > 0) { + settingBrightness = seekBar.getProgress(); + } + + HDLCommand.lightRGBCtrl(appliancesInfo, seekBar.getProgress(), mRGBBackInfo.getrStatus(), mRGBBackInfo.getgStatus(), mRGBBackInfo.getbStatus()); + } + }); + } + + private void displayStateView() { + + switch (appliancesInfo.getDeviceType()) { + case HDLApConfig.TYPE_LIGHT_RGB: + break; + default: + finish();//璁惧绫诲瀷涓嶅缁撴潫椤甸潰 + break; + } + /**鏍规嵁闇�姹傛槸鍚﹀彂閫佷竴娆¤幏鍙栧埛鏂扮姸鎬佽姹�*/ + + } + + + /** + * showRGBBackInfoInfo + * + * @param mRGBBackInfo + */ + private void showRGBBackInfoInfo(RGBBackInfo mRGBBackInfo) { + String message = ""; + if (mRGBBackInfo.getBrightness() > 0) { + //濡傛灉澶т簬0鎵嶈浣忓綋鍓嶈缃殑浜害鍊硷紝涓嬫鎵撳紑鏃剁户缁繖涓寒搴﹀�� + settingBrightness = mRGBBackInfo.getBrightness(); + message = "褰撳墠鐘舵�侊細寮�"; + message += "\n" + "浜害锛�" + mRGBBackInfo.getBrightness(); + message += "\n" + "R锛�" + mRGBBackInfo.getrStatus(); + message += "\n" + "G锛�" + mRGBBackInfo.getgStatus(); + message += "\n" + "B锛�" + mRGBBackInfo.getbStatus(); + } else { + message = "褰撳墠鐘舵�侊細鍏�"; + } + + + seekBar.setProgress(mRGBBackInfo.getBrightness()); + etR.setText(String.valueOf(mRGBBackInfo.getrStatus())); + etG.setText(String.valueOf(mRGBBackInfo.getgStatus())); + etB.setText(String.valueOf(mRGBBackInfo.getbStatus())); + switchText.setText(message); + showToast(message); + HDLLog.I(message); + } + + /** + * RGB鎺у埗鍥炶皟Event + * + * @param event + */ + @Subscribe(threadMode = ThreadMode.MAIN) + public void onRGBCtrlBackEventMain(LightRGBCtrlBackEvent event) { + if (event.getRGBBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() + && event.getRGBBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() + && event.getRGBBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum() + ) { + if (!event.isSuccess()) { + showToast("RGB鐏帶鍒惰秴鏃讹紝璇烽噸鏂板啀璇�"); + return; + } + +// showToast("RGB鐏帶鍒舵垚鍔�"); + mRGBBackInfo = event.getRGBBackInfo(); + showRGBBackInfoInfo(mRGBBackInfo); + } + } + + + @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_LIGHT_RGB: + if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) { + if (!event.isSuccess()) { + showToast("鑾峰彇RGB鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + String message = ""; + RGBBackInfo rgbBackInfo = new RGBBackInfo(event.appliancesInfo); + if (rgbBackInfo == null) { + showToast("鑾峰彇RGB鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + mRGBBackInfo = rgbBackInfo; + showRGBBackInfoInfo(mRGBBackInfo); + } + break; + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/hdl/sdk/hdl_sdk/base/RGBLightBean.java b/app/src/main/java/com/hdl/sdk/hdl_sdk/base/RGBLightBean.java new file mode 100644 index 0000000..ab28274 --- /dev/null +++ b/app/src/main/java/com/hdl/sdk/hdl_sdk/base/RGBLightBean.java @@ -0,0 +1,53 @@ +package com.hdl.sdk.hdl_sdk.base; + +/** + * Created by jlchen on 2020/10/20. + */ +public class RGBLightBean { +// private int lightType; //1-5//1鍗曡矾 2CCT 3RGB 4RGBW 5RGBWY + private int rStatus; //R + private int gStatus; //G + private int bStatus; //B + private int brightness; //褰撳墠鐪熷疄浜害brightness + private int setbrightness; //涓婁竴娆¤缃殑浜害 + + public int getrStatus() { + return rStatus; + } + + public void setrStatus(int rStatus) { + this.rStatus = rStatus; + } + + public int getgStatus() { + return gStatus; + } + + public void setgStatus(int gStatus) { + this.gStatus = gStatus; + } + + public int getbStatus() { + return bStatus; + } + + public void setbStatus(int bStatus) { + this.bStatus = bStatus; + } + + public int getBrightness() { + return brightness; + } + + public void setBrightness(int brightness) { + this.brightness = brightness; + } + + public int getSetbrightness() { + return setbrightness; + } + + public void setSetbrightness(int setbrightness) { + this.setbrightness = setbrightness; + } +} diff --git a/app/src/main/res/layout/activity_ctrl_cct_light.xml b/app/src/main/res/layout/activity_ctrl_cct_light.xml new file mode 100644 index 0000000..764fdac --- /dev/null +++ b/app/src/main/res/layout/activity_ctrl_cct_light.xml @@ -0,0 +1,181 @@ +<?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"> + <!-- <include--> + <!-- android:id="@+id/hdl_top_bar_layout"--> + <!-- layout="@layout/hdl_toolbar_top_view_b"/>--> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginLeft="20dp" + android:layout_marginRight="20dp" + android:orientation="vertical"> + + <TextView + android:layout_width="match_parent" + android:layout_height="40dp" + android:gravity="center|left" + android:text="CCT鐏澶�" + android:textSize="@dimen/ts_24" + /> + + <TextView + android:id="@+id/switchText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="10dp" + android:text="杩欎釜鎸夐挳鍋欳CT鐏殑婕旂ず" + android:textSize="@dimen/ts_20" /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="40dp" + android:layout_marginTop="20dp"> + + <TextView + android:layout_width="30dp" + android:layout_height="match_parent" + android:layout_gravity="center" + android:text="浜害:" + android:textSize="12sp"></TextView> + + <SeekBar + android:id="@+id/sb_brightness" + android:layout_width="match_parent" + android:layout_height="20dp" + android:max="100" + android:min="0"></SeekBar> + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="40dp" + android:layout_marginTop="20dp"> + + <TextView + android:layout_width="30dp" + android:layout_height="match_parent" + android:layout_gravity="center" + android:text="鑹叉俯:" + android:textSize="12sp"></TextView> + + <SeekBar + android:id="@+id/sb_cct" + android:layout_width="match_parent" + android:layout_height="20dp" + android:max="100" + android:min="0"></SeekBar> + </LinearLayout> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="20dp" + android:layout_marginLeft="40dp"> + + <TextView + android:layout_width="30dp" + android:layout_height="match_parent" + android:layout_gravity="center" + android:text="鏆�" + android:textSize="12sp"></TextView> + + <TextView + android:layout_width="30dp" + android:layout_height="match_parent" + android:layout_weight="1" + android:layout_gravity="center" + + android:textSize="12sp"></TextView> + <TextView + android:layout_width="30dp" + android:layout_height="match_parent" + android:layout_gravity="center" + android:text="鍐�" + android:textSize="12sp"></TextView> + + </LinearLayout> + + + +<!-- <LinearLayout--> +<!-- android:layout_width="match_parent"--> +<!-- android:layout_height="40dp"--> +<!-- android:layout_marginTop="20dp">--> + +<!-- <TextView--> +<!-- android:layout_width="20dp"--> +<!-- android:layout_height="match_parent"--> +<!-- android:gravity="center"--> +<!-- android:text="R:"--> +<!-- android:textSize="18sp"></TextView>--> + +<!-- <EditText--> +<!-- android:id="@+id/et_r"--> +<!-- android:layout_width="match_parent"--> +<!-- android:layout_height="match_parent"--> +<!-- android:layout_weight="1"--> +<!-- android:inputType="number"--> +<!-- android:maxLength="3"--> +<!-- android:text="255"></EditText>--> + +<!-- <TextView--> +<!-- android:layout_width="20dp"--> +<!-- android:layout_height="match_parent"--> +<!-- android:text="G:"--> +<!-- android:gravity="center"--> +<!-- android:textSize="18sp"></TextView>--> + +<!-- <EditText--> +<!-- android:id="@+id/et_g"--> +<!-- android:layout_width="match_parent"--> +<!-- android:layout_height="match_parent"--> +<!-- android:layout_weight="1"--> +<!-- android:inputType="number"--> +<!-- android:maxLength="3"--> +<!-- android:text="255"></EditText>--> + +<!-- <TextView--> +<!-- android:layout_width="20dp"--> +<!-- android:layout_height="match_parent"--> +<!-- android:text="B:"--> +<!-- android:gravity="center"--> +<!-- android:textSize="18sp"></TextView>--> + +<!-- <EditText--> +<!-- android:id="@+id/et_b"--> +<!-- android:layout_width="match_parent"--> +<!-- android:layout_height="match_parent"--> +<!-- android:layout_weight="1"--> +<!-- android:inputType="number"--> +<!-- android:maxLength="3"--> +<!-- android:text="255"></EditText>--> + + +<!-- </LinearLayout>--> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="40dp" + android:layout_marginTop="20dp"> + + <Button + android:id="@+id/btnOpen" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="寮�鐏�" /> + + <Button + android:id="@+id/btnClose" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="鍏崇伅" /> + </LinearLayout> + + </LinearLayout> + +</RelativeLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_ctrl_r_g_b_light.xml b/app/src/main/res/layout/activity_ctrl_r_g_b_light.xml new file mode 100644 index 0000000..f3b6ee6 --- /dev/null +++ b/app/src/main/res/layout/activity_ctrl_r_g_b_light.xml @@ -0,0 +1,139 @@ +<?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"> + <!-- <include--> + <!-- android:id="@+id/hdl_top_bar_layout"--> + <!-- layout="@layout/hdl_toolbar_top_view_b"/>--> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginLeft="20dp" + android:layout_marginRight="20dp" + android:orientation="vertical"> + + <TextView + android:layout_width="match_parent" + android:layout_height="40dp" + android:gravity="center|left" + android:text="RGB鐏澶�" + android:textSize="@dimen/ts_24" + /> + + <TextView + android:id="@+id/switchText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="10dp" + android:text="杩欎釜鎸夐挳鍋歊GB鐏殑婕旂ず" + android:textSize="@dimen/ts_20" /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="40dp" + android:layout_marginTop="20dp"> + + <TextView + android:layout_width="30dp" + android:layout_height="match_parent" + android:layout_gravity="center" + android:text="浜害:" + android:textSize="12sp"></TextView> + + <SeekBar + android:id="@+id/sb_brightness" + android:layout_width="match_parent" + android:layout_height="20dp" + android:max="100" + android:min="0"></SeekBar> + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="40dp"> + + <TextView + android:layout_width="20dp" + android:layout_height="match_parent" + android:gravity="center" + android:text="R:" + android:textSize="18sp"></TextView> + + <EditText + android:id="@+id/et_r" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_weight="1" + android:inputType="number" + android:maxLength="3" + android:text="255"></EditText> + + <TextView + android:layout_width="20dp" + android:layout_height="match_parent" + android:text="G:" + android:gravity="center" + android:textSize="18sp"></TextView> + + <EditText + android:id="@+id/et_g" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_weight="1" + android:inputType="number" + android:maxLength="3" + android:text="255"></EditText> + + <TextView + android:layout_width="20dp" + android:layout_height="match_parent" + android:text="B:" + android:gravity="center" + android:textSize="18sp"></TextView> + + <EditText + android:id="@+id/et_b" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_weight="1" + android:inputType="number" + android:maxLength="3" + android:text="255"></EditText> + + + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="40dp" + android:layout_marginTop="20dp"> + + <Button + android:id="@+id/btnRGB" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="鍗曠嫭璁剧疆RGB" /> + + <Button + android:id="@+id/btnOpen" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="寮�鐏�" /> + + + <Button + android:id="@+id/btnClose" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="鍏崇伅" /> + </LinearLayout> + + </LinearLayout> + +</RelativeLayout> \ No newline at end of file diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java index 0e08292..859b388 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java @@ -19,7 +19,7 @@ public static final int SECURITY_BIG_TYPE = 10; public static final int LOGIC_BIG_TYPE = 12; public static final int GLOBAL_LOGIC_BIG_TYPE = 17; - /** + /**E3D8 * 鏂伴绯荤粺 */ public static final int FRESH_AIR_BIG_TYPE = 19; @@ -79,6 +79,18 @@ public static final int LIGHT_STATE_COMMAND = 0x0033; public static final int LIGHT_STATE_BACK_COMMAND = 0x0034; + //RGB CCT 鐏厜鎿嶄綔鐮併�佺姸鎬佽鍙栫爜 + public static final int LIGHT_RGB_CTRL_COMMAND = 0xE45C; + public static final int LIGHT_RGB_CTRL_BACK_COMMAND = 0xE45D; + public static final int LIGHT_RGB_STATE_COMMAND = 0xE472; + public static final int LIGHT_RGB_STATE_BACK_COMMAND = 0xE473; + +// //CCT鐏厜鎿嶄綔鐮併�佺姸鎬佽鍙栫爜 +// public static final int LIGHT_CCT_CTRL_COMMAND = 0xE45C; +// public static final int LIGHT_CCT_CTRL_BACK_COMMAND = 0xE45D; +// public static final int LIGHT_CCT_STATE_COMMAND = 0xE472; +// public static final int LIGHT_CCT_STATE_BACK_COMMAND = 0xE473; + //绐楀笜鎿嶄綔鐮併�佺姸鎬佽鍙栫爜 public static final int CURTAIN_CTRL_COMMAND = 0xE3E0; public static final int CURTAIN_CTRL_BACK_COMMAND = 0xE3E1; diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/Config/HDLApConfig.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/Config/HDLApConfig.java index 32963d5..e8ff927 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/Config/HDLApConfig.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/Config/HDLApConfig.java @@ -10,6 +10,10 @@ 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_LIGHT_CCT = 107; + public static final int TYPE_LIGHT_RGB = 108; + + public static final int TYPE_CURTAIN_GLYSTRO = 201; public static final int TYPE_CURTAIN_ROLLER = 202; diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLight/CCTBackInfo.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLight/CCTBackInfo.java new file mode 100644 index 0000000..8262933 --- /dev/null +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLight/CCTBackInfo.java @@ -0,0 +1,76 @@ +package com.hdl.sdk.hdl_core.HDLAppliances.HDLLight; + +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; + +/** + * Created by JLChen on 2020/10/20 + */ +public class CCTBackInfo { + private AppliancesInfo appliancesInfo; + private int brightness; //浜害 + private int lightType; //1-5//1鍗曡矾 2CCT 3RGB 4RGBW 5RGBWY + private int cctValue; //褰撳墠鑹叉俯鍊� + private byte[] curState;//鎺у埗鍥為淇℃伅 + + public int getCctValue() { + return cctValue; + } + + public void setCctValue(int cctValue) { + this.cctValue = cctValue; + } + + public CCTBackInfo() { + + } + + /** + * GeothermalBackInfo + * @param mAppliancesInfo + */ + public CCTBackInfo(AppliancesInfo mAppliancesInfo) { + this.appliancesInfo = mAppliancesInfo; + this.curState = mAppliancesInfo.getFeedbackState(); + if (this.curState == null) return; + if (this.curState.length >= 9) { + this.brightness = this.curState[1] & 0xFF; + this.lightType = this.curState[5] & 0xFF; + int high = this.curState[6] & 0xFF; + int low = this.curState[7] & 0xFF; + this.cctValue = high * 256 + low; + } + } + + public AppliancesInfo getAppliancesInfo() { + return appliancesInfo; + } + + public void setAppliancesInfo(AppliancesInfo appliancesInfo) { + this.appliancesInfo = appliancesInfo; + } + + public int getBrightness() { + return brightness; + } + + public void setBrightness(int brightness) { + this.brightness = brightness; + } + + public int getLightType() { + return lightType; + } + + public void setLightType(int lightType) { + this.lightType = lightType; + } + + public byte[] getCurState() { + return curState; + } + + public void setCurState(byte[] curState) { + this.curState = curState; + } + +} diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLight/RGBBackInfo.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLight/RGBBackInfo.java new file mode 100644 index 0000000..4054594 --- /dev/null +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLLight/RGBBackInfo.java @@ -0,0 +1,113 @@ +package com.hdl.sdk.hdl_core.HDLAppliances.HDLLight; + +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; + +/** + * Created by JLChen on 2020/10/20 + * ///1 閫昏緫鍥炶矾鍙� + * ///2 鏁翠綋浜害 + * ///3 棰滆壊鍙� 鍥哄畾涓� 254 + * ///4 杩愯鏃堕棿 楂樹綅 + * ///5 杩愯鏃堕棿 浣庝綅 + * ///6 閫昏緫鐏被鍨� 1-5 //1鍗曡矾 2CCT 3RGB 4RGBW 5RGBWY + * ///7 閫昏緫鍥炶矾 閫氶亾1鐨勫�� //RGB鏈�澶у�兼槸255 鍏跺畠绫讳负鏈�澶т负100 + * ///8 閫昏緫鍥炶矾 閫氶亾2鐨勫�� //RGB鏈�澶у�兼槸255 鍏跺畠绫讳负鏈�澶т负100 + * ///9 閫昏緫鍥炶矾 閫氶亾3鐨勫�� //RGB鏈�澶у�兼槸255 鍏跺畠绫讳负鏈�澶т负100 + * ///10 閫昏緫鍥炶矾 閫氶亾4鐨勫�� //RGB鏈�澶у�兼槸255 鍏跺畠绫讳负鏈�澶т负100 + * ///11 閫昏緫鍥炶矾 閫氶亾5鐨勫�� //RGB鏈�澶у�兼槸255 鍏跺畠绫讳负鏈�澶т负100 + * + * 锛�7~11浣嶆暟鎹級 + * 鎴朇CT鏃�:涓�鑸�2000-7000K(楂樹綅鍦ㄥ墠銆佷綆浣嶅湪鍚�) 2BYTE+3BYTE(鏃犳晥) (5BYTE) + * 鎴朢GB鏃�:R銆丟銆丅(0-255)锛� 3BYTE+2BYTE(鏃犳晥) (5BYTE) + */ +public class RGBBackInfo { + + private AppliancesInfo appliancesInfo; + private int brightness; //浜害 + private int lightType; //1-5//1鍗曡矾 2CCT 3RGB 4RGBW 5RGBWY + private int rStatus; //R + private int gStatus; //G + private int bStatus; //B + private byte[] curState;//鎺у埗鍥為淇℃伅 + + public RGBBackInfo() { + + } + + /** + * GeothermalBackInfo + * + * @param mAppliancesInfo + */ + public RGBBackInfo(AppliancesInfo mAppliancesInfo) { + this.appliancesInfo = mAppliancesInfo; + this.curState = mAppliancesInfo.getFeedbackState(); + + if (this.curState == null) return; + + if (this.curState.length >= 9) { + this.brightness = this.curState[1] & 0xFF; + this.lightType = this.curState[5] & 0xFF; + this.rStatus = this.curState[6] & 0xFF; + this.gStatus = this.curState[7] & 0xFF; + this.bStatus = this.curState[8] & 0xFF; + } + } + + public AppliancesInfo getAppliancesInfo() { + return appliancesInfo; + } + + public void setAppliancesInfo(AppliancesInfo appliancesInfo) { + this.appliancesInfo = appliancesInfo; + } + + public int getBrightness() { + return brightness; + } + + public void setBrightness(int brightness) { + this.brightness = brightness; + } + + public int getLightType() { + return lightType; + } + + public void setLightType(int lightType) { + this.lightType = lightType; + } + + public int getrStatus() { + return rStatus; + } + + public void setrStatus(int rStatus) { + this.rStatus = rStatus; + } + + public int getgStatus() { + return gStatus; + } + + public void setgStatus(int gStatus) { + this.gStatus = gStatus; + } + + public int getbStatus() { + return bStatus; + } + + public void setbStatus(int bStatus) { + this.bStatus = bStatus; + } + + public byte[] getCurState() { + return curState; + } + + public void setCurState(byte[] curState) { + this.curState = curState; + } + +} diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java index 1c572c8..e1a3746 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java @@ -16,6 +16,7 @@ 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.HDLLight.RGBBackInfo; import com.hdl.sdk.hdl_core.HDLAppliances.HDLLogic.LogicCtrlBackInfo; import com.hdl.sdk.hdl_core.HDLAppliances.HDLSecurity.Parser.SecurityParser; import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; @@ -29,6 +30,7 @@ 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.LightRGBCtrlBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.SecurityArmingFeedBackEvent; import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; import com.hdl.sdk.hdl_core.Util.NetUtil.NetWorkUtil; @@ -60,6 +62,8 @@ private static Timer securityCtrlFailTimer = null;//瀹夐槻妯″潡鎿嶄綔澶辫触Timer private static Timer commonSwitchCtrlFailTimer = null;//閫氱敤寮�鍏冲け璐imer + private static Timer lightRgbCtrlFailTimer = null;//RGB澶辫触Timer + private static Timer lightCCTCtrlFailTimer = null;//CCT澶辫触Timer /** * 鍒濆鍖� @@ -73,6 +77,7 @@ /** * 寮�鍚痓us妯″紡 * 鍚敤6000绔彛 + * * @param context */ public static void startHomeMode(Context context) { @@ -86,6 +91,7 @@ /** * 寮�鍚疪CU妯″紡 * 鍚敤6008绔彛 + * * @param context * @param newRcuIp RCU鐨処P鍦板潃 */ @@ -107,15 +113,17 @@ /** * 鑾峰彇鏈湴骞挎挱IP + * * @return */ - public static String getLocalBroadCastIp(){ + public static String getLocalBroadCastIp() { return NetWorkUtil.getLocalBroadCast(); } /** * 鏄惁寮�鍚疭DK鏃ュ織鎵撳嵃 * 2019-07-10鏂板 + * * @param bOpen */ public static void setHDLLogOpen(boolean bOpen) { @@ -133,7 +141,6 @@ // private static void devicesSearch() { // HandleSearch.getRcuIp(); // } - /** @@ -762,8 +769,8 @@ && info.getChannelNum() == infos.get(j).getChannelNum() ) { //杩欓噷搴旇鏄淇鐨勶紝鏆傛椂鏈壘鍒般�� - //20190712瑙e喅寮哄埗杞崲int绫诲瀷闂�� - int state = HDLUtlis.getIntegerByObject(infos.get(j).getCurStateObject()); + //20190712瑙e喅寮哄埗杞崲int绫诲瀷闂�� + int state = HDLUtlis.getIntegerByObject(infos.get(j).getCurStateObject()); switch (state) { case -1: curState = 0; @@ -1139,6 +1146,7 @@ /** * 鑾峰彇閫氱敤寮�鍏崇姸鎬� + * * @param info */ public static void getCommonSwitchStateFromNetwork(final AppliancesInfo info) { @@ -1159,6 +1167,7 @@ /** * 鑾峰彇瀹夐槻妯″潡鐘舵�� + * * @param info */ public static void getSecurityStateFromNetwork(final AppliancesInfo info) { @@ -1180,6 +1189,7 @@ /** * 瀹夐槻妯″潡 甯冮槻璁剧疆 * 2020-06-23 + * * @param info */ public static void securityArmingCtrl(final AppliancesInfo info, int state) { @@ -1197,7 +1207,7 @@ @Override public void run() { if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { - EventBus.getDefault().post(new SecurityArmingFeedBackEvent(info,0, false)); + EventBus.getDefault().post(new SecurityArmingFeedBackEvent(info, 0, false)); } } }, 5000); @@ -1231,6 +1241,7 @@ /** * 鑾峰彇骞叉帴鐐逛紶鎰熷櫒妯″潡鐘舵�� + * * @param info */ public static void getDryContactSensorStateFromNetwork(final AppliancesInfo info) { @@ -1281,4 +1292,130 @@ } } + /**************************************2020-10-20 鏂板***************************************/ + /** + * 鎺у埗RGB + * + * @param info + */ + public static void lightRGBCtrl(final AppliancesInfo info, int brightness, int rStatus, int gStatus, int bStatus) { + + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); + if (info.getBigType() == Configuration.LIGTH_BIG_TYPE) { + + if (lightRgbCtrlFailTimer != null) { + lightRgbCtrlFailTimer.cancel(); + lightRgbCtrlFailTimer = null; + } + + byte[] bytes = new byte[]{ + (byte) info.getChannelNum(), + (byte) brightness, + (byte) 254, + 0, + 0, + 3, + (byte) rStatus, + (byte) gStatus, + (byte) bStatus, + 0, + 0 + }; + + addSendData(info, bytes, Configuration.CONTROL); + + lightRgbCtrlFailTimer = new Timer(); + lightRgbCtrlFailTimer.schedule(new TimerTask() { + @Override + public void run() { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { + HDLLog.info("RGB鎺у埗澶辫触"); + RGBBackInfo mRGBBackInfo = new RGBBackInfo(); + mRGBBackInfo.setAppliancesInfo(info); + EventBus.getDefault().post(new LightRGBCtrlBackEvent(mRGBBackInfo, false)); + } + } + }, mRequestTimeout); + } else { + HDLLog.info("djlCtrl: 璁惧鎺у埗涓嶅湪鑼冨洿鍐�" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + } + + + /** + * 鑾峰彇CCT 鎴栬�匯GB鐏姸鎬� + * + * @param info + */ + public static void getRGBCCTStateFromNetwork(final AppliancesInfo info) { + if (info == null) { + return; + } + HDLDeviceManager.isGetDeviceStateSuccess = false; + switch (info.getDeviceType()) { + case HDLApConfig.TYPE_LIGHT_RGB: + case HDLApConfig.TYPE_LIGHT_CCT: + //鍙戦�丆CT RGB鐘舵�佹暟鎹� + addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); + break; + default: + HDLLog.info("涓嶆槸瀹夐槻妯″潡"); + break; + } + } + + /** + * 鎺у埗CCT + * + * @param info + */ + public static void lightCCTCtrl(final AppliancesInfo info, int brightness, int cctStatus) { + + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); + if (info.getBigType() == Configuration.LIGTH_BIG_TYPE) { + + if (lightCCTCtrlFailTimer != null) { + lightCCTCtrlFailTimer.cancel(); + lightCCTCtrlFailTimer = null; + } + + byte[] bytes = new byte[]{ + (byte) info.getChannelNum(), + (byte) brightness, + (byte) 254, + 0, + 0, + 2, + (byte) (cctStatus / 256), + (byte) (cctStatus % 256), + 0, + 0, + 0 + }; + + addSendData(info, bytes, Configuration.CONTROL); + + lightCCTCtrlFailTimer = new Timer(); + lightCCTCtrlFailTimer.schedule(new TimerTask() { + @Override + public void run() { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { + HDLLog.info("RGB鎺у埗澶辫触"); + RGBBackInfo mRGBBackInfo = new RGBBackInfo(); + mRGBBackInfo.setAppliancesInfo(info); + EventBus.getDefault().post(new LightRGBCtrlBackEvent(mRGBBackInfo, false)); + } + } + }, mRequestTimeout); + } else { + HDLLog.info("djlCtrl: 璁惧鎺у埗涓嶅湪鑼冨洿鍐�" + + " LittleType = " + info.getLittleType() + + " BigType = " + info.getBigType() + ); + } + } + } diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java index 34d027c..54518fe 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java @@ -17,7 +17,9 @@ 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.CCTBackInfo; import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.LightCtrlBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.RGBBackInfo; 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.HDLSecurity.SecurityBackInfo; @@ -38,8 +40,10 @@ 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.LightCCTCtrlBackEvent; 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.LightRGBCtrlBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.SecurityAlarmFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.SecurityArmingFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.WarningInfoEvent; @@ -118,28 +122,30 @@ /** * 閰嶇疆绠�鏄撶紪绋嬫悳绱㈣繑鍥炵殑榛樿鍙傛暟 - * @param mSDKLocalBigClass 澶х被ID + * + * @param mSDKLocalBigClass 澶х被ID * @param mSDKLocalSmallClass 灏忕被ID - * @param mSDKLocalRemark 澶囨敞 + * @param mSDKLocalRemark 澶囨敞 */ - public static void setEasyProgrammingSearchLocalData(int mSDKLocalBigClass, int mSDKLocalSmallClass, String mSDKLocalRemark){ + public static void setEasyProgrammingSearchLocalData(int mSDKLocalBigClass, int mSDKLocalSmallClass, String mSDKLocalRemark) { SDKLocalBigClass = mSDKLocalBigClass; SDKLocalSmallClass = mSDKLocalSmallClass; - if(mSDKLocalRemark != null){ + if (mSDKLocalRemark != null) { SDKLocalRemark = mSDKLocalRemark; } isAllowEasyProgrammingSearch = true; } - public static void setEasyProgrammingSearchLocalData(int mSDKLocalBigClass, int mSDKLocalSmallClass){ - setEasyProgrammingSearchLocalData(mSDKLocalBigClass, mSDKLocalSmallClass,null); + public static void setEasyProgrammingSearchLocalData(int mSDKLocalBigClass, int mSDKLocalSmallClass) { + setEasyProgrammingSearchLocalData(mSDKLocalBigClass, mSDKLocalSmallClass, null); } /** * 璁剧疆鏄惁鍏佽琚畝鏄撶紪绋嬫悳绱� + * * @param isAllow */ - public static void setIsAllowEasyProgrammingSearch(boolean isAllow){ + public static void setIsAllowEasyProgrammingSearch(boolean isAllow) { isAllowEasyProgrammingSearch = isAllow; } @@ -180,6 +186,12 @@ case Configuration.AIR_HVAC_CTRL_BACK_COMMAND: case Configuration.FRESH_AIR_CTRL_BACK_COMMAND: //20190709鏂板 handleCtrlData(getDatas); + break; + case Configuration.LIGHT_RGB_CTRL_BACK_COMMAND: //2020-10-19鏂板 + handleRGBCCTCtrlData(getDatas); + break; + case Configuration.LIGHT_RGB_STATE_BACK_COMMAND: //2020-10-19鏂板 + handleRGBCCTStateData(getDatas); break; case Configuration.GEOTHERMAL_MODULE_CTRL_BACK_COMMAND://20190709鏂板 handleGeothermalCtrlData(getDatas); @@ -326,7 +338,7 @@ * @param getDatas */ private static void sendDeviceSearchBackInfo(UdpDataBean getDatas) { - byte[] remarkByte = StringUtil.stringtoBytes(SDKLocalRemark); + byte[] remarkByte = StringUtil.stringtoBytes(SDKLocalRemark); byte[] addBytes = new byte[25]; addBytes[0] = getDatas.addBytes[0]; addBytes[1] = getDatas.addBytes[1]; @@ -352,11 +364,12 @@ /** * 鏀跺埌绠�鏄撶紪绋嬫悳绱㈤潪缃戠粶璁惧 + * * @param getDatas */ - public static void handleDeviceSearchBackData(UdpDataBean getDatas){ + public static void handleDeviceSearchBackData(UdpDataBean getDatas) { //鍒ゆ柇鏄惁鍏佽琚畝鏄撶紪绋嬫悳绱㈠拰鍥炲 - if(!isAllowEasyProgrammingSearch) return; + if (!isAllowEasyProgrammingSearch) return; if (getDatas.addBytes.length == 2) { sendDeviceSearchBackInfo(getDatas); @@ -365,7 +378,7 @@ 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 + && (getDatas.addBytes[i + 1] & 0xFF) == Crc.localDeviceID ) { isExit = true; break; @@ -373,14 +386,13 @@ } } - if(!isExit){ + if (!isExit) { sendDeviceSearchBackInfo(getDatas); } } } - /** @@ -595,9 +607,10 @@ * 澶勭悊鐏厜杩斿洖 * 2020-1-18 * 淇娣峰悎璋冨厜娣峰悎寮�鍏� 绫绘ā鍧楅棶棰� + * * @param getDatas */ - private static void handleLightCtrlData(UdpDataBean getDatas){ + private static void handleLightCtrlData(UdpDataBean getDatas) { if (TextUtils.isEmpty(HandleSearch.rcuIp)) { outter: @@ -607,7 +620,7 @@ ) { 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).getLittleType() == 9 || infos.get(j).getLittleType() == 10) { if (infos.get(j).getPhysicsChannelNum() == (getDatas.addBytes[0] & 0xFF)) { @@ -628,7 +641,7 @@ } - }else { + } else { if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { @@ -776,7 +789,7 @@ 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 + 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 ) { @@ -1981,7 +1994,7 @@ hvacBytes[i - 23] = getDatas.addBytes[i]; } - HDLLog.info("鑾峰彇澶囨敞Configuration.AIR_BIG_TYPE锛� "+ StringUtil.ByteArrToHex(hvacBytes,0, hvacBytes.length)); + 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()) { @@ -2409,7 +2422,7 @@ devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes); EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); break outter; - }else { + } else { HDLLog.info("handleFreshAirStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷"); } } @@ -2450,7 +2463,7 @@ } break outter; - }else { + } else { HDLLog.info("handleFreshAirStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷"); } } @@ -2458,7 +2471,6 @@ } } } - /** @@ -2554,21 +2566,23 @@ /** * 璁剧疆鎺у埗鏄惁鎴愬姛鐘舵�� + * * @param info * @param success */ - public static void setDeviceCtrlSuccessStateWithInfo(AppliancesInfo info, Boolean 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; + public static Boolean getDeviceCtrlSuccessStateWithInfo(AppliancesInfo info) { + Boolean success = ctrlSuccessStateHashMap.get(info.getDeviceKey()); + if (success == null) success = false; return success; } @@ -2576,6 +2590,7 @@ * 淇濆瓨璁惧鏁版嵁鍒楄〃 * 鏍规嵁闇�瑕侊紝瀹炴椂淇濆瓨褰撳墠鏁版嵁 * 2019-10-14 + * * @return boolean */ public static boolean saveDevicesDataList() { @@ -2619,7 +2634,7 @@ HandleSearch.curSearchMode = HandleSearch.GET_RCU_DEVICES; HDLUdpCore.closeSocket6000(); HDLUdpCore.init6008(); - }else { + } else { HandleSearch.curSearchMode = HandleSearch.GET_BUS_DEVICES; HDLUdpCore.closeSocket6008(); HDLUdpCore.init6000(); @@ -2629,8 +2644,7 @@ } - - private static void setRemarkList(){ + 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) { @@ -2877,4 +2891,106 @@ } + /** + * RGB CCT璁惧鎺у埗鏁版嵁 + * 2020-10-20 鏂板 + * + * @param getDatas + */ + private static void handleRGBCCTCtrlData(UdpDataBean getDatas) { + if (getDatas.addBytes.length >= 9) { + //1-5//1鍗曡矾 2CCT 3RGB 4RGBW 5RGBWY + if (getDatas.addBytes[5] == 3) {//RGB + outter: + for (int i = 0, len = devicesDataList.size(); i < len; i++) { + if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID + && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID) { + + List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); + for (int j = 0, len2 = infos.size(); j < len2; j++) { + if (infos.get(j).getBigType() == Configuration.LIGTH_BIG_TYPE + && infos.get(j).getDeviceType() == HDLApConfig.TYPE_LIGHT_RGB + && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF) + ) { + devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes); + AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); + RGBBackInfo info = new RGBBackInfo(mInfo); + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); + EventBus.getDefault().post(new LightRGBCtrlBackEvent(info, true)); + } + } + break outter;//璺冲嚭寰幆 + } + } + } else if (getDatas.addBytes[5] == 2) {//CCT + outter: + for (int i = 0, len = devicesDataList.size(); i < len; i++) { + if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID + && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID) { + + List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); + for (int j = 0, len2 = infos.size(); j < len2; j++) { + if (infos.get(j).getBigType() == Configuration.LIGTH_BIG_TYPE + && infos.get(j).getDeviceType() == HDLApConfig.TYPE_LIGHT_CCT + && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF) + ) { + devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes); + AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); + CCTBackInfo info = new CCTBackInfo(mInfo); + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); + EventBus.getDefault().post(new LightCCTCtrlBackEvent(info, true)); + } + } + break outter;//璺冲嚭寰幆 + } + } + + } + + } + + + } + + /** + * RGB CCT 鐘舵�佽鍙栧洖澶嶆暟鎹� + * 2020-10-20 鏂板 + * + * @param getDatas + */ + private static void handleRGBCCTStateData(UdpDataBean getDatas) { + outter: + for (int i = 0, len = devicesDataList.size(); i < len; i++) { + if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID + && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID + ) { + List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); + for (int j = 0, len2 = infos.size(); j < len2; j++) { + if (infos.get(j).getBigType() == Configuration.LIGTH_BIG_TYPE + && (infos.get(j).getDeviceType() == HDLApConfig.TYPE_LIGHT_RGB || infos.get(j).getDeviceType() == HDLApConfig.TYPE_LIGHT_CCT) + && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { + if (getDatas.addBytes.length >= 9) { + byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getFeedbackState(); + if (getBytes == null || getBytes.length < 9) {//鏍囧噯鍗忚闀垮害鏄�11锛屼絾鏄姄鍖呭彂鐜版湁鐨勮澶囦細灏戜簬11 + getBytes = new byte[11]; + } + System.arraycopy(getDatas.addBytes, 0, getBytes, 0, Math.min(getDatas.addBytes.length, 11)); + 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("RGB CCT鐘舵�佸弽棣堟暟鎹紓甯�"); + } + + break outter; + } else { +// HDLLog.info("handleFreshAirStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷"); + } + } + break outter; + } + } + + } + } diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java index 42479d3..57390c6 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java @@ -31,8 +31,6 @@ private static DatagramSocket datagramSocket6000 = null; - - /** * 鍙戦�佹暟鎹寘 * 鐐瑰鐐规垨骞挎挱 @@ -40,7 +38,7 @@ * @param sendDatas */ public static void sendData(final Crc sendDatas) { - HDLLog.info("HDLsendData锛� "+ StringUtil.ByteArrToHex(sendDatas.GetSendBytes(),0, sendDatas.GetSendBytes().length)); + HDLLog.info("HDLsendData锛� " + StringUtil.ByteArrToHex(sendDatas.GetSendBytes(), 0, sendDatas.GetSendBytes().length)); // sendTestCMD(sendDatas.GetSendBytes(), HDLTest.SEND_TEST_PORT); new Thread(new Runnable() { @@ -71,12 +69,11 @@ sendSocket.send(packet); sendSocket.close(); } catch (Exception e) { - HDLLog.info( "HDL 鍙戦�佹搷浣滃懡浠ゅけ璐�:" + e); + HDLLog.info("HDL 鍙戦�佹搷浣滃懡浠ゅけ璐�:" + e); } } }).start(); } - /** @@ -178,9 +175,9 @@ */ public static void init6008() { if (datagramSocket6008 != null) { - HDLLog.info( "HDL SDK 6008 宸插惎鍔�"); + HDLLog.info("HDL SDK 6008 宸插惎鍔�"); } else { - HDLLog.info( "HDLSocket 6008 init"); + HDLLog.info("HDLSocket 6008 init"); // sdkHeartBeat(); new Thread(new Runnable() { @Override @@ -221,9 +218,9 @@ */ public static void init6000() { if (datagramSocket6000 != null) { - HDLLog.info( "HDL SDK 6000 宸插惎鍔�"); + HDLLog.info("HDL SDK 6000 宸插惎鍔�"); } else { - HDLLog.info( "HDLSocket 6000 init"); + HDLLog.info("HDLSocket 6000 init"); // sdkHeartBeat(); new Thread(new Runnable() { @Override @@ -338,7 +335,7 @@ return; } - HDLLog.info("HDL ReceiveBytes锛� "+ StringUtil.ByteArrToHex(receiveBytes,0, receiveBytes.length)); +// HDLLog.info("HDL ReceiveBytes锛� " + StringUtil.ByteArrToHex(receiveBytes, 0, receiveBytes.length)); //鏍¢獙鏄惁涓篐DL 鏁版嵁 byte[] hdlDataVerify = new byte[10]; @@ -391,7 +388,7 @@ // } //2019-10-8 鐩爣瀛愮綉鍙疯澶囧彿杩囨护鍒ゆ柇 - if((targetSubnetID == 0xFF && targetDeviceID == 0xFF) || (targetSubnetID == Crc.localSubnetID && targetDeviceID == Crc.localDeviceID)) { + if ((targetSubnetID == 0xFF && targetDeviceID == 0xFF) || (targetSubnetID == Crc.localSubnetID && targetDeviceID == Crc.localDeviceID)) { HandleOutsideData(targetSubnetID, targetDeviceID, command, usefulBytes, receiveBytes, udpDataBean); HandleInsideData(udpDataBean); } @@ -416,7 +413,7 @@ if (sendDatas.addBytes[0] == HandleSearch.random1 && sendDatas.addBytes[1] == HandleSearch.random2 && HandleSearch.rcuIp.equals(sendDatas.ipAddress) - ) { + ) { HDLDeviceManager.handle(sendDatas, sendDatas.command); } @@ -440,6 +437,9 @@ case Configuration.SECURITY_ALARM_CTRL_BACK_COMMAND://20190729 鎶ヨ璁剧疆鍙嶉 case Configuration.DRY_CONTACT_STATE_BACK_COMMAND: case Configuration.DRY_CONTACT_BROADCAST_STATE_COMMAND://2020-06-23 澧炲姞骞叉帴鐐圭姸鎬佸洖澶� + case Configuration.LIGHT_RGB_CTRL_BACK_COMMAND://2020-10-19 澧炲姞RGB CCT鎺у埗鍥炲 + case Configuration.LIGHT_RGB_STATE_BACK_COMMAND://2020-10-19 澧炲姞RGB CCT鐘舵�佸洖澶� + case Configuration.CURTAIN_STATE_BACK_COMMAND: case Configuration.AIR_STATE_BACK_COMMAND: @@ -472,7 +472,7 @@ case Configuration.RCU_SEARCH_COMMAND: if (sendDatas.port == Configuration.RCU_SEND_PORT) { - HDLLog.info( "鏀跺埌鎼滅储RCU鍛戒护"); + HDLLog.info("鏀跺埌鎼滅储RCU鍛戒护"); HDLDeviceManager.handle(sendDatas, sendDatas.command); } @@ -484,7 +484,7 @@ // HDLDeviceManager.handle(sendDatas, Configuration.RCU_READ); // } if (sendDatas.port == Configuration.RCU_SEND_PORT) { - HDLLog.info( "鏀跺埌璇诲彇SDK淇℃伅鍛戒护"); + HDLLog.info("鏀跺埌璇诲彇SDK淇℃伅鍛戒护"); HDLDeviceManager.handle(sendDatas, sendDatas.command); } @@ -585,14 +585,13 @@ // } - 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 @@ -608,7 +607,7 @@ socket6001.send(packet); socket6001.close(); } catch (Exception e) { - HDLLog.info( "HDL 鍙戦�佸懡浠ゅけ璐�:" + e); + HDLLog.info("HDL 鍙戦�佸懡浠ゅけ璐�:" + e); } } }).start(); @@ -645,6 +644,7 @@ /** * 鍒ゆ柇鏄惁涓篐DL鏁版嵁 + * * @param bytes * @return */ diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/LightCCTCtrlBackEvent.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/LightCCTCtrlBackEvent.java new file mode 100644 index 0000000..de5c8f8 --- /dev/null +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/LightCCTCtrlBackEvent.java @@ -0,0 +1,24 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.CCTBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.RGBBackInfo; + +/** + * Created by jlchen on 2020/10/20. + */ +public class LightCCTCtrlBackEvent { + CCTBackInfo mCCTBackInfo; + boolean isSuccess; + + public LightCCTCtrlBackEvent(CCTBackInfo cctBackInfo, boolean isSuccess){ + this.isSuccess = isSuccess; + this.mCCTBackInfo = cctBackInfo; + } + + public CCTBackInfo getCCTBackInfo() { + return mCCTBackInfo; + } + + public boolean isSuccess() { + return isSuccess; + } +} diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/LightRGBCtrlBackEvent.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/LightRGBCtrlBackEvent.java new file mode 100644 index 0000000..ac86124 --- /dev/null +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/LightRGBCtrlBackEvent.java @@ -0,0 +1,23 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLLight.RGBBackInfo; + +/** + * Created by jlchen on 2020/10/20. + */ +public class LightRGBCtrlBackEvent { + RGBBackInfo mRGBBackInfo; + boolean isSuccess; + + public LightRGBCtrlBackEvent(RGBBackInfo rgbBackInfo, boolean isSuccess){ + this.isSuccess = isSuccess; + this.mRGBBackInfo = rgbBackInfo; + } + + public RGBBackInfo getRGBBackInfo() { + return mRGBBackInfo; + } + + public boolean isSuccess() { + return isSuccess; + } +} diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java index 8ad79e7..0152844 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java @@ -40,11 +40,18 @@ 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; + if(bigType == Configuration.LIGTH_BIG_TYPE && (littleType == 7 || littleType == 8)){ + //2020-10-20 濡傛灉鏄疪GBhuozCCT鍏堝彧浣跨敤1鍥炶矾锛屽悗闈㈢湅闇�瑕佸啀淇敼锛屽洜涓哄彂鐜扮畝鏄撶紪绋嬫悳绱紝鎴戝彂鐜拌繖CCT鎴栬�匯GB璁惧鍙敤1锛�2涓洖璺紝浣嗘槸浠栬繕鏄洖澶嶆湁60澶氫釜鍥炶矾锛屽悗闈㈣璁哄啀澶勭悊 + //鍥炶矾鎬绘暟寮哄埗淇敼鎴�1鍏� + channelNum = 1; + } + curCount++; int curChannelNum = 0; while (curChannelNum < channelNum) { @@ -126,6 +133,12 @@ isWant = true; break; case 1: + isWant = true; + break; + case 7: + isWant = true; + break; + case 8: isWant = true; break; case 9: @@ -288,9 +301,11 @@ break; case 7: appliancesInfo.setDeviceName("DALI"); + appliancesInfo.setDeviceType(HDLApConfig.TYPE_LIGHT_CCT); break; case 8: - appliancesInfo.setDeviceName("鑷畾涔夐�昏緫鐏�"); + appliancesInfo.setDeviceName("鑷畾涔夐�昏緫鐏疪GB"); + appliancesInfo.setDeviceType(HDLApConfig.TYPE_LIGHT_RGB); break; case 9: appliancesInfo.setDeviceName("娣峰悎璋冨厜绫�"); @@ -317,6 +332,14 @@ appliancesInfo.setParentRemarks(parentRemarks); appliancesInfo.setPort(port); appliancesInfo.setIpAddress(ipAddress); + + if(littleType == 7 || littleType == 8){ + appliancesInfo.setCtrlCommand(Configuration.LIGHT_RGB_CTRL_COMMAND); + appliancesInfo.setCtrlBackCommand(Configuration.LIGHT_RGB_CTRL_BACK_COMMAND); + appliancesInfo.setStateCommand(Configuration.LIGHT_RGB_STATE_COMMAND); + appliancesInfo.setStateBackCommand(Configuration.LIGHT_RGB_STATE_BACK_COMMAND); + } + } } -- Gitblit v1.8.0