Is there a simple way to see what version of an app is installed on a device (like a commit hash)?
When I’m deploying an update of my app, I want a simple way to query the devices to see which have the new version and which do not.
Is there a simple way to see what version of an app is installed on a device (like a commit hash)?
When I’m deploying an update of my app, I want a simple way to query the devices to see which have the new version and which do not.
You could use a particle variable that contains a string of the version number. Query the variable to see what firmware it’s running. Just keep advancing the version number each time you compile.
A slightly more sophisticated approach credit to @ninjatill could be to include the following:
// This macro strips the path from the filename
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
char deviceInfo[120]; //adjust size as required
void setup() {
Particle.variable("deviceInfo", deviceInfo);
snprintf(deviceInfo, sizeof(deviceInfo)
,"App: %s, Date: %s, Time: %s, Sysver: %s"
,__FILENAME__
,__DATE__
,__TIME__
,(const char*)System.version());
}
I use the technique @armor recommended and it works very well. I include this in every program I write.
@armor thanks this is great. One question, how are __DATE__
and __TIME__
defined?
Beat me to it! Thanks @ScruffR