func onPeriphDiscovered(p gatt.Peripheral, a *gatt.Advertisement, rssi int) { fmt.Printf("\nPeripheral ID:%s, NAME:(%s)\n", p.ID(), p.Name()) fmt.Println(" Local Name =", a.LocalName) fmt.Println(" TX Power Level =", a.TxPowerLevel) fmt.Println(" Manufacturer Data =", a.ManufacturerData) fmt.Println(" Service Data =", a.ServiceData) }
func (g *Gonashi) onPeriphDisconnected(p gatt.Peripheral, err error) { connected := g.connected.GetKonashiMap() idStr := strings.ToUpper(p.ID()) if k, ok := connected[idStr]; ok { g.connected.DelKonashi(idStr) k.Disconnected <- struct{}{} } }
func (g *Gonashi) onPeriphConnected(p gatt.Peripheral, err error) { discovered := g.discovered.GetKonashiMap() idStr := strings.ToUpper(p.ID()) if k, ok := discovered[idStr]; ok { k.SetPeripheral(p) g.connected.AddKonashi(k) k.Connected <- struct{}{} } }
func (dp *discovered) AddDiscovered(p gatt.Peripheral, a *gatt.Advertisement, rssi int) { dp.mu.Lock() defer dp.mu.Unlock() idStr := strings.ToUpper(p.ID()) if k, ok := dp.konashis[idStr]; ok { k.Update(a, rssi) } else { dp.konashis[idStr] = NewKonashi(p, a, rssi) } dp.Update.In() <- dp.konashis }
func onPeriphDiscovered(p gatt.Peripheral, a *gatt.Advertisement, rssi int) { id := strings.ToUpper(flag.Args()[0]) if strings.ToUpper(p.ID()) != id { return } // Stop scanning once we've got the peripheral we're looking for. p.Device().StopScanning() fmt.Printf("\nPeripheral ID:%s, NAME:(%s)\n", p.ID(), p.Name()) fmt.Println(" Local Name =", a.LocalName) fmt.Println(" TX Power Level =", a.TxPowerLevel) fmt.Println(" Manufacturer Data =", a.ManufacturerData) fmt.Println(" Service Data =", a.ServiceData) fmt.Println("") p.Device().Connect(p) }