【发布时间】:2016-09-15 07:36:31
【问题描述】:
我正在使用 Arduino nano 和 Sim808 调制解调器从互联网上读取一些数据。 为了与调制解调器通信,我正在使用 SeedStudio GPRS 库。 当我运行示例程序https://github.com/Seeed-Studio/Seeeduino_GPRS/blob/master/example/GPRS_HTTP/GPRS_HTTP.ino 一切正常,我收到“hello world”消息,所以我尝试从我的服务器http://instel.hr/proba.txt 读取 txt 文件,而不是“hello!!!!”消息 我有很多 html 标签和一些文本。 为了从服务器读取数据,我在这 2 行中对代码进行了更改: 我已经替换了这个:
char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\r\n\r\n"
if(0 == gprs.connectTCP("mbed.org", 80)) {
有了这个:
char http_cmd[] = "GET proba.txt HTTP/1.0\r\n\r\n";
if(0 == gprs.connectTCP("instel.hr", 80)) {
有人知道怎么做吗?
卢卡
【问题讨论】:
-
您到底得到了什么 HTML 输出?很可能是因为您的请求“不够完整”。您需要添加一个 Host 标头。
-
问题解决了:) char http_cmd[] = "GET instel.hr/proba.txt HTTP/1.0\r\n\r\n";
-
不错。就像我说的,你需要指定一个主机。我怀疑您的服务器的 IP 地址是唯一的;可能与他人共享。