Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Commit

Permalink
Fix for battery reporting -1 in Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
RaithSphere committed Nov 13, 2020
1 parent 4c3c61b commit f129a7d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions HRM.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def main_linux(addr=None, gatttool="gatttool", check_battery=False, hr_handle=No
"""
hr_ctl_handle = None
retry = True
global ct, bt
while retry:

while 1:
Expand Down Expand Up @@ -257,7 +258,7 @@ def main_linux(addr=None, gatttool="gatttool", check_battery=False, hr_handle=No
gt.expect("value: ([0-9a-f]+)")
battery_level = gt.match.group(1)
log.info("Battery level: " + str(int(battery_level, 16)))
battery = str(int(battery_level, 16))
bt = str(int(battery_level, 16))
except pexpect.TIMEOUT:
log.error("Couldn't read battery level.")

Expand Down Expand Up @@ -330,8 +331,6 @@ def main_linux(addr=None, gatttool="gatttool", check_battery=False, hr_handle=No
res = interpret(list(data))

log.debug(res)

global ct, bt
writeout(None, None, bt, ct)

# We quit close the BLE connection properly
Expand Down

0 comments on commit f129a7d

Please sign in to comment.