Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Much needed example addition for ATCommands #85

Open
al-davis opened this issue Mar 4, 2020 · 0 comments
Open

Much needed example addition for ATCommands #85

al-davis opened this issue Mar 4, 2020 · 0 comments

Comments

@al-davis
Copy link

al-davis commented Mar 4, 2020

A snipet to show one example of writing commands with variables -- a MUCH NEEDED expansion of the ATCommands example. I hope this saves someone the time I wasted trying to get it to work.

//------------------------------------------------------------
//
// AT Cmd section used in API mode.
//
// This example exhibits Sleep commands but applies to any command that needs to
// pass a parameter.
//
//------------------------------------------------------------

void InitATCmd()
{
atRequest = AtCommandRequest();
atResponse = AtCommandResponse();
}

void SetSleep()
{
uint8_t cmd_p[] = "SP", val_p[] = { 0x01, 0xf4 }; //500 * 10ms = 5 S sleep
uint8_t cmd_n[] = "SN", val_n[] = { 0x01 }; // # of SP's before pin assert /on/sleep
uint8_t cmd_t[] = "ST", val_t[] = { 0x03, 0xe8 }; // * 1ms = 1S wake
uint8_t cmd_o[] = "SO", val_o[] = { 0x01, 0x00 }; // wake for all ST
uint8_t cmd_m[] = "SM", val_m[] = { 0x05 }; // 0 is disable 5 (& others) will sleep 5 sec wake 1s

uint8_t cmd_ac[] = "AC"; // apply above changes

//uint8_t cmd_ss[] = "SS"; // status read
//uint8_t cmd_os[] = "OS"; // status read
//uint8_t cmd_ow[] = "OW"; // status read

atRequest.setCommand(cmd_p); // The AT command
atRequest.setCommandValue(val_p); // The variable
atRequest.setCommandValueLength(sizeof(val_p)); // Number of bytes in the variable
SendATCmd(); // Send params (cmd, value, length of value)
atRequest.clearCommandValue(); // clear the passed params

atRequest.setCommand(cmd_n);
atRequest.setCommandValue(val_n);
atRequest.setCommandValueLength(sizeof(val_n));
SendATCmd();
atRequest.clearCommandValue();

atRequest.setCommand(cmd_t);
atRequest.setCommandValue(val_t);
atRequest.setCommandValueLength(sizeof(val_t));
SendATCmd();
atRequest.clearCommandValue();

atRequest.setCommand(cmd_o);
atRequest.setCommandValue(val_o);
atRequest.setCommandValueLength(sizeof(val_o));
SendATCmd();
atRequest.clearCommandValue();

atRequest.setCommand(cmd_m);
atRequest.setCommandValue(val_m);
atRequest.setCommandValueLength(sizeof(val_m));
SendATCmd();
atRequest.clearCommandValue();

atRequest.setCommand(cmd_ac); // write to actually store vars
SendATCmd();
/*
atRequest.setCommand(cmd_ss); // these seem to display old or maybe default values
SendATCmd();
atRequest.setCommand(cmd_os);
SendATCmd();
atRequest.setCommand(cmd_ow);
SendATCmd();
/
/

atRequest.setCommand(cmd_p); // read what we just put there
SendATCmd();
atRequest.setCommand(cmd_n);
SendATCmd();
atRequest.setCommand(cmd_t);
SendATCmd();
atRequest.setCommand(cmd_o);
SendATCmd();
atRequest.setCommand(cmd_m);
SendATCmd();
*/
}

@al-davis al-davis changed the title Much needed example addition for here Much needed example addition for ATCommands Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant