Android 2.1蓝牙SPP到LM058(串行电缆更换)问题

时间:2010-10-04 10:51:51

标签: android connection bluetooth serial-port

嘿,我对Android编程比较陌生(但不是一般的编程)。

设置: HTC Wildfire(运行Android 2.1) LM058(RS232串行电缆更换) LM058稍后将连接到MCU,但现在它连接到我的笔记本电脑(终端)

目标: 使用'双向流'将Wildfire与LM058相互连接(例如:“来自Android的Hello”,响应:“嘿,来自LM058”)。

到目前为止: 我已经成功连接了两个设备(配对),我可以通过LM058上的LED来判断。

问题: 我似乎无法从我的Wildfire向LM058发送任何内容,也无法回复任何内容。它们是配对和连接的。

代码示例:

            String message = "Hello message from client to server.";
            byte[] msgBuffer = message.getBytes();
            try {
             outStream.write(msgBuffer);

       Log.e(TAG, "App was here!");

            } catch (IOException e) {
                    Log.e(TAG, "ON RESUME: Exception during write.", e);
            }

我之前使用Windows Mobile成功地建立了类似的连接,但Android现在似乎给我带来了一些麻烦。

如果你能帮助我通过这个小障碍,我将非常感激!

它是否与BaudRate有关,因为当建立链接(配对和连接)时,它应该替换两个设备(作为简单的RS232电缆),因此PC上的终端应设置为某个BaudRate (因为我似乎无法在Android中找到波特率)。但是我仍然看不到任何东西,如果Baudrate错了那么我就能看到一些东西(即使它可能是垃圾)或者?

1 个答案:

答案 0 :(得分:1)

蓝牙连接没有波特率,只需要配置BT-RS232设备和电脑之间的波特率......

对于BluetoothConnection,您可以看到下一个示例:

http://developer.android.com/resources/samples/BluetoothChat/index.html

或者这个:

http://developer.android.com/guide/topics/wireless/bluetooth.html