mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +04:00
Storage: remove LFS (#3577)
* Storage: drop internal storage * Storage: rollback some unnecessary changes * Storage: rollback some unnecessary changes part 2 * Storage: cleanup various defines and int handling. Ble: allow short connection interval if internal flash is not used. * Storage: do not return storage if it is not ready * Save PIN code to RTC, update settings * Simplify the code, clean up includes * Rearrange some code * apps: storage_move_to_sd: conditionally enable with --extra-define=STORAGE_INT_ON_LFS * Load Desktop settings automatically * Redirect /any to /ext * Abolish storage_move_to_sd app * Remove as many mentions of ANY_PATH as possible * Fix desktop settings wrongly not loading * Improve desktop settings handling and strings * Load BLE settings and keys automatically * Improve BLE configuration procedure * Do not load bluetooth keys twice if they were already loaded * Load dolphin state automatically * Fix merge artifact * Load notification settings automatically * Update desktop settings strings * Load expansion settings automatically * Do not use thread signals to reload desktop settings * Load region data automatically, separate to its own hook * Improve ble behaviour with no keys * Fix Dolphin state not resetting correctly * Add a status check * Make Desktop save its own settings * Check result when taking and releasing mutex * Improve default thread signal handling in FuriEventLoop * Make bt service in charge of saving settings, add settings api * Fix a deadlock due to timer thread not receiving time * Lock core2 when reinitialising bt * Update clang-format * Revert "Update clang-format" This reverts commit d61295ac063c6ec879375ceeab54d6ff2c90a9a1. * Format sources with clang-format * Revert old stack size for desktop settings * Allocate big struct dynamically * Simplify PIN comparison * Save pointer to storage in Desktop object * Fix region provisioning for hardware regions * Remove stale TODO + siimplify code * Clean up region.c * Use sizeof instead of macro define * Limit PIN length to 10 for consistency * Emit a warning upon usage of /any * Add delay after finding flipper * Remove unnecessary delay * Remove all mentions of STORAGE_INT_ON_LFS * Remove littlefs and internal storage * Remove all possible LittleFS mentions * Fix browser tab in Archive * Ble: fix connection interval explanation * Bump API Symbols * BLE: Update comments interval connection comments * Storage: clear FuriHalRtcFlagStorageFormatInternal if set --------- Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com> Co-authored-by: hedger <hedger@nanode.su> Co-authored-by: Georgii Surkov <37121527+gsurkov@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,70.0,,
|
||||
Version,+,71.0,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
@@ -687,6 +687,7 @@ Function,+,bt_forget_bonded_devices,void,Bt*
|
||||
Function,+,bt_keys_storage_alloc,BtKeysStorage*,const char*
|
||||
Function,+,bt_keys_storage_delete,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_free,void,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_is_changed,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_load,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_set_default_path,void,Bt*
|
||||
Function,+,bt_keys_storage_set_file_path,void,"BtKeysStorage*, const char*"
|
||||
@@ -1372,6 +1373,7 @@ Function,+,furi_hal_rtc_get_log_baud_rate,FuriHalRtcLogBaudRate,
|
||||
Function,+,furi_hal_rtc_get_log_device,FuriHalRtcLogDevice,
|
||||
Function,+,furi_hal_rtc_get_log_level,uint8_t,
|
||||
Function,+,furi_hal_rtc_get_pin_fails,uint32_t,
|
||||
Function,-,furi_hal_rtc_get_pin_value,uint32_t,
|
||||
Function,+,furi_hal_rtc_get_register,uint32_t,FuriHalRtcRegister
|
||||
Function,+,furi_hal_rtc_get_timestamp,uint32_t,
|
||||
Function,-,furi_hal_rtc_init,void,
|
||||
@@ -1391,6 +1393,7 @@ Function,+,furi_hal_rtc_set_log_baud_rate,void,FuriHalRtcLogBaudRate
|
||||
Function,+,furi_hal_rtc_set_log_device,void,FuriHalRtcLogDevice
|
||||
Function,+,furi_hal_rtc_set_log_level,void,uint8_t
|
||||
Function,+,furi_hal_rtc_set_pin_fails,void,uint32_t
|
||||
Function,-,furi_hal_rtc_set_pin_value,void,uint32_t
|
||||
Function,+,furi_hal_rtc_set_register,void,"FuriHalRtcRegister, uint32_t"
|
||||
Function,+,furi_hal_rtc_sync_shadow,void,
|
||||
Function,+,furi_hal_sd_get_card_state,FuriStatus,
|
||||
@@ -1626,6 +1629,7 @@ Function,+,furi_thread_get_id,FuriThreadId,FuriThread*
|
||||
Function,+,furi_thread_get_name,const char*,FuriThreadId
|
||||
Function,+,furi_thread_get_priority,FuriThreadPriority,FuriThread*
|
||||
Function,+,furi_thread_get_return_code,int32_t,FuriThread*
|
||||
Function,+,furi_thread_get_signal_callback,FuriThreadSignalCallback,const FuriThread*
|
||||
Function,+,furi_thread_get_stack_space,uint32_t,FuriThreadId
|
||||
Function,+,furi_thread_get_state,FuriThreadState,FuriThread*
|
||||
Function,+,furi_thread_get_stdout_callback,FuriThreadStdoutWriteCallback,
|
||||
@@ -2509,7 +2513,7 @@ Function,+,storage_file_write,size_t,"File*, const void*, size_t"
|
||||
Function,+,storage_get_next_filename,void,"Storage*, const char*, const char*, const char*, FuriString*, uint8_t"
|
||||
Function,+,storage_get_pubsub,FuriPubSub*,Storage*
|
||||
Function,+,storage_int_backup,FS_Error,"Storage*, const char*"
|
||||
Function,+,storage_int_restore,FS_Error,"Storage*, const char*, Storage_name_converter"
|
||||
Function,+,storage_int_restore,FS_Error,"Storage*, const char*, StorageNameConverter"
|
||||
Function,+,storage_sd_format,FS_Error,Storage*
|
||||
Function,+,storage_sd_info,FS_Error,"Storage*, SDInfo*"
|
||||
Function,+,storage_sd_mount,FS_Error,Storage*
|
||||
@@ -2641,7 +2645,7 @@ Function,+,tar_archive_open,_Bool,"TarArchive*, const char*, TarOpenMode"
|
||||
Function,+,tar_archive_set_file_callback,void,"TarArchive*, tar_unpack_file_cb, void*"
|
||||
Function,+,tar_archive_store_data,_Bool,"TarArchive*, const char*, const uint8_t*, const int32_t"
|
||||
Function,+,tar_archive_unpack_file,_Bool,"TarArchive*, const char*, const char*"
|
||||
Function,+,tar_archive_unpack_to,_Bool,"TarArchive*, const char*, Storage_name_converter"
|
||||
Function,+,tar_archive_unpack_to,_Bool,"TarArchive*, const char*, TarArchiveNameConverter"
|
||||
Function,-,tempnam,char*,"const char*, const char*"
|
||||
Function,+,text_box_alloc,TextBox*,
|
||||
Function,+,text_box_free,void,TextBox*
|
||||
|
||||
|
@@ -17,7 +17,6 @@
|
||||
"stm32wb",
|
||||
"hwdrivers",
|
||||
"fatfs",
|
||||
"littlefs",
|
||||
"toolbox",
|
||||
"digital_signal",
|
||||
"signal_reader",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,70.0,,
|
||||
Version,+,71.0,,
|
||||
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
|
||||
@@ -764,6 +764,7 @@ Function,+,bt_forget_bonded_devices,void,Bt*
|
||||
Function,+,bt_keys_storage_alloc,BtKeysStorage*,const char*
|
||||
Function,+,bt_keys_storage_delete,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_free,void,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_is_changed,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_load,_Bool,BtKeysStorage*
|
||||
Function,+,bt_keys_storage_set_default_path,void,Bt*
|
||||
Function,+,bt_keys_storage_set_file_path,void,"BtKeysStorage*, const char*"
|
||||
@@ -1556,6 +1557,7 @@ Function,+,furi_hal_rtc_get_log_baud_rate,FuriHalRtcLogBaudRate,
|
||||
Function,+,furi_hal_rtc_get_log_device,FuriHalRtcLogDevice,
|
||||
Function,+,furi_hal_rtc_get_log_level,uint8_t,
|
||||
Function,+,furi_hal_rtc_get_pin_fails,uint32_t,
|
||||
Function,-,furi_hal_rtc_get_pin_value,uint32_t,
|
||||
Function,+,furi_hal_rtc_get_register,uint32_t,FuriHalRtcRegister
|
||||
Function,+,furi_hal_rtc_get_timestamp,uint32_t,
|
||||
Function,-,furi_hal_rtc_init,void,
|
||||
@@ -1575,6 +1577,7 @@ Function,+,furi_hal_rtc_set_log_baud_rate,void,FuriHalRtcLogBaudRate
|
||||
Function,+,furi_hal_rtc_set_log_device,void,FuriHalRtcLogDevice
|
||||
Function,+,furi_hal_rtc_set_log_level,void,uint8_t
|
||||
Function,+,furi_hal_rtc_set_pin_fails,void,uint32_t
|
||||
Function,-,furi_hal_rtc_set_pin_value,void,uint32_t
|
||||
Function,+,furi_hal_rtc_set_register,void,"FuriHalRtcRegister, uint32_t"
|
||||
Function,+,furi_hal_rtc_sync_shadow,void,
|
||||
Function,+,furi_hal_sd_get_card_state,FuriStatus,
|
||||
@@ -1840,6 +1843,7 @@ Function,+,furi_thread_get_id,FuriThreadId,FuriThread*
|
||||
Function,+,furi_thread_get_name,const char*,FuriThreadId
|
||||
Function,+,furi_thread_get_priority,FuriThreadPriority,FuriThread*
|
||||
Function,+,furi_thread_get_return_code,int32_t,FuriThread*
|
||||
Function,+,furi_thread_get_signal_callback,FuriThreadSignalCallback,const FuriThread*
|
||||
Function,+,furi_thread_get_stack_space,uint32_t,FuriThreadId
|
||||
Function,+,furi_thread_get_state,FuriThreadState,FuriThread*
|
||||
Function,+,furi_thread_get_stdout_callback,FuriThreadStdoutWriteCallback,
|
||||
@@ -3186,7 +3190,7 @@ Function,+,storage_file_write,size_t,"File*, const void*, size_t"
|
||||
Function,+,storage_get_next_filename,void,"Storage*, const char*, const char*, const char*, FuriString*, uint8_t"
|
||||
Function,+,storage_get_pubsub,FuriPubSub*,Storage*
|
||||
Function,+,storage_int_backup,FS_Error,"Storage*, const char*"
|
||||
Function,+,storage_int_restore,FS_Error,"Storage*, const char*, Storage_name_converter"
|
||||
Function,+,storage_int_restore,FS_Error,"Storage*, const char*, StorageNameConverter"
|
||||
Function,+,storage_sd_format,FS_Error,Storage*
|
||||
Function,+,storage_sd_info,FS_Error,"Storage*, SDInfo*"
|
||||
Function,+,storage_sd_mount,FS_Error,Storage*
|
||||
@@ -3482,7 +3486,7 @@ Function,+,tar_archive_open,_Bool,"TarArchive*, const char*, TarOpenMode"
|
||||
Function,+,tar_archive_set_file_callback,void,"TarArchive*, tar_unpack_file_cb, void*"
|
||||
Function,+,tar_archive_store_data,_Bool,"TarArchive*, const char*, const uint8_t*, const int32_t"
|
||||
Function,+,tar_archive_unpack_file,_Bool,"TarArchive*, const char*, const char*"
|
||||
Function,+,tar_archive_unpack_to,_Bool,"TarArchive*, const char*, Storage_name_converter"
|
||||
Function,+,tar_archive_unpack_to,_Bool,"TarArchive*, const char*, TarArchiveNameConverter"
|
||||
Function,-,tempnam,char*,"const char*, const char*"
|
||||
Function,+,text_box_alloc,TextBox*,
|
||||
Function,+,text_box_free,void,TextBox*
|
||||
|
||||
|
@@ -8,9 +8,9 @@
|
||||
|
||||
#define GAP_MS_TO_SCAN_INTERVAL(x) ((uint16_t)((x) / 0.625))
|
||||
|
||||
// Also used as an indicator of whether the beacon had ever been configured
|
||||
// AN5289: 4.7, we need at least 25ms + advertisement, which is 30 ms
|
||||
#define GAP_MIN_ADV_INTERVAL_MS (30u)
|
||||
// AN5289: 4.7, in order to use flash controller interval must be at least 25ms + advertisement, which is 30 ms
|
||||
// Since we don't use flash controller anymore interval can be lowered to 20ms
|
||||
#define GAP_MIN_ADV_INTERVAL_MS (20U)
|
||||
|
||||
typedef struct {
|
||||
GapExtraBeaconConfig last_config;
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
(LL_C2_IPCC_IsActiveFlag_CHx(IPCC, channel) && \
|
||||
LL_C1_IPCC_IsEnabledReceiveChannel(IPCC, channel))
|
||||
|
||||
#define IPCC_SEND_CMD_TIMEOUT_US (33UL * 1000UL * 1000UL)
|
||||
|
||||
static void (*FreeBufCb)(void);
|
||||
|
||||
static void HW_IPCC_BLE_EvtHandler(void);
|
||||
@@ -113,7 +115,7 @@ void HW_IPCC_SYS_Init(void) {
|
||||
void HW_IPCC_SYS_SendCmd(void) {
|
||||
LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL);
|
||||
|
||||
FuriHalCortexTimer timer = furi_hal_cortex_timer_get(33000000);
|
||||
FuriHalCortexTimer timer = furi_hal_cortex_timer_get(IPCC_SEND_CMD_TIMEOUT_US);
|
||||
|
||||
while(LL_C1_IPCC_IsActiveFlag_CHx(IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL)) {
|
||||
furi_check(!furi_hal_cortex_timer_is_expired(timer), "HW_IPCC_SYS_SendCmd timeout");
|
||||
|
||||
@@ -40,14 +40,20 @@ static void ble_profile_serial_stop(FuriHalBleProfileBase* profile) {
|
||||
ble_svc_serial_stop(serial_profile->serial_svc);
|
||||
}
|
||||
|
||||
// AN5289: 4.7, in order to use flash controller interval must be at least 25ms + advertisement, which is 30 ms
|
||||
// Since we don't use flash controller anymore interval can be lowered to 7.5ms
|
||||
#define CONNECTION_INTERVAL_MIN (0x06)
|
||||
// Up to 45 ms
|
||||
#define CONNECTION_INTERVAL_MAX (0x24)
|
||||
|
||||
static GapConfig serial_template_config = {
|
||||
.adv_service_uuid = 0x3080,
|
||||
.appearance_char = 0x8600,
|
||||
.bonding_mode = true,
|
||||
.pairing_method = GapPairingPinCodeShow,
|
||||
.conn_param = {
|
||||
.conn_int_min = 0x18, // AN5289: 4.7, we need at least 25ms + advertisement, which is 30 ms
|
||||
.conn_int_max = 0x24, // 45 ms
|
||||
.conn_int_min = CONNECTION_INTERVAL_MIN,
|
||||
.conn_int_max = CONNECTION_INTERVAL_MAX,
|
||||
.slave_latency = 0,
|
||||
.supervisor_timeout = 0,
|
||||
}};
|
||||
|
||||
@@ -87,10 +87,9 @@ static bool furi_hal_bt_radio_stack_is_supported(const BleGlueC2Info* info) {
|
||||
}
|
||||
|
||||
bool furi_hal_bt_start_radio_stack(void) {
|
||||
bool res = false;
|
||||
furi_check(furi_hal_bt.core2_mtx);
|
||||
furi_hal_bt_lock_core2();
|
||||
|
||||
furi_mutex_acquire(furi_hal_bt.core2_mtx, FuriWaitForever);
|
||||
bool res = false;
|
||||
|
||||
// Explicitly tell that we are in charge of CLK48 domain
|
||||
furi_check(LL_HSEM_1StepLock(HSEM, CFG_HW_CLK48_CONFIG_SEMID) == 0);
|
||||
@@ -123,7 +122,8 @@ bool furi_hal_bt_start_radio_stack(void) {
|
||||
}
|
||||
res = true;
|
||||
} while(false);
|
||||
furi_mutex_release(furi_hal_bt.core2_mtx);
|
||||
|
||||
furi_hal_bt_unlock_core2();
|
||||
|
||||
gap_extra_beacon_init();
|
||||
return res;
|
||||
@@ -198,6 +198,8 @@ FuriHalBleProfileBase* furi_hal_bt_start_app(
|
||||
}
|
||||
|
||||
void furi_hal_bt_reinit(void) {
|
||||
furi_hal_bt_lock_core2();
|
||||
|
||||
furi_hal_power_insomnia_enter();
|
||||
FURI_LOG_I(TAG, "Disconnect and stop advertising");
|
||||
furi_hal_bt_stop_advertising();
|
||||
@@ -229,6 +231,7 @@ void furi_hal_bt_reinit(void) {
|
||||
furi_hal_bus_disable(FuriHalBusCRC);
|
||||
|
||||
furi_hal_bt_init();
|
||||
furi_hal_bt_unlock_core2();
|
||||
furi_hal_bt_start_radio_stack();
|
||||
furi_hal_power_insomnia_exit();
|
||||
}
|
||||
|
||||
@@ -262,36 +262,54 @@ bool furi_hal_crypto_enclave_load_key(uint8_t slot, const uint8_t* iv) {
|
||||
|
||||
furi_hal_bus_enable(FuriHalBusAES1);
|
||||
|
||||
if(!furi_hal_bt_is_alive()) {
|
||||
return false;
|
||||
}
|
||||
bool success = false;
|
||||
|
||||
furi_hal_crypto_mode_init_done = false;
|
||||
crypto_key_init(NULL, (uint32_t*)iv);
|
||||
furi_hal_bt_lock_core2();
|
||||
|
||||
if(SHCI_C2_FUS_LoadUsrKey(slot) == SHCI_Success) {
|
||||
return true;
|
||||
} else {
|
||||
CLEAR_BIT(AES1->CR, AES_CR_EN);
|
||||
furi_check(furi_mutex_release(furi_hal_crypto_mutex) == FuriStatusOk);
|
||||
return false;
|
||||
}
|
||||
do {
|
||||
if(!furi_hal_bt_is_alive()) {
|
||||
break;
|
||||
}
|
||||
|
||||
furi_hal_crypto_mode_init_done = false;
|
||||
crypto_key_init(NULL, (uint32_t*)iv);
|
||||
|
||||
if(SHCI_C2_FUS_LoadUsrKey(slot) == SHCI_Success) {
|
||||
success = true;
|
||||
} else {
|
||||
CLEAR_BIT(AES1->CR, AES_CR_EN);
|
||||
furi_check(furi_mutex_release(furi_hal_crypto_mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
} while(false);
|
||||
|
||||
furi_hal_bt_unlock_core2();
|
||||
return success;
|
||||
}
|
||||
|
||||
bool furi_hal_crypto_enclave_unload_key(uint8_t slot) {
|
||||
if(!furi_hal_bt_is_alive()) {
|
||||
return false;
|
||||
}
|
||||
furi_hal_bt_lock_core2();
|
||||
|
||||
CLEAR_BIT(AES1->CR, AES_CR_EN);
|
||||
bool success = false;
|
||||
|
||||
SHCI_CmdStatus_t shci_state = SHCI_C2_FUS_UnloadUsrKey(slot);
|
||||
do {
|
||||
if(!furi_hal_bt_is_alive()) {
|
||||
break;
|
||||
}
|
||||
|
||||
furi_hal_bus_disable(FuriHalBusAES1);
|
||||
CLEAR_BIT(AES1->CR, AES_CR_EN);
|
||||
|
||||
furi_check(furi_mutex_release(furi_hal_crypto_mutex) == FuriStatusOk);
|
||||
SHCI_CmdStatus_t shci_state = SHCI_C2_FUS_UnloadUsrKey(slot);
|
||||
|
||||
return shci_state == SHCI_Success;
|
||||
furi_hal_bus_disable(FuriHalBusAES1);
|
||||
|
||||
furi_check(furi_mutex_release(furi_hal_crypto_mutex) == FuriStatusOk);
|
||||
|
||||
success = (shci_state == SHCI_Success);
|
||||
} while(false);
|
||||
|
||||
furi_hal_bt_unlock_core2();
|
||||
return success;
|
||||
}
|
||||
|
||||
bool furi_hal_crypto_load_key(const uint8_t* key, const uint8_t* iv) {
|
||||
|
||||
@@ -71,66 +71,80 @@ const FuriHalRegion furi_hal_region_jp = {
|
||||
.duty_cycle = 50,
|
||||
}}};
|
||||
|
||||
static const FuriHalRegion* furi_hal_region = NULL;
|
||||
static const FuriHalRegion* const furi_hal_static_regions[] = {
|
||||
[FuriHalVersionRegionUnknown] = &furi_hal_region_zero,
|
||||
[FuriHalVersionRegionEuRu] = &furi_hal_region_eu_ru,
|
||||
[FuriHalVersionRegionUsCaAu] = &furi_hal_region_us_ca_au,
|
||||
[FuriHalVersionRegionJp] = &furi_hal_region_jp,
|
||||
};
|
||||
|
||||
static FuriHalRegion* furi_hal_dynamic_region;
|
||||
static FuriMutex* furi_hal_dynamic_region_mutex;
|
||||
|
||||
void furi_hal_region_init(void) {
|
||||
FuriHalVersionRegion region = furi_hal_version_get_hw_region();
|
||||
|
||||
if(region == FuriHalVersionRegionUnknown) {
|
||||
furi_hal_region = &furi_hal_region_zero;
|
||||
} else if(region == FuriHalVersionRegionEuRu) {
|
||||
furi_hal_region = &furi_hal_region_eu_ru;
|
||||
} else if(region == FuriHalVersionRegionUsCaAu) {
|
||||
furi_hal_region = &furi_hal_region_us_ca_au;
|
||||
} else if(region == FuriHalVersionRegionJp) {
|
||||
furi_hal_region = &furi_hal_region_jp;
|
||||
}
|
||||
furi_assert(furi_hal_dynamic_region_mutex == NULL);
|
||||
furi_hal_dynamic_region_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
}
|
||||
|
||||
const FuriHalRegion* furi_hal_region_get(void) {
|
||||
return furi_hal_region;
|
||||
const FuriHalVersionRegion region = furi_hal_version_get_hw_region();
|
||||
const FuriHalRegion* ret;
|
||||
|
||||
furi_check(furi_mutex_acquire(furi_hal_dynamic_region_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
if(region < FuriHalVersionRegionWorld && furi_hal_dynamic_region == NULL) {
|
||||
ret = furi_hal_static_regions[region];
|
||||
} else {
|
||||
ret = furi_hal_dynamic_region;
|
||||
}
|
||||
|
||||
furi_check(furi_mutex_release(furi_hal_dynamic_region_mutex) == FuriStatusOk);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void furi_hal_region_set(FuriHalRegion* region) {
|
||||
furi_check(region);
|
||||
|
||||
furi_hal_region = region;
|
||||
furi_check(furi_mutex_acquire(furi_hal_dynamic_region_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
if(furi_hal_dynamic_region) {
|
||||
free(furi_hal_dynamic_region);
|
||||
}
|
||||
|
||||
furi_hal_dynamic_region = region;
|
||||
|
||||
furi_check(furi_mutex_release(furi_hal_dynamic_region_mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
bool furi_hal_region_is_provisioned(void) {
|
||||
return furi_hal_region != NULL;
|
||||
return furi_hal_region_get() != NULL;
|
||||
}
|
||||
|
||||
const char* furi_hal_region_get_name(void) {
|
||||
if(furi_hal_region) {
|
||||
return furi_hal_region->country_code;
|
||||
const FuriHalRegion* region = furi_hal_region_get();
|
||||
|
||||
if(region) {
|
||||
return region->country_code;
|
||||
} else {
|
||||
return "--";
|
||||
}
|
||||
}
|
||||
|
||||
bool furi_hal_region_is_frequency_allowed(uint32_t frequency) {
|
||||
if(!furi_hal_region) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const FuriHalRegionBand* band = furi_hal_region_get_band(frequency);
|
||||
if(!band) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return furi_hal_region_get_band(frequency) != NULL;
|
||||
}
|
||||
|
||||
const FuriHalRegionBand* furi_hal_region_get_band(uint32_t frequency) {
|
||||
if(!furi_hal_region) {
|
||||
const FuriHalRegion* region = furi_hal_region_get();
|
||||
|
||||
if(!region) {
|
||||
return 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];
|
||||
for(size_t i = 0; i < region->bands_count; i++) {
|
||||
if(region->bands[i].start <= frequency && region->bands[i].end >= frequency) {
|
||||
return ®ion->bands[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -411,6 +411,14 @@ uint32_t furi_hal_rtc_get_pin_fails(void) {
|
||||
return furi_hal_rtc_get_register(FuriHalRtcRegisterPinFails);
|
||||
}
|
||||
|
||||
void furi_hal_rtc_set_pin_value(uint32_t value) {
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterPinValue, value);
|
||||
}
|
||||
|
||||
uint32_t furi_hal_rtc_get_pin_value(void) {
|
||||
return furi_hal_rtc_get_register(FuriHalRtcRegisterPinValue);
|
||||
}
|
||||
|
||||
uint32_t furi_hal_rtc_get_timestamp(void) {
|
||||
DateTime datetime = {0};
|
||||
furi_hal_rtc_get_datetime(&datetime);
|
||||
|
||||
@@ -46,9 +46,10 @@ typedef enum {
|
||||
FuriHalRtcRegisterVersion, /**< Pointer to Version */
|
||||
FuriHalRtcRegisterLfsFingerprint, /**< LFS geometry fingerprint */
|
||||
FuriHalRtcRegisterFaultData, /**< Pointer to last fault message */
|
||||
FuriHalRtcRegisterPinFails, /**< Failed pins count */
|
||||
FuriHalRtcRegisterPinFails, /**< Failed PINs count */
|
||||
/* Index of FS directory entry corresponding to FW update to be applied */
|
||||
FuriHalRtcRegisterUpdateFolderFSIndex,
|
||||
FuriHalRtcRegisterPinValue, /**< Encoded value of the currently set PIN */
|
||||
|
||||
FuriHalRtcRegisterMAX, /**< Service value, do not use */
|
||||
} FuriHalRtcRegister;
|
||||
@@ -257,18 +258,29 @@ void furi_hal_rtc_set_fault_data(uint32_t value);
|
||||
*/
|
||||
uint32_t furi_hal_rtc_get_fault_data(void);
|
||||
|
||||
/** Set Pin Fails count
|
||||
/** Set PIN Fails count
|
||||
*
|
||||
* @param[in] value The Pin Fails count
|
||||
* @param[in] value The PIN Fails count
|
||||
*/
|
||||
void furi_hal_rtc_set_pin_fails(uint32_t value);
|
||||
|
||||
/** Get Pin Fails count
|
||||
/** Get PIN Fails count
|
||||
*
|
||||
* @return Pin Fails Count
|
||||
* @return PIN Fails Count
|
||||
*/
|
||||
uint32_t furi_hal_rtc_get_pin_fails(void);
|
||||
|
||||
/** Set encoded PIN value
|
||||
*
|
||||
* @param[in] value new PIN code value to be set
|
||||
*/
|
||||
void furi_hal_rtc_set_pin_value(uint32_t value);
|
||||
|
||||
/** Get the current PIN encoded value
|
||||
*
|
||||
*/
|
||||
uint32_t furi_hal_rtc_get_pin_value(void);
|
||||
|
||||
/** Get UNIX Timestamp
|
||||
*
|
||||
* @return Unix Timestamp in seconds from UNIX epoch start
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
"stm32wb",
|
||||
"hwdrivers",
|
||||
"fatfs",
|
||||
"littlefs",
|
||||
"subghz",
|
||||
"toolbox",
|
||||
"nfc",
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
Reference in New Issue
Block a user