it is just a case of parsing char by char until you get what you want.
I have not tested this code, there are bound to be typos and syntax errors. So treat it as pseudo code and work from it as an idea of how it might be done.
It is even easier if you want to use String objects.
so if you know that a text message has come in and is waiting in the serial buffer to be read, you do the following
void extractNumber( char *sendingNumber) {
char d;
uint8_t numDoubleQuotes = 0;
bool foundColon = false;
uint8_t index = 0;
while (Serial.available()) {
d = Serial.read();
if (foundColon) {
if (numDoubleQuotes == 3) {
if (d == '"') return; //we have finished collecting
sendingNumber[index] = d;
sendingNumber[index + 1] = NULL;
index++;
} else {
numDoubleQuotes++;
}
} else {
if (d == ':') foundColon = true;
}
}
}
void extractMessageText(char *textMessage) {
char d;
uint8_t numCommas = 0;
char messageLengthChar[4];
uint8_t messageLength;
bool capturing = false;
uint8_t index = 0;
while (Serial.available()) {
d = Serial.read();
if (!capturing) {
if (d == ',') {
numCommas++;
if (numCommas == 9) capturing = true;
continue;
}
} else { // we are capturing
if (d == '\r') {
messageLength = atoi(messageLengthChar);
}
if (d == '\n') break;
messageLengthChar[index] = d;
messageLengthChar[index + 1] = NULL;
}
}
while (Serial.read()) {
for (index = 0; index < messageLength; index++) {
d = Serial.read();
textMessage[index] = d;
}
}
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
char sendingNumber[15];
char messageText[171];
extractNumber( sendingNumber );
extractMessageText( messageText );
Serial.print(F("The following message was received from: "));
Serial.println(sendingNumber);
Serial.println(messageText);
}
void loop() {
// put your main code here, to run repeatedly:
}
if the text is already in a buffer, then pass a reference to the buffer as a second argument and iterate over the buffer rather than reading from Serial.