本文整理汇总了C++中EthernetServer::write方法的典型用法代码示例。如果您正苦于以下问题:C++ EthernetServer::write方法的具体用法?C++ EthernetServer::write怎么用?C++ EthernetServer::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EthernetServer
的用法示例。
在下文中一共展示了EthernetServer::write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: 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
}