Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arduino Uno+;WifiShield:Telnet错误“;“拒绝连接”;_Arduino_Wifi_Telnet - Fatal编程技术网

Arduino Uno+;WifiShield:Telnet错误“;“拒绝连接”;

Arduino Uno+;WifiShield:Telnet错误“;“拒绝连接”;,arduino,wifi,telnet,Arduino,Wifi,Telnet,我的新Arduino Uno+Wifishefield有问题。我想测试arduino.cc或arduino IDE“WifiChatServer”提供的示例代码: #包括 #包括 字符ssid[]=“ssid”//您的网络SSID(名称) 字符传递[]=“密码”;//您的网络密码(用于WPA,或用作WEP的密钥) int-keyIndex=0;//您的网络密钥索引号(仅WEP需要) int状态=WL\U空闲\U状态; WiFiServer服务器(23); 布尔值alreadyConnected=

我的新Arduino Uno+Wifishefield有问题。我想测试arduino.cc或arduino IDE“WifiChatServer”提供的示例代码:

#包括
#包括
字符ssid[]=“ssid”//您的网络SSID(名称)
字符传递[]=“密码”;//您的网络密码(用于WPA,或用作WEP的密钥)
int-keyIndex=0;//您的网络密钥索引号(仅WEP需要)
int状态=WL\U空闲\U状态;
WiFiServer服务器(23);
布尔值alreadyConnected=false;//客户端以前是否已连接
无效设置(){
//初始化串行端口并等待端口打开:
Serial.begin(9600);
而(!串行){
;//等待串行端口连接。仅Leonardo需要
}
//检查是否存在屏蔽:
如果(WiFi.status()=无线无屏蔽){
Serial.println(“不存在WiFi屏蔽”);
//不要继续:
虽然(正确);
} 
//尝试连接到Wifi网络:
当(状态!=WL_已连接){
Serial.print(“试图连接到SSID:”);
序列号println(ssid);
//连接到WPA/WPA2网络。如果使用open或WEP网络,请更改此行:
状态=WiFi.begin(ssid,通过);
//等待10秒钟以进行连接:
延迟(10 000);
} 
//启动服务器:
server.begin();
//您现在已连接,请打印状态:
printWifiStatus();
}
void循环(){
//等待新客户端:
WiFiClient=server.available();
//当客户端发送第一个字节时,打招呼:
如果(客户){
如果(!已连接){
//清除输入缓冲区:
client.flush();
Serial.println(“我们有一个新客户”);
println(“你好,客户!”);
alreadyConnected=true;
} 
if(client.available()>0){
//读取从客户端传入的字节:
char thisChar=client.read();
//将字节回显到客户端:
server.write(thisChar);
//将字节也回显到服务器:
Serial.write(thisChar);
}
}
}
void printWifiStatus(){
序列号。打印(“SSID:”);
Serial.println(WiFi.SSID());
//打印您的WiFi屏蔽的IP地址:
ip地址ip=WiFi.localIP();
串行打印(“IP地址:”);
序列号println(ip);
//打印接收到的信号强度:
长rssi=WiFi.rssi();
串行打印(“信号强度(RSSI):”;
串行打印(rssi);
Serial.println(“dBm”);
}
您也可以在此处查找代码:

除了输入我的家庭wifi连接数据外,我没有做任何更改。在将代码上传到我的arduino后,控制器连接到wifi并打印我的路由器分配的ip地址。arduino也列在路由器上的连接设备表中

从我的笔记本电脑Ping arduino成功了

试图通过telnet(putty)连接arduino时,显示错误“连接被拒绝”。我试图连接我的笔记本电脑上禁用的防火墙,另一个端口(8888/9999)和我的智能手机,每次都出现同样的错误

以下是wireshark捕获的简单ping和telnet请求:


有人有办法解决这个问题吗?

我也遇到过一些类似的问题(官方的wifi屏蔽)。我使用ArduinoIDE的早期版本解决了这个问题。我从1.0.5降到了1.0.3,效果不错。也许你也有同样的问题


至少值得一试

使用Arduino 1.05我也遇到了同样的问题。我刚刚将WiFi库从Arduino 1.0.4复制到Arduino 1.0.5,它可以正常工作。

我似乎复制了一个示例代码,其中
服务器.begin()丢失。因此,请确保您的实现是完整的

无法解释,但它使用的代码完全相同。。荒谬是最好的。尖端的Thx;-)
#include <SPI.h>
#include <WiFi.h>

char ssid[] = "ssid"; //  your network SSID (name) 
char pass[] = "password";    // your network password (use for WPA, or use      as key for WEP)

int keyIndex = 0;            // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

WiFiServer server(23);

boolean alreadyConnected = false; // whether or not the client was connected previously

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600); 
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present"); 
   // don't continue:
    while(true);
  } 

  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) { 
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:    
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  } 
  // start the server:
  server.begin();
  // you're connected now, so print out the status:
  printWifiStatus();
 }


void loop() {
 // wait for a new client:
  WiFiClient client = server.available();


  // when the client sends the first byte, say hello:
   if (client) {
    if (!alreadyConnected) {
      // clead out the input buffer:
      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);
    }
  }
}


void printWifiStatus() {
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}