polarofficial / polar-ble-sdk

Repository includes SDK and code examples. More info https://polar.com/en/developers
Other
449 stars 147 forks source link

Verity Delta Sample Timestamps #361

Closed fagerburg closed 10 months ago

fagerburg commented 1 year ago

Platform your question concerns:

Device:

Description: Hello, there was a technical spec document in the repo that was recently removed Polar Measurement Spec for the 5.0.0 release. I have code written that parses the ACC and PPG data streams from the Verity and I recently updated my firmware and realized that v4.0.0 introduced timestamps with each delta sample. Will that document be updated to show the inclusion of the timestamps? If not, is the timestamp that has been added to the delta samples a delta from the original timestamp just like the ACC and PPG delta samples are from the reference? The 4.0.0 release notes seemed to show that it was a long but I wasn't sure if that was just the reference sample or the delta samples.

jimmyzumthurm commented 12 months ago

Hi @fagerbur

I can't really answer related to the documentation, but the time-stamping of individual samples follows the same logic for each measurement type that has timestamps:

x = current_delta_frame.timestamp - prev_delta_frame_timestamp;
y = x / current_delta_frame.nb_samples
for i, sample in enumerate(current_delta_frame) : 
    sample.timestamp = prev_delta_frame_timestamp + i * y
prev_delta_frame_timestamp = current_delta_frame.timestamp

For the first received delta frame, logic is different as x delta between frames cannot be calculated yet. It will use this formula instead, using the frame timestamp and the sample rate :

y = 1 / current_delta_frame.sample_rate * 1'000'000'000
for i, sample in enumerate(current_delta_frame) : 
    sample.timestamp = current_delta_frame.timestamp - (current_delta_frame.nb_samples - i)*y

I hope this clarifies your questions.