|
35 | 35 | #include "esp3d_values.h"
|
36 | 36 | #include "translations/esp3d_translation_service.h"
|
37 | 37 |
|
| 38 | +#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_OPEN |
| 39 | +#if ESP3D_WIFI_FEATURE |
| 40 | +#define WIFI_CONNECTED_BIT BIT0 |
| 41 | +#define WIFI_FAIL_BIT BIT1 |
| 42 | +#define WIFI_STA_LOST_IP BIT2 |
| 43 | +#define MIN_RSSI -78 |
| 44 | +#define ESP3D_STA_MAXIMUM_RETRY 10 |
| 45 | +#endif // ESP3D_WIFI_FEATURE |
| 46 | + |
38 | 47 | ESP3DNetwork esp3dNetwork;
|
39 | 48 |
|
40 | 49 | /* The event group allows multiple bits for each event, but we only care about
|
41 | 50 | * two events:
|
42 | 51 | * - we are connected to the AP with an IP
|
43 | 52 | * - we failed to connect after the maximum amount of retries */
|
44 | 53 | #if ESP3D_WIFI_FEATURE
|
45 |
| -#define WIFI_CONNECTED_BIT BIT0 |
46 |
| -#define WIFI_FAIL_BIT BIT1 |
47 |
| -#define WIFI_STA_LOST_IP BIT2 |
48 |
| - |
49 |
| -#define MIN_RSSI -78 |
50 |
| -#define ESP3D_STA_MAXIMUM_RETRY 10 |
51 | 54 |
|
52 | 55 | static void wifi_ap_event_handler(void* arg, esp_event_base_t event_base,
|
53 | 56 | int32_t event_id, void* event_data) {
|
@@ -365,6 +368,7 @@ bool ESP3DNetwork::startStaMode() {
|
365 | 368 | ipMode == static_cast<uint8_t>(ESP3DIpMode::staticIp) ? "Static"
|
366 | 369 | : "DHCP");
|
367 | 370 | wifi_config_t wifi_config;
|
| 371 | + memset(&wifi_config, 0, sizeof(wifi_config_t)); |
368 | 372 | strcpy((char*)wifi_config.sta.ssid, ssid_str);
|
369 | 373 | strcpy((char*)wifi_config.sta.password, ssid_pwd_str);
|
370 | 374 | wifi_config.sta.threshold.authmode = WIFI_AUTH_OPEN;
|
@@ -438,9 +442,10 @@ bool ESP3DNetwork::startStaMode() {
|
438 | 442 | netbiosns_set_name(_hostname.c_str());
|
439 | 443 | ESP_ERROR_CHECK(esp_wifi_start());
|
440 | 444 | _current_radio_mode = ESP3DRadioMode::wifi_sta;
|
441 |
| - /* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or |
442 |
| - * connection failed for the maximum number of re-tries (WIFI_FAIL_BIT). The |
443 |
| - * bits are set by event_handler() (see above) */ |
| 445 | + |
| 446 | + // Waiting until either the connection is established (WIFI_CONNECTED_BIT) or |
| 447 | + // connection failed for the maximum number of re-tries (WIFI_FAIL_BIT). The |
| 448 | + // bits are set by event_handler() (see above) |
444 | 449 | EventBits_t bits = xEventGroupWaitBits(_s_wifi_event_group,
|
445 | 450 | WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
|
446 | 451 | pdFALSE, pdFALSE, portMAX_DELAY);
|
|
0 commit comments