I'm using a Sim800L module connected to an Arduino, and trying to send data to a web server using the AT commands.
Usually, by doing the send procedure (manually, by writing each line of code on the Arduino serial monitor) in order to upload the datas on a table, the answer is: 0,200,35 or 0,200,36, and it perfectly works.
By doing it from the code below, the answer is always 0,200,351, 0,200,371... by reading the data sheet of the SIM800L module, the last number of the reply of the command, refer to the <datalen>
, and the 200 correspond to an 'OK'. However, nothing is posted when I receive that 3xx code.
void post_mySQL(){
String url = get_url();
execute_AT("AT+CFUN=1");
execute_AT("AT+CGATT=1");
execute_AT("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
execute_AT("AT+SAPBR=3,1,\"APN\",\"TM\"");
execute_AT("AT+SAPBR=3,1,\"USER\",\"\"");
execute_AT("AT+SAPBR=3,1,\"PWD\",\"\"");
execute_AT("AT+SAPBR=0,1");
execute_AT("AT+SAPBR=1,1");
execute_AT("AT+SAPBR=2,1");
execute_AT("AT+HTTPINIT");
execute_AT("AT+HTTPPARA=\"CID\",1");
execute_AT("AT+HTTPPARA=\"URL\","+url);
execute_AT("AT+HTTPACTION=0");
//execute_AT("WAIT=6");
execute_AT("AT+HTTPTERM");
execute_AT("AT+CIPSHUT");
}
String execute_AT(String AT){
boolean answered = false;
String response;
Serial1.println(AT);
delay(4000);
do{
if(Serial1.available() > 0){
answer = true;
response = Serial1.readString();
}
}while(answer == false);
Serial.println(response);
return response;
}
Does anybody knows why there's such difference?
datalen was too high as sim800l buffer was always full, solved by defining:
#define SERIAL_BUFFER_SIZE 256
#define SERIAL1_BUFFER_SIZE 256