Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Eliminate delay of HTTPREAD action after ?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Eliminate delay of HTTPREAD action after ?

by ironhalo on Fri Jul 03, 2020 9:53 am

Hello. I am successfully using the FONA libraries to POST data to ThingsBoard.io, and I am now trying to optimize the activities of the GSM module to save on battery life.

Within Adafruit_FONA.cpp, it seems that after posting the data, the postData function then issues getReply/HTTPREAD, readline and print statements, with the intent of retrieving and printing the server's reply.

Code: Select all | TOGGLE FULL SIZE
  DEBUG_PRINT("HTTP status: "); DEBUG_PRINTLN(status);
  DEBUG_PRINT("Data length: "); DEBUG_PRINTLN(datalen);

  if (status != 200) return false;

  getReply(F("AT+HTTPREAD"));

  readline(10000);
  DEBUG_PRINT("\t<--- "); DEBUG_PRINTLN(replybuffer); // Print out server reply

  // Terminate HTTP service
  sendCheckReply(F("AT+HTTPTERM"), ok_reply, 10000);

  return true;


In my case, this results in a 10-15 second pause after the HTTPREAD request, and then what looks to be a blank server reply (which is fine because I'm not expecting any data back from the server).

---> AT+HTTPACTION=1
<--- OK
HTTP status: 200
Data length: 0
---> AT+HTTPREAD
<--- OK ******(the 10-15 second pause occurs here, then a blank response prints on the next line)*****
<---
---> AT+HTTPTERM
<--- OK

So my question is this: If I'm not actually seeing/expecting any response from the server here, is it okay to skip this step by commenting out the three corresponding lines as such?

Code: Select all | TOGGLE FULL SIZE
  DEBUG_PRINT("HTTP status: "); DEBUG_PRINTLN(status);
  DEBUG_PRINT("Data length: "); DEBUG_PRINTLN(datalen);

  if (status != 200) return false;

 // getReply(F("AT+HTTPREAD"));

 // readline(10000);
 // DEBUG_PRINT("\t<--- "); DEBUG_PRINTLN(replybuffer); // Print out server reply

  // Terminate HTTP service
  sendCheckReply(F("AT+HTTPTERM"), ok_reply, 10000);

  return true;


I have done so and am currently testing the sketch, and it seems to be working fine so far. The delay is gone and my uploads complete much quicker. However I don't know if this edit is going to be prone to cause communication issues at some point, as I don't know if this getReply/HTTPREAD step is a vital part of the customary HTTP exchange.

Thanks in advance for any feedback.

ironhalo
 
Posts: 1
Joined: Mon Jan 09, 2017 3:22 pm

Please be positive and constructive with your questions and comments.