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


C++ EthernetServer类代码示例

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


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

示例1: 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

示例2: 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

示例3: setup

void setup() {

Serial.begin(9600);
Ethernet.begin(mac, ip);
server.begin();
Serial.println("ready");
}
开发者ID:SoftsquareBr,项目名称:telemetria,代码行数:7,代码来源:ArduinoCode2.cpp

示例4: 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");
  }
}
开发者ID:Zhuanghq7,项目名称:Socket,代码行数:60,代码来源:1.cpp

示例5: 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();
}
开发者ID:SoftsquareBr,项目名称:telemetria,代码行数:33,代码来源:ArduinoCode2.cpp

示例6: 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

示例7: loop

void loop() {
  // wait for a new client:
  EthernetClient client = server.available();

  // when the client sends the first byte, say hello:
  if (client) {
    if (!gotAMessage) {
      Serial.println("We have a new client");
      client.println("Hello, client!"); 
      gotAMessage = true;
    }

    // read the bytes incoming from the client:
    char thisChar = client.read();
    // echo the bytes back to the client:
    server.write(thisChar);
    // echo the bytes to the server as well:
    Serial.print(thisChar);
  }
}
开发者ID:blackphoenix208,项目名称:ARMWork,代码行数:20,代码来源:main.cpp

示例8: init

void NetworkConnectionClass::init()
{
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();

  Serial.print("IP Address: ");
  Serial.println(Ethernet.localIP());

  sensorData = new LinkedList<SensorData*>();
  state = RECV_DATA;
}
开发者ID:balsabojic,项目名称:ArduinoDemo,代码行数:12,代码来源:NetworkConnection.cpp

示例9: SetupWebServer

bool SetupWebServer ( void )
{
    bool success = false;

#ifdef INTERFACE_ETHERNET
#ifdef ETHERNET_WEBSERVER
        server.begin();
#endif //ETHERNET_WEBSERVER
#endif // INTERFACE_ETHERNET

    return success;
}
开发者ID:mechatrocity,项目名称:greenOmatic,代码行数:12,代码来源:Ethernets.cpp

示例10: 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 and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}
开发者ID:Zhuanghq7,项目名称:Socket,代码行数:14,代码来源:1.cpp

示例11: setup

void setup() {
  Serial.begin(9600);
 // Open serial communications and wait for port to open:
  pinMode(3, INPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  
  // start the Ethernet connection and the server:
  Ethernet.begin(mac);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
  startRequest = false;
}
开发者ID:Russ93,项目名称:atw,代码行数:14,代码来源:server.cpp

示例12: setup

void setup()
{
	Serial.begin(9600);

	uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
	IPAddress myIP(192,168,0,6);

	Serial.println("Iniciando...");

	Ethernet.begin(mac,myIP);

	server.begin();

	Serial.println("Rodando!!!");
}
开发者ID:davidalain,项目名称:ArduinoProjectsAndLibraries,代码行数:15,代码来源:TCPServerExample.cpp

示例13: setup

void setup()
{
  Serial.begin(115200);
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(SPK, OUTPUT);
  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();
  for(int i = 0; i < MAX_TASKS; i++)
  {
    taskList[i][0] = 0;
  }
  createTask(1, 0, 0);
  Serial.println("setup complete");
}
开发者ID:Nuk3R4z0r,项目名称:K-A,代码行数:15,代码来源:Server.cpp

示例14: setup

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

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print(F("server is at "));
  Serial.println(Ethernet.localIP());

  // setup Motors
  setupMotors();

}
开发者ID:koppii,项目名称:NimanRov,代码行数:17,代码来源:main.cpp

示例15: log_ethernet_logger

    void log_ethernet_logger(const char * name, const char * value, const char * unit){
        #ifdef DEBUG_ETHERNET_LOGGER
            DEBUG_1("Starting");
        #endif
        #ifdef ETHERNET_ENABLE_SERVER
            eth_server.print(millis(),DEC);
            eth_server.write(",");
            eth_server.write(name);
            eth_server.write(",");
            eth_server.write(value);
            eth_server.write(",");
            eth_server.write(unit);
            eth_server.println(",");
        #endif
        #ifdef ETHERNET_ENABLE_MQTT
            if (!mqtt_client.connected()){
                #ifdef ETHERNET_MQTT_USER
                    mqtt_client.connect(ETHERNET_MQTT_CLIENT, ETHERNET_MQTT_USER, "ETHERNET_MQTT_PASS");
                #else
                    mqtt_client.connect(ETHERNET_MQTT_CLIENT);
                #endif
                if (!mqtt_client.connected()){
                    return;
                }
            }
            char *nbuf;
            char *vbuf;
            int len;

            nbuf=(char*)malloc(sizeof(char)*(strlen(name)+1));
            vbuf=(char*)malloc(sizeof(char)*(strlen(name)+1));
            strcpy(nbuf, name);
            strcpy(vbuf,value);

            mqtt_client.publish(nbuf, vbuf);

            free(nbuf);
            free(vbuf);
        #endif
        #ifdef DEBUG_ETHERNET_LOGGER
            DEBUG_1("Finishing");
        #endif
    }
开发者ID:Tambralinga,项目名称:loguino,代码行数:43,代码来源:code.c


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