5

I'm using AT commands to communicate with an Ai-Thinker A9G chip from an ESP8266, as part of a GPS tracker unit. It works fine to start with, then HTTPS requests start failing after sending 7 or 8 successfully. However, it's still fine making HTTP requests.

What could be causing HTTPS requests to fail after the first 7 or 8, when HTTP requests work just fine?


Details...

As the unit starts up, I'm using the following to establish the GPRS connection:

AT+CGREG=1
> OK

AT+CGATT=1
> +CGATT:1
> OK

AT+CGDCONT=1,"IP","data.uk" // APN for 1pmobile
> OK

AT+CGACT=1,1
> OK

AT+CGACT?
> +CGACT: 1, 1
> OK

Then to publish the location every N minutes, the following:

AT+HTTPPOST="https://<URL>","application/x-www-form-urlencoded","arg1=val1&arg2=val2&..."

That works the first 7 or 8 times, after which all HTTPS requests fail with the following message (copied exactly as sent from the A9G chip, including the firmware's spelling error):

+CME ERROR: parameters are invalid
failure, pelase check your network or certificate!

After the HTTPPOST commands start failing I've tried the following status checks but everything suggests the chip is in a good state and online still:

AT+CIPSTATUS
> +CIPSTATUS:
> STATE:IP INITIAL

AT+CGACT?
> +CGACT: 1, 1
> OK

AT+CGREG?
> +CGREG: 1, 1
> OK

AT+CGDCONT?
> +CGDCONT:1,"IP","data.uk","<IP address>",0,0
> OK

I've also tried:

  • Sending the requests back-to-back or 5 minutes apart - no change in behaviour, it still fails after 7 or 8 requests, regardless of time elapsed.
  • Swapping to a different SIM card and updating the APN specified in CGDCONT - no change.
  • Deactivating the network connection with AT+CGACT=0,1, AT+CGATT=0, AT+CGREG=0 then re-enabling it - no change.
  • Making AT+HTTPGET requests instead of HTTPPOST - no change.
  • Restarting the A9G chip - this gives me another 7 or 8 requests, then the pattern repeats.
  • Making requests to an HTTP URL instead of HTTPS - as noted, these work just fine.

Annoyingly, documentation for the A9/A9G chip is thin on the ground. Much of it is in Chinese-language PDFs that don't play nicely with Google Translate. These are the most useful links I've found to piece together what I have above:

Mark Ormesher
  • 2,289
  • 3
  • 27
  • 35
  • My congratulations, as the question is well written as it rarely happens. Your note _"Restarting the A9G chip - this gives me another 7 or 8 requests, then the pattern repeats."_ makes me think it could be a bug of the firmware. Actually, if the work around of turning the chip down (and "awaking" 10-15 seconds before the following post) can be acceptable to you, you could also obtain to optimize power consumption. – Roberto Caboni Aug 02 '21 at 12:20
  • Anyway, I was going to check for any tips in the AT command guide, but I wasn't able to find it. Can you link it? – Roberto Caboni Aug 02 '21 at 12:20
  • @RobertoCaboni I was starting to think it might be a problem with the firmware. Unfortunately the A9G chip also handles the GPS and provides the location, which in turn dictates how often the location is published. Annoyingly there isn't a lot of documentation about the A9G, but I'll update the question with the handful of resources I've found. – Mark Ormesher Aug 02 '21 at 17:41
  • You write your own code to automate the sending of AT commands or you use some library? Do you check the heap utilisation of your program? – hcheung Aug 04 '21 at 08:27
  • @hcheung The code sending the AT commands is written by me, yes. The ESP8266 is running ESPHome, but all of the interaction with the A9G is "manual" (i.e. not via a library) communication over UART. I monitor the heap memory on the ESP and it's fine; I don't think I can check the heap on the A9G via AT commands. – Mark Ormesher Aug 04 '21 at 09:18
  • Firmware spelling mistake!! lol. – Subhash Chaganti Apr 30 '23 at 14:22
  • I have bought Maduino A9G module. AT+HTTPGET is not working reliably. It will have same firmware and same issue right? – Subhash Chaganti Apr 30 '23 at 14:43
  • @SubhashChaganti It will very likely be the same firmware, yes - last time I checked the manufacturer considers the A9G "done" so isn't releasing any new firmware for it. It's possible that Maduino have made their own tweaks to the firmware though, or have some other way of dealing with the issue - all I can say is give it a go and see! – Mark Ormesher May 01 '23 at 08:35
  • https://arduino.stackexchange.com/questions/81606/sim-a9g-cme-error-53-failure/86180#86180?newreg=f5edfd0df2db4cd4ba1e5d218343e621 Check this link. Sequence of commands might work. For me, as of now, it seems to be working. – Subhash Chaganti May 01 '23 at 09:39

1 Answers1

3

In the end I contacted the chip manufacturer, explained the problems I've had and suggested there might be a bug in the firmware. They responded and confirmed that was the case, and suggested that it wasn't likely to be resolved any time soon:

Hello Mark,

yes, we now find many issue feedback of A9G modules including the on you state, but now we have no enough engineer to support this problem.

i only can try to push if you have big quantity requirement.

Best Regards,

- Overseas Team

深圳市安信可科技有限公司

Shenzhen Anxinke Technology Co., Ltd

I'm posting this as an answer rather than a comment because it directly answers the main question at the top of my original post: "What could be causing HTTPS requests to fail after the first 7 or 8, when HTTP requests work just fine?". Answer: bad firmware. My best guess is a bug when allocating and de-allocating memory to handle TLS exchanges, but that could be way off.

To anyone else encountering this problem, you have a couple of options:

  • Use WiFi whenever possible.
  • Stick to HTTP requests.
  • Restart the chip after every 7 commands.
Mark Ormesher
  • 2,289
  • 3
  • 27
  • 35
  • Do you know if they're open to releasing the source code? Not sure how it is with these China manufacturers – Amir Asyraf Sep 16 '21 at 06:55
  • I asked about that when I replied to the email I copied above - no response yet unfortunately. I've written the A9G off now anyway and have recently received a SIM808 module to use in V2 of this project. – Mark Ormesher Sep 16 '21 at 14:44
  • @MarkOrmesher are you able to get data from https requests that support TLS1.2 – narayan rathod Sep 20 '22 at 10:55
  • I wasn't able to get any HTTPS requests to work after the first 7/8 unfortunately. – Mark Ormesher Sep 20 '22 at 13:09
  • @MarkOrmesher With SIM808 are you able to make https requests which supports TLS because I also have sim808 but not successful in getting data from https website like jsonplaceholder.typicode.com it throws http status code 606. I have tried this with enabling SSL as well but still doesn’t work. Did you try HTTPS requests with SIM808 if yes would be great help on the steps you performed for doing so.Thanks – narayan rathod Sep 20 '22 at 16:21
  • Hey @narayanrathod - I've been able to make HTTPS requests from the SIM808 to a site using TLS1.3, but unfortunately it required disabling SSL verification by sending AT+HTTPSSL=0 before making the request. – Mark Ormesher Jan 01 '23 at 13:17