1717 It makes it easy to build Arduino applications that use the full power of ME310 module
1818
1919 @version
20- 2.11.0
20+ 2.13.1
2121
2222 @note
2323
@@ -43,7 +43,7 @@ const char *ME310::OK_STRING = "OK"; ///< String for OK modem
4343const char *ME310::ERROR_STRING = " ERROR" ; // /< String for ERROR modem answer
4444const char *ME310::CONNECT_STRING = " CONNECT" ; // /< String for CONNECT modem answer
4545const char *ME310::CME_ERROR_STRING = " +CME ERROR: " ; // /< String for +CME ERROR modem answer
46- const char *ME310::SEQUENCE_STRING = " >>> " ; // /< Sequence string
46+ const char *ME310::SEQUENCE_STRING = " >>>" ; // /< Sequence string
4747const char *ME310::WAIT_DATA_STRING = " > " ; // /< Wait Data string
4848const char *ME310::TERMINATION_STRING = " " ; // /< Termination character
4949const char *ME310::NO_CARRIER_STRING = " NO CARRIER" ; // /< String for NO CARRIER modem answer
@@ -5114,6 +5114,12 @@ ME310::return_t ME310::send_http_send(int prof_id, int command, const char *reso
51145114{
51155115 ME310::return_t ret;
51165116 memset (mBuffer , 0 , ME310_BUFFSIZE);
5117+ if ( post_param == " " )
5118+ {
5119+ ret = send_http_send_without_params (prof_id, command, resource, data_len, data, aTimeout);
5120+ return ret;
5121+ }
5122+
51175123 snprintf ((char *)mBuffer , ME310_BUFFSIZE-1 , F (" AT#HTTPSND=%d,%d,\" %s\" ,%d,\" %s\" ,\" %s\" " ), prof_id, command, resource, data_len, post_param, extra_header_line);
51185124 ret = send_wait ((char *)mBuffer ,SEQUENCE_STRING,aTimeout);
51195125 if ((ret == RETURN_VALID))
@@ -5125,6 +5131,31 @@ ME310::return_t ME310::send_http_send(int prof_id, int command, const char *reso
51255131 return ret;
51265132}
51275133
5134+ // ! \brief Implements the AT\#HTTPSND command and waits for OK answer
5135+ /* ! \details
5136+ This command performs a POST or PUT request to HTTP server and starts sending data to the server.
5137+ * \param prof_id profile identifier
5138+ * \param command command requested to HTTP server
5139+ * \param resource HTTP resource (uri), object of the request
5140+ * \param data_len data length to send in bytes
5141+ * \param aTimeout timeout in ms
5142+ * \return return code
5143+ */
5144+ ME310::return_t ME310::send_http_send_without_params (int prof_id, int command, const char *resource, int data_len, char *data, tout_t aTimeout)
5145+ {
5146+ ME310::return_t ret;
5147+ memset (mBuffer , 0 , ME310_BUFFSIZE);
5148+ snprintf ((char *)mBuffer , ME310_BUFFSIZE-1 , F (" AT#HTTPSND=%d,%d,\" %s\" ,%d" ), prof_id, command, resource, data_len);
5149+ ret = send_wait ((char *)mBuffer ,SEQUENCE_STRING,aTimeout);
5150+ if ((ret == RETURN_VALID))
5151+ {
5152+ memset (mBuffer , 0 , ME310_BUFFSIZE);
5153+ memcpy (mBuffer , data, data_len);
5154+ ret = send_wait ((char *)mBuffer ,OK_STRING,TERMINATION_STRING,aTimeout);
5155+ }
5156+ return ret;
5157+ }
5158+
51285159// ! \brief Implements the AT\#HTTPRCV command and returns
51295160/* ! \details
51305161This command permits the user to read data from HTTP server in response to a previous HTTP module
@@ -7612,7 +7643,6 @@ ME310::return_t ME310::send_wait(const char *aCommand, int flag, const char *aA
76127643 return wait_for (aCommand, flag, aAnswer, aTimeout);
76137644}
76147645
7615-
76167646// ! \brief Waits for the answer to an AT command or timeouts
76177647/* !
76187648 * \param aAnswer answer string to wait for
@@ -7648,6 +7678,11 @@ ME310::return_t ME310::wait_for(const char *aAnswer, ME310::tout_t aTimeout)
76487678 on_valid ((const char *)pBuffer);
76497679 return RETURN_VALID;
76507680 }
7681+ if (str_start ((const char *)pBuffer,aAnswer))
7682+ {
7683+ on_valid ((const char *)pBuffer);
7684+ return RETURN_VALID;
7685+ }
76517686 if (str_equal ((const char *)pBuffer,ERROR_STRING))
76527687 {
76537688 on_error ((const char *)pBuffer);
@@ -7952,12 +7987,17 @@ const char *ME310::str_start(const char *buffer, const char *string)
79527987 return nullptr ;
79537988 }
79547989 const char *rc = buffer;
7955- for (; ;buffer++,string++)
7990+
7991+ String bufTMP, strTMP;
7992+ bufTMP = buffer;
7993+ strTMP = string;
7994+ if (bufTMP.startsWith (strTMP))
79567995 {
7957- if (*buffer != *string)
7958- return nullptr ; // exit if different
7959- else if (*buffer == 0 )
7960- return rc; // exit if equal but = 0
7996+ return rc;
7997+ }
7998+ else
7999+ {
8000+ return nullptr ;
79618001 }
79628002}
79638003
0 commit comments