Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorあく <alleteam@gmail.com>2021-07-18 22:08:26 +0300
committerGitHub <noreply@github.com>2021-07-18 22:08:26 +0300
commitb6f63786284d55bd220162b5795b1604b21d16cf (patch)
tree9efc69ffc8ecfbaa018ff3a566d3953d6ba68ce7 /applications/cli
parentddfdbc05303159212a4bdbffd33dec1450182805 (diff)
Cli: insomnia safe flags and better insomnia handling in cli (#587)
Diffstat (limited to 'applications/cli')
-rw-r--r--applications/cli/cli.c52
-rw-r--r--applications/cli/cli.h1
2 files changed, 33 insertions, 20 deletions
diff --git a/applications/cli/cli.c b/applications/cli/cli.c
index 87ed8d10..fa424729 100644
--- a/applications/cli/cli.c
+++ b/applications/cli/cli.c
@@ -142,6 +142,37 @@ static void cli_normalize_line(Cli* cli) {
cli->cursor_position = string_size(cli->line);
}
+static void cli_execute_command(Cli* cli, CliCommand* command, string_t args) {
+ if(!(command->flags & CliCommandFlagInsomniaSafe)) {
+ api_hal_power_insomnia_enter();
+ }
+
+ // Ensure that we running alone
+ if(!(command->flags & CliCommandFlagParallelSafe)) {
+ Loader* loader = furi_record_open("loader");
+ bool safety_lock = loader_lock(loader);
+ if(safety_lock) {
+ // Execute command
+ command->callback(cli, args, command->context);
+ loader_unlock(loader);
+ // Clear line
+ cli_reset(cli);
+ } else {
+ printf("Other application is running, close it first");
+ }
+ furi_record_close("loader");
+ } else {
+ // Execute command
+ command->callback(cli, args, command->context);
+ // Clear line
+ cli_reset(cli);
+ }
+
+ if(!(command->flags & CliCommandFlagInsomniaSafe)) {
+ api_hal_power_insomnia_exit();
+ }
+}
+
static void cli_handle_enter(Cli* cli) {
cli_normalize_line(cli);
@@ -171,26 +202,7 @@ static void cli_handle_enter(Cli* cli) {
CliCommand* cli_command = CliCommandTree_get(cli->commands, command);
if(cli_command) {
cli_nl(cli);
- // Ensure that we running alone
- if(!(cli_command->flags & CliCommandFlagParallelSafe)) {
- Loader* loader = furi_record_open("loader");
- bool safety_lock = loader_lock(loader);
- if(safety_lock) {
- // Execute command
- cli_command->callback(cli, args, cli_command->context);
- loader_unlock(loader);
- // Clear line
- cli_reset(cli);
- } else {
- printf("Other application is running, close it first");
- }
- furi_record_close("loader");
- } else {
- // Execute command
- cli_command->callback(cli, args, cli_command->context);
- // Clear line
- cli_reset(cli);
- }
+ cli_execute_command(cli, cli_command, args);
} else {
cli_nl(cli);
printf(
diff --git a/applications/cli/cli.h b/applications/cli/cli.h
index 5957cc37..c7322fdb 100644
--- a/applications/cli/cli.h
+++ b/applications/cli/cli.h
@@ -24,6 +24,7 @@ typedef enum {
CliCommandFlagDefault = 0, /** Default, loader lock is used */
CliCommandFlagParallelSafe =
(1 << 0), /** Safe to run in parallel with other apps, loader lock is not used */
+ CliCommandFlagInsomniaSafe = (1 << 1), /** Safe to run with insomnia mode on */
} CliCommandFlag;
/* Cli type