diff --git a/hal/src/photon/wlan_hal.cpp b/hal/src/photon/wlan_hal.cpp index 6f7baf11c3..f6db64400f 100644 --- a/hal/src/photon/wlan_hal.cpp +++ b/hal/src/photon/wlan_hal.cpp @@ -856,6 +856,10 @@ wiced_result_t sniffer( wiced_scan_handler_result_t* malloced_scan_result ) wiced_result_t sniff_security(SnifferInfo* info) { + if (!wiced_wlan_connectivity_initialized()) + { + return WICED_ERROR; + } wiced_result_t result = wiced_rtos_init_semaphore(&info->complete); if (result != WICED_SUCCESS) diff --git a/user/tests/wiring/no_fixture/wifi.cpp b/user/tests/wiring/no_fixture/wifi.cpp index 6d2b6d837e..c5a24f6b43 100644 --- a/user/tests/wiring/no_fixture/wifi.cpp +++ b/user/tests/wiring/no_fixture/wifi.cpp @@ -196,4 +196,25 @@ test(WIFI_10_restore_default_hostname) #endif // PLATFORM_ID == 6 || PLATFORM_ID == 8 +test(WIFI_11_scan_returns_zero_result_or_error_when_wifi_is_off) +{ + WiFiAccessPoint results[5]; + WiFi.off(); + uint32_t ms = millis(); + while (WiFi.ready()) { + if (millis() - ms >= 10000) { + assertTrue(false); + } + } + assertLessOrEqual(WiFi.scan(results, 5), 0); +} + +test(WIFI_12_restore_connection) +{ + if (!Particle.connected()) + { + Particle.connect(); + } +} + #endif