- set wifi to use access point with strongest signal if more than one is found with same SSID

This commit is contained in:
Carlos
2021-10-25 21:11:08 +02:00
Unverified
parent 7b24787e73
commit b65c0f03f9
6 changed files with 68 additions and 94 deletions

View File

@@ -2408,37 +2408,43 @@ player_task (void *pvParameters)
adjust_apll (dir);
}
int64_t t;
get_diff_to_server (&t);
// struct timeval now;
// // get current time
// if (gettimeofday (&now, NULL))
// {
// ESP_LOGE (TAG, "Failed to get time of day");
// }
// int64_t t;
// get_diff_to_server (&t);
//
// // for getting rssi value
// wifi_ap_record_t ap;
// esp_wifi_sta_get_ap_info(&ap);
////
// ESP_LOGI (TAG, "%ld.%ld, rssi: %d, %d,
// %lldus, %lldus %lldus, %d, %d, %d, %d, %d",
// now.tv_sec, now.tv_usec, ap.rssi,
// dir, age, avg, t,
// heap_caps_get_free_size (MALLOC_CAP_8BIT),
// heap_caps_get_largest_free_block
// (MALLOC_CAP_8BIT), uxQueueMessagesWaiting
// (pcmChkQHdl),
// heap_caps_get_free_size
//(MALLOC_CAP_32BIT | MALLOC_CAP_EXEC),
// heap_caps_get_largest_free_block (MALLOC_CAP_32BIT |
// MALLOC_CAP_EXEC));
// struct timeval now;
// // get current time
// if (gettimeofday (&now, NULL))
// {
// ESP_LOGE (TAG, "Failed to get
// time of day");
// }
//
// // for getting rssi value
// wifi_ap_record_t ap;
// esp_wifi_sta_get_ap_info(&ap);
//
// ESP_LOGI (TAG, "%ld.%ld, rssi:
// %d, %d, %lldus, %lldus %lldus,
// %d, %d, %d, %d, %d",
// now.tv_sec, now.tv_usec,
// ap.rssi,
// dir, age, avg, t,
// heap_caps_get_free_size
// (MALLOC_CAP_8BIT),
// heap_caps_get_largest_free_block
// (MALLOC_CAP_8BIT),
// uxQueueMessagesWaiting
// (pcmChkQHdl),
// heap_caps_get_free_size
// (MALLOC_CAP_32BIT | MALLOC_CAP_EXEC),
// heap_caps_get_largest_free_block
// (MALLOC_CAP_32BIT | MALLOC_CAP_EXEC));
// ESP_LOGI (TAG, "%d, %lldus, %lldus %lldus", dir, age, avg, t);
// ESP_LOGI (TAG, "%d %lldus, %d", dir, avg,
// uxQueueMessagesWaiting (pcmChkQHdl));
// ESP_LOGI (TAG, "%d %lldus, %d",
// dir, avg, uxQueueMessagesWaiting
// (pcmChkQHdl));
fragment = chnk->fragment;
p_payload = fragment->payload;

View File

@@ -160,8 +160,15 @@ wifi_init (void)
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT ();
ESP_ERROR_CHECK (esp_wifi_init (&cfg));
esp_wifi_set_bandwidth (WIFI_IF_STA, WIFI_BW_HT20);
esp_wifi_set_protocol (WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G
| WIFI_PROTOCOL_11N);
// esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G);
// esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_11B);
// esp_wifi_set_ps(WIFI_PS_MIN_MODEM);
// esp_wifi_set_ps(WIFI_PS_NONE);
// esp_wifi_set_ps(WIFI_PS_NONE);
#if ENABLE_WIFI_PROVISIONING
// Configuration for the provisioning manager
@@ -241,6 +248,12 @@ wifi_init (void)
/* Start Wi-Fi station */
ESP_ERROR_CHECK (esp_wifi_set_mode (WIFI_MODE_STA));
wifi_config_t wifi_config;
ESP_ERROR_CHECK (esp_wifi_get_config (WIFI_IF_STA, &wifi_config));
wifi_config.sta.sort_method = WIFI_CONNECT_AP_BY_SIGNAL;
ESP_ERROR_CHECK (esp_wifi_set_config (WIFI_IF_STA, &wifi_config));
ESP_ERROR_CHECK (esp_wifi_start ());
ESP_LOGI (TAG, "wifi_init_sta finished.");

Submodule components/wifi_logger deleted from 23bf246c86