mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
console: fix wrong timeout settiing in join command
1. Fix wrong timeout setting in join command, also alter the default timeout value to 10 seconds 2. Don't clear the CONNECTED_BIT when connected to AP.
This commit is contained in:
parent
ea0a1c3030
commit
378f8f72f0
@ -20,6 +20,8 @@
|
||||
#include "esp_event_loop.h"
|
||||
#include "cmd_wifi.h"
|
||||
|
||||
#define JOIN_TIMEOUT_MS (10000)
|
||||
|
||||
static EventGroupHandle_t wifi_event_group;
|
||||
const int CONNECTED_BIT = BIT0;
|
||||
|
||||
@ -71,7 +73,7 @@ static bool wifi_join(const char* ssid, const char* pass, int timeout_ms)
|
||||
ESP_ERROR_CHECK( esp_wifi_connect() );
|
||||
|
||||
int bits = xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT,
|
||||
1, 1, timeout_ms / portTICK_PERIOD_MS);
|
||||
pdFALSE, pdTRUE, timeout_ms / portTICK_PERIOD_MS);
|
||||
return (bits & CONNECTED_BIT) != 0;
|
||||
}
|
||||
|
||||
@ -93,6 +95,11 @@ static int connect(int argc, char** argv)
|
||||
ESP_LOGI(__func__, "Connecting to '%s'",
|
||||
join_args.ssid->sval[0]);
|
||||
|
||||
/* set default value*/
|
||||
if (join_args.timeout->count == 0) {
|
||||
join_args.timeout->ival[0] = JOIN_TIMEOUT_MS;
|
||||
}
|
||||
|
||||
bool connected = wifi_join(join_args.ssid->sval[0],
|
||||
join_args.password->sval[0],
|
||||
join_args.timeout->ival[0]);
|
||||
@ -107,7 +114,6 @@ static int connect(int argc, char** argv)
|
||||
void register_wifi()
|
||||
{
|
||||
join_args.timeout = arg_int0(NULL, "timeout", "<t>", "Connection timeout, ms");
|
||||
join_args.timeout->ival[0] = 5000; // set default value
|
||||
join_args.ssid = arg_str1(NULL, NULL, "<ssid>", "SSID of AP");
|
||||
join_args.password = arg_str0(NULL, NULL, "<pass>", "PSK of AP");
|
||||
join_args.end = arg_end(2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user