yy1717
2020-11-25 356c58a31ab0e605cb51d833398e987d15daccb2
蓝牙
2个文件已修改
14 ■■■■■ 已修改文件
lib/src/main/cpp/rtk_platform/platform.cpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/java/com/anyun/exam/lib/util/Bluetooth.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/rtk_platform/platform.cpp
@@ -613,7 +613,7 @@
            if (strlen(btAddr) > 0) {
                ConnectToBluetooth(btAddr, NULL);
            }
//            ConnectToBluetooth("00:1B:35:16:20:4A", "5516");
//            ConnectToBluetooth("00:1B:35:16:20:4A", NULL);
//            ConnectToBluetooth("00:1B:35:16:20:4A", "3800");``
//            ConnectToBluetooth("00:1D:43:9A:E0:79", "1900");
//            ConnectToBluetooth("DESKTOP-IE9V7U8", "0000");
lib/src/main/java/com/anyun/exam/lib/util/Bluetooth.java
@@ -47,7 +47,7 @@
        filter.addAction(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED);
        filter.addAction("android.bluetooth.device.action.PAIRING_REQUEST");
        filter.setPriority(1000);
//        filter.setPriority(1000);
        context.registerReceiver(this, filter);
    }
@@ -129,11 +129,12 @@
                OpenBluetooth();
            }
        } else if (action.equals("android.bluetooth.device.action.PAIRING_REQUEST")) {
            Log.d(TAG, "匹配请求");
            // Get the BluetoothDevice object from the Intent
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            String name = device.getName();
            Log.d(TAG, "匹配请求 " + name);
            if (pin == null && name != null && name.contains("AKS3A_") && name.length() >= 8) {
                char [] sn = new char[8];
@@ -150,10 +151,11 @@
                pin = DEFAULT_BT_PASSWORD;
            }
            Log.d(TAG, "匹配吗 " + pin);
            Log.d(TAG, "蓝牙Pin " + pin);
            /*if (device.getName().equals(BLUETOOTH_OBD_NAME) || device.getName().equals(BLUETOOTH_TARGET2_NAME)) */{
                try {
                    ClsUtils.setPairingConfirmation(device.getClass(), device, true);
                    // 第三方的系统需要注释掉,否则会抛异常
//                    ClsUtils.setPairingConfirmation(device.getClass(), device, true);
                    Log.d(TAG, "isOrderedBroadcast:"+isOrderedBroadcast()+",isInitialStickyBroadcast:"+isInitialStickyBroadcast());
                    if (isOrderedBroadcast()) {
                        abortBroadcast();
@@ -161,7 +163,7 @@
                    ClsUtils.setPin(device.getClass(), device, pin);
                } catch (Exception e) {
                    Log.e(TAG, e.getMessage());
                }
            }
        } else if (BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED.equals(action)) {