Skip to main content
APhuc.1
Associate II
November 18, 2021
Solved

Send AT Command to GSM Module via UART

  • November 18, 2021
  • 4 replies
  • 3087 views

0693W00000GY0gTQAT.pngI am having a problem with this line. When i use sprintf to send command but in this command have "", so this line is error. I want to some advice and solution to this.

Thanks

This topic has been closed for replies.
Best answer by TDK

Double quotes within strings need to be escaped. You need to add a backslash before them.

sprintf(cmd, "AT+QCGDEFCONT=\"IP\",\"v-internert\"\r\n");

4 replies

voyvoda .
Senior
November 18, 2021

try to use below.

sprintf(cmd, "AT+QCGDEFCONT=/"IP/",/"v-internert/"\r\");

APhuc.1
APhuc.1Author
Associate II
November 18, 2021

Thank you very much, i have try this but it seem isn't correct too, this below is error code

0693W00000GY1whQAD.png

TDK
TDKBest answer
November 18, 2021

Double quotes within strings need to be escaped. You need to add a backslash before them.

sprintf(cmd, "AT+QCGDEFCONT=\"IP\",\"v-internert\"\r\n");

"If you feel a post has answered your question, please click ""Accept as Solution""."
APhuc.1
APhuc.1Author
Associate II
November 18, 2021

Thank you very much. I have understanded.