2016-05-13 148 views
0

这是我第一次在Stack Overflow上发布,所以请原谅/指出我在格式化这个问题时已经违反的方式,下次我会尽量做得更好。我从我认为是Yun的“Bridge”库中运行HttpClient示例。相反,像它应该打印出ASCII的,它打印此:Arduino Yun HttpClient示例故障

<html> 
<head><title>301 Moved Permanently</title></head> 
<body bgcolor="white"> 
<center><h1>301 Moved Permanently</h1></center> 
<hr><center>nginx/1.4.2</center> 
</body> 
</html> 

这是正在运行的代码:

#include <Bridge.h> 
#include <HttpClient.h> 

void setup() { 
    // Bridge takes about two seconds to start up 
    // it can be helpful to use the on-board LED 
    // as an indicator for when it has initialized 
    pinMode(13, OUTPUT); 
    digitalWrite(13, LOW); 
    Bridge.begin(); 
    digitalWrite(13, HIGH); 

    SerialUSB.begin(9600); 

    while (!SerialUSB); // wait for a serial connection 
} 

void loop() { 
    // Initialize the client library 
    HttpClient client; 

    // Make a HTTP request: 
    client.get("http://www.arduino.cc/asciilogo.txt"); 

    // if there are incoming bytes available 
    // from the server, read them and print them: 
    while (client.available()) { 
    char c = client.read(); 
    SerialUSB.print(c); 
    } 
    SerialUSB.flush(); 

    delay(5000); 
} 

我相信我的芸已正确连接到我的WiFi网络,但我对于它如何工作或HTML如何处理知之甚少,所以任何形式的解释都会有帮助。

谢谢!

回答

0

变化

client.get("http://www.arduino.cc/asciilogo.txt"); 

进入

client.get("http://arduino.cc/asciilogo.txt");