I’ve had and programmed Particle Photons (and love them), and now own some of the mesh products.
If I’m using the web IDE, is there a way to know which program was uploaded to a an old Photon? - one that you don’t remember what’s on it and you plug it in to your computer?
Sure, there’s output to look for at the pins or the serial output, but barring that, is the name of the file that was uploaded to it available in memory?
If the answer is no, then I just realized what might be a good “best practice”: upload a string variable containing the filename to the protected memory, and make a program that queries that.
I have used this technique with other platforms outside of Particle.
You can either do something simple like store the name of the source file in EEPROM. Or, if you want, you can add additional metadata, such as:
description
version
date of last modification
I guess it depends on whether or not you’re using EEPROM for other purposes. Perhaps we could, as a community, come up with a “standard” definition of what we want to store about the average program. You could either store it starting at location 0, or if you wanted to be able to use EEPROM for other reasons, perhaps you start writing at a certain offset (this would depend of course, on the size of EEPROM for the give platform).
@peekay123 introduced me to this concept recently of defining a Particle.variable() named “version”. Every time you flash new code, you increment the version number. This gives you a method to verify what version is on the device by querying the variable. It’s as easy as going to console.particle.io, getting into the device page and retrieving the “version” variable. It’s also a simple method to verify the device is online and communicating to the cloud. Works great on Mesh devices and I would imagine Gen 2 devices as well.
@OdorDecoder, I use a Particle.variable to report some details on what is running on a given device:
// This strips the path from the filename
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
char gDeviceInfo[120]; //adjust size as required
void setup() {
Particle.variable("deviceInfo",gDeviceInfo);
snprintf(gDeviceInfo, sizeof(gDeviceInfo)
,"App: %s, Date: %s, Time: %s, Sysver: %s
,__FILENAME__
,__DATE__
,__TIME__
,(const char*)System.version() // cast required for String
);
...
}
This produces, for example, the following string when the variable is queried: App: MarcoPolo.ino, Date: Dec 14 2018, Time: 17:38:07, Sysver: 0.8.0-rc.26