当前位置: 首页>>代码示例>>Golang>>正文


Golang Peripheral.ID方法代码示例

本文整理汇总了Golang中github.com/currantlabs/gatt.Peripheral.ID方法的典型用法代码示例。如果您正苦于以下问题:Golang Peripheral.ID方法的具体用法?Golang Peripheral.ID怎么用?Golang Peripheral.ID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/currantlabs/gatt.Peripheral的用法示例。


在下文中一共展示了Peripheral.ID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ConnectHandler

func (b *BLEClientAdaptor) ConnectHandler(p gatt.Peripheral, err error) {
	fmt.Printf("\nConnected Peripheral ID:%s, NAME:(%s)\n", p.ID(), p.Name())

	b.peripheral = p

	if err := p.SetMTU(250); err != nil {
		fmt.Printf("Failed to set MTU, err: %s\n", err)
	}

	ss, err := p.DiscoverServices(nil)
	if err != nil {
		fmt.Printf("Failed to discover services, err: %s\n", err)
		return
	}

	for _, s := range ss {
		b.services[s.UUID().String()] = NewBLEService(s.UUID().String(), s)

		cs, err := p.DiscoverCharacteristics(nil, s)
		if err != nil {
			fmt.Printf("Failed to discover characteristics, err: %s\n", err)
			continue
		}

		for _, c := range cs {
			b.services[s.UUID().String()].characteristics[c.UUID().String()] = c
		}
	}

	b.connected = true
	close(b.ready)
}
开发者ID:nathany,项目名称:gobot,代码行数:32,代码来源:ble_client_adaptor.go

示例2: onPeriphDiscovered

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)
}
开发者ID:currantlabs,项目名称:gatt,代码行数:7,代码来源:discoverer.go

示例3: DiscoveryHandler

func (b *BLEClientAdaptor) DiscoveryHandler(p gatt.Peripheral, a *gatt.Advertisement, rssi int) {
	// try looking by local name
	if a.LocalName == b.UUID() {
		b.uuid = p.ID()
	} else {
		// try looking by ID
		id := strings.ToUpper(b.UUID())
		if strings.ToUpper(p.ID()) != id {
			return
		}
	}

	// Stop scanning once we've got the peripheral we're looking for.
	p.Device().StopScanning()

	// and connect to it
	p.Device().Connect(p)
}
开发者ID:nathany,项目名称:gobot,代码行数:18,代码来源:ble_client_adaptor.go

示例4: onPeriphDiscovered

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)
}
开发者ID:currantlabs,项目名称:gatt,代码行数:18,代码来源:explorer.go


注:本文中的github.com/currantlabs/gatt.Peripheral.ID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。