Android应用无法通过带有套接字的wifi接收来自arduino的数据包

时间:2019-07-01 17:32:51

标签: android networking arduino

我正在制作一个使用套接字将消息发送到硬件(arduino)的应用程序,但是我无法收到任何消息吗?

new Thread(new Runnable() {

                @Override
                public void run() {
                    try {
                        client = new Socket(ipAddress, portNumber);
                        printwriter = new OutputStreamWriter(client

               .getOutputStream(), "ISO-8859-1");enter code here
                        printwriter.write(message);
                        printwriter.flush();
                        BufferedReader br = new BufferedReader(new InputStreamReader(client.getInputStream()));
                        String line;

                        while ((line = br.readLine()) != null) {
                            line = br.readLine();

                        }
                        Toast.makeText(getBaseContext(),line,Toast.LENGTH_SHORT).show();
                        printwriter.close();
                        client.close();
                    }

                    catch (UnknownHostException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }).start();

            t.setText("done");

发生的情况是,当我发送消息时,它会打印在arduion上,但是当arduion发送回消息时,我在数据包跟踪器应用程序中看到它实际上是在发送数据包,但是我的应用程序没有捕获并将其放入吐司面包

0 个答案:

没有答案