0

I need to test my android program by sending strings to my PC with bluetooth communication.

I have found this app which exactly sends strings to an arduino

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

Can i send strings to my PC with this app without using arduino ?

Thanks in advance

4

1 回答 1

0

您可以创建一个 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();
于 2013-04-27T23:30:55.970 回答