Android新手,在学习scoket套接字编程。我正在写一个用Arduino开发板获取数据并将数据通过wifi传送到手机上的项目,现在android可以向wifi发送数据,然后Arduinno可以将传感器获取到的数据打印在串口上。请问各位大神,我在Android端怎么能拿到串口上的数据?下面是项目的部分过程和部分代码:1.Android端:
public class MainActivity extends AppCompatActivity {
    private EditText mEtIp,mEtData;
    private TextView tv;
    private OutputStream mOutputStream = null;
    private InputStream mInputStream=null;
    private Socket mSocket = null;
    private String ip;
    private String data;
    private boolean socketStatus = false;    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mEtIp = findViewById(R.id.et_ip);
        mEtData = findViewById(R.id.et_data);
    }
    public void connect(View view) {
        ip = mEtIp.getText().toString();
        Toast.makeText(MainActivity.this,""+ip,Toast.LENGTH_SHORT).show();
        Thread thread = new Thread() {
            @Override
            public void run() {
                super.run();
                if (!socketStatus) {
                    try {
                        //连接服务端
                        mSocket = new Socket(ip,2001);
                        if(mSocket != null){
                            socketStatus = true;
                        }
                        mOutputStream = mSocket.getOutputStream();
                        mInputStream=mSocket.getInputStream();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        thread.start();
    }
    public void send(View view){
        data = mEtData.getText().toString();
        Toast.makeText(MainActivity.this,""+data,Toast.LENGTH_SHORT).show();
        if (data != null) {
            data = data + '\0';
        }
        Thread thread = new Thread(){
            @Override
            public void run() {
                super.run();
                if(socketStatus){
                    try {
                        mOutputStream.write(data.getBytes());// 问题就在这儿,我想通过输入流获取串口内的数据,但是获取不到,而且Log打印出来的是中文乱码,但我串口里没有中文
                       byte[] buffer = new byte[mInputStream.available()];
                        mInputStream.read(buffer);
                        String s1=new String(buffer);
                        Log.i("context",s1);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        thread.start();
    }
    /*当客户端界面返回时,关闭相应的socket资源*/
    @Override
    public void onBackPressed() {
        super.onBackPressed();
        /*关闭相应的资源*/
        try {
            mOutputStream.close();
            mSocket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }    public static String readStream(InputStream in) {
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            byte[] buffer = new byte[1024];
            int len = -1;
            while ((len = in.read(buffer)) != -1) {
                baos.write(buffer, 0, len);
            }
            String content = baos.toString();
            in.close();
            baos.close();
            return content;
        } catch (Exception e) {
            e.printStackTrace();
            return  e.getMessage();
        }
    }
}这是android端的界面,通过输入ip地址连接wifi,再通过发送按钮发送想获取的数据这是串口调试软件,我在android发送的数据以后,Arduino开发板将我希望的得到的数据打印到了串口上,我现在就想在手机端获取到这些数据。请问大神们,有没有方法让我在Android端获取到串口调试软件里的这些数据??谢谢了