本文整理汇总了C++中EthernetClient::stop方法的典型用法代码示例。如果您正苦于以下问题:C++ EthernetClient::stop方法的具体用法?C++ EthernetClient::stop怎么用?C++ EthernetClient::stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EthernetClient
的用法示例。
在下文中一共展示了EthernetClient::stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: efail
void efail()
{
byte thisByte = 0;
int loopCount = 0;
eth_client.println(F("QUIT"));
while(!eth_client.available()) {
#ifdef WATCHDOG
wdt_reset();
#endif
delay(1);
loopCount++;
// if nothing received for 10 seconds, timeout
if(loopCount > 10000) {
eth_client.stop();
Serial.println(F("\r\nTimeout"));
return;
}
}
while(eth_client.available())
{
thisByte = eth_client.read();
Serial.write(thisByte);
}
eth_client.stop();
Serial.println(F("disconnected"));
}
示例2: recordValue
void Nimbits::recordValue(double value, String pointId) {
EthernetClient client;
String json;
json = "{\"d\":\"";
json += floatToString(value, 4);
json += "\"}";
String content;
content += "&json=";
content += json;
content += "&id=";
content += pointId;
if (client.connect(_hostname.c_str(), _port)) {
doPost(client, VALUE_API, content);
String response = getFullResponse(client);
client.stop();
}
else {
client.stop();
}
}
示例3: login
String Nimbits::login(String email, String password) {
EthernetClient client;
_email = email;
_password = password;
String content;
content = "email=";
content += email;
content += "&token=";
content += _password;
if (client.connect(_hostname.c_str(), _port)) {
doPost(client, SESSION_API, content);
String response = getFullResponse(client);
String str = getContent(response);
Serial.println(str);
client.stop();
int str_len = str.length() + 1;
StaticJsonBuffer<1024> jsonBuffer;
char char_array[str_len];
// Copy it over
str.toCharArray(char_array, str_len);
JsonObject& root = jsonBuffer.parseObject(char_array);
if (!root.success()) {
_authToken = "";
return "";
}
_authToken = root["token"];
}
else {
client.stop();
}
return _authToken;
}
示例4: getValue
double Nimbits::getValue(String point) {
EthernetClient client;
String content;
content += "&id=";
content += (_email + "/" + point);
if (client.connect(_hostname.c_str(), _port)) {
doGet(client, VALUE_API, content);
String response = getFullResponse(client);
String str = getContent(response);
client.stop();
int str_len = str.length() + 1;
StaticJsonBuffer<256> jsonBuffer;
char char_array[str_len];
// Copy it over
str.toCharArray(char_array, str_len);
JsonObject& root = jsonBuffer.parseObject(char_array);
if (!root.success()) {
return -1.0;
}
double d = root["d"];
return d;
}
else {
client.stop();
return 0;
}
}
示例5: GAE
String GAE(String link) {
httpRequest(link);
delay(10000);
String readString = ""; //Reset string
while (client.available() > 0) {
char s = client.read();
//Serial.print(s); //Complete response w/ headers. For dev mode.
if (s== '\n') {
char c = client.read();
//Serial.print(c); //Parsed response. For dev mode.
if (c == '\r') {
while (client.connected()) {
char z = client.read();
readString += z;
}
}
}
}
client.stop();
return(readString);
}
示例6: loop
void loop() {
// listen for incoming clients
EthernetClient client = server.available();
// we get a request
if (client) {
Serial.println(F("Client connected"));
// an http request ends with a blank line
boolean done = false;
while (client.connected() && !done) {
while (client.available () > 0 && !done) {
done = processIncomingByte (client.read ());
}
} // end of while client connected
// get ROV status values as json string
String rovStatus = getRovStatus();
// send a standard http response header
client.println(F("HTTP/1.1 200 OK"));
client.println(F("Content-Type: text/json"));
client.println(F("Connection: close")); // close after completion of the response
client.println(); // end of HTTP header
client.println(rovStatus);
// give the web browser time to receive the data
delay(10);
// close the connection:
client.stop();
Serial.println(F("Client disconnected"));
} // end of got a new client
} // end of loop
示例7: createPoint
void Nimbits::createPoint(String pointName)
{
EthernetClient client;
if (client.connect(GOOGLE, PORT))
{
client.println(F("POST /service/point HTTP/1.1"));
String content;
// writeAuthParams(content);
content += "email=";
content += _ownerEmail;
if (_accessKey.length() > 0)
{
content += ("&key=");
content += (_accessKey);
}
content += "&action=create&point=";
content += (pointName);
client.println(F("Host:nimbits1.appspot.com"));
client.println(F("Connection:close"));
client.println(F("Cache-Control:max-age=0"));
client.print(F("Content-Type: application/x-www-form-urlencoded\n"));
client.print(F("Content-Length: "));
client.print(content.length());
client.print(F("\n\n"));
client.print(content);
while (client.connected() && !client.available())
{
delay(1); //waits for data
}
client.stop();
client.flush();
}
}
示例8: loop
void loop() {
// listen for incoming clients
EthernetClient client = server.available();
if (client)
{
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected())
{
if (client.available())
{
char c = client.read();
Serial.write(c);
//*******************233333333333333333333333333333333333333333333*******
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank)
{
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: textml");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel);
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(sensorReading);
client.println("<br />");
}
client.println("<ml>");
break;
}
if (c == '\n')
{
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r')
{
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disconnected");
}
}
示例9: loop
void DataServeriOS::loop()
{
_client = _server->available();
if (_client)
{
WaitForRequest();
ParseReceivedRequest();
PerformRequestedCommand();
_client.flush();
_client.stop();
}
else {
_client.stop();
_substitudeLoop();
}
}
示例10: sendData
// this method makes a HTTP connection to the server:
void sendData(String thisData) {
// if there's a successful connection:
if (client.connect(server, 80)) {
Serial.println("connecting...");
// send the HTTP PUT request:
client.print("PUT /v2/feeds/");
client.print(FEEDID);
client.println(".csv HTTP/1.1");
client.println("Host: api.xively.com");
client.print("X-ApiKey: ");
client.println(APIKEY);
client.print("User-Agent: ");
client.println(USERAGENT);
client.print("Content-Length: ");
client.println(thisData.length());
// 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.println(thisData);
}
else {
// if you couldn't make a connection:
Serial.println("connection failed");
Serial.println();
Serial.println("disconnecting.");
client.stop();
}
// note the time that the connection was made or attempted:
lastConnectionTime = millis();
}
示例11: getData
void getData(char *dst)
{
Serial.println("Trying to grab data from server:");
// from the server, read them and print them:
int i = 0;
while (!client.available());
while (client.available()) {
char c = client.read();
Serial.print(c);
if (i < 10)
{
dst[i] = c;
//dst[i+1] = 0;
}
i++;
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
while(true);
}
}
示例12: 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() && lastConnected) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
}
// if you're not connected, and ten seconds have passed since
// your last connection, then connect again and send data:
if(!client.connected() && (millis() - lastConnectionTime > postingInterval)) {
httpRequest();
}
// store the state of the connection for next time through
// the loop:
lastConnected = client.connected();
}
示例13: sendData
/*
* Sends an HTTP POST request containing the name and the code to the server.
*/
void sendData() {
Serial.print("attempting to send data (name = ");
Serial.print(nameBuf);
Serial.print(", code = ");
Serial.print(buffer);
Serial.println(")");
// if you get a connection, report back via serial:
if (client.connect(server, port)) {
Serial.println("connected");
// Make a HTTP request:
client.print("POST /barcode");
client.print("?name=");
client.print(nameBuf);
client.print("&code=");
client.print(buffer);
client.print("&uptime=");
client.print(millis());
client.println(" HTTP/1.0");
client.println();
client.flush();
client.stop();
Serial.println("request sent");
}
else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}
示例14: loop
void loop() {
client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
if (client.find("GET /")) {
//INICIAR CRONOMETRAGEM
if (client.find("setCron=")) {
int charReaded = client.read();
if(charReaded == 49){
iniciarCronometragem();
}
}
//RETORNA O TEMPO DESDE O INICIO
if (client.find("getCron=")) {
int charReaded = client.read();
if(charReaded == 49){
getCronometragem();
}
}
}
}
Serial.println();
break;
}
client.println(" HTTP/1.1 200 OK ");
}
// give the web browser time to receive the data
delay(1);
client.stop();
}
示例15: serverRequest
//builds the url for the api request, connects to the server, and sends the request
boolean serverRequest() {
//Serial.print(server);
//Serial.println(page);
client.stop();
Serial.println("connecting...");
if (client.connect(server, 80)) {
Serial.println("connected");
client.print("GET /makermanager/index.php?r=api/toolValidate&badge=");
client.print(rfid_long);
client.print("&tool=1");
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println("User-Agent: arduino-ethernet");
client.println("Connection: close");
client.println("");
//Serial.println(cmd);
//client.println(cmd);
return true;
}
else {
Serial.println("connection failed");
return false;
}
}