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


C++ WiFiClient::stop方法代码示例

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


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

示例1: attemptClient

// See if port 80 is accessable.  Try 8080 as well.
boolean WiFiManager::attemptClient(const char *szUrl)
{
  WiFiClient client;

  int i;
  Serial.print("Probe port 80");
  for(i = 0; i < 5; i++)
  {
    if (client.connect(szUrl, httpPort)) {
      client.stop();
      Serial.println("Port 80 success");
      return true;
    }
    Serial.print(".");
    delay(20);
  }
  httpPort = 8080;
  Serial.println("");
  Serial.print("Probe port 8080");
  for(i = 0; i < 5; i++)
  {
    if (client.connect(szUrl, httpPort)) {
      client.stop();
      Serial.println("Port 8080 success");
      return true;
    }
    Serial.print(".");
    delay(20);
  }
  Serial.println("");
  Serial.println("No joy");
  return false;  
}
开发者ID:Dietmar-Franken,项目名称:WiFiWaterbedHeater,代码行数:34,代码来源:WiFiManager.cpp

示例2: connectClients

void connectClients() {
	if (server.hasClient()) {
		if (!serverClient || !serverClient.connected()) {
			if (serverClient) serverClient.stop();
			serverClient = server.available();
		} else {
			//no free/disconnected spot so reject
			WiFiClient rejectClient = server.available();
			rejectClient.stop();
		}
	}
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例3: sendData

void Farmy::sendData(const char* device_id, String api_key, WiFiClient client, String data)
{
  // Todo: use retry to connect internet.
  Serial.println("Connected to Famry.");
  Serial.println("Posted:" + data);

  // Create HTTP POST Data
  String url = String("/api/v0/user_devices/") + device_id + "/sensor_datas/";
  client.print(String("POST ") + url + " HTTP/1.1\n"+ "Host: " + host + "\n");
  client.print(String("Host: ") + host + "\n");
  client.print("Content-Type: application/json\n");
  client.print(String("X-Farmy-Api-Key: ") + api_key + "\n");
  client.print("Content-Length: ");
  client.print(data.length());
  client.print("\n\n");

  client.print(data);
  Serial.println("Posted finished -----------");

  delay(500);
  if (!client.connected()) {
      Serial.println();
      Serial.println("disconnecting.");
      client.stop();
  }
}
开发者ID:arthurbryant,项目名称:farmy,代码行数:26,代码来源:Farmy.cpp

示例4: Iotfy_getdata

String Iotfy_getdata(int no_of_bytes, int timeout)
{
  int ctr=0;
  int pt=millis()/1000;
  String data="";
  data.reserve(no_of_bytes);
  while(1)
  {
    if(client.available())
    {
      char c=client.read();
      data+=c;
      Serial.print(c);
      ctr++;
      if(ctr==no_of_bytes)
        break;
    }      
    else
    {
      if(millis()/1000-pt>timeout)
      {
        pt=millis()/1000;
        break;    
      } 
    }
  }
  Serial.println("calling disconnect");
  client.flush();
  client.stop();
     
  return data;
}
开发者ID:Iotfy,项目名称:iotfy-libs,代码行数:32,代码来源:iotfy.cpp

示例5: stopAllExcept

void WiFiClient::stopAllExcept(WiFiClient* except) 
{
    for (WiFiClient* it = _s_first; it; it = it->_next) {
        if (it != except) {
            it->stop();
        }
    }
}
开发者ID:Chevelless396,项目名称:Arduino,代码行数:8,代码来源:WiFiClient.cpp

示例6: TCPhandler

void Con::TCPhandler(){
   if (this->curType&CON_TCP){
      if (ConSrv.hasClient()){
         if (ConTcp.connected()){
            ConTcp.stop();
         }
         ConTcp=ConSrv.available();
         ConTcp.write("Hello\n",6);
      }  
   }
}
开发者ID:it-guru,项目名称:ThIN,代码行数:11,代码来源:console.cpp

示例7: MbmRun

//****************** Recieve data for ModBusMaster ****************
void MgsModbus::MbmRun()
{
  //****************** Read from socket ****************
  while (MbmClient.available()) {
    MbmByteArray[MbmCounter] = MbmClient.read();
    if (MbmCounter > 4)  {
      if (MbmCounter == MbmByteArray[5] + 5) { // the full answer is recieved  
        MbmClient.stop();
        MbmProcess();
        #ifdef DEBUG
          Serial.println("recieve klaar");
        #endif    
      }
    }
    MbmCounter++;
  }
}
开发者ID:frankdunn,项目名称:ESP8266-TCP-modbusmaster,代码行数:18,代码来源:MgsModbus.cpp

示例8: rcvCommand

void RobotHostInterface::rcvCommand(struct HostCommand *command)
{
	byte rawCmd = 0xFF;
	WiFiClient client = robotServer->available();

	if (client) {
		Serial.print("Robot Client connected...");
		Serial.println("Waiting for a command......" );

		while (client.available() == 0 ) {
			delay( 100 );
		}

		rawCmd = (byte)client.read();
		Serial.print("Raw Command: ");
		Serial.print(rawCmd);

		command->cmd = rawCmd >> 3;
		command->arg = rawCmd & 0x07;

		Serial.print(", Cmd: ");
		Serial.print(command->cmd);
		Serial.print(", arg: ");
		Serial.println(command->arg);

		if (command->cmd == CMD_ARRIVAL || command->cmd == CMD_WATCHDOG) {
			if (command->cmd == CMD_ARRIVAL && getArrival()) {
				rawCmd = CMD_ARRIVAL << 3;
				setArrival(false);
			} else if (command->cmd == CMD_WATCHDOG) {
				rawCmd = 0xFF;
			} else {
				rawCmd = 0xFF;
			}
		}

		/* send acknowledgement */
		robotServer->write(rawCmd);

		delay(100);

		client.stop();
		Serial.println("Client Disconnected.\n");
	}
}
开发者ID:xingri,项目名称:dasdas,代码行数:45,代码来源:RobotHostInterface.cpp

示例9: loop

void loop() {
  // if there are incoming bytes available 
  // from the server, read them and print them:
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting from server.");
    client.stop();

    // do nothing forevermore:
    while(true);
  }
}
开发者ID:chris-gunawardena,项目名称:mesh-avr,代码行数:18,代码来源:web_client.cpp

示例10: sendTeperatureTS

void sendTeperatureTS(int temp1, int temp2, int temp3, int temp4)
{
  WiFiClient client;

  if (client.connect(tsserver, 80)) { // use ip 184.106.153.149 or api.thingspeak.com
    Serial.println("WiFi Client connected_neu ");

    EEPROM.begin(512);
    delay(10);
    String apiKey = "";
    for (int i = 81; i < 97; i++)
    {
      apiKey += char(EEPROM.read(i));
    }
    EEPROM.end();
    Serial.println("Thingspeak-API_neu: " + apiKey);

    String postStr = apiKey;
    postStr += "&field1=";
    postStr += String(temp1);
    postStr += "&field2=";
    postStr += String(temp2);
    postStr += "&field3=";
    postStr += String(temp3);
    postStr += "&field4=";
    postStr += String(temp4);
    postStr += "\r\n\r\n";

    client.print("POST /update HTTP/1.1\n");
    client.print("Host: api.thingspeak.com\n");
    client.print("Connection: close\n");
    client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n");
    client.print("Content-Type: application/x-www-form-urlencoded\n");
    client.print("Content-Length: ");
    client.print(postStr.length());
    client.print("\n\n");
    client.print(postStr);
    delay(1000);
    Serial.println("Daten an Thingspeak gesendet");
  }//end if
  sent++;
  client.stop();
}//end send
开发者ID:TobiasN82,项目名称:SMASE,代码行数:43,代码来源:main.cpp

示例11: connectSensorAPI

bool connectSensorAPI()
{
  /* ToDo: Add SSL/TLS support */
  uint16_t port;
  char hostname[NODE_EEPROM_API_HOSTNAME_MAX_LENGTH + 1];

  if(WiFi.status() != WL_CONNECTED) {
    return false;
  }

  getAPIHostnameOrDefault(&hostname[0], NODE_EEPROM_API_HOSTNAME_MAX_LENGTH);
  hostname[NODE_EEPROM_API_HOSTNAME_MAX_LENGTH] = '\0';
  port = getAPIPortOrDefault();

  client.stop();
  if(client.connect(hostname, port)) {
    return true;
  }
  return false;
}
开发者ID:CodeforChemnitz,项目名称:sensor_node-module-esp8266,代码行数:20,代码来源:sensor_node.cpp

示例12: handleNewClients

/**
 * Handle incomming Connection Request
 */
void WebSocketsServer::handleNewClients(void) {
    WSclient_t * client;
    while(_server->hasClient()) {
        bool ok = false;
        // search free list entry for client
        for(uint8_t i = 0; i < WEBSOCKETS_SERVER_CLIENT_MAX; i++) {
            client = &_clients[i];

            // state is not connected or tcp connection is lost
            if(!clientIsConnected(client)) {

                // store new connection
                client->tcp = _server->available();
#ifdef ESP8266
                client->tcp.setNoDelay(true);
#endif
                // set Timeout for readBytesUntil and readStringUntil
                client->tcp.setTimeout(WEBSOCKETS_TCP_TIMEOUT);
                client->status = WSC_HEADER;

                IPAddress ip = client->tcp.remoteIP();
                DEBUG_WEBSOCKETS("[WS-Server][%d] new client from %d.%d.%d.%d\n", client->num, ip[0], ip[1], ip[2], ip[3]);
                ok = true;
                break;
            }
        }

        if(!ok) {
            // no free space to handle client
            WiFiClient tcpClient = _server->available();
            IPAddress ip = tcpClient.remoteIP();
            DEBUG_WEBSOCKETS("[WS-Server] no free space new client from %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
            tcpClient.stop();
        }

#ifdef ESP8266
        delay(0);
#endif
    }
}
开发者ID:,项目名称:,代码行数:43,代码来源:

示例13: httpRequest

void httpRequest() {
  // close any connection before send a new request.
  // This will free the socket on the WiFi shield
  client.stop();

  // if there's a successful connection:
  if (client.connect("www.hasthelargehadroncolliderdestroyedtheworldyet.com", 80)) {
    Serial5.println("connecting...");
    // send the HTTP PUT request:
    client.println("GET / HTTP/1.1");
    client.println("Host: www.hasthelargehadroncolliderdestroyedtheworldyet.com");
    //client.println("User-Agent: ArduinoWiFi/1.1");
    client.println("Connection: close");
    client.println();

    if( client.connected() )
    {
      Serial5.println("\tClient connected");
      while( client.available() == 0 )
      {
        //Waiting for data
        if( !client.connected() )
        {
          Serial5.println("\tClient disconnected !");
          break;
        }
      }
    }
    else
    {
      Serial5.println("\tClient not connected");
    }

  }
  else {
    // if you couldn't make a connection:
    Serial5.println("\tconnection failed");
  }
}
开发者ID:Bogaat,项目名称:Arduino,代码行数:39,代码来源:test.cpp

示例14: next_client

void next_client() {
  // Listenning for new clients
  client = server.available();
  if (client) {
    Serial.println("New client");
    // bolean to locate when the http request ends
    boolean blank_line = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        if (c == '\n' && blank_line) {
            client.println("HTTP/1.1 200 OK");
            client.println("Content-Type: application/json");
            client.println("Access-Control-Allow-Origin: *");
            client.println("Connection: close");
            client.println();
            print_json();
            break;
        }
        if (c == '\n') {
          // when starts reading a new line
          Serial.println();
          blank_line = true;
        }
        else if (c != '\r') {
          // when finds a character on the current line
          Serial.write(c);
          blank_line = false;
        }
      }
    }  
    // closing the client connection
    delay(1);
    client.stop();
    Serial.println("Client disconnected.");
  }
}
开发者ID:WardCunningham,项目名称:SensorServer,代码行数:37,代码来源:esp_sensor_server.cpp

示例15: loop

void loop(){
  WiFiClient client = server.available();   // Listen for incoming clients

  if (client) {
      // Print local IP address and start web server
      Serial.println("");
      Serial.println("WiFi connected.");
      Serial.println("IP address: ");
      Serial.println(WiFi.localIP());
      //server.begin();

      // If a new client connects,
    Serial.println("New Client.");          // print a message out in the serial port
    String currentLine = "";                // make a String to hold incoming data from the client
    while (client.connected()) {            // loop while the client's connected
      if (client.available()) {             // if there's bytes to read from the client,
        char c = client.read();             // read a byte, then
        Serial.write(c);                    // print it out the serial monitor
        header += c;
        if (c == '\n') {                    // if the byte is a newline character
          // if the current line is blank, you got two newline characters in a row.
          // that's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0) {
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println("Connection: close");
            client.println();

            // turns the GPIOs on and off
            if (header.indexOf("GET /5/on") >= 0) {
              Serial.println("GPIO 5 on");
              output5State = "on";
              digitalWrite(output5, HIGH);
            } else if (header.indexOf("GET /5/off") >= 0) {
              Serial.println("GPIO 5 off");
              output5State = "off";
              digitalWrite(output5, LOW);
            } else if (header.indexOf("GET /4/on") >= 0) {
              Serial.println("GPIO 4 on");
              output4State = "on";
              digitalWrite(output4, HIGH);
            } else if (header.indexOf("GET /4/off") >= 0) {
              Serial.println("GPIO 4 off");
              output4State = "off";
              digitalWrite(output4, LOW);
            }

            // Display the HTML web page
            client.println("<!DOCTYPE html><html>");
            client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
            client.println("<link rel=\"icon\" href=\"data:,\">");
            // CSS to style the on/off buttons
            // Feel free to change the background-color and font-size attributes to fit your preferences
            client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}");
            client.println(".button { background-color: #195B6A; border: none; color: white; padding: 16px 40px;");
            client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}");
            client.println(".button2 {background-color: #77878A;}</style></head>");

            // Web Page Heading
            client.println("<body><h1>ESP8266 Web Server</h1>");

            // Display current state, and ON/OFF buttons for GPIO 5
            client.println("<p>GPIO 5 - State " + output5State + "</p>");
            // If the output5State is off, it displays the ON button
            if (output5State=="off") {
              client.println("<p><a href=\"/5/on\"><button class=\"button\">ON</button></a></p>");
            } else {
              client.println("<p><a href=\"/5/off\"><button class=\"button button2\">OFF</button></a></p>");
            }

            // Display current state, and ON/OFF buttons for GPIO 4
            client.println("<p>GPIO 4 - State " + output4State + "</p>");
            // If the output4State is off, it displays the ON button
            if (output4State=="off") {
              client.println("<p><a href=\"/4/on\"><button class=\"button\">ON</button></a></p>");
            } else {
              client.println("<p><a href=\"/4/off\"><button class=\"button button2\">OFF</button></a></p>");
            }
            client.println("</body></html>");

            // The HTTP response ends with another blank line
            client.println();
            // Break out of the while loop
            break;
          } else { // if you got a newline, then clear currentLine
            currentLine = "";
          }
        } else if (c != '\r') {  // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }
      }
    }
    // Clear the header variable
    header = "";
    // Close the connection
    client.stop();
    Serial.println("Client disconnected.");
    Serial.println("");
//.........这里部分代码省略.........
开发者ID:bensinghbeno,项目名称:design-engine,代码行数:101,代码来源:test2.cpp


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