diff --git a/applications/settings/about/about.c b/applications/settings/about/about.c index 97f575ab67..e6340072e5 100644 --- a/applications/settings/about/about.c +++ b/applications/settings/about/about.c @@ -138,7 +138,7 @@ static DialogMessageButton about_screen_hw_version(DialogsApp* dialogs, DialogMe furi_hal_version_get_hw_target(), furi_hal_version_get_hw_body(), furi_hal_version_get_hw_connect(), - furi_hal_version_get_hw_region_name_otp(), + furi_hal_version_get_hw_region_name(), furi_hal_region_get_name(), my_name ? my_name : "Unknown"); diff --git a/targets/f7/furi_hal/furi_hal.c b/targets/f7/furi_hal/furi_hal.c index 12a0ee88ea..03e4acdc91 100644 --- a/targets/f7/furi_hal/furi_hal.c +++ b/targets/f7/furi_hal/furi_hal.c @@ -49,6 +49,7 @@ void furi_hal_init() { furi_hal_flash_init(); furi_hal_resources_init(); furi_hal_version_init(); + furi_hal_region_init(); furi_hal_spi_config_init(); furi_hal_spi_dma_init(); furi_hal_ibutton_init(); @@ -59,7 +60,6 @@ void furi_hal_init() { furi_hal_light_init(); furi_hal_bt_init(); furi_hal_memory_init(); - furi_hal_region_init(); #ifndef FURI_RAM_EXEC furi_hal_usb_init(); diff --git a/targets/f7/furi_hal/furi_hal_region.c b/targets/f7/furi_hal/furi_hal_region.c index 84351cb7df..143d5c18c2 100644 --- a/targets/f7/furi_hal/furi_hal_region.c +++ b/targets/f7/furi_hal/furi_hal_region.c @@ -1,6 +1,5 @@ #include #include -#include const FuriHalRegion furi_hal_region_zero = { .country_code = "00", @@ -74,7 +73,7 @@ const FuriHalRegion furi_hal_region_jp = { static const FuriHalRegion* furi_hal_region = NULL; void furi_hal_region_init() { - FuriHalVersionRegion region = furi_hal_version_get_hw_region_otp(); + FuriHalVersionRegion region = furi_hal_version_get_hw_region(); if(region == FuriHalVersionRegionUnknown) { furi_hal_region = &furi_hal_region_zero; @@ -95,19 +94,16 @@ void furi_hal_region_set(FuriHalRegion* region) { furi_hal_region = region; } -const FuriHalRegionBand* furi_hal_region_get_band(uint32_t frequency) { - if(!furi_hal_region) { - return NULL; - } +bool furi_hal_region_is_provisioned() { + return furi_hal_region != NULL; +} - for(size_t i = 0; i < furi_hal_region->bands_count; i++) { - if(furi_hal_region->bands[i].start <= frequency && - furi_hal_region->bands[i].end >= frequency) { - return &furi_hal_region->bands[i]; - } +const char* furi_hal_region_get_name() { + if(furi_hal_region) { + return furi_hal_region->country_code; + } else { + return "--"; } - - return NULL; } bool furi_hal_region_is_frequency_allowed(uint32_t frequency) { @@ -123,14 +119,17 @@ bool furi_hal_region_is_frequency_allowed(uint32_t frequency) { return true; } -bool furi_hal_region_is_provisioned() { - return furi_hal_region != NULL; -} +const FuriHalRegionBand* furi_hal_region_get_band(uint32_t frequency) { + if(!furi_hal_region) { + return NULL; + } -const char* furi_hal_region_get_name() { - if(furi_hal_region) { - return furi_hal_region->country_code; - } else { - return "--"; + for(size_t i = 0; i < furi_hal_region->bands_count; i++) { + if(furi_hal_region->bands[i].start <= frequency && + furi_hal_region->bands[i].end >= frequency) { + return &furi_hal_region->bands[i]; + } } + + return NULL; } diff --git a/targets/f7/furi_hal/furi_hal_version.c b/targets/f7/furi_hal/furi_hal_version.c index 19f67ce050..8ce93b1de5 100644 --- a/targets/f7/furi_hal/furi_hal_version.c +++ b/targets/f7/furi_hal/furi_hal_version.c @@ -249,19 +249,15 @@ uint8_t furi_hal_version_get_hw_connect() { } FuriHalVersionRegion furi_hal_version_get_hw_region() { - return FuriHalVersionRegionUnknown; + return furi_hal_version.board_region; } FuriHalVersionRegion furi_hal_version_get_hw_region_otp() { - return furi_hal_version.board_region; + return furi_hal_version_get_hw_region(); } const char* furi_hal_version_get_hw_region_name() { - return "R00"; -} - -const char* furi_hal_version_get_hw_region_name_otp() { - switch(furi_hal_version_get_hw_region_otp()) { + switch(furi_hal_version_get_hw_region()) { case FuriHalVersionRegionUnknown: return "R00"; case FuriHalVersionRegionEuRu: @@ -276,6 +272,10 @@ const char* furi_hal_version_get_hw_region_name_otp() { return "R??"; } +const char* furi_hal_version_get_hw_region_name_otp() { + return furi_hal_version_get_hw_region_name(); +} + FuriHalVersionDisplay furi_hal_version_get_hw_display() { return furi_hal_version.board_display; } @@ -316,5 +316,5 @@ const uint8_t* furi_hal_version_uid() { if(version_get_custom_name(NULL) != NULL) { return (const uint8_t*)&(*((uint32_t*)version_get_custom_name(NULL))); } - return (const uint8_t*)UID64_BASE; + return furi_hal_version_uid_default(); } diff --git a/targets/furi_hal_include/furi_hal_version.h b/targets/furi_hal_include/furi_hal_version.h index 49f4f82cb1..cf8b97bfb5 100644 --- a/targets/furi_hal_include/furi_hal_version.h +++ b/targets/furi_hal_include/furi_hal_version.h @@ -141,25 +141,25 @@ FuriHalVersionColor furi_hal_version_get_hw_color(); */ uint8_t furi_hal_version_get_hw_connect(); -/** Get hardware region (fake) = 0 +/** Get hardware region * - * @return Hardware Region (fake) + * @return Hardware Region */ FuriHalVersionRegion furi_hal_version_get_hw_region(); -/** Get hardware region name (fake) = R00 +/** Get hardware region name * - * @return Hardware Region name (fake) + * @return Hardware Region name */ const char* furi_hal_version_get_hw_region_name(); -/** Get hardware region (OTP) +/** Get hardware region (compatibility with Unleashed API) * * @return Hardware Region */ FuriHalVersionRegion furi_hal_version_get_hw_region_otp(); -/** Get hardware region name (OTP) +/** Get hardware region name (compatibility with Unleashed API) * * @return Hardware Region name */