bluetooth_tool

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2024 License: Unlicense Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BT_CONNECT_TIMEOUT = 5
	BTNAME_SHX8800     = "walkie-talkie"

	HANDSHAKE_TIMEOUT = 5
	BT_SCAN_TIMEOUT   = 10

	BATTERY_CHARACTERISTIC_UUID           = "2a19"
	MANUFACTURER_CHARACTERISTIC_UUID      = "2a29"
	FIRMWARE_REVISION_CHARACTERISTIC_UUID = "2a26"
	MODEL_NUMBER_CHARACTERISTIC_UUID      = "2a24"
	CHECK_CHARACTERISTIC_UUID             = "ff31"
	RW_CHARACTERISTIC_UUID                = "ffe1"
)

Variables

View Source
var (
	CurrentDevice *BTCharacteristic

	FINAL_DATA_STARTER = []byte{87, 28, 00}

	NO_SSID_FILTER = false
)
View Source
var HANDSHAKE_CODE = []byte{80, 82, 79, 71, 82, 79, 77, 83, 72, 88, 85}
View Source
var HANDSHAKE_RESP = 6

Functions

func BTWriter

func BTWriter(ctx context.Context, recv <-chan []byte, repErr chan<- error, btIn chan<- struct{})

串口数据写蓝牙

func CheckRecvHandler

func CheckRecvHandler(c []byte)

func ConnectByMac

func ConnectByMac(mac bluetooth.Address) (*bluetooth.Device, error)

func DisconnectDevice

func DisconnectDevice(shx *bluetooth.Device)

func DisconnectHandler

func DisconnectHandler(_ bluetooth.Address, connected bool)

func EmptyFilter added in v0.2.1

func EmptyFilter(dev bluetooth.ScanResult) bool

func GetAvailableBtDevList

func GetAvailableBtDevList(filter DeviceFilter) ([]bluetooth.ScanResult, error)

func GetConnectStatus added in v0.2.0

func GetConnectStatus() bool

func RWRecvHandler

func RWRecvHandler(recvChan chan<- []byte, btOut chan<- struct{}) func(c []byte)

func SHX8800Filter

func SHX8800Filter(dev bluetooth.ScanResult) bool

func SetConnectStatus added in v0.2.0

func SetConnectStatus(connectStat bool)

func SetHandler

func SetHandler(connHandler func(address bluetooth.Address, connected bool))

Types

type BTCharacteristic

type BTCharacteristic struct {
	CheckCharacteristic *bluetooth.DeviceCharacteristic
	RWCharacteristic    *bluetooth.DeviceCharacteristic

	CheckRecvHandler RecvHandler
	RWRecvHandler    RecvHandler
}

func (*BTCharacteristic) SendDataToCheck

func (btc *BTCharacteristic) SendDataToCheck(data []byte) error

func (*BTCharacteristic) SendDataToRW

func (btc *BTCharacteristic) SendDataToRW(data []byte) error

func (*BTCharacteristic) SetCheckReceiveHandler

func (btc *BTCharacteristic) SetCheckReceiveHandler(handler RecvHandler, recvChan chan<- []byte)

func (*BTCharacteristic) SetReadWriteReceiveHandler

func (btc *BTCharacteristic) SetReadWriteReceiveHandler(handler RecvHandler, recvChan chan<- []byte, btIn chan<- struct{})

type DeviceFilter

type DeviceFilter func(dev bluetooth.ScanResult) bool

type RecvHandler

type RecvHandler func(recvChan chan<- []byte, btOut chan<- struct{}) func(c []byte)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL