I'm trying to build a device for my startup IoT-related, using an A7672S.
Here is the code:
mySerial.println("AT+HTTPINIT";
checkresponse("OK\r\n");
mySerial.println("AT+HTTPPARA=\"URL\",\"http://" + host + resources + "\"");
checkresponse("OK\r\n");
mySerial.println("AT+HTTPPARA=\"CONTENT\",\"application/json\"");
checkresponse("OK\r\n");
String st = "AT+HTTPDATA=";
int pdl = postdata.length();
st += String(pdl);
st += ",15000";
mySerial.println(st);
checkresponse("DOWNLOAD");
mySerial.println(postdata);
checkresponse("OK\r\n");
mySerial.println("AT+HTTPACTION=1");
checkresponse("+HTTPACTION: 1,200");
if (BuildINString2.indexOf("+HTTPACTION: 1,200") != -1) {
Serial.println("POST DONE");
} else
Serial.print("ERROR POST: ");
Serial.println(BuildINString2);
}
mySerial.println("AT+HTTPTERM");
checkresponse("OK\r\n");
// In the check function, we pass the check variable to check different possible responses of sim like ok, error, etc
void checkresponse(String check) {
int start = millis();
BuildINString2="";
while (true) {
if (mySerial.available() > 0) {
inData =mySerial.read();
BuildINString2 = BuildINString2 + char(inData);
}
if (BuildINString2.indexOf(check)! = -1) {
delay(100);
return;
}
if (millis()-start > 3000) {
delay(100);
Serial.println("SIM TIMEOUT");
return;
}
}
}
How can we speed up the POST time? Because in my last module (SIM7600), I used CHTTPACTION which was POSTing in less than 500 ms, but on the A7672s, it's taking more than 1 s.
Can someone confirm possible issues or any other method for the fast posting of data?
Also, in this HTTP method, is HTTPTERM required for every POST or change in URL point or when it's required?