Skip to content

Commit

Permalink
Merge pull request esp8266#6869 from dok-net/refactooptimisticyield
Browse files Browse the repository at this point in the history
Minor yield() cleanup: optimistic_yield, proper polledTimeout use
  • Loading branch information
devyte authored May 19, 2021
2 parents 117f163 + 7571c72 commit d7d03f9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion cores/esp8266/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ unsigned long HardwareSerial::detectBaudrate(time_t timeoutMillis)
if ((detectedBaudrate = testBaudrate())) {
break;
}
yield();
delay(100);
}
return detectedBaudrate;
Expand Down
2 changes: 1 addition & 1 deletion cores/esp8266/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void hexdump(const void *mem, uint32_t len, uint8_t cols)
}
src += linesize;
len -= linesize;
yield();
optimistic_yield(10000);
}
os_printf("\n");
}
6 changes: 3 additions & 3 deletions libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,10 @@ int8_t ESP8266WiFiSTAClass::waitForConnectResult(unsigned long timeoutLength) {
if((wifi_get_opmode() & 1) == 0) {
return WL_DISCONNECTED;
}
using esp8266::polledTimeout::oneShot;
oneShot timeout(timeoutLength); // number of milliseconds to wait before returning timeout error
// if probing doesn't trip, this yields
using oneShotYieldMs = esp8266::polledTimeout::timeoutTemplate<false, esp8266::polledTimeout::YieldPolicy::YieldOrSkip>;
oneShotYieldMs timeout(timeoutLength); // number of milliseconds to wait before returning timeout error
while(!timeout) {
yield();
if(status() != WL_DISCONNECTED) {
return status();
}
Expand Down

0 comments on commit d7d03f9

Please sign in to comment.