Skip to main content
Fix typos
Source Link
per1234
  • 4.3k
  • 2
  • 24
  • 44

I am working on a communication between androidAndroid and arduinoArduino board.

The android makeAndroid makes a TCP connection with the board and successfully sendsends some stringstrings to the board.

The problem is  , there is aan int in my arduinoArduino code (ege. int distanceg. int distance) and I would like to pass that back to my androidAndroid device.

I have handlehandled the androidAndroid side already  , but I do not know how to return a message from arduinoArduino.

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 androidAndroid side code but I think that it is not a specific androidAndroid problem, there should be some way for arduinoArduino to make a response of aan integer variable (without concern what is the source device)?

What I should do in ardinoArduino for making that response? Thanks for help.

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.

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?

Source Link
user782104
  • 141
  • 1
  • 3
  • 7

How to return a message when calling by a TCP connection?

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.