问题描述
我有一个连接到微电路的ESP8266芯片。当芯片值200时,灯开始闪烁4次,然后返回100值。我需要使用Java创建一个Android应用程序,它将连接到ESP8266芯片,向其发送数据并获得值100。我不知道应该用什么库来处理它。请帮助我,我该怎么办?我认为这不是最难的问题。
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.
推荐答案
对于你的控制器,你不需要任何Libary。您只需使用串行AT命令:
In your App you should deal with 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();
因此,您的ESP是服务器,应用程序是客户端。这应该没有问题。
So your ESP is the Server and the App the Client. This should work without problems.
这篇关于从Android设备向ESP8266 Wi-Fi芯片发送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!