本文整理汇总了C++中SoftwareSerial::find方法的典型用法代码示例。如果您正苦于以下问题:C++ SoftwareSerial::find方法的具体用法?C++ SoftwareSerial::find怎么用?C++ SoftwareSerial::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoftwareSerial
的用法示例。
在下文中一共展示了SoftwareSerial::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wificmd
bool wificmd(String cmd, String verify) {
ESPserial.println("AT+"+cmd);
if(verify != "") {
if(ESPserial.find("OK")) {
return true;
}
return false;
}
return true;
}
示例2: getState
int getState () {
if( !wificmd("CIPSTART=\"TCP\",\"example.com\",8080", "OK")) { //start a TCP connection.
return 0;
}
delay(1000);
String getRequest = "STATE";
ESPserial.print("AT+CIPSEND=");
ESPserial.println(getRequest.length());
delay(500);
if(ESPserial.find(">")) {
clearWifi();
//Serial.println("Sending..");
ESPserial.print(getRequest);
if( ESPserial.find("SEND OK")) {
//Serial.println("Packet sent");
String tmpResp = "";
while (ESPserial.available()) {
tmpResp = ESPserial.readString();
}
// close the connection
if(wificmd("CIPCLOSE", "OK")) {
if (tmpResp.substring(11) == "1") {
return 1;
} else {
return 0;
}
} else {
Serial.println("Error closing connection");
}
} else {
Serial.println("Error sending data");
}
}
return 0;
}
示例3: loop
void loop()
{
if(esp8266.available()) // check if the esp is sending a message
{
/*
while(esp8266.available())
{
// The esp has data so display its output to the serial window
char c = esp8266.read(); // read the next character.
Serial.write(c);
} */
if(esp8266.find("+IPD,"))
{
delay(1000);
int connectionId = esp8266.read()-48; // subtract 48 because the read() function returns
// the ASCII decimal value and 0 (the first decimal number) starts at 48
String webpage = "<h1>Hello</h1><h2>World!</h2><button>LED1</button>";
String cipSend = "AT+CIPSEND=";
cipSend += connectionId;
cipSend += ",";
cipSend +=webpage.length();
cipSend +="\r\n";
sendData(cipsend,1000,DEBUG);
sendData(webpage,1000,DEBUG);
webpage="<button>LED2</button>";
cipSend = "AT+CIPSEND=";
cipSend += connectionId;
cipSend += ",";
cipSend +=webpage.length();
cipSend +="\r\n";
sendData(cipsend,1000,DEBUG);
sendData(webpage,1000,DEBUG);
String closeCommand = "AT+CIPCLOSE=";
closeCommand+=connectionId; // append connection id
closeCommand+="\r\n";
sendData(closeCommand,3000,DEBUG);
}
}
}