forked from flipperdevices/flipperzero-firmware
-
-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added `timezone` CLI command * FAQ & README updated
- Loading branch information
Showing
10 changed files
with
140 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
#pragma once | ||
|
||
#define TOTP_CLI_ARG(arg) "<" arg ">" | ||
#define TOTP_CLI_OPTIONAL_PARAM(param) "[" param "]" | ||
#define TOTP_CLI_OPTIONAL_PARAM_MARK "[OPTIONAL]" | ||
|
||
#define TOTP_CLI_PRINTF(format, ...) \ | ||
_Pragma(STRINGIFY(GCC diagnostic push)); \ | ||
_Pragma(STRINGIFY(GCC diagnostic ignored "-Wdouble-promotion")); \ | ||
printf(format, ##__VA_ARGS__); \ | ||
_Pragma(STRINGIFY(GCC diagnostic pop)); | ||
|
||
void totp_cli_print_invalid_arguments(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "timezone.h" | ||
#include <lib/toolbox/args.h> | ||
#include "../../../config/config.h" | ||
#include "../../../../scenes/scene_director.h" | ||
#include "../../cli_common_helpers.h" | ||
|
||
#define TOTP_CLI_COMMAND_TIMEZONE_ARG_TIMEZONE "TIMEZONE" | ||
|
||
void totp_cli_command_timezone_print_help() { | ||
TOTP_CLI_PRINTF("\t" TOTP_CLI_COMMAND_TIMEZONE " " TOTP_CLI_OPTIONAL_PARAM(TOTP_CLI_ARG(TOTP_CLI_COMMAND_TIMEZONE_ARG_TIMEZONE)) "\r\n"); | ||
TOTP_CLI_PRINTF("\t\t" TOTP_CLI_ARG(TOTP_CLI_COMMAND_TIMEZONE_ARG_TIMEZONE) " - " TOTP_CLI_OPTIONAL_PARAM_MARK " timezone offset in hours to be set, if not provided then current timezone offset will be printed\r\n\r\n"); | ||
} | ||
|
||
void totp_cli_command_timezone_handle(PluginState* plugin_state, FuriString* args) { | ||
FuriString* temp_str = furi_string_alloc(); | ||
if (args_read_string_and_trim(args, temp_str)) { | ||
float tz = strtof(furi_string_get_cstr(temp_str), NULL); | ||
if (tz >= -12.75f && tz <= 12.75f) { | ||
plugin_state->timezone_offset = tz; | ||
totp_config_file_update_timezone_offset(tz); | ||
TOTP_CLI_PRINTF("Timezone is set to %f\r\n", tz); | ||
if (plugin_state->current_scene == TotpSceneGenerateToken) { | ||
totp_scene_director_activate_scene(plugin_state, TotpSceneNone, NULL); | ||
totp_scene_director_activate_scene(plugin_state, TotpSceneGenerateToken, NULL); | ||
} else if (plugin_state->current_scene == TotpSceneAppSettings) { | ||
totp_scene_director_activate_scene(plugin_state, TotpSceneNone, NULL); | ||
totp_scene_director_activate_scene(plugin_state, TotpSceneAppSettings, NULL); | ||
} | ||
} else { | ||
TOTP_CLI_PRINTF("Invalid timezone offset\r\n"); | ||
} | ||
} else { | ||
TOTP_CLI_PRINTF("Current timezone offset is %f\r\n", plugin_state->timezone_offset); | ||
} | ||
furi_string_free(temp_str); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
#include <cli/cli.h> | ||
#include "../../../../types/plugin_state.h" | ||
|
||
#define TOTP_CLI_COMMAND_TIMEZONE "timezone" | ||
|
||
void totp_cli_command_timezone_handle(PluginState* plugin_state, FuriString* args); | ||
void totp_cli_command_timezone_print_help(); |