Skip to content

Commit be374fb

Browse files
committed
Cellular: Add AT handler buffer size to configuration
1 parent 14e5d30 commit be374fb

File tree

12 files changed

+21
-10
lines changed

12 files changed

+21
-10
lines changed

connectivity/cellular/include/cellular/framework/API/ATHandler.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ class FileHandle;
5050
extern const char *OK;
5151
extern const char *CRLF;
5252

53-
#define BUFF_SIZE 32
54-
5553
/* AT Error types enumeration */
5654
enum DeviceErrorType {
5755
DeviceErrorTypeNoError = 0,
@@ -114,7 +112,7 @@ class ATHandler {
114112

115113
/** Set callback function for URC
116114
*
117-
* @param prefix URC text to look for, e.g. "+CMTI:". Maximum length is BUFF_SIZE.
115+
* @param prefix URC text to look for, e.g. "+CMTI:". Maximum length is MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE.
118116
* @param callback function to call on prefix, or 0 to remove callback
119117
*/
120118
void set_urc_handler(const char *prefix, Callback<void()> callback);
@@ -601,7 +599,7 @@ class ATHandler {
601599
bool _is_fh_usable;
602600

603601
// should fit any prefix and int
604-
char _recv_buff[BUFF_SIZE];
602+
char _recv_buff[MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE];
605603
// reading position
606604
size_t _recv_len;
607605
// reading length
@@ -630,7 +628,7 @@ class ATHandler {
630628
size_t _max_resp_length;
631629

632630
// prefix set during resp_start and used to try matching possible information responses
633-
char _info_resp_prefix[BUFF_SIZE];
631+
char _info_resp_prefix[MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE];
634632
bool _debug_on;
635633
bool _cmd_start;
636634
bool _use_delimiter;
@@ -640,7 +638,7 @@ class ATHandler {
640638
// eventqueue event id
641639
int _event_id;
642640

643-
char _cmd_buffer[BUFF_SIZE];
641+
char _cmd_buffer[MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE];
644642
};
645643

646644
} // namespace mbed

connectivity/cellular/mbed_lib.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
"plmn-fallback-auto" : {
4545
"help": "If manual PLMN is selected, use mode 4 manual/automatic in AT+COPS to try automatic mode if manual selection fails. Set to null to disable",
4646
"value": null
47+
},
48+
"at-handler-buffer-size" : {
49+
"help": "Size of the AT handler buffer",
50+
"value": 32
4751
}
4852
}
4953
}

connectivity/cellular/source/framework/device/ATHandler.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ int32_t ATHandler::read_int()
683683
return -1;
684684
}
685685

686-
char buff[BUFF_SIZE];
686+
char buff[MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE];
687687
if (read_string(buff, sizeof(buff)) == 0) {
688688
return -1;
689689
}
@@ -960,7 +960,7 @@ void ATHandler::resp_start(const char *prefix, bool stop)
960960
(void)fill_buffer(false);
961961

962962
if (prefix) {
963-
MBED_ASSERT(strlen(prefix) < BUFF_SIZE);
963+
MBED_ASSERT(strlen(prefix) < MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE);
964964
strcpy(_info_resp_prefix, prefix); // copy prefix so we can later use it without having to provide again for info_resp
965965
}
966966

@@ -1225,7 +1225,7 @@ void ATHandler::handle_start(const char *cmd, const char *cmd_chr)
12251225
if (cmd_chr) {
12261226
cmd_char_len = strlen(cmd_chr);
12271227
}
1228-
MBED_ASSERT((3 + strlen(cmd) + cmd_char_len) < BUFF_SIZE);
1228+
MBED_ASSERT((3 + strlen(cmd) + cmd_char_len) < MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE);
12291229

12301230
memcpy(_cmd_buffer + len, cmd, strlen(cmd));
12311231
len += strlen(cmd);
@@ -1258,7 +1258,7 @@ void ATHandler::cmd_start_stop(const char *cmd, const char *cmd_chr, const char
12581258

12591259
nsapi_error_t ATHandler::at_cmd_str(const char *cmd, const char *cmd_chr, char *resp_buf, size_t buf_size, const char *format, ...)
12601260
{
1261-
MBED_ASSERT(strlen(cmd) < BUFF_SIZE);
1261+
MBED_ASSERT(strlen(cmd) < MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE);
12621262
lock();
12631263

12641264
handle_start(cmd, cmd_chr);

connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,5 @@ set(unittest-test-flags
5151
-DMBED_CONF_CELLULAR_USE_SMS=1
5252
-DMBED_CONF_NSAPI_DEFAULT_CELLULAR_APN=NULL
5353
-DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
54+
-DMBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
5455
)

connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularinformation/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ set(unittest-test-flags
4040
-DDEVICE_SERIAL=1
4141
-DDEVICE_INTERRUPTIN=1
4242
-DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
43+
-DMBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
4344
)

connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularnetwork/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ set(unittest-test-flags
4242
-DDEVICE_SERIAL=1
4343
-DDEVICE_INTERRUPTIN=1
4444
-DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
45+
-DMBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
4546
)

connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularsms/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ set(unittest-test-flags
4444
-DDEVICE_SERIAL=1
4545
-DDEVICE_INTERRUPTIN=1
4646
-DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
47+
-DMBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
4748
)

connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularstack/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ set(unittest-test-flags
4949
-DDEVICE_SERIAL=1
5050
-DDEVICE_INTERRUPTIN=1
5151
-DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
52+
-DMBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
5253
)

connectivity/cellular/tests/UNITTESTS/framework/device/athandler/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ set(unittest-test-flags
4545
-DDEVICE_SERIAL=1
4646
-DDEVICE_INTERRUPTIN=1
4747
-DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
48+
-DMBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
4849
)

connectivity/cellular/tests/UNITTESTS/framework/device/cellularcontext/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@ set(unittest-test-flags
5656
-DDEVICE_SERIAL=1
5757
-DDEVICE_INTERRUPTIN=1
5858
-DMBED_CONF_CELLULAR_USE_SMS=1
59+
-DMBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
5960
)

connectivity/cellular/tests/UNITTESTS/framework/device/cellulardevice/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ set(unittest-test-flags
4747
-DDEVICE_SERIAL_FC=1
4848
-DDEVICE_SERIAL=1
4949
-DDEVICE_INTERRUPTIN=1
50+
-DMBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
5051
)

connectivity/cellular/tests/UNITTESTS/framework/device/cellularstatemachine/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,5 @@ set(unittest-test-flags
5252
-DDEVICE_SERIAL=1
5353
-DDEVICE_INTERRUPTIN=1
5454
-DMBED_CONF_CELLULAR_USE_SMS=1
55+
-DMBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
5556
)

0 commit comments

Comments
 (0)