-->
Page 1 of 1

Sending info to ESP

PostPosted: Wed Jul 15, 2015 9:52 pm
by ac21
When you send info to a ESP what dose the backward slash mean? for instance...
normally one would send

Code: Select allAT+CIPSTART=4,”TCP”,”www.google.com”,80


but when sending from a arduino

Code: Select all     String cmd = "AT+CIPSTART=\"TCP\",\"";
     cmd += DST_IP;
     cmd += "\",80";
     Serial2.println(cmd);

Re: Sending info to ESP

PostPosted: Wed Jul 15, 2015 10:38 pm
by kolban
In C programming, a string is a sequence of characters that are enclosed in double quotes for example:

String myVar = "hello world";

but what if you want your string to include the double quote character?

String myVar = "hello "world"";

will not work as the compiler isn't sure where the boundaries of the string are to be found. However, if you wish to include "special" characters such as the double quote within a string, you can prefix them with a "\" (backslash) character. This tells the compiler that what ever comes next is to be inserted into the string exactly as is. If you need to insert a backslash, simply insert "\\". The use of the backslash is called "escaping".

The following will work:

String myVar="hello \"world\"";

Re: Sending info to ESP

PostPosted: Wed Jul 15, 2015 11:11 pm
by ac21
Ohh i see thank you :D