added temporarily AP activation mechanism
This commit is contained in:
parent
7a032ac452
commit
0dde9cbc8b
|
|
@ -64,6 +64,7 @@ void WiFiScan(void);
|
|||
void WiFiStop();
|
||||
void WiFiStopAP();
|
||||
void WiFiStartAP();
|
||||
void WiFiStartAPTemp(int seconds);
|
||||
void EthStart(void);
|
||||
|
||||
void WiFiTransportTask(void *prm);
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ static HTTP_IO_RESULT HTTPPostAdaptersSettings(httpd_req_t *req, char *PostData)
|
|||
{
|
||||
if (!strcmp(tmp, (const char*) "prs"))
|
||||
{
|
||||
WiFiStartAP();
|
||||
WiFiStartAPTemp(120);
|
||||
}
|
||||
}
|
||||
if (httpd_query_key_value(PostData, "wifistop", tmp, 4) == ESP_OK)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ esp_netif_t *ap_netif;
|
|||
static const char *TAG = "WiFiTransport";
|
||||
|
||||
#define WIFI_CONNECT_AFTER_FAIL_DELAY 40
|
||||
#define WIFI_AP_ONBOOT_TIME 300
|
||||
|
||||
#define EXAMPLE_ESP_MAXIMUM_RETRY 5
|
||||
#define EXAMPLE_ESP_WIFI_CHANNEL 6
|
||||
|
|
@ -49,6 +50,7 @@ static bool isWiFiRunning = false;
|
|||
static bool isWiFiConnected = false;
|
||||
static bool isWiFiGotIp = false;
|
||||
static bool isWiFiFail = false;
|
||||
static int TempAPCounter = WIFI_AP_ONBOOT_TIME;
|
||||
|
||||
#define DEFAULT_SCAN_LIST_SIZE 20
|
||||
static wifi_ap_record_t ap_info[DEFAULT_SCAN_LIST_SIZE];
|
||||
|
|
@ -531,6 +533,15 @@ static void WiFiControlTask(void *arg)
|
|||
reconnect_counter = RECONNECT_INTERVAL;
|
||||
}
|
||||
}
|
||||
if (TempAPCounter > 0)
|
||||
{
|
||||
if (--TempAPCounter <= 0)
|
||||
{
|
||||
WiFiStopAP();
|
||||
ESP_LOGI(TAG, "WiFi AP stopped after temporarily activity");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isWiFiConnected)
|
||||
|
|
@ -570,6 +581,13 @@ void WiFiStartAP()
|
|||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
|
||||
}
|
||||
|
||||
void WiFiStartAPTemp(int seconds)
|
||||
{
|
||||
TempAPCounter = seconds;
|
||||
WiFiStartAP();
|
||||
ESP_LOGI(TAG, "WiFi AP started temporarily for %u seconds", seconds);
|
||||
}
|
||||
|
||||
static void wifi_scan(void *arg)
|
||||
{
|
||||
uint16_t number = DEFAULT_SCAN_LIST_SIZE;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user