example: Scan failure should not cause system crash

This commit is contained in:
xiehang
2021-01-15 19:45:59 +08:00
parent 2f4ef71beb
commit 3590a6816f
5 changed files with 7 additions and 7 deletions

View File

@@ -350,7 +350,7 @@ static void example_event_callback(esp_blufi_cb_event_t event, esp_blufi_cb_para
.channel = 0, .channel = 0,
.show_hidden = false .show_hidden = false
}; };
ESP_ERROR_CHECK(esp_wifi_scan_start(&scanConf, true)); esp_wifi_scan_start(&scanConf, true);
break; break;
} }
case ESP_BLUFI_EVENT_RECV_CUSTOM_DATA: case ESP_BLUFI_EVENT_RECV_CUSTOM_DATA:

View File

@@ -175,7 +175,7 @@ static bool wifi_cmd_sta_scan(const char *ssid)
scan_config.ssid = (uint8_t *) ssid; scan_config.ssid = (uint8_t *) ssid;
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) ); ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
ESP_ERROR_CHECK( esp_wifi_scan_start(&scan_config, false) ); esp_wifi_scan_start(&scan_config, false);
return true; return true;
} }

View File

@@ -152,7 +152,7 @@ void mesh_scan_done_handler(int num)
esp_wifi_scan_stop(); esp_wifi_scan_stop();
scan_config.show_hidden = 1; scan_config.show_hidden = 1;
scan_config.scan_type = WIFI_SCAN_TYPE_PASSIVE; scan_config.scan_type = WIFI_SCAN_TYPE_PASSIVE;
ESP_ERROR_CHECK(esp_wifi_scan_start(&scan_config, 0)); esp_wifi_scan_start(&scan_config, 0);
} }
} }
@@ -173,7 +173,7 @@ void mesh_event_handler(mesh_event_t event)
/* mesh softAP is hidden */ /* mesh softAP is hidden */
scan_config.show_hidden = 1; scan_config.show_hidden = 1;
scan_config.scan_type = WIFI_SCAN_TYPE_PASSIVE; scan_config.scan_type = WIFI_SCAN_TYPE_PASSIVE;
ESP_ERROR_CHECK(esp_wifi_scan_start(&scan_config, 0)); esp_wifi_scan_start(&scan_config, 0);
break; break;
case MESH_EVENT_STOPPED: case MESH_EVENT_STOPPED:
ESP_LOGI(MESH_TAG, "<MESH_EVENT_STOPPED>"); ESP_LOGI(MESH_TAG, "<MESH_EVENT_STOPPED>");
@@ -229,7 +229,7 @@ void mesh_event_handler(mesh_event_t event)
esp_wifi_scan_stop(); esp_wifi_scan_stop();
scan_config.show_hidden = 1; scan_config.show_hidden = 1;
scan_config.scan_type = WIFI_SCAN_TYPE_PASSIVE; scan_config.scan_type = WIFI_SCAN_TYPE_PASSIVE;
ESP_ERROR_CHECK(esp_wifi_scan_start(&scan_config, 0)); esp_wifi_scan_start(&scan_config, 0);
} }
break; break;
case MESH_EVENT_LAYER_CHANGE: case MESH_EVENT_LAYER_CHANGE:

View File

@@ -169,7 +169,7 @@ static bool wifi_cmd_sta_scan(const char* ssid)
scan_config.ssid = (uint8_t *) ssid; scan_config.ssid = (uint8_t *) ssid;
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) ); ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
ESP_ERROR_CHECK( esp_wifi_scan_start(&scan_config, false) ); esp_wifi_scan_start(&scan_config, false);
return true; return true;
} }

View File

@@ -147,7 +147,7 @@ static void init_wifi(void)
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_start()); ESP_ERROR_CHECK(esp_wifi_start());
ESP_ERROR_CHECK(esp_wifi_scan_start(NULL, true)); esp_wifi_scan_start(NULL, true);
while (1) { while (1) {
if (got_scan_done_event == true) { if (got_scan_done_event == true) {