Loading...
Searching...
No Matches
store_persist.h File Reference

Shared persist save and restore helpers for the stores. More...

#include <pebble.h>
#include "io/stores/store_sum.h"

Go to the source code of this file.

Macros

Store tags

Every store stamps the first byte of its blob with a tag. The high nibble names the store and the low nibble is that store's layout revision.

The size on its own cannot tell two blobs apart. Reordering two fields keeps the size, and so can two different structs, so the tag is what makes the guard mean anything. Bump a store's low nibble whenever its persisted struct changes shape, and an older blob is dropped rather than read as the wrong thing.

#define STORE_TAG_WEATHER   0x13
 The weather store's blob.
#define STORE_TAG_STOCK   0x21
 The stock store's blob.
#define STORE_TAG_CALENDAR   0x31
 The calendar store's snapshot.
#define STORE_TAG_HEALTH   0x42
 The health store's saved heart rate window.
#define STORE_TAG_LOCATION   0x51
 The location store's last fix.

Functions

static bool store_restore (uint32_t key, void *state, size_t size, uint8_t tag)
 Restore a saved blob into state, but only when it is this store's own current layout.
static bool store_save (uint32_t key, void *state, size_t size, uint8_t tag)
 Save a store's blob with its tag stamped in, so the next restore can recognize it.
bool store_save_changed (uint32_t key, void *state, size_t size, size_t reading_size, uint8_t tag, uint32_t *saved_sum)
 Save a store's blob only when its reading is different from what is already on flash.
bool store_restore_reading (uint32_t key, void *state, size_t size, size_t reading_size, uint8_t tag, uint32_t *saved_sum)
 Restore a saved blob as store_restore does, and record the sum of the reading it holds.

Detailed Description

Shared persist save and restore helpers for the stores.