繁体   English   中英

用于与arduino进行蓝牙通信的Android应用

[英]Android app for bluetooth communication with arduino

我需要通过使用蓝牙通信将字符串发送到PC来测试我的android程序。

我发现这个应用程序可以将字符串准确地发送到arduino

http://www.elecfreaks.com/829.html

我可以在不使用arduino的情况下使用此应用程序将字符串发送到PC吗?

提前致谢

您可以创建一个充当蓝牙服务器的Java应用程序,并使用它来与蓝牙客户端应用程序进行测试。

为此,您将需要Bluecove库 ,这是示例代码片段:

UUID serialUUID = new UUID("1101", true);
String SERVICE_URL = "btspp://localhost:" + serialUUID
        + ";name=My Bluetooth Server;authorize=false;authenticate=false";

StreamConnectionNotifier connectionNotifier = 
                          (StreamConnectionNotifier) Connector.open(SERVICE_URL);

System.out.println("Server is waiting for client ... \n URL=" + SERVICE_URL);

// Wait until client connects i.e. a blocking method
StreamConnection connection = connectionNotifier.acceptAndOpen();

RemoteDevice remoteDevice = RemoteDevice.getRemoteDevice(connection);
System.out.println("Client connected: "+remoteDevice.getBluetoothAddress());

// Communicate with the device using the below I/O streams
InputStream iStream = connection.openInputStream();
OutputStream oStream = connection.openOutputStream();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM