From 1baa8f7baa336ce7e78d4b8389a351526cb8c673 Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期三, 25 十一月 2020 15:10:39 +0800
Subject: [PATCH] 蓝牙密码

---
 lib/src/main/java/com/anyun/exam/lib/RemoteService.java |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
index f368d69..cfb15e1 100644
--- a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
+++ b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
@@ -70,6 +70,8 @@
     private Bluetooth mBluetooth = null;
     private BluetoothChatService mChatService = null;
     private String mConnectedDeviceName = null;
+    private String mConnectedDeviceAddr = null;
+
     private String mTargetBluetooth = null;
     private String mTargetBluetoothAddr = null;
     private boolean mDiscoveryBluetooth = false;
@@ -415,6 +417,14 @@
         }
     }
 
+    public void DisconnectBluetooth()
+    {
+        handlerConnectBluetooth.removeCallbacks(runnableConnectBluetooth);
+        if (mChatService != null) {
+            mChatService.stop();
+        }
+    }
+
     Handler handlerConnectBluetooth = new Handler();
     Runnable runnableConnectBluetooth = new Runnable() {
         @Override
@@ -473,7 +483,8 @@
                     switch (msg.arg1) {
                         case BluetoothChatService.STATE_CONNECTED:
                             Log.d(TAG, "钃濈墮宸茶繛鎺�");
-                            BluetoothStatusChange(3);
+//                            BluetoothStatusChange(3);
+                            BluetoothConnected(mConnectedDeviceName, mConnectedDeviceAddr);
                             break;
                         case BluetoothChatService.STATE_CONNECTING:
                             Log.d(TAG, "钃濈墮杩炴帴涓�...");
@@ -505,6 +516,10 @@
                     mConnectedDeviceName = msg.getData().getString(Constants.DEVICE_NAME);
                     Log.d(TAG, "MESSAGE_DEVICE_NAME: " + mConnectedDeviceName);
                     break;
+                case Constants.MESSAGE_DEVICE_ADDRESS:
+                    mConnectedDeviceAddr = msg.getData().getString(Constants.DEVICE_ADDRESS);
+                    Log.d(TAG, "MESSAGE_DEVICE_ADDRESS: " + mConnectedDeviceAddr);
+                    break;
                 case Constants.MESSAGE_TOAST:
                     break;
                     default:break;
@@ -529,6 +544,7 @@
     public native void MainProcBinMsgEntry(int cmd, byte []data, int length);
     public native void UpgradeMcu(String vercode, byte []rom);
     public native void TextSpeakEnd(int id);
+    public native void BluetoothConnected(String name, String addr);
     public native void BluetoothStatusChange(int status);
     public native void BluetoothDataComeIn(byte []data, int length);
 }

--
Gitblit v1.8.0