bluetooth

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package bluetooth contains helpers to interact with the system's bluetooth adapters.

Package bluetooth contains helpers to interact with the system's bluetooth adapters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisconnectAllDevices

func DisconnectAllDevices(ctx context.Context) error

DisconnectAllDevices disconnects all remote bluetooth devices.

func Enable

func Enable(ctx context.Context) error

Enable powers on the bluetooth adapter

func IsDisabled

func IsDisabled(ctx context.Context) (bool, error)

IsDisabled checks if bluetooth adapter present and powered off

func IsEnabled

func IsEnabled(ctx context.Context) (bool, error)

IsEnabled checks if bluetooth adapter present and powered on.

func PollForAdapterState

func PollForAdapterState(ctx context.Context, exp bool) error

PollForAdapterState polls bluetooth adapter state until expected state is received or timeout occurs.

func PollForBTDisabled

func PollForBTDisabled(ctx context.Context) error

PollForBTDisabled polls bluetooth adapter state till Adapter is powered off

func PollForBTEnabled

func PollForBTEnabled(ctx context.Context) error

PollForBTEnabled polls bluetooth adapter state till Adapter is powered on

func SetDebugLogLevels

func SetDebugLogLevels(ctx context.Context, levels LogVerbosity) error

SetDebugLogLevels sets the logging level for Bluetooth debug logs.

func StartBTSnoopLogging

func StartBTSnoopLogging(ctx context.Context, path string) *testexec.Cmd

StartBTSnoopLogging starts capturing Bluetooth HCI "btsnoop" logs in a file at the specified path. Call Start on the returned command to start log collection, and call Kill when finished to end btmon.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter contains helper functions for getting and setting bluetooth adapter state.

func Adapters

func Adapters(ctx context.Context) ([]*Adapter, error)

Adapters creates an Adapter for all bluetooth adapters in the system.

func NewAdapter

func NewAdapter(ctx context.Context, path dbus.ObjectPath) (*Adapter, error)

NewAdapter creates a new bluetooth Adapter from the passed D-Bus object path.

func (*Adapter) Address

func (a *Adapter) Address(ctx context.Context) (string, error)

Address returns the MAC address of the adapter.

func (*Adapter) Name

func (a *Adapter) Name(ctx context.Context) (string, error)

Name returns the name of the adapter.

func (*Adapter) Path

func (a *Adapter) Path() dbus.ObjectPath

Path gets the D-Bus path this adapter was created from.

func (*Adapter) Powered

func (a *Adapter) Powered(ctx context.Context) (bool, error)

Powered returns whether a bluetooth adapter is powered on.

func (*Adapter) SetPowered

func (a *Adapter) SetPowered(ctx context.Context, powered bool) error

SetPowered turns a bluetooth adapter on or off

func (*Adapter) StartDiscovery

func (a *Adapter) StartDiscovery(ctx context.Context) error

StartDiscovery starts a discovery on the adapter.

func (*Adapter) StopDiscovery

func (a *Adapter) StopDiscovery(ctx context.Context) error

StopDiscovery stops the discovery on the adapter.

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device is the bluz dbus remote device object abstraction.

func DeviceByAddress

func DeviceByAddress(ctx context.Context, address string) (*Device, error)

DeviceByAddress creates a new bluetooth device object by the address of the device.

func DeviceByAlias

func DeviceByAlias(ctx context.Context, alias string) (*Device, error)

DeviceByAlias creates a new bluetooth device object by the alias name of the device.

func Devices

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

Devices creates a Device for each of the remote bluetooth devices in the system.

func (*Device) Address

func (d *Device) Address(ctx context.Context) (string, error)

Address returns the Address of the bluetooth remote device.

func (*Device) Alias

func (d *Device) Alias(ctx context.Context) (string, error)

Alias returns the alias of the bluetooth remote device.

func (*Device) Connect

func (d *Device) Connect(ctx context.Context) error

Connect connects to the bluetooth remote device.

func (*Device) Connected

func (d *Device) Connected(ctx context.Context) (bool, error)

Connected returns true if the bluetooth remote device is connected.

func (*Device) Disconnect

func (d *Device) Disconnect(ctx context.Context) error

Disconnect disconnects the bluetooth remote device.

func (*Device) Pair

func (d *Device) Pair(ctx context.Context) error

Pair pairs the bluetooth remote device.

func (*Device) Paired

func (d *Device) Paired(ctx context.Context) (bool, error)

Paired returns true if the bluetooth remote device is paired.

func (*Device) Path

func (d *Device) Path() dbus.ObjectPath

Path gets the D-Bus path this device was created from.

type LogVerbosity

type LogVerbosity struct {
	Bluez  bool
	Kernel bool
}

LogVerbosity indicates whether or not to enable verbose logging for the different bluetooth modules.

Directories

Path Synopsis
Package mojo provides functions to access the bluetooth mojo interface defined in cros_bluetooth_config.mojom
Package mojo provides functions to access the bluetooth mojo interface defined in cros_bluetooth_config.mojom

Jump to

Keyboard shortcuts

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