Go Bluetooth

回复
头像
shaoziyang
帖子: 3917
注册时间: 2019年 10月 21日 13:48

Go Bluetooth

#1

帖子 shaoziyang »

图片

Go Bluetooth是一个跨平台的软件包,用于Go编程语言控制的蓝牙BLE硬件。它可以运行在Linux,macOS和Windows,以及Nordic单片机上。
LinuxmacOSWindowsNordic Semi
API usedBlueZCoreBluetoothWinRTSoftDevice
Scanning:heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:
Connect to peripheral:heavy_check_mark::heavy_check_mark:x:heavy_check_mark:
Write peripheral characteristics:heavy_check_mark::heavy_check_mark:x:heavy_check_mark:
Receive notifications:heavy_check_mark::heavy_check_mark:x:heavy_check_mark:
Advertisement:heavy_check_mark:xx:heavy_check_mark:
Local services:heavy_check_mark:xx:heavy_check_mark:
Local characteristics:heavy_check_mark:xx:heavy_check_mark:
Send notifications:heavy_check_mark:xx:heavy_check_mark:

代码: 全选

package main

import (
"tinygo.org/x/bluetooth"
)

var adapter = bluetooth.DefaultAdapter

func main() {
// Enable BLE interface.
must("enable BLE stack", adapter.Enable())

// Start scanning.
println("scanning...")
err := adapter.Scan(func(adapter *bluetooth.Adapter, device bluetooth.ScanResult) {
println("found device:", device.Address.String(), device.RSSI, device.LocalName())
})
must("start scan", err)
}

func must(action string, err error) {
if err != nil {
panic("failed to " + action + ": " + err.Error())
}
}

https://github.com/tinygo-org/bluetooth
 
 
 
 
 
 
 
 

回复

  • 随机主题
    回复总数
    阅读次数
    最新文章