Particle.publish("spark/device/name") don't work?

I need to get device name, but Particle.publish(“spark/device/name”) don’t work.
on the other hand Particle.publish(“spark/device/ip”) worked.
Please help!

int DEBUG = 1;

char deviceName[64];

void handler(const char *topic, const char *data) {
  Serial.printlnf("%s: %s", topic, data);
  if (strstr(topic, "spark/device/name"))
      strcpy(deviceName, data);
      Serial.printlnf("deviceName = %s", deviceName);
      Serial.printlnf("data = %s", data);

  if (strstr(topic, "spark/device/ip"))
      Serial.printlnf("data = %s", data);

void setup() {
  if (DEBUG) {
  for(int i=0;i<5;i++) {
      Serial.println("waiting... " + String(5 - i));

    Particle.subscribe("spark/", handler);


I am not sure why it’s not working for you. I ran that code and the device name and IP address were both printed properly. Tested with a Photon running 0.4.9.

rickkas7 Thank you for reply!
I do not know. I tried many times at several ways. but don’t work.
It causes by different version?
I am using Electron 3G-U270 System version 0.4.8-rc.6

It doesn’t return a device name for me on an Electron running 0.4.8 (or 0.5.0-rc2) either. I am not sure why this is.

I’m in trouble :pensive: .Thank you very much. I will continue to investigate.

I’m not sure and haven’t tested, but could you add a delay(2000) between the two publishes?

Confirmed - I’ve investigated and filed a bug internally.

Thank You! I hope that a bug is imroved early.