Documentation
¶
Overview ¶
Package ble provides the small Bluetooth Low Energy central/GATT client surface required by CTAP BLE transports.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type Characteristic ¶
type Characteristic interface {
UUID() UUID
Properties() CharacteristicProperties
Read(context.Context) ([]byte, error)
Write(context.Context, []byte) error
Subscribe(context.Context) (Subscription, error)
}
Characteristic is one discovered remote GATT characteristic. Write uses a GATT write request and waits for the peripheral's acknowledgement. Read is unavailable while the same characteristic has an active subscription.
type CharacteristicProperties ¶
type CharacteristicProperties uint16
CharacteristicProperties is the Bluetooth Characteristic Properties field.
const ( // Bit 0 is the Bluetooth Broadcast property, which this client API does not expose. CharacteristicPropertyRead CharacteristicProperties = 1 << (iota + 1) CharacteristicPropertyWriteWithoutResponse CharacteristicPropertyWrite CharacteristicPropertyNotify )
type DeviceInfo ¶
type DeviceInfo struct {
ID Identifier
Name string
RSSI int
}
DeviceInfo describes one peripheral advertisement.
type Error ¶
Error preserves a native Bluetooth error while exposing a portable cause through errors.Is.
type Identifier ¶
type Identifier string
Identifier is an opaque, platform-specific peripheral identifier.
type Peripheral ¶
type Peripheral interface {
DiscoverServices(context.Context, ...UUID) ([]Service, error)
io.Closer
}
Peripheral is an owned connection to a remote BLE peripheral.
func Open ¶
func Open(ctx context.Context, _ Identifier) (Peripheral, error)
Open reports that the current platform backend is not implemented.
type Service ¶
type Service interface {
UUID() UUID
Primary() bool
DiscoverCharacteristics(context.Context, ...UUID) ([]Characteristic, error)
}
Service is one discovered remote GATT service.
type Subscription ¶
Subscription publishes copied notification values in delivery order. If Listen closes unexpectedly, Close returns the terminal error.