I want to extract the last three characters of a Particle device's 24-character serial number using the substr tool. I am sure the process is very simple but I have been banging my head against the wall all day and can't get it to work. I repeatedly get the error "'class String' has no member named 'substr'"
. Can a firmware genius show me how?
The substr function is a standard C library function, which is available, but is not a method of String. Instead use:
myID = longID.substring(22);
See: substring() - String class | Reference | Particle
I'd also move the initialization of the variables from the declaration of the global variable into setup(). C++ global initialization time can have unexpected restrictions and random order of initialization so doing it from setup is far safer.
That did it!! As always Rick, you've been a terrific resource. It was simple yet obscure to me.