[FL-3105] Unify power info, power debug, and device_info into one info command (#2393)

* Unify power info, power debug, and device_info into one info command
* Fix the storage script
* Cli: return device_info command for compatibility, rollback storage script
* Cli: remove unused context in info_get calls
* Cli: cleanup device info callbacks, switch to new separator

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Astra 2023-02-26 14:28:52 +02:00 committed by GitHub
parent 9bda3e62ee
commit 0c06e54831
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 39 deletions

View File

@ -12,20 +12,42 @@
// Close to ISO, `date +'%Y-%m-%d %H:%M:%S %u'`
#define CLI_DATE_FORMAT "%.4d-%.2d-%.2d %.2d:%.2d:%.2d %d"
void cli_command_device_info_callback(const char* key, const char* value, bool last, void* context) {
UNUSED(context);
void cli_command_info_callback(const char* key, const char* value, bool last, void* context) {
UNUSED(last);
UNUSED(context);
printf("%-30s: %s\r\n", key, value);
}
/*
* Device Info Command
/** Info Command
*
* This command is intended to be used by humans
*
* Arguments:
* - device - print device info
* - power - print power info
* - power_debug - print power debug info
*
* @param cli The cli instance
* @param args The arguments
* @param context The context
*/
void cli_command_device_info(Cli* cli, FuriString* args, void* context) {
void cli_command_info(Cli* cli, FuriString* args, void* context) {
UNUSED(cli);
UNUSED(args);
furi_hal_info_get(cli_command_device_info_callback, '_', context);
if(context) {
furi_hal_info_get(cli_command_info_callback, '_', NULL);
return;
}
if(!furi_string_cmp(args, "device")) {
furi_hal_info_get(cli_command_info_callback, '.', NULL);
} else if(!furi_string_cmp(args, "power")) {
furi_hal_power_info_get(cli_command_info_callback, '.', NULL);
} else if(!furi_string_cmp(args, "power_debug")) {
furi_hal_power_debug_get(cli_command_info_callback, NULL);
} else {
cli_print_usage("info", "<device|power|power_debug>", furi_string_get_cstr(args));
}
}
void cli_command_help(Cli* cli, FuriString* args, void* context) {
@ -410,8 +432,9 @@ void cli_command_i2c(Cli* cli, FuriString* args, void* context) {
}
void cli_commands_init(Cli* cli) {
cli_add_command(cli, "!", CliCommandFlagParallelSafe, cli_command_device_info, NULL);
cli_add_command(cli, "device_info", CliCommandFlagParallelSafe, cli_command_device_info, NULL);
cli_add_command(cli, "!", CliCommandFlagParallelSafe, cli_command_info, (void*)true);
cli_add_command(cli, "info", CliCommandFlagParallelSafe, cli_command_info, NULL);
cli_add_command(cli, "device_info", CliCommandFlagParallelSafe, cli_command_info, (void*)true);
cli_add_command(cli, "?", CliCommandFlagParallelSafe, cli_command_help, NULL);
cli_add_command(cli, "help", CliCommandFlagParallelSafe, cli_command_help, NULL);

View File

@ -26,24 +26,6 @@ void power_cli_reboot2dfu(Cli* cli, FuriString* args) {
power_reboot(PowerBootModeDfu);
}
static void power_cli_callback(const char* key, const char* value, bool last, void* context) {
UNUSED(last);
UNUSED(context);
printf("%-24s: %s\r\n", key, value);
}
void power_cli_info(Cli* cli, FuriString* args) {
UNUSED(cli);
UNUSED(args);
furi_hal_power_info_get(power_cli_callback, '_', NULL);
}
void power_cli_debug(Cli* cli, FuriString* args) {
UNUSED(cli);
UNUSED(args);
furi_hal_power_debug_get(power_cli_callback, NULL);
}
void power_cli_5v(Cli* cli, FuriString* args) {
UNUSED(cli);
if(!furi_string_cmp(args, "0")) {
@ -74,8 +56,6 @@ static void power_cli_command_print_usage() {
printf("\toff\t - shutdown power\r\n");
printf("\treboot\t - reboot\r\n");
printf("\treboot2dfu\t - reboot to dfu bootloader\r\n");
printf("\tinfo\t - show power info\r\n");
printf("\tdebug\t - show debug information\r\n");
printf("\t5v <0 or 1>\t - enable or disable 5v ext\r\n");
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
printf("\t3v3 <0 or 1>\t - enable or disable 3v3 ext\r\n");
@ -108,16 +88,6 @@ void power_cli(Cli* cli, FuriString* args, void* context) {
break;
}
if(furi_string_cmp_str(cmd, "info") == 0) {
power_cli_info(cli, args);
break;
}
if(furi_string_cmp_str(cmd, "debug") == 0) {
power_cli_debug(cli, args);
break;
}
if(furi_string_cmp_str(cmd, "5v") == 0) {
power_cli_5v(cli, args);
break;