Skip to content

Commit b2272b4

Browse files
Merge pull request #513 from espressif-abhikroy/component/console_cmd_wifi
feat(console): wifi commands updates
2 parents 7f248bd + 5d43f96 commit b2272b4

File tree

8 files changed

+60
-16
lines changed

8 files changed

+60
-16
lines changed

components/console_cmd_wifi/.cz.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ commitizen:
33
bump_message: 'bump(console): $current_version -> $new_version'
44
pre_bump_hooks: python ../../ci/changelog.py console_cmd_wifi
55
tag_format: console_cmd_wifi-v$version
6-
version: 1.0.1
6+
version: 1.1.0
77
version_files:
88
- idf_component.yml

components/console_cmd_wifi/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [1.1.0](https://github.com/espressif/esp-protocols/commits/console_cmd_wifi-v1.1.0)
4+
5+
### Features
6+
7+
- Added support to join pre-configured network ([bdbf16c1](https://github.com/espressif/esp-protocols/commit/bdbf16c1))
8+
39
## [1.0.1](https://github.com/espressif/esp-protocols/commits/console_cmd_wifi-v1.0.1)
410

511
### Features
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
idf_component_register(SRCS "console_wifi.c"
2-
INCLUDE_DIRS "."
3-
PRIV_REQUIRES esp_netif console esp_wifi
4-
WHOLE_ARCHIVE)
2+
INCLUDE_DIRS "include"
3+
REQUIRES lwip
4+
PRIV_REQUIRES esp_netif console esp_wifi esp_timer)
5+
6+
if(CONFIG_WIFI_CMD_AUTO_REGISTRATION)
7+
target_link_libraries(${COMPONENT_LIB} "-u console_cmd_wifi_register")
8+
endif()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
menu "Wifi command Configuration"
2+
3+
config WIFI_CMD_AUTO_REGISTRATION
4+
bool "Enable Console command wifi Auto-registration"
5+
default y
6+
help
7+
Enabling this allows for the autoregistration of the wifi command.
8+
9+
config WIFI_CMD_NETWORK_SSID
10+
string "WiFi SSID"
11+
default "myssid"
12+
help
13+
SSID (network name) to connect to.
14+
15+
config WIFI_CMD_NETWORK_PASSWORD
16+
string "WiFi Password"
17+
default "mypassword"
18+
help
19+
WiFi password (WPA or WPA2) to use.
20+
Can be left blank if the network has no security set.
21+
22+
endmenu

components/console_cmd_wifi/README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,16 @@ The component offers a console with a command that enables runtime wifi configur
3333
ESP_ERROR_CHECK(console_cmd_start()); // Start console
3434
```
3535

36+
Note: Auto-registration of a specific plugin command can be disabled from menuconfig.
37+
3638
## Suported command:
3739

3840
### wifi:
39-
* ```wifi help```: Prints the help text for all wifi commands
40-
* ```wifi show network```: Scans and displays upto 10 available wifi networks.
41-
* ```wifi show sta```: Shows the details of wifi station.
42-
* ```wifi sta join <network ssid> <password>```: Station joins the given wifi network.
43-
* ```wifi sta join <network ssid>```: Station joins the given unsecured wifi network.
44-
* ```wifi sta leave```: Station leaves the wifi network.
41+
```
42+
wifi help: Prints the help text for all wifi commands
43+
wifi show network/sta: Scans and displays all available wifi APs./ Shows the details of wifi station.
44+
wifi sta join <network ssid> <password>: Station joins the given wifi network.
45+
wifi sta join <network ssid>: Station joins the given unsecured wifi network.
46+
wifi sta join: Station joins the pre-configured wifi network.
47+
wifi sta leave: Station leaves the wifi network.
48+
```

components/console_cmd_wifi/console_wifi.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#define DEFAULT_SCAN_LIST_SIZE 10
2323

24+
#if CONFIG_WIFI_CMD_AUTO_REGISTRATION
2425
/**
2526
* Static registration of this plugin is achieved by defining the plugin description
2627
* structure and placing it into .console_cmd_desc section.
@@ -30,6 +31,7 @@ static const console_cmd_plugin_desc_t __attribute__((section(".console_cmd_desc
3031
.name = "console_cmd_wifi",
3132
.plugin_regd_fn = &console_cmd_wifi_register
3233
};
34+
#endif
3335

3436
typedef struct wifi_op_t {
3537
char *name;
@@ -55,8 +57,9 @@ static const int CONNECTED_BIT = BIT1;
5557
static wifi_op_t cmd_list[] = {
5658
{.name = "help", .operation = wifi_help_op, .arg_cnt = 2, .start_index = 1, .help = "wifi help: Prints the help text for all wifi commands"},
5759
{.name = "show", .operation = wifi_show_op, .arg_cnt = 3, .start_index = 1, .help = "wifi show network/sta: Scans and displays all available wifi APs./ Shows the details of wifi station."},
58-
{.name = "join", .operation = wifi_sta_join_op, .arg_cnt = 4, .start_index = 2, .help = "wifi sta join <network ssid> <password>: Station joins the given wifi network."},
59-
{.name = "join", .operation = wifi_sta_join_op, .arg_cnt = 5, .start_index = 2, .help = "wifi sta join <network ssid>: Station joins the given unsecured wifi network."},
60+
{.name = "join", .operation = wifi_sta_join_op, .arg_cnt = 5, .start_index = 2, .help = "wifi sta join <network ssid> <password>: Station joins the given wifi network."},
61+
{.name = "join", .operation = wifi_sta_join_op, .arg_cnt = 4, .start_index = 2, .help = "wifi sta join <network ssid>: Station joins the given unsecured wifi network."},
62+
{.name = "join", .operation = wifi_sta_join_op, .arg_cnt = 3, .start_index = 2, .help = "wifi sta join: Station joins the pre-configured wifi network."},
6063
{.name = "leave", .operation = wifi_sta_leave_op, .arg_cnt = 3, .start_index = 2, .help = "wifi sta leave: Station leaves the wifi network."},
6164
};
6265

@@ -162,7 +165,6 @@ static esp_err_t wifi_show_op(wifi_op_t *self, int argc, char *argv[])
162165
ESP_LOGI(TAG, "Showing Joind AP details:");
163166
ESP_LOGI(TAG, "*************************");
164167
ESP_LOGI(TAG, "SSID: %s", wifi_config.sta.ssid);
165-
ESP_LOGI(TAG, "Password: %s", wifi_config.sta.password);
166168
ESP_LOGI(TAG, "Channel: %d", wifi_config.sta.channel);
167169
ESP_LOGI(TAG, "bssid: %02x:%02x:%02x:%02x:%02x:%02x", wifi_config.sta.bssid[0],
168170
wifi_config.sta.bssid[1], wifi_config.sta.bssid[2], wifi_config.sta.bssid[3],
@@ -184,7 +186,13 @@ static esp_err_t wifi_sta_join_op(wifi_op_t *self, int argc, char *argv[])
184186
return ESP_FAIL;
185187
}
186188

187-
strlcpy((char *) wifi_config.sta.ssid, argv[self->start_index + 1], sizeof(wifi_config.sta.ssid));
189+
if (self->arg_cnt == 3) {
190+
strlcpy((char *) wifi_config.sta.ssid, CONFIG_WIFI_CMD_NETWORK_SSID, sizeof(wifi_config.sta.ssid));
191+
strlcpy((char *) wifi_config.sta.password, CONFIG_WIFI_CMD_NETWORK_PASSWORD, sizeof(wifi_config.sta.password));
192+
} else {
193+
strlcpy((char *) wifi_config.sta.ssid, argv[self->start_index + 1], sizeof(wifi_config.sta.ssid));
194+
}
195+
188196
if (self->arg_cnt == 5) {
189197
strlcpy((char *) wifi_config.sta.password, argv[self->start_index + 2], sizeof(wifi_config.sta.password));
190198
}
@@ -260,7 +268,7 @@ static esp_err_t do_cmd_wifi(int argc, char **argv)
260268
*/
261269
esp_err_t console_cmd_wifi_register(void)
262270
{
263-
esp_err_t ret;
271+
esp_err_t ret = ESP_OK;
264272
esp_console_cmd_t command = {
265273
.command = "wifi",
266274
.help = "Command for wifi configuration and monitoring\n For more info run 'wifi help'",

components/console_cmd_wifi/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 1.0.1
1+
version: 1.1.0
22
url: https://github.com/espressif/esp-protocols/tree/master/components/console_cmd_wifi
33
description: The component offers a console that enables runtime wifi configuration and monitoring.
44
dependencies:

0 commit comments

Comments
 (0)