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


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

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


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

示例1: createFile

// Fonction créant un fichier sur carte mémoire SD
// par X. HINAULT - www.mon-club-elec.fr - GPLv3 - 03/2013
void UtilsSDEthernet::createFile(EthernetClient clientIn, char* nomFichierIn, boolean debug) {
  // La fonction reçoit : 
  // > le client Ethernet à utiliser 
  // > le nom du fichier au format 8.3
  // > un drapeau d'affichage de messages de debug
  
  // la fonction ne renvoie rien 
 
              // création nouveau fichier  
              File dataFile=SD.open(nomFichierIn, FILE_WRITE); // crée / ouvre un objet fichier et l'ouvre en mode écriture - NOM FICHIER en 8.3 ++++
              // > soit en mode : FILE_WRITE: ouvre le fichier pour lecture et écriture, en démarrant au début du fichier. 
              // Important : Si le fichier est ouvert pour écriture, il sera créé si il n'existe pas déjà (cependant le chemin le contenant doit déjà exister)
             
              clientIn.println("------"); 
                
              if (dataFile){ // le fichier est True si créé
                clientIn.println(F("Creation nouveau fichier OK")); 
                dataFile.print(""); // chaine vide
                dataFile.close(); // fermeture du fichier obligatoire après accès 
              } // si fichier existe 
              else { // sinon = si probleme creation
                clientIn.println(F("Probleme creation fichier")); 
              } // fin else datafile
  
} // fin fonction createFile 
开发者ID:sensor56,项目名称:UtilsSDEthernet,代码行数:27,代码来源:UtilsSDEthernet.cpp

示例2: setup

void setup() {
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /search?q=arduino HTTP/1.1");
    client.println("Host: www.google.com");
    client.println("Connection: close");
    client.println();
  }
  else {
    // kf you didn't get a connection to the server:
    Serial.println("connection failed");
  }

}
开发者ID:ern0,项目名称:posixino,代码行数:33,代码来源:WebClient.cpp

示例3: 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;
	}
}
开发者ID:mikelduke,项目名称:DMS-RFID-Interlock,代码行数:28,代码来源:PowerInterlock.cpp

示例4: sendData

void sendData()
{
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect("kaylee.markild.no", 80))
  
  {
    Serial.println("connected");
    // Make a HTTP request:
    Serial.println("GET /crap/test.txt HTTP/1.1");
    client.println("GET /crap/test.txt HTTP/1.1");
    Serial.println("Host: kaylee.markild.no");
    client.println("Host: kaylee.markild.no");
    Serial.println("User-Agent: ArduinoUno/r3 Ethernet Shield");
    client.println("User-Agent: ArduinoUno/r3 Ethernet Shield");
    Serial.println("Accept: */*");
    client.println("Accept: */*");    
    client.println();
  }
  else
  {
    // kf you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}
开发者ID:torkildr,项目名称:display,代码行数:26,代码来源:ehternet_utility.cpp

示例5: read

// Fonction affichant sur le port série le contenu d'un fichier sur carte mémoire SD
// par X. HINAULT - www.mon-club-elec.fr - GPLv3 - 03/2013
void UtilsSDEthernet::read(EthernetClient clientIn, char* nomFichierIn, boolean debug) {
  // La fonction reçoit : 
  // > le client Ethernet à utiliser 
  // > le nom du fichier au format 8.3
  // > un drapeau d'affichage de messages de debug
  
  // la fonction ne renvoie rien 
 
                // lecture du contenu du fichier  
                File dataFile=SD.open(nomFichierIn, FILE_READ); // ouvre le fichier en lecture - NOM FICHIER en 8.3 ++++
                // un seul fichier ne peut etre ouvert à la fois - fermer au préalable tout fichier déjà ouvert
               
                clientIn.println(F("------")); 
                    
                if (dataFile){ // le fichier est True si créé
                  if (debug) clientIn.println(F("Ouverture fichier OK")); 
                
                  while (dataFile.available()) { // tant que des données sont disposnibles dans le fichier
                  // le fichier peut etre considéré comme un "buffer" de données comme le buffer du port série
                
                    char c = dataFile.read(); // lit le caractère suivant
                    clientIn.print(c); // affiche le caractère courant
                    
                    //if (c==10) delay(10); // pause enttre 2 lignes
                  } // fin while available
                
                  dataFile.close(); // fermeture du fichier obligatoire après accès 
                  
                } // si fichier True 
                else { // sinon = si probleme creation
                  clientIn.println(F("Probleme lecture fichier")); 
                } // fin else              
  
} // fin fonction readSerial 
开发者ID:sensor56,项目名称:UtilsSDEthernet,代码行数:36,代码来源:UtilsSDEthernet.cpp

示例6: loop

void loop()
{
	static double v = 0.0;
	static int count = 0;

	EthernetClient client = server.available();
	if (client)
	{
		while(true){

			Serial.print("Printing data... count=");
			Serial.println(count);

			client.print(count++); client.print("; ");
			client.print(0.00 + v, 2); client.print("; ");
			client.print(1.23 + v, 2); client.print("; ");
			client.print(2.098 + v, 3); client.print("; ");
			client.print(3.83974 + v, 5); client.print("; ");
			client.print(1.23 + v, 10); client.print("; ");
			client.println(6.1276512765 + v, 10);
			client.println("\r\n");

			Serial.println("Done!");
			delay(1000);

			v += 0.2;
		}
	}else{
		Serial.print("NO client!!! count=");
		Serial.println(count++);
	}

	delay(1000);

}
开发者ID:davidalain,项目名称:ArduinoProjectsAndLibraries,代码行数:35,代码来源:TCPServerExample.cpp

示例7: sendData

void CosmClient::sendData(uint32_t feedId, char datastreamId[], double dataToSend)
{
    if (_client.connect("api.cosm.com", 80)) {
        Serial.println("Connecting to Cosm...");

        _client.print("PUT /v2/feeds/");
        _client.print(feedId);
        _client.print("/datastreams/");
        _client.print(datastreamId);
        _client.print(".csv HTTP/1.1\n");
        _client.print("Host: api.cosm.com\n");

        _client.print("X-ApiKey: ");
        _client.print(_api);
        _client.print("\n");
        _client.print("Content-Length: ");

        int lengthOfData = getLength(dataToSend);
        _client.println(lengthOfData, DEC);

        _client.print("Content-Type: text/csv\n");
        _client.println("Connection: close\n");

        _client.print(dataToSend, DEC);
    }
}
开发者ID:Gerst20051,项目名称:ArduinoExamples,代码行数:26,代码来源:Cosm.cpp

示例8: 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");
	}
}
开发者ID:rjoberon,项目名称:arduino-barcode-client,代码行数:33,代码来源:scanner.cpp

示例9: 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
开发者ID:koppii,项目名称:NimanRov,代码行数:32,代码来源:main.cpp

示例10: loop

void loop() {
  unsigned long time = millis();
  if (next < time) {
    Ethernet.maintain();
    next += send_delay;
    if (next <= time)
      next = time + 1;
    Serial.println("request time !");
    if (client.connected()) {
      Serial.println("already connected");
    } else {
      Serial.print("connecting results : ");
      Serial.println(client.connect("tarzan.info.emn.fr", 80));
    }
    int sent = client.println("GET /ping.php HTTP/1.1");
    sent = client.println(F("Host: tarzan.info.emn.fr"));
    client.println();
  }
  if (client.connected() && client.available() > 0) {
    Serial.println("client received data  : ");
    unsigned char buffer[buff_size + 1];
    while (client.available() > 0) {
      int read = client.read(buffer, buff_size);
      buffer[read] = '\0';
      Serial.println(read);
    }
  }
  if (radio.receiveDone()) {
  }
}
开发者ID:glelouet,项目名称:Connected_House,代码行数:30,代码来源:TcpClient.cpp

示例11: 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();
  }

}
开发者ID:pelrun,项目名称:Logger,代码行数:34,代码来源:Nimbits.cpp

示例12: loopServer

void loopServer() {
	EthernetClient client = server.available();
	if (client) {
		while (client.connected()) {
			if (client.available()) {
				char c = client.read();

				//read char by char HTTP request
				if (readString.length() < 100) {

					//store characters to string
					readString += c;
					//Serial.print(c);
				}

				//if HTTP request has ended
				if (c == '\n') {

					///////////////
					Serial.print(readString); //print to serial monitor for debuging

					//now output HTML data header
					client.println(F("HTTP/1.1 200 OK")); //send new page on browser request
					client.println(F("Content-Type: text/html"));
					client.println();

					client.println(F("Ok"));

					delay(1);
					//stopping client
					client.stop();

					if (readString.indexOf("R1=1") > 0){
						soldoRelays[0]->On();
//						Serial.println(">>>>>>>>>>>>");
//						Serial.println("R1=1");
					}
					if (readString.indexOf("R2=1") > 0){
						soldoRelays[1]->On();
//						Serial.println(">>>>>>>>>>>>");
//						Serial.println("R2=1");
					}
					if (readString.indexOf("R1=0") > 0){
						soldoRelays[0]->Off();
//						Serial.println(">>>>>>>>>>>>");
//						Serial.println("R1=0");
					}
					if (readString.indexOf("R2=0") > 0){
						soldoRelays[1]->Off();
//						Serial.println(">>>>>>>>>>>>");
//						Serial.println("R2=0");
					}
					readString="";

				}
			}
		}
	}
}
开发者ID:dcupovic,项目名称:arduino,代码行数:59,代码来源:SoldoEthernet.cpp

示例13: printHeader

void printHeader() {

  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: application/json");
  client.println("Connnection: close");
  client.println();
  client.println("{");

}
开发者ID:SoftsquareBr,项目名称:telemetria,代码行数:9,代码来源:ArduinoCode2.cpp

示例14: listenServer

void LeweiTcpClient::listenServer()
{
  EthernetClient clientWeb = server.available();
  if (clientWeb) {
    //Serial.println("new clientWeb");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    String clientStr = "";
    while (clientWeb.connected()) {
      if (clientWeb.available()) {
        char c = clientWeb.read();
        clientStr += c;
        //Serial.write(c);
        
        // 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) {
          clientWeb.println("<html><body><form method='get'>");
          clientWeb.print("KEY<input type='text' name='a' value='");
          clientWeb.print(_userKey);
          clientWeb.print("'>GW<input type='text' name='g' value='");
          clientWeb.print(_gatewayNo);
          clientWeb.println("'><input type='submit'>");
          clientWeb.println("</form></body></html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
          if(clientStr.indexOf(" /?a=")>0)
          {
          	Serial.print(clientStr);
          	String userInfoStr = clientStr.substring(clientStr.indexOf(" /?a=")+5,clientStr.indexOf("&g="));
          	userInfoStr += clientStr.substring(clientStr.indexOf("&g=")+3,clientStr.indexOf(" HTTP/1.1"));
            if(userInfoStr.length()>33)writeRom(userInfoStr);
            Serial.println(userInfoStr);
          }
          //Serial.println(clientStr);
          clientStr = "";
          //checkFreeMem();
        } 
        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:
    clientWeb.stop();
    clientWeb= NULL;
    //Serial.println("clientWeb disonnected");
  }
  
}
开发者ID:Red680812,项目名称:LeweiTcpClient,代码行数:57,代码来源:LeweiTcpClient.cpp

示例15: processCommand

//---------------------------------------------------------------------
void processCommand( uint8_t command )
{
    switch ( command )
    {
        //-------------------------------------------------------------
        case COMMAND_TAG_EMULATE:
        {
#ifdef DEBUG_SERIAL
            Serial.println( "DEBUG: nfc tag emulate" );
#endif
            emulateNfcTag();
            break;
        }
        //-------------------------------------------------------------
        case COMMAND_VIB_MEASUREMENT:
        {
#ifdef DEBUG_SERIAL
            Serial.println( "DEBUG: vibration measurement" );
#endif
            if ( measureVibration() )
                client_.println( VIB_MEASUREMENT_RESP_ON );
            else
                client_.println( VIB_MEASUREMENT_RESP_OFF );
            
            break;
        }
        //-------------------------------------------------------------
        case COMMAND_LIGHT_MEASUREMENT:
        {
#ifdef DEBUG_SERIAL
            Serial.println( "DEBUG: light measurement" );
#endif
            if ( measureLight() )
                client_.println( LIGHT_MEASUREMENT_RESP_ON );
            else
                client_.println( LIGHT_MEASUREMENT_RESP_OFF );
            
            break;
        }
        //-------------------------------------------------------------
        case COMMAND_VIB_CALIBRATE:
        {
#ifdef DEBUG_SERIAL
            Serial.println( "DEBUG: calibrate vibration sensor" );
#endif
            vibrationCalibration();
            break;
        }
        default:
            //handle error
            ;
#ifdef DEBUG_SERIAL
            Serial.println( "WARNING: unknown command" );
#endif
    }
}
开发者ID:BerndBaumann,项目名称:Arduino,代码行数:57,代码来源:main.cpp


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