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
pull/3167/head
Angus Gratton 2019-03-08 12:02:57 +08:00
commit bba89e1514
1 zmienionych plików z 17 dodań i 11 usunięć

Wyświetl plik

@ -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);