improved wifi power regulation accuracy, added lost beacon event
This commit is contained in:
parent
8e17437bbd
commit
d5cf42b17d
|
|
@ -151,7 +151,7 @@ static HTTP_IO_RESULT HTTPPostAdaptersSettings(httpd_req_t *req, char *PostData)
|
||||||
if (httpd_query_key_value(PostData, "wifipwr", tmp, sizeof(tmp)) == ESP_OK)
|
if (httpd_query_key_value(PostData, "wifipwr", tmp, sizeof(tmp)) == ESP_OK)
|
||||||
{
|
{
|
||||||
uint8_t pwr = atoi((const char*) tmp);
|
uint8_t pwr = atoi((const char*) tmp);
|
||||||
if (pwr >= 8 && pwr <= 84)
|
if (pwr >= 1 && pwr <= 20)
|
||||||
GetSysConf()->wifiSettings.MaxPower = pwr * 4;
|
GetSysConf()->wifiSettings.MaxPower = pwr * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,10 +108,16 @@ static void event_handler(void *arg, esp_event_base_t event_base,
|
||||||
}
|
}
|
||||||
else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED)
|
else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "Disconnected from AP");
|
ESP_LOGW(TAG, "Disconnected from AP");
|
||||||
xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
|
xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
|
||||||
xEventGroupClearBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
|
xEventGroupClearBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
|
||||||
}
|
}
|
||||||
|
else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_BEACON_TIMEOUT)
|
||||||
|
{
|
||||||
|
ESP_LOGW(TAG, "STA beacon timeout");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP)
|
else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP)
|
||||||
{
|
{
|
||||||
ip_event_got_ip_t *event = (ip_event_got_ip_t*) event_data;
|
ip_event_got_ip_t *event = (ip_event_got_ip_t*) event_data;
|
||||||
|
|
@ -222,7 +228,7 @@ static void wifi_init_softap(void *pvParameter)
|
||||||
ESP_ERROR_CHECK(esp_wifi_start());
|
ESP_ERROR_CHECK(esp_wifi_start());
|
||||||
|
|
||||||
int max_power = GetSysConf()->wifiSettings.MaxPower;
|
int max_power = GetSysConf()->wifiSettings.MaxPower;
|
||||||
if (max_power >= 8 && max_power <= 84)
|
if (max_power >= 8 && max_power <= 80)
|
||||||
esp_wifi_set_max_tx_power(max_power);
|
esp_wifi_set_max_tx_power(max_power);
|
||||||
|
|
||||||
ESP_LOGI(TAG, "wifi_init_softap finished");
|
ESP_LOGI(TAG, "wifi_init_softap finished");
|
||||||
|
|
@ -305,7 +311,7 @@ static void wifi_init_sta(void *pvParameter)
|
||||||
ESP_ERROR_CHECK(esp_wifi_start());
|
ESP_ERROR_CHECK(esp_wifi_start());
|
||||||
|
|
||||||
int max_power = GetSysConf()->wifiSettings.MaxPower;
|
int max_power = GetSysConf()->wifiSettings.MaxPower;
|
||||||
if (max_power >= 8 && max_power <= 84)
|
if (max_power >= 8 && max_power <= 80)
|
||||||
esp_wifi_set_max_tx_power(max_power);
|
esp_wifi_set_max_tx_power(max_power);
|
||||||
|
|
||||||
ESP_LOGI(TAG, "wifi_init_sta finished.");
|
ESP_LOGI(TAG, "wifi_init_sta finished.");
|
||||||
|
|
@ -456,7 +462,7 @@ static void wifi_init_apsta(void *pvParameter)
|
||||||
ESP_ERROR_CHECK(esp_wifi_start());
|
ESP_ERROR_CHECK(esp_wifi_start());
|
||||||
|
|
||||||
int max_power = GetSysConf()->wifiSettings.MaxPower;
|
int max_power = GetSysConf()->wifiSettings.MaxPower;
|
||||||
if (max_power >= 8 && max_power <= 84)
|
if (max_power >= 8 && max_power <= 80)
|
||||||
esp_wifi_set_max_tx_power(max_power);
|
esp_wifi_set_max_tx_power(max_power);
|
||||||
|
|
||||||
wifi_country_t CC;
|
wifi_country_t CC;
|
||||||
|
|
@ -518,10 +524,13 @@ static void WiFiControlTask(void *arg)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "WiFi STA started, reconnecting to AP...");
|
ESP_LOGI(TAG, "WiFi STA started, reconnecting to AP...");
|
||||||
esp_wifi_connect();
|
esp_wifi_connect();
|
||||||
|
/*
|
||||||
reconnect_interval += BASE_RECONNECT_INTERVAL;
|
reconnect_interval += BASE_RECONNECT_INTERVAL;
|
||||||
if (reconnect_interval >= BASE_RECONNECT_INTERVAL * 10)
|
if (reconnect_interval >= BASE_RECONNECT_INTERVAL * 10)
|
||||||
reconnect_interval = BASE_RECONNECT_INTERVAL * 10;
|
reconnect_interval = BASE_RECONNECT_INTERVAL * 10;
|
||||||
reconnect_counter = reconnect_interval;
|
reconnect_counter = reconnect_interval;
|
||||||
|
*/
|
||||||
|
reconnect_counter = BASE_RECONNECT_INTERVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user