To do the self subscribe test, I modified the test case sketch as follows:
unsigned old_time=0;
void handler(const char *event,const char *data) {
Serial.print("Event: ");
Serial.print(event);
Serial.print(", Data: ");
Serial.println(data);
}
void setup() {
Serial.begin(115200);
Serial.println("Begin");
Particle.subscribe("test",handler);
}
void loop() {
if(millis()-old_time > 2000) {
Serial.println(Particle.publish("test","my-test-msg",60,PRIVATE));
old_time = millis();
}
}
This is the output I get:
Begin
1
1
1
1
1
Event: testDevice,1,3Phase,testMotor,Chicago,TCV,0.1.0, Data: 90,1.2,1.3,1.4,0.01,0.02
1
1
1
1
1
1
1
1
Event: testDevice,1,3Phase,testMotor,Chicago,TCV,0.1.0, Data: 90,1.2,1.3,1.4,0.01,0.02
1
1
(As before, this repeats infinitely as expected, one line every 2 secs).
That event is not mine. If you look at the public firehose (e.g. with particle subscribe test
), you’ll see it every 16-17 s. So, my device picking up events from other people’s devices, just not any of mine.
Just to rule out any issues with public vs. private events, I tried listening only for events from my devices with:
Particle.subscribe("test",handler,MY_DEVICES);
The only effect this had was to exclude the testDevice events. I also tried making the event I’m publishing public by changing the Particle.publish()
line as follows:
Particle.publish("test","my-test-msg")
This had no effect, no matter whether I was listening for events from all devices or my devices only.