forked from flipperdevices/flipperzero-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into release-candidate
- Loading branch information
Showing
158 changed files
with
2,673 additions
and
2,165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,22 @@ | ||
#include "bt_settings.h" | ||
|
||
#include <furi.h> | ||
#include <file_worker.h> | ||
#include <lib/toolbox/saved_struct.h> | ||
|
||
#define TAG "BtSettings" | ||
#define BT_SETTINGS_PATH "/int/bt.settings" | ||
#define BT_SETTINGS_VERSION (0) | ||
#define BT_SETTINGS_MAGIC (0x19) | ||
|
||
bool bt_settings_load(BtSettings* bt_settings) { | ||
furi_assert(bt_settings); | ||
bool file_loaded = false; | ||
BtSettings settings = {}; | ||
|
||
FURI_LOG_I(TAG, "Loading settings from \"%s\"", BT_SETTINGS_PATH); | ||
FileWorker* file_worker = file_worker_alloc(true); | ||
if(file_worker_open(file_worker, BT_SETTINGS_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) { | ||
if(file_worker_read(file_worker, &settings, sizeof(settings))) { | ||
file_loaded = true; | ||
} | ||
} | ||
file_worker_free(file_worker); | ||
|
||
if(file_loaded) { | ||
FURI_LOG_I(TAG, "Settings load success"); | ||
if(settings.version != BT_SETTINGS_VERSION) { | ||
FURI_LOG_E(TAG, "Settings version mismatch"); | ||
} else { | ||
osKernelLock(); | ||
*bt_settings = settings; | ||
osKernelUnlock(); | ||
} | ||
} else { | ||
FURI_LOG_E(TAG, "Settings load failed"); | ||
} | ||
return file_loaded; | ||
return saved_struct_load( | ||
BT_SETTINGS_PATH, bt_settings, sizeof(BtSettings), BT_SETTINGS_MAGIC, BT_SETTINGS_VERSION); | ||
} | ||
|
||
bool bt_settings_save(BtSettings* bt_settings) { | ||
furi_assert(bt_settings); | ||
bool result = false; | ||
|
||
FileWorker* file_worker = file_worker_alloc(true); | ||
if(file_worker_open(file_worker, BT_SETTINGS_PATH, FSAM_WRITE, FSOM_OPEN_ALWAYS)) { | ||
if(file_worker_write(file_worker, bt_settings, sizeof(BtSettings))) { | ||
FURI_LOG_I(TAG, "Settings saved to \"%s\"", BT_SETTINGS_PATH); | ||
result = true; | ||
} | ||
} | ||
file_worker_free(file_worker); | ||
return result; | ||
return saved_struct_save( | ||
BT_SETTINGS_PATH, bt_settings, sizeof(BtSettings), BT_SETTINGS_MAGIC, BT_SETTINGS_VERSION); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.