Unable to scan for WiFi Networks

When using WiFi.h. I am unable to use its scanNetworks function like this - WiFi.ScanNetworks(); I am using the unPhone 9 building through platformio. Everything else works, its just when I try to scan the network. I have also attached the serial monitor output: ESP-ROM:esp32s3-20210327Build:Mar 27 2021rst:0xc (RTC_SW_CPU_RST),boot:0x2b - Pastebin.com

I have tried two methods:

// WiFi Page
void wifiPage()
{
  int n = WiFi.scanNetworks();
...
}

and also this, where it was non-blocking.

    void scanNetworks()
    {
        Serial.println("Scanning for WiFi networks...");
        WiFi.scanNetworks(true);

        unsigned long scanStar = millis();

        int scanResult = WIFI_SCAN_RUNNING;

        while (scanResult == WIFI_SCAN_RUNNING)
        {
            scanResult = WiFi.scanComplete();

            delay(100);
            yield();

            if (millis() - scanStar > 10000)
            {
                Serial.println("Scan timed out");
                WiFi.scanDelete();
                return;
            }
        }
...

The error in the serial output is that a task timed out (and triggered the WDT watchdog). It reports this in async_tcp I think. What happens if you don’t run that code, just the WiFi scan networks code? HTH, H

Hey Hamish,

thanks for your response, it was heplful! I ended up changing the task watchdog settings to this (importantly to not panic, through the false flag)
esp_task_wdt_init(1000, false)