Cellular: Added ATHandler option to write parameters without delimiters

pull/8401/head
Mirela Chirica 2018-10-15 10:40:43 +03:00
parent f016d1126f
commit 273590f615
3 changed files with 23 additions and 3 deletions

View File

@ -81,6 +81,7 @@ ATHandler::ATHandler(FileHandle *fh, EventQueue &queue, int timeout, const char
_max_resp_length(MAX_RESP_LENGTH),
_debug_on(MBED_CONF_CELLULAR_DEBUG_AT),
_cmd_start(false),
_use_delimiter(true),
_start_time(0)
{
clear_error();
@ -612,6 +613,11 @@ void ATHandler::set_default_delimiter()
_delimiter = DEFAULT_DELIMITER;
}
void ATHandler::use_delimiter(bool use_delimiter)
{
_use_delimiter = use_delimiter;
}
void ATHandler::set_tag(tag_t *tag_dst, const char *tag_seq)
{
if (tag_seq) {
@ -1147,6 +1153,11 @@ bool ATHandler::check_cmd_send()
return false;
}
// Don't write delimiter if flag was set so
if (!_use_delimiter) {
return true;
}
// Don't write delimiter if this is the first subparameter
if (_cmd_start) {
_cmd_start = false;

View File

@ -281,6 +281,12 @@ public:
*/
void set_default_delimiter();
/** Defines behaviour for using or ignoring the delimiter within an AT command
*
* @param use_delimiter indicating if delimiter should be used or not
*/
void use_delimiter(bool use_delimiter);
/** Consumes the reading buffer up to the delimiter or stop_tag
*
* @param count number of parameters to be skipped
@ -435,6 +441,7 @@ private:
char _info_resp_prefix[BUFF_SIZE];
bool _debug_on;
bool _cmd_start;
bool _use_delimiter;
// time when a command or an URC processing was started
uint64_t _start_time;

View File

@ -386,9 +386,11 @@ nsapi_error_t AT_CellularNetwork::open_data_channel()
_at.write_int(_cid);
} else {
MBED_ASSERT(_cid >= 0 && _cid <= 99);
char cmd_buf[sizeof("ATD*99***xx#")];
std::sprintf(cmd_buf, "ATD*99***%d#", _cid);
_at.cmd_start(cmd_buf);
_at.cmd_start("ATD*99***");
_at.use_delimiter(false);
_at.write_int(_cid);
_at.write_string("#", false);
_at.use_delimiter(true);
}
_at.cmd_stop();