mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #15240 from OpenNuvoton/nuvoton_esp8266_flow_control_reconnect
ESP8266: Fix serial flow control inconsistency on reconnectpull/15249/head
commit
170aea5932
|
@ -193,7 +193,7 @@ struct ESP8266::fw_at_version ESP8266::at_version()
|
||||||
return _at_v;
|
return _at_v;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ESP8266::stop_uart_hw_flow_ctrl(void)
|
bool ESP8266::stop_uart_hw_flow_ctrl(bool board_only)
|
||||||
{
|
{
|
||||||
bool done = true;
|
bool done = true;
|
||||||
#if DEVICE_SERIAL_FC
|
#if DEVICE_SERIAL_FC
|
||||||
|
@ -202,10 +202,12 @@ bool ESP8266::stop_uart_hw_flow_ctrl(void)
|
||||||
// Stop board's flow control
|
// Stop board's flow control
|
||||||
_serial.set_flow_control(SerialBase::Disabled, _serial_rts, _serial_cts);
|
_serial.set_flow_control(SerialBase::Disabled, _serial_rts, _serial_cts);
|
||||||
|
|
||||||
|
if (!board_only) {
|
||||||
// Stop ESP8266's flow control
|
// Stop ESP8266's flow control
|
||||||
done = _parser.send("AT+UART_CUR=%u,8,1,0,0", MBED_CONF_ESP8266_SERIAL_BAUDRATE)
|
done = _parser.send("AT+UART_CUR=%u,8,1,0,0", MBED_CONF_ESP8266_SERIAL_BAUDRATE)
|
||||||
&& _parser.recv("OK\n");
|
&& _parser.recv("OK\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
return done;
|
return done;
|
||||||
|
|
|
@ -455,9 +455,10 @@ public:
|
||||||
/**
|
/**
|
||||||
* Stop board's and ESP8266's UART flow control
|
* Stop board's and ESP8266's UART flow control
|
||||||
*
|
*
|
||||||
|
* @param board_only true to apply to board only, false to apply both
|
||||||
* @return true if started
|
* @return true if started
|
||||||
*/
|
*/
|
||||||
bool stop_uart_hw_flow_ctrl();
|
bool stop_uart_hw_flow_ctrl(bool board_only = false);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* From AT firmware v1.7.0.0 onwards enables TCP passive mode
|
* From AT firmware v1.7.0.0 onwards enables TCP passive mode
|
||||||
|
|
|
@ -722,8 +722,14 @@ bool ESP8266Interface::_get_firmware_ok()
|
||||||
nsapi_error_t ESP8266Interface::_init(void)
|
nsapi_error_t ESP8266Interface::_init(void)
|
||||||
{
|
{
|
||||||
if (!_initialized) {
|
if (!_initialized) {
|
||||||
|
if (_pwr_pin.is_connected()) {
|
||||||
_pwr_pin.power_off();
|
_pwr_pin.power_off();
|
||||||
_pwr_pin.power_on();
|
_pwr_pin.power_on();
|
||||||
|
/* Align board's serial flow control with ESP8266's, resetting to disabled on re-power or reset */
|
||||||
|
if (!_esp.stop_uart_hw_flow_ctrl(true)) {
|
||||||
|
return NSAPI_ERROR_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_reset() != NSAPI_ERROR_OK) {
|
if (_reset() != NSAPI_ERROR_OK) {
|
||||||
return NSAPI_ERROR_DEVICE_ERROR;
|
return NSAPI_ERROR_DEVICE_ERROR;
|
||||||
|
@ -780,6 +786,10 @@ nsapi_error_t ESP8266Interface::_reset()
|
||||||
ThisThread::sleep_for(delay);
|
ThisThread::sleep_for(delay);
|
||||||
_esp.flush();
|
_esp.flush();
|
||||||
_rst_pin.rst_deassert();
|
_rst_pin.rst_deassert();
|
||||||
|
/* Align board's serial flow control with ESP8266's, resetting to disabled on re-power or reset */
|
||||||
|
if (!_esp.stop_uart_hw_flow_ctrl(true)) {
|
||||||
|
return NSAPI_ERROR_DEVICE_ERROR;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_esp.flush();
|
_esp.flush();
|
||||||
if (!_esp.at_available()) {
|
if (!_esp.at_available()) {
|
||||||
|
|
Loading…
Reference in New Issue