Exposed function not showing up on Photon

I have an old Photon running 0.6.1. All of a sudden exposed functions are not showing up and I cant make any function call but still got online and receviing published events.

reseting it once in a while exposed functions showed up. Any suggestions? Or would it be that the hardware is going bad?

I think this is the same thing that we reported in this post. I finally got mine to show up after re-flashing it at least 20 times. So far, nobody has responded to that post. @KyleG, who should we ping at Particle to look into this?

1 Like

@Ric, thanks for the reply. I flashed it 3 or 4 times but did not help. However, I left it running for a while and now all of the sudden they showed up. Looks very intermittent and random.

I do not have this issue on my newer Photons. At lease not yet. I also noticed that this older one looses connection often as well. It is in good wifi coverage.

Yeah, mine is too, but I don't think I've seen it in a Photon that's been running for months until I flash an update to the code. So it seems that it happens right after flashing (some of the time). I haven't tried just letting it run to see if they spontaneously come back. I'll try that the next time it happens. My Photons are all of a similar age, so I can't corroborate your observation regarding new vs. old devices.

What does your setup function look like?

1 Like

Mine looks like the following. This code has been running fine for months, but when I added the waitFor() statement, and re-flashed, my function and variables disappeared. The code was still running (data sent to Ubidots), and the problem did not go away when I commented out the waitFor() statement. The problem eventually went away after many re-flashes. It is now back to normal, with the waitFor() statement included. Adding that one line was the only change I made, but I think that the firmware might have been updated to 0.6.1 also.


SYSTEM_THREAD(ENABLED);

void setup() {
	waitFor(Time.isValid, 600000); // wait up to 10 minutes for Wi-Fi router to come back online after power failure
	setZone(); // sets time zone to Pacific Daylight Time or Pacific Standard Time depending on the date
    request.hostname = "things.ubidots.com";
    request.port = 80;

    pinMode(dataPin, INPUT_PULLUP);

    pinMode(onesBit, OUTPUT);
    pinMode(twosBit, OUTPUT);
    pinMode(foursBit, OUTPUT);
    pinMode(eightsBit, OUTPUT);

    pinMode(chipInh0,OUTPUT);
    pinMode(chipInh1,OUTPUT);
    pinMode(chipInh2,OUTPUT);

    Particle.function("getRSSI", getRSSI);
    Particle.variable("gallonsDown", gallonsDown);
    Particle.variable("values", valuesString);

	fiveSecs.begin(); // nothing here other than start = millis() for a millis-like timer object
}

The problem may be that

void setup() {
  waitFor(Time.isValid, 600000); // wait up to 10 minutes for Wi-Fi router to come back online after power failure
 ...
  Particle.function("getRSSI", getRSSI);
  Particle.variable("gallonsDown", gallonsDown);
  Particle.variable("values", valuesString);
}

You should put that Particle.function() / Particle.variable() (and for the same reason Particle.subscribe()) block to the top of setup().

If the waitFor() (or anything else) takes more than 5sec after cloud connection you might miss the registration window after connect.

1 Like

In my case I am using the same old code has been running very stable for close to a year. I also have simple setup like this:

void setup(){
registerFunction();
}

void registerFunction(){
particle.function(…X…,hello);
}

Took me days to find this 5 Sec. gotcha!

1 Like