Hi there!
In my code (adapted from a tiny mqtt exemple) there are a byte pointer variable that will receive the content of a mqtt subscription. This subscription will just receive 1 or 0. 1 to tunr a relay on and 0 to turn a relay off.
The problem is that I need to know how to compare this pointer on my code to decide what action need to be done.
I am a begginer in C++ and don't know how to do this comparison.
Can some one help me with this, please?
This is the part of my code that I am talking about:
void mqttCallback(char* topic, byte* message, unsigned int len) {
Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("]: ");
Serial.write(message, len);
Serial.println();
Serial.println();
if (String(topic) == tRoubado) {
if(message[0] == msg[0]) { // declared as unsigned char* msg; at the beginning of my code, it was just an attempt that didn't work
Serial.println("PASSOU PELO IF");
digitalWrite(disparaAlarme, liga);
} else {
Serial.println("PASSOU PELO ELSE");
//Serial.println(msg[0]);
digitalWrite(disparaAlarme, desliga);
}
mqtt.publish(tRoubadoEst, message ? "1" : "0");
}