What am I doing wrong with Particle.publish()? --> "Particle.publish() will require event scope to be specified explicitly..."

I’ve looked at the example in https://github.com/particle-iot/device-os/pull/1365, but I’m too new to fully understand what needs to change in my code to support the new method.

These publish events are failing - i"ve tried these variations on the publish event, but they all fail to compile and returns the seemingly infamous error:
_"CloudClass::publish(const char*, const char*)’ is deprecated: _
Beginning with 0.8.0 release, Particle.publish() will require event scope to be specified explicitly. Define PARTICLE_USING_DEPRECATED_API macro to avoid this warning."

Here are my examples I’ve tried.
Particle.publish(“StartTime”,String(startTime));
Particle.publish(“StartTime”,String(startTime),60);
Particle.publish(“StartTime”,String(startTime), MY_DEVICES);
Particle.publish(“StartTime”,String(startTime), 60, MY_DEVICES);

All of them fail to compile (I have several of these publish events). I don’t understand what I need to do about “const char* const char*” error messages…this code used to work…would love an explanation about the error and what I can do to fix this.

How about Particle.publish("StartTime", String(startTime), PRIVATE);
this would also line up with the docs :wink:
https://docs.particle.io/reference/device-os/firmware/photon/#particle-publish-

MY_DEVICES would be the scope for Particle.subscribe()

The opposite scope would be PUBLIC for publishing and ALL_DEVICES for subscribing.

3 Likes

Doh, mixed those two up. Thanks!

1 Like