Skip to content

Commit

Permalink
Merge pull request #91 from steam3d/master
Browse files Browse the repository at this point in the history
improved AT+XEVENT battery parsing
  • Loading branch information
TheWeirdDev committed Jan 16, 2023
2 parents e74acb7 + d33d37a commit ef80afe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bluetooth_battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ def _perform_query(self) -> int:
break
elif b"XEVENT=BATTERY" in line:
params = line.strip().split(b"=")[1].split(b",")
result = int(params[1]) / int(params[2]) * 100
if len(params) >= 3:
# AT+XEVENT=BATTERY,6,11,461,0
result = int(params[1]) / int(params[2]) * 100
else:
# AT+XEVENT=BATTERY,9
result = (int(params[1]) + 1) * 10
break
else:
sock.send(b"OK")
Expand Down

0 comments on commit ef80afe

Please sign in to comment.