[SOLVED]Particle.publish() problems

I have code that compiles when logged in as one user in the web IDE but the same code will not compile when logged in as another user in the web IDE. The problem appears to be with Particle.publish(). The line in question reads:

Particle.publish(“telemetry”, pq.buffer, NO_ACK);

The code compiles as written when logged in as one user. However, when logged in as another user, the same code gives the error message:

‘NO_ACK’ was not declared within this scope.

For this second user, if I edit the line eliminating the NO_ACK parameter, so that it reads

Particle.publish(“telemetry”, pq.buffer);

the code compiles.

Why would identical code compile differently for different users?

My guess is it’s because one of the user’s default target device is an Electron, and one is not. The NO_ACK flag is only available on the Electron, so if you build for a Photon or Core, you’ll get a not declared within this scope error.

1 Like

That sounds quite right. How do I change the designation for the user to be Electron?

Select another device is the devices tab.

That’s it!!! Thanks! You rock!

One more question, what is the “Device ID” I need to enter to add a new device? Is that the sim card number?

The device ID is a 24-character long hexadecimal string, but it’s not printed on the package anywhere, as it’s intended to be kept relatively secret. It’s different from the SIM card ICCID.

If you have already configured your device and claimed it to your account, you can use https://build.particle.io, select the Device tab (the circle with the lines, the target icon), then select the device. It will list the device ID.

If you have not set up your device yet, the easiest way to deal with the device ID is to use the Particle CLI, Command Line Interface. It will be useful later on as you use your Photon or Electron, so it’s worth taking the time to set it up.

If you are using Windows, I recommend using the new Windows CLI installer:

For Mac and Linux, follow these instructions instead:

Once you’ve installed the CLI, connect the device by USB to your computer and put the device in Listening Mode if it’s not already blinking blue. Hold down the SETUP button (MODE for Electron) until the status LED blinks blue.

Issue the command:

particle identify

This should list the device ID.

Thank you. I have the CLI running now. I will add the Electron device. I think that should do it. Thanks again!