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 ofHTTPPOST
- 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:
- AT command reference for the A6 and A7, which are similar-but-not-identical chips made by the same manufacturer.
- A Hackster.io project that mentions several of the AT commands
- Code examples from the chip manufacturer, which are poorly formatted but easier to read if you view the page source.
- ESP8266 + A9G combo GitHub project, which includes some background info.