1
\$\begingroup\$

I have a SIM900 GSM/GPRS device, I can send AT commands through HyperTerminal and everything is fine. I can configure GPRS connection through AT commands:

AT+CGATT=1
AT+CIPMUX=0
AT+CSTT="INTERNET","",""
AT+CIICR
AT+CIFSR
AT+CIPSTART="TCP","IP","PORT"

With these configuration I can make it connect my PC (using port forwarding on the home router). I created a TCP server in C# and the server accepted the TCP connection from the device. My question is, is it possible to send AT commands through TCP and execute them ? The server sends AT commands to the device and they are received but as data not commands.

\$\endgroup\$
  • 2
    \$\begingroup\$ It does not seem sensible for a GSM modem to accept AT commands from the network, as that would be a big security issue! You could make something that the modem is wired to receive them as data and send them back into the modem as commands, but probably not in real time as doing so could disrupt the data connection. \$\endgroup\$ – Chris Stratton May 21 '15 at 12:30
  • 1
    \$\begingroup\$ I think that you can do this, just need to process that received TCP packets, extract string and send it via serial port at required baud rate to GSM. \$\endgroup\$ – Lazar May 21 '15 at 12:35
  • \$\begingroup\$ @3bdalla Can you contact me regarding the SIM5320A? Have a similar issue. My contact info in my profile. Thanks. \$\endgroup\$ – Joel Wigton Oct 31 '16 at 22:50
  • \$\begingroup\$ @JoelWigton Sorry Joel, the whole thing was a project for my friend and it is abandoned more than a year ago. \$\endgroup\$ – 3bdalla Nov 1 '16 at 11:43
  • \$\begingroup\$ @3bdalla I had questions on how you tested with your TCP server, which I can't get working. If you're able to help, please contact me. I plan to start a post here but since you've directly done it I thought you might be willing to help me get started. \$\endgroup\$ – Joel Wigton Nov 1 '16 at 16:05
4
\$\begingroup\$

All GSM modems that I know of have two modes: command and data. And that includes the SIM900. The modem starts out in command mode, where it is listening for AT commands, typically over a serial UART connection with a microcontroller.

AT commands are patterned after the Hayes telephone modems of the 1980s and 90s. AT stands for Attention. They are used to both set up the parameters for the connection, and then initiate the connection itself, in the case of the SIM900 this is done with the AT+CIPSTART command. If the connection is successful, the modem responds CONNECT OK and switches to data mode.

At that point a binary data connection is established between the GSM modem and a far-end socket. Bytes can be sent back and forth transparently. The modem can only be changed back into command mode if any one of the three things happen: the +++ escape sequence (patented by Hayes) is sent from the local microcontroller, or the DTR lead is turned off (only if it has been configured to act this way), or the connection is dropped.

Only in the first case (+++ escape sequence) is the connection still held up. However while the modem is in command sequence, it can't "see" the far end anymore.

So what you wanted to do, i.e. send AT commands from the far end and have the modem execute them, is impossible because the modem only listens for commands from its local microcontroller and only when it is in command mode. Even if you were to send AT commands over the link in data mode, the GSM modem would just forward them on to the microcontroller it is attached to.

It would be possible to indirectly execute AT commands from the far end with assistance from the local microcontroller. The far end would send the AT command(s) over the link in data mode, and the local microcontroller would queue them up. The far end would need to have some way to tell the local microcontroller when it was done and should start executing commands. At that time, the microcontroller would send the +++ escape sequence, and then send the queued AT commands. When it was done, it would return to data mode using the ATO command, and perhaps send the results of the commands back to the far end.

\$\endgroup\$
  • \$\begingroup\$ This is the right answer. +1 for DTR pin. \$\endgroup\$ – Joel Wigton Oct 31 '16 at 22:38
1
\$\begingroup\$

Well this is not directly possible.

It is indirectly, but not recommended. You could receive the TCP interfaced AT commands and then resend the to the modem.

This is much work to do, that is not necessary, and it is considered a security hole. It would be better to send "higher-level" commands through TCP, and then the receiver will issue the correct AT commands to the modem.

\$\endgroup\$
  • \$\begingroup\$ What do you mean by "higher-level" commands ? \$\endgroup\$ – 3bdalla May 23 '15 at 6:20
  • \$\begingroup\$ A command like "perform_get('server-name')", that the microcontroller will receive and convert it to the appropriate AT commands on the UART. Also this scheme enhances portability, since only the the microcontroller needs to know how this specific modem works. \$\endgroup\$ – Fotis Panagiotopoulos May 23 '15 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.