Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch to address bad values from Zephyr (for reference only) #8

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# JetBrains IDE
.idea/
.vscode/

# virtualenv
venv/
22 changes: 21 additions & 1 deletion core/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,28 @@ def __init__(self, msgid, payload, fin=MC.ETX):
class SummaryDataMessage(StreamingMessage):
"""Common base class for the two versions of the summary data packet."""

device_worn_confidence = math.nan
button_pressed = math.nan
not_fitted_to_garment = math.nan
heart_rate_unreliable = math.nan
respiration_rate_unreliable = math.nan
skin_temperature_unreliable = math.nan
posture_unreliable = math.nan
activity_unreliable = math.nan
hrv_unreliable = math.nan
estimated_core_temp_unreliable = math.nan
usb_power_connected = math.nan
resting_state_detected = math.nan
external_sensors_connected = math.nan

def _decode_status_info(self, status_info):
"""Parse status info word and write into state."""

isnan = status_info != status_info # NaN is the only value that is not equal to itself

if isnan:
return

self.device_worn_confidence = 1 - (status_info & 3)/3
self.button_pressed = (status_info & 2**2) > 0
self.not_fitted_to_garment = (status_info & 2**3) > 0
Expand Down Expand Up @@ -452,7 +472,7 @@ def __init__(self, msgid, payload, fin=MC.ETX):
self.aux_adc_chan1 = parse_num(payload[63:65], False, inval=0xFFFF)
self.aux_adc_chan2 = parse_num(payload[65:67], False, inval=0xFFFF)
self.aux_adc_chan3 = parse_num(payload[67:69], False, inval=0xFFFF)
ext_status_info = parse_num(payload[69:71], False, inval=0xFFFF)
ext_status_info = parse_num(payload[69:71])
flags_valid = 0 if (ext_status_info & 2**15) > 0 else math.nan
self.resp_rate_low = (ext_status_info & 2 ** 0) > 0 + flags_valid
self.resp_rate_high = (ext_status_info & 2 ** 1) > 0 + flags_valid
Expand Down