Skip to content

Bluetooth

Ayke edited this page Aug 15, 2019 · 3 revisions

API proposal for Bluetooth

// UUID type used across the Bluetooth stack.
// A [4]uint32 allows more optimizations than a [16]uint8.
type UUID [4]uint32

// MAC address
type Address [6]uint8

type Bluetooth struct {
    // some private fields
}

// Enable initializes the Bluetooth stack. Before this, none of the other calls will work (except for Disable).
func (b *Bluetooth) Enable(config BluetoothConfig) error {}

// Disable turns off the Bluetooth stack, freeing the resources it took up. It is a no-op if it is already disabled.
func (b *Bluetooth) Disable() error {}

// Enable advertisement with the given data. Stop advertisement by passing 0 in the interval.
func (b *Bluetooth) Advertise(interval int8, advertisement, scanResponse []byte) {}

type ScanResult struct {
    Address
    // ...
}

func (b *Bluetooth) Scan(callback func(*ScanResult)) error {}

func (b *Bluetooth) StopScan() error {}
Clone this wiki locally