Skip to content

Commit

Permalink
Process battery levels as big-endian values instead of little-endian.
Browse files Browse the repository at this point in the history
Fixes #2.
  • Loading branch information
sworisbreathing committed May 11, 2019
1 parent dde41cf commit d8ab7f3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ibbq/ibbq.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d8ab7f3

Please sign in to comment.