* furi-hal-bt: add mutex guarding core2 state * ble-glue: configure ble keys storage in SRAM2 * bt: add load and save ble keys in internal storage * bt: improve work furi_hal_bt API * bt: rework app_entry -> ble_glue * bt: apply changes for f6 target * desktop: remove furi check * ble-glue: comment NVM in SRAM2 configuration * FuriHal: fix flash controller state corruption, fix incorrect semaphore release, implement C1-C2 flash controller access according to spec. Gui: change logging level. * Libs: better lfs integration with lfs_config. * Ble: switch C2 NVM to RAM. * FuriHalCrypto: ensure that core2 is alive before sending shci commands * Ble: fix incorrect nvm buffer size Co-authored-by: あく <alleteam@gmail.com>
		
			
				
	
	
		
			42 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
#include "bt_keys_storage.h"
 | 
						|
#include <furi.h>
 | 
						|
#include <file-worker.h>
 | 
						|
 | 
						|
#define BT_KEYS_STORAGE_TAG "bt keys storage"
 | 
						|
#define BT_KEYS_STORAGE_PATH "/int/bt.keys"
 | 
						|
 | 
						|
bool bt_load_key_storage(Bt* bt) {
 | 
						|
    furi_assert(bt);
 | 
						|
 | 
						|
    bool file_loaded = false;
 | 
						|
    furi_hal_bt_get_key_storage_buff(&bt->bt_keys_addr_start, &bt->bt_keys_size);
 | 
						|
 | 
						|
    FileWorker* file_worker = file_worker_alloc(true);
 | 
						|
    if(file_worker_open(file_worker, BT_KEYS_STORAGE_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) {
 | 
						|
        furi_hal_bt_nvm_sram_sem_acquire();
 | 
						|
        if(file_worker_read(file_worker, bt->bt_keys_addr_start, bt->bt_keys_size)) {
 | 
						|
            file_loaded = true;
 | 
						|
        }
 | 
						|
        furi_hal_bt_nvm_sram_sem_release();
 | 
						|
    }
 | 
						|
    file_worker_free(file_worker);
 | 
						|
    return file_loaded;
 | 
						|
}
 | 
						|
 | 
						|
bool bt_save_key_storage(Bt* bt) {
 | 
						|
    furi_assert(bt);
 | 
						|
    furi_assert(bt->bt_keys_addr_start);
 | 
						|
 | 
						|
    bool file_saved = false;
 | 
						|
    FileWorker* file_worker = file_worker_alloc(true);
 | 
						|
    if(file_worker_open(file_worker, BT_KEYS_STORAGE_PATH, FSAM_WRITE, FSOM_OPEN_ALWAYS)) {
 | 
						|
        furi_hal_bt_nvm_sram_sem_acquire();
 | 
						|
        if(file_worker_write(file_worker, bt->bt_keys_addr_start, bt->bt_keys_size)) {
 | 
						|
            file_saved = true;
 | 
						|
        }
 | 
						|
        furi_hal_bt_nvm_sram_sem_release();
 | 
						|
    }
 | 
						|
    file_worker_free(file_worker);
 | 
						|
    return file_saved;
 | 
						|
}
 |