Fix the date parsing for several models.
To store the day (range 1 to 31) as a binary encoded value, only 5 bits are required. The extra 6th bit is part of the year. The year is also not BCD encoded. This happened to work by accident, because for a single nibble, the current implementation of the bcd2dec() function returns the binary value.
This commit is contained in:
parent
06e0de6712
commit
dd779d531a
@ -251,6 +251,10 @@ oceanic_atom2_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetim
|
||||
case VEO20:
|
||||
case VEO30:
|
||||
case DG03:
|
||||
case T3A:
|
||||
case T3B:
|
||||
case GEO20:
|
||||
case PROPLUS3:
|
||||
datetime->year = ((p[3] & 0xE0) >> 1) + (p[4] & 0x0F) + 2000;
|
||||
datetime->month = (p[4] & 0xF0) >> 4;
|
||||
datetime->day = p[3] & 0x1F;
|
||||
@ -294,11 +298,7 @@ oceanic_atom2_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetim
|
||||
default:
|
||||
datetime->year = bcd2dec (((p[3] & 0xC0) >> 2) + (p[4] & 0x0F)) + 2000;
|
||||
datetime->month = (p[4] & 0xF0) >> 4;
|
||||
if (parser->model == T3A || parser->model == T3B ||
|
||||
parser->model == GEO20 || parser->model == PROPLUS3)
|
||||
datetime->day = p[3] & 0x3F;
|
||||
else
|
||||
datetime->day = bcd2dec (p[3] & 0x3F);
|
||||
datetime->day = bcd2dec (p[3] & 0x3F);
|
||||
datetime->hour = bcd2dec (p[1] & 0x1F);
|
||||
datetime->minute = bcd2dec (p[0]);
|
||||
break;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user