如何配对蓝牙设备编程机器人蓝牙、机器人、设备

2023-09-12 22:46:34 作者:奮鬥的青春

我发展,我想连接的蓝牙设备的主要问题是,我不希望用户输入所需的引脚,而不是应用程序应该做到这一点的自己......我没有任何连接相关的问题的应用程序.. 。只有希望通过应用程序本身插入和完整的引脚验证过程。

I am developing an application where I want to connect a Bluetooth device main issue is I don't want user to enter required pin instead application should do that by himself...I don't have any connection related issue...Only want to insert and complete pin authentication process by application itself.

我发现下面code我相信这是工作,但不知道如何添加脚本code ??

I found following code I am sure it is working but not sure on how to add pin in this code??

private void pairDevice(BluetoothDevice device) {
        try {
            Log.d("pairDevice()", "Start Pairing...");
            Method m = device.getClass().getMethod("createBond", (Class[]) null);
            m.invoke(device, (Object[]) null);
            Log.d("pairDevice()", "Pairing finished.");
        } catch (Exception e) {
            Log.e("pairDevice()", e.getMessage());
        }
    }

有谁知道如何在上述code或任何类似code,以解决问题进入销.. 谢谢

Does anyone know how to enter pin in above code or any similar code to solve problem.. Thank You

推荐答案

How我能避免或者解聘Android的蓝牙配对通知,当我在做方案的配对?

这似乎给你答案,与销进入和所有。它包括发送.setPin()时,你得到的消息。

This seems to give you the answer, with the pin entering and all. It involves sending .setPin() whenever you get the message.