mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Improve on divecomputer data handling
This simplifies the vendor/product fields into just a single "model" string for the dive computer, since we can't really validly ever use it any other way anyway. Also, add 'deviceid' and 'diveid' fields: they are just 32-bit hex values that are unique for that particular dive computer model. For libdivecomputer, they are basically the first word of the SHA1 of the data that libdivecomputer gives us. (Trying to expose it in some other way is insane - different dive computers use different models for the ID, so don't try to do some kind of serial number or something like that) For the Uemis Zurich, which doesn't use the libdivecomputer import, we currently only set the model name. The computer does have some kind of device ID string, and we could/should just do the same "SHA1 over the ID" to give it a unique ID, but the pseudo-xml parsing confuses me, so I'll let Dirk fix that up. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1b861ba20e
commit
1ca1fe7994
7 changed files with 105 additions and 14 deletions
15
parse-xml.c
15
parse-xml.c
|
@ -523,6 +523,13 @@ static void get_index(char *buffer, void *_i)
|
|||
free(buffer);
|
||||
}
|
||||
|
||||
static void hex_value(char *buffer, void *_i)
|
||||
{
|
||||
uint32_t *i = _i;
|
||||
*i = strtol(buffer, NULL, 16);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
static void get_tripflag(char *buffer, void *_tf)
|
||||
{
|
||||
tripflag_t *tf = _tf;
|
||||
|
@ -715,9 +722,11 @@ static void try_to_fill_dc(struct divecomputer *dc, const char *name, char *buf)
|
|||
return;
|
||||
if (MATCH(".time", divetime, &dc->when))
|
||||
return;
|
||||
if (MATCH(".vendor", utf8_string, &dc->vendor))
|
||||
if (MATCH(".model", utf8_string, &dc->model))
|
||||
return;
|
||||
if (MATCH(".product", utf8_string, &dc->product))
|
||||
if (MATCH(".deviceid", hex_value, &dc->deviceid))
|
||||
return;
|
||||
if (MATCH(".diveid", hex_value, &dc->diveid))
|
||||
return;
|
||||
|
||||
nonmatch("divecomputer", name, buf);
|
||||
|
@ -1333,7 +1342,7 @@ static void divecomputer_start(void)
|
|||
dc = dc->next;
|
||||
|
||||
/* Did we already fill that in? */
|
||||
if (dc->samples || dc->vendor || dc->product || dc->when) {
|
||||
if (dc->samples || dc->model || dc->when) {
|
||||
struct divecomputer *newdc = calloc(1, sizeof(*newdc));
|
||||
if (newdc) {
|
||||
dc->next = newdc;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue