Commit 1c3b6ca2 by 韩飞虎

测试吧

parent 4eb775c2
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
</set> </set>
</option> </option>
<option name="resolveModulePerSourceSet" value="false" /> <option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings> </GradleProjectSettings>
</option> </option>
</component> </component>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\main\jniLibs"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\debug\jniLibs"/></dataSet></merger> <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/jniLibs"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/debug/jniLibs"/></dataSet></merger>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\main\shaders"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\debug\shaders"/></dataSet></merger> <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/shaders"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/debug/shaders"/></dataSet></merger>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\main\assets"/><source path="D:\androidProject\BluToysApplication\FastBleLib\build\intermediates\shader_assets\debug\out"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\debug\assets"/></dataSet></merger> <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/assets"/><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/build/intermediates/shader_assets/debug/out"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/debug/assets"/></dataSet></merger>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\main\res"/><source path="D:\androidProject\BluToysApplication\FastBleLib\build\generated\res\rs\debug"/><source path="D:\androidProject\BluToysApplication\FastBleLib\build\generated\res\resValues\debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main" generated-set="main$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\main\res"/><source path="D:\androidProject\BluToysApplication\FastBleLib\build\generated\res\rs\debug"/><source path="D:\androidProject\BluToysApplication\FastBleLib\build\generated\res\resValues\debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\debug\res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug" generated-set="debug$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="D:\androidProject\BluToysApplication\FastBleLib\src\debug\res"/></dataSet><mergedItems/></merger> <merger version="3"><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/res"/><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/build/generated/res/rs/debug"/><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/build/generated/res/resValues/debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main" generated-set="main$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/res"/><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/build/generated/res/rs/debug"/><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/build/generated/res/resValues/debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/debug/res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug" generated-set="debug$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/debug/res"/></dataSet><mergedItems/></merger>
\ No newline at end of file \ No newline at end of file
...@@ -6,21 +6,21 @@ ...@@ -6,21 +6,21 @@
6 6
7 <uses-sdk 7 <uses-sdk
8 android:minSdkVersion="14" 8 android:minSdkVersion="14"
8-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml 8-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
9 android:targetSdkVersion="30" /> 9 android:targetSdkVersion="30" />
9-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml 9-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
10 10
11 <uses-permission android:name="android.permission.BLUETOOTH" /> 11 <uses-permission android:name="android.permission.BLUETOOTH" />
11-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:4:5-68 11-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:4:5-68
11-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:4:22-65 11-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:4:22-65
12 <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> 12 <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
12-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:5:5-74 12-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:5:5-74
12-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:5:22-71 12-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:5:22-71
13 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 13 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
13-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:6:5-81 13-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:6:5-81
13-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:6:22-78 13-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:6:22-78
14 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 14 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
14-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:7:5-79 14-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:7:5-79
14-->D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:7:22-76 14-->/Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:7:22-76
15 15
16</manifest> 16</manifest>
-- Merging decision tree log --- -- Merging decision tree log ---
manifest manifest
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
package package
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:2:5-30 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:2:5-30
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
android:versionName android:versionName
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
android:versionCode android:versionCode
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:1-9:12 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:1-9:12
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
xmlns:android xmlns:android
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:1:11-69 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:1:11-69
uses-permission#android.permission.BLUETOOTH uses-permission#android.permission.BLUETOOTH
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:4:5-68 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:4:5-68
android:name android:name
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:4:22-65 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:4:22-65
uses-permission#android.permission.BLUETOOTH_ADMIN uses-permission#android.permission.BLUETOOTH_ADMIN
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:5:5-74 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:5:5-74
android:name android:name
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:5:22-71 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:5:22-71
uses-permission#android.permission.ACCESS_COARSE_LOCATION uses-permission#android.permission.ACCESS_COARSE_LOCATION
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:6:5-81 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:6:5-81
android:name android:name
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:6:22-78 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:6:22-78
uses-permission#android.permission.ACCESS_FINE_LOCATION uses-permission#android.permission.ACCESS_FINE_LOCATION
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:7:5-79 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:7:5-79
android:name android:name
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml:7:22-76 ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml:7:22-76
uses-sdk uses-sdk
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml reason: use-sdk injection requested INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml reason: use-sdk injection requested
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
android:targetSdkVersion android:targetSdkVersion
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
android:minSdkVersion android:minSdkVersion
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
ADDED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml ADDED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
INJECTED from D:\androidProject\BluToysApplication\FastBleLib\src\main\AndroidManifest.xml INJECTED from /Users/hanfeihu/助利帮/BluToysApplication/FastBleLib/src/main/AndroidManifest.xml
package com.example.blu.toys.activity; package com.example.blu.toys.activity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.widget.Toast; import android.widget.Toast;
import androidx.appcompat.widget.AppCompatImageView; import androidx.appcompat.widget.AppCompatImageView;
import com.example.blu.toys.MainActivity; import com.example.blu.toys.MainActivity;
import com.example.blu.toys.R; import com.example.blu.toys.R;
import com.example.blu.toys.app.AppManager; import com.example.blu.toys.app.AppManager;
import butterknife.BindView; import butterknife.BindView;
import butterknife.OnClick; import butterknife.OnClick;
......
...@@ -77,20 +77,24 @@ public class PlayActivity extends BaseActivity { ...@@ -77,20 +77,24 @@ public class PlayActivity extends BaseActivity {
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
super.handleMessage(msg); super.handleMessage(msg);
LogUtils.e("定时器在走111", msg.what, mHour, mMin, mSecond); LogUtils.e("定时器在走111", msg.what, mHour, mMin, mSecond);
if ((mHour + mMin + mSecond) < 1) { if (totalSecond < 1) {
suspendAndContinue = 0; suspendAndContinue = 0;
} }else{
if (suspendAndContinue == 1) { if (suspendAndContinue == 1) {
computeTime();
}
}
String mHourStr = addZeroForNum(mHour + "", 2); String mHourStr = addZeroForNum(mHour + "", 2);
String mMinStr = addZeroForNum(mMin + "", 2); String mMinStr = addZeroForNum(mMin + "", 2);
String mSecondStr = addZeroForNum(mSecond + "", 2); String mSecondStr = addZeroForNum(mSecond + "", 2);
typefaceTextView.setText(mHourStr + ":" + mMinStr + ":" + mSecondStr); typefaceTextView.setText(mHourStr + ":" + mMinStr + ":" + mSecondStr);
}
sendBleData(); sendBleData();
computeTime();
} }
}; };
...@@ -189,9 +193,7 @@ public class PlayActivity extends BaseActivity { ...@@ -189,9 +193,7 @@ public class PlayActivity extends BaseActivity {
@Override @Override
public void onBackPressed() { public void onBackPressed() {
timerManager.cancelTimer(); timerManager.cancelTimer();
Intent intent = new Intent(PlayActivity.this, SetTimeActivity.class); AppManager.getInstance().finishActivity();
startActivity(intent);
} }
@OnClick({R.id.cancel_but, R.id.pause_but, R.id.resume_but}) @OnClick({R.id.cancel_but, R.id.pause_but, R.id.resume_but})
......
package com.example.blu.toys.adapter; package com.example.blu.toys.adapter;
import android.text.TextUtils;
import com.chad.library.adapter.base.BaseQuickAdapter; import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder; import com.chad.library.adapter.base.BaseViewHolder;
import com.clj.fastble.data.BleDevice;
import com.example.blu.toys.R; import com.example.blu.toys.R;
import com.example.blu.toys.utils.SpUtils; import com.example.blu.toys.utils.SpUtils;
......
...@@ -75,18 +75,36 @@ public class TrafficLightBean { ...@@ -75,18 +75,36 @@ public class TrafficLightBean {
*/ */
public TrafficLightBean(Integer protocolNo,Integer suspendAndContinue,Integer timeRemaining,Integer brightness,Integer openSoundNo,Integer closeSoundNo,Integer trafficLightUpdateSet,Integer alarm){ public TrafficLightBean(Integer protocolNo,Integer suspendAndContinue,Integer timeRemaining,Integer brightness,Integer openSoundNo,Integer closeSoundNo,Integer trafficLightUpdateSet,Integer alarm){
//这个方法是 给该对象属性赋值的 ,就是 在new TrafficLightBean(xx,xxx) 的时候调用
// 传入的协议编号 01 和 02 关机 是 01 其他操作 都是02
this.cmd= BitOperator.integerTo1Byte(protocolNo); this.cmd= BitOperator.integerTo1Byte(protocolNo);
//暂停与继续 ,如果是关机协议传入0 即可
this.suspendAndContinue=BitOperator.integerTo1Byte(suspendAndContinue); this.suspendAndContinue=BitOperator.integerTo1Byte(suspendAndContinue);
System.out.println("传入的剩余时间:"+timeRemaining); System.out.println("传入的剩余时间:"+timeRemaining);
//剩余时间 小端 2字节 toLH 方法是转为小端的 传入的是秒数
this.timeRemaining=toLH(timeRemaining); //BitOperator.integerTo2Bytes(); this.timeRemaining=toLH(timeRemaining); //BitOperator.integerTo2Bytes();
//亮度 0-100 将 10进制的 BitOperator.integerTo1Byte是 数字 转为 1字节的byte
this.brightness=BitOperator.integerTo1Byte(brightness); this.brightness=BitOperator.integerTo1Byte(brightness);
//开机声音的编号 1-20 BitOperator.integerTo1Byte是 将 10进制的 数字 转为 1字节的byte
this.openSoundNo=BitOperator.integerTo1Byte(openSoundNo); this.openSoundNo=BitOperator.integerTo1Byte(openSoundNo);
//关机声音的编号 1-20 BitOperator.integerTo1Byte是 将 10进制的 数字 转为 1字节的byte
this.closeSoundNo=BitOperator.integerTo1Byte(closeSoundNo); this.closeSoundNo=BitOperator.integerTo1Byte(closeSoundNo);
//红绿灯变更方式 BitOperator.integerTo1Byte是 将 10进制的 数字 转为 1字节的byte
this.trafficLightUpdateSet=BitOperator.integerTo1Byte(trafficLightUpdateSet); this.trafficLightUpdateSet=BitOperator.integerTo1Byte(trafficLightUpdateSet);
//警报开关 BitOperator.integerTo1Byte是 将 10进制的 数字 转为 1字节的byte
this.alarm=BitOperator.integerTo1Byte(alarm); this.alarm=BitOperator.integerTo1Byte(alarm);
//格式化时间的对象
SimpleDateFormat format= new SimpleDateFormat("yyMMddHHmmss"); SimpleDateFormat format= new SimpleDateFormat("yyMMddHHmmss");
//将当前时间格式化
String phoneTime= format.format(new Date()); String phoneTime= format.format(new Date());
//将字符串的日期转换为 6个字节的byte 数组
this.phoneTime= BCD8421Operater.string2Bcd(phoneTime); this.phoneTime= BCD8421Operater.string2Bcd(phoneTime);
//分别获取时间的时分秒
String yy= phoneTime.substring(0,2); String yy= phoneTime.substring(0,2);
String MM= phoneTime.substring(2,4); String MM= phoneTime.substring(2,4);
String dd= phoneTime.substring(4,6); String dd= phoneTime.substring(4,6);
...@@ -94,16 +112,28 @@ public class TrafficLightBean { ...@@ -94,16 +112,28 @@ public class TrafficLightBean {
String mm= phoneTime.substring(8,10); String mm= phoneTime.substring(8,10);
String ss= phoneTime.substring(10,12); String ss= phoneTime.substring(10,12);
//开始加密协议
// yy + HH 也就是 年 +时 = 第一个数
// 比如 20 + 12=0x32 10 //20年 + 12点 =0x32
Integer bo1=BCD8421Operater.string2Bcd(yy)[0]+BCD8421Operater.string2Bcd(HH)[0]; Integer bo1=BCD8421Operater.string2Bcd(yy)[0]+BCD8421Operater.string2Bcd(HH)[0];
// MM + mm 也就是 月 异或 分钟 = 第二个数
Integer bo2=BCD8421Operater.string2Bcd(MM)[0]^BCD8421Operater.string2Bcd(mm)[0]; Integer bo2=BCD8421Operater.string2Bcd(MM)[0]^BCD8421Operater.string2Bcd(mm)[0];
// dd + ss 也就是 天 + 秒 = 第三个数
Integer bo3=BCD8421Operater.string2Bcd(dd)[0]+BCD8421Operater.string2Bcd(ss)[0]; Integer bo3=BCD8421Operater.string2Bcd(dd)[0]+BCD8421Operater.string2Bcd(ss)[0];
//最后 经过下面公式 得到KEY
Integer key=(bo1^bo2)+bo3; Integer key=(bo1^bo2)+bo3;
// 将KEY 换算为byte
this.key=BitOperator.integerTo1Byte(key); this.key=BitOperator.integerTo1Byte(key);
System.out.println("时间:"+phoneTime); System.out.println("时间:"+phoneTime);
System.out.println("key 10进制:"+key); System.out.println("key 10进制:"+key);
System.out.println("key byte:"+this.key); System.out.println("key java byte:"+this.key);
System.out.println("key HEX:"+HexStringUtils.toHexString(new byte[]{this.key}));
//到此协议组装 完毕, 值也都付完了, 因为java 框架,发送给蓝牙设备的的是byte 有一个toByte方法 在下面 调用即可得到 这个协议的byte[] 数组 发送给设备即可
} }
...@@ -122,10 +152,16 @@ public class TrafficLightBean { ...@@ -122,10 +152,16 @@ public class TrafficLightBean {
public byte[] toByte(){ public byte[] toByte(){
//数据要加密的 //数据要加密的
//协议总长度 是17个自己 因此定义 byte 17
byte[] resData=new byte[17]; byte[] resData=new byte[17];
//第一个字节 固定头
resData[0]=this.begin; resData[0]=this.begin;
//第二个节=协议长度
resData[1]=this.length; resData[1]=this.length;
//第三个节=协议编号 从这里开始 往下每个字节都需要加密 手机时间字节不需要 加密方式就是 将数据加上刚计算出来的KEY 所以是 this.cmd+this.key
resData[2]=BitOperator.integerTo1Byte(this.cmd+this.key); resData[2]=BitOperator.integerTo1Byte(this.cmd+this.key);
//拼装 手机时间
resData[3]=this.phoneTime[0];//1 不需要加密 resData[3]=this.phoneTime[0];//1 不需要加密
resData[4]=this.phoneTime[1];//2 不需要加密 resData[4]=this.phoneTime[1];//2 不需要加密
resData[5]=this.phoneTime[2];//3 不需要加密 resData[5]=this.phoneTime[2];//3 不需要加密
...@@ -133,29 +169,45 @@ public class TrafficLightBean { ...@@ -133,29 +169,45 @@ public class TrafficLightBean {
resData[7]=this.phoneTime[4];//5 不需要急吗 resData[7]=this.phoneTime[4];//5 不需要急吗
resData[8]=this.phoneTime[5];//6 不需要加密 resData[8]=this.phoneTime[5];//6 不需要加密
//暂停与继续 +this.key
resData[9]=BitOperator.integerTo1Byte(this.suspendAndContinue+this.key); resData[9]=BitOperator.integerTo1Byte(this.suspendAndContinue+this.key);
//剩余时间 第一个字节 KEY
resData[10]=BitOperator.integerTo1Byte(this.timeRemaining[0]+this.key); resData[10]=BitOperator.integerTo1Byte(this.timeRemaining[0]+this.key);
//剩余时间 第二个字节 KEY
resData[11]=BitOperator.integerTo1Byte(this.timeRemaining[1]+this.key); resData[11]=BitOperator.integerTo1Byte(this.timeRemaining[1]+this.key);
resData[12]=BitOperator.integerTo1Byte(this.brightness+this.key); resData[12]=BitOperator.integerTo1Byte(this.brightness+this.key);
resData[13]=BitOperator.integerTo1Byte(this.openSoundNo+this.key); resData[13]=BitOperator.integerTo1Byte(this.openSoundNo+this.key);
resData[14]=BitOperator.integerTo1Byte(this.closeSoundNo+this.key); resData[14]=BitOperator.integerTo1Byte(this.closeSoundNo+this.key);
resData[15]=BitOperator.integerTo1Byte(this.trafficLightUpdateSet+this.key); resData[15]=BitOperator.integerTo1Byte(this.trafficLightUpdateSet+this.key);
//报警开关
resData[16]=BitOperator.integerTo1Byte(this.alarm+this.key); resData[16]=BitOperator.integerTo1Byte(this.alarm+this.key);
System.out.println("发送数据为:"+HexStringUtils.toHexString(resData)); System.out.println("发送数据为:"+HexStringUtils.toHexString(resData));
return resData; return resData;
} }
//这里是调用的示例 main 函数
public static void main(String[] args) { public static void main(String[] args) {
TrafficLightBean trafficLightBean=new TrafficLightBean(2,0,
300,100,10,20,01,01);
//创建了一个这样的对象 ,将参数都传入
TrafficLightBean trafficLightBean=new TrafficLightBean(2,0,
255,100,10,20,01,01);
//然后调用这个对象里面的 toByte 方法 生成给设备发送的数据
System.out.println(HexStringUtils.toHexString(trafficLightBean.toByte())); System.out.println(HexStringUtils.toHexString(trafficLightBean.toByte()));
// System.out.printf("00000000"); System.out.println(HexStringUtils.toHexString(new byte[]{-1}));
System.out.println(HexStringUtils.toHexString(new byte[]{117}));
System.out.println(HexStringUtils.toHexString(new byte[]{116}));
System.out.println(HexStringUtils.toHexString(new byte[]{116}));
int a=0xff+0x75;
System.out.println(a);
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment