Detect hidden bluetooth device with known ID

匆匆过客 提交于 2019-11-29 15:48:07

I'm not sure what you mean by "hidden mode." You can connect to a device that is not discoverable, but you cannot connect to a device that is not connectable.

Generally, using JSR-82 (or Bluecove, a JSR-82 implementation) you need to have a RemoteDevice object in order to open a connection. The only way to get a RemoteDevice is via device search. It looks like you can't do a device search in your case, as the device is "hidden."

In Bluecove, you'll notice that RemoteDevice has a protected constructor that takes a Bluetooth address String. You can create a subclass of RemoteDevice that simply makes that constructor public. For example:

public class MyRemoteDevice extends javax.Bluetooth.RemoteDevice {
  public MyRemoteDevice(String addr) {
    super(addr);
  }
}

You can then create an instance of MyRemoteDevice, passing it the known MAC address, and use it to open the connection.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!