How to convert from byte to string array.
I am using mqtt to send the message (data array) from raspberry pi to esp8266. This is how esp8266 receive. So I need help to receive the array. I try to convert but it's still error.
Here is a part in my code:
String abc, dfs, rer, fdfs;
String Data[ ]={abc, dfs, rer, fdfs};
void callback(String topic, byte* message , unsigned int length) {
Serial.print("Message arrived on topic: ");
Serial.print(topic);
Serial.print(". Message: ");
String messageTemp;
for (int i = 0; i < length; i++) {
Serial.print((char)message[i]);
messageTemp += (char)message[i];
}
Serial.println();
topic == "submit
if messageTemp == Data){
Serial.print( abc );
}
}
Not really sure what you are trying to do but this sketch works
BUT it assumes that in the callback the argument byte* message
is '\0' terminated.
What library are you using for the MQTT?
You need to check the library code to see if the byte* message is '\0' terminated