Sfoglia il codice sorgente

feat: add parser for Minew Acc data and info data

master
Blaz Smehov 4 settimane fa
parent
commit
04c6114b55
1 ha cambiato i file con 34 aggiunte e 4 eliminazioni
  1. +34
    -4
      internal/pkg/common/utils/beacons.go

+ 34
- 4
internal/pkg/common/utils/beacons.go Vedi File

@@ -57,8 +57,12 @@ func LoopADStructures(b []byte, i [][2]int, id string) model.BeaconEvent {
be.ID = id
be.Name = id
break
} else if checkMinewB7(ad) {
fmt.Println("Minew B7 vendor format")
} else if checkMinewDeviceInfo(ad) {
be = parseMinewDeviceInfo(ad)
be.ID = id
be.Name = id
break
} else if checkMinewAccData(ad) {
break
}
}
@@ -116,14 +120,40 @@ func parseEddystoneState(ad []byte) model.BeaconEvent {
}
}

// I dont think this is always true, but for testing is ok
func checkMinewB7(ad []byte) bool {
// Minew Battery level
func checkMinewDeviceInfo(ad []byte) bool {
if len(ad) >= 4 &&
len(ad) != 19 &&
ad[1] == 0x16 &&
ad[2] == 0xE1 &&
ad[3] == 0xFF {
fmt.Println("Minew device info")
return true
}

return false
}

func parseMinewDeviceInfo(ad []byte) model.BeaconEvent {
fmt.Printf("ad: %x\n", ad)
return model.BeaconEvent{
Battery: uint32(ad[6]),
Type: "Minew B7",
}
}

func checkMinewAccData(ad []byte) bool {
if len(ad) == 19 &&
ad[1] == 0x16 &&
ad[2] == 0xE1 &&
ad[3] == 0xFF {
fmt.Println("Minew Acc data")
return true
}

return false
}

// func parseMinewAccData(ad []byte) model.BeaconEvent {

// }

Caricamento…
Annulla
Salva