-->
Page 1 of 2

ESP-01 Function call - parsing AT commands issue

PostPosted: Sat Jan 21, 2017 7:19 am
by mike_cymru
Hi
I have an issue with parsing AT commands which are passed to a declared function 'sendData' when the AT command argument passed includes strings. For example, when setting an Soft Access point, the password and SSID are both strings within the AT command. The function declaration (part) is:

Code: Select allString sendData(String command, const int timeout, boolean debug)


The arguments passed are (for example):
Code: Select allsendData("AT+CWSAP=2,"CG_BRST", "12345678",1,3", 100,1);


Clearly I think there will be issues with the double quotation characters bounding the command argument and indeed this gives rise to an 'ESP' error response which suggests parsing is necessary. Incidentally, I can successfully implement and verify this command using SimpleTermGold and an FTDI cable so can eliminate hardware issues when issuing this and other AT commands.
In anticipation, hope someone can shed light on this problem.
Many thanks.

Re: ESP-01 Function call - parsing AT commands issue

PostPosted: Sat Jan 21, 2017 9:21 am
by martinayotte
You need to escape the double-quotes inside :
Code: Select allsendData("AT+CWSAP=2,\"CG_BRST\", \"12345678\",1,3", 100,1);

Re: ESP-01 Function call - parsing AT commands issue

PostPosted: Sat Jan 21, 2017 11:06 am
by mike_cymru
Thanks for your prompt reply. I applied the escape characters as suggested but get an 'Error' response from the ESP. Close inspection shows a space is inserted after the ',' delimiter between the SSID and Password arguments in the echoed commands: ...."CG_BRST_AP", "burstner"....displayed in the Arduino Serial Monitor. (yes I have changed the arguments from the initial post).

Using the SimpleTermGold FTDI application I can replicate this error with the ESP if indeed a single space is introduced at this point; if removed, no issue with the command. The Arduino code modified as per your suggestion is (clearly no space characters) :

Code: Select all  sendData("AT+CWSAP=2,\"CG_BRST_AP\", \"burstner\",1,3\r\n", 1000,1);


Can you suggest why the syntax of the echoed command is slightly different, producing thiserror?
Many thanks again.

Re: ESP-01 Function call - parsing AT commands issue

PostPosted: Sat Jan 21, 2017 1:55 pm
by martinayotte
Did you remove the space character (it is actually present in the above code) ?
For AT specific issues, I'm not expert about AT commands, I simply hate them and never use them.