Skip to content

Commit 273590f

Browse files
author
Mirela Chirica
committed
Cellular: Added ATHandler option to write parameters without delimiters
1 parent f016d11 commit 273590f

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

features/cellular/framework/AT/ATHandler.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ ATHandler::ATHandler(FileHandle *fh, EventQueue &queue, int timeout, const char
8181
_max_resp_length(MAX_RESP_LENGTH),
8282
_debug_on(MBED_CONF_CELLULAR_DEBUG_AT),
8383
_cmd_start(false),
84+
_use_delimiter(true),
8485
_start_time(0)
8586
{
8687
clear_error();
@@ -612,6 +613,11 @@ void ATHandler::set_default_delimiter()
612613
_delimiter = DEFAULT_DELIMITER;
613614
}
614615

616+
void ATHandler::use_delimiter(bool use_delimiter)
617+
{
618+
_use_delimiter = use_delimiter;
619+
}
620+
615621
void ATHandler::set_tag(tag_t *tag_dst, const char *tag_seq)
616622
{
617623
if (tag_seq) {
@@ -1147,6 +1153,11 @@ bool ATHandler::check_cmd_send()
11471153
return false;
11481154
}
11491155

1156+
// Don't write delimiter if flag was set so
1157+
if (!_use_delimiter) {
1158+
return true;
1159+
}
1160+
11501161
// Don't write delimiter if this is the first subparameter
11511162
if (_cmd_start) {
11521163
_cmd_start = false;

features/cellular/framework/AT/ATHandler.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,12 @@ class ATHandler {
281281
*/
282282
void set_default_delimiter();
283283

284+
/** Defines behaviour for using or ignoring the delimiter within an AT command
285+
*
286+
* @param use_delimiter indicating if delimiter should be used or not
287+
*/
288+
void use_delimiter(bool use_delimiter);
289+
284290
/** Consumes the reading buffer up to the delimiter or stop_tag
285291
*
286292
* @param count number of parameters to be skipped
@@ -435,6 +441,7 @@ class ATHandler {
435441
char _info_resp_prefix[BUFF_SIZE];
436442
bool _debug_on;
437443
bool _cmd_start;
444+
bool _use_delimiter;
438445

439446
// time when a command or an URC processing was started
440447
uint64_t _start_time;

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,11 @@ nsapi_error_t AT_CellularNetwork::open_data_channel()
386386
_at.write_int(_cid);
387387
} else {
388388
MBED_ASSERT(_cid >= 0 && _cid <= 99);
389-
char cmd_buf[sizeof("ATD*99***xx#")];
390-
std::sprintf(cmd_buf, "ATD*99***%d#", _cid);
391-
_at.cmd_start(cmd_buf);
389+
_at.cmd_start("ATD*99***");
390+
_at.use_delimiter(false);
391+
_at.write_int(_cid);
392+
_at.write_string("#", false);
393+
_at.use_delimiter(true);
392394
}
393395
_at.cmd_stop();
394396

0 commit comments

Comments
 (0)