How to tell what version of an app is installed?


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"
        ,(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?


This might help :wink:


Beat me to it! Thanks @ScruffR