Skip to content

Cellular: Check if serial is supported #12804

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
Apr 15, 2020
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
11 changes: 10 additions & 1 deletion features/cellular/framework/AT/AT_CellularDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,10 @@ nsapi_error_t AT_CellularDevice::clear()

nsapi_error_t AT_CellularDevice::set_baud_rate(int baud_rate)
{
nsapi_error_t error = set_baud_rate_impl(baud_rate);
nsapi_error_t error;

#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN)
error = set_baud_rate_impl(baud_rate);

if (error) {
tr_warning("Baudrate was not changed to desired value: %d", baud_rate);
Expand All @@ -609,6 +612,12 @@ nsapi_error_t AT_CellularDevice::set_baud_rate(int baud_rate)

// Give some time before starting using the UART with the new baud rate
rtos::ThisThread::sleep_for(3000);
#else
// Currently ATHandler only supports BufferedSerial based communication and
// if serial is disabled, baud rate cannot be set
tr_warn("set_baud_rate: Serial not supported");
error = NSAPI_ERROR_UNSUPPORTED;
#endif

return error;
}
Expand Down
5 changes: 4 additions & 1 deletion features/cellular/framework/device/ATHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,9 @@ void ATHandler::write_hex_string(const char *str, size_t size)

void ATHandler::set_baud(int baud_rate)
{
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN)
static_cast<BufferedSerial *>(_fileHandle)->set_baud(baud_rate);
#else
tr_error("Device does not support BufferedSerial");
#endif
}