Skip to content

Commit c9e2452

Browse files
Merge pull request #22 from telit/feature/add-http-send-without-par-method
add http_send_with_parameter method and fix str_start method
2 parents 5fb3dc0 + d0188ab commit c9e2452

File tree

4 files changed

+57
-11
lines changed

4 files changed

+57
-11
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
ME310 0.0.0 - ????.??.??
22

3+
ME310 2.13.1 - 2024.04.16
4+
* Fixes in M2MWrite
5+
* Added Http_send_without_parameter
6+
* Fixes str_start
7+
38
ME310 2.12.1 - 2023.11.23
49
* Fixes in LWM2M_first example
510

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ME310G1
2-
version=2.12.1
2+
version=2.13.1
33
author=Telit
44
maintainer=Telit <info@telit.com>
55
sentence=Allows communication with ME310G1 Telit module.

src/ME310.cpp

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
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
4343
const char *ME310::ERROR_STRING = "ERROR"; ///< String for ERROR modem answer
4444
const char *ME310::CONNECT_STRING = "CONNECT"; ///< String for CONNECT modem answer
4545
const 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
4747
const char *ME310::WAIT_DATA_STRING = "> "; ///< Wait Data string
4848
const char *ME310::TERMINATION_STRING = ""; ///< Termination character
4949
const 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
51305161
This 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

src/ME310.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
It makes it easy to build Arduino applications that use the full power of ME310 module
1414
1515
@version
16-
2.11.0
16+
2.13.1
1717
1818
@note
1919
Dependencies:
@@ -1032,7 +1032,8 @@ namespace me310
10321032
return_t send_http_query(int prof_id, int command, const char *resource, tout_t aTimeout = TOUT_100MS);
10331033
_TEST(send_http_query,"AT#HTTPQRY",TOUT_100MS)
10341034

1035-
return_t send_http_send(int prof_id, int command, const char *resource, int data_len, char *data, const char *post_param ="", const char *extra_header_line = "",tout_t aTimeout = TOUT_100MS);
1035+
return_t send_http_send(int prof_id, int command, const char *resource, int data_len, char *data, const char *post_param ="", const char *extra_header_line = "", tout_t aTimeout = TOUT_100MS);
1036+
return_t send_http_send_without_params(int prof_id, int command, const char *resource, int data_len, char *data, tout_t aTimeout = TOUT_100MS);
10361037
_TEST(send_http_send,"AT#HTTPSND",TOUT_100MS)
10371038

10381039
void receive_http_data_start(int prof_id, int max_byte = 0);

0 commit comments

Comments
 (0)