Arduino Yun HttpClient示例故障

时间:2016-05-13 19:02:53

标签: arduino

这是我第一次在Stack Overflow上发帖,所以请原谅/指出我在格式化这个问题时违反的方法,下次我会尝试做得更好。我正在运行HttpClient示例,我认为是我的Yun上的“Bridge”库。它不是像预期的那样打印出ASCII,而是打印出来:

<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);
}

我相信我的Yun已正确连接到我的Wifi网络,但我对它的工作方式或HTML的处理方式知之甚少,因此任何解释都会有所帮助。

谢谢!

1 个答案:

答案 0 :(得分:0)

更改

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

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