Update
This commit is contained in:
@@ -89,6 +89,8 @@ func onPeriphConnected(p gatt.Peripheral, err error) {
|
||||
// fmt.Printf("Failed to read characteristic, err: %s\n", err)
|
||||
// return
|
||||
// }
|
||||
// parseData(b)
|
||||
// return
|
||||
// fmt.Printf(" value %x | %q\n", b, b)
|
||||
|
||||
histChar := getCharByUUID(WEIGHT_MEASUREMENT_HISTORY_CHARACTERISTIC, chars)
|
||||
@@ -101,13 +103,11 @@ func onPeriphConnected(p gatt.Peripheral, err error) {
|
||||
log.Printf("Got back from %s: %#x\n", c.UUID(), b)
|
||||
//weight :=
|
||||
if len(b) == 20 {
|
||||
first := b[0:10]
|
||||
weight := parseData(first)
|
||||
weight := parseData(b[0:10])
|
||||
if weight != nil {
|
||||
weights = append(weights, weight)
|
||||
}
|
||||
second := b[10:20]
|
||||
weight = parseData(second)
|
||||
weight = parseData(b[10:20])
|
||||
if weight != nil {
|
||||
weights = append(weights, weight)
|
||||
}
|
||||
|
||||
@@ -14,14 +14,14 @@ func parseData(weightBytes []byte) *Weight {
|
||||
isLBSUnit := isBitSet(ctrlByte, 0)
|
||||
isCattyUnit := isBitSet(ctrlByte, 4)
|
||||
|
||||
// fmt.Printf("IsWeightRemoved: %v\n", isWeightRemoved)
|
||||
// fmt.Printf("IsWeightRemoved: %v\n", isBitSet(ctrlByte, 7))
|
||||
// fmt.Printf("6 LSB Unknown: %v\n", isBitSet(ctrlByte, 6))
|
||||
// fmt.Printf("IsStabilized: %v\n", isStabilized)
|
||||
// fmt.Printf("IsCattyOrKg: %v\n", isCattyUnit)
|
||||
// fmt.Printf("3 LSB Unknown: %v\n", isBitSet(ctrlByte, 3))
|
||||
// fmt.Printf("2 LSB Unknown: %v\n", isBitSet(ctrlByte, 2))
|
||||
// fmt.Printf("1 LSB Unknown: %v\n", isBitSet(ctrlByte, 1))
|
||||
// fmt.Printf("IsLBS: %v\n", isLBSUnit)
|
||||
// fmt.Printf("IsStabilized: %v\n", isBitSet(ctrlByte, 5))
|
||||
// fmt.Printf("IsCattyOrKg: %v\n", isBitSet(ctrlByte, 4))
|
||||
// fmt.Printf("BMI and Height present: %v\n", isBitSet(ctrlByte, 3))
|
||||
// fmt.Printf("User ID present: %v\n", isBitSet(ctrlByte, 2))
|
||||
// fmt.Printf("Time stamp present: %v\n", isBitSet(ctrlByte, 1))
|
||||
// fmt.Printf("IsLBS: %v\n", isBitSet(ctrlByte, 0))
|
||||
|
||||
// // Only if the value is stabilized and the weight is *not* removed, the date is valid
|
||||
if isStabilized && !isWeightRemoved {
|
||||
|
||||
Reference in New Issue
Block a user