Sending AT commands via switch case in Arduino

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












Is this the proper use for switch case? I am looking to make a simple utility for reporting back Wireless AP info, Baud Rate, and Mode of a ESP8266 module.



When the program loads it gives the user a small menu of option and based on the input of the user (1,2 or 3) it will run the associated AT command stored as a variable in the code.



Will this work as is? Or am I missing something to send the command and get the data back?



void loop() 

if (Serial.available() > 0)
input = Serial.read();
Serial.flush();

switch (input)
case '1':
Serial.println(baud);
break;

case '2':
Serial.println(wap);
break;

case '3':
Serial.println(amode);
break;

default:
Serial.print("'");
Serial.print((char)input);
Serial.println("' is not a command!");





The baud, wap, and amode commands are setup as follows:



const char* wap = "AT+CWLAP";
const char* baud = "AT+CIOBAUD";
const char* amode = "AT+CWMODE";






share|improve this question





















  • I am stuck. The code works to send the commands to the serial monitor but it's not returning the information it should. It just shows the command.
    – Das Nuk
    Mar 5 at 22:12










  • I can post my full code if that would help.
    – Das Nuk
    Mar 5 at 23:29
















up vote
1
down vote

favorite












Is this the proper use for switch case? I am looking to make a simple utility for reporting back Wireless AP info, Baud Rate, and Mode of a ESP8266 module.



When the program loads it gives the user a small menu of option and based on the input of the user (1,2 or 3) it will run the associated AT command stored as a variable in the code.



Will this work as is? Or am I missing something to send the command and get the data back?



void loop() 

if (Serial.available() > 0)
input = Serial.read();
Serial.flush();

switch (input)
case '1':
Serial.println(baud);
break;

case '2':
Serial.println(wap);
break;

case '3':
Serial.println(amode);
break;

default:
Serial.print("'");
Serial.print((char)input);
Serial.println("' is not a command!");





The baud, wap, and amode commands are setup as follows:



const char* wap = "AT+CWLAP";
const char* baud = "AT+CIOBAUD";
const char* amode = "AT+CWMODE";






share|improve this question





















  • I am stuck. The code works to send the commands to the serial monitor but it's not returning the information it should. It just shows the command.
    – Das Nuk
    Mar 5 at 22:12










  • I can post my full code if that would help.
    – Das Nuk
    Mar 5 at 23:29












up vote
1
down vote

favorite









up vote
1
down vote

favorite











Is this the proper use for switch case? I am looking to make a simple utility for reporting back Wireless AP info, Baud Rate, and Mode of a ESP8266 module.



When the program loads it gives the user a small menu of option and based on the input of the user (1,2 or 3) it will run the associated AT command stored as a variable in the code.



Will this work as is? Or am I missing something to send the command and get the data back?



void loop() 

if (Serial.available() > 0)
input = Serial.read();
Serial.flush();

switch (input)
case '1':
Serial.println(baud);
break;

case '2':
Serial.println(wap);
break;

case '3':
Serial.println(amode);
break;

default:
Serial.print("'");
Serial.print((char)input);
Serial.println("' is not a command!");





The baud, wap, and amode commands are setup as follows:



const char* wap = "AT+CWLAP";
const char* baud = "AT+CIOBAUD";
const char* amode = "AT+CWMODE";






share|improve this question













Is this the proper use for switch case? I am looking to make a simple utility for reporting back Wireless AP info, Baud Rate, and Mode of a ESP8266 module.



When the program loads it gives the user a small menu of option and based on the input of the user (1,2 or 3) it will run the associated AT command stored as a variable in the code.



Will this work as is? Or am I missing something to send the command and get the data back?



void loop() 

if (Serial.available() > 0)
input = Serial.read();
Serial.flush();

switch (input)
case '1':
Serial.println(baud);
break;

case '2':
Serial.println(wap);
break;

case '3':
Serial.println(amode);
break;

default:
Serial.print("'");
Serial.print((char)input);
Serial.println("' is not a command!");





The baud, wap, and amode commands are setup as follows:



const char* wap = "AT+CWLAP";
const char* baud = "AT+CIOBAUD";
const char* amode = "AT+CWMODE";








share|improve this question












share|improve this question




share|improve this question








edited Mar 2 at 1:56









200_success

123k14142399




123k14142399









asked Mar 2 at 0:38









Das Nuk

235




235











  • I am stuck. The code works to send the commands to the serial monitor but it's not returning the information it should. It just shows the command.
    – Das Nuk
    Mar 5 at 22:12










  • I can post my full code if that would help.
    – Das Nuk
    Mar 5 at 23:29
















  • I am stuck. The code works to send the commands to the serial monitor but it's not returning the information it should. It just shows the command.
    – Das Nuk
    Mar 5 at 22:12










  • I can post my full code if that would help.
    – Das Nuk
    Mar 5 at 23:29















I am stuck. The code works to send the commands to the serial monitor but it's not returning the information it should. It just shows the command.
– Das Nuk
Mar 5 at 22:12




I am stuck. The code works to send the commands to the serial monitor but it's not returning the information it should. It just shows the command.
– Das Nuk
Mar 5 at 22:12












I can post my full code if that would help.
– Das Nuk
Mar 5 at 23:29




I can post my full code if that would help.
– Das Nuk
Mar 5 at 23:29















active

oldest

votes











Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
);
);
, "mathjax-editing");

StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "196"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f188647%2fsending-at-commands-via-switch-case-in-arduino%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f188647%2fsending-at-commands-via-switch-case-in-arduino%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Greedy Best First Search implementation in Rust

Function to Return a JSON Like Objects Using VBA Collections and Arrays

C++11 CLH Lock Implementation