mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 20:24:32 +02:00
Merge branch 'bugfix/console_join_example' into 'master'
console: fix wrong timeout settiing in join command Closes IDF-168 See merge request idf/esp-idf!4366
This commit is contained in:
@@ -20,6 +20,8 @@
|
|||||||
#include "esp_event_loop.h"
|
#include "esp_event_loop.h"
|
||||||
#include "cmd_wifi.h"
|
#include "cmd_wifi.h"
|
||||||
|
|
||||||
|
#define JOIN_TIMEOUT_MS (10000)
|
||||||
|
|
||||||
static EventGroupHandle_t wifi_event_group;
|
static EventGroupHandle_t wifi_event_group;
|
||||||
const int CONNECTED_BIT = BIT0;
|
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() );
|
ESP_ERROR_CHECK( esp_wifi_connect() );
|
||||||
|
|
||||||
int bits = xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT,
|
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;
|
return (bits & CONNECTED_BIT) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,6 +95,11 @@ static int connect(int argc, char** argv)
|
|||||||
ESP_LOGI(__func__, "Connecting to '%s'",
|
ESP_LOGI(__func__, "Connecting to '%s'",
|
||||||
join_args.ssid->sval[0]);
|
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],
|
bool connected = wifi_join(join_args.ssid->sval[0],
|
||||||
join_args.password->sval[0],
|
join_args.password->sval[0],
|
||||||
join_args.timeout->ival[0]);
|
join_args.timeout->ival[0]);
|
||||||
@@ -107,7 +114,6 @@ static int connect(int argc, char** argv)
|
|||||||
void register_wifi()
|
void register_wifi()
|
||||||
{
|
{
|
||||||
join_args.timeout = arg_int0(NULL, "timeout", "<t>", "Connection timeout, ms");
|
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.ssid = arg_str1(NULL, NULL, "<ssid>", "SSID of AP");
|
||||||
join_args.password = arg_str0(NULL, NULL, "<pass>", "PSK of AP");
|
join_args.password = arg_str0(NULL, NULL, "<pass>", "PSK of AP");
|
||||||
join_args.end = arg_end(2);
|
join_args.end = arg_end(2);
|
||||||
|
Reference in New Issue
Block a user