내 프로젝트는 Android로 제어되는 Arduino RC 자동차입니다. 그것을 위해 나는 Arduino Uno R3와 Arduino WiFi shield을 샀다. 문제는 wifiShield가 클라이언트를 경청하지 않고 데이터를받을 수 없다는 것입니다. 문제를 해결하는 방법을 모르며 장치간에 연결을 설정할 수 없습니다.Arduino Wifi Shield가 통신하지 않습니다.
아두 이노 코드 : 내 문제가 발생할 수 있습니다이며 어떻게 해결할 수 무엇
char ssid[] = "***";
char pass[] = "***";
int status = WL_IDLE_STATUS;
WiFiServer server(1991);
boolean alreadyConnected = false;
void setup() {
Serial.begin(9600);
Serial.println("Attempting to connect to WPA network...");
Serial.print("SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
if (status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection");
while(true);
}
else {
server.begin();
server.status();
Serial.print("Connected to wifi. My address:");
IPAddress myAddress = WiFi.localIP();
IPAddress inetAddress=WiFi.gatewayIP();
Serial.println(myAddress);
Serial.println("Inet: ");
Serial.println(inetAddress);
}
}
void loop() {
WiFiClient client = server.available();
if(client) {
if (!alreadyConnected) {
client.flush();
Serial.println("We have a new client");
client.println("Hello, client!");
alreadyConnected = true;
}
if (client.available() > 0) {
// read the bytes incoming from the client:
char thisChar = client.read();
// echo the bytes back to the client:
server.write(thisChar);
// echo the bytes to the server as well:
Serial.write(thisChar);
}
}
}
?
표시되는 출력은 무엇입니까? 어떤 상태 메시지가 인쇄됩니까? 왜 연결에 실패하면 무한 루프가 생깁니 까? – Bart