no matching versions for query "latest"
AliceShynie opened this issue · 1 comments
pi@raspberrypi:~/Desktop/WeatherMachine2-hrm-master $ go run hrm1.go
go: finding module for package github.com/muka/go-bluetooth/api
hrm1.go:16:2: no matching versions for query "latest"
==========================Inside hrm.go=========================
package main
import (
"encoding/binary"
"flag"
"fmt"
"log"
"os"
"strings"
"github.com/cfreeman/gatt"
"github.com/cfreeman/gatt/examples/option"
"github.com/muka/go-bluetooth/api"
)
func pollHeartRateMonitor(hr chan uint16, halt chan bool) {
// Connect bluetooth.
hciconfig := linux.HCIConfig{}
_, err := hciconfig.Up()
if err != nil {
log.Printf("Unable to connect %s", err)
return
}
// Bluetooth cleanup function.
defer func() {
api.Exit()
_, err = hciconfig.Down()
if err != nil {
log.Printf("Unable to disconnect %s", err)
return
}
log.Printf("HRM stopped.")
}()
// Give the hardware a second to warmup.
time.Sleep(time.Second)
// See if the device is known first.
d, err := api.GetDeviceByAddress("E5:20:2B:3A:13:F5")
if err != nil {
log.Printf("Unable to get device %s", err)
return
}
// Unable to find the device, try discovering it for 10 seconds.
if d == nil {
log.Printf("Starting discovery")
err = api.StartDiscovery()
if err != nil {
log.Printf("Unable to start discovery %s", err)
}
api.On("discovery", emitter.NewCallback(func(ev emitter.Event) {
discoveryEvent := ev.GetData().(api.DiscoveredDeviceEvent)
dev := discoveryEvent.Device
if dev == nil {
log.Printf("Device removed!")
return
}
log.Printf("Found %v", dev)
}))
time.Sleep(10 * time.Second)
log.Printf("Stopping discovery")
api.StopDiscovery()
d, err = api.GetDeviceByAddress("0C:F3:EE:AA:B1:F7")
if err != nil {
log.Printf("Unable to get device %s", err)
return
}
}
log.Printf("Connecting to device %v", d.Properties)
err = d.Connect()
if err != nil {
log.Printf("Unable to connect to device %s", err)
return
}
// Discover the bluetooth device characteristics.
char := getCharacteristic(d, "2A37")
if char == nil {
log.Printf("waiting while characteristics are discovered")
time.Sleep(15 * time.Second)
char = getCharacteristic(d, "2A37")
}
hrChannel, err := char.Register()
if err != nil {
log.Printf("Unable to register to characteristic %s", err)
return
}
err = char.StartNotify()
if err != nil {
log.Printf("StartNotify error %v", err)
return
}
log.Printf("Characteristic registered %v", char)
for e := range hrChannel {
if e == nil {
return
}
select {
case <-halt:
log.Printf("Stopping HRM")
char.StopNotify()
return
default:
// Keep polling.
}
switch v := e.Body[1].(type) {
case map[string]dbus.Variant:
if val, ok := v["Value"]; ok {
heartRate := binary.LittleEndian.Uint16(append([]byte(val.Value().([]byte)[1:2]), []byte{0}...))
hr <- heartRate
}
default:
log.Printf("Unable to determine type %v", v)
}
}
}
Please reformat this issue, as it is I cannot help. Best