|
12 | 12 | #include <zephyr/shell/shell.h> |
13 | 13 | #include <shell/shell_help.h> |
14 | 14 |
|
| 15 | +#if CONFIG_PM_DEVICE |
| 16 | +#include <zephyr/pm/device.h> |
| 17 | +#endif |
| 18 | + |
15 | 19 | #include "tmo_shell.h" |
16 | 20 |
|
17 | 21 | #define WIFI_SHELL_MGMT_EVENTS (NET_EVENT_WIFI_SCAN_RESULT | \ |
@@ -293,6 +297,16 @@ int cmd_wifi_connect(const struct shell *shell, size_t argc, |
293 | 297 | return -EINVAL; |
294 | 298 | } |
295 | 299 |
|
| 300 | +#if CONFIG_PM_DEVICE |
| 301 | + enum pm_device_state st; |
| 302 | + |
| 303 | + pm_device_state_get(iface->if_dev->dev, &st); |
| 304 | + if (st == PM_DEVICE_STATE_OFF) { |
| 305 | + shell_error(shell, "Device %s is off, Command ignored", iface->if_dev->dev->name); |
| 306 | + return -EIO; |
| 307 | + } |
| 308 | +#endif |
| 309 | + |
296 | 310 | static struct wifi_connect_req_params cnx_params; |
297 | 311 |
|
298 | 312 | if (__wifi_args_to_params(argc - 2, &argv[2], &cnx_params)) { |
@@ -332,6 +346,16 @@ int cmd_wifi_disconnect(const struct shell *shell, size_t argc, |
332 | 346 | return -EINVAL; |
333 | 347 | } |
334 | 348 |
|
| 349 | +#if CONFIG_PM_DEVICE |
| 350 | + enum pm_device_state st; |
| 351 | + |
| 352 | + pm_device_state_get(iface->if_dev->dev, &st); |
| 353 | + if (st == PM_DEVICE_STATE_OFF) { |
| 354 | + shell_error(shell, "Device %s is off, Command ignored", iface->if_dev->dev->name); |
| 355 | + return -EIO; |
| 356 | + } |
| 357 | +#endif |
| 358 | + |
335 | 359 | // struct net_if *iface = net_if_get_default(); |
336 | 360 | int status; |
337 | 361 |
|
@@ -373,6 +397,16 @@ int cmd_wifi_scan(const struct shell *shell, size_t argc, char *argv[]) |
373 | 397 | return -EINVAL; |
374 | 398 | } |
375 | 399 |
|
| 400 | +#if CONFIG_PM_DEVICE |
| 401 | + enum pm_device_state st; |
| 402 | + |
| 403 | + pm_device_state_get(iface->if_dev->dev, &st); |
| 404 | + if (st == PM_DEVICE_STATE_OFF) { |
| 405 | + shell_error(shell, "Device %s is off, Command ignored", iface->if_dev->dev->name); |
| 406 | + return -EIO; |
| 407 | + } |
| 408 | +#endif |
| 409 | + |
376 | 410 | context.shell = shell; |
377 | 411 |
|
378 | 412 | if (net_mgmt(NET_REQUEST_WIFI_SCAN, iface, NULL, 0)) { |
@@ -402,6 +436,16 @@ int cmd_wifi_status(const struct shell *shell, size_t argc, char *argv[]) |
402 | 436 | return -EINVAL; |
403 | 437 | } |
404 | 438 |
|
| 439 | +#if CONFIG_PM_DEVICE |
| 440 | + enum pm_device_state st; |
| 441 | + |
| 442 | + pm_device_state_get(iface->if_dev->dev, &st); |
| 443 | + if (st == PM_DEVICE_STATE_OFF) { |
| 444 | + shell_error(shell, "Device %s is off, Command ignored", iface->if_dev->dev->name); |
| 445 | + return -EIO; |
| 446 | + } |
| 447 | +#endif |
| 448 | + |
405 | 449 | context.shell = shell; |
406 | 450 |
|
407 | 451 | if (net_mgmt(NET_REQUEST_WIFI_STATUS, iface, NULL, 0)) { |
@@ -477,6 +521,17 @@ int cmd_wifi_mac(const struct shell *shell, size_t argc, char *argv[]) |
477 | 521 | shell_error(shell, "Interface %d not found", idx); |
478 | 522 | return -EINVAL; |
479 | 523 | } |
| 524 | + |
| 525 | +#if CONFIG_PM_DEVICE |
| 526 | + enum pm_device_state st; |
| 527 | + |
| 528 | + pm_device_state_get(iface->if_dev->dev, &st); |
| 529 | + if (st == PM_DEVICE_STATE_OFF) { |
| 530 | + shell_error(shell, "Device %s is off, Command ignored", iface->if_dev->dev->name); |
| 531 | + return -EIO; |
| 532 | + } |
| 533 | +#endif |
| 534 | + |
480 | 535 | #ifdef CONFIG_WIFI_RS9116W |
481 | 536 | else if (strstr(iface->if_dev->dev->name,"9116")) { |
482 | 537 | uint8_t mac[6]; |
|
0 commit comments