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.

1 Like

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());
}
6 Likes

I use the technique @armor recommended and it works very well. I include this in every program I write.

1 Like

@armor thanks this is great. One question, how are __DATE__ and __TIME__ defined?

This might help :wink:
https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html

2 Likes

Beat me to it! Thanks @ScruffR

2 Likes