|
5 | 5 | */ |
6 | 6 |
|
7 | 7 | #include <stdio.h> |
| 8 | +#include <unistd.h> |
| 9 | +#include <getopt.h> |
8 | 10 |
|
9 | 11 | #include <zephyr/shell/shell.h> |
10 | 12 | #include <zephyr/shell/shell_uart.h> |
11 | | -#include <unistd.h> |
12 | | -#include <getopt.h> |
| 13 | +#include <zephyr/sys/poweroff.h> |
13 | 14 |
|
14 | 15 | #include <nrf_modem_at.h> |
15 | 16 | #include <modem/nrf_modem_lib.h> |
@@ -375,6 +376,7 @@ static const char link_modem_usage_str[] = |
375 | 376 | " --init, Initialize modem using nrf_modem_lib_init()\n" |
376 | 377 | " --shutdown, Shutdown modem\n" |
377 | 378 | " --shutdown_cfun0, Send AT+CFUN=0 AT command and shutdown modem\n" |
| 379 | + " --systemoff, Send AT+CFUN=0 AT command, shutdown modem and trigger SYSTEMOFF\n" |
378 | 380 | " -h, --help, Shows this help information\n" |
379 | 381 | "\n" |
380 | 382 | "Several options can be given and they are run in the given order."; |
@@ -448,6 +450,7 @@ enum { |
448 | 450 | LINK_SHELL_OPT_MODEM_INIT, |
449 | 451 | LINK_SHELL_OPT_MODEM_SHUTDOWN, |
450 | 452 | LINK_SHELL_OPT_MODEM_SHUTDOWN_CFUN0, |
| 453 | + LINK_SHELL_OPT_MODEM_SYSTEMOFF, |
451 | 454 | LINK_SHELL_OPT_ENVEVAL_EVAL_TYPE, |
452 | 455 | LINK_SHELL_OPT_ENVEVAL_PLMNS, |
453 | 456 | }; |
@@ -528,6 +531,7 @@ static struct option long_options[] = { |
528 | 531 | { "init", no_argument, 0, LINK_SHELL_OPT_MODEM_INIT }, |
529 | 532 | { "shutdown", no_argument, 0, LINK_SHELL_OPT_MODEM_SHUTDOWN }, |
530 | 533 | { "shutdown_cfun0", no_argument, 0, LINK_SHELL_OPT_MODEM_SHUTDOWN_CFUN0 }, |
| 534 | + { "systemoff", no_argument, 0, LINK_SHELL_OPT_MODEM_SYSTEMOFF }, |
531 | 535 | { "eval_type", required_argument, 0, LINK_SHELL_OPT_ENVEVAL_EVAL_TYPE }, |
532 | 536 | { "plmns", required_argument, 0, LINK_SHELL_OPT_ENVEVAL_PLMNS }, |
533 | 537 | { 0, 0, 0, 0 } |
@@ -1719,6 +1723,14 @@ static int link_shell_modem(const struct shell *shell, size_t argc, char **argv) |
1719 | 1723 | nrf_modem_at_printf("AT+CFUN=0"); |
1720 | 1724 | nrf_modem_lib_shutdown(); |
1721 | 1725 | break; |
| 1726 | + case LINK_SHELL_OPT_MODEM_SYSTEMOFF: |
| 1727 | + operation_selected = true; |
| 1728 | + nrf_modem_at_printf("AT+CFUN=0"); |
| 1729 | + nrf_modem_lib_shutdown(); |
| 1730 | + printk("Entering SYSTEMOFF in 1 second, wakeup only with reset\n"); |
| 1731 | + k_sleep(K_SECONDS(1)); |
| 1732 | + sys_poweroff(); |
| 1733 | + break; |
1722 | 1734 |
|
1723 | 1735 | case 'h': |
1724 | 1736 | goto show_usage; |
|
0 commit comments