SIM5360A - HTTP bad request - http

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

Related

ESP-NOW with HTTPClient Request Returning Status Code -1

I'm building a project where I use 2 ESP8266 and 1 ESP32 devices, where I collect data with sensors on ESP8266's and send those gathered data to ESP32. Then, this ESP32 device sends an HTTP request (w/ HTTPClient) to my NodeJS Web Server, with the data received, which will eventually be processed there and saved to the database.
I'm having a problem though; when I use some mock data, and use only ESP32 without ESP-NOW and any other connection with other devices, I get status code 200, which indicates that my HTTP Request is sent succesfully. And when I use ESP-NOW to establish conenction between ESP devices, and not send any HTTP Request, I can successfully send and receive data.
However, when I use ESP-NOW to send and receive data, and send the data using HTTPClient request to my Web server on ESP32, I get status code -1 (refused connection). I couldn't find any other issues regarding this topic, so I figured I might ask for some help.
I have also used painlessmesh library to send/receive data between ESP devices, but that gave me the same exact issue. I'm using Wifi mode STA on my ESP32 device, which I connect it to my router to connect to the internet.
Thanks in advance for any help and support.
You cannot use ESP-NOW and WiFi in parallel at the same time; it's either-or. Exception: if you use the same channel for both (may not be possible)!
Option 1
You can alternate between the two protocols. So, as soon as the ESP-NOW transmissions from node 1 has completed (data fully received) you turn off ESP-NOW, connect to WiFi, publish via MQTT and then reverse. Needless to say that while your ESP32 is on WiFi you cannot receive data via ESP-NOW from either node 1 or node 2.
Option 2
Use some sort of gateway between ESP-NOW and WiFi. This product for example contains two ESP32 (connected over UART), one for ESP-NOW, one for WiFi: https://thingpulse.com/product/espgateway/. Disclaimer: I am a ThingPulse co-founder.
It is possible to run a web server and esp_now in the same esp32. Check my code here https://github.com/Servayejc/esp_now_web_server for the server
https://github.com/Servayejc/esp_now_web_server for the sender
This code make also automatic pairing of the nodes of esp_now.
This code is based on randomnerdtutorial…

Arduino & ESP8266 - strange characters in response

I'm working on an Arduino Uno + ESP8266 project.
I try to use them as a web server on Wi-Fi network to control a motor that connects to Arduino - basically a trigger system that receives signals via Wi-Fi. Currently, I've successfully connected ESP8266 to my access point by sending AT commands from Arduino. Another client on the same network can statically access ESP8266's assigned IP address.
However, when I try to catch some HTTP queries (I want to use them as conditions to control the motor) I occasionally encountered the non-ASCII characters in HTTP request. I use serial comm to debug, please look at the screenshot in the link below:
Arduino - Computer serial communication for debugging
The line ",519:POST ..." should contain a complete number following "/?", but there's some strange characters instead. So I cannot determine the input data to control motor. Once in a blue moon, the expected format of request shows up as follows:
The correct data received
There's no issue with the HTTP response part, even though I got the uninterpretable request, I can still send the JSON error message back to client.
Attempt Note:
The Arduino uses different serial ports to talk to computer and ESP8266. Since the connection can be established, and the data being sent, I believe that the baud rate is simply correct on both side. (115200 for ESP8266, 9600 for computer - also tried 115200 for both and got the same result)
I use V3.3 from Arduino as power source for ESP8266. But I also use voltage regulator to smooth out the current as many people suggest that. The problem still remains.
I'm struggled with this issue for a few days, just want to know if anybody had the similar experience, or could give some clue for the next step.
After a considerable effort to stabilize the circuit, I switched to NodeMCU and got the system working perfectly. I assume that ESP8266 alone is somehow not robust enough without other components, which I unfortunately have no knowledge on.
So I'd like to close this thread with a short recommendation for anybody struggling with the same issue to switch to NodeMCU (which would replace both Arduino and ESP8266); if that could support the requirement.

SNMP custom made device ESP8266

my company uses the application PRTG from paessler.com to monitor several SNMP sensors, I need to monitor the voltage of some devices and transmit it to the manager.
I was going to use an ESP8266 programmed via arduino to do it.
So far I've been able to send data to the ESP via UDP, and I configured it in the manager so it can retrieve the information from it and ping it.
The ping tests are successful however the monitoring does not work, by using the serial interface I can see that the ESP is receiving the data from the manager, with the OID that was set up. But the monitor shows it as inactive, I set up the ESP to send a simple string in the response.
When using a program called Packet Sender I am able to send the udp packets and receive the response as well, and everything works fine.
The ports I am using is 161 to receive in the ESP and I made it send to the 161, 123, 1023 as i saw specified in the prtg site
I may be sending the packets trough a port that is not the right one, or maybe I have to put a header before the message so the controller can Interpret it. I am not sure what the error can be. Any help will be apreciated
pretty easy - simply use the http push sensor from PRTG:
https://www.paessler.com/manuals/prtg/http_push_data_sensor
All best
Christian

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.

Wavecom GSM modem as a TCP client

I've been trying to do TCP communication using my Wavecom Fastrack modem. What I want to achieve is make the modem connect to a specified TCP server port to enable me to transfer data to and from the server. I found some information on than in the user's guide.
Basing on the information you can find on page 66 I created an application that opens the serial port to which the modem is connected and writes the following AT commands:
AT+WIPCFG=1 //start IP stack
AT+WIPBR=1,6 //open GPRS bearer
AT+WIPBR=2,6,11,"APN" //set APN of GPRS bearer
AT+WIPBR=2,6,0 //username
AT+WIPBR=2,6,1 //password
AT+WIPBR=4,6,0 //start GPRS bearer
AT+WIPCREATE=2,1,"server_ip_address",server_port //create a TCP client on port "server_port"
AT+WIPDATA=2,1,1 //switch do data exchange mode
This is exactly what the user's guide says. After the last command is sent to the modem, the device switches to data exchange mode and from then on everything what is written to the serial port opened by my application should be received by the server and everything the server sends should appear in the input buffer of that port.
The thing is that I did not manage to maintain stable bidirectional communication between the server and my modem. When I write some data to the serial port (only a few bytes), it takes a lot of time before the data appears on the server's side and in many cases the data does not reach the server at all.
I performed a few tests writing about 100 bytes to the serial port at once. Logging the data received by my server application I noticed that the first piece of data (8-35 bytes) is received after a second or two. The rest of the data appears in 2-5 seconds (either as a whole or in pieces of the said size) or does not appear at all.
I do not know where to look for the reason of that behaviour. Did I use wrong AT commands to switch the modem to TCP client mode? I can't believe the communication may be so slow and unstable.
Any advice will be appreciated. Thank you in advance.
what OS are you running? Windows does a pretty good job of hiding the messy details of communicating with the GPRS modem, all you have to do is create a new dial-up connection. To establish the connection you can make a call to the Win32 RasDial function. Once connected, you can use standard sockets to transfer data on a TCP port.
i have been using wavecomm modem for 2 years now.As far as i know from my experience is that if you are able to send some of the data then you can send all of the data.
the problem might be in the listening application which receives the data on the server side.
It could be that it is unable to deal with the amount of data that you are trying to send.
try sending the same data in smaller busts
with some delay in between them,then you might receive all data intact.

Resources