Obtaining system status for Photon and Electron

Is there any easy way to grab the system status? I assume there is an enum somewhere that is used to set the LED status; can I grab that somehow and show on an LCD screen rather than relying on the RGB LED?

The published API is the RGB object so you could use the onChange handler to do what you want:

https://docs.particle.io/reference/firmware/photon/#onchange-handler-

It’s a good idea to have another enum and I encourage you to add a github request for that.

There is a also Particle.connected() that you might want to use:

https://docs.particle.io/reference/firmware/photon/#particle-connected-

I almost forgot the system events handler–check this doc too:

https://docs.particle.io/reference/firmware/electron/#system-events

Both great suggestions! I have created a feature request on GitHub. I am trying to implement this using just the system events handler, but it seems there are many system events that aren’t listed in the table. Is there a master list somewhere, or is it best just to go to the source code?

This doc or the source code are your best bets:

https://docs.particle.io/reference/firmware/photon/#system-events-reference

Thanks.

So I tried implementing this same idea by attaching an onChange handler to the RGB LED. as suggested; however, it appears that no matter what, the pattern and color methods of the RGB class always return the same values (RGB_COLOR_WHITE and LED_PATTERN_BLINK) even though the status is clearly changing. Am I wrong in assuming I can just initiate a lookup of the values using the LEDStatus?

So I am not sure I understand your question. The onChange handler take three uint8’s as arguments whereas the LEDStatus uses a packed uint32 so you would need to translate that at a minimum.

Have you looked at the unit test for this interface here:

That might give some insight.

@bko, the RGB.onChange() handler only helps “copying” the color info but deriving the mode of operation of the device from the RGB info would be a rather laborious task.
I think @hagandh would prefer to have a “high level” mode indicator for things like WiFi on, off, connecting, ready, Particle connecting, connected, Listening Mode, Safe Mode, DFU Mode, … as one single state variable instead of having to check for each of the respective states with a dedicated function (if one exists).

Here is the definition of the state enum
https://github.com/particle-iot/firmware/blob/656851a06a0ae659fdb98885218d2256ce5caac4/system/inc/system_led_signal.h#L53

Hi @ScruffR

Totally agree that a higher level abstraction API would be better and I asked @hagandh to create a github issue for that, which he did.

I put the link to the unit test because it does what he wants to do today with the current API, which while not ideal has the benefit of being available now.

3 Likes