yy1717
2020-11-25 1baa8f7baa336ce7e78d4b8389a351526cb8c673
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);
}