本文整理汇总了Golang中github.com/devicehive/gatt.Peripheral.ID方法的典型用法代码示例。如果您正苦于以下问题:Golang Peripheral.ID方法的具体用法?Golang Peripheral.ID怎么用?Golang Peripheral.ID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/devicehive/gatt.Peripheral
的用法示例。
在下文中一共展示了Peripheral.ID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: OnPeripheralConnected
func (w *BleDbusWrapper) OnPeripheralConnected(p gatt.Peripheral, err error) {
id, _ := normalizeHex(p.ID())
w.devicesDiscovered[id].peripheral = p
w.devicesConnectedsync.Lock()
w.devicesConnected[id] = &sync.Mutex{}
w.devicesConnectedsync.Unlock()
w.connChan <- true
}
示例2: OnPeripheralDisconnected
func (w *BleDbusWrapper) OnPeripheralDisconnected(p gatt.Peripheral, err error) {
w.devicesConnectedsync.Lock()
defer w.devicesConnectedsync.Unlock()
id, _ := normalizeHex(p.ID())
if _, ok := w.devicesDiscovered[id]; ok {
delete(w.devicesDiscovered, id)
}
if _, ok := w.devicesConnected[id]; ok {
log.Printf("Disconnected: %s", id)
delete(w.devicesConnected, id)
w.emitPeripheralDisconnected(id)
}
}
示例3: OnPeripheralDiscovered
func (w *BleDbusWrapper) OnPeripheralDiscovered(p gatt.Peripheral, a *gatt.Advertisement, rssi int) {
w.devicesDiscoveredsync.Lock()
defer w.devicesDiscoveredsync.Unlock()
id, _ := normalizeHex(p.ID())
name := strings.Trim(p.Name(), "\x00")
dev, ok := w.devicesDiscovered[id]
if !ok {
w.devicesDiscovered[id] = &DiscoveredDeviceInfo{name: name, rssi: rssi, peripheral: p, ready: false, connectedOnce: false}
w.emitPeripheralDiscovered(id, name, int16(rssi))
} else {
if (dev.name == "") && (name != "") {
dev.name = name
}
w.emitPeripheralDiscovered(id, dev.name, int16(rssi))
}
}