Skip to content

Commit eb3deb0

Browse files
author
Veijo Pesonen
committed
fixup! Initial UART HW flow control support
1 parent 28552b8 commit eb3deb0

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

ESP8266/ESP8266.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ int ESP8266::get_firmware_version()
7575
}
7676
}
7777

78+
bool ESP8266::stop_uart_hw_flow_ctrl(void)
79+
{
80+
// Stop board's flow control
81+
_serial.set_flow_control(SerialBase::Disabled, _serial_rts, _serial_cts);
82+
83+
// Stop ESP8266's flow control
84+
bool done = _parser.send("AT+UART_CUR=%u,8,1,0,0", ESP8266_DEFAULT_BAUD_RATE)
85+
&& _parser.recv("OK\n");
86+
87+
return done;
88+
}
89+
7890
bool ESP8266::start_uart_hw_flow_ctrl(void)
7991
{
8092
bool done = true;

ESP8266/ESP8266.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@ class ESP8266
272272
*/
273273
bool start_uart_hw_flow_ctrl();
274274

275+
/**
276+
* Stop board's and ESP8266's UART flow control
277+
*
278+
* @return true if started
279+
*/
280+
bool stop_uart_hw_flow_ctrl();
281+
275282
static const int8_t WIFIMODE_STATION = 1;
276283
static const int8_t WIFIMODE_SOFTAP = 2;
277284
static const int8_t WIFIMODE_STATION_SOFTAP = 3;

ESP8266Interface.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,15 @@ bool ESP8266Interface::_disable_default_softap()
267267
nsapi_error_t ESP8266Interface::_init(void)
268268
{
269269
if (!_initialized) {
270-
if (!_esp.start_uart_hw_flow_ctrl()) {
270+
if (!_esp.stop_uart_hw_flow_ctrl()) {
271271
return NSAPI_ERROR_DEVICE_ERROR;
272272
}
273273
if (!_esp.reset()) {
274274
return NSAPI_ERROR_DEVICE_ERROR;
275275
}
276+
if (!_esp.start_uart_hw_flow_ctrl()) {
277+
return NSAPI_ERROR_DEVICE_ERROR;
278+
}
276279
if (!_get_firmware_ok()) {
277280
return NSAPI_ERROR_DEVICE_ERROR;
278281
}

0 commit comments

Comments
 (0)