java 从Android设备向ESP8266 Wi-Fi芯片发送数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32273886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sending data to ESP8266 Wi-Fi chip from Android device
提问by Arthur Vasilyev
I have a ESP8266 chip which is connected to the microcircuit. When chip gets value "200" the light is starting to blink 4 times and than it returns "100" value. I need to make an Android app using Java which will connect to the ESP8266 chip, send data to it and will get value "100". I don't know what library I should use to deal with it. Please, help me, how can I do that? I think it is not the most hard question here.
我有一个连接到微电路的 ESP8266 芯片。当芯片获得值“200”时,灯开始闪烁 4 次,然后返回“100”值。我需要使用 Java 制作一个 Android 应用程序,它将连接到 ESP8266 芯片,向它发送数据并获得值“100”。我不知道我应该使用什么库来处理它。请帮帮我,我该怎么做?我认为这不是这里最难的问题。
回答by Fruchtzwerg
For your Controller you dont need any Libary. You just can use the serial AT Commands: http://www.electrodragon.com/w/ESP8266
对于您的控制器,您不需要任何 Libary。您只需使用串行 AT 命令:http: //www.electrodragon.com/w/ESP8266
After setting up your ESP like this:
像这样设置 ESP 后:
In your App you should deal with TCP-Sockets: https://de.wikibooks.org/wiki/Googles_Android/_TCP-Sockets
在您的应用程序中,您应该处理 TCP-Sockets:https: //de.wikibooks.org/wiki/Googles_Android/_TCP-Sockets
Try something like this in an async task:
在异步任务中尝试这样的事情:
socket = new Socket();
socket.connect(new InetSocketAddress(ip, port), Connect_Timeout);
DataOutputStream DataOut = new DataOutputStream(socket.getOutputStream());
DataOut.writeBytes(message);
DataOut.flush();
socket.close();
So your ESP is the Server and the App the Client. This should work without problems.
所以你的 ESP 是服务器,应用程序是客户端。这应该没有问题。