I am working on a communication between Android and Arduino board.
The Android makes a TCP connection with the board and successfully sends some strings to the board.
The problem is, there is an int in my Arduino code (e.g. int distance
) and I would like to pass that back to my Android device.
I have handled 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 an integer variable (without concern what is the source device)?
What I should do in Arduino for making that response?