String tokens and associated string

I am adding a function to MRMP to periodically poll for new records from the bridge controller and send an email for selected records using xPort.

I send… Ig1v#Rg1vR2,970,48#

A typical record reply like this…
R1gvR,970,48,5,77,0,0,1239762623,65#

Using the limited RAM and string functions in stdlib.h I am trying to parse the string and associate the tokens (77) with expanded strings that mean something to the reader of the email message.

For example, the token “77” (ASCII ‘S’) means “Stopped”

So I am trying various methods to create a function that takes the token and returns the address of the associated string.

I have spent many hours Googlng for examples, with some success.

Is there a better, smaller more efficient way to accomplish this?
I also would like to pass the address of the array and walk it by index. So far I haven’t solved that syntax.

#include <stdlib.h>      

char stData[64] = "970,0,5,97,1,2,-1234567890,151";  // Testing

// Token $ Expanded string Null Token $ Expanded string Null Token $ Expanded string Null
char* stControllerTokens[] = {
  "2", "s$Slave", "g$Garage\0b$House", "p$Pond"};
char* stAlarmTokens[] = {
  "7", "A$Triggered", "H$Horn sounding", "S$Stopped", "O$Delay entry", "I$Instant", "M$Maintenance", "C$Close"};
char* stAlarmLoopTokens[] = {
  "7", "2$Instant-Windows", "3$Always-Glass", "4$Delay-Door", "5$Interior", "6$Button-Press", "7$Motion" "11$Set", "15$Heat-Fire\0"};
char stUnknown[] = "Unknown";


char *parmAdd=0;      // Parameter address pointer
char *nextParmAdd=0;  // Next parameter address
long parameterLond=0;
int chkSum=0; // Checksum is last parameter


/* Sources is a two dimentional array of strings.
 Format...
 Token$Expanded string\0      Token$Expanded string\0        Token$Expanded string\0
 
 Token is 1 or more characters ending with '

If you woul like to learn more about MRMP…
http://www.mmcs.com/~gmatthews/FAV1-00012D85/S00050299-00050299
following which is the null terminated expanded string.
parmAdd is the Address of the expanded string.
*/

char* findStrAlarmLoop(const char *find)   // Pointer address, parameter string delimiter
{
 int e;

e = atoi(stAlarmTokens[0]);  // 0th element holds number of tokens

for (int i = 1; i <= e; i++)
 {
   parmAdd=(strstr(stAlarmTokens[i],find));
if(parmAdd)
{
 return parmAdd+strlen(find);
 
}
 
 }
}

void setup()  
{
 Serial.begin(9600);
}

void loop()                    
{

Serial.print(findStrAlarmLoop(“S$”));
 delay(200);
}


If you woul like to learn more about MRMP...
http://www.mmcs.com/~gmatthews/FAV1-00012D85/S00050299-00050299