Get remote data without broken with modem response - gprs

I am writing an application to deal with SIM900 GPRS and send/receive data to servers in multi connection mode (AT+CIPMUX=1). The problem is when I got data from server, it may get broken by modem response too, and there is no clew how to detect that or avoid that.
The normal procedure to send data (to connection 0) after everything is ready is:
AT+CIPSEND=0
>
GET /index.php?packet=Test HTTP/1.1 \r\n Host:...
+RECEIVE,0,137:
bla bla bla
bla bla bla
bla bla bla
So consider you got modem response between those blas. For example if I send AT+CIPSEND=1 (after the first one) I got the > between data block after +RECEIVE. This is an example, I may get X, CLOSED, Y, CONNECT OK, ...
+RECEIVE,0,137:
bla bla bla
bla bla 1, CONNECT OK
bla bla bla bla
How to get data properly without broken with modem responses?

There is command AT+CIPTXISS that will "Discard input AT data in TCP data mode" (from the SIM900 AT manual). The desc is not very clear for me, but as I tested it is obvious when receiving TCP data, sending any AT command will be discarded although responds such as CONNECT OK or CLOSED will be received but after or before +RECEIVE block thus not interrupting the data block.

Related

Sending data to MyMqttHub through AT Commands

I've been coding a AT client using ESP32 S2 as a host and Nimbelink's Skywire Nano (nrf9160) as a LTE Modem controlled by Serial AT Commands, the LTE module is responsive and is working well. The LTE modem has an internal TCP Stack, which we have used to send data to dweet.io through a HTTP POST with success, but we haven't been successful in doing the same sending data to a private MQTT server.
The LTE module uses a method called Socket Dials, these are AT commands that facilitate sending data to the web, it basically consist in these three commands:
AT#SOCKET to activate the socket
AT#TCPCONN to connect to an URL
Example:
at#xtcpconn=3,"node02.myqtthub.com",1883
AT#TCPSEND which opens a > promt in which you enter whatever you are going to send
I'm not a communication protocols expert, so it has been a bit difficult finding the correct way to send the string since I haven't found similar examples using TCP sockets. I have tried sending mosquitto_pub strings withouy success and nimbelink only has an example using HTTP, I hope some one can help me with this or at least send me in the right direction.
at#xsocket=3,1,1
#XSOCKET: 3,6
OK
at#xtcpconn=3,"node02.myqtthub.com",1883
#XTCPCONN: 1
OK
at#xtcpsend=3
mosquitto_pub -h node02.myqtthub.com -i hub -u user -P 'password' -t topic -m "hello world"#XTCPSEND: 104
OK
SOCK: 3,HUP
Edit: added the LTE log of the attempt

SIM5360A - HTTP bad request

I'm developing a device with an ESP32 connected through a level shifter to a SIM5360A.
The system is supposed to make a periodic HTTP post with it's sensor readings.
Even though I have a working setup with a SIM5360E breakout board, when I shifted to a custom PCB with a SIM5360A (because of carrier frequency), I'm not able of making an HTTP post/get.
Using a server hosted in AWS and doing a TCPDump, I detected that before the GET payload the SIM5360A inserts two spurious characters (0x01 0xF0).
The commands I'm sending to the modem are:
AT+CIPOPEN=0,"TCP","XX.XXX.XXX.XXX",80
AT+CIPSEND=0,39
GET /login HTTP/1.1<CR><LF>
Host: XX.XXX.XXX.XXX:80<CR><LF>
<CR><LF>
<CR><LF>
Using Wireshark to analyze the query on the server side, the data received is:
{0x01} {0xF0} GET ....
Those two characters confuse the apache server (and Wireshark) which doesn't interpret this as a HTTP message driving a 400: Bad Request.
I verified using PostMan that the query is correct. I also use the exact same firmware on my SIM5360E breakout successfully.
Using a scope I verified that the two characters are dumped into the UART channel by the SIM5360A and not by the level shifter or the ESP32.
I wanted to do a firmware upgrade on the SIM5360A but SIMCOM only has the 'E' firmware update available on it's website (just including this consideration for if someone has the firmware update for this version).
Any thoughts?
Thanks in advance
Bests

ESP8266 Wifi P2P with Arduino

I am fairly new to using the ESP8266 and trying to get two of them to connect directly via the wifi generated by the server. For now, I am using two Arduino Unos, one for each wifi module. I am sending the ESP8266 AT commands from the Serial Monitor. I have one ESP8266 dedicated to being a server and the other as a client. My goal is to send a simple message from the client to the server without connecting to any external wifi. Here is the series of AT commands I am using in the Arduino Serial Monitor.
Server code:
INPUT: AT+CWSAP="ESP SSID","ESP PASSWORD",2,3
OUTPUT: OK
INPUT: AT+CWMODE=3
OUTPUT: OK
INPUT: AT+CIPMUX=1
OUTPUT: OK
INPUT: AT+CIPSERVER=1,80
OUTPUT: no change
OK
INPUT: AT+CIFSR
OUTPUT: +CIFSR:APIP,"192.168.4.1"
+CIFSR:APMAC,"2e:3a:e8:20:f9:96"
+CIFSR:STAIP,"0.0.0.0"
+CIFSR:STAMAC,"2c:3a:e8:20:f9:96"
Client Code:
INPUT: AT+CWMODE=3
OUTPUT: OK
INPUT: AT+CJAP="ESP SSID","ESP PASSWORD"
OUTPUT: WIFI CONNECTED
WIFI GOT IP
INPUT: AT+CIPMUX=1
OUTPUT: OK
INPUT: AT+CIPSTART=2,"TCP","192.168.4.1",80
OUTPUT: ERROR
2,CLOSED
I cannot figure out why I am getting this error when trying to start a connection with the server. I am aware of the thread Communication between 2 ESP8266 WiFi modules without router using AT commands but none of these solutions have fixed this error.
I have also swapped the original ESP8266s with 2 new ones, which did not solve the problem. In addition, I have been able to communicate with these wifi modules using a smartphone with a TCP client app, so I don't think any of my hardware is broken. Thank you for any suggestions and help.
After some extreme trial and error, I got the connection to work. After manually setting the IP address of the client using
AT+CIPSTA="192.168.4.2"
the connection could be made using the AT commands above. I guess the client needs to contain the same first three parts of the IP address as the server. I'm not sure if I'm just a noob that should know about this IP address nomenclature, but here is an official answer to help others with the same problem. Good luck!

How to get device information from a remote modbus service?

We need to send a message to a remote modbus service listening on por 502 and get as a response the device information, the same way shodan (https://www.shodan.io) does when you search from an IP address running a modbus service. We have read modbus specifications and tried to build a message but we send it to the server over TCP and it never responds.
For example, the following message should do the trick but does not work for us:
002B0E0104
00: address, not used.
2B: function code for get information
0E: additional function code for get device information
01: read device ID code
04: object ID.
How should we do to build a correct message and get the device information as a response?
There's no requirement that a Modbus device actually supports function code 0x2B.
In my experience it's very uncommon.
I have found that modbus protocol has 2 modes of building messages:
ASCII and RTU. I was using ASCII but it was bad because I have found
that a modbus service over TCP uses RTU mode.
Also, when it is over
TCP, the modbus messages must not have address byte neither error
check byte and I was building the messages with that bytes on it.
The
third thing I was doing bad was that when modbus is over TCP, its
messages must include a 7-byte header at the beginning that I was not
inserting.
All of this is described on:
https://scadahacker.com/library/Documents/ICS_Protocols/Acromag%20-%20Introduction%20to%20Modbus-TCP.pdf
For example, a well formed message (represented in hexadecimal) could be:
000000000005002B0E0106
At least, server is giving me a readable response. The message must be converted from hexadecimal to binary and then inserted into the data section of a TCP packet which will be sent to the server to the 502 port and over an IP packet which will contain the IP to the server.
Linux nc command lets you to send messages inside of TCP packets so you don't have to deal with the OSI layers.
My problem was that the messages I was sending to the server were not meeting the modbus/TCP protocol rules.

CMS Error 518 while sending messages using AT Commands

I have connected a gsm modem to my computer. I am trying to read sms from gsm modem and send sms to other mobile numbers using AT commands. When I type
at+cmgl ="all"
It lists all the messages from SIM card. But the messages displyed in hyper terminal are like this..
+CMGL: 1,"REC READ","004C004D002D00560065006E005300650063",,"11/12/15,16:10:04+2
2"
0041007400200063006C006F00730065002C002000530065006E0073006500780020003100350038
003300360028002D003400350029002C0020004E0069006600740079002000340037003400360028
002D0031003700290020006C006500640020006200790020006D006500740061006C007300200028
0053007400650072006C006900740065002D00340025002900200026002000630061007000200067
006F006F0064007300200028004200480045004C002D003300250029002E0020004500750072006F
007000650061006E0020006D006B00740073002000740072006100640069006E0067002B00760065
002E00200044006F00770020006600750074002B0037002E002000560045004E0054005500520041
+CMGL: 2,"REC READ","00540041002D0049004E004E005300450054",,"12/03/24,20:32:04+2
2"
00480069002100200059006F00750072002000640065007600690063006500200073007500700070
006F0072007400730020004D004D0053002C005400410054004100200044006F0063006F006D006F
0020004400690076006500200049006E00200061006E006400200047005000520053002E00530061
0076006500200066007200650065002000730065007400740069006E0067007300200079006F0075
0020006100720065002000610062006F0075007400200074006F0020007200650063006500690076
006500200061006E006400200065006E006A006F00790020006F00750072002000560061006C0075
0065002000410064006400650064002000730065007200760069006300650073
While the messages in sim cad are in simple text format. How can I see the messages from sim card in text format in Hyper terminal?
Also when I try to send the message from hyper terminal using command
at+cmgs="phone number"
It gives me error saying
+CMS ERROR: 518
Can Anybody tell me what's the problem?
Note: I have set sms service centre no.
Seems your message format is not set to Text format and is likely in PDU mode. You should give AT+CMGF=1 to set to text format.
Also you are getting +CMS ERROR: 518 means that your storage type is invalid. Set your storage appropriately

Resources