bt

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package bt provides cross-platform Bluetooth Classic discovery, pairing and SPP connection for PITEC chambers. Each platform has its own backend:

  • macOS: shells out to blueutil (brew install blueutil)
  • Linux: BlueZ over D-Bus for scan/pair, raw RFCOMM socket for data
  • Windows: Win32 Bluetooth API for scan/pair, registry lookup for the virtual COM port created after pairing

The per-platform files implement:

Scan(ctx) ([]Device, error)            — discover nearby + known devices
Pair(ctx, dev, pin) error              — pair with a fixed PIN
Connect(dev) (device.Transport, error) — open the SPP data channel

Index

Constants

View Source
const DefaultPIN = "1010"

DefaultPIN is the pairing key used by PITEC Bluetooth modules.

Variables

This section is empty.

Functions

func Connect

func Connect(dev Device) (device.Transport, error)

Connect opens a raw RFCOMM socket to the device's SPP channel.

func IsPitec

func IsPitec(name string) bool

IsPitec reports whether the device name looks like a PITEC chamber.

func NormalizeAddr

func NormalizeAddr(a string) string

NormalizeAddr converts a MAC address to canonical "AA:BB:CC:DD:EE:FF" form.

func Pair

func Pair(ctx context.Context, dev Device, pin string) error

Pair registers a temporary agent that answers with pin and pairs the device. The device must have been seen in a recent scan so BlueZ knows it.

Types

type Device

type Device struct {
	Name    string
	Address string // MAC "00:11:22:33:44:55", uppercase
	Paired  bool
}

Device is a Bluetooth device found during a scan.

func FilterPitecs

func FilterPitecs(devs []Device) []Device

FilterPitecs returns only the devices whose name matches IsPitec.

func Scan

func Scan(ctx context.Context) ([]Device, error)

Scan runs a BlueZ discovery and returns all known + nearby devices.

Jump to

Keyboard shortcuts

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