Skip to content

Cellular: Add AT handler buffer size to configuration #14716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UNITTESTS/stubs/connectivity/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ target_compile_definitions(mbed-stubs-connectivity
MBED_CONF_LORA_OVER_THE_AIR_ACTIVATION=true
MBED_CONF_LORA_AUTOMATIC_UPLINK_MESSAGE=true
MBED_CONF_LORA_TX_MAX_SIZE=255
MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
MDMTXD=NC
MDMRXD=NC
)
Expand Down
10 changes: 4 additions & 6 deletions connectivity/cellular/include/cellular/framework/API/ATHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ class FileHandle;
extern const char *OK;
extern const char *CRLF;

#define BUFF_SIZE 32

/* AT Error types enumeration */
enum DeviceErrorType {
DeviceErrorTypeNoError = 0,
Expand Down Expand Up @@ -114,7 +112,7 @@ class ATHandler {

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

// should fit any prefix and int
char _recv_buff[BUFF_SIZE];
char _recv_buff[MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE];
// reading position
size_t _recv_len;
// reading length
Expand Down Expand Up @@ -630,7 +628,7 @@ class ATHandler {
size_t _max_resp_length;

// prefix set during resp_start and used to try matching possible information responses
char _info_resp_prefix[BUFF_SIZE];
char _info_resp_prefix[MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE];
bool _debug_on;
bool _cmd_start;
bool _use_delimiter;
Expand All @@ -640,7 +638,7 @@ class ATHandler {
// eventqueue event id
int _event_id;

char _cmd_buffer[BUFF_SIZE];
char _cmd_buffer[MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE];
};

} // namespace mbed
Expand Down
4 changes: 4 additions & 0 deletions connectivity/cellular/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
"plmn-fallback-auto" : {
"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",
"value": null
},
"at-handler-buffer-size" : {
"help": "Size of the AT handler buffer",
"value": 32
}
}
}
8 changes: 4 additions & 4 deletions connectivity/cellular/source/framework/device/ATHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ int32_t ATHandler::read_int()
return -1;
}

char buff[BUFF_SIZE];
char buff[MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE];
if (read_string(buff, sizeof(buff)) == 0) {
return -1;
}
Expand Down Expand Up @@ -960,7 +960,7 @@ void ATHandler::resp_start(const char *prefix, bool stop)
(void)fill_buffer(false);

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

Expand Down Expand Up @@ -1225,7 +1225,7 @@ void ATHandler::handle_start(const char *cmd, const char *cmd_chr)
if (cmd_chr) {
cmd_char_len = strlen(cmd_chr);
}
MBED_ASSERT((3 + strlen(cmd) + cmd_char_len) < BUFF_SIZE);
MBED_ASSERT((3 + strlen(cmd) + cmd_char_len) < MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE);

memcpy(_cmd_buffer + len, cmd, strlen(cmd));
len += strlen(cmd);
Expand Down Expand Up @@ -1258,7 +1258,7 @@ void ATHandler::cmd_start_stop(const char *cmd, const char *cmd_chr, const char

nsapi_error_t ATHandler::at_cmd_str(const char *cmd, const char *cmd_chr, char *resp_buf, size_t buf_size, const char *format, ...)
{
MBED_ASSERT(strlen(cmd) < BUFF_SIZE);
MBED_ASSERT(strlen(cmd) < MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE);
lock();

handle_start(cmd, cmd_chr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ target_compile_definitions(${TEST_NAME}
MBED_CONF_CELLULAR_USE_SMS=1
MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN=NULL
MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
)

target_sources(${TEST_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ target_compile_definitions(${TEST_NAME}
MDMRXD=NC
MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
MBED_CONF_CELLULAR_USE_SMS=1
MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
)

target_sources(${TEST_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target_compile_definitions(${TEST_NAME}
DEVICE_SERIAL=1
DEVICE_INTERRUPTIN=1
MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
)

target_sources(${TEST_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target_compile_definitions(${TEST_NAME}
DEVICE_SERIAL=1
DEVICE_INTERRUPTIN=1
MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
)

target_sources(${TEST_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ target_compile_definitions(${TEST_NAME}
DEVICE_INTERRUPTIN=1
MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
MBED_CONF_CELLULAR_USE_SMS=1
MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
)

target_sources(${TEST_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target_compile_definitions(${TEST_NAME}
DEVICE_SERIAL=1
DEVICE_INTERRUPTIN=1
MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
)

target_sources(${TEST_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ target_compile_definitions(${TEST_NAME}
DEVICE_SERIAL=1
DEVICE_INTERRUPTIN=1
MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
)

target_sources(${TEST_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ target_compile_definitions(${TEST_NAME}
DEVICE_SERIAL=1
DEVICE_INTERRUPTIN=1
MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
)

target_sources(${TEST_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ target_compile_definitions(${TEST_NAME}
DEVICE_SERIAL=1
DEVICE_INTERRUPTIN=1
MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
)

target_sources(${TEST_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ target_compile_definitions(${TEST_NAME}
DEVICE_SERIAL=1
DEVICE_INTERRUPTIN=1
MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200
MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
)

target_sources(${TEST_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ target_compile_definitions(${TEST_NAME}
DEVICE_SERIAL=1
DEVICE_INTERRUPTIN=1
MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200

MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE=32
)

target_sources(${TEST_NAME}
Expand Down