Skip to content

Commit 447cfbc

Browse files
authored
Merge pull request #12804 from kivaisan/check_serial_for_set_baud_rate
Cellular: Check if serial is supported
2 parents 9ffc5bc + 214df55 commit 447cfbc

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

features/cellular/framework/AT/AT_CellularDevice.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,10 @@ nsapi_error_t AT_CellularDevice::clear()
598598

599599
nsapi_error_t AT_CellularDevice::set_baud_rate(int baud_rate)
600600
{
601-
nsapi_error_t error = set_baud_rate_impl(baud_rate);
601+
nsapi_error_t error;
602+
603+
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN)
604+
error = set_baud_rate_impl(baud_rate);
602605

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

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

613622
return error;
614623
}

features/cellular/framework/device/ATHandler.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,9 @@ void ATHandler::write_hex_string(const char *str, size_t size)
15471547

15481548
void ATHandler::set_baud(int baud_rate)
15491549
{
1550+
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN)
15501551
static_cast<BufferedSerial *>(_fileHandle)->set_baud(baud_rate);
1552+
#else
1553+
tr_error("Device does not support BufferedSerial");
1554+
#endif
15511555
}
1552-

0 commit comments

Comments
 (0)