This commit is contained in:
2017-02-06 20:00:33 +03:00
parent a829a3dd5c
commit 40c834f7e8
5 changed files with 47 additions and 31 deletions
+28
View File
@@ -0,0 +1,28 @@
package workers
import (
"fmt"
"github.com/currantlabs/gatt"
)
type Log struct {
Worker
}
func (s Log) OnDiscovery(p gatt.Peripheral, a *gatt.Advertisement, rssi int) bool {
fmt.Printf("\nPeripheral ID:%s, NAME:(%s)\n", p.ID(), p.Name())
fmt.Println(" Local Name =", a.LocalName)
fmt.Println(" Manufacturer Data =", a.ManufacturerData)
fmt.Println(" Service Data =", a.ServiceData)
fmt.Println(" RSSI =", rssi)
return false
}
func (s Log) OnConnect(p gatt.Peripheral, err error) error {
ID := p.ID()
fmt.Println("Connected to " + ID)
return nil
}
-8
View File
@@ -40,14 +40,6 @@ func (s Scale) OnConnect(p gatt.Peripheral, err error) error {
return nil
}
fmt.Println("Connected")
defer p.Device().CancelConnection(p)
if err := p.SetMTU(500); err != nil {
fmt.Printf("Failed to set MTU, err: %s\n", err)
}
fmt.Printf("Set mtu done.\n")
// Discovery services
services, err := p.DiscoverServices(nil)
fmt.Printf("Services: %v+", services)