This is a very peculiar one and I'm having trouble fully isolating the cause of the issue. It could be many things at this point, but after hours of trial and error I thing I've narrowed it down, although I don't really know why this is an issue.
Here's what I've got.... Adafruit CC3000 REST API passing params from the URL to custom functions to control RGB LEDs.
here's 2 example calls...
Set the LED to yellow: http://###.###.###.###/setRGB?params=255,255,0
Fade the LED to Cyan over 5secs http://###.###.###.###/fadeRGB?params=0,255,255,5000
The adafruit lib works like this... To access a function defined in your sketch, you have to declare it first, and then call it from with a REST call. Note that all functions needs to take a String as the unique argument (for parameters to be passed to the function) and return an integer.
So I wrote a universal function to split a string of comma separated integer values into an array of long ints to use from within my different functions. Here it is:
void splitCommand(String command, long *vals, byte len) {
int i = 0;
int j = 0;
int inChar;
String inString;
do {
inChar = command[i];
if (isDigit(inChar)) {
inString += (char)inChar;
} else if (inChar == 44) {
vals[j] = inString.toInt();
inString = "";
j++;
}
i++;
} while(inChar > 0 && i < 255 && j < len);
if(j < len) vals[j] = inString.toInt();
}
So in my function for setRGB I use it like this...
int setRGB(String command) {
long vals[3];
splitCommand(command, vals, 3);
red = vals[0];
green = vals[1];
blue = vals[2];
//do some stuff...
for now splitCommand() is used in 2 functions setRGB() and fadeRGB() but I will be writing lots more functions. I have found if I only declare one of these functions in the REST api everything works. If I declare both functions as REST calls I get strange results. Mostly random resets but also sometimes the functions just arn't available via the REST api. If I just pick one of the 2 RGB functions and only declare that everything works great. If I add another function it also works fine as long as it doesn't make use of the splitCommand() function.
Does anyone have any ideas, I'm totally open to a differnt solution for splitCommand() I just need to turn the string of params into ints that can be accessed by different functions.