This commit is contained in:
Monster
2018-02-10 19:41:37 +03:00
parent 012c35a556
commit 93fe1358e8
3 changed files with 11 additions and 11 deletions
BIN
View File
Binary file not shown.
+4 -4
View File
@@ -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)
}
+7 -7
View File
@@ -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 {