Due to having quite a few Particle devices and many different applications under development, I often lose track of what application software is running on each device. I also like to (easily) know what version of system software is running on field devices. I’m usually interested in the application name, the system firmware, the SSID and the RSSI.
In the past, I’ve used several instances of Particle.variable()
to let me be aware of these, but I’m pretty sure I’m wasting bandwidth and using up Particle variables that may be needed in the future. Besides I don’t need to know this ALL the time…just when I need to know!
So, I created a simple function that I can call that can provide me this information. This might make for a handy library so I can easily keep it updated across multiple applications. I guess that’s another day and will be based upon feedback I get from this topic. I’m assuming there’s a much “smarter” way of satisfying this need and someone will enlighten me.
So…here’s what I’ve done:
I create a global variable declared at the top of the program, so it’s readily visible for modification when I create or update an applications:
char gAppName[30] = "myProjectV1.ino";
In setup, I publish the function I created:
Particle.function("deviceInfo",deviceInfo);
…and here’s the function:
int deviceInfo(String command) {
//Publishes info about the device
String fw = System.version();
char SystemFW[20];
fw.toCharArray(SystemFW,15);
char PublishString[200];
sprintf(PublishString,"Application: %s, System firmware: %s, SSID: %s, RSSI: %i",gAppName,SystemFW,WiFi.SSID(),WiFi.RSSI());
Particle.publish("deviceInfo",PublishString,60,PRIVATE);
return 1;
}
I’ll likely create something similar for Electrons (sans SSID and WiFi RSSI, but with…APN?)
Constructive feedback is welcome, as I hope to put this in all my applications moving forward.