mirror of
https://github.com/cmur2/miflorad.git
synced 2026-04-02 16:18:34 +02:00
reorga
This commit is contained in:
@@ -3,6 +3,9 @@ package common
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/currantlabs/gatt"
|
||||
)
|
||||
@@ -107,3 +110,16 @@ func MifloraRequstSensorData(p gatt.Peripheral) (SensorDataResponse, error) {
|
||||
Conductivity: binary.LittleEndian.Uint16(bytes[8:10]),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (res VersionBatteryResponse) NumericFirmwareVersion() int {
|
||||
// turns "2.3.4" into 20304
|
||||
version := 0
|
||||
parts := strings.Split(res.FirmwareVersion, ".")
|
||||
for i, part := range parts {
|
||||
partNumber, err := strconv.Atoi(part)
|
||||
if err != nil {
|
||||
version += int(math.Pow10((len(parts)-(i+1))*2)) * partNumber
|
||||
}
|
||||
}
|
||||
return version
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user