File tree Expand file tree Collapse file tree 3 files changed +24
-5
lines changed
components/wifi/esp8266-driver Expand file tree Collapse file tree 3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -1114,6 +1114,13 @@ int8_t ESP8266::default_wifi_mode()
1114
1114
return 0 ;
1115
1115
}
1116
1116
1117
+ void ESP8266::flush ()
1118
+ {
1119
+ _smutex.lock ();
1120
+ _parser.flush ();
1121
+ _smutex.unlock ();
1122
+ }
1123
+
1117
1124
bool ESP8266::set_default_wifi_mode (const int8_t mode)
1118
1125
{
1119
1126
_smutex.lock ();
Original file line number Diff line number Diff line change @@ -367,6 +367,15 @@ class ESP8266 {
367
367
*/
368
368
void bg_process_oob (uint32_t timeout, bool all);
369
369
370
+ /* *
371
+ * Flush the serial port input buffers.
372
+ *
373
+ * If you do HW reset for ESP module, you should
374
+ * flush the input buffers from existing responses
375
+ * from the device.
376
+ */
377
+ void flush ();
378
+
370
379
static const int8_t WIFIMODE_STATION = 1 ;
371
380
static const int8_t WIFIMODE_SOFTAP = 2 ;
372
381
static const int8_t WIFIMODE_STATION_SOFTAP = 3 ;
Original file line number Diff line number Diff line change @@ -368,11 +368,14 @@ nsapi_error_t ESP8266Interface::_init(void)
368
368
369
369
void ESP8266Interface::_hw_reset ()
370
370
{
371
- _rst_pin.rst_assert ();
372
- // If you happen to use Pin7 CH_EN as reset pin, not needed otherwise
373
- // https://www.espressif.com/sites/default/files/documentation/esp8266_hardware_design_guidelines_en.pdf
374
- wait_ms (2 ); // Documentation says 200 us should have been enough, but experimentation shows that 1ms was not enough
375
- _rst_pin.rst_deassert ();
371
+ if (_rst_pin.is_connected ()) {
372
+ _rst_pin.rst_assert ();
373
+ // If you happen to use Pin7 CH_EN as reset pin, not needed otherwise
374
+ // https://www.espressif.com/sites/default/files/documentation/esp8266_hardware_design_guidelines_en.pdf
375
+ wait_ms (2 ); // Documentation says 200 us should have been enough, but experimentation shows that 1ms was not enough
376
+ _esp.flush ();
377
+ _rst_pin.rst_deassert ();
378
+ }
376
379
}
377
380
378
381
struct esp8266_socket {
You can’t perform that action at this time.
0 commit comments