连接到不可发现的蓝牙设备

JPr*_*Pro 8 android bluetooth java-me

我正在为Android开发一个应用程序.只是一般性问题,是否可以连接到公开不可发现的设备?

提前致谢.

Ale*_*lex 6

如果您之前已与该设备配对,则即使它不在可发现模式下,也可以再次连接到该设备.看到这篇文章: programmatically-connect-to-paired-bluetooth-device

    // use paired devices or create a BluetoothDevice using a mac address
    //Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
    BluetoothAdapter myAdapter = BluetoothAdapter.getDefaultAdapter();
    BluetoothDevice remoteDevice = myAdapter.getRemoteDevice("00:00:00:00:00:00");
    BluetoothSockt btSocket = remoteDevice.createRfcommSocketToServiceRecord(UUID);
    btSocket.connect();
    //get input and output stream etc...
Run Code Online (Sandbox Code Playgroud)


Den*_*ews 3

通过可发现,我假设您的意思是响应来自另一台设备的设备搜索。一些制造商也将其称为可见的。根据设备制造商的不同,某些设备允许打开蓝牙并将可见性/发现能力设置为关闭。因此,如果您已经知道设备的蓝牙地址(MAC 地址),即使设备不可发现/不可见,您也可以直接连接到该设备。在实践中,这是一件好事,许多制造商通过仅在特定时间段(例如在配对过程中)可见设备来实现这一点,或者具有明确的菜单选项来打开特定时间段的发现能力。从安全角度来看,这是一个很好的做法,因为它可以防止设备跟踪/黑客攻击。

例如,当蓝牙打开时,默认情况下 iPhone 是不可发现的(但您仍然可以连接到它),只有当您从设置菜单进入蓝牙菜单时才能发现它。