User manual
001
//-------Controll ESP--------
002
003
boolean sendCom(String command, char respond[])
004
{
005
esp8266.println(command);
006
if (esp8266.findUntil(respond, "ERROR"))
007
{
008
return true;
009
}
010
else
011
{
012
debug("ESP SEND ERROR: " + command);
013
return false;
014
}
015
}
When you call the function, you therefore need to submit the command and the
expected return value to the function, e.g. AT and the expected return value OK.
println() transmits the command and finally waits until the expected return value or
an ERROR is received. When the expectation is met, the function returns the val-
ue true. Otherwise, the module will use the debug()-function to return an ESP
SEND ERROR and the sent command, so that it is easy to check which command
caused the problem.
Not all AT-commands have a unique or one-line return value. If, e.g., the IP ad-
dress is queried, there usually is no previously known value. Therefore, a second
sendCom()-function exists that only needs the parameter command and will then
return the entire received string. The string should not be too long, since the buffer
of SoftwareSerial can overflow.
001
String sendCom(String command)
002
{
003
esp8266.println(command);