Skip to content

Commit 240ae5e

Browse files
dok-netd-a-v
authored andcommitted
Add/unify comments for target and source sites of async scheduling via delay()/esp_yield()/esp_schedule() (#6780)
1 parent 05454df commit 240ae5e

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ int ESP8266WiFiGenericClass::hostByName(const char* aHostname, IPAddress& aResul
623623
} else if(err == ERR_INPROGRESS) {
624624
_dns_lookup_pending = true;
625625
delay(timeout_ms);
626+
// will resume on timeout or when wifi_dns_found_callback fires
626627
_dns_lookup_pending = false;
627628
// will return here when dns_found_callback fires
628629
if(aResult.isSet()) {
@@ -654,7 +655,7 @@ void wifi_dns_found_callback(const char *name, CONST ip_addr_t *ipaddr, void *ca
654655
if(ipaddr) {
655656
(*reinterpret_cast<IPAddress*>(callback_arg)) = IPAddress(ipaddr);
656657
}
657-
esp_schedule(); // resume the hostByName function
658+
esp_schedule(); // break delay in hostByName
658659
}
659660

660661
uint32_t ESP8266WiFiGenericClass::shutdownCRC (const WiFiState* state)

libraries/ESP8266WiFi/src/ESP8266WiFiSTA-WPS.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ bool ESP8266WiFiSTAClass::beginWPSConfig(void) {
7171
}
7272

7373
esp_yield();
74-
// will return here when wifi_wps_status_cb fires
74+
// will resume when wifi_wps_status_cb fires
7575

7676
return true;
7777
}
@@ -107,5 +107,5 @@ void wifi_wps_status_cb(wps_cb_status status) {
107107
}
108108
// TODO user function to get status
109109

110-
esp_schedule(); // resume the beginWPSConfig function
110+
esp_schedule(); // resume beginWPSConfig
111111
}

libraries/ESP8266WiFi/src/ESP8266WiFiScan.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ int8_t ESP8266WiFiScanClass::scanNetworks(bool async, bool show_hidden, uint8 ch
9898
return WIFI_SCAN_RUNNING;
9999
}
100100

101-
esp_yield();
101+
esp_yield(); // will resume when _scanDone fires
102102
return ESP8266WiFiScanClass::_scanCount;
103103
} else {
104104
return WIFI_SCAN_FAILED;
@@ -323,7 +323,7 @@ void ESP8266WiFiScanClass::_scanDone(void* result, int status) {
323323
ESP8266WiFiScanClass::_scanComplete = true;
324324

325325
if(!ESP8266WiFiScanClass::_scanAsync) {
326-
esp_schedule();
326+
esp_schedule(); // resume scanNetworks
327327
} else if (ESP8266WiFiScanClass::_onComplete) {
328328
ESP8266WiFiScanClass::_onComplete(ESP8266WiFiScanClass::_scanCount);
329329
ESP8266WiFiScanClass::_onComplete = nullptr;

libraries/ESP8266WiFi/src/include/ClientContext.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ class ClientContext
130130
}
131131
_connect_pending = true;
132132
_op_start_time = millis();
133-
// Following delay will be interrupted by connect callback
134133
for (decltype(_timeout_ms) i = 0; _connect_pending && i < _timeout_ms; i++) {
135134
// Give scheduled functions a chance to run (e.g. Ethernet uses recurrent)
136135
delay(1);
136+
// will resume on timeout or when _connected or _notify_error fires
137137
}
138138
_connect_pending = false;
139139
if (!_pcb) {
@@ -435,7 +435,7 @@ class ClientContext
435435
if (_connect_pending || _send_waiting) {
436436
_send_waiting = false;
437437
_connect_pending = false;
438-
esp_schedule(); // break current delay()
438+
esp_schedule(); // break delay in connect or _write_from_source
439439
}
440440
}
441441

@@ -461,10 +461,11 @@ class ClientContext
461461
}
462462

463463
_send_waiting = true;
464-
// Following delay will be interrupted by on next received ack
465464
for (decltype(_timeout_ms) i = 0; _send_waiting && i < _timeout_ms; i++) {
466465
// Give scheduled functions a chance to run (e.g. Ethernet uses recurrent)
467466
delay(1);
467+
// will resume on timeout or when _write_some_from_cb or _notify_error fires
468+
468469
}
469470
_send_waiting = false;
470471
} while(true);
@@ -536,7 +537,7 @@ class ClientContext
536537
{
537538
if (_send_waiting) {
538539
_send_waiting = false;
539-
esp_schedule(); // break current delay()
540+
esp_schedule(); // break delay in _write_from_source
540541
}
541542
}
542543

@@ -612,7 +613,7 @@ class ClientContext
612613
assert(pcb == _pcb);
613614
if (_connect_pending) {
614615
_connect_pending = false;
615-
esp_schedule(); // break current delay()
616+
esp_schedule(); // break delay in connect
616617
}
617618
return ERR_OK;
618619
}

0 commit comments

Comments
 (0)