|
楼主 |
发表于 2012-12-26 10:56:34
|
显示全部楼层
皮皮 发表于 2012-12-25 09:02
Mega2560也是一样的,多看一下Arduino提供的库,他们的库写的很好。
不好意思没看懂:这个是arduino cosm client 的例子
// send the HTTP PUT request:
client.print("PUT /v2/feeds/");
client.print(FEEDID);
client.println(".csv HTTP/1.1");
client.println("Host: api.cosm.com");
client.print("X-ApiKey: ");
client.println(APIKEY);
client.print("User-Agent: ");
client.println(USERAGENT);
client.print("Content-Length: ");
// calculate the length of the sensor reading in bytes:
// 8 bytes for "sensor1," + number of digits of the data:
int thisLength = 8 + getLength(thisData);
client.println(thisLength);
// last pieces of the HTTP PUT request:
client.println("Content-Type: text/csv");
client.println("Connection: close");
client.println();
// here's the actual content of the PUT request:
client.print("sensor1,");
client.println(thisData);
我尝试把 client.print的内容组成一个字符串一起 cient.print ,还是一个字节一个字节发出去的,能仔细解释一下怎么开一个缓冲么? 是要改写库函数么? |
|