23ff6723cf
* bt: update connection parameters * bt: set correct connection latency and timeout * gui popup: add clean method * furi_hal_bt: add connection parameters request, clear database * bt: add forget bonded devices API * bt_settings: add forget bonded devices GUI * bt: rework pin code show with view port to hide view * bt: support conn parameters for different profiles * furi_hal_bt: sync f6 target * target f6: fix build * bt: format sources * furi_hal_bt: update connection parameters * bt: update connection params, fix GUI * FuriHal: fix spelling * Refactoring: rename _clean to _reset Co-authored-by: あく <alleteam@gmail.com>
55 lines
1.6 KiB
C
55 lines
1.6 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;
|
|
}
|
|
|
|
bool bt_delete_key_storage(Bt* bt) {
|
|
furi_assert(bt);
|
|
bool delete_succeed = false;
|
|
|
|
furi_hal_bt_stop_advertising();
|
|
delete_succeed = furi_hal_bt_clear_white_list();
|
|
if(bt->bt_settings.enabled) {
|
|
furi_hal_bt_start_advertising();
|
|
}
|
|
|
|
return delete_succeed;
|
|
}
|