README.md
@@ -2,6 +2,33 @@ HDL XW Android SDK Copyright (c) 2019 HDL Inc. SDK 版本:hdl_lib_v1.6.8.20191016_beta 1.控制都改成广播形式了,不记录一端口的IP。 SDK 版本:hdl_lib_v1.6.4.20191015_beta 1.增加搜索完设备或者备注刷新完,自动保存一次数据到本地。 2.增加读取本地数据接口; 3.增加刷新所有设备的备注和状态接口; 接口说明: /** * 读取和加载本地数据 */ private void getLocalDevicesDataList() { devicesDatas = HDLDeviceManager.getLocalDevicesDataList(); if (devicesDatas.size() > 0) { updateDeviceListView(); HandleSearch.refreshAllDevicesStateAndRemarks();//如果本地有数据,可以调用该方法,遍历发送指令,刷新所有设备的备注和状态 } else { //showToast("本地数据为空"); } } /**保存数据到本地接口,除SDK自动保存后,上层可以选择手动调用保存*/ HDLDeviceManager.saveDevicesDataList(); 提供声必可SDK项目 ##Version 1.0.2 app/src/main/AndroidManifest.xml
@@ -18,7 +18,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".activity.AddDevicesManuallyActivity"></activity> <activity android:name=".activity.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> @@ -30,7 +30,7 @@ <activity android:name=".activity.CtrlActivity" /> <activity android:name=".activity.AudioActivity" /> <activity android:name=".activity.FreshAirActivity" /> <activity android:name=".activity.GeothermalActivity"></activity> <activity android:name=".activity.GeothermalActivity" /> <receiver android:name=".activity.BootComplete"> <intent-filter> app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AddDevicesManuallyActivity.java
New file @@ -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(); } } app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlActivity.java
@@ -23,6 +23,7 @@ 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 org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -126,8 +127,9 @@ sensorText.setVisibility(View.GONE); if (appliancesInfo.getCurState() != null) { int curLightState = (int) appliancesInfo.getCurState(); if (appliancesInfo.getCurStateObject() != null) { int curLightState = HDLUtlis.getIntegerByObject(appliancesInfo.getCurStateObject()); lightText.setText("当前灯光亮度:" + curLightState); lightBtn.setText("当前灯光亮度:" + curLightState); @@ -163,9 +165,9 @@ curtainBtn4.setVisibility(View.GONE); curtainBtn5.setVisibility(View.GONE); if (appliancesInfo.getCurState() != null) { if (appliancesInfo.getCurStateObject() != null) { String stringCurtainState = ""; int curCurtainState = (int) appliancesInfo.getCurState(); int curCurtainState = HDLUtlis.getIntegerByObject(appliancesInfo.getCurStateObject()); Log.i("djl", "curCurtainState = " + curCurtainState); switch (curCurtainState) { case CurtainCtrlParser.TYPE_STATE_PAUSE: @@ -197,8 +199,8 @@ curText1.setVisibility(View.GONE); curtainBtn.setVisibility(View.GONE); if (appliancesInfo.getCurState() != null) { curText2.setText("当前窗帘状态:" + appliancesInfo.getCurState()); if (appliancesInfo.getCurStateObject() != null) { curText2.setText("当前窗帘状态:" + HDLUtlis.getIntegerByObject(appliancesInfo.getCurStateObject())); } else { curText2.setText("未获取到窗帘模块状态"); } @@ -410,8 +412,8 @@ lightText.setVisibility(View.GONE); logicBtn.setVisibility(View.GONE); logicText.setVisibility(View.GONE); if (appliancesInfo.getCurState() != null) { float value = (float) appliancesInfo.getCurState(); if (appliancesInfo.getCurStateObject() != null) { float value = (float) appliancesInfo.getCurStateObject(); sensorBtn.setText("传感器数值:" + value); } break; @@ -636,10 +638,10 @@ } int tempInt = Integer.parseInt(tempStr); if (tempInt < 16 || tempInt > 30) { showToast("温度设置范围为:16~30摄氏度(℃)"); return; } // if (tempInt < 16 || tempInt > 30) { // showToast("温度设置范围为:16~30摄氏度(℃)"); // return; // } switch (airModeState) { case 0: @@ -948,7 +950,7 @@ showToast("获取灯光状态失败,请重新再试"); return; } lightBtn.setText("亮度 = " + event.getAppliancesInfo().getCurState()); lightBtn.setText("亮度 = " + HDLUtlis.getIntegerByObject(event.getAppliancesInfo().getCurStateObject())); } break; case HDLApConfig.TYPE_CURTAIN_GLYSTRO: @@ -961,7 +963,7 @@ } //窗帘模块:curState:0=停止,1=打开,2=关闭。 //开合帘电机,卷帘电机:curState:1-100开合度。 int curState = (int) event.getAppliancesInfo().getCurState(); int curState = HDLUtlis.getIntegerByObject(event.getAppliancesInfo().getCurStateObject()); if (event.getAppliancesInfo().getDeviceType() == HDLApConfig.TYPE_CURTAIN_MODULE) {//判断是否为窗帘模块,否则为开合帘或卷帘电机 switch (curState) { case CurtainCtrlParser.curtainOff: @@ -1123,7 +1125,7 @@ showToast("获取传感器---干接点状态失败,请重新再试"); return; } float dryContactValue = (float) event.getAppliancesInfo().getCurState(); float dryContactValue = (float) event.getAppliancesInfo().getCurStateObject(); String dryContactUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---干接点状态:" + dryContactValue + dryContactUnit); Log.i("djl", "传感器---干接点状态:" + dryContactValue + dryContactUnit); @@ -1134,7 +1136,7 @@ showToast("获取传感器---移动探测灵敏度状态失败,请重新再试"); return; } float mdValue = (float) event.getAppliancesInfo().getCurState(); float mdValue = (float) event.getAppliancesInfo().getCurStateObject(); String mdValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---移动探测灵敏度:" + mdValue + mdValueUnit); Log.i("djl", "传感器---移动探测灵敏度:" + mdValue + mdValueUnit); @@ -1145,7 +1147,7 @@ showToast("获取传感器---温度状态失败,请重新再试"); return; } float tempValue = (float) event.getAppliancesInfo().getCurState(); float tempValue = (float) event.getAppliancesInfo().getCurStateObject(); String tempValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---温度:" + tempValue + tempValueUnit); Log.i("djl", "传感器---温度:" + tempValue + tempValueUnit); @@ -1156,7 +1158,7 @@ showToast("获取传感器---湿度状态失败,请重新再试"); return; } float humidityValue = (float) event.getAppliancesInfo().getCurState(); float humidityValue = (float) event.getAppliancesInfo().getCurStateObject(); String humidityValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---湿度:" + humidityValue + humidityValueUnit); Log.i("djl", "传感器---湿度:" + humidityValue + humidityValueUnit); @@ -1167,7 +1169,7 @@ showToast("获取传感器---照度状态失败,请重新再试"); return; } float illuminaceValue = (float) event.getAppliancesInfo().getCurState(); float illuminaceValue = (float) event.getAppliancesInfo().getCurStateObject(); String illuminaceValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---照度:" + illuminaceValue + illuminaceValueUnit); Log.i("djl", "传感器---照度:" + illuminaceValue + illuminaceValueUnit); @@ -1178,7 +1180,7 @@ showToast("获取传感器---当前空气质量等级状态失败,请重新再试"); return; } float vocValue = (float) event.getAppliancesInfo().getCurState(); float vocValue = (float) event.getAppliancesInfo().getCurStateObject(); String vocValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---当前空气质量等级:" + vocValue + vocValueUnit); Log.i("djl", "传感器---当前空气质量等级:" + vocValue + vocValueUnit); @@ -1189,7 +1191,7 @@ showToast("获取传感器---pm2.5状态失败,请重新再试"); return; } float pm2_5Value = (float) event.getAppliancesInfo().getCurState(); 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); @@ -1200,7 +1202,7 @@ showToast("获取传感器---二氧化碳状态失败,请重新再试"); return; } float co2Value = (float) event.getAppliancesInfo().getCurState(); float co2Value = (float) event.getAppliancesInfo().getCurStateObject(); String co2ValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---二氧化碳:" + co2Value + co2ValueUnit); Log.i("djl", "传感器---二氧化碳:" + co2Value + co2ValueUnit); @@ -1211,7 +1213,7 @@ showToast("获取传感器---液化石油气状态失败,请重新再试"); return; } float lpgValue = (float) event.getAppliancesInfo().getCurState(); float lpgValue = (float) event.getAppliancesInfo().getCurStateObject(); String lpgValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---液化石油气:" + lpgValue + lpgValueUnit); Log.i("djl", "传感器---液化石油气:" + lpgValue + lpgValueUnit); @@ -1222,7 +1224,7 @@ showToast("获取传感器---人工煤气状态失败,请重新再试"); return; } float coh2Value = (float) event.getAppliancesInfo().getCurState(); float coh2Value = (float) event.getAppliancesInfo().getCurStateObject(); String coh2ValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---人工煤气:" + coh2Value + coh2ValueUnit); Log.i("djl", "传感器---人工煤气:" + coh2Value + coh2ValueUnit); @@ -1233,7 +1235,7 @@ showToast("获取传感器---天然气状态失败,请重新再试"); return; } float ch4Value = (float) event.getAppliancesInfo().getCurState(); float ch4Value = (float) event.getAppliancesInfo().getCurStateObject(); String ch4ValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---天然气:" + ch4Value + ch4ValueUnit); Log.i("djl", "传感器---天然气:" + ch4Value + ch4ValueUnit); @@ -1244,7 +1246,7 @@ showToast("获取传感器---烟雾状态失败,请重新再试"); return; } float smogValue = (float) event.getAppliancesInfo().getCurState(); float smogValue = (float) event.getAppliancesInfo().getCurStateObject(); String smogValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---烟雾:" + smogValue + smogValueUnit); Log.i("djl", "传感器---烟雾:" + smogValue + smogValueUnit); @@ -1255,7 +1257,7 @@ showToast("获取传感器---风速状态失败,请重新再试"); return; } float windSpeedValue = (float) event.getAppliancesInfo().getCurState(); float windSpeedValue = (float) event.getAppliancesInfo().getCurStateObject(); String windSpeedValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---风速:" + windSpeedValue + windSpeedValueUnit); Log.i("djl", "传感器---风速:" + windSpeedValue + windSpeedValueUnit); @@ -1266,7 +1268,7 @@ showToast("获取传感器---风压状态失败,请重新再试"); return; } float windPressureValue = (float) event.getAppliancesInfo().getCurState(); float windPressureValue = (float) event.getAppliancesInfo().getCurStateObject(); String windPressureValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---风压:" + windPressureValue + windPressureValueUnit); Log.i("djl", "传感器---风压:" + windPressureValue + windPressureValueUnit); @@ -1277,7 +1279,7 @@ showToast("获取传感器---液体流量状态失败,请重新再试"); return; } float liquidFlowValue = (float) event.getAppliancesInfo().getCurState(); float liquidFlowValue = (float) event.getAppliancesInfo().getCurStateObject(); String liquidFlowValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---液体流量:" + liquidFlowValue + liquidFlowValueUnit); Log.i("djl", "传感器---液体流量:" + liquidFlowValue + liquidFlowValueUnit); @@ -1288,7 +1290,7 @@ showToast("获取传感器---液体压力状态失败,请重新再试"); return; } float liquidPressureValue = (float) event.getAppliancesInfo().getCurState(); float liquidPressureValue = (float) event.getAppliancesInfo().getCurStateObject(); String liquidPressureValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---液体压力:" + liquidPressureValue + liquidPressureValueUnit); Log.i("djl", "传感器---液体压力:" + liquidPressureValue + liquidPressureValueUnit); @@ -1299,7 +1301,7 @@ showToast("获取传感器---液体深度状态失败,请重新再试"); return; } float liquidDepthValue = (float) event.getAppliancesInfo().getCurState(); float liquidDepthValue = (float) event.getAppliancesInfo().getCurStateObject(); String liquidDepthValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---液体深度:" + liquidDepthValue + liquidDepthValueUnit); Log.i("djl", "传感器---液体深度:" + liquidDepthValue + liquidDepthValueUnit); @@ -1310,7 +1312,7 @@ showToast("获取传感器---雨量状态失败,请重新再试"); return; } float rainFallValue = (float) event.getAppliancesInfo().getCurState(); float rainFallValue = (float) event.getAppliancesInfo().getCurStateObject(); String rainFallValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---雨量:" + rainFallValue + rainFallValueUnit); Log.i("djl", "传感器---雨量:" + rainFallValue + rainFallValueUnit); @@ -1321,7 +1323,7 @@ showToast("获取传感器---重量状态失败,请重新再试"); return; } float weightValue = (float) event.getAppliancesInfo().getCurState(); float weightValue = (float) event.getAppliancesInfo().getCurStateObject(); String weightValueUnit = ((SensorStateBackInfo) event).getUnite(); showToast("传感器---重量:" + weightValue + weightValueUnit); Log.i("djl", "传感器---重量:" + weightValue + weightValueUnit); @@ -1332,7 +1334,7 @@ showToast("获取传感器---重量状态失败,请重新再试"); return; } float height_lengthValue = (float) event.getAppliancesInfo().getCurState(); 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); @@ -1343,7 +1345,7 @@ showToast("获取传感器---物体速度状态失败,请重新再试"); return; } float objectSpeedValue = (float) event.getAppliancesInfo().getCurState(); float objectSpeedValue = (float) event.getAppliancesInfo().getCurStateObject(); String objectSpeedUnite = ((SensorStateBackInfo) event).getUnite();//数值单位 showToast("传感器---物体速度:" + objectSpeedValue + objectSpeedUnite); Log.i("djl", "传感器---物体速度:" + objectSpeedValue + objectSpeedUnite); @@ -1354,7 +1356,7 @@ showToast("获取传感器---震动状态失败,请重新再试"); return; } float shakeValue = (float) event.getAppliancesInfo().getCurState(); float shakeValue = (float) event.getAppliancesInfo().getCurStateObject(); String shakeValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位 showToast("传感器---震动:" + shakeValue + shakeValueUnite); Log.i("djl", "传感器---震动:" + shakeValue + shakeValueUnite); @@ -1365,7 +1367,7 @@ showToast("获取传感器---电压状态失败,请重新再试"); return; } float voltageValue = (float) event.getAppliancesInfo().getCurState(); float voltageValue = (float) event.getAppliancesInfo().getCurStateObject(); String voltageValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位 showToast("传感器---电压:" + voltageValue + voltageValueUnite); Log.i("djl", "传感器---电压:" + voltageValue + voltageValueUnite); @@ -1376,7 +1378,7 @@ showToast("获取传感器---电流状态失败,请重新再试"); return; } float electricityValue = (float) event.getAppliancesInfo().getCurState(); float electricityValue = (float) event.getAppliancesInfo().getCurStateObject(); String electricityValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位 showToast("传感器---电流:" + electricityValue + electricityValueUnite); Log.i("djl", "传感器---电流:" + electricityValue + electricityValueUnite); @@ -1387,7 +1389,7 @@ showToast("获取传感器---功率状态失败,请重新再试"); return; } float powerValue = (float) event.getAppliancesInfo().getCurState(); float powerValue = (float) event.getAppliancesInfo().getCurStateObject(); String powerValueUnite = ((SensorStateBackInfo) event).getUnite();//数值单位 showToast("传感器---功率:" + powerValue + powerValueUnite); Log.i("djl", "传感器---功率:" + powerValue + powerValueUnite); app/src/main/java/com/hdl/sdk/hdl_sdk/activity/MainActivity.java
@@ -19,11 +19,14 @@ 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.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_sdk.R; import com.hdl.sdk.hdl_sdk.utlis.HDLLog; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -37,7 +40,7 @@ public class MainActivity extends AppCompatActivity { private Button btn, btn2; private Button btn_get_all,btn_on_all, btn_off_all; private Button btn_get_all,btn_on_all, btn_off_all,btn_getlocal,btn_getlocal_add; private TextView tv; private EditText editText; private List<DevicesData> devicesDatas; @@ -72,7 +75,10 @@ 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); tv = findViewById(R.id.tv); editText = findViewById(R.id.edt); editText.setText("172.168.188.100"); @@ -142,8 +148,77 @@ 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); } }); } 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() { app/src/main/res/layout/activity_add_devices_manually.xml
New file @@ -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> app/src/main/res/layout/activity_main.xml
@@ -25,6 +25,16 @@ 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" app/src/main/res/values/strings.xml
@@ -1,4 +1,4 @@ <resources> <string name="app_name">HDL_SDK</string> <string name="app_version">hdl_lib_v1.6.2.20191008_beta</string> <string name="app_version">hdl_lib_v1.6.4.20191015_beta</string> </resources> hdl_core/build.gradle
@@ -7,7 +7,7 @@ minSdkVersion 17 targetSdkVersion 28 versionCode 1 versionName "1.0.4" versionName "1.0.5" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" hdl_core/libs/gson-2.8.5.jarBinary files differ
hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/AppliancesInfo.java
@@ -49,7 +49,7 @@ this.port = port; } public String getIpAddress() { public String getIpAddressDevice() { return ipAddress; } @@ -89,9 +89,20 @@ this.parentRemarks = parentRemarks; } public Object getCurState() { // 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; hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java
@@ -27,6 +27,7 @@ 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.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; @@ -63,6 +64,21 @@ HDLDeviceManager.init(context); } // /** // * 获取本地广播IP // * @return // */ // public static String getLocalBroadCastIp(){ // return NetWorkUtil.getLocalBroadCast(); // } /** * 获取本地广播IP * @return */ public static String getLocalBroadCastIp(){ return NetWorkUtil.getLocalBroadCast(); } /** * 是否开启SDK日志打印 @@ -617,7 +633,7 @@ } } //更新所有设备状态 HandleSearch.refreshAllDevicesState(); // HandleSearch.refreshAllDevicesState(30); if (!deviceStateBeanList.isEmpty()) { return deviceStateBeanList; } else { @@ -649,7 +665,7 @@ ) { // curState = (int) infos.get(j).getCurState();//旧 //20190712解决强制转换int类型闪退 curState = HDLUtlis.getIntegerByObject(infos.get(j).getCurState()); curState = HDLUtlis.getIntegerByObject(infos.get(j).getCurStateObject()); break outter; } @@ -680,7 +696,7 @@ ) { //这里应该是要修复的,暂时未找到。 //20190712解决强制转换int类型闪退 int state = HDLUtlis.getIntegerByObject(infos.get(j).getCurState()); int state = HDLUtlis.getIntegerByObject(infos.get(j).getCurStateObject()); switch (state) { case -1: curState = 0; @@ -815,7 +831,7 @@ // HDLLog.info("发出数据:"+sendData+"子网id:"+info.getDeviceSubnetID()+" 设备id:"+info.getDeviceDeviceID()); cusSendCommand(command, info.getDeviceSubnetID(), info.getDeviceDeviceID(), musicBytes, info.getPort(), info.getIpAddress()); info.getPort(), getLocalBroadCastIp()); } } @@ -857,7 +873,7 @@ // HDLLog.info("发出数据:"+sendData+"子网id:"+info.getDeviceSubnetID()+" 设备id:"+info.getDeviceDeviceID()); cusSendCommand(command, info.getDeviceSubnetID(), info.getDeviceDeviceID(), musicBytes, info.getPort(), info.getIpAddress()); info.getPort(), getLocalBroadCastIp()); } } @@ -891,7 +907,7 @@ // HDLLog.info("发出数据:"+sendData+"子网id:"+info.getDeviceSubnetID()+" 设备id:"+info.getDeviceDeviceID()); cusSendCommand(command, info.getDeviceSubnetID(), info.getDeviceDeviceID(), musicBytes, info.getPort(), info.getIpAddress()); info.getPort(), getLocalBroadCastIp()); } } @@ -920,7 +936,7 @@ */ 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(), info.getIpAddress()); final Crc sendDatas = new Crc(info.getStateCommand(), info.getDeviceSubnetID(), info.getDeviceDeviceID(), addBytes, info.getPort(), getLocalBroadCastIp()); sendDatas.count = 0; @@ -966,7 +982,7 @@ // } } if (!sendDatas.isCtrlSuccess) { cusSendCommand(sendDatas.command, info.getDeviceSubnetID(), info.getDeviceDeviceID(), sendDatas.addBytes, info.getPort(), info.getIpAddress()); cusSendCommand(sendDatas.command, info.getDeviceSubnetID(), info.getDeviceDeviceID(), sendDatas.addBytes, info.getPort(), getLocalBroadCastIp()); } else { // HDLLog.info("控制已成功,停止"); sendCycleTimer.cancel(); hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java
@@ -4,6 +4,9 @@ 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; @@ -95,12 +98,16 @@ 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); // HandleSearch.curSearchMode = HandleSearch.GET_BUS_DEVICES; // HDLUdpCore.initMulticastSocket6000(); } /** @@ -213,7 +220,7 @@ SPUtils.setParam(viewContext, SPUtils.KEY_HDL_RCU_IP, getDatas.ipAddress); } handleSearchData(getDatas); HandleSearch.deviceListCallBack();//手动添加设备成功立刻返回 HandleSearch.OnDeviceListGetSuccessCallBack();//手动添加设备成功立刻返回 HDLCommand.cusSendCommand(Configuration.MANUAL_ADD_DEVICE_BACK_COMMAND, Crc.localSubnetID, Crc.localDeviceID, @@ -230,7 +237,7 @@ break; case Configuration.MANUAL_ADD_REMARK_COMMAND: handleRemarkCurStateData(getDatas); HandleSearch.deviceListCallBack();//手动添加备注成功立刻返回 HandleSearch.OnDeviceListGetSuccessCallBack();//手动添加备注成功立刻返回 HDLCommand.cusSendCommand(Configuration.MANUAL_ADD_REMARK_BACK_COMMAND, Crc.localSubnetID, Crc.localDeviceID, @@ -839,7 +846,7 @@ setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true); for (int oldAirInedx = 0; oldAirInedx < oldAirInfo.length; oldAirInedx++) { if (oldAirInedx == 0) { // if (oldAirInfo[0] != newAirInfo[8]) {//2019 去掉相同开关状态判断,解决开状态下,调用开命令状态下,不停重发问题 if (oldAirInfo[0] != newAirInfo[8]) {//2019 去掉相同开关状态判断,解决开状态下,调用开命令状态下,不停重发问题 oldAirInfo[0] = newAirInfo[8]; curAirInfo = new byte[]{AirCtrlParser.airSwich, newAirInfo[8]}; if (curAirInfo.length > 1) { @@ -853,7 +860,7 @@ EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true)); } // } } } else if (oldAirInedx == 1) { // int mode = ((newAirInfo[4] & 0xf0) >> 4); int mode = newAirInfo[9] & 0xff; @@ -2413,4 +2420,78 @@ 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); //将List转换成Json // 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()); //将json字符串转换成List集合 } } catch (JsonSyntaxException e) { e.printStackTrace(); } if (devicesDataList == null) devicesDataList = new ArrayList<>(); List<DevicesData> devicesDataList2 = devicesDataList; setRemarkList();//加载备注list if (!TextUtils.isEmpty(HandleSearch.rcuIp)) {//判断之前是否为RUC模式 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); } } } } } hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HandleSearch.java
@@ -20,7 +20,7 @@ public class HandleSearch { public static boolean isSearching = true; public static boolean isSearching = false; public static int curSearchMode = 0; public static String rcuIp = "";//主动传入的rcu ip地址 // private static Timer getRcuIpTimer = null;//获取Rcuip Timer @@ -389,38 +389,87 @@ } } /** * 返回设备列表 * 2019-10-14 */ 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; 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); // } 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)); /**搜索设备成功,执行一次保存到本地*/ HDLDeviceManager.saveDevicesDataList(); } public static void refreshAllDevicesState() { // /** // * 返回设备列表 // */ // 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(); @@ -441,7 +490,7 @@ } getDevRemarks(); } }, 1000 * 30); }, 1000 * delayTime); } @@ -475,13 +524,15 @@ //判断是否获取设备备注完全,若完全则返回所有设备列表。 if (HDLDeviceManager.listRemarks != null && HDLDeviceManager.listRemarks.size() != 0 && pos == -1) { if (!isRefreshAllDevicesState) { HandleSearch.deviceListCallBack(); HandleSearch.OnDeviceListGetSuccessCallBack(); } else { //刷新完毕 // TODO: 2018/12/29 刷新完毕可能要做某些事情 // TODO: 刷新完毕可能要做某些事情 HDLLog.info("刷新设备状态完毕"); isRefreshAllDevicesState = false; HandleSearch.OnDeviceListGetSuccessCallBack(); // /**刷新设备状态完毕,执行一次保存到本地*/ // HDLDeviceManager.saveDevicesDataList(); } return; @@ -508,8 +559,8 @@ port = Configuration.RCU_SEND_PORT; break; case HandleSearch.GET_BUS_DEVICES: // ipAddress = NetWorkUtil.getLocalBroadCast(); ipAddress = HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getIpAddress(); ipAddress = HDLCommand.getLocalBroadCastIp();//2019-10-16 // ipAddress = HDLDeviceManager.listRemarks.get(newPos).getAppliancesInfo().getIpAddress(); port = Configuration.PORT; break; } hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java
@@ -4,6 +4,8 @@ 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.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; @@ -690,4 +692,94 @@ } } /** * * @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); HDLDeviceManager.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; } } hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/NetUtil/NetWorkUtil.java
@@ -7,6 +7,8 @@ import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; import java.net.InetAddress; import java.net.InterfaceAddress; import java.net.NetworkInterface; @@ -128,13 +130,17 @@ //只有 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; } hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/SPUtil/SPUtils.java
@@ -35,7 +35,7 @@ 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"; /** * 保存数据的方法,我们需要拿到保存数据的具体类型,然后根据类型调用不同的保存方法 * hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/HDLUtlis.java
@@ -33,6 +33,18 @@ return in; } public static float getFloatByObject(Object object) { float f = 0f; try { f = (float)object; } catch (Exception e) { e.printStackTrace(); } return f; } /** * 4 byte 转换为float类型 *