Hi there.
I am having trouble with a partcile.scubscribe event. I have two devices, one that will act as a door controller and temperature monitor publishing events. This one is mostly working fine. The second device is displaying the info sent with Publish events. I am however trying to send triggers back to the first device but the data in the publish is getting mangled some how.
Here is a segment of the code on the first device.
Setup:
Particle.subscribe("DoorControl", doorControl, MY_DEVICES);
Function:
void doorControl(const char *event, const char *data) {
Particle.publish("DEBUG", "Enter DoorControl");
Particle.publish("DEBUG", data);
Serial.println(data);
if (strcmp(data,"Right")==0) {
Particle.publish("DEBUG", "RIGHT");
triggerRight();
} else if (strcmp(data,"Left")==0) {
Particle.publish("DEBUG", "LEFT");
triggerLeft();
}
}
Second device sending code.
if (millis() > testInterval +5000) { // for testing. this will be changed later.
testInterval = millis();
Particle.publish("DoorControl", "Left",60,PRIVATE);
}
And here is an example of what is getting to the first device.
{“data”:")�D��W\u0013.#�-�N�ŷ�",“ttl”:60,“published_at”:“2018-02-03T14:51:54.531Z”,“coreid”:“2a0021000f47353136383631”,“name”:“DEBUG”}
The data changes every time and I suspect it I have messed something up with the pointer.
Can someone help?