From d8ab7f341da9778ca7948997fcdc7e69c6c428d8 Mon Sep 17 00:00:00 2001 From: Steven Swor Date: Sat, 11 May 2019 14:25:08 +1000 Subject: [PATCH] Process battery levels as big-endian values instead of little-endian. Fixes #2. --- ibbq/ibbq.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ibbq/ibbq.go b/ibbq/ibbq.go index cb61ac7..2634219 100644 --- a/ibbq/ibbq.go +++ b/ibbq/ibbq.go @@ -254,10 +254,10 @@ func (ibbq *Ibbq) settingResultReceived() ble.NotificationHandler { switch data[0] { case 0x24: // battery - currentVoltage := int(binary.LittleEndian.Uint16(data[1:3])) - maxVoltage := int(binary.LittleEndian.Uint16(data[3:5])) + currentVoltage := int(binary.BigEndian.Uint16(data[1:3])) + maxVoltage := int(binary.BigEndian.Uint16(data[3:5])) if maxVoltage == 0 { - maxVoltage = 6550 + maxVoltage = 65535 } batteryPct := 100 * currentVoltage / maxVoltage go ibbq.batteryLevelReceivedHandler(batteryPct)