I'm trying to build a device for my startup IoT-related, using a7672s, here code :an A7672S.
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 Here is the check variable to check different possible responses of sim like ok, error, etccode:
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; }
}
}
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 postPOST time? becozBecause in my last module sim7600(SIM7600), I used CHTTPACTION, that which was postedPOSTing in less than 500 millisecondsms, but inon the A7672s, it's taking more than 1 second,s.
canCan someone confirm possible issues or any other method of makingfor the fast posting of data? also
Also, in this httpHTTP method, is HTTPTERM is required for every postPOST or change in URL point or when it's required? http