Add DC_FIELD_STRING support to Atomics Aquatics Cobalt parser
Just support a few of the most useful values. There are several more we could and should add. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
eac8e98ee7
commit
f902f5882c
@ -20,6 +20,12 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#include <libdivecomputer/atomics_cobalt.h>
|
||||
#include <libdivecomputer/units.h>
|
||||
@ -139,6 +145,9 @@ atomics_cobalt_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *dateti
|
||||
}
|
||||
|
||||
|
||||
#define BUFLEN 16
|
||||
|
||||
|
||||
static dc_status_t
|
||||
atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value)
|
||||
{
|
||||
@ -153,6 +162,9 @@ atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, un
|
||||
dc_tank_t *tank = (dc_tank_t *) value;
|
||||
|
||||
double atmospheric = 0.0;
|
||||
char buf[BUFLEN];
|
||||
dc_field_string_t *string = (dc_field_string_t *) value;
|
||||
|
||||
if (parser->atmospheric)
|
||||
atmospheric = parser->atmospheric;
|
||||
else
|
||||
@ -218,6 +230,29 @@ atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, un
|
||||
return DC_STATUS_DATAFORMAT;
|
||||
}
|
||||
break;
|
||||
case DC_FIELD_STRING:
|
||||
switch(flags) {
|
||||
case 0: // Serialnr
|
||||
string->desc = "Serial";
|
||||
snprintf(buf, BUFLEN, "%c%c%c%c-%c%c%c%c", p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11]);
|
||||
break;
|
||||
case 1: // Program Version
|
||||
string->desc = "Program Version";
|
||||
snprintf(buf, BUFLEN, "%.2f", array_uint16_le(p + 30) / 100.0);
|
||||
break;
|
||||
case 2: // Boot Version
|
||||
string->desc = "Boot Version";
|
||||
snprintf(buf, BUFLEN, "%.2f", array_uint16_le(p + 32) / 100.0);
|
||||
break;
|
||||
case 3: // Nofly
|
||||
string->desc = "NoFly Time";
|
||||
snprintf(buf, BUFLEN, "%0u:%02u", p[0x52], p[0x53]);
|
||||
break;
|
||||
default:
|
||||
return DC_STATUS_UNSUPPORTED;
|
||||
}
|
||||
string->value = strdup(buf);
|
||||
break;
|
||||
default:
|
||||
return DC_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user