core: load and save fingerprint to cloud storage

Very similar structure to the XML format. Raw data is again saved as a
hex string (which implicitly provides us with its length). The rest of
components are in a more human readable format.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2021-10-30 18:01:14 -07:00
parent 2b1db9da82
commit 31e688ec00
2 changed files with 68 additions and 1 deletions

View file

@ -869,6 +869,16 @@ static void save_one_device(struct membuffer *b, const struct device *d)
put_string(b, "\n");
}
static void save_one_fingerprint(struct membuffer *b, unsigned int i)
{
put_format(b, "fingerprint model=%08x serial=%08x deviceid=%08x diveid=%08x data=\"%s\"\n",
fp_get_model(&fingerprint_table, i),
fp_get_serial(&fingerprint_table, i),
fp_get_deviceid(&fingerprint_table, i),
fp_get_diveid(&fingerprint_table, i),
fp_get_data(&fingerprint_table, i));
}
static void save_settings(git_repository *repo, struct dir *tree)
{
struct membuffer b = { 0 };
@ -876,6 +886,10 @@ static void save_settings(git_repository *repo, struct dir *tree)
put_format(&b, "version %d\n", DATAFORMAT_VERSION);
for (int i = 0; i < nr_devices(&device_table); i++)
save_one_device(&b, get_device(&device_table, i));
/* save the fingerprint data */
for (unsigned int i = 0; i < nr_fingerprints(&fingerprint_table); i++)
save_one_fingerprint(&b, i);
cond_put_format(autogroup, &b, "autogroup\n");
save_units(&b);
if (prefs.tankbar)