Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By martinayotte
#54250
ShantanuJ wrote:Is there a way that I can compare the data in (packetBuffer) to perform end device actions?

for eg:
Code: Select allif (packetBuffer == "turnON"){
digitalWrite(Led,HIGH);
}

You need to learn a bit more about C/C++ syntax ... :ugeek:
If packetBuffer is defined as "char packetBuffer[128];" for example, your code will never work because it is comparing pointer, not the actual data.
If packetBuffer is a String, the code will succeed only when that data is a perfect match, but since other characters can be present at the end, such CR+LF, it will also fail.
You need to do a " if (packetBuffer.startWith("turnON") ", again, assuming that packetBuffer is a String.