本文整理汇总了C++中WiFiServer::println方法的典型用法代码示例。如果您正苦于以下问题:C++ WiFiServer::println方法的具体用法?C++ WiFiServer::println怎么用?C++ WiFiServer::println使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WiFiServer
的用法示例。
在下文中一共展示了WiFiServer::println方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loop
void loop() {
static boolean packetActive = false;
static uint8_t index = 0;
static boolean readingReturn = false;
static uint8_t rindex = 0;
if (!client.connected()) {
// try to connect to a new client
client = server.available();
} else {
// read data from the connected client
if (client.available() > 0) {
char c = client.read();
if (packetActive) {
commandBuffer[index] = c;
commandBuffer[++index] = 0;
if (c == EOP) {
comHandler();
packetActive = false;
}
}
else if (c == SOP) {
index = 0;
commandBuffer[index] = c;
commandBuffer[++index] = 0;
packetActive = true;
}
if (returnReady) {
client.println(returnBuffer);
server.println(returnBuffer);
Serial.println(returnBuffer);
returnReady = false;
}
}
}
if (Serial.available() && !returnReady) {
char s = Serial.read();
if (s == SOP) {
readingReturn = true;
rindex = 0;
}
if (readingReturn) {
returnBuffer[rindex] = s;
returnBuffer[++rindex] = 0;
if (s == EOP) {
returnReady = true;
}
}
}
}
示例2: transmitTele
void transmitTele()
{
Serial.println("tele");
while(!alreadyConnectedTele)
{
//attempt to save a client connecting to the server
teleClient = teleServer.available();
//if a client is connected, begin communication
if (teleClient) {
if (!alreadyConnectedTele) {
// clead out the input buffer:
teleClient.flush();
Serial.println("We have a new client");
alreadyConnectedTele = true;
}
}
}
for(int i = 0; i < 20; i++)
{
if (teleClient.available() > 0) {
// read the bytes incoming from the client:
char thisChar = teleClient.read();
// echo the bytes back to the client:
if(thisChar == '1')
teleServer.println(curSpeedKn * KNOTS_TO_MPS);
if(thisChar == '2')
teleServer.println(pollPing());
if(thisChar == '3')
teleServer.println(distToTar());
if(thisChar == '4')
teleServer.println(curLat);
if(thisChar == '5')
teleServer.println(curLon);
if(thisChar == '6')
teleServer.println(curHead);
// echo the bytes to the server as well:
Serial.println(thisChar);
}
}
}
示例3: waitForTarget
void waitForTarget()
{
//define a client object to connect to the server
WiFiClient mainClient;
//wait for a client to connect to the server
while(!alreadyConnectedMain)
{
//attempt to save a client connecting to the server
mainClient = mainServer.available();
//if a client is connected, begin communication
if (mainClient) {
if (!alreadyConnectedMain) {
// clead out the input buffer:
mainClient.flush();
Serial.println("We have a new client");
debugServer.println("We have a new client");
mainClient.println("Hello, client!");
alreadyConnectedMain = true;
}
}
delay(100);
delay(100);
}
Serial.println("writing");
debugClient.println("writing");
//mainServer.println("ready");
delay(1000);
//Strings to read in latitude and longitude from the client
char lat[50] = "";
char lon[50] = "";
int ind = 0;
//Wait for input to be on the buffer
while(!mainClient.available());
char destNum = '0';
while(!(destNum == '1' || destNum == '2' || destNum == '3'))
{
destNum = mainClient.read();
Serial.println(destNum);
}
if(destNum == '1')
{
tarLat = LAT1;
tarLon = LON1;
}
if(destNum == '2')
{
tarLat = LAT2;
tarLon = LON2;
}
if(destNum == '3')
{
tarLat = LAT3;
tarLon = LON3;
}
/*
//Read in characters from the input buffer until a new line character is reached
//this will be the latitude
while(mainClient.available())
{
char c = mainClient.read();
lat[ind] = c;
if(c == '\n')
{
lat[ind] = NULL;
break;
}
ind++;
}
ind = 0;
//Read in characters from the input buffer until a new line character is reached
//this will be the longitude
while(mainClient.available())
{
char c = mainClient.read();
lon[ind] = c;
if(c == '\n')
{
lon[ind] = NULL;
break;
}
ind++;
//.........这里部分代码省略.........