1

I can't validate an AT command. Would anyone have any suggestions as to what I might be doing wrong? It should be printing "Sending successful! or "Sending failed!", but it doesn't show any text.

if (httpReadResponse.indexOf("OK") != -1) {
  Serial.println("Envio bem-sucedido!");
} else {
  Serial.println("Falha no envio!");
}

My serial monitor is printing this:

AT+HTTPDATA=192,5000\
DOWNLOAD\
OK\
AT+HTTPACTION=0\
OK\
AT+HTTPREAD

Full function:

void sendHttpRequest(int distance_cm) {
  gsm_send_serial("AT+HTTPINIT");
  gsm_send_serial("AT+HTTPPARA=CID,1");
  gsm_send_serial("AT+HTTPSSL=1");
  gsm_send_serial("AT+HTTPPARA=URL," + url2 + "/" + distance_cm + "/" + id_cliente + "/" + id_caixa + "/" + ipadd1 + "/" + sinal + "/" + totalMilliLitres + "/" + vazao_atual + "/" + apikey);
  gsm_send_serial("AT+HTTPPARA=CONTENT,application/x-www-form-urlencoded");
  gsm_send_serial("AT+HTTPDATA=192,5000");
  gsm_send_serial("param=Aqualizar");
  gsm_send_serial("AT+HTTPACTION=0");

String httpReadResponse = gsm_send_serial("AT+HTTPREAD");

gsm_send_serial("AT+HTTPTERM");

if (httpReadResponse.indexOf("OK") != -1) { Serial.println("Sending successful!"); } else { Serial.println("Sending failed!"); } }

ocrdu
  • 1,795
  • 3
  • 12
  • 24

1 Answers1

0

AT+HTTPACTION=0

AT+HTTPACTION=0 starts a GET session. Based on your code, you are supposed to create a POST session, which should be AT+HTTPACTION=1.

Read SIM800 Series_IP_Application Note which provides the examples for both GET and POST request based on the SIMCOM HTTP AT-command set. The application note can be found at SIMCOM's website (requires registration for free download) or simply google "SIM800 Series_IP_Application Note" as there are many sites that have the document available without the need for registration.

ocrdu
  • 1,795
  • 3
  • 12
  • 24
hcheung
  • 1,933
  • 8
  • 15