当前位置: 首页>>代码示例>>C++>>正文


C++ EthernetClient::readString方法代码示例

本文整理汇总了C++中EthernetClient::readString方法的典型用法代码示例。如果您正苦于以下问题:C++ EthernetClient::readString方法的具体用法?C++ EthernetClient::readString怎么用?C++ EthernetClient::readString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EthernetClient的用法示例。


在下文中一共展示了EthernetClient::readString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: config_handler

static boolean config_handler(TinyWebServer& web_server) 
{
	web_server.send_error_code(200);
	web_server.end_headers();

	const char* length_str = web_server.get_header_value("Content-Length");
	int length = atoi(length_str);
	uint32_t start_time = millis();
	StringParse buf;

	EthernetClient client = web_server.get_client();

	while (buf.length() < length && client.connected() && (millis() - start_time < 30000)) {
		if (!client.available()) continue;
		buf += client.readString();
	}

	ParseConfig(buf);
	IP_Config.SaveConfig();

	main_page(client, F("<font color='green'>IP Config saved</font>"));

	return true;
}
开发者ID:nanda-dash,项目名称:LDuino,代码行数:24,代码来源:plcweb.cpp

示例2: loop

// The loop function is called in an endless loop
void loop() {



	// if there's incoming data from the net connection.
	// send it out the serial port. This is for debugging
	// purposes only:
	if (client.available()) {
		char c = client.read();
		Serial.print(c);
	}

	// if there's no net connection, but there was one last time
	// through the loop, then stop the client:
	if (!client.connected() && wasConnected) {
		Serial.println();
		Serial.println("disconnecting.");
		client.stop();
		wasConnected = false;
	}

	if (PowerSerial::solar.count < 0) {
		int waitTime = millis() - lastupdate;
		if (waitTime > 30000) {
			String jsonResult = PowerSerial::solar.jsonResult;
			Serial.println("transmit Every 30 seconds");
			lastupdate = millis();

			lmillis = tmillis; //timing to determine amount of time since last call
			tmillis = millis();

			delay(1000);
			if (!client.connected()) {
				Serial.println(jsonResult);
				// if there's a successful connection:
				Serial.println("!client.connected() --> 1");

//				DNSClient dns;
//				IPAddress remote_addr;
//				dns.begin(Ethernet.dnsServerIP());
//				int ret = dns.getHostByName(serverName, remote_addr);
//				  if (ret == 1) {
//				    Serial.println(serverName);
//				    Serial.println(remote_addr);
//				  } else {
//					    Serial.println("Fail !!!");
//				  }


				if (client.connect(serverName, 80)) {
					delay(1000);
					Serial.println("!client.connect() --> 2");
					wasConnected = true;
					Serial.println("connecting...");
					// send the HTTP PUT request:
					String str = "GET ";
						str.concat(input);
    					str.concat(apikey);
						str.concat(inputJson);
						str.concat(jsonResult);
						str.concat(" HTTP/1.0");

					client.println(str);
					client.println("Host: emoncms.org");
					client.println("User-Agent: arduino-ethernet");
					client.println("Connection: close");
					client.println();
					client.flush();
					Serial.println(str);
					Serial.println("Respons:");
					Serial.println(client.readString());
					PowerSerial::solar.count = 0;
				} else {
					delay(1000);
					// if you couldn't make a connection:
					Serial.println("connection failed");
					Serial.println();
					Serial.println("disconnecting.");
					client.stop();
				}

			}
		} else {
//			Serial.print("Still waiting: ");
//			Serial.println(waitTime);
		}
	} else {
		Serial.println("Powerserial has no result .... waiting: ");
	}

	if (PowerSerial::solar.count >= 0){
		PowerSerial::parse();
	}

}
开发者ID:sknipa,项目名称:thrx-arduino-home-project,代码行数:96,代码来源:irTest.cpp


注:本文中的EthernetClient::readString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。