espressif ping: reduce wait time on failure^
This commit is contained in:
parent
17c4e9c864
commit
a004c1685e
2 changed files with 11 additions and 9 deletions
|
|
@ -554,21 +554,18 @@ mp_int_t common_hal_wifi_radio_ping(wifi_radio_obj_t *self, mp_obj_t ip_address,
|
|||
// ESP-IDF creates a task to do the ping session. It shuts down when done, but only after a one second delay.
|
||||
// Calling common_hal_wifi_radio_ping() too fast will cause resource exhaustion.
|
||||
esp_ping_handle_t ping;
|
||||
esp_err_t ret;
|
||||
for (size_t tries = 1; tries <= 5; tries++) {
|
||||
ret = esp_ping_new_session(&ping_config, &ping_callbacks, &ping);
|
||||
if (ret == ESP_OK) {
|
||||
break;
|
||||
}
|
||||
if (esp_ping_new_session(&ping_config, &ping_callbacks, &ping) != ESP_OK) {
|
||||
// Wait for old task to go away and then try again.
|
||||
// Empirical testing shows we have to wait at least two seconds, despite the task
|
||||
// having a one-second timeout.
|
||||
common_hal_time_delay_ms(2000);
|
||||
// Return if interrupted now, to show the interruption as KeyboardInterrupt instead of the
|
||||
// IDF error.
|
||||
if (mp_hal_is_interrupted()) {
|
||||
return -1;
|
||||
return (uint32_t)(-1);
|
||||
}
|
||||
CHECK_ESP_RESULT(esp_ping_new_session(&ping_config, &ping_callbacks, &ping));
|
||||
}
|
||||
CHECK_ESP_RESULT(ret);
|
||||
|
||||
esp_ping_start(ping);
|
||||
|
||||
|
|
|
|||
|
|
@ -698,7 +698,12 @@ MP_PROPERTY_GETTER(wifi_radio_ap_info_obj,
|
|||
//| self, ip: ipaddress.IPv4Address, *, timeout: Optional[float] = 0.5
|
||||
//| ) -> Optional[float]:
|
||||
//| """Ping an IP to test connectivity. Returns echo time in seconds.
|
||||
//| Returns None when it times out."""
|
||||
//| Returns None when it times out.
|
||||
//|
|
||||
//| **Limitations:** On Espressif, calling `ping()` multiple times rapidly
|
||||
//| exhausts available resources after several calls. Rather than failing at that point, `ping()`
|
||||
//| will wait two seconds for enough resources to be freed up before proceeding.
|
||||
//| """
|
||||
//| ...
|
||||
//|
|
||||
static mp_obj_t wifi_radio_ping(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue