mirror of https://github.com/ARMmbed/mbed-os.git
Cellular: Added set routine for baud rate
parent
cbf9f0650b
commit
c484fc88f9
|
|
@ -25,6 +25,8 @@ set(unittest-test-sources
|
||||||
stubs/EventQueue_stub.cpp
|
stubs/EventQueue_stub.cpp
|
||||||
stubs/FileHandle_stub.cpp
|
stubs/FileHandle_stub.cpp
|
||||||
stubs/us_ticker_stub.cpp
|
stubs/us_ticker_stub.cpp
|
||||||
|
stubs/UARTSerial_stub.cpp
|
||||||
|
stubs/SerialBase_stub.cpp
|
||||||
stubs/mbed_assert_stub.c
|
stubs/mbed_assert_stub.c
|
||||||
stubs/mbed_poll_stub.cpp
|
stubs/mbed_poll_stub.cpp
|
||||||
stubs/Timer_stub.cpp
|
stubs/Timer_stub.cpp
|
||||||
|
|
|
||||||
|
|
@ -418,3 +418,7 @@ void ATHandler::set_send_delay(uint16_t send_delay)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ATHandler::set_baud(int baud_rate)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -261,3 +261,13 @@ nsapi_error_t AT_CellularDevice::clear()
|
||||||
{
|
{
|
||||||
return NSAPI_ERROR_OK;
|
return NSAPI_ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsapi_error_t AT_CellularDevice::set_baud_rate(int baud_rate)
|
||||||
|
{
|
||||||
|
return NSAPI_ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsapi_error_t AT_CellularDevice::set_baud_rate_impl(int baud_rate)
|
||||||
|
{
|
||||||
|
return NSAPI_ERROR_OK;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -176,6 +176,10 @@ public:
|
||||||
{
|
{
|
||||||
return NSAPI_ERROR_OK;
|
return NSAPI_ERROR_OK;
|
||||||
}
|
}
|
||||||
|
nsapi_error_t set_baud_rate(int baud_rate)
|
||||||
|
{
|
||||||
|
return NSAPI_ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
void verify_timeout_array(const uint16_t timeout[], int array_len)
|
void verify_timeout_array(const uint16_t timeout[], int array_len)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -443,6 +443,13 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual nsapi_error_t release_at_handler(ATHandler *at_handler) = 0;
|
virtual nsapi_error_t release_at_handler(ATHandler *at_handler) = 0;
|
||||||
|
|
||||||
|
/** Sets cellular modem to given baud rate
|
||||||
|
*
|
||||||
|
* @param baud_rate
|
||||||
|
* @return NSAPI_ERROR_OK on success, NSAPI_ERROR_DEVICE_ERROR on failure
|
||||||
|
*/
|
||||||
|
virtual nsapi_error_t set_baud_rate(int baud_rate) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class AT_CellularNetwork;
|
friend class AT_CellularNetwork;
|
||||||
friend class AT_CellularContext;
|
friend class AT_CellularContext;
|
||||||
|
|
|
||||||
|
|
@ -1612,3 +1612,9 @@ void ATHandler::write_hex_string(char *str, size_t size)
|
||||||
write(hexbuf, 2);
|
write(hexbuf, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ATHandler::set_baud(int baud_rate)
|
||||||
|
{
|
||||||
|
static_cast<UARTSerial *>(_fileHandle)->set_baud(baud_rate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@
|
||||||
|
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
|
|
||||||
|
#include "UARTSerial.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If application calls associated FileHandle only from single thread context
|
* If application calls associated FileHandle only from single thread context
|
||||||
* then locking between AT command and response is not needed. However,
|
* then locking between AT command and response is not needed. However,
|
||||||
|
|
@ -219,6 +221,12 @@ public:
|
||||||
*/
|
*/
|
||||||
void set_send_delay(uint16_t send_delay);
|
void set_send_delay(uint16_t send_delay);
|
||||||
|
|
||||||
|
/** Sets UARTSerial filehandle to given baud rate
|
||||||
|
*
|
||||||
|
* @param baud_rate
|
||||||
|
*/
|
||||||
|
void set_baud(int baud_rate);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void event();
|
void event();
|
||||||
#if defined AT_HANDLER_MUTEX && defined MBED_CONF_RTOS_PRESENT
|
#if defined AT_HANDLER_MUTEX && defined MBED_CONF_RTOS_PRESENT
|
||||||
|
|
|
||||||
|
|
@ -635,3 +635,25 @@ nsapi_error_t AT_CellularDevice::clear()
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsapi_error_t AT_CellularDevice::set_baud_rate(int baud_rate)
|
||||||
|
{
|
||||||
|
nsapi_error_t error = set_baud_rate_impl(baud_rate);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
tr_warning("Baudrate was not changed to desired value: %d", baud_rate);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
_at->set_baud(baud_rate);
|
||||||
|
|
||||||
|
// Give some time before starting using the UART with the new baud rate
|
||||||
|
rtos::ThisThread::sleep_for(3000);
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsapi_error_t AT_CellularDevice::set_baud_rate_impl(int baud_rate)
|
||||||
|
{
|
||||||
|
return _at->at_cmd_discard("+IPR", "=", "%d", baud_rate);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,8 @@ public:
|
||||||
|
|
||||||
virtual CellularContext *get_context_list() const;
|
virtual CellularContext *get_context_list() const;
|
||||||
|
|
||||||
|
virtual nsapi_error_t set_baud_rate(int baud_rate);
|
||||||
|
|
||||||
AT_CellularNetwork *_network;
|
AT_CellularNetwork *_network;
|
||||||
AT_CellularSMS *_sms;
|
AT_CellularSMS *_sms;
|
||||||
AT_CellularInformation *_information;
|
AT_CellularInformation *_information;
|
||||||
|
|
@ -153,6 +155,7 @@ protected:
|
||||||
// Sets up parameters for AT handler, for now only the send delay and URCs.
|
// Sets up parameters for AT handler, for now only the send delay and URCs.
|
||||||
// This kind of routine is needed for initialisation routines that are virtual and therefore cannot be called from constructor.
|
// This kind of routine is needed for initialisation routines that are virtual and therefore cannot be called from constructor.
|
||||||
void setup_at_handler();
|
void setup_at_handler();
|
||||||
|
virtual nsapi_error_t set_baud_rate_impl(int baud_rate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void urc_nw_deact();
|
void urc_nw_deact();
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,11 @@ nsapi_error_t QUECTEL_BC95::init()
|
||||||
return _at->unlock_return_error();
|
return _at->unlock_return_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsapi_error_t QUECTEL_BC95::set_baud_rate_impl(int baud_rate)
|
||||||
|
{
|
||||||
|
return _at->at_cmd_discard("+NATSPEED", "=", "%d%d%d%d%d%d%d", baud_rate, 30, 0, 2, 1, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
#if MBED_CONF_QUECTEL_BC95_PROVIDE_DEFAULT
|
#if MBED_CONF_QUECTEL_BC95_PROVIDE_DEFAULT
|
||||||
#include "UARTSerial.h"
|
#include "UARTSerial.h"
|
||||||
CellularDevice *CellularDevice::get_default_instance()
|
CellularDevice *CellularDevice::get_default_instance()
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ protected: // AT_CellularDevice
|
||||||
virtual AT_CellularNetwork *open_network_impl(ATHandler &at);
|
virtual AT_CellularNetwork *open_network_impl(ATHandler &at);
|
||||||
virtual AT_CellularContext *create_context_impl(ATHandler &at, const char *apn, bool cp_req = false, bool nonip_req = false);
|
virtual AT_CellularContext *create_context_impl(ATHandler &at, const char *apn, bool cp_req = false, bool nonip_req = false);
|
||||||
virtual AT_CellularInformation *open_information_impl(ATHandler &at);
|
virtual AT_CellularInformation *open_information_impl(ATHandler &at);
|
||||||
|
virtual nsapi_error_t set_baud_rate_impl(int baud_rate);
|
||||||
virtual nsapi_error_t init();
|
virtual nsapi_error_t init();
|
||||||
|
|
||||||
public: // NetworkInterface
|
public: // NetworkInterface
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue