Remote-Bluetooth-Android
Remote-Bluetooth-Android copied to clipboard
Send string data over the server
Hi! Its a great example to send commands but I need to send more information like strings or byts to decode in the server side.
Can U help me with the modifications on the server side when inputStream is read
inputStream.read
thanks!
I can do this in the server
StringWriter writer = new StringWriter();
IOUtils.copy(inputStream, writer, "UTF-8");
String theString = writer.toString();
System.out.println(theString);
but this is the output
BlueCove version 2.1.1-SNAPSHOT on winsock
04c6093b00001000800000805f9b34fb
waiting for connection...
waiting for connection...
waiting for input
23456789?
finish process
in Android I send "123456789" with this code
public void write(String out) {
// Create temporary object
ConnectedThread r;
// Synchronize a copy of the ConnectedThread
synchronized (this) {
if (mState != STATE_CONNECTED) return;
r = mConnectedThread;
}
// Perform the write unsynchronized
r.write(out.getBytes());
}
News!
I comment this line
int command = inputStream.read();
and I get the "full" string
123456789ÿ
I can eliminate the last char but is not the best...
In my android app I have this
mCommandService.write(editText.getText().toString().trim());
editText.getText().clear();
mCommandService.stop();
If I remove the last line, the ÿ disapear. So I guess that is the stop command. Can I remove that or is native?