Here is an example to split your character array into parts using the strtok() function.. The for loop using the strtok() function returns an array of pointers to the pieces of the original array. The the hours, minutes, seconds, day, month and year are pulled from piece [1] and [10] using pointer arithmetic and the memcpy() function. Maybe a easier or more elegant way to do it, but here is my take.
char array[] = "+QGPSLOC: 184241.0,51.53045,5.99622,1.9,11.0,2,97.49,0.0,0.0,111120,04";
char *strings[16]; // an array of pointers to the pieces of the above array after strtok()
char *ptr = NULL;
void setup()
{
Serial.begin(9600);
//Serial.print(array);
byte index = 0;
ptr = strtok(array, " ,"); // delimiters space and comma
while (ptr != NULL)
{
strings[index] = ptr;
index++;
ptr = strtok(NULL, ",");
}
//Serial.println(index);
// print all the parts
Serial.println("The pieces, separated by strtok()");
for (int n = 0; n < index; n++)
{
Serial.print(n);
Serial.print(" ");
Serial.println(strings[n]);
}
// get hours, minutes, seconds, day, month and year from piece [1] and [10].
Serial.println();
Serial.println("data separated from piece [1] and piece [10]");
// hours 2 characters + null
char h[] = {'0','0','\0'};
memcpy(h, strings[1], 2); // characters 0 and 1
int _h = atoi(h);
Serial.print(" _h = ");
Serial.println(_h);
// minutes
char m[] = {'0','0','\0'};
memcpy(m, strings[1] + 2, 2); // characters 2 and 3
int _m = atoi(m);
Serial.print(" _m = ");
Serial.println(_m);
// seconds
char s[] = {'0','0','\0'};
memcpy(s, strings[1] + 4, 2); // characters 4 and 5
int _s = atoi(s);
Serial.print(" _s = ");
Serial.println(_s);
// day
char da[] = {'0','0','\0'};
memcpy(da, strings[10], 2);
int _da = atoi(da);
Serial.print("\n _da = ");
Serial.println(_da);
// month
char mo[] = {'0','0','\0'};
memcpy(mo, strings[10] + 2, 2);
int _mo = atoi(mo);
Serial.print(" _mo = ");
Serial.println(_mo);
// year
char yr[] = {'0','0','\0'};
memcpy(yr, strings[10] + 4, 2);
int _yr = atoi(yr);
Serial.print(" _yr = ");
Serial.println(_yr);
}
void loop()
{
// step away, nothing to see here.
}
Output:
The pieces, separated by strtok()
0 +QGPSLOC:
1 184241.0
2 51.53045
3 5.99622
4 1.9
5 11.0
6 2
7 97.49
8 0.0
9 0.0
10 110520
11 04
data separated from piece [1] and piece [10]
_h = 18
_m = 42
_s = 41
_da = 11
_mo = 11
_yr = 20