Decoding BLE log entry date bytes

Post questions and issues with Concept2 PM3 SDK
Post Reply
maidenelk
Paddler
Posts: 5
Joined: September 4th, 2021, 8:49 pm

Decoding BLE log entry date bytes

Post by maidenelk » September 5th, 2021, 7:12 pm

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

angrytongan
Paddler
Posts: 33
Joined: October 30th, 2015, 11:10 pm

Re: Decoding BLE log entry date bytes

Post by angrytongan » September 5th, 2021, 7:17 pm

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
Image
Male, 46, 5'11", 100kg, log.

maidenelk
Paddler
Posts: 5
Joined: September 4th, 2021, 8:49 pm

Re: Decoding BLE log entry date bytes

Post by maidenelk » September 5th, 2021, 7:46 pm

Gorgeous, thank you!

moralcode
Paddler
Posts: 1
Joined: February 12th, 2022, 5:27 pm

Re: Decoding BLE log entry date bytes

Post by moralcode » 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

tussocky
Paddler
Posts: 6
Joined: December 4th, 2021, 5:14 am

Re: Decoding BLE log entry date bytes

Post by tussocky » October 16th, 2022, 7:12 pm

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!

Post Reply