Page 1 of 1

Decoding BLE log entry date bytes

Posted: September 5th, 2021, 7:12 pm
by maidenelk
Curious if anyone knows how to decode Log Entry Date into an actual Gregorian date?

Somehow these bytes -- 89, 42 -- correspond to 2021-09-05. And these bytes -- 8, 43 -- to 2021-08-17.

At first I thought it was maybe an epoch offset...but the epoch would have been at some point in 1991, so I'm probably chasing the rabbit down the wrong hole w/ that approach. Unless the firmware developer used their first born's birthday as the epoch?! :D

Re: Decoding BLE log entry date bytes

Posted: September 5th, 2021, 7:17 pm
by angrytongan
I think this is what you're after:

Code: Select all

logDate: function(n) {
	let month = n & 0x0f;                   /* bits 0 to 3 */
        let day = (n >> 4) & 0x1f;              /* bits 4 to 8 */
        let year = 2000 + ((n >> 9) & 0x7f);    /* bits 9 to 13 (15); epoch is 2000 */

        return day + "/" + month + "/" + year;
},
From https://github.com/ergarcade/pm5-detail ... es.js#L146

Re: Decoding BLE log entry date bytes

Posted: September 5th, 2021, 7:46 pm
by maidenelk
Gorgeous, thank you!

Re: Decoding BLE log entry date bytes

Posted: February 13th, 2022, 12:03 am
by moralcode
Turns out we were both investigating this around the same time - wish I had seen this sooner.

I ended up making a diagram for the bit layout to help map each bit/byte's value to the words concept2 uses in their spec when talking about piece timestamps (the bold text on the left). Initially I was assuming the boundary between day and year was on the byte boundary, but then my year values were incorrect once 2022 rolled around. In case the diagram is confusing, the order bits are sent over the wire goes from right to left starting at the top row and working down

Image

Re: Decoding BLE log entry date bytes

Posted: October 16th, 2022, 7:12 pm
by tussocky
moralcode wrote:
February 13th, 2022, 12:03 am
Turns out we were both investigating this around the same time - wish I had seen this sooner.

I ended up making a diagram for the bit layout to help map each bit/byte's value to the words concept2 uses in their spec when talking about piece timestamps (the bold text on the left). Initially I was assuming the boundary between day and year was on the byte boundary, but then my year values were incorrect once 2022 rolled around. In case the diagram is confusing, the order bits are sent over the wire goes from right to left starting at the top row and working down

Image
This is great!