You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 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_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();
*/
}
The text was updated successfully, but these errors were encountered:
al-davis
changed the title
Much needed example addition for here
Much needed example addition for ATCommands
Mar 5, 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();
*/
}
The text was updated successfully, but these errors were encountered: