我有一个 Android 设备(HTC Incredible),我想在 android 手机和 MacBook Pro 之间设置蓝牙通信。我已经在 Mac 上启动了 bluecove,并且我已经在 Android 中使用 Sockets 完成了编码,但我无法使连接正常工作。这是我的安卓代码
BluetoothDevice device = reciever.getDevice("00:25:00:XX:XX:XX"); //my bluetooth address
UUID generalUuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
socket = device.createRfcommSocketToServiceRecord(generalUuid);
socket.connect();
writer = new OutputStreamWriter(socket.getOutputStream());
reader = new InputStreamReader(socket.getInputStream());
在 Mac 上
String serverUUID = "btspp://localhost:0000110100001000800000805F9B34FB;name=matt";
StreamConnectionNotifier notifier = (StreamConnectionNotifier) Connector.open(serverUUID);
StreamConnection connection = notifier.acceptAndOpen();
// prepare to send/receive data
byte buffer[] = new byte[100];
String msg = "hello there, client";
InputStream is = connection.openInputStream();
OutputStream os = connection.openOutputStream();
任何帮助或示例都会有所帮助。