I am working on a communication between android and arduino board.
The android make a TCP connection with the board and successfully send some string to the board.
The problem is , there is a int in my arduino code (eg. int distance) and I would like to pass that back to my android device
I have handle the android side already , but I do not know how to return a message from arduino
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
//in this while the client listens for the messages sent by the server
while (mRun) {
serverMessage = in.readLine();
if (serverMessage != null && mMessageListener != null) {
//call the method messageReceived from MyActivity class
mMessageListener.messageReceived(serverMessage);
}
serverMessage = null;
}
This is the android side code but I think that it is not a specific android problem, there should be some way for arduino to make a response of a integer variable (without concern what is the source device)?
What I should do in ardino for making that response? Thanks for help.