Home/Support/Support Forum/AT_CMD_LOCAL - Will not return AT command result to main

AT_CMD_LOCAL - Will not return AT command result to main

0 votes
I am playing with the sample program at_cmd_local and cannot figure out how to capture an AT command result. I call the AT command but no matter what I try I cannot capture the result, its stored in the response->value_bytes array in the function called command_dump. Could someone explain how I could do something equivalent to:

Temperature = response->value_bytes;
Temperature = get_atcmd_value("TP");

The problem isn't setting up pointers or a global variable to capture the result, the issue is that main does not wait for get_atcmd_value("TP"); to finish, it continues on meaning I don't have a temperature value to use in the rest of Main.

Thank you for any help,
asked Oct 1, 2016 in XBee Programmable Development by squarej New to the Community (11 points)
edited Oct 1, 2016 by squarej

Please log in or register to answer this question.

1 Answer

0 votes
I could not figure out how to capture the AT result in MAIN so I had to place code within the command_dump function. I am no C coder so pardon the possibly poor code, but it works.

//Sends Temperature info
if ( strncmp(response->command.str, "TP", 2) == 0 )
memset(SendBuffer, 0, 100 * sizeof(SendBuffer[0]));
printf("\nAT Read: %s = %d\n", response->command.str, response->value_bytes[1] );
strcat(SendBuffer, "Temperature:");
sprintf(IntegerString, "%d", response->value_bytes[1]);
//sprintf(IntegerString, "%02x", response->value_bytes[1]);
strcat(SendBuffer, IntegerString);
env.payload = SendBuffer;
//printf("AT env.payload: %02x\n", env.payload );
env.length = strlen(SendBuffer);
//printf("AT env.length: %i\n\n", env.length );

//Sends data
answered Oct 2, 2016 by squarej New to the Community (11 points)