我们从 Java 应用程序连接蓝牙血压计
- 操作系统:Windows 10
- 语言:Java 11
我们能够完成以下事情
我们已将血压计与 windows 平板电脑配对
BP 监视器的地址是
c15a8bb412d0
,服务名称是14839ac4...
我们尝试了下面的代码,但我们无法连接到设备。
//Sample code
LocalDevice local = LocalDevice.getLocalDevice();
String serviceUUID="14839ac47d7e415c9a42167340cf2339";
//String address="c15a8bb412d0";
String deviceURL = "btspp://"+serviceUUID+";name=BP2 3513;authenticate=false;encrypt=false;master=false";
javax.microedition.io.Connection notifier = Connector.open(deviceURL);
StreamConnectionNotifier streamNotifier = (StreamConnectionNotifier) notifier;
StreamConnection connection = streamNotifier.acceptAndOpen();
System.out.println(" Connection accepted.");
OutputStream output = connection.openOutputStream();
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(isr);
控件卡在“已接受连接”行之前。