static int decode_datetime(uint8_t *buffer, unsigned int len)
{
int ret;
- uint8_t code[4] = { 0 };
+ uint8_t code[4] = { 0 }; /* the initial STX + 3 bytes command code */
struct datetime d;
uint8_t *pbuffer = buffer;
code[1] = buffer[2];
code[2] = buffer[3];
- ret = extract_datetime(pbuffer + 4, &d);
+ ret = extract_datetime(pbuffer + sizeof(code), &d);
if (ret < 0)
return ret;