Electrical – Testing a connection to a TCP socket through SIM5320A cellular module

at commandssockettcp/ip

I'm using a SIMCOM 5320A module like this one to try to establish a TCP connection.

Adafruit's SIMCOM5320A instantiation.

I'm going through SIMCOM's application note on TCP/IP as a reference.

The AT commands I'm using may very well be working, but I'm not sure the best way to verify this. I later plan to build atop this TCP connection to add a MQTT protocol connection to Amazon's AWS servers for IoT. But I like to do smaller "unit-testing" and build my way up, so that when I get to the MQTT and it's not working, I know that my TCP foundation it's built on is not the issue.

I believe my preliminary steps to this are working fine (registering to GPRS, connecting via APN, establishing PDP context, open network connection, open TCP socket). At least, they seem to be giving me the expected AT command return values indicating they're OK. It's from that point on where I have my doubts.

Currently what I'm doing is ust connecting to a web server (happen to be using Adafruit's IP address) and I send a simple message, like:

AT+CIPSEND=0,5   // send 5 chars to link 0
> HELLO
OK

When I send the command to see sent/received, it reports 5 chars were sent, 0 received. I don't think the Adafruit server is configured to do anything in response to my sent data, like I am not doing an HTTP GET request or anything, so it does nothing. So again, it might be working, but I don't know.

I thought the best way to test this might be an echo server. I poked around for quite some time trying to find free online echo servers I could try to connect to, who whould just send back my "HELLO" ever so politely. There is a whole UNIX protocol for this, but it looks like it's been obsoleted.

I then tried to set up a local echo server on my PC and connect into that. I think I set it up right, because when I ran both a server and also a client (on the same machine, connected to localhost IP address), I got echoes in both terminals. But when I tried to connect to it from my SIMCOM module, I couldn't establish any connection. I messed around with firewall settings forever, and probably opened up every port to hackers in the process, but no dice.

I'm a bit out of my expertise with this internets stuff (more of a circuits/embedded guy), so I'm hoping someone can help point me in the right direction.

Finally, there are two similar questions to this on Stack Exchange, but I'm having trouble reaching those guys to see how they had configured their testing.

Is it possible to send AT commands through TCP?
How do I send data over TCP from a SIM5320A?

Essentially, I just want to connect to a TCP socket in transparent mode (vs. data mode), send some data one way, and read some data back successfully, then close the connection. Any help greatly appreciated.

Best Answer

About the easiest way to get a response from a server is to do a HEAD request.

For example, open a socket to www.stackexchange.com port 80

Then send:

HEAD /about HTTP/1.1
Host: www.stackexchange.com
(blank line)

You should get a response back, but just the headers, not the whole page.

Something like:

HTTP/1.1 200 OK
Date: Tue, 31 Oct 2016 22:44:11 GMT
Server: Apache

etc.

I have used this just to get the current time off the network.