darwin

package
v0.0.0-...-8c5522f Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: BSD-3-Clause Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	cbgo.PeripheralDelegateBase
	// contains filtered or unexported fields
}

A Client is a GATT client.

func NewClient

func NewClient(cm cbgo.CentralManager, c ble.Conn) (*Client, error)

NewClient ...

func (*Client) Addr

func (cln *Client) Addr() ble.Addr

Addr returns UUID of the remote peripheral.

func (*Client) CancelConnection

func (cln *Client) CancelConnection() error

CancelConnection disconnects the connection.

func (*Client) ClearSubscriptions

func (cln *Client) ClearSubscriptions() error

ClearSubscriptions clears all subscriptions to notifications and indications.

func (*Client) Conn

func (cln *Client) Conn() ble.Conn

Conn returns the client's current connection.

func (*Client) DidDiscoverCharacteristics

func (cln *Client) DidDiscoverCharacteristics(prph cbgo.Peripheral, svc cbgo.Service, err error)

func (*Client) DidDiscoverDescriptors

func (cln *Client) DidDiscoverDescriptors(prph cbgo.Peripheral, chr cbgo.Characteristic, err error)

func (*Client) DidDiscoverServices

func (cln *Client) DidDiscoverServices(prph cbgo.Peripheral, err error)

func (*Client) DidReadRSSI

func (cln *Client) DidReadRSSI(prph cbgo.Peripheral, rssi int, err error)

func (*Client) DidUpdateNotificationState

func (cln *Client) DidUpdateNotificationState(prph cbgo.Peripheral, chr cbgo.Characteristic, err error)

func (*Client) DidUpdateValueForCharacteristic

func (cln *Client) DidUpdateValueForCharacteristic(prph cbgo.Peripheral, chr cbgo.Characteristic, err error)

func (*Client) DidUpdateValueForDescriptor

func (cln *Client) DidUpdateValueForDescriptor(prph cbgo.Peripheral, dsc cbgo.Descriptor, err error)

func (*Client) DidWriteValueForCharacteristic

func (cln *Client) DidWriteValueForCharacteristic(prph cbgo.Peripheral, chr cbgo.Characteristic, err error)

func (*Client) DidWriteValueForDescriptor

func (cln *Client) DidWriteValueForDescriptor(prph cbgo.Peripheral, dsc cbgo.Descriptor, err error)

func (*Client) Disconnected

func (cln *Client) Disconnected() <-chan struct{}

Disconnected returns a receiving channel, which is closed when the client disconnects.

func (*Client) DiscoverCharacteristics

func (cln *Client) DiscoverCharacteristics(cs []ble.UUID, s *ble.Service) ([]*ble.Characteristic, error)

DiscoverCharacteristics finds all the characteristics within a service. [Vol 3, Part G, 4.6.1] If filter is specified, only filtered characteristics are returned.

func (*Client) DiscoverDescriptors

func (cln *Client) DiscoverDescriptors(ds []ble.UUID, c *ble.Characteristic) ([]*ble.Descriptor, error)

DiscoverDescriptors finds all the descriptors within a characteristic. [Vol 3, Part G, 4.7.1] If filter is specified, only filtered descriptors are returned.

func (*Client) DiscoverIncludedServices

func (cln *Client) DiscoverIncludedServices(ss []ble.UUID, s *ble.Service) ([]*ble.Service, error)

DiscoverIncludedServices finds the included services of a service. [Vol 3, Part G, 4.5.1] If filter is specified, only filtered services are returned.

func (*Client) DiscoverProfile

func (cln *Client) DiscoverProfile(force bool) (*ble.Profile, error)

DiscoverProfile discovers the whole hierarchy of a server.

func (*Client) DiscoverServices

func (cln *Client) DiscoverServices(ss []ble.UUID) ([]*ble.Service, error)

DiscoverServices finds all the primary services on a server. [Vol 3, Part G, 4.4.1] If filter is specified, only filtered services are returned.

func (*Client) ExchangeMTU

func (cln *Client) ExchangeMTU(mtu int) (int, error)

ExchangeMTU set the ATT_MTU to the maximum possible value that can be supported by both devices [Vol 3, Part G, 4.3.1]

func (*Client) Name

func (cln *Client) Name() string

Name returns the name of the remote peripheral. This can be the advertised name, if exists, or the GAP device name, which takes priority.

func (*Client) Profile

func (cln *Client) Profile() *ble.Profile

Profile returns the discovered profile.

func (*Client) ReadCharacteristic

func (cln *Client) ReadCharacteristic(c *ble.Characteristic) ([]byte, error)

ReadCharacteristic reads a characteristic value from a server. [Vol 3, Part G, 4.8.1]

func (*Client) ReadDescriptor

func (cln *Client) ReadDescriptor(d *ble.Descriptor) ([]byte, error)

ReadDescriptor reads a characteristic descriptor from a server. [Vol 3, Part G, 4.12.1]

func (*Client) ReadLongCharacteristic

func (cln *Client) ReadLongCharacteristic(c *ble.Characteristic) ([]byte, error)

ReadLongCharacteristic reads a characteristic value which is longer than the MTU. [Vol 3, Part G, 4.8.3]

func (*Client) ReadRSSI

func (cln *Client) ReadRSSI() int

ReadRSSI retrieves the current RSSI value of remote peripheral. [Vol 2, Part E, 7.5.4]

func (*Client) Subscribe

func (cln *Client) Subscribe(c *ble.Characteristic, ind bool, fn ble.NotificationHandler) error

Subscribe subscribes to indication (if ind is set true), or notification of a characteristic value. [Vol 3, Part G, 4.10 & 4.11]

func (*Client) Unsubscribe

func (cln *Client) Unsubscribe(c *ble.Characteristic, ind bool) error

Unsubscribe unsubscribes to indication (if ind is set true), or notification of a specified characteristic value. [Vol 3, Part G, 4.10 & 4.11]

func (*Client) WriteCharacteristic

func (cln *Client) WriteCharacteristic(c *ble.Characteristic, b []byte, noRsp bool) error

WriteCharacteristic writes a characteristic value to a server. [Vol 3, Part G, 4.9.3]

func (*Client) WriteDescriptor

func (cln *Client) WriteDescriptor(d *ble.Descriptor, b []byte) error

WriteDescriptor writes a characteristic descriptor to a server. [Vol 3, Part G, 4.12.3]

type Device

type Device struct {
	// Embed these two bases so we don't have to override all the esoteric
	// functions defined by CoreBluetooth delegate interfaces.
	cbgo.CentralManagerDelegateBase
	cbgo.PeripheralManagerDelegateBase
	// contains filtered or unexported fields
}

Device is either a Peripheral or Central device.

func NewDevice

func NewDevice(opts ...ble.Option) (*Device, error)

NewDevice returns a BLE device.

func (*Device) AddService

func (d *Device) AddService(svc *ble.Service) error

func (*Device) Advertise

func (d *Device) Advertise(ctx context.Context, adv ble.Advertisement) error

func (*Device) AdvertiseIBeacon

func (d *Device) AdvertiseIBeacon(ctx context.Context, u ble.UUID, major, minor uint16, pwr int8) error

func (*Device) AdvertiseIBeaconData

func (d *Device) AdvertiseIBeaconData(ctx context.Context, b []byte) error

func (*Device) AdvertiseMfgData

func (d *Device) AdvertiseMfgData(ctx context.Context, id uint16, b []byte) error

func (*Device) AdvertiseNameAndServices

func (d *Device) AdvertiseNameAndServices(ctx context.Context, name string, uuids ...ble.UUID) error

func (*Device) AdvertiseServiceData16

func (d *Device) AdvertiseServiceData16(ctx context.Context, id uint16, b []byte) error

func (*Device) CentralDidSubscribe

func (d *Device) CentralDidSubscribe(pmgr cbgo.PeripheralManager, cent cbgo.Central, cbchr cbgo.Characteristic)

func (*Device) CentralDidUnsubscribe

func (d *Device) CentralDidUnsubscribe(pmgr cbgo.PeripheralManager, cent cbgo.Central, chr cbgo.Characteristic)

func (*Device) CentralManagerDidUpdateState

func (d *Device) CentralManagerDidUpdateState(cmgr cbgo.CentralManager)

func (*Device) Dial

func (d *Device) Dial(ctx context.Context, a ble.Addr) (ble.Client, error)

Dial ...

func (*Device) DidAddService

func (d *Device) DidAddService(pmgr cbgo.PeripheralManager, svc cbgo.Service, err error)

func (*Device) DidConnectPeripheral

func (d *Device) DidConnectPeripheral(cmgr cbgo.CentralManager, prph cbgo.Peripheral)

func (*Device) DidDisconnectPeripheral

func (d *Device) DidDisconnectPeripheral(cmgr cbgo.CentralManager, prph cbgo.Peripheral, err error)

func (*Device) DidDiscoverPeripheral

func (d *Device) DidDiscoverPeripheral(cmgr cbgo.CentralManager, prph cbgo.Peripheral,
	advFields cbgo.AdvFields, rssi int)

func (*Device) DidReceiveReadRequest

func (d *Device) DidReceiveReadRequest(pmgr cbgo.PeripheralManager, cbreq cbgo.ATTRequest)

func (*Device) DidReceiveWriteRequests

func (d *Device) DidReceiveWriteRequests(pmgr cbgo.PeripheralManager, cbreqs []cbgo.ATTRequest)

func (*Device) DidStartAdvertising

func (d *Device) DidStartAdvertising(pmgr cbgo.PeripheralManager, err error)

func (*Device) Option

func (d *Device) Option(opts ...ble.Option) error

Option sets the options specified.

func (*Device) PeripheralManagerDidUpdateState

func (d *Device) PeripheralManagerDidUpdateState(pmgr cbgo.PeripheralManager)

func (*Device) RemoveAllServices

func (d *Device) RemoveAllServices() error

func (*Device) Scan

func (d *Device) Scan(ctx context.Context, allowDup bool, h ble.AdvHandler) error

Scan begins scanning for advertisements, calling h for every advertisement received. This function returns only when ctx expires, at which time no further advertisements should be delivered to h.

Concurrent Scan operations will result in undefined behavior.

func (*Device) SetAdvParams

func (d *Device) SetAdvParams(param cmd.LESetAdvertisingParameters) error

SetAdvParams overrides default advertising parameters.

func (*Device) SetCentralRole

func (d *Device) SetCentralRole() error

SetCentralRole configures the device to perform Central tasks.

func (*Device) SetConnParams

func (d *Device) SetConnParams(param cmd.LECreateConnection) error

SetConnParams overrides default connection parameters.

func (*Device) SetConnectedHandler

func (d *Device) SetConnectedHandler(f func(evt.LEConnectionComplete)) error

SetConnectedHandler sets handler to be called when new connection is established.

func (*Device) SetDeviceID

func (d *Device) SetDeviceID(id int) error

SetDeviceID sets HCI device ID.

func (*Device) SetDialerTimeout

func (d *Device) SetDialerTimeout(dur time.Duration) error

SetDialerTimeout sets dialing timeout for Dialer.

func (*Device) SetDisconnectedHandler

func (d *Device) SetDisconnectedHandler(f func(evt.DisconnectionComplete)) error

SetDisconnectedHandler sets handler to be called on disconnect.

func (*Device) SetListenerTimeout

func (d *Device) SetListenerTimeout(dur time.Duration) error

SetListenerTimeout sets dialing timeout for Listener.

func (*Device) SetPeripheralRole

func (d *Device) SetPeripheralRole() error

SetPeripheralRole configures the device to perform Peripheral tasks.

func (*Device) SetScanParams

func (d *Device) SetScanParams(param cmd.LESetScanParameters) error

SetScanParams overrides default scanning parameters.

func (*Device) SetServices

func (d *Device) SetServices(svcs []*ble.Service) error

func (*Device) Stop

func (d *Device) Stop() error

Stop ...

type State

type State int

State ...

const (
	StateUnknown      State = 0
	StateResetting    State = 1
	StateUnsupported  State = 2
	StateUnauthorized State = 3
	StatePoweredOff   State = 4
	StatePoweredOn    State = 5
)

State ...

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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