本文整理汇总了C++中WiFly::println方法的典型用法代码示例。如果您正苦于以下问题:C++ WiFly::println方法的具体用法?C++ WiFly::println怎么用?C++ WiFly::println使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WiFly
的用法示例。
在下文中一共展示了WiFly::println方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: request
int JSONAPI::request ( js0n_user_cb_t cb ) {
if (this->hasBody) {
wifly.println("0");
wifly.println();
}
js0n_parser_t parser;
parser.buffer = this->buffer;
parser.stream = &wifly;
parser.user_cb = cb;
int status_code = 0;
readResponseHeaders(&status_code, (int *) &parser.length);
if (status_code != 0 && status_code < 500) {
int parse_status = js0n_parse ( &parser );
}
return status_code;
}
示例3: 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();
}
示例4: _headerEnd
void JSONAPI::_headerEnd () {
wifly.println(" HTTP/1.1"); // paste your number here
wifly.print("Host: ");
wifly.println(this->host);
wifly.println("User-Agent: lifegraph/0.0.1");
if (this->hasBody) {
wifly.println("Content-Type: application/x-www-form-urlencoded");
wifly.println("Transfer-Encoding: chunked");
}
wifly.println();
}
示例5: _chunk
void JSONAPI::_chunk (const char *str, int len) {
char lenstr[12];
sprintf(lenstr, "%X", len);
wifly.println(lenstr);
wifly.println(str);
}
示例6: 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();
}