Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgornekich <n.gorbadey@gmail.com>2021-11-04 20:26:41 +0300
committerGitHub <noreply@github.com>2021-11-04 20:26:41 +0300
commit3225f408708fafde07d942645c6e739f1c399db4 (patch)
treeaf15859945e24549788ccc31cf1228f99e0c9a9e /applications/dolphin
parentbb9c464a138a12283b6a34a9bdd5dadd7b034c8c (diff)
[FL-1952] BLE bonding fix (#805)
* 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>
Diffstat (limited to 'applications/dolphin')
-rw-r--r--applications/dolphin/helpers/dolphin_state.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/applications/dolphin/helpers/dolphin_state.c b/applications/dolphin/helpers/dolphin_state.c
index 450add29..379908c9 100644
--- a/applications/dolphin/helpers/dolphin_state.c
+++ b/applications/dolphin/helpers/dolphin_state.c
@@ -4,9 +4,10 @@
#include <math.h>
#include <toolbox/saved_struct.h>
-#define DOLPHIN_STORE_PATH "/int/dolphin.state"
-#define DOLPHIN_STORE_HEADER_MAGIC 0xD0
-#define DOLPHIN_STORE_HEADER_VERSION 0x01
+#define DOLPHIN_STATE_TAG "DolphinState"
+#define DOLPHIN_STATE_PATH "/int/dolphin.state"
+#define DOLPHIN_STATE_HEADER_MAGIC 0xD0
+#define DOLPHIN_STATE_HEADER_VERSION 0x01
#define DOLPHIN_LVL_THRESHOLD 20.0f
typedef struct {
@@ -35,28 +36,42 @@ void dolphin_state_free(DolphinState* dolphin_state) {
}
bool dolphin_state_save(DolphinState* dolphin_state) {
- return saved_struct_save(
- DOLPHIN_STORE_PATH,
+ if(!dolphin_state->dirty) {
+ return true;
+ }
+
+ bool result = saved_struct_save(
+ DOLPHIN_STATE_PATH,
&dolphin_state->data,
sizeof(DolphinStoreData),
- DOLPHIN_STORE_HEADER_MAGIC,
- DOLPHIN_STORE_HEADER_VERSION);
+ DOLPHIN_STATE_HEADER_MAGIC,
+ DOLPHIN_STATE_HEADER_VERSION);
+
+ if(result) {
+ FURI_LOG_I(DOLPHIN_STATE_TAG, "State saved");
+ dolphin_state->dirty = false;
+ } else {
+ FURI_LOG_E(DOLPHIN_STATE_TAG, "Failed to save state");
+ }
+
+ return result;
}
bool dolphin_state_load(DolphinState* dolphin_state) {
bool loaded = saved_struct_load(
- DOLPHIN_STORE_PATH,
+ DOLPHIN_STATE_PATH,
&dolphin_state->data,
sizeof(DolphinStoreData),
- DOLPHIN_STORE_HEADER_MAGIC,
- DOLPHIN_STORE_HEADER_VERSION);
+ DOLPHIN_STATE_HEADER_MAGIC,
+ DOLPHIN_STATE_HEADER_VERSION);
+
if(!loaded) {
- FURI_LOG_W("dolphin-state", "Reset dolphin-state");
+ FURI_LOG_W(DOLPHIN_STATE_TAG, "Reset dolphin-state");
memset(dolphin_state, 0, sizeof(*dolphin_state));
- dolphin_state_save(dolphin_state);
+ dolphin_state->dirty = true;
}
- return true;
+ return loaded;
}
uint64_t dolphin_state_timestamp() {