How to tell what version of an app is installed?


#1

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.


#2

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.


#3

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

#4

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


#5

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


#6

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


#7

Beat me to it! Thanks @ScruffR