Skip to content

Commit 214df55

Browse files
author
Kimmo Vaisanen
committed
Cellular: Check if serial is supported
Baud rate can be only changed if BufferedSerial (or Serial in general) object is supported
1 parent 64bc9d9 commit 214df55

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
@@ -1545,6 +1545,9 @@ void ATHandler::write_hex_string(const char *str, size_t size)
15451545

15461546
void ATHandler::set_baud(int baud_rate)
15471547
{
1548+
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN)
15481549
static_cast<BufferedSerial *>(_fileHandle)->set_baud(baud_rate);
1550+
#else
1551+
tr_error("Device does not support BufferedSerial");
1552+
#endif
15491553
}
1550-

0 commit comments

Comments
 (0)