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