本文整理汇总了C++中WiFly::sendChunkln方法的典型用法代码示例。如果您正苦于以下问题:C++ WiFly::sendChunkln方法的具体用法?C++ WiFly::sendChunkln怎么用?C++ WiFly::sendChunkln使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WiFly
的用法示例。
在下文中一共展示了WiFly::sendChunkln方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendPong
/** Send an index HTML page with an input box for a username */
void sendPong()
{
/* Send the header direclty with print */
wifly.println(F("HTTP/1.1 200 OK"));
wifly.println(F("Content-Type: text/xml"));
wifly.println(F("Transfer-Encoding: chunked"));
wifly.println();
/* Send the body using the chunked protocol so the client knows when
* the message is finished.
* Note: we're not simply doing a close() because in version 2.32
* firmware the close() does not work for client TCP streams.
*/
wifly.sendChunkln(F("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
snprintf_P(wbuf, sizeof(wbuf), PSTR("<pong>%s</pong>"), macaddr);
wifly.sendChunkln(wbuf);
wifly.sendChunkln();
}
示例2: send404
/** Send a 404 error */
void send404()
{
wifly.println(F("HTTP/1.1 404 Not Found"));
wifly.println(F("Content-Type: text/html"));
wifly.println(F("Transfer-Encoding: chunked"));
wifly.println();
wifly.sendChunkln(F("<html><head>"));
wifly.sendChunkln(F("<title>404 Not Found</title>"));
wifly.sendChunkln(F("</head><body>"));
wifly.sendChunkln(F("<h1>Not Found</h1>"));
wifly.sendChunkln(F("<hr>"));
wifly.sendChunkln(F("</body></html>"));
wifly.sendChunkln();
}
示例3: sendSensorsDataXML
void sendSensorsDataXML() {
/* Send the header directly with print */
wifly.println(F("HTTP/1.1 200 OK"));
wifly.println(F("Content-Type: text/xml"));
wifly.println(F("Transfer-Encoding: chunked"));
wifly.println();
/* Send the body using the chunked protocol so the client knows when
* the message is finished.
*/
wifly.sendChunkln(F("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
wifly.sendChunkln(F("<datacollector>"));
snprintf_P(wbuf, sizeof(wbuf), PSTR("<dcid>%s</dcid>"), macaddr);
wifly.sendChunkln(wbuf);
wifly.sendChunkln(F("<geoloc>"));
int ind;
char scanbufcpy[500];
strncpy(scanbufcpy, scanbuf, 500);
char *ap, *oap;
char *apdesctok, *apdesc;
ap = strtok_r(scanbufcpy, "|", &oap);
while(ap != NULL) {
wifly.sendChunkln(F("<ap>"));
ind = 0;
apdesctok = strtok_r(ap, " ", &apdesc);
while(apdesctok != NULL) {
ind++;
switch(ind) {
case 3:
snprintf_P(wbuf, sizeof(wbuf), PSTR("<channel>%s</channel>"), apdesctok);
wifly.sendChunkln(wbuf);
break;
case 4:
snprintf_P(wbuf, sizeof(wbuf), PSTR("<rssi>%s</rssi>"), apdesctok);
wifly.sendChunkln(wbuf);
break;
case 6:
snprintf_P(wbuf, sizeof(wbuf), PSTR("<mac>%s</mac>"), apdesctok);
wifly.sendChunkln(wbuf);
break;
default:
;
}
apdesctok = strtok_r(NULL, " ", &apdesc);
}
wifly.sendChunkln(F("</ap>"));
//Serial.println();
ap = strtok_r(NULL, "|", &oap);
}
wifly.sendChunkln(F("</geoloc>"));
wifly.sendChunkln(F("<sensors>"));
/* Include readings from Analog pins */
dtostrf(Thermistor(analogRead(ThermistorPIN)), 5,2, convbuf);
snprintf_P(wbuf, sizeof(wbuf), PSTR("<sensor><type>temp</type><value>%s</value></sensor>"), convbuf);
#ifdef DEBUG
Serial.println(wbuf);
#endif
wifly.sendChunkln(wbuf);
dtostrf(Photoresistor(analogRead(PhotoresistorPIN)), 5,2, convbuf);
snprintf_P(wbuf, sizeof(wbuf), PSTR("<sensor><type>light</type><value>%s</value></sensor>"), convbuf);
#ifdef DEBUG
Serial.println(wbuf);
#endif
wifly.sendChunkln(wbuf);
sprintf(convbuf,"NA");
snprintf_P(wbuf, sizeof(wbuf), PSTR("<sensor><type>humidity</type><value>%s</value></sensor>"), convbuf);
#ifdef DEBUG
Serial.println(wbuf);
#endif
wifly.sendChunkln(wbuf);
sprintf(convbuf,"NA");
snprintf_P(wbuf, sizeof(wbuf), PSTR("<sensor><type>pressure</type><value>%s</value></sensor>"), convbuf);
#ifdef DEBUG
Serial.println(wbuf);
#endif
wifly.sendChunkln(wbuf);
wifly.sendChunkln(F("</sensors>"));
wifly.sendChunkln(F("</datacollector>"));
wifly.sendChunkln();
}