简体   繁体   English

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

[英]Android app for bluetooth communication with arduino

I need to test my android program by sending strings to my PC with bluetooth communication. 我需要通过使用蓝牙通信将字符串发送到PC来测试我的android程序。

I have found this app which exactly sends strings to an arduino 我发现这个应用程序可以将字符串准确地发送到arduino

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

Can i send strings to my PC with this app without using arduino ? 我可以在不使用arduino的情况下使用此应用程序将字符串发送到PC吗?

Thanks in advance 提前致谢

You can create a Java application to act as Bluetooth server and using it for testing with you Bluetooth client app. 您可以创建一个充当蓝牙服务器的Java应用程序,并使用它来与蓝牙客户端应用程序进行测试。

You will need to Bluecove library for this, here is an example code snippet: 为此,您将需要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