From 721f83dd836be30f8e7b3b45ee05acc88ff0430b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Fri, 2 Jul 2021 18:12:05 +0300 Subject: [PATCH] [FL-1516] Fix name read on device without OTP (#561) * Fix name read on device without OTP * Dolphin: proper name handling. --- applications/cli/cli_commands.c | 26 ++++-------------------- applications/dolphin/dolphin_views.c | 6 ++++-- applications/dolphin/passport/passport.c | 3 ++- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/applications/cli/cli_commands.c b/applications/cli/cli_commands.c index df04f169..6900a425 100644 --- a/applications/cli/cli_commands.c +++ b/applications/cli/cli_commands.c @@ -15,7 +15,10 @@ void cli_command_device_info(Cli* cli, string_t args, void* context) { // Model name printf("hardware_model : %s\r\n", api_hal_version_get_model_name()); - printf("hardware_name : %s\r\n", api_hal_version_get_name_ptr()); + const char* name = api_hal_version_get_name_ptr(); + if(name) { + printf("hardware_name : %s\r\n", name); + } // Unique ID printf("hardware_uid : "); @@ -191,27 +194,6 @@ void cli_command_log(Cli* cli, string_t args, void* context) { furi_stdglue_set_global_stdout_callback(NULL); } -void cli_command_hw_info(Cli* cli, string_t args, void* context) { - printf( - "%-20s %d.F%dB%dC%d\r\n", - "HW version:", - api_hal_version_get_hw_version(), - api_hal_version_get_hw_target(), - api_hal_version_get_hw_body(), - api_hal_version_get_hw_connect()); - time_t time = api_hal_version_get_hw_timestamp(); - char time_string[26] = ""; - ctime_r(&time, time_string); - if(time_string[strlen(time_string) - 1] == '\n') { - time_string[strlen(time_string) - 1] = '\0'; - } - printf("%-20s %s\r\n", "Production date:", time_string); - const char* name = api_hal_version_get_name_ptr(); - if(name) { - printf("%-20s %s", "Name:", name); - } -} - void cli_command_vibro(Cli* cli, string_t args, void* context) { if(!string_cmp(args, "0")) { NotificationApp* notification = furi_record_open("notification"); diff --git a/applications/dolphin/dolphin_views.c b/applications/dolphin/dolphin_views.c index a140569d..f2a70569 100644 --- a/applications/dolphin/dolphin_views.c +++ b/applications/dolphin/dolphin_views.c @@ -15,6 +15,7 @@ void dolphin_view_first_start_draw(Canvas* canvas, void* model) { canvas_set_font(canvas, FontSecondary); uint8_t width = canvas_width(canvas); uint8_t height = canvas_height(canvas); + const char* my_name = api_hal_version_get_name_ptr(); if(m->page == 0) { canvas_draw_icon_name(canvas, 0, height - 48, I_DolphinFirstStart0_70x53); elements_multiline_text_framed(canvas, 75, 20, "Hey m8,\npress > to\ncontinue"); @@ -37,7 +38,7 @@ void dolphin_view_first_start_draw(Canvas* canvas, void* model) { 64, "%s %s%s", "I am", - api_hal_version_get_name_ptr(), + my_name ? my_name : "Unknown", ",\ncyberdolphin\nliving in your\npocket >"); canvas_draw_icon_name(canvas, 0, height - 48, I_DolphinFirstStart5_45x53); elements_multiline_text_framed(canvas, 60, 17, buf); @@ -119,6 +120,7 @@ void dolphin_view_idle_down_draw(Canvas* canvas, void* model) { if(m->screen != DolphinViewStatsMeta) { // Hardware version + const char* my_name = api_hal_version_get_name_ptr(); snprintf( buffer, sizeof(buffer), @@ -127,7 +129,7 @@ void dolphin_view_idle_down_draw(Canvas* canvas, void* model) { api_hal_version_get_hw_target(), api_hal_version_get_hw_body(), api_hal_version_get_hw_connect(), - api_hal_version_get_name_ptr()); + my_name ? my_name : "Unknown"); canvas_draw_str(canvas, 5, 23, buffer); ver = m->screen == DolphinViewStatsBoot ? api_hal_version_get_boot_version() : diff --git a/applications/dolphin/passport/passport.c b/applications/dolphin/passport/passport.c index c037d93f..c5803bee 100644 --- a/applications/dolphin/passport/passport.c +++ b/applications/dolphin/passport/passport.c @@ -80,7 +80,8 @@ static void render_callback(Canvas* canvas, void* ctx) { canvas_draw_line(canvas, 59, 31, 124, 31); canvas_draw_line(canvas, 59, 44, 124, 44); - canvas_draw_str(canvas, 59, 15, api_hal_version_get_name_ptr()); + const char* my_name = api_hal_version_get_name_ptr(); + canvas_draw_str(canvas, 59, 15, my_name ? my_name : "Unknown"); snprintf(level, 20, "Level: %ld", current_level); snprintf(mood, 20, "Mood: %s", mood_strings[butthurt]);