0
Arduino(ノードMCU)用のwifiサーバーを作成しました。Arduinoのwifiサーバーで多数のクライアントが作成され、接続が失われました
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
const char *ssid = "mywifi"; // You will connect your phone to this Access Point
const char *pw = "qwerty123"; // and this is the password
IPAddress ip(192, 168, 0, 1); // From RoboRemo app, connect to this IP
IPAddress netmask(255, 255, 255, 0);
const int port = 9876; // and this port
WiFiServer server(port);
WiFiClient client;
char cmd[100]; // stores the command chars received from RoboRemo
int cmdIndex;
unsigned long lastCmdTime = 60000;
unsigned long aliveSentTime = 0;
void setup() {
delay(1000);
Serial.begin(115200);
WiFi.softAPConfig(ip, ip, netmask); // configure ip address for softAP
WiFi.softAP(ssid, pw); // configure ssid and password for softAP
server.begin(); // start TCP server
Serial.println("ESP8266 RC receiver 1.1 powered by RoboRemo");
Serial.println((String)"SSID: " + ssid + " PASS: " + pw);
Serial.println((String)"RoboRemo app must connect to " + ip.toString() + ":" + port);
}
void loop() {
if(!client.connected()) {
client = server.available();
return;
}
Serial.println("new client");
if(client.available()) {
char c = (char)client.read(); // read char from client (RoboRemo app)
Serial.println((String)c);
}
}
私はこのサーバを起動すると気にしません。私はそれを私のアンドロイドから正常に接続します。その後、アンドロイドでtelnetを開き、サーバーに接続しようとしました。しかし、サーバー側では多くのクライアントを作成した後、接続が失われました。
私は、サーバーを始めたとき、私は、このログを持っているtelnet
からサーバーに接続しようとしたとき、私はこのログ
SID: mywifi PASS: qwerty123
RoboRemo app must connect to 192.168.0.1:9876
を持っている:
SSID: mywifi PASS: qwerty123
RoboRemo app must connect to 192.168.0.1:9876
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
new client
.....
とオンandroid telnet
サイドエラーがある:
Error while receive from server: recvfron filed: ECONNRESET (Connection reset by peer)