Android 2.1 Bluetooth SPP to LM058 (Serial Cable Replacement) problem
Hey I'm relatively new to Android programming (but not programming in general).
The Setup: HTC Wildfire (running Android 2.1) LM058 (RS232 Serial Cable Replacement) LM058 will later on be attached to a MCU but for now it's connected to my laptop (terminal)
The Goal: To connect Wildfire to LM058 to each other with a 'bidirectional-stream' (like: "Hello from Android", response: "Hey from LM058").
So far: I've managed to connect the two devices (paired), I can tell by the LEDs on the LM058.
Problem: I can't seem to send anything from my Wildfire to LM058, and can't write anything back. They are paired and Connected.
Code example:
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);
}
I have previously made a similar connection using a Windows Mobile succesfully, but Android seems to give me some trouble at this point.
If you can help me get passed this small hurdle I would be very gratefull!
Could it have anything to do with BaudRate, because when a link is established (paired and Connected) it should replace the two devices (as a simple RS232 cable), so my Terminal on the PC should be set to a certain BaudRate (since I can't seem to find Baud Rate in Android). But still I can't see anything, if Baudrate was开发者_如何学编程 wrong then I would be able to see something (even though it might be rubbish) or?
There isn't Baudrate for Bluetooth connection, only you have to configure the baudrate between your BT-RS232 device and your computer...
For the BluetoothConnection you could see the next example:
http://developer.android.com/resources/samples/BluetoothChat/index.html
or this:
http://developer.android.com/guide/topics/wireless/bluetooth.html
精彩评论