There seems to be a bug with storing the device name. I followed the docs https://docs.particle.io/reference/firmware/photon/#get-device-name and all seemed to work well. However, when I go to store the data into a string so that I can use it later something goes wrong.
String unitName;
void handler(const char *topic, const char *data) {
Particle.publish("dName","received " + String(topic) + ": " + String(data),PRIVATE); // Might cause a bug with storing the name.
unitName = String(data);
Particle.publish("uName",unitName,PRIVATE);
}
The above code results in.
However, if I save the name before publishing it. All is well
String unitName;
void handler(const char *topic, const char *data) {
unitName = String(data);
Particle.publish("dName","received " + String(topic) + ": " + String(data), PRIVATE); // Might cause a bug with storing the name.
Particle.publish("uName", unitName, PRIVATE);
}
Is this a bug or am I misunderstanding something about the Particle.publish() function?